emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] harfbuzz 886bedb: Merge branch 'master' into harfbuzz


From: YAMAMOTO Mitsuharu
Subject: [Emacs-diffs] harfbuzz 886bedb: Merge branch 'master' into harfbuzz
Date: Sat, 27 Apr 2019 05:35:34 -0400 (EDT)

branch: harfbuzz
commit 886bedb36c7b959b7e6fc8ce8e0c04e144b0ae28
Merge: 015a6e1 8dc00b2
Author: YAMAMOTO Mitsuharu <address@hidden>
Commit: YAMAMOTO Mitsuharu <address@hidden>

    Merge branch 'master' into harfbuzz
---
 .dir-locals.el                                     |   20 +-
 .gitattributes                                     |    2 +-
 .gitignore                                         |   10 +-
 .gitlab-ci.yml                                     |   36 +-
 CONTRIBUTE                                         |   11 +-
 ChangeLog.1                                        |    2 +-
 ChangeLog.2                                        |    2 +-
 ChangeLog.3                                        | 1647 +++++-
 GNUmakefile                                        |   10 +-
 INSTALL                                            |    8 +-
 INSTALL.REPO                                       |    2 +-
 Makefile.in                                        |   15 +-
 README                                             |    2 +-
 admin/CPP-DEFINES                                  |    1 -
 admin/ChangeLog.1                                  |    2 +-
 admin/README                                       |    2 +-
 admin/admin.el                                     |   12 +-
 admin/alloc-colors.c                               |    2 +-
 admin/authors.el                                   |    2 +-
 admin/automerge                                    |    2 +-
 admin/build-configs                                |    2 +-
 admin/charsets/Makefile.in                         |    2 +-
 admin/charsets/mapconv                             |    2 +-
 admin/charsets/mapfiles/README                     |    2 +-
 admin/cus-test.el                                  |    2 +-
 admin/diff-tar-files                               |    2 +-
 admin/find-gc.el                                   |    2 +-
 admin/gitmerge.el                                  |    6 +-
 admin/grammars/Makefile.in                         |    2 +-
 admin/grammars/c.by                                |    2 +-
 admin/grammars/grammar.wy                          |    2 +-
 admin/grammars/java-tags.wy                        |    2 +-
 admin/grammars/js.wy                               |    2 +-
 admin/grammars/make.by                             |    2 +-
 admin/grammars/python.wy                           |    2 +-
 admin/grammars/scheme.by                           |    2 +-
 admin/grammars/srecode-template.wy                 |    2 +-
 admin/last-chance.el                               |    2 +-
 admin/make-emacs                                   |    2 +-
 admin/make-manuals                                 |    2 +-
 admin/merge-gnulib                                 |    6 +-
 admin/merge-pkg-config                             |    2 +-
 admin/notes/bugtracker                             |   22 +-
 admin/notes/copyright                              |    5 +-
 admin/notes/emba                                   |   64 +
 admin/notes/font-backend                           |    2 +-
 admin/notes/hydra                                  |    6 +-
 admin/notes/multi-tty                              |    2 +-
 admin/notes/unicode                                |   55 +-
 admin/notes/www                                    |    2 +-
 admin/nt/README-UNDUMP.W32                         |    2 +-
 admin/nt/README-ftp-server                         |    2 +-
 admin/nt/dist-build/build-dep-zips.py              |    2 +-
 admin/nt/dist-build/build-zips.sh                  |    2 +-
 admin/quick-install-emacs                          |    2 +-
 admin/unidata/BidiBrackets.txt                     |    4 +-
 admin/unidata/BidiMirroring.txt                    |    6 +-
 admin/unidata/Blocks.txt                           |   15 +-
 admin/unidata/Makefile.in                          |    2 +-
 admin/unidata/NormalizationTest.txt                |   33 +-
 admin/unidata/SpecialCasing.txt                    |    6 +-
 admin/unidata/UnicodeData.txt                      |  564 +-
 admin/unidata/blocks.awk                           |    7 +-
 admin/unidata/copyright.html                       |  209 +-
 admin/unidata/unidata-gen.el                       |    4 +-
 admin/unidata/uvs.el                               |    2 +-
 admin/update-copyright                             |    2 +-
 admin/update_autogen                               |    2 +-
 admin/upload-manuals                               |    2 +-
 autogen.sh                                         |    2 +-
 build-aux/config.guess                             |  200 +-
 build-aux/config.sub                               |   35 +-
 build-aux/git-hooks/commit-msg                     |    2 +-
 build-aux/git-hooks/pre-commit                     |    2 +-
 build-aux/gitlog-to-changelog                      |    2 +-
 build-aux/gitlog-to-emacslog                       |    2 +-
 build-aux/make-info-dir                            |    2 +-
 build-aux/move-if-change                           |    5 +-
 build-aux/msys-to-w32                              |    2 +-
 build-aux/update-copyright                         |    2 +-
 build-aux/update-subdirs                           |    2 +-
 config.bat                                         |    2 +-
 configure.ac                                       |  452 +-
 doc/emacs/ChangeLog.1                              |    4 +-
 doc/emacs/Makefile.in                              |    2 +-
 doc/emacs/abbrevs.texi                             |    2 +-
 doc/emacs/ack.texi                                 |    6 +-
 doc/emacs/anti.texi                                |    2 +-
 doc/emacs/arevert-xtra.texi                        |    2 +-
 doc/emacs/basic.texi                               |    2 +-
 doc/emacs/buffers.texi                             |    2 +-
 doc/emacs/building.texi                            |   16 +-
 doc/emacs/cal-xtra.texi                            |    2 +-
 doc/emacs/calendar.texi                            |    2 +-
 doc/emacs/cmdargs.texi                             |   19 +-
 doc/emacs/commands.texi                            |    2 +-
 doc/emacs/custom.texi                              |   89 +-
 doc/emacs/dired-xtra.texi                          |    2 +-
 doc/emacs/dired.texi                               |    2 +-
 doc/emacs/display.texi                             |    2 +-
 doc/emacs/emacs-xtra.texi                          |    2 +-
 doc/emacs/emacs.texi                               |    7 +-
 doc/emacs/emerge-xtra.texi                         |    2 +-
 doc/emacs/entering.texi                            |    2 +-
 doc/emacs/files.texi                               |   34 +-
 doc/emacs/fixit.texi                               |    2 +-
 doc/emacs/fortran-xtra.texi                        |    2 +-
 doc/emacs/frames.texi                              |   12 +-
 doc/emacs/glossary.texi                            |    2 +-
 doc/emacs/gnu.texi                                 |    2 +-
 doc/emacs/help.texi                                |    2 +-
 doc/emacs/indent.texi                              |    6 +-
 doc/emacs/killing.texi                             |    2 +-
 doc/emacs/kmacro.texi                              |   21 +-
 doc/emacs/m-x.texi                                 |    2 +-
 doc/emacs/macos.texi                               |   23 +-
 doc/emacs/maintaining.texi                         |   24 +-
 doc/emacs/mark.texi                                |    4 +-
 doc/emacs/mini.texi                                |    2 +-
 doc/emacs/misc.texi                                |   35 +-
 doc/emacs/modes.texi                               |    2 +-
 doc/emacs/msdos-xtra.texi                          |    2 +-
 doc/emacs/msdos.texi                               |    2 +-
 doc/emacs/mule.texi                                |    4 +-
 doc/emacs/package.texi                             |    2 +-
 doc/emacs/picture-xtra.texi                        |    2 +-
 doc/emacs/programs.texi                            |    2 +-
 doc/emacs/regs.texi                                |    2 +-
 doc/emacs/rmail.texi                               |    2 +-
 doc/emacs/screen.texi                              |    2 +-
 doc/emacs/search.texi                              |   25 +-
 doc/emacs/sending.texi                             |    2 +-
 doc/emacs/text.texi                                |    2 +-
 doc/emacs/trouble.texi                             |    9 +-
 doc/emacs/vc-xtra.texi                             |    2 +-
 doc/emacs/vc1-xtra.texi                            |    2 +-
 doc/emacs/windows.texi                             |    9 +-
 doc/emacs/xresources.texi                          |    2 +-
 doc/lispintro/ChangeLog.1                          |    2 +-
 doc/lispintro/Makefile.in                          |    2 +-
 doc/lispintro/README                               |    2 +-
 doc/lispintro/cons-1.eps                           |    2 +-
 doc/lispintro/cons-2.eps                           |    2 +-
 doc/lispintro/cons-2a.eps                          |    2 +-
 doc/lispintro/cons-3.eps                           |    2 +-
 doc/lispintro/cons-4.eps                           |    2 +-
 doc/lispintro/cons-5.eps                           |    2 +-
 doc/lispintro/drawers.eps                          |    2 +-
 doc/lispintro/emacs-lisp-intro.texi                |    8 +-
 doc/lispintro/lambda-1.eps                         |    2 +-
 doc/lispintro/lambda-2.eps                         |    2 +-
 doc/lispintro/lambda-3.eps                         |    2 +-
 doc/lispref/ChangeLog.1                            |    2 +-
 doc/lispref/Makefile.in                            |    2 +-
 doc/lispref/README                                 |    2 +-
 doc/lispref/abbrevs.texi                           |    4 +-
 doc/lispref/anti.texi                              |    2 +-
 doc/lispref/back.texi                              |    2 +-
 doc/lispref/backups.texi                           |    2 +-
 doc/lispref/buffers.texi                           |   10 +-
 doc/lispref/commands.texi                          |   13 +-
 doc/lispref/compile.texi                           |    2 +-
 doc/lispref/control.texi                           |    2 +-
 doc/lispref/customize.texi                         |   10 +-
 doc/lispref/debugging.texi                         |    2 +-
 doc/lispref/display.texi                           |  126 +-
 doc/lispref/edebug.texi                            |    2 +-
 doc/lispref/elisp.texi                             |    2 +-
 doc/lispref/errors.texi                            |    2 +-
 doc/lispref/eval.texi                              |    3 +-
 doc/lispref/files.texi                             |   58 +-
 doc/lispref/frames.texi                            |   33 +-
 doc/lispref/functions.texi                         |    9 +-
 doc/lispref/hash.texi                              |    2 +-
 doc/lispref/help.texi                              |    2 +-
 doc/lispref/hooks.texi                             |    2 +-
 doc/lispref/internals.texi                         |  344 +-
 doc/lispref/intro.texi                             |    2 +-
 doc/lispref/keymaps.texi                           |   13 +-
 doc/lispref/lay-flat.texi                          |    2 +-
 doc/lispref/lists.texi                             |   18 +-
 doc/lispref/loading.texi                           |    2 +-
 doc/lispref/macros.texi                            |    2 +-
 doc/lispref/maps.texi                              |    2 +-
 doc/lispref/markers.texi                           |    2 +-
 doc/lispref/minibuf.texi                           |   63 +-
 doc/lispref/modes.texi                             |  133 +-
 doc/lispref/nonascii.texi                          |   30 +-
 doc/lispref/numbers.texi                           |   10 +-
 doc/lispref/objects.texi                           |    2 +-
 doc/lispref/os.texi                                |   40 +-
 doc/lispref/package.texi                           |   35 +-
 doc/lispref/positions.texi                         |    2 +-
 doc/lispref/processes.texi                         |  142 +-
 doc/lispref/records.texi                           |    2 +-
 doc/lispref/searching.texi                         |  130 +-
 doc/lispref/sequences.texi                         |   11 +-
 doc/lispref/streams.texi                           |    2 +-
 doc/lispref/strings.texi                           |    2 +-
 doc/lispref/symbols.texi                           |   17 +-
 doc/lispref/syntax.texi                            |   17 +-
 doc/lispref/text.texi                              |  227 +-
 doc/lispref/threads.texi                           |    8 +-
 doc/lispref/tips.texi                              |   17 +-
 doc/lispref/two-volume-cross-refs.txt              |    2 +-
 doc/lispref/two-volume.make                        |    2 +-
 doc/lispref/variables.texi                         |   19 +-
 doc/lispref/windows.texi                           |  528 +-
 doc/man/ChangeLog.1                                |    2 +-
 doc/man/ebrowse.1                                  |    2 +-
 doc/man/emacs.1.in                                 |    6 +-
 doc/man/etags.1                                    |    2 +-
 doc/misc/ChangeLog.1                               |    2 +-
 doc/misc/Makefile.in                               |    2 +-
 doc/misc/ada-mode.texi                             |    2 +-
 doc/misc/auth.texi                                 |   13 +-
 doc/misc/autotype.texi                             |    2 +-
 doc/misc/bovine.texi                               |    2 +-
 doc/misc/calc.texi                                 |    8 +-
 doc/misc/cc-mode.texi                              |  160 +-
 doc/misc/cl.texi                                   |    8 +-
 doc/misc/dbus.texi                                 |    2 +-
 doc/misc/dired-x.texi                              |    2 +-
 doc/misc/ebrowse.texi                              |    2 +-
 doc/misc/ede.texi                                  |   18 +-
 doc/misc/ediff.texi                                |    4 +-
 doc/misc/edt.texi                                  |    2 +-
 doc/misc/efaq-w32.texi                             |    2 +-
 doc/misc/efaq.texi                                 |    2 +-
 doc/misc/eieio.texi                                |   54 +-
 doc/misc/emacs-gnutls.texi                         |   40 +-
 doc/misc/emacs-mime.texi                           |   68 +-
 doc/misc/epa.texi                                  |    2 +-
 doc/misc/erc.texi                                  |    2 +-
 doc/misc/ert.texi                                  |    2 +-
 doc/misc/eshell.texi                               |   32 +-
 doc/misc/eudc.texi                                 |    2 +-
 doc/misc/eww.texi                                  |   15 +-
 doc/misc/flymake.texi                              |    2 +-
 doc/misc/forms.texi                                |    2 +-
 doc/misc/gnus-coding.texi                          |  159 +-
 doc/misc/gnus-faq.texi                             |    4 +-
 doc/misc/gnus-news.el                              |  115 -
 doc/misc/gnus-news.texi                            |  371 --
 doc/misc/gnus-overrides.texi                       |    0
 doc/misc/gnus.texi                                 |  396 +-
 doc/misc/htmlfontify.texi                          |    2 +-
 doc/misc/idlwave.texi                              |    2 +-
 doc/misc/ido.texi                                  |    2 +-
 doc/misc/info.texi                                 |    2 +-
 doc/misc/mairix-el.texi                            |    2 +-
 doc/misc/message.texi                              |    4 +-
 doc/misc/mh-e.texi                                 |   12 +-
 doc/misc/newsticker.texi                           |    2 +-
 doc/misc/nxml-mode.texi                            |    4 +-
 doc/misc/octave-mode.texi                          |    2 +-
 doc/misc/org.texi                                  |    6 +-
 doc/misc/pcl-cvs.texi                              |    2 +-
 doc/misc/pgg.texi                                  |    4 +-
 doc/misc/rcirc.texi                                |    2 +-
 doc/misc/reftex.texi                               |    2 +-
 doc/misc/remember.texi                             |    2 +-
 doc/misc/sasl.texi                                 |    4 +-
 doc/misc/sc.texi                                   |    9 +-
 doc/misc/sem-user.texi                             |    2 +-
 doc/misc/semantic.texi                             |    2 +-
 doc/misc/ses.texi                                  |    2 +-
 doc/misc/sieve.texi                                |    4 +-
 doc/misc/smtpmail.texi                             |    2 +-
 doc/misc/speedbar.texi                             |    2 +-
 doc/misc/srecode.texi                              |    2 +-
 doc/misc/texinfo.tex                               |  470 +-
 doc/misc/todo-mode.texi                            |    2 +-
 doc/misc/tramp.texi                                |  175 +-
 doc/misc/trampver.texi                             |    4 +-
 doc/misc/url.texi                                  |    2 +-
 doc/misc/vhdl-mode.texi                            |    2 +-
 doc/misc/vip.texi                                  |    2 +-
 doc/misc/viper.texi                                |    2 +-
 doc/misc/widget.texi                               |    2 +-
 doc/misc/wisent.texi                               |    2 +-
 doc/misc/woman.texi                                |    2 +-
 etc/AUTHORS                                        |  112 +-
 etc/CALC-NEWS                                      |   13 +-
 etc/CENSORSHIP                                     |    8 -
 etc/ChangeLog.1                                    |    2 +-
 etc/DEBUG                                          |  142 +-
 etc/DISTRIB                                        |    2 +-
 etc/ERC-NEWS                                       |    2 +-
 etc/ETAGS.EBNF                                     |    2 +-
 etc/ETAGS.README                                   |    2 +-
 etc/FTP                                            |    9 -
 etc/GNU                                            |    8 -
 etc/GNUS-NEWS                                      |  316 --
 etc/HELLO                                          |   10 +-
 etc/HISTORY                                        |    2 +
 etc/LINUX-GNU                                      |    8 -
 etc/MACHINES                                       |    2 +-
 etc/MH-E-NEWS                                      |    2 +-
 etc/MORE.STUFF                                     |    8 -
 etc/NEWS                                           |  647 ++-
 etc/NEWS.1-17                                      |    6 +-
 etc/NEWS.18                                        |    2 +-
 etc/NEWS.19                                        |    2 +-
 etc/NEWS.20                                        |    2 +-
 etc/NEWS.21                                        |    2 +-
 etc/NEWS.22                                        |    2 +-
 etc/NEWS.23                                        |    2 +-
 etc/NEWS.24                                        |    2 +-
 etc/NEWS.25                                        |    2 +-
 etc/NEWS.26                                        |   63 +-
 etc/NEXTSTEP                                       |    2 +-
 etc/NXML-NEWS                                      |    2 +-
 etc/ORDERS                                         |    8 -
 etc/ORG-NEWS                                       |    2 +-
 etc/PROBLEMS                                       |    8 +-
 etc/README                                         |    2 +-
 etc/TERMS                                          |    2 +-
 etc/THE-GNU-PROJECT                                |    8 -
 etc/TODO                                           |    2 +-
 etc/WHY-FREE                                       |    8 -
 etc/charsets/README                                |    2 +-
 etc/compilation.txt                                |    2 +-
 etc/edt-user.el                                    |    2 +-
 etc/emacs-buffer.gdb                               |    2 +-
 etc/emacs.appdata.xml                              |    2 +-
 etc/enriched.txt                                   |    2 +-
 etc/forms/forms-d2.el                              |    2 +-
 etc/gnus-tut.txt                                   |    2 +-
 etc/grep.txt                                       |    2 +-
 etc/images/README                                  |    8 +-
 etc/images/checked.xpm                             |    2 +-
 etc/images/custom/README                           |    2 +-
 etc/images/ezimage/README                          |    2 +-
 etc/images/gnus/README                             |    6 +-
 etc/images/gnus/gnus.svg                           |    2 +-
 etc/images/gud/README                              |    6 +-
 etc/images/icons/README                            |    8 +-
 etc/images/icons/hicolor/scalable/apps/emacs.svg   |    2 +-
 etc/images/icons/hicolor/scalable/apps/emacs23.svg |    2 +-
 .../scalable/mimetypes/emacs-document23.svg        |    2 +-
 etc/images/mh-logo.xpm                             |    2 +-
 etc/images/mpc/README                              |    2 +-
 etc/images/newsticker/README                       |    2 +-
 etc/images/smilies/README                          |    2 +-
 etc/images/smilies/grayscale/README                |    2 +-
 etc/images/smilies/medium/README                   |    2 +-
 etc/images/splash.svg                              |    2 +-
 etc/images/tree-widget/default/README              |    2 +-
 etc/images/tree-widget/folder/README               |    2 +-
 etc/images/unchecked.xpm                           |    2 +-
 etc/org/README                                     |    2 +-
 etc/package-keyring.gpg                            |  Bin 999 -> 2069 bytes
 etc/ps-prin0.ps                                    |    2 +-
 etc/ps-prin1.ps                                    |    2 +-
 etc/refcards/Makefile                              |    2 +-
 etc/refcards/README                                |    4 +-
 etc/refcards/calccard.tex                          |    2 +-
 etc/refcards/cs-dired-ref.tex                      |    2 +-
 etc/refcards/cs-refcard.tex                        |    2 +-
 etc/refcards/cs-survival.tex                       |    2 +-
 etc/refcards/de-refcard.tex                        |    2 +-
 etc/refcards/dired-ref.tex                         |    2 +-
 etc/refcards/emacsver.tex.in                       |    2 +-
 etc/refcards/fr-dired-ref.tex                      |    2 +-
 etc/refcards/fr-refcard.tex                        |    2 +-
 etc/refcards/fr-survival.tex                       |    2 +-
 etc/refcards/gnus-logo.eps                         |    2 +-
 etc/refcards/gnus-refcard.tex                      |    2 +-
 etc/refcards/orgcard.tex                           |    2 +-
 etc/refcards/pdflayout.sty                         |    2 +-
 etc/refcards/pl-refcard.tex                        |    2 +-
 etc/refcards/pt-br-refcard.tex                     |    2 +-
 etc/refcards/refcard.tex                           |    2 +-
 etc/refcards/ru-refcard.tex                        |    4 +-
 etc/refcards/sk-dired-ref.tex                      |    2 +-
 etc/refcards/sk-refcard.tex                        |    2 +-
 etc/refcards/sk-survival.tex                       |    2 +-
 etc/refcards/survival.tex                          |    2 +-
 etc/refcards/vipcard.tex                           |    2 +-
 etc/refcards/viperCard.tex                         |    2 +-
 etc/schema/locate.rnc                              |    2 +-
 etc/schema/relaxng.rnc                             |    2 +-
 etc/schema/schemas.xml                             |    2 +-
 etc/ses-example.ses                                |    2 +-
 etc/srecode/c.srt                                  |    2 +-
 etc/srecode/cpp.srt                                |    2 +-
 etc/srecode/default.srt                            |    2 +-
 etc/srecode/doc-cpp.srt                            |    2 +-
 etc/srecode/doc-default.srt                        |    2 +-
 etc/srecode/doc-java.srt                           |    2 +-
 etc/srecode/ede-autoconf.srt                       |    2 +-
 etc/srecode/ede-make.srt                           |    2 +-
 etc/srecode/el.srt                                 |    2 +-
 etc/srecode/getset-cpp.srt                         |    2 +-
 etc/srecode/java.srt                               |    2 +-
 etc/srecode/make.srt                               |    2 +-
 etc/srecode/template.srt                           |    2 +-
 etc/srecode/test.srt                               |    2 +-
 etc/srecode/texi.srt                               |    2 +-
 etc/srecode/wisent.srt                             |    2 +-
 etc/themes/adwaita-theme.el                        |    2 +-
 etc/themes/deeper-blue-theme.el                    |    2 +-
 etc/themes/dichromacy-theme.el                     |    2 +-
 etc/themes/leuven-theme.el                         |    2 +-
 etc/themes/light-blue-theme.el                     |    2 +-
 etc/themes/manoj-dark-theme.el                     |    2 +-
 etc/themes/misterioso-theme.el                     |    2 +-
 etc/themes/tango-dark-theme.el                     |    2 +-
 etc/themes/tango-theme.el                          |    2 +-
 etc/themes/tsdh-dark-theme.el                      |    2 +-
 etc/themes/tsdh-light-theme.el                     |    2 +-
 etc/themes/wheatgrass-theme.el                     |    2 +-
 etc/themes/whiteboard-theme.el                     |    2 +-
 etc/themes/wombat-theme.el                         |    2 +-
 etc/tutorials/TUTORIAL                             |    4 +-
 etc/tutorials/TUTORIAL.bg                          |    2 +-
 etc/tutorials/TUTORIAL.cn                          |    4 +-
 etc/tutorials/TUTORIAL.cs                          |    2 +-
 etc/tutorials/TUTORIAL.de                          |    2 +-
 etc/tutorials/TUTORIAL.eo                          |    2 +-
 etc/tutorials/TUTORIAL.es                          |    2 +-
 etc/tutorials/TUTORIAL.fr                          |    2 +-
 etc/tutorials/TUTORIAL.he                          |    2 +-
 etc/tutorials/TUTORIAL.it                          |    2 +-
 etc/tutorials/TUTORIAL.ja                          |    2 +-
 etc/tutorials/TUTORIAL.ko                          |    2 +-
 etc/tutorials/TUTORIAL.nl                          |    4 +-
 etc/tutorials/TUTORIAL.pl                          |    2 +-
 etc/tutorials/TUTORIAL.pt_BR                       |    2 +-
 etc/tutorials/TUTORIAL.ro                          |    4 +-
 etc/tutorials/TUTORIAL.ru                          |    2 +-
 etc/tutorials/TUTORIAL.sk                          |    2 +-
 etc/tutorials/TUTORIAL.sl                          |    2 +-
 etc/tutorials/TUTORIAL.sv                          |    2 +-
 etc/tutorials/TUTORIAL.th                          |    2 +-
 etc/tutorials/TUTORIAL.zh                          |    2 +-
 leim/ChangeLog.1                                   |    2 +-
 leim/Makefile.in                                   |    8 +-
 leim/README                                        |    2 +-
 leim/leim-ext.el                                   |    2 +-
 lib-src/ChangeLog.1                                |    2 +-
 lib-src/Makefile.in                                |   19 +-
 lib-src/ebrowse.c                                  |   70 +-
 lib-src/emacsclient.c                              |   30 +-
 lib-src/etags.c                                    |    2 +-
 lib-src/hexl.c                                     |    2 +-
 lib-src/make-docfile.c                             |    9 +-
 lib-src/make-fingerprint.c                         |  179 +
 lib-src/movemail.c                                 |    2 +-
 lib-src/ntlib.c                                    |  102 +-
 lib-src/ntlib.h                                    |    2 +-
 lib-src/pop.c                                      |    2 +-
 lib-src/pop.h                                      |    2 +-
 lib-src/profile.c                                  |   97 -
 lib-src/rcs2log                                    |    4 +-
 lib-src/update-game-score.c                        |    2 +-
 lib/Makefile.in                                    |    4 +-
 lib/_Noreturn.h                                    |   25 +-
 lib/acl-errno-valid.c                              |    2 +-
 lib/acl-internal.c                                 |    2 +-
 lib/acl-internal.h                                 |    2 +-
 lib/acl.h                                          |    2 +-
 lib/acl_entries.c                                  |    2 +-
 lib/alloca.in.h                                    |    8 +-
 lib/allocator.h                                    |    2 +-
 lib/arg-nonnull.h                                  |    2 +-
 lib/at-func.c                                      |    2 +-
 lib/binary-io.c                                    |    2 +-
 lib/binary-io.h                                    |    2 +-
 lib/byteswap.in.h                                  |    2 +-
 lib/c++defs.h                                      |    2 +-
 lib/c-ctype.h                                      |    2 +-
 lib/c-strcase.h                                    |    2 +-
 lib/c-strcasecmp.c                                 |    2 +-
 lib/c-strncasecmp.c                                |    2 +-
 lib/careadlinkat.c                                 |    2 +-
 lib/careadlinkat.h                                 |    2 +-
 lib/cdefs.h                                        |    6 +-
 lib/cloexec.c                                      |    2 +-
 lib/cloexec.h                                      |    2 +-
 lib/close-stream.c                                 |    2 +-
 lib/count-leading-zeros.h                          |    2 +-
 lib/count-one-bits.h                               |    2 +-
 lib/count-trailing-zeros.h                         |    2 +-
 lib/diffseq.h                                      |    2 +-
 lib/dirent.in.h                                    |    2 +-
 lib/dirfd.c                                        |    2 +-
 lib/dosname.h                                      |    2 +-
 lib/dtotimespec.c                                  |    2 +-
 lib/dup2.c                                         |    2 +-
 lib/errno.in.h                                     |    2 +-
 lib/euidaccess.c                                   |    2 +-
 lib/execinfo.in.h                                  |    2 +-
 lib/explicit_bzero.c                               |    2 +-
 lib/faccessat.c                                    |    2 +-
 lib/fcntl.c                                        |    4 +-
 lib/fcntl.in.h                                     |    2 +-
 lib/fdopendir.c                                    |    2 +-
 lib/filemode.c                                     |    2 +-
 lib/filemode.h                                     |    2 +-
 lib/filevercmp.c                                   |    2 +-
 lib/filevercmp.h                                   |    2 +-
 lib/fingerprint.c                                  |   66 +
 src/mini-gmp-emacs.c => lib/fingerprint.h          |   23 +-
 lib/flexmember.h                                   |    2 +-
 lib/fpending.c                                     |    2 +-
 lib/fpending.h                                     |    2 +-
 lib/fstatat.c                                      |    8 +-
 lib/fsusage.c                                      |    2 +-
 lib/fsusage.h                                      |    2 +-
 lib/fsync.c                                        |    2 +-
 lib/ftoastr.c                                      |    8 +-
 lib/ftoastr.h                                      |    2 +-
 lib/get-permissions.c                              |    2 +-
 lib/getdtablesize.c                                |    2 +-
 lib/getgroups.c                                    |    2 +-
 lib/getloadavg.c                                   |   35 +-
 lib/getopt-cdefs.in.h                              |    2 +-
 lib/getopt-core.h                                  |    2 +-
 lib/getopt-ext.h                                   |    2 +-
 lib/getopt-pfx-core.h                              |    2 +-
 lib/getopt-pfx-ext.h                               |    2 +-
 lib/getopt.c                                       |    2 +-
 lib/getopt.in.h                                    |    2 +-
 lib/getopt1.c                                      |    2 +-
 lib/getopt_int.h                                   |    2 +-
 lib/gettext.h                                      |   15 +-
 lib/gettime.c                                      |    2 +-
 lib/gettimeofday.c                                 |    8 +-
 lib/gnulib.mk.in                                   |   42 +-
 lib/group-member.c                                 |    2 +-
 lib/ieee754.in.h                                   |    2 +-
 lib/ignore-value.h                                 |    2 +-
 lib/intprops.h                                     |    2 +-
 lib/inttypes.in.h                                  |    2 +-
 lib/libc-config.h                                  |    2 +-
 lib/limits.in.h                                    |    2 +-
 lib/localtime-buffer.c                             |    4 +-
 lib/localtime-buffer.h                             |    2 +-
 lib/lstat.c                                        |    8 +-
 lib/md5.c                                          |    2 +-
 lib/md5.h                                          |    2 +-
 lib/memmem.c                                       |   71 +
 lib/memrchr.c                                      |    2 +-
 lib/minmax.h                                       |    2 +-
 lib/mkostemp.c                                     |    2 +-
 lib/mktime-internal.h                              |    2 +-
 lib/mktime.c                                       |    4 +-
 lib/nstrftime.c                                    |   99 +-
 lib/open.c                                         |    2 +-
 lib/openat-priv.h                                  |    2 +-
 lib/openat-proc.c                                  |    2 +-
 lib/openat.h                                       |    2 +-
 lib/pipe2.c                                        |    2 +-
 lib/pselect.c                                      |    2 +-
 lib/pthread_sigmask.c                              |    2 +-
 lib/putenv.c                                       |    2 +-
 lib/qcopy-acl.c                                    |    2 +-
 lib/readlink.c                                     |    2 +-
 lib/readlinkat.c                                   |    2 +-
 lib/regcomp.c                                      |   38 +-
 lib/regex.c                                        |    6 +-
 lib/regex.h                                        |    2 +-
 lib/regex_internal.c                               |    2 +-
 lib/regex_internal.h                               |   24 +-
 lib/regexec.c                                      |   33 +-
 lib/root-uid.h                                     |    2 +-
 lib/save-cwd.c                                     |    2 +-
 lib/save-cwd.h                                     |    2 +-
 lib/set-permissions.c                              |    2 +-
 lib/sha1.c                                         |    2 +-
 lib/sha1.h                                         |    2 +-
 lib/sha256.c                                       |    2 +-
 lib/sha256.h                                       |    2 +-
 lib/sha512.c                                       |    2 +-
 lib/sha512.h                                       |    2 +-
 lib/sig2str.c                                      |    2 +-
 lib/sig2str.h                                      |    2 +-
 lib/signal.in.h                                    |    2 +-
 lib/stat-time.h                                    |    4 +-
 lib/stdalign.in.h                                  |    2 +-
 lib/stddef.in.h                                    |    2 +-
 lib/stdint.in.h                                    |    2 +-
 lib/stdio-impl.h                                   |   11 +-
 lib/stdio.in.h                                     |    9 +-
 lib/stdlib.in.h                                    |   97 +-
 lib/stpcpy.c                                       |    2 +-
 lib/str-two-way.h                                  |  452 ++
 lib/strftime.h                                     |    2 +-
 lib/string.in.h                                    |    2 +-
 lib/strtoimax.c                                    |    2 +-
 lib/strtol.c                                       |    2 +-
 lib/strtoll.c                                      |    2 +-
 lib/symlink.c                                      |    2 +-
 lib/sys_select.in.h                                |    2 +-
 lib/sys_stat.in.h                                  |   11 +-
 lib/sys_time.in.h                                  |    2 +-
 lib/sys_types.in.h                                 |    2 +-
 lib/tempname.c                                     |    2 +-
 lib/tempname.h                                     |    2 +-
 lib/time-internal.h                                |    2 +-
 lib/time.in.h                                      |    2 +-
 lib/time_r.c                                       |    2 +-
 lib/time_rz.c                                      |    2 +-
 lib/timegm.c                                       |    2 +-
 lib/timespec-add.c                                 |    2 +-
 lib/timespec-sub.c                                 |    2 +-
 lib/timespec.h                                     |    2 +-
 lib/u64.h                                          |    2 +-
 lib/unistd.in.h                                    |   15 +-
 lib/unlocked-io.h                                  |    2 +-
 lib/utimens.c                                      |   10 +-
 lib/utimens.h                                      |    2 +-
 lib/verify.h                                       |    8 +-
 lib/vla.h                                          |   28 +-
 lib/warn-on-use.h                                  |    2 +-
 lib/xalloc-oversized.h                             |    2 +-
 lisp/ChangeLog.1                                   |    2 +-
 lisp/ChangeLog.10                                  |    2 +-
 lisp/ChangeLog.11                                  |    2 +-
 lisp/ChangeLog.12                                  |    4 +-
 lisp/ChangeLog.13                                  |    2 +-
 lisp/ChangeLog.14                                  |    2 +-
 lisp/ChangeLog.15                                  |    2 +-
 lisp/ChangeLog.16                                  |    2 +-
 lisp/ChangeLog.17                                  |    2 +-
 lisp/ChangeLog.2                                   |    2 +-
 lisp/ChangeLog.3                                   |    2 +-
 lisp/ChangeLog.4                                   |    2 +-
 lisp/ChangeLog.5                                   |    2 +-
 lisp/ChangeLog.6                                   |    2 +-
 lisp/ChangeLog.7                                   |    4 +-
 lisp/ChangeLog.8                                   |    2 +-
 lisp/ChangeLog.9                                   |    2 +-
 lisp/Makefile.in                                   |   31 +-
 lisp/abbrev.el                                     |    5 +-
 lisp/align.el                                      |   12 +-
 lisp/allout-widgets.el                             |    2 +-
 lisp/allout.el                                     |   15 +-
 lisp/ansi-color.el                                 |    2 +-
 lisp/apropos.el                                    |    4 +-
 lisp/arc-mode.el                                   |   17 +-
 lisp/array.el                                      |    2 +-
 lisp/auth-source-pass.el                           |    8 +-
 lisp/auth-source.el                                |    2 +-
 lisp/autoarg.el                                    |    2 +-
 lisp/autoinsert.el                                 |    2 +-
 lisp/autorevert.el                                 |  119 +-
 lisp/avoid.el                                      |    2 +-
 lisp/battery.el                                    |  118 +-
 lisp/bindings.el                                   |    2 +-
 lisp/bookmark.el                                   |    2 +-
 lisp/bs.el                                         |    2 +-
 lisp/buff-menu.el                                  |   10 +-
 lisp/button.el                                     |   12 +-
 lisp/calc/calc-aent.el                             |    2 +-
 lisp/calc/calc-alg.el                              |    2 +-
 lisp/calc/calc-arith.el                            |    2 +-
 lisp/calc/calc-bin.el                              |    2 +-
 lisp/calc/calc-comb.el                             |    2 +-
 lisp/calc/calc-cplx.el                             |    2 +-
 lisp/calc/calc-embed.el                            |    2 +-
 lisp/calc/calc-ext.el                              |    2 +-
 lisp/calc/calc-fin.el                              |    2 +-
 lisp/calc/calc-forms.el                            |   29 +-
 lisp/calc/calc-frac.el                             |    2 +-
 lisp/calc/calc-funcs.el                            |    2 +-
 lisp/calc/calc-graph.el                            |   41 +-
 lisp/calc/calc-help.el                             |    4 +-
 lisp/calc/calc-incom.el                            |    2 +-
 lisp/calc/calc-keypd.el                            |    2 +-
 lisp/calc/calc-lang.el                             |    8 +-
 lisp/calc/calc-macs.el                             |    2 +-
 lisp/calc/calc-map.el                              |    2 +-
 lisp/calc/calc-math.el                             |    2 +-
 lisp/calc/calc-menu.el                             |    2 +-
 lisp/calc/calc-misc.el                             |    2 +-
 lisp/calc/calc-mode.el                             |    2 +-
 lisp/calc/calc-mtx.el                              |    2 +-
 lisp/calc/calc-nlfit.el                            |    2 +-
 lisp/calc/calc-poly.el                             |    2 +-
 lisp/calc/calc-prog.el                             |    2 +-
 lisp/calc/calc-rewr.el                             |    2 +-
 lisp/calc/calc-rules.el                            |    2 +-
 lisp/calc/calc-sel.el                              |    2 +-
 lisp/calc/calc-stat.el                             |    2 +-
 lisp/calc/calc-store.el                            |    6 +-
 lisp/calc/calc-stuff.el                            |    2 +-
 lisp/calc/calc-trail.el                            |    2 +-
 lisp/calc/calc-undo.el                             |    2 +-
 lisp/calc/calc-units.el                            |    2 +-
 lisp/calc/calc-vec.el                              |    2 +-
 lisp/calc/calc-yank.el                             |    2 +-
 lisp/calc/calc.el                                  |   15 +-
 lisp/calc/calcalg2.el                              |    2 +-
 lisp/calc/calcalg3.el                              |    2 +-
 lisp/calc/calccomp.el                              |    2 +-
 lisp/calc/calcsel2.el                              |    2 +-
 lisp/calculator.el                                 |    2 +-
 lisp/calendar/appt.el                              |    2 +-
 lisp/calendar/cal-bahai.el                         |    2 +-
 lisp/calendar/cal-china.el                         |    2 +-
 lisp/calendar/cal-coptic.el                        |    2 +-
 lisp/calendar/cal-dst.el                           |    8 +-
 lisp/calendar/cal-french.el                        |    2 +-
 lisp/calendar/cal-hebrew.el                        |    2 +-
 lisp/calendar/cal-html.el                          |    2 +-
 lisp/calendar/cal-islam.el                         |    2 +-
 lisp/calendar/cal-iso.el                           |    2 +-
 lisp/calendar/cal-julian.el                        |    2 +-
 lisp/calendar/cal-mayan.el                         |    2 +-
 lisp/calendar/cal-menu.el                          |    2 +-
 lisp/calendar/cal-move.el                          |    2 +-
 lisp/calendar/cal-persia.el                        |    2 +-
 lisp/calendar/cal-tex.el                           |    6 +-
 lisp/calendar/cal-x.el                             |    2 +-
 lisp/calendar/calendar.el                          |    2 +-
 lisp/calendar/diary-lib.el                         |    2 +-
 lisp/calendar/holidays.el                          |    2 +-
 lisp/calendar/icalendar.el                         |   22 +-
 lisp/calendar/lunar.el                             |    2 +-
 lisp/calendar/parse-time.el                        |   30 +-
 lisp/calendar/solar.el                             |    2 +-
 lisp/calendar/time-date.el                         |   16 +-
 lisp/calendar/timeclock.el                         |   82 +-
 lisp/calendar/todo-mode.el                         |    9 +-
 lisp/case-table.el                                 |    2 +-
 lisp/cdl.el                                        |    2 +-
 lisp/cedet/ChangeLog.1                             |    2 +-
 lisp/cedet/cedet-cscope.el                         |    2 +-
 lisp/cedet/cedet-files.el                          |    2 +-
 lisp/cedet/cedet-global.el                         |    2 +-
 lisp/cedet/cedet-idutils.el                        |    2 +-
 lisp/cedet/cedet.el                                |    2 +-
 lisp/cedet/data-debug.el                           |    8 +-
 lisp/cedet/ede.el                                  |    2 +-
 lisp/cedet/ede/auto.el                             |    2 +-
 lisp/cedet/ede/autoconf-edit.el                    |    2 +-
 lisp/cedet/ede/base.el                             |    2 +-
 lisp/cedet/ede/config.el                           |    2 +-
 lisp/cedet/ede/cpp-root.el                         |    2 +-
 lisp/cedet/ede/custom.el                           |    2 +-
 lisp/cedet/ede/detect.el                           |    4 +-
 lisp/cedet/ede/dired.el                            |    2 +-
 lisp/cedet/ede/emacs.el                            |    2 +-
 lisp/cedet/ede/files.el                            |    2 +-
 lisp/cedet/ede/generic.el                          |    2 +-
 lisp/cedet/ede/linux.el                            |    2 +-
 lisp/cedet/ede/locate.el                           |    2 +-
 lisp/cedet/ede/make.el                             |    2 +-
 lisp/cedet/ede/makefile-edit.el                    |    4 +-
 lisp/cedet/ede/pconf.el                            |    2 +-
 lisp/cedet/ede/pmake.el                            |    2 +-
 lisp/cedet/ede/proj-archive.el                     |    2 +-
 lisp/cedet/ede/proj-aux.el                         |    2 +-
 lisp/cedet/ede/proj-comp.el                        |    2 +-
 lisp/cedet/ede/proj-elisp.el                       |    2 +-
 lisp/cedet/ede/proj-info.el                        |    2 +-
 lisp/cedet/ede/proj-misc.el                        |    2 +-
 lisp/cedet/ede/proj-obj.el                         |    2 +-
 lisp/cedet/ede/proj-prog.el                        |    2 +-
 lisp/cedet/ede/proj-scheme.el                      |    2 +-
 lisp/cedet/ede/proj-shared.el                      |    2 +-
 lisp/cedet/ede/proj.el                             |    2 +-
 lisp/cedet/ede/project-am.el                       |    2 +-
 lisp/cedet/ede/shell.el                            |    2 +-
 lisp/cedet/ede/simple.el                           |    2 +-
 lisp/cedet/ede/source.el                           |    2 +-
 lisp/cedet/ede/speedbar.el                         |    4 +-
 lisp/cedet/ede/srecode.el                          |    2 +-
 lisp/cedet/ede/system.el                           |    2 +-
 lisp/cedet/ede/util.el                             |    2 +-
 lisp/cedet/inversion.el                            |    2 +-
 lisp/cedet/mode-local.el                           |    2 +-
 lisp/cedet/pulse.el                                |    2 +-
 lisp/cedet/semantic.el                             |    2 +-
 lisp/cedet/semantic/analyze.el                     |    2 +-
 lisp/cedet/semantic/analyze/complete.el            |    2 +-
 lisp/cedet/semantic/analyze/debug.el               |    2 +-
 lisp/cedet/semantic/analyze/fcn.el                 |    2 +-
 lisp/cedet/semantic/analyze/refs.el                |    2 +-
 lisp/cedet/semantic/bovine.el                      |    2 +-
 lisp/cedet/semantic/bovine/c.el                    |    2 +-
 lisp/cedet/semantic/bovine/debug.el                |    2 +-
 lisp/cedet/semantic/bovine/el.el                   |    2 +-
 lisp/cedet/semantic/bovine/gcc.el                  |    2 +-
 lisp/cedet/semantic/bovine/grammar.el              |    2 +-
 lisp/cedet/semantic/bovine/make.el                 |    2 +-
 lisp/cedet/semantic/bovine/scm.el                  |    2 +-
 lisp/cedet/semantic/chart.el                       |    2 +-
 lisp/cedet/semantic/complete.el                    |    2 +-
 lisp/cedet/semantic/ctxt.el                        |    2 +-
 lisp/cedet/semantic/db-debug.el                    |    2 +-
 lisp/cedet/semantic/db-ebrowse.el                  |    2 +-
 lisp/cedet/semantic/db-el.el                       |    2 +-
 lisp/cedet/semantic/db-file.el                     |    2 +-
 lisp/cedet/semantic/db-find.el                     |    2 +-
 lisp/cedet/semantic/db-global.el                   |    2 +-
 lisp/cedet/semantic/db-javascript.el               |    2 +-
 lisp/cedet/semantic/db-mode.el                     |    2 +-
 lisp/cedet/semantic/db-ref.el                      |    2 +-
 lisp/cedet/semantic/db-typecache.el                |    2 +-
 lisp/cedet/semantic/db.el                          |    2 +-
 lisp/cedet/semantic/debug.el                       |    2 +-
 lisp/cedet/semantic/decorate.el                    |    2 +-
 lisp/cedet/semantic/decorate/include.el            |    2 +-
 lisp/cedet/semantic/decorate/mode.el               |    2 +-
 lisp/cedet/semantic/dep.el                         |    2 +-
 lisp/cedet/semantic/doc.el                         |    5 +-
 lisp/cedet/semantic/ede-grammar.el                 |    2 +-
 lisp/cedet/semantic/edit.el                        |    2 +-
 lisp/cedet/semantic/find.el                        |    2 +-
 lisp/cedet/semantic/format.el                      |    2 +-
 lisp/cedet/semantic/fw.el                          |    2 +-
 lisp/cedet/semantic/grammar-wy.el                  |    2 +-
 lisp/cedet/semantic/grammar.el                     |    2 +-
 lisp/cedet/semantic/html.el                        |    2 +-
 lisp/cedet/semantic/ia-sb.el                       |    2 +-
 lisp/cedet/semantic/ia.el                          |    2 +-
 lisp/cedet/semantic/idle.el                        |    2 +-
 lisp/cedet/semantic/imenu.el                       |    2 +-
 lisp/cedet/semantic/java.el                        |    2 +-
 lisp/cedet/semantic/lex-spp.el                     |    2 +-
 lisp/cedet/semantic/lex.el                         |    2 +-
 lisp/cedet/semantic/mru-bookmark.el                |    2 +-
 lisp/cedet/semantic/sb.el                          |    6 +-
 lisp/cedet/semantic/scope.el                       |    2 +-
 lisp/cedet/semantic/senator.el                     |    2 +-
 lisp/cedet/semantic/sort.el                        |    2 +-
 lisp/cedet/semantic/symref.el                      |    2 +-
 lisp/cedet/semantic/symref/cscope.el               |    2 +-
 lisp/cedet/semantic/symref/filter.el               |    2 +-
 lisp/cedet/semantic/symref/global.el               |    2 +-
 lisp/cedet/semantic/symref/grep.el                 |    2 +-
 lisp/cedet/semantic/symref/idutils.el              |    2 +-
 lisp/cedet/semantic/symref/list.el                 |    2 +-
 lisp/cedet/semantic/tag-file.el                    |    2 +-
 lisp/cedet/semantic/tag-ls.el                      |    2 +-
 lisp/cedet/semantic/tag-write.el                   |    2 +-
 lisp/cedet/semantic/tag.el                         |    2 +-
 lisp/cedet/semantic/texi.el                        |    2 +-
 lisp/cedet/semantic/util-modes.el                  |    2 +-
 lisp/cedet/semantic/util.el                        |    2 +-
 lisp/cedet/semantic/wisent.el                      |    2 +-
 lisp/cedet/semantic/wisent/comp.el                 |    2 +-
 lisp/cedet/semantic/wisent/grammar.el              |    2 +-
 lisp/cedet/semantic/wisent/java-tags.el            |    2 +-
 lisp/cedet/semantic/wisent/javascript.el           |    2 +-
 lisp/cedet/semantic/wisent/python.el               |    2 +-
 lisp/cedet/semantic/wisent/wisent.el               |    2 +-
 lisp/cedet/srecode.el                              |    2 +-
 lisp/cedet/srecode/args.el                         |    2 +-
 lisp/cedet/srecode/compile.el                      |    2 +-
 lisp/cedet/srecode/cpp.el                          |    2 +-
 lisp/cedet/srecode/ctxt.el                         |    2 +-
 lisp/cedet/srecode/dictionary.el                   |    2 +-
 lisp/cedet/srecode/document.el                     |    2 +-
 lisp/cedet/srecode/el.el                           |    2 +-
 lisp/cedet/srecode/expandproto.el                  |    2 +-
 lisp/cedet/srecode/extract.el                      |    2 +-
 lisp/cedet/srecode/fields.el                       |    2 +-
 lisp/cedet/srecode/filters.el                      |    2 +-
 lisp/cedet/srecode/find.el                         |    2 +-
 lisp/cedet/srecode/getset.el                       |    2 +-
 lisp/cedet/srecode/insert.el                       |    2 +-
 lisp/cedet/srecode/java.el                         |    2 +-
 lisp/cedet/srecode/map.el                          |    2 +-
 lisp/cedet/srecode/mode.el                         |    2 +-
 lisp/cedet/srecode/semantic.el                     |    2 +-
 lisp/cedet/srecode/srt-mode.el                     |    4 +-
 lisp/cedet/srecode/srt.el                          |    2 +-
 lisp/cedet/srecode/table.el                        |    2 +-
 lisp/cedet/srecode/template.el                     |    2 +-
 lisp/cedet/srecode/texi.el                         |    2 +-
 lisp/char-fold.el                                  |    2 +-
 lisp/chistory.el                                   |    2 +-
 lisp/cmuscheme.el                                  |    2 +-
 lisp/color.el                                      |    2 +-
 lisp/comint.el                                     |   29 +-
 lisp/completion.el                                 |    9 +-
 lisp/composite.el                                  |    2 +-
 lisp/cus-dep.el                                    |    2 +-
 lisp/cus-edit.el                                   |    2 +-
 lisp/cus-face.el                                   |    2 +-
 lisp/cus-start.el                                  |   14 +-
 lisp/cus-theme.el                                  |    2 +-
 lisp/custom.el                                     |    2 +-
 lisp/dabbrev.el                                    |    2 +-
 lisp/delim-col.el                                  |    2 +-
 lisp/delsel.el                                     |    2 +-
 lisp/descr-text.el                                 |    2 +-
 lisp/desktop.el                                    |   23 +-
 lisp/dframe.el                                     |    2 +-
 lisp/dired-aux.el                                  |  156 +-
 lisp/dired-x.el                                    |    8 +-
 lisp/dired.el                                      |  143 +-
 lisp/dirtrack.el                                   |    2 +-
 lisp/disp-table.el                                 |   16 +-
 lisp/display-line-numbers.el                       |    2 +-
 lisp/dnd.el                                        |    3 +-
 lisp/doc-view.el                                   |  292 +-
 lisp/dom.el                                        |    2 +-
 lisp/dos-fns.el                                    |    2 +-
 lisp/dos-vars.el                                   |    2 +-
 lisp/dos-w32.el                                    |    2 +-
 lisp/double.el                                     |    2 +-
 lisp/dynamic-setting.el                            |    2 +-
 lisp/ebuff-menu.el                                 |    2 +-
 lisp/echistory.el                                  |    2 +-
 lisp/ecomplete.el                                  |    6 +-
 lisp/edmacro.el                                    |   14 +-
 lisp/ehelp.el                                      |    2 +-
 lisp/elec-pair.el                                  |   73 +-
 lisp/electric.el                                   |  190 +-
 lisp/elide-head.el                                 |    4 +-
 lisp/emacs-lisp/advice.el                          |    2 +-
 lisp/emacs-lisp/autoload.el                        |    4 +-
 lisp/emacs-lisp/avl-tree.el                        |    2 +-
 lisp/emacs-lisp/backquote.el                       |    2 +-
 lisp/emacs-lisp/backtrace.el                       |    2 +-
 lisp/emacs-lisp/benchmark.el                       |    4 +-
 lisp/emacs-lisp/bindat.el                          |    2 +-
 lisp/emacs-lisp/byte-opt.el                        |   10 +-
 lisp/emacs-lisp/byte-run.el                        |   19 +-
 lisp/emacs-lisp/bytecomp.el                        |   68 +-
 lisp/emacs-lisp/cconv.el                           |    4 +-
 lisp/emacs-lisp/chart.el                           |    4 +-
 lisp/emacs-lisp/check-declare.el                   |    2 +-
 lisp/emacs-lisp/checkdoc.el                        |   18 +-
 lisp/emacs-lisp/cl-extra.el                        |   16 +-
 lisp/emacs-lisp/cl-generic.el                      |    2 +-
 lisp/emacs-lisp/cl-indent.el                       |    2 +-
 lisp/emacs-lisp/cl-lib.el                          |    9 +-
 lisp/emacs-lisp/cl-macs.el                         |   17 +-
 lisp/emacs-lisp/cl-preloaded.el                    |    2 +-
 lisp/emacs-lisp/cl-print.el                        |    2 +-
 lisp/emacs-lisp/cl-seq.el                          |    9 +-
 lisp/emacs-lisp/cl.el                              |    2 +-
 lisp/emacs-lisp/copyright.el                       |    4 +-
 lisp/emacs-lisp/crm.el                             |    2 +-
 lisp/emacs-lisp/cursor-sensor.el                   |   53 +-
 lisp/emacs-lisp/debug.el                           |   56 +-
 lisp/emacs-lisp/derived.el                         |    2 +-
 lisp/emacs-lisp/disass.el                          |    2 +-
 lisp/emacs-lisp/easy-mmode.el                      |   19 +-
 lisp/emacs-lisp/easymenu.el                        |    2 +-
 lisp/emacs-lisp/edebug.el                          |    7 +-
 lisp/emacs-lisp/eieio-base.el                      |    2 +-
 lisp/emacs-lisp/eieio-compat.el                    |    2 +-
 lisp/emacs-lisp/eieio-core.el                      |    2 +-
 lisp/emacs-lisp/eieio-custom.el                    |    2 +-
 lisp/emacs-lisp/eieio-datadebug.el                 |    2 +-
 lisp/emacs-lisp/eieio-opt.el                       |    4 +-
 lisp/emacs-lisp/eieio-speedbar.el                  |    4 +-
 lisp/emacs-lisp/eieio.el                           |    2 +-
 lisp/emacs-lisp/eldoc.el                           |    2 +-
 lisp/emacs-lisp/elint.el                           |    2 +-
 lisp/emacs-lisp/elp.el                             |    2 +-
 lisp/emacs-lisp/ert-x.el                           |    2 +-
 lisp/emacs-lisp/ert.el                             |    9 +-
 lisp/emacs-lisp/ewoc.el                            |    2 +-
 lisp/emacs-lisp/faceup.el                          |    2 +-
 lisp/emacs-lisp/find-func.el                       |    2 +-
 lisp/emacs-lisp/float-sup.el                       |    2 +-
 lisp/emacs-lisp/generator.el                       |    9 +-
 lisp/emacs-lisp/generic.el                         |    2 +-
 lisp/emacs-lisp/gv.el                              |    2 +-
 lisp/emacs-lisp/helper.el                          |    2 +-
 lisp/emacs-lisp/inline.el                          |    2 +-
 lisp/emacs-lisp/let-alist.el                       |    2 +-
 lisp/emacs-lisp/lisp-mnt.el                        |    2 +-
 lisp/emacs-lisp/lisp-mode.el                       |    3 +-
 lisp/emacs-lisp/lisp.el                            |    2 +-
 lisp/emacs-lisp/macroexp.el                        |    4 +-
 lisp/emacs-lisp/map-ynp.el                         |    2 +-
 lisp/emacs-lisp/map.el                             |  360 +-
 lisp/emacs-lisp/nadvice.el                         |    9 +-
 lisp/emacs-lisp/package-x.el                       |    2 +-
 lisp/emacs-lisp/package.el                         |  146 +-
 lisp/emacs-lisp/pcase.el                           |   13 +-
 lisp/emacs-lisp/pp.el                              |    2 +-
 lisp/emacs-lisp/radix-tree.el                      |    6 +-
 lisp/emacs-lisp/re-builder.el                      |    2 +-
 lisp/emacs-lisp/regexp-opt.el                      |   57 +-
 lisp/emacs-lisp/regi.el                            |    2 +-
 lisp/emacs-lisp/ring.el                            |    2 +-
 lisp/emacs-lisp/rmc.el                             |    2 +-
 lisp/emacs-lisp/rx.el                              |  144 +-
 lisp/emacs-lisp/seq.el                             |   36 +-
 lisp/emacs-lisp/shadow.el                          |    2 +-
 lisp/emacs-lisp/smie.el                            |   38 +-
 lisp/emacs-lisp/subr-x.el                          |   31 +-
 lisp/emacs-lisp/syntax.el                          |   39 +-
 lisp/emacs-lisp/tabulated-list.el                  |   73 +-
 lisp/emacs-lisp/tcover-ses.el                      |    2 +-
 lisp/emacs-lisp/tcover-unsafep.el                  |    2 +-
 lisp/emacs-lisp/testcover.el                       |    2 +-
 lisp/emacs-lisp/text-property-search.el            |    2 +-
 lisp/emacs-lisp/thunk.el                           |    2 +-
 lisp/emacs-lisp/timer-list.el                      |   28 +-
 lisp/emacs-lisp/timer.el                           |   12 +-
 lisp/emacs-lisp/tq.el                              |    2 +-
 lisp/emacs-lisp/trace.el                           |    2 +-
 lisp/emacs-lisp/unsafep.el                         |    7 +-
 lisp/emacs-lisp/warnings.el                        |    2 +-
 lisp/emacs-lock.el                                 |    2 +-
 lisp/emulation/cua-base.el                         |   25 +-
 lisp/emulation/cua-gmrk.el                         |    2 +-
 lisp/emulation/cua-rect.el                         |    2 +-
 lisp/emulation/edt-lk201.el                        |    2 +-
 lisp/emulation/edt-mapper.el                       |    2 +-
 lisp/emulation/edt-pc.el                           |    2 +-
 lisp/emulation/edt-vt100.el                        |    2 +-
 lisp/emulation/edt.el                              |    2 +-
 lisp/emulation/keypad.el                           |    2 +-
 lisp/emulation/viper-cmd.el                        |   32 +-
 lisp/emulation/viper-ex.el                         |   22 +-
 lisp/emulation/viper-init.el                       |    3 +-
 lisp/emulation/viper-keym.el                       |    2 +-
 lisp/emulation/viper-macs.el                       |    2 +-
 lisp/emulation/viper-mous.el                       |    2 +-
 lisp/emulation/viper-util.el                       |    2 +-
 lisp/emulation/viper.el                            |    2 +-
 lisp/env.el                                        |    2 +-
 lisp/epa-dired.el                                  |    2 +-
 lisp/epa-file.el                                   |    2 +-
 lisp/epa-hook.el                                   |    2 +-
 lisp/epa-mail.el                                   |    4 +-
 lisp/epa.el                                        |    2 +-
 lisp/epg-config.el                                 |    2 +-
 lisp/epg.el                                        |    4 +-
 lisp/erc/ChangeLog.1                               |    4 +-
 lisp/erc/ChangeLog.2                               |    2 +-
 lisp/erc/erc-autoaway.el                           |    2 +-
 lisp/erc/erc-backend.el                            |   34 +-
 lisp/erc/erc-button.el                             |    2 +-
 lisp/erc/erc-capab.el                              |    2 +-
 lisp/erc/erc-compat.el                             |    2 +-
 lisp/erc/erc-dcc.el                                |   15 +-
 lisp/erc/erc-desktop-notifications.el              |   24 +-
 lisp/erc/erc-ezbounce.el                           |    2 +-
 lisp/erc/erc-fill.el                               |    2 +-
 lisp/erc/erc-goodies.el                            |    4 +-
 lisp/erc/erc-ibuffer.el                            |    2 +-
 lisp/erc/erc-identd.el                             |    2 +-
 lisp/erc/erc-imenu.el                              |    2 +-
 lisp/erc/erc-join.el                               |    2 +-
 lisp/erc/erc-lang.el                               |    2 +-
 lisp/erc/erc-list.el                               |    2 +-
 lisp/erc/erc-log.el                                |    2 +-
 lisp/erc/erc-match.el                              |    4 +-
 lisp/erc/erc-menu.el                               |    2 +-
 lisp/erc/erc-netsplit.el                           |    2 +-
 lisp/erc/erc-networks.el                           |    2 +-
 lisp/erc/erc-notify.el                             |    2 +-
 lisp/erc/erc-page.el                               |    2 +-
 lisp/erc/erc-pcomplete.el                          |    2 +-
 lisp/erc/erc-replace.el                            |    2 +-
 lisp/erc/erc-ring.el                               |    2 +-
 lisp/erc/erc-services.el                           |    2 +-
 lisp/erc/erc-sound.el                              |    2 +-
 lisp/erc/erc-speedbar.el                           |    8 +-
 lisp/erc/erc-spelling.el                           |    2 +-
 lisp/erc/erc-stamp.el                              |    2 +-
 lisp/erc/erc-track.el                              |   11 +-
 lisp/erc/erc-truncate.el                           |    2 +-
 lisp/erc/erc-xdcc.el                               |    2 +-
 lisp/erc/erc.el                                    |   55 +-
 lisp/eshell/em-alias.el                            |   10 +-
 lisp/eshell/em-banner.el                           |    4 +-
 lisp/eshell/em-basic.el                            |    4 +-
 lisp/eshell/em-cmpl.el                             |   42 +-
 lisp/eshell/em-dirs.el                             |  114 +-
 lisp/eshell/em-glob.el                             |    4 +-
 lisp/eshell/em-hist.el                             |   26 +-
 lisp/eshell/em-ls.el                               |    5 +-
 lisp/eshell/em-pred.el                             |   25 +-
 lisp/eshell/em-prompt.el                           |    4 +-
 lisp/eshell/em-rebind.el                           |    4 +-
 lisp/eshell/em-script.el                           |   12 +-
 lisp/eshell/em-smart.el                            |    4 +-
 lisp/eshell/em-term.el                             |    8 +-
 lisp/eshell/em-tramp.el                            |    8 +-
 lisp/eshell/em-unix.el                             |   32 +-
 lisp/eshell/em-xtra.el                             |    4 +-
 lisp/eshell/esh-arg.el                             |   98 +-
 lisp/eshell/esh-cmd.el                             |  100 +-
 lisp/eshell/esh-ext.el                             |   24 +-
 lisp/eshell/esh-io.el                              |    7 +-
 lisp/eshell/esh-mode.el                            |   37 +-
 lisp/eshell/esh-module.el                          |    6 +-
 lisp/eshell/esh-opt.el                             |   18 +-
 lisp/eshell/esh-proc.el                            |   72 +-
 lisp/eshell/esh-util.el                            |   34 +-
 lisp/eshell/esh-var.el                             |  133 +-
 lisp/eshell/eshell.el                              |   23 +-
 lisp/expand.el                                     |    2 +-
 lisp/ezimage.el                                    |    2 +-
 lisp/face-remap.el                                 |    2 +-
 lisp/facemenu.el                                   |    2 +-
 lisp/faces.el                                      |   22 +-
 lisp/ffap.el                                       |    2 +-
 lisp/filecache.el                                  |    2 +-
 lisp/{multifile.el => fileloop.el}                 |   76 +-
 lisp/filenotify.el                                 |   73 +-
 lisp/files-x.el                                    |   56 +-
 lisp/files.el                                      |   58 +-
 lisp/filesets.el                                   |    2 +-
 lisp/find-cmd.el                                   |    2 +-
 lisp/find-dired.el                                 |    4 +-
 lisp/find-file.el                                  |    2 +-
 lisp/find-lisp.el                                  |   13 +-
 lisp/finder.el                                     |    2 +-
 lisp/flow-ctrl.el                                  |    2 +-
 lisp/foldout.el                                    |    2 +-
 lisp/follow.el                                     |    2 +-
 lisp/font-core.el                                  |    2 +-
 lisp/font-lock.el                                  |   18 +-
 lisp/format-spec.el                                |    2 +-
 lisp/format.el                                     |    2 +-
 lisp/forms.el                                      |    2 +-
 lisp/frame.el                                      |  205 +-
 lisp/frameset.el                                   |    2 +-
 lisp/fringe.el                                     |    2 +-
 lisp/generic-x.el                                  |    7 +-
 lisp/gnus/ChangeLog.1                              |    2 +-
 lisp/gnus/ChangeLog.2                              |    2 +-
 lisp/gnus/ChangeLog.3                              |    2 +-
 lisp/gnus/canlock.el                               |    2 +-
 lisp/gnus/deuglify.el                              |    2 +-
 lisp/gnus/gmm-utils.el                             |    2 +-
 lisp/gnus/gnus-agent.el                            |  371 +-
 lisp/gnus/gnus-art.el                              |   44 +-
 lisp/gnus/gnus-async.el                            |   31 +-
 lisp/gnus/gnus-bcklg.el                            |  116 +-
 lisp/gnus/gnus-bookmark.el                         |    2 +-
 lisp/gnus/gnus-cache.el                            |   62 +-
 lisp/gnus/gnus-cite.el                             |    6 +-
 lisp/gnus/gnus-cloud.el                            |    2 +-
 lisp/gnus/gnus-cus.el                              |    2 +-
 lisp/gnus/gnus-delay.el                            |   28 +-
 lisp/gnus/gnus-demon.el                            |   12 +-
 lisp/gnus/gnus-diary.el                            |   47 +-
 lisp/gnus/gnus-dired.el                            |    2 +-
 lisp/gnus/gnus-draft.el                            |    2 +-
 lisp/gnus/gnus-dup.el                              |   58 +-
 lisp/gnus/gnus-eform.el                            |    2 +-
 lisp/gnus/gnus-fun.el                              |    2 +-
 lisp/gnus/gnus-gravatar.el                         |    2 +-
 lisp/gnus/gnus-group.el                            |  417 +-
 lisp/gnus/gnus-html.el                             |    2 +-
 lisp/gnus/gnus-icalendar.el                        |   78 +-
 lisp/gnus/gnus-int.el                              |    5 +-
 lisp/gnus/gnus-kill.el                             |    2 +-
 lisp/gnus/gnus-logic.el                            |    8 +-
 lisp/gnus/gnus-mh.el                               |    2 +-
 lisp/gnus/gnus-ml.el                               |    2 +-
 lisp/gnus/gnus-mlspl.el                            |    2 +-
 lisp/gnus/gnus-msg.el                              |    2 +-
 lisp/gnus/gnus-notifications.el                    |    2 +-
 lisp/gnus/gnus-picon.el                            |    2 +-
 lisp/gnus/gnus-range.el                            |    2 +-
 lisp/gnus/gnus-registry.el                         |    2 +-
 lisp/gnus/gnus-rfc1843.el                          |    2 +-
 lisp/gnus/gnus-salt.el                             |    2 +-
 lisp/gnus/gnus-score.el                            |   33 +-
 lisp/gnus/gnus-sieve.el                            |    2 +-
 lisp/gnus/gnus-spec.el                             |    2 +-
 lisp/gnus/gnus-srvr.el                             |    2 +-
 lisp/gnus/gnus-start.el                            |  511 +-
 lisp/gnus/gnus-sum.el                              |  482 +-
 lisp/gnus/gnus-topic.el                            |   50 +-
 lisp/gnus/gnus-undo.el                             |    2 +-
 lisp/gnus/gnus-util.el                             |   81 +-
 lisp/gnus/gnus-uu.el                               |    2 +-
 lisp/gnus/gnus-vm.el                               |    2 +-
 lisp/gnus/gnus-win.el                              |    2 +-
 lisp/gnus/gnus.el                                  |   55 +-
 lisp/gnus/gssapi.el                                |    2 +-
 lisp/gnus/legacy-gnus-agent.el                     |    2 +-
 lisp/gnus/mail-source.el                           |    8 +-
 lisp/gnus/message.el                               |   66 +-
 lisp/gnus/mm-archive.el                            |    2 +-
 lisp/gnus/mm-bodies.el                             |    4 +-
 lisp/gnus/mm-decode.el                             |   46 +-
 lisp/gnus/mm-encode.el                             |    2 +-
 lisp/gnus/mm-extern.el                             |    2 +-
 lisp/gnus/mm-partial.el                            |    2 +-
 lisp/gnus/mm-url.el                                |    2 +-
 lisp/gnus/mm-util.el                               |    2 +-
 lisp/gnus/mm-uu.el                                 |    2 +-
 lisp/gnus/mm-view.el                               |   46 +-
 lisp/gnus/mml-sec.el                               |    4 +-
 lisp/gnus/mml-smime.el                             |    2 +-
 lisp/gnus/mml.el                                   |   10 +-
 lisp/gnus/mml1991.el                               |    2 +-
 lisp/gnus/mml2015.el                               |    2 +-
 lisp/gnus/nnagent.el                               |    2 +-
 lisp/gnus/nnbabyl.el                               |    8 +-
 lisp/gnus/nndiary.el                               |   26 +-
 lisp/gnus/nndir.el                                 |    2 +-
 lisp/gnus/nndoc.el                                 |    6 +-
 lisp/gnus/nndraft.el                               |    2 +-
 lisp/gnus/nneething.el                             |    4 +-
 lisp/gnus/nnfolder.el                              |    2 +-
 lisp/gnus/nngateway.el                             |    2 +-
 lisp/gnus/nnheader.el                              |   11 +-
 lisp/gnus/nnimap.el                                |   21 +-
 lisp/gnus/nnir.el                                  |    4 +-
 lisp/gnus/nnmail.el                                |   15 +-
 lisp/gnus/nnmaildir.el                             |  295 +-
 lisp/gnus/nnmairix.el                              |    2 +-
 lisp/gnus/nnmbox.el                                |    2 +-
 lisp/gnus/nnmh.el                                  |    2 +-
 lisp/gnus/nnml.el                                  |   18 +-
 lisp/gnus/nnoo.el                                  |    2 +-
 lisp/gnus/nnregistry.el                            |    2 +-
 lisp/gnus/nnrss.el                                 |   28 +-
 lisp/gnus/nnspool.el                               |   25 +-
 lisp/gnus/nntp.el                                  |    2 +-
 lisp/gnus/nnvirtual.el                             |   18 +-
 lisp/gnus/nnweb.el                                 |   10 +-
 lisp/gnus/score-mode.el                            |    2 +-
 lisp/gnus/smiley.el                                |    2 +-
 lisp/gnus/smime.el                                 |    2 +-
 lisp/gnus/spam-report.el                           |    2 +-
 lisp/gnus/spam-stat.el                             |    2 +-
 lisp/gnus/spam-wash.el                             |    2 +-
 lisp/gnus/spam.el                                  |    2 +-
 lisp/help-at-pt.el                                 |    2 +-
 lisp/help-fns.el                                   |  429 +-
 lisp/help-macro.el                                 |    2 +-
 lisp/help-mode.el                                  |    2 +-
 lisp/help.el                                       |    7 +-
 lisp/hex-util.el                                   |    2 +-
 lisp/hexl.el                                       |    2 +-
 lisp/hfy-cmap.el                                   |    2 +-
 lisp/hi-lock.el                                    |   30 +-
 lisp/hilit-chg.el                                  |    2 +-
 lisp/hippie-exp.el                                 |    2 +-
 lisp/hl-line.el                                    |    2 +-
 lisp/htmlfontify.el                                |    2 +-
 lisp/ibuf-ext.el                                   |    9 +-
 lisp/ibuf-macs.el                                  |    2 +-
 lisp/ibuffer.el                                    |    4 +-
 lisp/icomplete.el                                  |   44 +-
 lisp/ido.el                                        |   80 +-
 lisp/ielm.el                                       |    7 +-
 lisp/iimage.el                                     |    2 +-
 lisp/image-dired.el                                |    2 +-
 lisp/image-file.el                                 |    7 +-
 lisp/image-mode.el                                 |   14 +-
 lisp/image.el                                      |   36 +-
 lisp/image/compface.el                             |    2 +-
 lisp/image/gravatar.el                             |    2 +-
 lisp/imenu.el                                      |    2 +-
 lisp/indent.el                                     |   17 +-
 lisp/info-look.el                                  |    2 +-
 lisp/info-xref.el                                  |    4 +-
 lisp/info.el                                       |   21 +-
 lisp/informat.el                                   |    2 +-
 lisp/international/ccl.el                          |    2 +-
 lisp/international/characters.el                   |   36 +-
 lisp/international/fontset.el                      |   27 +-
 lisp/international/isearch-x.el                    |    2 +-
 lisp/international/iso-ascii.el                    |    2 +-
 lisp/international/iso-cvt.el                      |    2 +-
 lisp/international/iso-transl.el                   |    2 +-
 lisp/international/ja-dic-cnv.el                   |   71 +-
 lisp/international/ja-dic-utl.el                   |   43 +-
 lisp/international/kinsoku.el                      |   38 +-
 lisp/international/kkc.el                          |    6 +-
 lisp/international/latexenc.el                     |    2 +-
 lisp/international/latin1-disp.el                  |    2 +-
 lisp/international/mule-cmds.el                    |  121 +-
 lisp/international/mule-conf.el                    |    2 +-
 lisp/international/mule-diag.el                    |    2 +-
 lisp/international/mule-util.el                    |    2 +-
 lisp/international/mule.el                         |   41 +-
 lisp/international/ogonek.el                       |    2 +-
 lisp/international/quail.el                        |   19 +-
 lisp/international/rfc1843.el                      |    2 +-
 lisp/international/titdic-cnv.el                   |  325 +-
 lisp/international/ucs-normalize.el                |    8 +-
 lisp/international/utf-7.el                        |    2 +-
 lisp/international/utf7.el                         |    2 +-
 lisp/isearch.el                                    |   57 +-
 lisp/isearchb.el                                   |    2 +-
 lisp/jit-lock.el                                   |    2 +-
 lisp/jka-cmpr-hook.el                              |    2 +-
 lisp/jka-compr.el                                  |    2 +-
 lisp/json.el                                       |   73 +-
 lisp/jsonrpc.el                                    |   16 +-
 lisp/kermit.el                                     |    2 +-
 lisp/kmacro.el                                     |   14 +-
 lisp/language/china-util.el                        |    4 +-
 lisp/language/chinese.el                           |    2 +-
 lisp/language/cyril-util.el                        |    2 +-
 lisp/language/cyrillic.el                          |    2 +-
 lisp/language/czech.el                             |    2 +-
 lisp/language/english.el                           |    2 +-
 lisp/language/ethio-util.el                        |    4 +-
 lisp/language/ethiopic.el                          |    2 +-
 lisp/language/european.el                          |    2 +-
 lisp/language/georgian.el                          |    2 +-
 lisp/language/greek.el                             |    2 +-
 lisp/language/hanja-util.el                        |    2 +-
 lisp/language/hebrew.el                            |    2 +-
 lisp/language/ind-util.el                          |    2 +-
 lisp/language/indian.el                            |    2 +-
 lisp/language/japan-util.el                        |   98 +-
 lisp/language/japanese.el                          |    6 +-
 lisp/language/korea-util.el                        |    2 +-
 lisp/language/korean.el                            |    2 +-
 lisp/language/lao-util.el                          |    2 +-
 lisp/language/lao.el                               |    2 +-
 lisp/language/romanian.el                          |    2 +-
 lisp/language/slovak.el                            |    2 +-
 lisp/language/tai-viet.el                          |    2 +-
 lisp/language/thai-util.el                         |    2 +-
 lisp/language/thai.el                              |    2 +-
 lisp/language/tibet-util.el                        |    2 +-
 lisp/language/tibetan.el                           |    2 +-
 lisp/language/utf-8-lang.el                        |    2 +-
 lisp/language/viet-util.el                         |    2 +-
 lisp/language/vietnamese.el                        |    2 +-
 lisp/ldefs-boot.el                                 | 2389 +++------
 lisp/leim/quail/arabic.el                          |    2 +-
 lisp/leim/quail/croatian.el                        |    2 +-
 lisp/leim/quail/cyril-jis.el                       |  206 +-
 lisp/leim/quail/cyrillic.el                        |    2 +-
 lisp/leim/quail/czech.el                           |    2 +-
 lisp/leim/quail/georgian.el                        |    2 +-
 lisp/leim/quail/greek.el                           |    2 +-
 lisp/leim/quail/hangul.el                          |    2 +-
 lisp/leim/quail/hanja-jis.el                       |  984 ++--
 lisp/leim/quail/hanja.el                           |    2 +-
 lisp/leim/quail/hanja3.el                          |    2 +-
 lisp/leim/quail/indian.el                          |    2 +-
 lisp/leim/quail/ipa-praat.el                       |    2 +-
 lisp/leim/quail/ipa.el                             |    2 +-
 lisp/leim/quail/japanese.el                        |  376 +-
 lisp/leim/quail/latin-alt.el                       |    2 +-
 lisp/leim/quail/latin-ltx.el                       |    2 +-
 lisp/leim/quail/latin-post.el                      |    2 +-
 lisp/leim/quail/latin-pre.el                       |   31 +-
 lisp/leim/quail/lrt.el                             |    2 +-
 lisp/leim/quail/persian.el                         |    2 +-
 lisp/leim/quail/programmer-dvorak.el               |    2 +-
 lisp/leim/quail/py-punct.el                        |   16 +-
 lisp/leim/quail/pypunct-b5.el                      |    8 +-
 lisp/leim/quail/rfc1345.el                         |    2 +-
 lisp/leim/quail/sami.el                            |  755 +++
 lisp/leim/quail/sgml-input.el                      |    2 +-
 lisp/leim/quail/sisheng.el                         |    2 +-
 lisp/leim/quail/slovak.el                          |    2 +-
 lisp/leim/quail/symbol-ksc.el                      |    2 +-
 lisp/leim/quail/tamil-dvorak.el                    |    2 +-
 lisp/leim/quail/tibetan.el                         |    2 +-
 lisp/leim/quail/uni-input.el                       |    2 +-
 lisp/leim/quail/vntelex.el                         |    2 +-
 lisp/leim/quail/vnvni.el                           |    2 +-
 lisp/leim/quail/welsh.el                           |    2 +-
 lisp/linum.el                                      |    2 +-
 lisp/loadhist.el                                   |    5 +-
 lisp/loadup.el                                     |  178 +-
 lisp/locate.el                                     |   16 +-
 lisp/lpr.el                                        |   22 +-
 lisp/ls-lisp.el                                    |   12 +-
 lisp/macros.el                                     |    2 +-
 lisp/mail/binhex.el                                |    2 +-
 lisp/mail/blessmail.el                             |    2 +-
 lisp/mail/emacsbug.el                              |    2 +-
 lisp/mail/feedmail.el                              |   10 +-
 lisp/mail/flow-fill.el                             |    2 +-
 lisp/mail/footnote.el                              |   22 +-
 lisp/mail/hashcash.el                              |   10 +-
 lisp/mail/ietf-drums.el                            |   14 +-
 lisp/mail/mail-extr.el                             |   45 +-
 lisp/mail/mail-hist.el                             |    2 +-
 lisp/mail/mail-parse.el                            |    2 +-
 lisp/mail/mail-prsvr.el                            |    2 +-
 lisp/mail/mail-utils.el                            |    6 +-
 lisp/mail/mailabbrev.el                            |    2 +-
 lisp/mail/mailalias.el                             |    2 +-
 lisp/mail/mailclient.el                            |    4 +-
 lisp/mail/mailheader.el                            |    4 +-
 lisp/mail/metamail.el                              |    2 +-
 lisp/mail/mspools.el                               |    2 +-
 lisp/mail/qp.el                                    |    2 +-
 lisp/mail/reporter.el                              |    2 +-
 lisp/mail/rfc2045.el                               |    2 +-
 lisp/mail/rfc2047.el                               |   10 +-
 lisp/mail/rfc2231.el                               |    2 +-
 lisp/mail/rfc2368.el                               |    2 +-
 lisp/mail/rfc822.el                                |    8 +-
 lisp/mail/rmail-spam-filter.el                     |    2 +-
 lisp/mail/rmail.el                                 |   58 +-
 lisp/mail/rmailedit.el                             |    2 +-
 lisp/mail/rmailkwd.el                              |    2 +-
 lisp/mail/rmailmm.el                               |    2 +-
 lisp/mail/rmailmsc.el                              |    2 +-
 lisp/mail/rmailout.el                              |    2 +-
 lisp/mail/rmailsort.el                             |    2 +-
 lisp/mail/rmailsum.el                              |    2 +-
 lisp/mail/sendmail.el                              |   11 +-
 lisp/mail/smtpmail.el                              |    9 +-
 lisp/mail/supercite.el                             |    8 +-
 lisp/mail/uce.el                                   |    2 +-
 lisp/mail/undigest.el                              |    2 +-
 lisp/mail/unrmail.el                               |    2 +-
 lisp/mail/uudecode.el                              |    2 +-
 lisp/mail/yenc.el                                  |    2 +-
 lisp/makesum.el                                    |    2 +-
 lisp/man.el                                        |   23 +-
 lisp/master.el                                     |    2 +-
 lisp/mb-depth.el                                   |    2 +-
 lisp/md4.el                                        |    2 +-
 lisp/menu-bar.el                                   |    6 +-
 lisp/mh-e/ChangeLog.1                              |    2 +-
 lisp/mh-e/ChangeLog.2                              |    2 +-
 lisp/mh-e/mh-acros.el                              |   16 +-
 lisp/mh-e/mh-alias.el                              |    8 +-
 lisp/mh-e/mh-buffers.el                            |    2 +-
 lisp/mh-e/mh-comp.el                               |    4 +-
 lisp/mh-e/mh-compat.el                             |    2 +-
 lisp/mh-e/mh-e.el                                  |   20 +-
 lisp/mh-e/mh-folder.el                             |    2 +-
 lisp/mh-e/mh-funcs.el                              |    2 +-
 lisp/mh-e/mh-gnus.el                               |    2 +-
 lisp/mh-e/mh-identity.el                           |    2 +-
 lisp/mh-e/mh-inc.el                                |    2 +-
 lisp/mh-e/mh-junk.el                               |    2 +-
 lisp/mh-e/mh-letter.el                             |    2 +-
 lisp/mh-e/mh-limit.el                              |    2 +-
 lisp/mh-e/mh-mime.el                               |    2 +-
 lisp/mh-e/mh-print.el                              |    2 +-
 lisp/mh-e/mh-scan.el                               |    2 +-
 lisp/mh-e/mh-search.el                             |   12 +-
 lisp/mh-e/mh-seq.el                                |    2 +-
 lisp/mh-e/mh-show.el                               |    2 +-
 lisp/mh-e/mh-speed.el                              |    2 +-
 lisp/mh-e/mh-thread.el                             |    2 +-
 lisp/mh-e/mh-tool-bar.el                           |    2 +-
 lisp/mh-e/mh-utils.el                              |    6 +-
 lisp/mh-e/mh-xface.el                              |    4 +-
 lisp/midnight.el                                   |    2 +-
 lisp/minibuf-eldef.el                              |    2 +-
 lisp/minibuffer.el                                 |  275 +-
 lisp/misc.el                                       |    2 +-
 lisp/misearch.el                                   |    2 +-
 lisp/mouse-copy.el                                 |    2 +-
 lisp/mouse-drag.el                                 |    2 +-
 lisp/mouse.el                                      |   10 +-
 lisp/mpc.el                                        |   13 +-
 lisp/msb.el                                        |    2 +-
 lisp/mwheel.el                                     |    2 +-
 lisp/net/ange-ftp.el                               |   11 +-
 lisp/net/browse-url.el                             |    2 +-
 lisp/net/dbus.el                                   |    2 +-
 lisp/net/dig.el                                    |    2 +-
 lisp/net/dns.el                                    |    7 +-
 lisp/net/eudc-bob.el                               |    2 +-
 lisp/net/eudc-export.el                            |    2 +-
 lisp/net/eudc-hotlist.el                           |    2 +-
 lisp/net/eudc-vars.el                              |    2 +-
 lisp/net/eudc.el                                   |    2 +-
 lisp/net/eudcb-bbdb.el                             |    2 +-
 lisp/net/eudcb-ldap.el                             |    2 +-
 lisp/net/eudcb-mab.el                              |    2 +-
 lisp/net/eww.el                                    |   38 +-
 lisp/net/gnutls.el                                 |   52 +-
 lisp/net/goto-addr.el                              |    6 +-
 lisp/net/hmac-def.el                               |    2 +-
 lisp/net/hmac-md5.el                               |    2 +-
 lisp/net/imap.el                                   |   28 +-
 lisp/net/ldap.el                                   |    7 +-
 lisp/net/mailcap.el                                |    2 +-
 lisp/net/mairix.el                                 |    2 +-
 lisp/net/net-utils.el                              |    2 +-
 lisp/net/netrc.el                                  |    2 +-
 lisp/net/network-stream.el                         |    9 +-
 lisp/net/newst-backend.el                          |   29 +-
 lisp/net/newst-plainview.el                        |    2 +-
 lisp/net/newst-reader.el                           |    2 +-
 lisp/net/newst-ticker.el                           |    2 +-
 lisp/net/newst-treeview.el                         |    2 +-
 lisp/net/newsticker.el                             |    2 +-
 lisp/net/nsm.el                                    |    2 +-
 lisp/net/ntlm.el                                   |    2 +-
 lisp/net/pop3.el                                   |   35 +-
 lisp/net/puny.el                                   |    2 +-
 lisp/net/quickurl.el                               |    2 +-
 lisp/net/rcirc.el                                  |   24 +-
 lisp/net/rfc2104.el                                |    2 +-
 lisp/net/rlogin.el                                 |    2 +-
 lisp/net/sasl-cram.el                              |    2 +-
 lisp/net/sasl-digest.el                            |    2 +-
 lisp/net/sasl-ntlm.el                              |    2 +-
 lisp/net/sasl-scram-rfc.el                         |    2 +-
 lisp/net/sasl.el                                   |    2 +-
 lisp/net/secrets.el                                |    2 +-
 lisp/net/shr-color.el                              |    2 +-
 lisp/net/shr.el                                    |   11 +-
 lisp/net/sieve-manage.el                           |    2 +-
 lisp/net/sieve-mode.el                             |    2 +-
 lisp/net/sieve.el                                  |    2 +-
 lisp/net/snmp-mode.el                              |    2 +-
 lisp/net/soap-client.el                            |    4 +-
 lisp/net/soap-inspect.el                           |    2 +-
 lisp/net/socks.el                                  |    2 +-
 lisp/net/telnet.el                                 |    2 +-
 lisp/net/tramp-adb.el                              |  535 +-
 lisp/net/tramp-archive.el                          |   81 +-
 lisp/net/tramp-cache.el                            |   52 +-
 lisp/net/tramp-cmds.el                             |   44 +-
 lisp/net/tramp-compat.el                           |   67 +-
 lisp/net/tramp-ftp.el                              |   43 +-
 lisp/net/tramp-gvfs.el                             |  110 +-
 lisp/net/tramp-integration.el                      |  199 +
 lisp/net/tramp-rclone.el                           |  104 +-
 lisp/net/tramp-sh.el                               | 1449 ++---
 lisp/net/tramp-smb.el                              |  210 +-
 lisp/net/tramp-sudoedit.el                         |  893 ++++
 lisp/net/tramp-uu.el                               |    2 +-
 lisp/net/tramp.el                                  |  732 +--
 lisp/net/trampver.el                               |    6 +-
 lisp/net/webjump.el                                |    4 +-
 lisp/net/zeroconf.el                               |    2 +-
 lisp/newcomment.el                                 |   10 +-
 lisp/notifications.el                              |    2 +-
 lisp/novice.el                                     |    2 +-
 lisp/nxml/nxml-enc.el                              |    2 +-
 lisp/nxml/nxml-maint.el                            |    6 +-
 lisp/nxml/nxml-mode.el                             |    2 +-
 lisp/nxml/nxml-ns.el                               |    2 +-
 lisp/nxml/nxml-outln.el                            |    2 +-
 lisp/nxml/nxml-parse.el                            |    2 +-
 lisp/nxml/nxml-rap.el                              |    2 +-
 lisp/nxml/nxml-util.el                             |    2 +-
 lisp/nxml/rng-cmpct.el                             |    2 +-
 lisp/nxml/rng-dt.el                                |    2 +-
 lisp/nxml/rng-loc.el                               |    2 +-
 lisp/nxml/rng-maint.el                             |    5 +-
 lisp/nxml/rng-match.el                             |    2 +-
 lisp/nxml/rng-nxml.el                              |    8 +-
 lisp/nxml/rng-parse.el                             |    2 +-
 lisp/nxml/rng-pttrn.el                             |    2 +-
 lisp/nxml/rng-uri.el                               |   11 +-
 lisp/nxml/rng-util.el                              |    2 +-
 lisp/nxml/rng-valid.el                             |    2 +-
 lisp/nxml/rng-xsd.el                               |    4 +-
 lisp/nxml/xmltok.el                                |    2 +-
 lisp/nxml/xsd-regexp.el                            |    2 +-
 lisp/obarray.el                                    |    2 +-
 lisp/obsolete/abbrevlist.el                        |    2 +-
 lisp/obsolete/assoc.el                             |    2 +-
 lisp/obsolete/bruce.el                             |    2 +-
 lisp/obsolete/cc-compat.el                         |    2 +-
 lisp/obsolete/cl-compat.el                         |    2 +-
 lisp/obsolete/complete.el                          |    2 +-
 lisp/obsolete/crisp.el                             |    2 +-
 lisp/obsolete/cust-print.el                        |    2 +-
 lisp/obsolete/erc-hecomplete.el                    |    2 +-
 lisp/obsolete/eudcb-ph.el                          |    2 +-
 lisp/obsolete/fast-lock.el                         |    2 +-
 lisp/obsolete/gs.el                                |    2 +-
 lisp/obsolete/gulp.el                              |    2 +-
 lisp/obsolete/html2text.el                         |    2 +-
 lisp/obsolete/iswitchb.el                          |    2 +-
 lisp/obsolete/landmark.el                          |   13 +-
 lisp/obsolete/lazy-lock.el                         |    2 +-
 lisp/obsolete/ledit.el                             |    2 +-
 lisp/obsolete/levents.el                           |    2 +-
 lisp/obsolete/lmenu.el                             |    2 +-
 lisp/obsolete/longlines.el                         |    2 +-
 lisp/obsolete/lucid.el                             |    2 +-
 lisp/obsolete/messcompat.el                        |    2 +-
 lisp/obsolete/mouse-sel.el                         |    2 +-
 lisp/obsolete/old-emacs-lock.el                    |    2 +-
 lisp/obsolete/old-whitespace.el                    |    2 +-
 lisp/obsolete/otodo-mode.el                        |    2 +-
 lisp/obsolete/pc-mode.el                           |    2 +-
 lisp/obsolete/pc-select.el                         |    2 +-
 lisp/obsolete/pgg-def.el                           |    2 +-
 lisp/obsolete/pgg-gpg.el                           |    2 +-
 lisp/obsolete/pgg-parse.el                         |    2 +-
 lisp/obsolete/pgg-pgp.el                           |    2 +-
 lisp/obsolete/pgg-pgp5.el                          |    2 +-
 lisp/obsolete/pgg.el                               |    4 +-
 lisp/obsolete/rcompile.el                          |    2 +-
 lisp/obsolete/s-region.el                          |    2 +-
 lisp/obsolete/sregex.el                            |    2 +-
 lisp/obsolete/starttls.el                          |    6 +-
 lisp/obsolete/sup-mouse.el                         |    2 +-
 lisp/obsolete/terminal.el                          |    2 +-
 lisp/obsolete/tls.el                               |    2 +-
 lisp/obsolete/tpu-edt.el                           |    2 +-
 lisp/obsolete/tpu-extras.el                        |    2 +-
 lisp/obsolete/tpu-mapper.el                        |    2 +-
 lisp/obsolete/vc-arch.el                           |    2 +-
 lisp/obsolete/vi.el                                |    2 +-
 lisp/obsolete/vip.el                               |   18 +-
 lisp/obsolete/ws-mode.el                           |   62 +-
 lisp/obsolete/xesam.el                             |    5 +-
 lisp/obsolete/yow.el                               |    2 +-
 lisp/org/ChangeLog.1                               |    2 +-
 lisp/org/ob-C.el                                   |    2 +-
 lisp/org/ob-J.el                                   |    2 +-
 lisp/org/ob-R.el                                   |    2 +-
 lisp/org/ob-abc.el                                 |    6 +-
 lisp/org/ob-asymptote.el                           |    2 +-
 lisp/org/ob-awk.el                                 |    2 +-
 lisp/org/ob-calc.el                                |    2 +-
 lisp/org/ob-clojure.el                             |    2 +-
 lisp/org/ob-comint.el                              |    2 +-
 lisp/org/ob-coq.el                                 |    2 +-
 lisp/org/ob-core.el                                |    4 +-
 lisp/org/ob-css.el                                 |    2 +-
 lisp/org/ob-ditaa.el                               |    2 +-
 lisp/org/ob-dot.el                                 |    2 +-
 lisp/org/ob-ebnf.el                                |    2 +-
 lisp/org/ob-emacs-lisp.el                          |    2 +-
 lisp/org/ob-eval.el                                |    2 +-
 lisp/org/ob-exp.el                                 |    2 +-
 lisp/org/ob-forth.el                               |    4 +-
 lisp/org/ob-fortran.el                             |    2 +-
 lisp/org/ob-gnuplot.el                             |    2 +-
 lisp/org/ob-groovy.el                              |    2 +-
 lisp/org/ob-haskell.el                             |    2 +-
 lisp/org/ob-hledger.el                             |    2 +-
 lisp/org/ob-io.el                                  |    2 +-
 lisp/org/ob-java.el                                |    2 +-
 lisp/org/ob-js.el                                  |    2 +-
 lisp/org/ob-keys.el                                |    2 +-
 lisp/org/ob-latex.el                               |    2 +-
 lisp/org/ob-ledger.el                              |    2 +-
 lisp/org/ob-lilypond.el                            |    2 +-
 lisp/org/ob-lisp.el                                |    2 +-
 lisp/org/ob-lob.el                                 |    2 +-
 lisp/org/ob-lua.el                                 |    2 +-
 lisp/org/ob-makefile.el                            |    2 +-
 lisp/org/ob-matlab.el                              |    2 +-
 lisp/org/ob-maxima.el                              |    2 +-
 lisp/org/ob-mscgen.el                              |    2 +-
 lisp/org/ob-ocaml.el                               |    2 +-
 lisp/org/ob-octave.el                              |    2 +-
 lisp/org/ob-org.el                                 |    2 +-
 lisp/org/ob-perl.el                                |    2 +-
 lisp/org/ob-picolisp.el                            |    2 +-
 lisp/org/ob-plantuml.el                            |    2 +-
 lisp/org/ob-processing.el                          |    2 +-
 lisp/org/ob-python.el                              |    2 +-
 lisp/org/ob-ref.el                                 |    2 +-
 lisp/org/ob-ruby.el                                |    2 +-
 lisp/org/ob-sass.el                                |    2 +-
 lisp/org/ob-scheme.el                              |    2 +-
 lisp/org/ob-screen.el                              |    2 +-
 lisp/org/ob-sed.el                                 |    2 +-
 lisp/org/ob-shell.el                               |    2 +-
 lisp/org/ob-shen.el                                |    2 +-
 lisp/org/ob-sql.el                                 |    2 +-
 lisp/org/ob-sqlite.el                              |    2 +-
 lisp/org/ob-stan.el                                |    2 +-
 lisp/org/ob-table.el                               |    2 +-
 lisp/org/ob-tangle.el                              |    2 +-
 lisp/org/ob-vala.el                                |    2 +-
 lisp/org/ob.el                                     |    2 +-
 lisp/org/org-agenda.el                             |   42 +-
 lisp/org/org-archive.el                            |    2 +-
 lisp/org/org-attach.el                             |    2 +-
 lisp/org/org-bbdb.el                               |    2 +-
 lisp/org/org-bibtex.el                             |    2 +-
 lisp/org/org-capture.el                            |   10 +-
 lisp/org/org-clock.el                              |  124 +-
 lisp/org/org-colview.el                            |   12 +-
 lisp/org/org-compat.el                             |    2 +-
 lisp/org/org-crypt.el                              |    2 +-
 lisp/org/org-ctags.el                              |    2 +-
 lisp/org/org-datetree.el                           |   11 +-
 lisp/org/org-docview.el                            |    2 +-
 lisp/org/org-duration.el                           |   11 +-
 lisp/org/org-element.el                            |   13 +-
 lisp/org/org-entities.el                           |    2 +-
 lisp/org/org-eshell.el                             |    4 +-
 lisp/org/org-eww.el                                |    2 +-
 lisp/org/org-faces.el                              |    2 +-
 lisp/org/org-feed.el                               |    2 +-
 lisp/org/org-footnote.el                           |    2 +-
 lisp/org/org-gnus.el                               |    2 +-
 lisp/org/org-habit.el                              |    7 +-
 lisp/org/org-id.el                                 |    8 +-
 lisp/org/org-indent.el                             |    6 +-
 lisp/org/org-info.el                               |    2 +-
 lisp/org/org-inlinetask.el                         |    2 +-
 lisp/org/org-irc.el                                |    2 +-
 lisp/org/org-lint.el                               |    2 +-
 lisp/org/org-list.el                               |    6 +-
 lisp/org/org-macro.el                              |    4 +-
 lisp/org/org-macs.el                               |    2 +-
 lisp/org/org-mhe.el                                |    4 +-
 lisp/org/org-mobile.el                             |    6 +-
 lisp/org/org-mouse.el                              |    4 +-
 lisp/org/org-pcomplete.el                          |    8 +-
 lisp/org/org-plot.el                               |    4 +-
 lisp/org/org-protocol.el                           |   19 +-
 lisp/org/org-rmail.el                              |    2 +-
 lisp/org/org-src.el                                |    2 +-
 lisp/org/org-table.el                              |   25 +-
 lisp/org/org-timer.el                              |   34 +-
 lisp/org/org-w3m.el                                |    2 +-
 lisp/org/org.el                                    |  145 +-
 lisp/org/ox-ascii.el                               |    6 +-
 lisp/org/ox-beamer.el                              |    2 +-
 lisp/org/ox-html.el                                |    8 +-
 lisp/org/ox-icalendar.el                           |    2 +-
 lisp/org/ox-latex.el                               |    4 +-
 lisp/org/ox-man.el                                 |    2 +-
 lisp/org/ox-md.el                                  |    2 +-
 lisp/org/ox-odt.el                                 |    2 +-
 lisp/org/ox-org.el                                 |    2 +-
 lisp/org/ox-publish.el                             |   14 +-
 lisp/org/ox-texinfo.el                             |    2 +-
 lisp/org/ox.el                                     |    6 +-
 lisp/outline.el                                    |    2 +-
 lisp/paren.el                                      |    2 +-
 lisp/password-cache.el                             |    2 +-
 lisp/pcmpl-cvs.el                                  |    2 +-
 lisp/pcmpl-gnu.el                                  |    2 +-
 lisp/pcmpl-linux.el                                |    2 +-
 lisp/pcmpl-rpm.el                                  |    2 +-
 lisp/pcmpl-unix.el                                 |    2 +-
 lisp/pcmpl-x.el                                    |    2 +-
 lisp/pcomplete.el                                  |   28 +-
 lisp/pixel-scroll.el                               |   11 +-
 lisp/play/5x5.el                                   |    2 +-
 lisp/play/animate.el                               |    2 +-
 lisp/play/blackbox.el                              |    2 +-
 lisp/play/bubbles.el                               |    2 +-
 lisp/play/cookie1.el                               |    2 +-
 lisp/play/decipher.el                              |    2 +-
 lisp/play/dissociate.el                            |    2 +-
 lisp/play/doctor.el                                |    2 +-
 lisp/play/dunnet.el                                |    2 +-
 lisp/play/fortune.el                               |    2 +-
 lisp/play/gamegrid.el                              |   40 +-
 lisp/play/gametree.el                              |    2 +-
 lisp/play/gomoku.el                                |   30 +-
 lisp/play/handwrite.el                             |    2 +-
 lisp/play/hanoi.el                                 |    2 +-
 lisp/play/life.el                                  |    2 +-
 lisp/play/morse.el                                 |    2 +-
 lisp/play/mpuz.el                                  |    2 +-
 lisp/play/pong.el                                  |    2 +-
 lisp/play/snake.el                                 |    2 +-
 lisp/play/solitaire.el                             |    2 +-
 lisp/play/spook.el                                 |    2 +-
 lisp/play/tetris.el                                |    2 +-
 lisp/play/zone.el                                  |    2 +-
 lisp/plstore.el                                    |    2 +-
 lisp/printing.el                                   | 1762 +++----
 lisp/proced.el                                     |    4 +-
 lisp/profiler.el                                   |    2 +-
 lisp/progmodes/ada-mode.el                         |    4 +-
 lisp/progmodes/ada-prj.el                          |    2 +-
 lisp/progmodes/ada-stmt.el                         |    2 +-
 lisp/progmodes/ada-xref.el                         |    7 +-
 lisp/progmodes/antlr-mode.el                       |    2 +-
 lisp/progmodes/asm-mode.el                         |    2 +-
 lisp/progmodes/autoconf.el                         |    2 +-
 lisp/progmodes/bat-mode.el                         |    4 +-
 lisp/progmodes/bug-reference.el                    |   10 +-
 lisp/progmodes/cc-align.el                         |  126 +-
 lisp/progmodes/cc-awk.el                           |   14 +-
 lisp/progmodes/cc-bytecomp.el                      |    2 +-
 lisp/progmodes/cc-cmds.el                          |  429 +-
 lisp/progmodes/cc-defs.el                          |  108 +-
 lisp/progmodes/cc-engine.el                        | 1099 +++-
 lisp/progmodes/cc-fonts.el                         | 1103 ++--
 lisp/progmodes/cc-guess.el                         |    2 +-
 lisp/progmodes/cc-langs.el                         |   63 +-
 lisp/progmodes/cc-menus.el                         |    2 +-
 lisp/progmodes/cc-mode.el                          |  393 +-
 lisp/progmodes/cc-styles.el                        |   18 +-
 lisp/progmodes/cc-vars.el                          |    8 +-
 lisp/progmodes/cfengine.el                         |    6 +-
 lisp/progmodes/cmacexp.el                          |    2 +-
 lisp/progmodes/compile.el                          |  333 +-
 lisp/progmodes/cperl-mode.el                       |   58 +-
 lisp/progmodes/cpp.el                              |    6 +-
 lisp/progmodes/cwarn.el                            |    2 +-
 lisp/progmodes/dcl-mode.el                         |    4 +-
 lisp/progmodes/ebnf-abn.el                         |    2 +-
 lisp/progmodes/ebnf-bnf.el                         |    2 +-
 lisp/progmodes/ebnf-dtd.el                         |    2 +-
 lisp/progmodes/ebnf-ebx.el                         |    2 +-
 lisp/progmodes/ebnf-iso.el                         |    2 +-
 lisp/progmodes/ebnf-otz.el                         |    2 +-
 lisp/progmodes/ebnf-yac.el                         |    4 +-
 lisp/progmodes/ebnf2ps.el                          |    2 +-
 lisp/progmodes/ebrowse.el                          |  177 +-
 lisp/progmodes/elisp-mode.el                       |    2 +-
 lisp/progmodes/etags.el                            |   42 +-
 lisp/progmodes/executable.el                       |    2 +-
 lisp/progmodes/f90.el                              |    4 +-
 lisp/progmodes/flymake-cc.el                       |   14 +-
 lisp/progmodes/flymake-proc.el                     |    8 +-
 lisp/progmodes/flymake.el                          |   72 +-
 lisp/progmodes/fortran.el                          |   15 +-
 lisp/progmodes/gdb-mi.el                           |    8 +-
 lisp/progmodes/glasses.el                          |    2 +-
 lisp/progmodes/grep.el                             |   44 +-
 lisp/progmodes/gud.el                              |    6 +-
 lisp/progmodes/hideif.el                           |   13 +-
 lisp/progmodes/hideshow.el                         |    2 +-
 lisp/progmodes/icon.el                             |    2 +-
 lisp/progmodes/idlw-complete-structtag.el          |    4 +-
 lisp/progmodes/idlw-help.el                        |    2 +-
 lisp/progmodes/idlw-shell.el                       |    2 +-
 lisp/progmodes/idlw-toolbar.el                     |    2 +-
 lisp/progmodes/idlwave.el                          |   17 +-
 lisp/progmodes/inf-lisp.el                         |    2 +-
 lisp/progmodes/js.el                               | 1223 ++++-
 lisp/progmodes/ld-script.el                        |    2 +-
 lisp/progmodes/m4-mode.el                          |    4 +-
 lisp/progmodes/make-mode.el                        |    2 +-
 lisp/progmodes/mantemp.el                          |   10 +-
 lisp/progmodes/meta-mode.el                        |    4 +-
 lisp/progmodes/mixal-mode.el                       |    4 +-
 lisp/progmodes/octave.el                           |    2 +-
 lisp/progmodes/opascal.el                          |    4 +-
 lisp/progmodes/pascal.el                           |    4 +-
 lisp/progmodes/perl-mode.el                        |    2 +-
 lisp/progmodes/prog-mode.el                        |    2 +-
 lisp/progmodes/project.el                          |  255 +-
 lisp/progmodes/prolog.el                           |    6 +-
 lisp/progmodes/ps-mode.el                          |    2 +-
 lisp/progmodes/python.el                           |   86 +-
 lisp/progmodes/ruby-mode.el                        |   55 +-
 lisp/progmodes/scheme.el                           |    4 +-
 lisp/progmodes/sh-script.el                        |    5 +-
 lisp/progmodes/simula.el                           |    2 +-
 lisp/progmodes/sql.el                              |  347 +-
 lisp/progmodes/subword.el                          |    2 +-
 lisp/progmodes/tcl.el                              |    2 +-
 lisp/progmodes/vera-mode.el                        |    2 +-
 lisp/progmodes/verilog-mode.el                     |   98 +-
 lisp/progmodes/vhdl-mode.el                        |   30 +-
 lisp/progmodes/which-func.el                       |   19 +-
 lisp/progmodes/xref.el                             |   60 +-
 lisp/progmodes/xscheme.el                          |    2 +-
 lisp/ps-bdf.el                                     |    2 +-
 lisp/ps-def.el                                     |    2 +-
 lisp/ps-mule.el                                    |    2 +-
 lisp/ps-print.el                                   |    2 +-
 lisp/ps-samp.el                                    |    6 +-
 lisp/recentf.el                                    |    2 +-
 lisp/rect.el                                       |    2 +-
 lisp/register.el                                   |    2 +-
 lisp/registry.el                                   |    2 +-
 lisp/repeat.el                                     |    2 +-
 lisp/replace.el                                    |  124 +-
 lisp/reposition.el                                 |    2 +-
 lisp/reveal.el                                     |    2 +-
 lisp/rfn-eshadow.el                                |    2 +-
 lisp/rot13.el                                      |    2 +-
 lisp/rtree.el                                      |    2 +-
 lisp/ruler-mode.el                                 |    2 +-
 lisp/savehist.el                                   |    2 +-
 lisp/saveplace.el                                  |    2 +-
 lisp/sb-image.el                                   |    2 +-
 lisp/scroll-all.el                                 |    2 +-
 lisp/scroll-bar.el                                 |    2 +-
 lisp/scroll-lock.el                                |    2 +-
 lisp/select.el                                     |    2 +-
 lisp/server.el                                     |   17 +-
 lisp/ses.el                                        |    4 +-
 lisp/shadowfile.el                                 |    2 +-
 lisp/shell.el                                      |   73 +-
 lisp/simple.el                                     |  194 +-
 lisp/skeleton.el                                   |    2 +-
 lisp/sort.el                                       |    2 +-
 lisp/soundex.el                                    |    2 +-
 lisp/speedbar.el                                   |  139 +-
 lisp/startup.el                                    |   74 +-
 lisp/strokes.el                                    |    2 +-
 lisp/subr.el                                       |  129 +-
 lisp/svg.el                                        |    2 +-
 lisp/t-mouse.el                                    |    2 +-
 lisp/tabify.el                                     |    2 +-
 lisp/talk.el                                       |    2 +-
 lisp/tar-mode.el                                   |    4 +-
 lisp/tempo.el                                      |    2 +-
 lisp/term.el                                       |  158 +-
 lisp/term/AT386.el                                 |    2 +-
 lisp/term/README                                   |    2 +-
 lisp/term/common-win.el                            |    2 +-
 lisp/term/internal.el                              |    2 +-
 lisp/term/iris-ansi.el                             |    2 +-
 lisp/term/konsole.el                               |    2 +-
 lisp/term/news.el                                  |    2 +-
 lisp/term/ns-win.el                                |   56 +-
 lisp/term/pc-win.el                                |    2 +-
 lisp/term/rxvt.el                                  |    2 +-
 lisp/term/screen.el                                |    2 +-
 lisp/term/sun.el                                   |    2 +-
 lisp/term/tmux.el                                  |    2 +-
 lisp/term/tty-colors.el                            |    2 +-
 lisp/term/tvi970.el                                |    2 +-
 lisp/term/vt100.el                                 |    2 +-
 lisp/term/w32-win.el                               |    2 +-
 lisp/term/w32console.el                            |    2 +-
 lisp/term/wyse50.el                                |    2 +-
 lisp/term/x-win.el                                 |    2 +-
 lisp/term/xterm.el                                 |   10 +-
 lisp/textmodes/artist.el                           |    4 +-
 lisp/textmodes/bib-mode.el                         |    4 +-
 lisp/textmodes/bibtex-style.el                     |    2 +-
 lisp/textmodes/bibtex.el                           |    2 +-
 lisp/textmodes/conf-mode.el                        |   10 +-
 lisp/textmodes/css-mode.el                         |    8 +-
 lisp/textmodes/dns-mode.el                         |    8 +-
 lisp/textmodes/enriched.el                         |    2 +-
 lisp/textmodes/fill.el                             |    2 +-
 lisp/textmodes/flyspell.el                         |    6 +-
 lisp/textmodes/ispell.el                           |   26 +-
 lisp/textmodes/less-css-mode.el                    |    6 +-
 lisp/textmodes/makeinfo.el                         |    2 +-
 lisp/textmodes/mhtml-mode.el                       |    6 +-
 lisp/textmodes/nroff-mode.el                       |    2 +-
 lisp/textmodes/page-ext.el                         |    2 +-
 lisp/textmodes/page.el                             |    2 +-
 lisp/textmodes/paragraphs.el                       |    2 +-
 lisp/textmodes/picture.el                          |   16 +-
 lisp/textmodes/po.el                               |    2 +-
 lisp/textmodes/refbib.el                           |    4 +-
 lisp/textmodes/refer.el                            |    2 +-
 lisp/textmodes/refill.el                           |    2 +-
 lisp/textmodes/reftex-auc.el                       |    2 +-
 lisp/textmodes/reftex-cite.el                      |    6 +-
 lisp/textmodes/reftex-dcr.el                       |    2 +-
 lisp/textmodes/reftex-global.el                    |    2 +-
 lisp/textmodes/reftex-index.el                     |    2 +-
 lisp/textmodes/reftex-parse.el                     |    4 +-
 lisp/textmodes/reftex-ref.el                       |    4 +-
 lisp/textmodes/reftex-sel.el                       |    2 +-
 lisp/textmodes/reftex-toc.el                       |    2 +-
 lisp/textmodes/reftex-vars.el                      |   53 +-
 lisp/textmodes/reftex.el                           |    2 +-
 lisp/textmodes/remember.el                         |    2 +-
 lisp/textmodes/rst.el                              |    4 +-
 lisp/textmodes/sgml-mode.el                        |   69 +-
 lisp/textmodes/table.el                            |    2 +-
 lisp/textmodes/tex-mode.el                         |    2 +-
 lisp/textmodes/texinfmt.el                         |   10 +-
 lisp/textmodes/texinfo.el                          |   35 +-
 lisp/textmodes/texnfo-upd.el                       |    4 +-
 lisp/textmodes/text-mode.el                        |   39 +-
 lisp/textmodes/tildify.el                          |    2 +-
 lisp/textmodes/two-column.el                       |    2 +-
 lisp/textmodes/underline.el                        |    2 +-
 lisp/thingatpt.el                                  |   15 +-
 lisp/thread.el                                     |    2 +-
 lisp/thumbs.el                                     |    2 +-
 lisp/time-stamp.el                                 |    2 +-
 lisp/time.el                                       |   22 +-
 lisp/timezone.el                                   |    2 +-
 lisp/tmm.el                                        |    2 +-
 lisp/tool-bar.el                                   |    2 +-
 lisp/tooltip.el                                    |    5 +-
 lisp/tree-widget.el                                |    2 +-
 lisp/tutorial.el                                   |    2 +-
 lisp/type-break.el                                 |   16 +-
 lisp/uniquify.el                                   |    2 +-
 lisp/url/ChangeLog.1                               |    2 +-
 lisp/url/url-about.el                              |    2 +-
 lisp/url/url-auth.el                               |    5 +-
 lisp/url/url-cache.el                              |    6 +-
 lisp/url/url-cid.el                                |    2 +-
 lisp/url/url-cookie.el                             |   11 +-
 lisp/url/url-dav.el                                |    4 +-
 lisp/url/url-dired.el                              |    2 +-
 lisp/url/url-domsuf.el                             |    2 +-
 lisp/url/url-expand.el                             |    2 +-
 lisp/url/url-file.el                               |    2 +-
 lisp/url/url-ftp.el                                |    2 +-
 lisp/url/url-future.el                             |    2 +-
 lisp/url/url-gw.el                                 |    2 +-
 lisp/url/url-handlers.el                           |   14 +-
 lisp/url/url-history.el                            |    2 +-
 lisp/url/url-http.el                               |   20 +-
 lisp/url/url-imap.el                               |    2 +-
 lisp/url/url-irc.el                                |    2 +-
 lisp/url/url-ldap.el                               |    2 +-
 lisp/url/url-mailto.el                             |    2 +-
 lisp/url/url-methods.el                            |    2 +-
 lisp/url/url-misc.el                               |    4 +-
 lisp/url/url-news.el                               |    2 +-
 lisp/url/url-nfs.el                                |    2 +-
 lisp/url/url-ns.el                                 |    2 +-
 lisp/url/url-parse.el                              |    4 +-
 lisp/url/url-privacy.el                            |    2 +-
 lisp/url/url-proxy.el                              |    2 +-
 lisp/url/url-queue.el                              |    6 +-
 lisp/url/url-tramp.el                              |    2 +-
 lisp/url/url-util.el                               |   11 +-
 lisp/url/url-vars.el                               |    2 +-
 lisp/url/url.el                                    |    5 +-
 lisp/userlock.el                                   |    8 +-
 lisp/vc/add-log.el                                 |    4 +-
 lisp/vc/compare-w.el                               |    2 +-
 lisp/vc/cvs-status.el                              |    2 +-
 lisp/vc/diff-mode.el                               |  395 +-
 lisp/vc/diff.el                                    |    5 +-
 lisp/vc/ediff-diff.el                              |    2 +-
 lisp/vc/ediff-help.el                              |    2 +-
 lisp/vc/ediff-hook.el                              |    2 +-
 lisp/vc/ediff-init.el                              |    2 +-
 lisp/vc/ediff-merg.el                              |    2 +-
 lisp/vc/ediff-mult.el                              |    2 +-
 lisp/vc/ediff-ptch.el                              |    6 +-
 lisp/vc/ediff-util.el                              |    8 +-
 lisp/vc/ediff-vers.el                              |    2 +-
 lisp/vc/ediff-wind.el                              |    2 +-
 lisp/vc/ediff.el                                   |    2 +-
 lisp/vc/log-edit.el                                |   24 +-
 lisp/vc/log-view.el                                |    2 +-
 lisp/vc/pcvs-defs.el                               |    2 +-
 lisp/vc/pcvs-info.el                               |    2 +-
 lisp/vc/pcvs-parse.el                              |    2 +-
 lisp/vc/pcvs-util.el                               |    2 +-
 lisp/vc/pcvs.el                                    |    2 +-
 lisp/vc/smerge-mode.el                             |   40 +-
 lisp/vc/vc-annotate.el                             |    6 +-
 lisp/vc/vc-bzr.el                                  |    4 +-
 lisp/vc/vc-cvs.el                                  |   13 +-
 lisp/vc/vc-dav.el                                  |    2 +-
 lisp/vc/vc-dir.el                                  |    2 +-
 lisp/vc/vc-dispatcher.el                           |    2 +-
 lisp/vc/vc-filewise.el                             |    2 +-
 lisp/vc/vc-git.el                                  |   65 +-
 lisp/vc/vc-hg.el                                   |   62 +-
 lisp/vc/vc-hooks.el                                |   27 +-
 lisp/vc/vc-mtn.el                                  |    2 +-
 lisp/vc/vc-rcs.el                                  |    2 +-
 lisp/vc/vc-sccs.el                                 |    2 +-
 lisp/vc/vc-src.el                                  |    2 +-
 lisp/vc/vc-svn.el                                  |    4 +-
 lisp/vc/vc.el                                      |  193 +-
 lisp/vcursor.el                                    |    2 +-
 lisp/version.el                                    |    2 +-
 lisp/view.el                                       |    2 +-
 lisp/vt-control.el                                 |    2 +-
 lisp/vt100-led.el                                  |    2 +-
 lisp/w32-fns.el                                    |    2 +-
 lisp/w32-vars.el                                   |    2 +-
 lisp/wdired.el                                     |   27 +-
 lisp/whitespace.el                                 |    2 +-
 lisp/wid-browse.el                                 |    2 +-
 lisp/wid-edit.el                                   |    9 +-
 lisp/widget.el                                     |    2 +-
 lisp/windmove.el                                   |  110 +-
 lisp/window.el                                     |  433 +-
 lisp/winner.el                                     |    2 +-
 lisp/woman.el                                      |   18 +-
 lisp/x-dnd.el                                      |    2 +-
 lisp/xdg.el                                        |    4 +-
 lisp/xml.el                                        |   11 +-
 lisp/xt-mouse.el                                   |   30 +-
 lisp/xwidget.el                                    |    2 +-
 lwlib/ChangeLog.1                                  |    2 +-
 lwlib/Makefile.in                                  |    2 +-
 lwlib/deps.mk                                      |    2 +-
 lwlib/lwlib-Xaw.c                                  |   95 +-
 lwlib/lwlib-Xlw.c                                  |    2 +-
 lwlib/lwlib-Xm.c                                   |    2 +-
 lwlib/lwlib-int.h                                  |    5 +-
 lwlib/lwlib-utils.c                                |  142 +-
 lwlib/lwlib-utils.h                                |   45 +
 lwlib/lwlib-widget.h                               |    2 +-
 lwlib/lwlib.c                                      |    2 +-
 lwlib/lwlib.h                                      |    2 +-
 lwlib/xlwmenu.c                                    |   47 +-
 lwlib/xlwmenu.h                                    |    2 +-
 lwlib/xlwmenuP.h                                   |   12 +-
 m4/00gnulib.m4                                     |    2 +-
 m4/__inline.m4                                     |    2 +-
 m4/absolute-header.m4                              |    2 +-
 m4/acl.m4                                          |    2 +-
 m4/alloca.m4                                       |   11 +-
 m4/builtin-expect.m4                               |    2 +-
 m4/byteswap.m4                                     |    2 +-
 m4/c-strtod.m4                                     |   76 -
 m4/clock_time.m4                                   |    2 +-
 m4/close-stream.m4                                 |    2 +-
 m4/count-leading-zeros.m4                          |    2 +-
 m4/count-one-bits.m4                               |    2 +-
 m4/count-trailing-zeros.m4                         |    2 +-
 m4/d-type.m4                                       |    2 +-
 m4/dirent_h.m4                                     |    2 +-
 m4/dirfd.m4                                        |    2 +-
 m4/dup2.m4                                         |    2 +-
 m4/eealloc.m4                                      |    2 +-
 m4/environ.m4                                      |    2 +-
 m4/errno_h.m4                                      |    2 +-
 m4/euidaccess.m4                                   |    2 +-
 m4/execinfo.m4                                     |    2 +-
 m4/explicit_bzero.m4                               |    2 +-
 m4/extensions.m4                                   |    2 +-
 m4/extern-inline.m4                                |    2 +-
 m4/faccessat.m4                                    |    2 +-
 m4/fcntl.m4                                        |    2 +-
 m4/fcntl_h.m4                                      |    2 +-
 m4/fdopendir.m4                                    |   14 +-
 m4/filemode.m4                                     |    2 +-
 m4/flexmember.m4                                   |    2 +-
 m4/fpending.m4                                     |    2 +-
 m4/fpieee.m4                                       |    2 +-
 m4/fstatat.m4                                      |    2 +-
 m4/fsusage.m4                                      |    2 +-
 m4/fsync.m4                                        |    2 +-
 m4/getdtablesize.m4                                |    2 +-
 m4/getgroups.m4                                    |    8 +-
 m4/getloadavg.m4                                   |    2 +-
 m4/getopt.m4                                       |    2 +-
 m4/gettime.m4                                      |    2 +-
 m4/gettimeofday.m4                                 |    6 +-
 m4/glibc21.m4                                      |    2 +-
 m4/gnulib-common.m4                                |   40 +-
 m4/gnulib-comp.m4                                  |   26 +-
 m4/group-member.m4                                 |    2 +-
 m4/ieee754-h.m4                                    |    2 +-
 m4/include_next.m4                                 |    2 +-
 m4/inttypes.m4                                     |    2 +-
 m4/largefile.m4                                    |    2 +-
 m4/limits-h.m4                                     |    2 +-
 m4/localtime-buffer.m4                             |    2 +-
 m4/longlong.m4                                     |    2 +-
 m4/lstat.m4                                        |    2 +-
 m4/manywarnings.m4                                 |    2 +-
 m4/mbstate_t.m4                                    |    2 +-
 m4/md5.m4                                          |    2 +-
 m4/memmem.m4                                       |  154 +
 m4/memrchr.m4                                      |    2 +-
 m4/minmax.m4                                       |    2 +-
 m4/mkostemp.m4                                     |    2 +-
 m4/mktime.m4                                       |    2 +-
 m4/mode_t.m4                                       |    2 +-
 m4/multiarch.m4                                    |    2 +-
 m4/nocrash.m4                                      |    2 +-
 m4/nstrftime.m4                                    |    2 +-
 m4/off_t.m4                                        |    2 +-
 m4/open-cloexec.m4                                 |    2 +-
 m4/open.m4                                         |    2 +-
 m4/pipe2.m4                                        |    2 +-
 m4/pselect.m4                                      |    2 +-
 m4/pthread_sigmask.m4                              |    2 +-
 m4/putenv.m4                                       |    6 +-
 m4/readlink.m4                                     |    2 +-
 m4/readlinkat.m4                                   |    2 +-
 m4/regex.m4                                        |   15 +-
 m4/sha1.m4                                         |    2 +-
 m4/sha256.m4                                       |    2 +-
 m4/sha512.m4                                       |    2 +-
 m4/sig2str.m4                                      |    2 +-
 m4/signal_h.m4                                     |    2 +-
 m4/socklen.m4                                      |    2 +-
 m4/ssize_t.m4                                      |    2 +-
 m4/st_dm_mode.m4                                   |    2 +-
 m4/stat-time.m4                                    |    2 +-
 m4/std-gnu11.m4                                    |    2 +-
 m4/stdalign.m4                                     |    2 +-
 m4/stddef_h.m4                                     |    2 +-
 m4/stdint.m4                                       |    2 +-
 m4/stdio_h.m4                                      |    2 +-
 m4/stdlib_h.m4                                     |   17 +-
 m4/stpcpy.m4                                       |    2 +-
 m4/string_h.m4                                     |    2 +-
 m4/strtoimax.m4                                    |    2 +-
 m4/strtoll.m4                                      |    2 +-
 m4/symlink.m4                                      |    2 +-
 m4/sys_select_h.m4                                 |    2 +-
 m4/sys_socket_h.m4                                 |    2 +-
 m4/sys_stat_h.m4                                   |    2 +-
 m4/sys_time_h.m4                                   |    2 +-
 m4/sys_types_h.m4                                  |    2 +-
 m4/tempname.m4                                     |    2 +-
 m4/time_h.m4                                       |    2 +-
 m4/time_r.m4                                       |    2 +-
 m4/time_rz.m4                                      |    2 +-
 m4/timegm.m4                                       |    2 +-
 m4/timer_time.m4                                   |    2 +-
 m4/timespec.m4                                     |    2 +-
 m4/tm_gmtoff.m4                                    |    2 +-
 m4/unistd_h.m4                                     |    2 +-
 m4/unlocked-io.m4                                  |    2 +-
 m4/utimbuf.m4                                      |   39 -
 m4/utimens.m4                                      |    2 +-
 m4/utimes.m4                                       |   12 +-
 m4/vararrays.m4                                    |    2 +-
 m4/warnings.m4                                     |    2 +-
 m4/wchar_t.m4                                      |    2 +-
 make-dist                                          |  393 +-
 modules/modhelp.py                                 |    2 +-
 msdos/ChangeLog.1                                  |    2 +-
 msdos/INSTALL                                      |    2 +-
 msdos/README                                       |    4 +-
 msdos/autogen/Makefile.in                          |    6 +-
 msdos/autogen/config.in                            |    2 +-
 msdos/depfiles.bat                                 |    2 +-
 msdos/inttypes.h                                   |    2 +-
 msdos/mainmake.v2                                  |    2 +-
 msdos/sed1v2.inp                                   |    2 +-
 msdos/sed1x.inp                                    |    2 +-
 msdos/sed2v2.inp                                   |    4 +-
 msdos/sed2x.inp                                    |    2 +-
 msdos/sed3v2.inp                                   |    2 +-
 msdos/sed4.inp                                     |    2 +-
 msdos/sed5x.inp                                    |    2 +-
 msdos/sed6.inp                                     |    2 +-
 msdos/sedadmin.inp                                 |    2 +-
 msdos/sedalloc.inp                                 |    2 +-
 msdos/sedleim.inp                                  |    2 +-
 msdos/sedlibcf.inp                                 |    2 +-
 msdos/sedlibmk.inp                                 |    2 +-
 msdos/sedlisp.inp                                  |    2 +-
 nextstep/ChangeLog.1                               |    2 +-
 nextstep/INSTALL                                   |    2 +-
 nextstep/Makefile.in                               |    9 +-
 nextstep/README                                    |    2 +-
 nextstep/templates/Info.plist.in                   |    2 +-
 nt/ChangeLog.1                                     |    2 +-
 nt/INSTALL                                         |    2 +-
 nt/INSTALL.W64                                     |    2 +-
 nt/Makefile.in                                     |    2 +-
 nt/README                                          |    2 +-
 nt/README.W32                                      |   79 +-
 nt/addpm.c                                         |    2 +-
 nt/cmdproxy.c                                      |    2 +-
 nt/configure.bat                                   |    2 +-
 nt/ddeclient.c                                     |    2 +-
 nt/emacs.rc.in                                     |    2 +-
 nt/emacsclient.rc.in                               |    2 +-
 nt/epaths.nt                                       |    2 +-
 nt/gnulib-cfg.mk                                   |    2 +-
 nt/icons/README                                    |    6 +-
 nt/inc/grp.h                                       |    2 +-
 nt/inc/inttypes.h                                  |    2 +-
 nt/inc/langinfo.h                                  |    6 +-
 nt/inc/ms-w32.h                                    |    2 +-
 nt/inc/nl_types.h                                  |    2 +-
 nt/inc/stdint.h                                    |    2 +-
 nt/inc/sys/resource.h                              |    2 +-
 nt/inc/sys/socket.h                                |    2 +-
 nt/inc/sys/stat.h                                  |    2 +-
 nt/inc/sys/wait.h                                  |    2 +-
 nt/mingw-cfg.site                                  |    1 +
 nt/preprep.c                                       |    2 +-
 nt/runemacs.c                                      |    2 +-
 oldXMenu/Activate.c                                |    2 +-
 oldXMenu/ChangeLog.1                               |    2 +-
 oldXMenu/Create.c                                  |    6 +-
 oldXMenu/FindSel.c                                 |    2 +-
 oldXMenu/Internal.c                                |    2 +-
 oldXMenu/Makefile.in                               |    2 +-
 oldXMenu/deps.mk                                   |    2 +-
 oldXMenu/insque.c                                  |    2 +-
 src/.gdbinit                                       |   26 +-
 src/ChangeLog.1                                    |    2 +-
 src/ChangeLog.10                                   |    2 +-
 src/ChangeLog.11                                   |    4 +-
 src/ChangeLog.12                                   |    2 +-
 src/ChangeLog.13                                   |    2 +-
 src/ChangeLog.2                                    |    2 +-
 src/ChangeLog.3                                    |    2 +-
 src/ChangeLog.4                                    |    4 +-
 src/ChangeLog.5                                    |    2 +-
 src/ChangeLog.6                                    |    2 +-
 src/ChangeLog.7                                    |    2 +-
 src/ChangeLog.8                                    |    2 +-
 src/ChangeLog.9                                    |    2 +-
 src/Makefile.in                                    |  148 +-
 src/README                                         |    2 +-
 src/alloc.c                                        | 1576 +++---
 src/atimer.c                                       |   27 +-
 src/atimer.h                                       |    2 +-
 src/bidi.c                                         |    6 +-
 src/bignum.c                                       |   14 +-
 src/bignum.h                                       |    2 +-
 src/blockinput.h                                   |    2 +-
 src/buffer.c                                       |  145 +-
 src/buffer.h                                       |   41 +-
 src/bytecode.c                                     |    5 +-
 src/callint.c                                      |   16 +-
 src/callproc.c                                     |   20 +-
 src/casefiddle.c                                   |    2 +-
 src/casetab.c                                      |    2 +-
 src/category.c                                     |   13 +-
 src/ccl.c                                          |    2 +-
 src/character.c                                    |    2 +-
 src/charset.c                                      |   72 +-
 src/charset.h                                      |    3 +-
 src/cm.c                                           |    2 +-
 src/cm.h                                           |    2 +-
 src/cmds.c                                         |   36 +-
 src/coding.c                                       |  294 +-
 src/coding.h                                       |   17 +-
 src/commands.h                                     |    2 +-
 src/composite.c                                    |   30 +-
 src/composite.h                                    |    2 +-
 src/conf_post.h                                    |   22 +-
 src/cygw32.c                                       |    2 +-
 src/cygw32.h                                       |    2 +-
 src/data.c                                         |  189 +-
 src/dbusbind.c                                     |    4 +-
 src/decompress.c                                   |   24 +-
 src/deps.mk                                        |    2 +-
 src/dired.c                                        |   26 +-
 src/dispextern.h                                   |  114 +-
 src/dispnew.c                                      |  112 +-
 src/disptab.h                                      |    2 +-
 src/dmpstruct.awk                                  |   45 +
 src/doc.c                                          |   24 +-
 src/doprnt.c                                       |    6 +-
 src/dosfns.c                                       |    2 +-
 src/dosfns.h                                       |    2 +-
 src/dynlib.c                                       |    8 +-
 src/dynlib.h                                       |    4 +-
 src/editfns.c                                      |  240 +-
 src/emacs-icon.h                                   |    2 +-
 src/emacs-module.c                                 |  697 ++-
 src/emacs-module.h.in                              |   34 +-
 src/emacs.c                                        |  418 +-
 src/emacsgtkfixed.c                                |    2 +-
 src/emacsgtkfixed.h                                |    2 +-
 src/epaths.in                                      |    2 +-
 src/eval.c                                         |  304 +-
 src/fileio.c                                       |  119 +-
 src/filelock.c                                     |   16 +-
 src/firstfile.c                                    |    2 +-
 src/floatfns.c                                     |   29 +-
 src/fns.c                                          |  268 +-
 src/font.c                                         |   27 +-
 src/font.h                                         |   67 +-
 src/fontset.c                                      |   23 +-
 src/fontset.h                                      |    2 +-
 src/frame.c                                        |  621 ++-
 src/frame.h                                        |  194 +-
 src/fringe.c                                       |   19 +-
 src/ftcrfont.c                                     |  177 +-
 src/ftfont.c                                       |   64 +-
 src/ftfont.h                                       |    6 +-
 src/ftxfont.c                                      |   11 +-
 src/getpagesize.h                                  |    2 +-
 src/gfilenotify.c                                  |   30 +-
 src/gmalloc.c                                      |   23 +-
 src/gnutls.c                                       |  119 +-
 src/gnutls.h                                       |    2 +-
 src/gtkutil.c                                      |  244 +-
 src/gtkutil.h                                      |    2 +-
 src/image.c                                        |  831 +--
 src/indent.c                                       |   27 +-
 src/indent.h                                       |    2 +-
 src/inotify.c                                      |    6 +-
 src/insdel.c                                       |   33 +-
 src/intervals.c                                    |   32 +-
 src/intervals.h                                    |   17 +-
 src/json.c                                         |  185 +-
 src/keyboard.c                                     |  227 +-
 src/keyboard.h                                     |    6 +-
 src/keymap.c                                       |   38 +-
 src/keymap.h                                       |    2 +-
 src/kqueue.c                                       |   12 +-
 src/lastfile.c                                     |    4 +-
 src/lcms.c                                         |    2 +-
 src/lisp.h                                         |  641 ++-
 src/lread.c                                        |  325 +-
 src/macfont.h                                      |    2 +-
 src/macfont.m                                      |   43 +-
 src/macros.c                                       |    6 +-
 src/macros.h                                       |    2 +-
 src/macuvs.h                                       |    3 +-
 src/marker.c                                       |    4 +-
 src/menu.c                                         |   42 +-
 src/menu.h                                         |    8 +-
 src/mini-gmp-emacs.c                               |    2 +-
 src/mini-gmp.c                                     |    2 +-
 src/mini-gmp.h                                     |    2 +-
 src/minibuf.c                                      |   65 +-
 src/module-env-25.h                                |    4 +-
 src/module-env-27.h                                |   18 +
 src/msdos.c                                        |    5 +-
 src/msdos.h                                        |    3 +-
 src/nsfns.m                                        |  434 +-
 src/nsfont.m                                       |   23 +-
 src/nsgui.h                                        |    5 +-
 src/nsimage.m                                      |   72 +-
 src/nsmenu.m                                       |    6 +-
 src/nsselect.m                                     |    2 +-
 src/nsterm.h                                       |   55 +-
 src/nsterm.m                                       |  387 +-
 src/pdumper.c                                      | 5518 ++++++++++++++++++++
 src/pdumper.h                                      |  254 +
 src/print.c                                        |    8 +-
 src/process.c                                      |  131 +-
 src/process.h                                      |    6 +-
 src/profiler.c                                     |  117 +-
 src/ptr-bounds.h                                   |    2 +-
 src/puresize.h                                     |    4 +-
 src/ralloc.c                                       |   14 +-
 src/regex-emacs.c                                  |  351 +-
 src/regex-emacs.h                                  |   42 +-
 src/region-cache.c                                 |    2 +-
 src/region-cache.h                                 |    2 +-
 src/scroll.c                                       |   14 +-
 src/search.c                                       |  219 +-
 src/sheap.c                                        |    3 +-
 src/sheap.h                                        |    3 +-
 src/sound.c                                        |    6 +-
 src/syntax.c                                       |   99 +-
 src/syntax.h                                       |    2 +-
 src/sysdep.c                                       |   25 +-
 src/sysselect.h                                    |    2 +-
 src/syssignal.h                                    |    4 +-
 src/sysstdio.h                                     |    2 +-
 src/systhread.c                                    |    2 +-
 src/systhread.h                                    |   10 +-
 src/systime.h                                      |    7 +-
 src/systty.h                                       |    2 +-
 src/syswait.h                                      |    2 +-
 src/term.c                                         |   38 +-
 src/termcap.c                                      |   45 +-
 src/termchar.h                                     |    2 +-
 src/termhooks.h                                    |   99 +-
 src/terminal.c                                     |    6 +-
 src/terminfo.c                                     |    2 +-
 src/termopts.h                                     |    2 +-
 src/textprop.c                                     |   98 +-
 src/thread.c                                       |  111 +-
 src/thread.h                                       |   22 +-
 src/timefns.c                                      |  109 +-
 src/tparam.c                                       |    2 +-
 src/tparam.h                                       |    2 +-
 src/undo.c                                         |   13 +-
 src/unexaix.c                                      |    2 +-
 src/unexcoff.c                                     |    6 +-
 src/unexcw.c                                       |    2 +-
 src/unexelf.c                                      |    2 +-
 src/unexmacosx.c                                   |    4 +-
 src/unexw32.c                                      |  128 +-
 src/vm-limit.c                                     |    2 +-
 src/w16select.c                                    |   18 +-
 src/w32.c                                          |   75 +-
 src/w32.h                                          |    4 +-
 src/w32common.h                                    |    2 +-
 src/w32console.c                                   |    4 +-
 src/w32cygwinx.c                                   |    5 +-
 src/w32fns.c                                       |  766 +--
 src/w32font.c                                      |   15 +-
 src/w32font.h                                      |    2 +-
 src/w32gui.h                                       |    4 +-
 src/w32heap.c                                      |   44 +-
 src/w32heap.h                                      |    5 +-
 src/w32inevt.c                                     |    4 +-
 src/w32inevt.h                                     |    2 +-
 src/w32menu.c                                      |    8 +-
 src/w32notify.c                                    |    2 +-
 src/w32proc.c                                      |  221 +-
 src/w32reg.c                                       |   18 +-
 src/w32select.c                                    |    4 +-
 src/w32select.h                                    |    2 +-
 src/w32term.c                                      |  843 +--
 src/w32term.h                                      |   56 +-
 src/w32uniscribe.c                                 |   17 +-
 src/w32xfns.c                                      |    2 +-
 src/widget.c                                       |   30 +-
 src/widget.h                                       |    2 +-
 src/widgetprv.h                                    |    2 +-
 src/window.c                                       | 1219 +++--
 src/window.h                                       |  185 +-
 src/xdisp.c                                        |  622 +--
 src/xfaces.c                                       |  178 +-
 src/xfns.c                                         |  549 +-
 src/xfont.c                                        |   12 +-
 src/xftfont.c                                      |   11 +-
 src/xgselect.c                                     |    2 +-
 src/xgselect.h                                     |    2 +-
 src/xmenu.c                                        |   26 +-
 src/xml.c                                          |    2 +-
 src/xrdb.c                                         |   23 +-
 src/xselect.c                                      |   44 +-
 src/xsettings.c                                    |   70 +-
 src/xsettings.h                                    |    2 +-
 src/xsmfns.c                                       |    2 +-
 src/xterm.c                                        |  562 +-
 src/xterm.h                                        |   64 +-
 src/xwidget.c                                      |   10 +-
 src/xwidget.h                                      |    8 +-
 test/ChangeLog.1                                   |    2 +-
 test/Makefile.in                                   |   22 +-
 test/README                                        |   12 +-
 test/data/decompress/tg.tar.gz                     |  Bin 0 -> 150 bytes
 test/data/decompress/zg.zip                        |  Bin 0 -> 182 bytes
 test/data/emacs-module/mod-test.c                  |  131 +-
 test/data/shr/ol.html                              |   29 +
 test/data/shr/ol.txt                               |   19 +
 test/data/vc/diff-mode/hello_emacs.c               |    6 +
 test/data/vc/diff-mode/hello_emacs_1.c             |    1 +
 test/data/vc/diff-mode/hello_world.c               |    6 +
 test/data/vc/diff-mode/hello_world_1.c             |    1 +
 test/lib-src/emacsclient-tests.el                  |    2 +-
 test/lisp/abbrev-tests.el                          |    2 +-
 test/lisp/arc-mode-tests.el                        |   16 +-
 test/lisp/auth-source-pass-tests.el                |    2 +-
 test/lisp/auth-source-tests.el                     |    2 +-
 test/lisp/autorevert-tests.el                      |    2 +-
 test/lisp/buff-menu-tests.el                       |    2 +-
 test/lisp/button-tests.el                          |   40 +
 test/lisp/calc/calc-tests.el                       |    2 +-
 test/lisp/calendar/icalendar-tests.el              |    2 +-
 test/lisp/calendar/parse-time-tests.el             |    2 +-
 test/lisp/calendar/todo-mode-tests.el              |    2 +-
 test/lisp/char-fold-tests.el                       |    2 +-
 test/lisp/color-tests.el                           |    2 +-
 test/lisp/comint-tests.el                          |    2 +-
 test/lisp/custom-resources/custom--test-theme.el   |    9 +
 test/lisp/custom-tests.el                          |   41 +-
 test/lisp/dabbrev-tests.el                         |    2 +-
 test/lisp/descr-text-tests.el                      |    2 +-
 test/lisp/dired-aux-tests.el                       |    2 +-
 test/lisp/dired-tests.el                           |    2 +-
 test/lisp/dired-x-tests.el                         |    2 +-
 test/lisp/dom-tests.el                             |    2 +-
 test/lisp/electric-tests.el                        |  152 +-
 test/lisp/emacs-lisp/backtrace-tests.el            |    2 +-
 test/lisp/emacs-lisp/benchmark-tests.el            |    2 +-
 test/lisp/emacs-lisp/bytecomp-tests.el             |    6 +-
 test/lisp/emacs-lisp/cconv-tests.el                |    2 +-
 test/lisp/emacs-lisp/checkdoc-tests.el             |    2 +-
 test/lisp/emacs-lisp/cl-extra-tests.el             |    7 +-
 test/lisp/emacs-lisp/cl-generic-tests.el           |    2 +-
 test/lisp/emacs-lisp/cl-lib-tests.el               |    2 +-
 test/lisp/emacs-lisp/cl-macs-tests.el              |    2 +-
 test/lisp/emacs-lisp/cl-preloaded-tests.el         |    2 +-
 test/lisp/emacs-lisp/cl-print-tests.el             |    4 +-
 test/lisp/emacs-lisp/cl-seq-tests.el               |    2 +-
 test/lisp/emacs-lisp/cl-tests.el                   |    2 +-
 test/lisp/emacs-lisp/derived-tests.el              |    2 +-
 .../edebug-resources/edebug-test-code.el           |    2 +-
 test/lisp/emacs-lisp/edebug-tests.el               |    2 +-
 .../eieio-tests/eieio-test-methodinvoke.el         |    2 +-
 .../emacs-lisp/eieio-tests/eieio-test-persist.el   |    2 +-
 test/lisp/emacs-lisp/eieio-tests/eieio-tests.el    |    2 +-
 test/lisp/emacs-lisp/ert-tests.el                  |    2 +-
 test/lisp/emacs-lisp/ert-x-tests.el                |    2 +-
 .../faceup-resources/faceup-test-mode.el           |    2 +-
 .../faceup-test-this-file-directory.el             |    2 +-
 .../emacs-lisp/faceup-tests/faceup-test-basics.el  |    2 +-
 .../emacs-lisp/faceup-tests/faceup-test-files.el   |    2 +-
 test/lisp/emacs-lisp/generator-tests.el            |    2 +-
 test/lisp/emacs-lisp/gv-tests.el                   |    2 +-
 test/lisp/emacs-lisp/let-alist-tests.el            |    2 +-
 test/lisp/emacs-lisp/lisp-mode-tests.el            |    2 +-
 test/lisp/emacs-lisp/lisp-tests.el                 |    2 +-
 test/lisp/emacs-lisp/map-tests.el                  |   27 +-
 test/lisp/emacs-lisp/nadvice-tests.el              |    2 +-
 test/lisp/emacs-lisp/package-tests.el              |   87 +-
 test/lisp/emacs-lisp/pcase-tests.el                |    6 +-
 test/lisp/emacs-lisp/pp-tests.el                   |    2 +-
 test/lisp/emacs-lisp/regexp-opt-tests.el           |    2 +-
 test/lisp/emacs-lisp/ring-tests.el                 |    2 +-
 test/lisp/emacs-lisp/rmc-tests.el                  |    2 +-
 test/lisp/emacs-lisp/rx-tests.el                   |   70 +-
 test/lisp/emacs-lisp/seq-tests.el                  |   39 +-
 test/lisp/emacs-lisp/shadow-tests.el               |    2 +-
 test/lisp/emacs-lisp/subr-x-tests.el               |    2 +-
 test/lisp/emacs-lisp/tabulated-list-test.el        |    2 +-
 .../emacs-lisp/testcover-resources/testcases.el    |    2 +-
 test/lisp/emacs-lisp/testcover-tests.el            |    2 +-
 test/lisp/emacs-lisp/text-property-search-tests.el |    2 +-
 test/lisp/emacs-lisp/thunk-tests.el                |    2 +-
 test/lisp/emacs-lisp/timer-tests.el                |    2 +-
 test/lisp/emulation/viper-tests.el                 |    2 +-
 test/lisp/epg-tests.el                             |    6 +-
 test/lisp/erc/erc-track-tests.el                   |    2 +-
 test/lisp/eshell/em-hist-tests.el                  |    2 +-
 test/lisp/eshell/em-ls-tests.el                    |   16 +-
 test/lisp/eshell/esh-opt-tests.el                  |    2 +-
 test/lisp/eshell/eshell-tests.el                   |    4 +-
 test/lisp/faces-tests.el                           |   11 +-
 test/lisp/ffap-tests.el                            |    2 +-
 test/lisp/filenotify-tests.el                      |  224 +-
 test/lisp/files-tests.el                           |   64 +-
 test/lisp/files-x-tests.el                         |   91 +-
 test/lisp/gnus/gnus-test-headers.el                |  178 +
 test/lisp/gnus/gnus-tests.el                       |    2 +-
 test/lisp/gnus/message-tests.el                    |    2 +-
 test/lisp/help-fns-tests.el                        |    2 +-
 test/lisp/hi-lock-tests.el                         |    2 +-
 test/lisp/htmlfontify-tests.el                     |    2 +-
 test/lisp/ibuffer-tests.el                         |    6 +-
 test/lisp/ido-tests.el                             |    9 +-
 test/lisp/image-tests.el                           |   45 +
 test/lisp/imenu-tests.el                           |    2 +-
 test/lisp/info-xref-tests.el                       |    2 +-
 test/lisp/international/ccl-tests.el               |    2 +-
 test/lisp/international/mule-tests.el              |    2 +-
 test/lisp/international/mule-util-tests.el         |    2 +-
 test/lisp/international/ucs-normalize-tests.el     |   72 +-
 test/lisp/isearch-tests.el                         |    2 +-
 test/lisp/jit-lock-tests.el                        |    2 +-
 test/lisp/json-tests.el                            |    2 +-
 test/lisp/jsonrpc-tests.el                         |    2 +-
 test/lisp/kmacro-tests.el                          |    2 +-
 test/lisp/ls-lisp-tests.el                         |    2 +-
 test/lisp/mail/rmail-tests.el                      |    4 +-
 test/lisp/man-tests.el                             |    2 +-
 test/lisp/md4-tests.el                             |    2 +-
 test/lisp/minibuffer-tests.el                      |    8 +-
 test/lisp/mouse-tests.el                           |    2 +-
 test/lisp/net/dbus-tests.el                        |    2 +-
 test/lisp/net/gnutls-tests.el                      |    2 +-
 test/lisp/net/mailcap-tests.el                     |    2 +-
 test/lisp/net/network-stream-tests.el              |  436 +-
 test/lisp/net/newsticker-tests.el                  |    2 +-
 test/lisp/net/puny-tests.el                        |    2 +-
 test/lisp/net/sasl-scram-rfc-tests.el              |    2 +-
 test/lisp/net/secrets-tests.el                     |    9 +-
 test/lisp/net/shr-tests.el                         |    2 +-
 test/lisp/net/tramp-archive-tests.el               |   53 +-
 test/lisp/net/tramp-tests.el                       |  755 ++-
 test/lisp/obarray-tests.el                         |    2 +-
 test/lisp/org/org-tests.el                         |    2 +-
 test/lisp/progmodes/bat-mode-tests.el              |    2 +-
 test/lisp/progmodes/cc-mode-tests.el               |    2 +-
 test/lisp/progmodes/compile-tests.el               |    2 +-
 test/lisp/progmodes/elisp-mode-tests.el            |   30 +-
 test/lisp/progmodes/etags-tests.el                 |    2 +-
 test/lisp/progmodes/f90-tests.el                   |    4 +-
 test/lisp/progmodes/flymake-resources/Makefile     |    2 +-
 test/lisp/progmodes/flymake-tests.el               |    7 +-
 test/lisp/progmodes/js-tests.el                    |    2 +-
 test/lisp/progmodes/python-tests.el                |   15 +-
 test/lisp/progmodes/ruby-mode-tests.el             |   92 +-
 test/lisp/progmodes/sql-tests.el                   |  360 +-
 test/lisp/progmodes/subword-tests.el               |    2 +-
 test/lisp/progmodes/tcl-tests.el                   |    2 +-
 test/lisp/progmodes/xref-tests.el                  |    2 +-
 test/lisp/ps-print-tests.el                        |    2 +-
 test/lisp/register-tests.el                        |    2 +-
 test/lisp/replace-tests.el                         |    2 +-
 test/lisp/rot13-tests.el                           |    2 +-
 test/lisp/ses-tests.el                             |    2 +-
 test/lisp/shadowfile-tests.el                      |    2 +-
 test/lisp/shell-tests.el                           |    2 +-
 test/lisp/simple-tests.el                          |  156 +-
 test/lisp/sort-tests.el                            |    2 +-
 test/lisp/soundex-tests.el                         |    2 +-
 test/lisp/subr-tests.el                            |   39 +-
 test/lisp/tar-mode-tests.el                        |   15 +-
 test/lisp/term-tests.el                            |    2 +-
 test/lisp/textmodes/conf-mode-tests.el             |  204 +
 test/lisp/textmodes/css-mode-tests.el              |    2 +-
 test/lisp/textmodes/dns-mode-tests.el              |    2 +-
 test/lisp/textmodes/fill-tests.el                  |    2 +-
 test/lisp/textmodes/mhtml-mode-tests.el            |    2 +-
 test/lisp/textmodes/reftex-tests.el                |    2 +-
 test/lisp/textmodes/sgml-mode-tests.el             |    2 +-
 test/lisp/textmodes/tildify-tests.el               |    2 +-
 test/lisp/thingatpt-tests.el                       |    2 +-
 test/lisp/thread-tests.el                          |    2 +-
 test/lisp/url/url-auth-tests.el                    |    2 +-
 test/lisp/url/url-expand-tests.el                  |    2 +-
 test/lisp/url/url-file-tests.el                    |    2 +-
 test/lisp/url/url-future-tests.el                  |    2 +-
 test/lisp/url/url-handlers-test.el                 |    2 +-
 test/lisp/url/url-misc-tests.el                    |    2 +-
 test/lisp/url/url-parse-tests.el                   |    2 +-
 test/lisp/url/url-tramp-tests.el                   |    2 +-
 test/lisp/url/url-util-tests.el                    |    2 +-
 test/lisp/vc/add-log-tests.el                      |    2 +-
 test/lisp/vc/diff-mode-tests.el                    |  118 +-
 test/lisp/vc/ediff-diff-tests.el                   |    2 +-
 test/lisp/vc/ediff-ptch-tests.el                   |    2 +-
 test/lisp/vc/smerge-mode-tests.el                  |    2 +-
 test/lisp/vc/vc-bzr-tests.el                       |    2 +-
 test/lisp/vc/vc-hg-tests.el                        |    2 +-
 test/lisp/vc/vc-tests.el                           |    2 +-
 test/lisp/wdired-tests.el                          |   47 +-
 test/lisp/whitespace-tests.el                      |    2 +-
 test/lisp/{shell-tests.el => wid-edit-tests.el}    |   36 +-
 test/lisp/xdg-tests.el                             |    2 +-
 test/lisp/xml-tests.el                             |    2 +-
 test/lisp/xt-mouse-tests.el                        |    2 +-
 test/manual/BidiCharacterTest.txt                  |    4 +-
 test/manual/biditest.el                            |    2 +-
 test/manual/cedet/cedet-utests.el                  |    2 +-
 test/manual/cedet/ede-tests.el                     |    2 +-
 test/manual/cedet/semantic-ia-utest.el             |    2 +-
 test/manual/cedet/semantic-tests.el                |    2 +-
 test/manual/cedet/semantic-utest-c.el              |    2 +-
 test/manual/cedet/semantic-utest.el                |    2 +-
 test/manual/cedet/srecode-tests.el                 |    2 +-
 test/manual/cedet/tests/test.c                     |    2 +-
 test/manual/cedet/tests/test.el                    |    2 +-
 test/manual/cedet/tests/test.make                  |    2 +-
 test/manual/cedet/tests/testdoublens.cpp           |    2 +-
 test/manual/cedet/tests/testdoublens.hpp           |    2 +-
 test/manual/cedet/tests/testjavacomp.java          |    2 +-
 test/manual/cedet/tests/testpolymorph.cpp          |    2 +-
 test/manual/cedet/tests/testspp.c                  |    2 +-
 test/manual/cedet/tests/testsppreplace.c           |    2 +-
 test/manual/cedet/tests/testsppreplaced.c          |    2 +-
 test/manual/cedet/tests/testsubclass.cpp           |    2 +-
 test/manual/cedet/tests/testsubclass.hh            |    2 +-
 test/manual/cedet/tests/testtypedefs.cpp           |    2 +-
 test/manual/cedet/tests/testvarnames.c             |    2 +-
 test/manual/etags/c-src/abbrev.c                   |    2 +-
 test/manual/etags/c-src/emacs/src/gmalloc.c        |    2 +-
 test/manual/etags/c-src/emacs/src/keyboard.c       |    2 +-
 test/manual/etags/c-src/emacs/src/lisp.h           |    2 +-
 test/manual/etags/c-src/emacs/src/regex.h          |    2 +-
 test/manual/etags/c-src/etags.c                    |    2 +-
 test/manual/etags/c-src/exit.c                     |    2 +-
 test/manual/etags/c-src/exit.strange_suffix        |    2 +-
 test/manual/etags/c-src/getopt.h                   |    2 +-
 test/manual/etags/c-src/sysdep.h                   |    2 +-
 .../etags/el-src/emacs/lisp/progmodes/etags.el     |    2 +-
 test/manual/etags/tex-src/texinfo.tex              |    2 +-
 test/manual/etags/y-src/cccp.c                     |    2 +-
 test/manual/etags/y-src/parse.c                    |    2 +-
 test/manual/etags/y-src/parse.y                    |    2 +-
 test/manual/image-size-tests.el                    |    2 +-
 test/manual/indent/js-jsx.js                       |   85 -
 test/manual/indent/js.js                           |   21 +
 test/manual/indent/jsx-align-gt-with-lt.jsx        |   12 +
 test/manual/indent/jsx-indent-level.jsx            |   13 +
 test/manual/indent/jsx-quote.jsx                   |   16 +
 test/manual/indent/jsx-self-closing.jsx            |   13 +
 test/manual/indent/jsx-unclosed-1.jsx              |   13 +
 test/manual/indent/jsx-unclosed-2.jsx              |   65 +
 test/manual/indent/jsx.jsx                         |  314 ++
 test/manual/indent/pascal.pas                      |    2 +-
 test/manual/redisplay-testsuite.el                 |    2 +-
 test/manual/rmailmm.el                             |    2 +-
 test/manual/scroll-tests.el                        |    2 +-
 test/src/alloc-tests.el                            |    2 +-
 test/src/buffer-tests.el                           |    2 +-
 test/src/callint-tests.el                          |    2 +-
 test/src/callproc-tests.el                         |   25 +-
 test/src/casefiddle-tests.el                       |    2 +-
 test/src/charset-tests.el                          |    2 +-
 test/src/chartab-tests.el                          |    2 +-
 test/src/cmds-tests.el                             |   10 +-
 test/src/coding-tests.el                           |    2 +-
 test/src/data-tests.el                             |   24 +-
 test/src/decompress-tests.el                       |    2 +-
 test/src/doc-tests.el                              |    2 +-
 test/src/editfns-tests.el                          |   25 +-
 test/src/emacs-module-tests.el                     |   83 +-
 test/src/eval-tests.el                             |    2 +-
 test/src/fileio-tests.el                           |    6 +-
 test/src/floatfns-tests.el                         |    2 +-
 test/src/fns-tests.el                              |   25 +-
 test/src/font-tests.el                             |    2 +-
 test/src/inotify-tests.el                          |    2 +-
 test/src/json-tests.el                             |   12 +-
 test/src/keyboard-tests.el                         |    2 +-
 test/src/keymap-tests.el                           |    2 +-
 test/src/lcms-tests.el                             |    2 +-
 test/src/lread-tests.el                            |    6 +-
 test/src/marker-tests.el                           |    2 +-
 test/src/minibuf-tests.el                          |    2 +-
 test/src/print-tests.el                            |    2 +-
 test/src/process-tests.el                          |   84 +-
 test/src/regex-emacs-tests.el                      |   10 +-
 test/src/syntax-tests.el                           |    2 +-
 test/src/textprop-tests.el                         |    2 +-
 test/src/thread-tests.el                           |    2 +-
 test/src/timefns-tests.el                          |    2 +-
 test/src/undo-tests.el                             |    2 +-
 test/src/xml-tests.el                              |    2 +-
 2783 files changed, 49144 insertions(+), 27404 deletions(-)

diff --git a/.dir-locals.el b/.dir-locals.el
index 68eb58f..ffd65c8 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -1,14 +1,22 @@
 ((nil . ((tab-width . 8)
          (sentence-end-double-space . t)
-         (fill-column . 70)))
+         (fill-column . 70)
+         (bug-reference-url-format . "https://debbugs.gnu.org/%s";)))
  (c-mode . ((c-file-style . "GNU")
-            (c-noise-macro-names . ("UNINIT" "CALLBACK" "ALIGN_STACK"))))
- (objc-mode . ((c-file-style . "GNU")))
+            (c-noise-macro-names . ("INLINE" "ATTRIBUTE_NO_SANITIZE_UNDEFINED" 
"UNINIT" "CALLBACK" "ALIGN_STACK"))
+            (electric-quote-comment . nil)
+            (electric-quote-string . nil)))
+ (objc-mode . ((c-file-style . "GNU")
+               (electric-quote-comment . nil)
+               (electric-quote-string . nil)))
  (log-edit-mode . ((log-edit-font-lock-gnu-style . t)
                    (log-edit-setup-add-author . t)))
  (change-log-mode . ((add-log-time-zone-rule . t)
                     (fill-column . 74)
-                    (bug-reference-url-format . "https://debbugs.gnu.org/%s";)
-                    (mode . bug-reference)))
+                    (eval . (bug-reference-mode))))
  (diff-mode . ((mode . whitespace)))
- (emacs-lisp-mode . ((indent-tabs-mode . nil))))
+ (emacs-lisp-mode . ((indent-tabs-mode . nil)
+                     (electric-quote-comment . nil)
+                     (electric-quote-string . nil)))
+ (texinfo-mode . ((electric-quote-comment . nil)
+                  (electric-quote-string . nil))))
diff --git a/.gitattributes b/.gitattributes
index 15f83ae..65a943f 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,6 +1,6 @@
 # Attributes of Emacs files in the Git repository.
 
-# Copyright 2015-2018 Free Software Foundation, Inc.
+# Copyright 2015-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
diff --git a/.gitignore b/.gitignore
index 8ab4e8d..88b2976 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,6 @@
 # Files that Git should ignore in the Emacs source directory.
 
-# Copyright 2009-2018 Free Software Foundation, Inc.
+# Copyright 2009-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
@@ -171,6 +171,7 @@ lib-src/emacsclient
 lib-src/etags
 lib-src/hexl
 lib-src/make-docfile
+lib-src/make-fingerprint
 lib-src/movemail
 lib-src/profile
 lib-src/test-distrib
@@ -184,6 +185,9 @@ src/bootstrap-emacs
 src/emacs
 src/emacs-[0-9]*
 src/temacs
+src/fingerprint.c
+src/dmpstruct.h
+src/*.pdmp
 
 # Character-set info.
 admin/charsets/jisx2131-filter
@@ -194,6 +198,7 @@ lisp/international/charscript.el
 lisp/international/cp51932.el
 lisp/international/eucjp-ms.el
 lisp/international/uni-*.el
+lisp/language/pinyin.el
 
 # Documentation.
 *.aux
@@ -257,6 +262,9 @@ ChangeLog
 # Built by 'make install'.
 etc/emacs.tmpdesktop
 
+# Built by 'make-dist'.
+/MANIFEST
+
 # Distribution directories.
 /emacs-[1-9]*/
 
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 60c4d55..92efcf6 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,4 +1,4 @@
-# Copyright (C) 2017-2018 Free Software Foundation, Inc.
+# Copyright (C) 2017-2019 Free Software Foundation, Inc.
 #
 #  This file is part of GNU Emacs.
 #
@@ -22,20 +22,46 @@
 # evaluation purposes, thus possibly temporary.
 
 # Maintainer: address@hidden
-# URL: https://gitlab.com/emacs-ci/emacs
+# URL: https://emba.gnu.org/emacs/emacs
 
 image: debian:stretch
 
+variables:
+  GIT_STRATEGY: fetch
+  EMACS_EMBA_CI: 1
+
 before_script:
   - apt update -qq
-  - DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y -qq 
-o=Dpkg::Use-Pty=0 libc-dev gcc make autoconf automake libncurses-dev gnutls-dev
+  - DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y -qq 
-o=Dpkg::Use-Pty=0 libc-dev gcc make autoconf automake libncurses-dev 
gnutls-dev git
 
 stages:
   - test
 
-test:
+test-all:
+  # This tests also file monitor libraries inotify and inotifywatch.
   stage: test
   script:
+    - DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y 
-qq -o=Dpkg::Use-Pty=0 inotify-tools
     - ./autogen.sh autoconf
     - ./configure --without-makeinfo
-    - make check
+    - make bootstrap
+    - make check-expensive
+
+test-filenotify-gio:
+  stage: test
+  # This tests file monitor libraries gfilemonitor and gio.
+  only:
+    changes:
+      - .gitlab-ci.yml
+      - lisp/autorevert.el
+      - lisp/filenotify.el
+      - lisp/net/tramp-sh.el
+      - src/gfilenotify.c
+      - test/lisp/autorevert-tests.el
+      - test/lisp/filenotify-tests.el
+  script:
+    - DEBIAN_FRONTEND=noninteractive apt install --no-install-recommends -y 
-qq -o=Dpkg::Use-Pty=0 libglib2.0-dev libglib2.0-bin libglib2.0-0
+    - ./autogen.sh autoconf
+    - ./configure --without-makeinfo --with-file-notification=gfile
+    - make bootstrap
+    - make -C test autorevert-tests filenotify-tests
diff --git a/CONTRIBUTE b/CONTRIBUTE
index efd4bf1..a5433e3 100644
--- a/CONTRIBUTE
+++ b/CONTRIBUTE
@@ -54,12 +54,21 @@ packages the patch's commit message and changes.  To send 
just one
 such patch without additional remarks, you can use a command like
 'git send-email address@hidden 0001-DESCRIPTION.patch'.
 
+Once the cumulative amount of your submissions exceeds about 15 lines
+of non-trivial changes, we will need you to assign to the FSF the
+copyright for your contributions.  Ask on address@hidden, and we
+will send you the necessary form together with the instructions to
+fill and email it, in order to start this legal paperwork.
+
 ** Issue tracker (a.k.a. "bug tracker")
 
 The Emacs issue tracker at https://debbugs.gnu.org lets you view bug
 reports and search the database for bugs matching several criteria.
 Messages posted to the address@hidden mailing list, mentioned
-above, are recorded by the tracker with the corresponding bugs/issues.
+above, are recorded by the tracker with the corresponding
+bugs/issues.  If a message to the bug tracker contains a patch, please
+include the string "[PATCH]" in the subject of the message in order to
+let the bug tracker tag the bug properly.
 
 GNU ELPA has a 'debbugs' package that allows accessing the tracker
 database from Emacs.
diff --git a/ChangeLog.1 b/ChangeLog.1
index 011b383..8324af3 100644
--- a/ChangeLog.1
+++ b/ChangeLog.1
@@ -14700,7 +14700,7 @@
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 1993-1999, 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 1993-1999, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/ChangeLog.2 b/ChangeLog.2
index 71c792e..d26ea14 100644
--- a/ChangeLog.2
+++ b/ChangeLog.2
@@ -35787,7 +35787,7 @@ See ChangeLog.1 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 2015-2018 Free Software Foundation, Inc.
+  Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/ChangeLog.3 b/ChangeLog.3
index 194fa68..e7f4d86 100644
--- a/ChangeLog.3
+++ b/ChangeLog.3
@@ -1,3 +1,1646 @@
+2019-04-11  Eli Zaretskii  <address@hidden>
+
+       Improve documentation of 'read-command'
+
+       * src/minibuf.c (Fread_command): Document the return value
+       when DEFAULT-VALUE is nil and the user enters nothing.
+       * doc/lispref/minibuf.texi (High-Level Completion): Document
+       the printed representation of a symbol whose name is empty.
+       (Bug#3522)
+
+2019-04-11  Eli Zaretskii  <address@hidden>
+
+       Fix an outdated URL in a comment
+
+       * src/emacs.c: Fix reference to Cocoa CoreFoundation Release
+       Notes.  (Bug#35225)
+
+2019-04-11  Basil L. Contovounesios  <address@hidden>
+
+       Backport: Fix comment-empty-lines docstring (bug#35152)
+
+       * lisp/newcomment.el (comment-empty-lines): Consistently use US
+       commas in docstring.  Fix indentation of and typo in custom :type.
+
+       (cherry picked from commit 690c678fb6c1fb5b2f828f9bb90782bd0b01c399)
+
+2019-04-11  Alex Branham  <address@hidden>
+
+       Backport: Update documentation for indent-relative functions
+
+       * lisp/indent.el (indent-relative): Document what happens when there
+         is no previous nonblank line.
+       * doc/lispref/text.texi (Relative Indent): Document
+         indent-relative-first-indent-point instead of obsolete
+         indent-relative-maybe. Fix documentation of which argument from
+         'indent-relative' is used.
+
+       Bug#34858
+
+       (cherry picked from commit 10cd65878c741d2a22a1f2c36c54fcad4e516f72)
+
+2019-04-11  Noam Postavsky  <address@hidden>
+
+       Update nxml-mode.texi: completion now gives xmlns="-!-"
+
+       * doc/misc/nxml-mode.texi (Completion): As of 2016-01-16 "* lisp/nxml:
+       Use standard completion; it also works for company-mode", completing
+       an attribute when there is only one candidate inserts both quotes.
+       Update the example accordingly.
+
+2019-04-10  Eric Abrahamsen  <address@hidden>
+
+       Note that choose-completion-string-functions funcs take four args
+
+       * lisp/simple.el (choose-completion-string-functions): Functions in
+         this list actually need to accept four arguments, though the fourth
+         should be ignored.
+
+2019-04-10  Gemini Lasswell  <address@hidden>
+
+       Address name conflicts in EIEIO documentation (bug#31660)
+
+       * doc/misc/eieio.texi (Quick Start): Rename the class used in the
+       example from 'record' to 'person'.
+       (Building Classes): Advise user to check for name conflicts before
+       naming a class.  Add a missing apostrophe.
+       (Making New Objects): Correct grammar.  Rename the class used in the
+       example from 'record' to 'my-class'.
+
+2019-04-09  Mattias Engdegård  <address@hidden>
+
+       Clarify the TESTFN argument to `alist-get'
+
+       * lisp/subr.el (alist-get):
+       Rephrase the initial text to clarify the meaning of the TESTFN argument.
+       It's an equality predicate, not a look-up function (Bug#35206).
+
+       (cherry picked from commit c81465580fe262f28ce47502c00f4afcbe3b8f8d)
+
+2019-04-08  Eli Zaretskii  <address@hidden>
+
+       * src/editfns.c (Fnarrow_to_region): Doc fix.  (Bug#35163)
+
+2019-04-06  Eli Zaretskii  <address@hidden>
+
+       Fix doc strings of 'vc-version-diff' and 'vc-version-ediff'
+
+       * lisp/vc/vc.el (vc-version-diff, vc-version-ediff): Describe
+       arguments in the doc strings.  (Bug#35019)
+
+2019-04-06  Eli Zaretskii  <address@hidden>
+
+       Improve documentation of set-window-start
+
+       * doc/lispref/windows.texi (Window Start and End):
+       * src/window.c (Fset_window_start): Document that reliable
+       setting of a window start position requires to adjust point to
+       be visible.  (Bug#34038)
+
+2019-04-06  Eli Zaretskii  <address@hidden>
+
+       Improve documentation of window parameters
+
+       * doc/lispref/windows.texi (Cyclic Window Ordering): Describe
+       the effect of the 'other-window' window parameter.
+       (Window Parameters): Improve the descriptions of window
+       parameters.  Move the detailed description of the
+       'quit-restore' window parameter from here...
+       (Quitting Windows): ...to here.  (Bug#35063)
+
+2019-04-06  Eli Zaretskii  <address@hidden>
+
+       Improve commentary in frame.el
+
+       * lisp/frame.el: Improve commentary for display-* functions.
+       (Bug#35058)
+
+2019-04-06  Mauro Aranda  <address@hidden>
+
+       Fix typo in a doc string
+
+       * lisp/autorevert.el (global-auto-revert-mode): Fix a typo.
+       (Bug#35165)
+
+2019-03-20  Paul Eggert  <address@hidden>
+
+       Say which regexp ranges should be avoided
+
+       * doc/lispref/searching.texi (Regexp Special): Say that
+       regular expressions like "[a-m-z]" and "[[:alpha:]-~]" should
+       be avoided, for the same reason that regular expressions like
+       "+" and "*" should be avoided: POSIX says their behavior is
+       undefined, and they are confusing anyway.  Also, explain
+       better what happens when the bound of a range is a raw 8-bit
+       byte; the old explanation appears to have been obsolete
+       anyway.  Finally, say that ranges like "[\u00FF-\xFF]" that
+       mix non-ASCII characters and raw 8-bit bytes should be
+       avoided, since it’s not clear what they should mean.
+
+2019-03-20  Nicolas Petton  <address@hidden>
+
+       * etc/AUTHORS: Update.
+
+       * ; ChangeLog.3 update
+
+2019-03-20  Eli Zaretskii  <address@hidden>
+
+       Improve indexing of the user manual
+
+       * doc/emacs/search.texi (Word Search): Improve indexing of
+       "M-s M-w".
+
+2019-03-19  Basil L. Contovounesios  <address@hidden>
+
+       Fix url-copy-file arglist
+
+       * lisp/url/url-handlers.el: Silence byte-compiler.
+       (url-copy-file): Add 6th argument following change to copy-file in
+       2012-12-16T19:22:27+01:address@hidden (bug#4410)
+
+2019-03-19  Eli Zaretskii  <address@hidden>
+
+       Fix downloading updates for packages with non-ASCII descriptions
+
+       * lisp/emacs-lisp/package.el (package--download-one-archive):
+       Make sure archive contents are written using UTF-8 encoding.
+       (Bug#34909)
+       (list-packages): Set buffer's encoding to UTF-8.
+
+2019-03-18  Nicolas Petton  <address@hidden>
+
+       * etc/NEWS: Remove temporary markers.
+
+2019-03-15  Alan Mackenzie  <address@hidden>
+
+       * doc/misc/cc-mode.texi (Config Basics): in @itemize, @asis -> @w{}
+
+2019-03-15  Eli Zaretskii  <address@hidden>
+
+       Don't clobber 'comint-input-autoexpand' in 'read-shell-command'
+
+       * lisp/shell.el (shell-completion-vars): Set only the
+       buffer-local value of 'comint-input-autoexpand'.  (Bug#34815)
+
+2019-03-13  Martin Rudalics  <address@hidden>
+
+       Document restrictions when setting window margins, fringes or scroll 
bars
+
+       * src/window.c (Fset_window_margins, Fset_window_fringes)
+       (Fset_window_scroll_bars): In doc-strings tell that a window
+       must be large enough to accommodate fringes, sroll bars and
+       margins of the desired size.
+       * doc/lispref/display.texi (Fringe Size/Pos, Scroll Bars)
+       (Display Margins): Tell that windows must be large enough to
+       accommodate fringes, sroll bars and margins of the desired
+       size.
+
+2019-03-10  Eli Zaretskii  <address@hidden>
+
+       More improvements for 'read-buffer's doc string
+
+       * src/minibuf.c (Fread_buffer): Further improve the doc
+       string.  (Bug#347694)
+
+2019-03-10  Alan Mackenzie  <address@hidden>
+
+       * lisp/progmodes/cc-defs.el: Update c-version to 5.33.2 for Emacs 26.2
+
+2019-03-09  Eli Zaretskii  <address@hidden>
+
+       * src/minibuf.c (Fread_buffer): Minor doc fixes.  (Bug#34749)
+
+2019-03-09  Eli Zaretskii  <address@hidden>
+
+       Fix markup of fake keys in the ELisp manual
+
+       * doc/lispref/keymaps.texi (Menu Bar, Tool Bar): Fix markup of
+       fake keys.  (Bug#34785)
+
+2019-03-09  Eli Zaretskii  <address@hidden>
+
+       Avoid errors in Auto Revert mode
+
+       * lisp/autorevert.el (auto-revert-buffers): Cancel
+       auto-revert-timer only if it is non-nil.  This avoids errors
+       on first invocation of Auto-Revert mode.
+
+2019-03-09  Michael Albinus  <address@hidden>
+
+       Mention empty strings in file name expansion, emacs lisp reference
+
+       * doc/lispref/files.texi (Files, File Name Expansion):
+       Mention also empty strings.
+
+2019-03-08  Alan Mackenzie  <address@hidden>
+
+       cc-mode.texi: Work around makeinfo alignment bug.  Fix problem with ss 
index
+
+       * doc/misc/cc-mode.texi (top level): Using txicommandconditionals to
+       differentiate between the C and perl versions of Texinfo, create an "ss
+       index" unless we are both using the C Texinfo and are building the .dvi 
output
+       format.
+       (Config Basics): Work around a perl Texinfo alignment bug by writing a
+       separate version of an item list structure for this version, 
simplifying it
+       considerably.
+
+2019-03-08  Martin Rudalics  <address@hidden>
+
+       Warn against recursive invocations of 'buffer-list-update-hook' 
(Bug#34765)
+
+       * src/buffer.c (Vbuffer_list_update_hook):
+       * doc/lispref/buffers.texi (Buffer List): Warn against
+       recursive invocations of 'buffer-list-update-hook' (Bug#34765).
+
+2019-03-08  Martin Rudalics  <address@hidden>
+
+       Provide more details in doc-string of 'delete-windows-on' (Bug#34749)
+
+       * lisp/window.el (delete-windows-on): Provide more details in
+       doc-string (Bug#34749).
+
+2019-03-08  Eli Zaretskii  <address@hidden>
+
+       Improve documentation of 'delete-windows-on'
+
+       * doc/emacs/windows.texi (Change Window): Document
+       'delete-windows-on'.
+
+       * lisp/window.el (delete-windows-on): Doc fix.  (Bug#34749)
+
+2019-03-08  Eli Zaretskii  <address@hidden>
+
+       * lisp/frame.el (make-frame-command): Doc fix.  (Bug#34715)
+
+2019-03-07  Eli Zaretskii  <address@hidden>
+
+       Avoid undefined behavior in gdb-mi.el
+
+       * lisp/progmodes/gdb-mi.el (gdb-send): Don't call match-string
+       if this is not a control command.  (Bug#34769)
+
+2019-03-06  Martin Rudalics  <address@hidden>
+
+       * lisp/window.el (fit-frame-to-buffer): Make doc-string more accurate.
+
+2019-03-05  Basil L. Contovounesios  <address@hidden>
+
+       Minor spelling and grammar fixes (bug#34756)
+
+       doc/misc/cc-mode.texi (Style Variables, Customizing Indentation):
+       doc/misc/ede.texi (Extending EDE, ede-project-placeholder)
+       (ede-target, ede-proj-target, ede-compilation-program, ede-compiler)
+       (ede-linker): Remove apostrophe from possessive "it's".
+       doc/lispintro/emacs-lisp-intro.texi (Find a File):
+       doc/misc/gnus-faq.texi (FAQ 2-2): Write "an other" as a single word.
+       doc/misc/gnus.texi (Article Buttons):
+       lisp/gnus/gnus-art.el (gnus-button-mid-or-mail-heuristic-alist)
+       (gnus-button-mid-or-mail-heuristic): Write singular number of
+       Message-IDs, rather than plural.
+       lisp/gnus/message.el (message-user-fqdn): Capitalize initialism.
+
+2019-03-04  Eli Zaretskii  <address@hidden>
+
+       Minor improvement of documentation of '(when CONDITION . SPEC)'
+
+       * doc/lispref/display.texi (Other Display Specs): Add a caveat
+       to using the '(when CONDITION . SPEC)' display specs.
+
+2019-03-02  Eli Zaretskii  <address@hidden>
+
+       Improve documentation of 'auto-coding-functions'
+
+       * doc/lispref/nonascii.texi (Default Coding Systems): Clarify
+       that the functions in 'auto-coding-functions' are called both
+       for decoding and for encoding.
+
+       * lisp/international/mule.el (auto-coding-functions): Doc fix.
+
+2019-03-02  Eli Zaretskii  <address@hidden>
+
+       Fix visiting XML files with non-Unix EOL format
+
+       * lisp/international/mule.el (sgml-xml-auto-coding-function)
+       (sgml-html-meta-auto-coding-function): Don't use
+       'buffer-file-coding-system' if the buffer is unibyte.
+       (Bug#34704)
+
+2019-03-02  Basil L. Contovounesios  <address@hidden>
+
+       Update example major mode code in Elisp manual
+
+       * doc/lispref/modes.texi (Example Major Modes): Update code examples
+       to reflect current state of lisp/textmodes/text-mode.el and
+       lisp/emacs-lisp/lisp-mode.el. (bug#34671)
+
+2019-03-01  Eli Zaretskii  <address@hidden>
+
+       Fix a typo in the Calc manual
+
+       * doc/misc/calc.texi (Algebraic Tutorial): Fix parentheses in
+       @example.  (Bug#34689)
+
+2019-03-01  Eli Zaretskii  <address@hidden>
+
+       Minor improvement in cross-references of the ELisp manual
+
+       * doc/lispref/modes.texi (Minor Mode Conventions): Add
+       cross-references to related major-mode descriptions.  (Bug#34678)
+
+2019-03-01  Tobias Bading  <address@hidden>  (tiny change)
+
+       Fix last change on 'compilation-parse-errors'
+
+       * lisp/progmodes/compile.el (compilation-parse-errors): Fix
+       previous change in this function.  (Bug#34479)
+
+2019-02-25  Dmitry Gutov  <address@hidden>
+
+       Backport: js--re-search-backward-inner: Fix infloop
+
+       Fix JS indentation infloop reported in
+       https://github.com/mooz/js2-mode/issues/513.
+
+       * lisp/progmodes/js.el (js--re-search-backward-inner): Account for
+       multiline string literals.
+       * test/manual/indent/js.js: New test example.
+
+       (cherry picked from commit b01a4295c2f9bb58858880e4e28b05cc8396791c)
+
+2019-02-23  Eli Zaretskii  <address@hidden>
+
+       Minor improvement for docs of completion
+
+       * doc/lispref/minibuf.texi (Completion Commands)
+       (Completion in Buffers, Programmed Completion): Add to text
+       that references completion tables a cross-reference to where
+       "completion table" is described.
+       (Programmed Completion): Fix the description of
+       'completion-table-dynamic'.  Add more cross-references.
+
+2019-02-22  Ken Brown  <address@hidden>
+
+       Disable the timerfd interface on Cygwin
+
+       * configure.ac (emacs_cv_have_timerfd): Set to "no" on Cygwin.
+
+2019-02-22  Eli Zaretskii  <address@hidden>
+
+       Fix a typo in the doc string of 'regex-opt'
+
+       * lisp/emacs-lisp/regexp-opt.el (regexp-opt): Fix example in
+       the doc string.  (Bug#34596)
+
+2019-02-21  Michael Albinus  <address@hidden>
+
+       Document bash 5.0.0 misbehavior in tramp.texi (Bug#34192)
+
+       * doc/misc/tramp.texi (Frequently Asked Questions): Warn about
+       bash 5.0.0 and HISTSIZE=0.  (Bug#34192)
+
+2019-02-20  Nicolas Petton  <address@hidden>
+
+       Bump Emacs version to 26.1.92
+
+       * README:
+       * configure.ac:
+       * msdos/sed2v2.inp:
+       * nt/README.W32: Bump Emacs version to 26.1.92.
+
+2019-02-20  Nicolas Petton  <address@hidden>
+
+       * ; ChangeLog.3 update
+
+       * etc/AUTHORS: Update.
+
+2019-02-20  Glenn Morris  <address@hidden>
+
+       Remove .art from the default list of ImageMagick extensions
+
+       It seems that .art files can be non-image files that
+       ImageMagick mistakenly treats as extremely large images.
+       Real .art images seem rare.
+       * lisp/image.el (imagemagick-enabled-types): Remove ART.  (Bug#22289)
+
+2019-02-19  Eli Zaretskii  <address@hidden>
+
+       Fix input after setting x-wait-for-event-timeout nil
+
+       * src/w32term.c (x_make_frame_visible): Call unblock_input
+       before returning early.  (Bug#34575)
+
+2019-02-19  Martin Rudalics  <address@hidden>
+
+       Fix two warnings in eshell.texi
+
+       * doc/misc/eshell.texi (Built-ins, Globbing): Fix `.' or `,'
+       must follow @xref, not `f' warnings.
+
+2019-02-18  Stefan Monnier  <address@hidden>
+
+       * lisp/minibuffer.el (completion-table-dynamic): Improve docstring
+
+2019-02-18  David Pathakjee  <address@hidden>  (tiny change)
+
+       * lisp/emacs-lisp/debug.el (debug-on-variable-change): Doc fix.  
(Bug#34518)
+
+2019-02-17  Eli Zaretskii  <address@hidden>
+
+       Fix a typo in ELisp manual
+
+       * doc/lispref/abbrevs.texi (Abbrev Table Properties): Fix a
+       typo.  (Bug#34508)
+
+2019-02-16  Paul Eggert  <address@hidden>
+
+       Update citations of Internet RFCs
+
+       For example, RFC 822 has been obsoleted by RFC 2822, which in
+       turn has been obsoleted by RFC 5322.
+       * doc/emacs/ack.texi, doc/lispref/os.texi:
+       * doc/misc/emacs-mime.texi, doc/misc/gnus-coding.texi:
+       * doc/misc/gnus.texi, doc/misc/sc.texi:
+       * lisp/calendar/parse-time.el, lisp/gnus/gnus-cite.el:
+       * lisp/gnus/gnus-util.el, lisp/gnus/message.el:
+       * lisp/gnus/mm-bodies.el, lisp/gnus/nnrss.el:
+       * lisp/mail/feedmail.el, lisp/mail/ietf-drums.el:
+       * lisp/mail/mail-extr.el, lisp/mail/mail-utils.el:
+       * lisp/mail/mailclient.el, lisp/mail/mailheader.el:
+       * lisp/mail/rfc2047.el, lisp/mail/rfc822.el, lisp/mail/rmail.el:
+       * lisp/mail/sendmail.el, lisp/mail/smtpmail.el:
+       * lisp/mail/supercite.el, lisp/mh-e/mh-e.el:
+       * lisp/mh-e/mh-utils.el, lisp/net/imap.el:
+       * lisp/net/newst-backend.el, lisp/org/org-id.el:
+       * lisp/ps-samp.el, lisp/simple.el, lisp/url/url-util.el:
+       Update RFC citations.
+
+2019-02-16  Eli Zaretskii  <address@hidden>
+
+       Fix handling of manpage references divided by hyphenation
+
+       * lisp/man.el (Man-reference-regexp): Accept a newline as part
+       of a manpage name only if it's preceded by a hyphen.  (Bug#34286)
+       (Man-translate-references): Adapt to change in
+       'Man-reference-regexp'.
+       (Man-default-man-entry): Support references divided between
+       two lines by an ASCII hyphen.  This is a left-over from fixing
+       bug#6289.
+
+2019-02-16  Gregor Zattler  <address@hidden>  (tiny change)
+
+       * doc/misc/eshell.texi: Fix some @ref's.
+
+2019-02-16  Eli Zaretskii  <address@hidden>
+
+       Fix a typo in lispref/syntax.texi
+
+       * doc/lispref/syntax.texi (Syntax Table Internals): Fix a
+       typo.  (Bug#34495)
+
+2019-02-15  Victor J. Orlikowski  <address@hidden>  (tiny change)
+
+       Avoid errors in erc-dcc.el when erc-dcc-verbose is non-nil
+
+       * lisp/erc/erc-dcc.el (erc-dcc-get-filter): Don't assume STR
+       is always a string.  Use 'buffer-name' to get the DCC file
+       name, as buffer-file-name is not set in the process buffer.
+
+2019-02-15  Daniel Lopez  <address@hidden>  (tiny change)
+
+       Fix faces in compilation messages
+
+       * lisp/progmodes/compile.el (compilation-parse-errors): Don't
+       clobber the value of TYPE inside the loop.  (Bug#34479)
+
+2019-02-15  Gregor Zattler  <address@hidden>
+
+       * doc/misc/eshell.texi (Built-ins): Fix alias description
+
+       Dear eamcs developers, eshells current documentation first states
+       that alias definitions are not saved to an alias file, later that
+       they are saved to an alias file.  I tested it and the latter is
+       correct.
+
+       Please find attached a patch which fixes this.
+
+       Thanks for working on emacs which is really great, Gregor
+
+       >From 1fe51cc769ab7a30d0896fb3d6105c0561243fa7 Mon Sep 17 00:00:00 2001
+       From: Gregor Zattler <address@hidden>
+       Date: Wed, 13 Feb 2019 20:19:38 +0100
+       Subject: * doc/misc/eshell.texi (Built-ins): Fix alias description.
+
+       Bring description of built-in 'alias' in line with (info "(eshell) 
Aliases"),
+       which describes the actual behaviur.
+
+       (cherry picked from commit a48099ce7ff63cda416a870766fe61f5b8ac7c2c)
+
+2019-02-14  Katsumi Yamaoka  <address@hidden>
+
+       Work for empty MIME attachments (related to bug#34387)
+
+       * lisp/gnus/mm-view.el (mm-inline-text):
+       Make undisplayer do nothing if the part is empty.
+
+       * lisp/gnus/mm-decode.el (mm-copy-to-buffer): Work for empty MIME part.
+       * lisp/gnus/mml.el (mime-to-mml): Ditto.
+
+2019-02-14  Jackson Ray Hamilton  <address@hidden>
+
+       Backport: js-indent-align-list-continuation: Make variable safe
+
+       * lisp/progmodes/js.el (js-indent-align-list-continuation): Indicate
+       variable is safe as a file-local variable.  This fixes the
+       js-indent-align-list-continuation-nil test when run with make.
+
+       (cherry picked from commit dd319f2711f895eec87c1017b82cd9d88d9ecd0a)
+
+2019-02-13  Eli Zaretskii  <address@hidden>
+
+       Avoid crashes upon C-g in nested invocations of 'read_char'
+
+       * src/keyboard.c (read_char, read_event_from_main_queue):
+       Ensure the global value of getcjmp is restored when the stack
+       is unwound by the likes of 'throw', by calling
+       record_unwind_protect_ptr instead of restoring the value
+       manually.  (Bug#34394)
+       (restore_getcjmp): Argument is now 'void *', to match the
+       signature of record_unwind_protect_ptr.
+
+       (cherry picked from commit 10527fca66e39d7067986904161fa33741abcd26)
+
+2019-02-12  Stefan Monnier  <address@hidden>
+
+       * src/data.c (Fmake_local_variable): Fix bug#34318
+
+       Revert part of ed962f2b8a.
+
+       * test/src/data-tests.el (data-tests-make-local-forwarded-var):
+       Add corresponding test.
+
+2019-02-12  Eli Zaretskii  <address@hidden>
+
+       Minor fixes in ELisp manual wrt syntax-table properties
+
+       * doc/lispref/syntax.texi (Syntax Properties): Fix reference
+       to syntax-table properties.  (Bug#34455)
+       (Control Parsing): Remove redundant @vindex entry.
+
+2019-02-12  Michael Albinus  <address@hidden>
+
+       * admin/notes/emba: New file.
+
+2019-02-11  Eli Zaretskii  <address@hidden>
+
+       Fix Hunspell invocation for discovering its dictionaries
+
+       * lisp/textmodes/ispell.el
+       (ispell-find-hunspell-dictionaries): Invoke Hunspell with the
+       -a switch, to prevent it from initializing its curses UI.
+       (Bug#34272)
+
+2019-02-08  Eli Zaretskii  <address@hidden>
+
+       Minor improvements to do strings in callproc.c
+
+       * src/callproc.c (Fcall_process, Fcall_process_region): Minor
+       fixes to doc strings.  Suggested by Nicholas Drozd
+       <address@hidden>.  (Bug#34274)
+
+2019-02-08  Eli Zaretskii  <address@hidden>
+
+       Improve documentation of 'date-to-time' and 'parse-time-string'
+
+       * doc/lispref/os.texi (Time Parsing): Document
+       'parse-time-string', and refer to it for the description of
+       the argument of 'date-to-time'.
+
+       * lisp/calendar/time-date.el (date-to-time): Refer in the doc
+       string to 'parse-time-string' for more information about the
+       format of the DATE argument.  (Bug#34303)
+
+2019-02-08  Nick Drozd  <address@hidden>
+
+       Fix downloading of URLs that end in a slash
+
+       * lisp/net/eww.el (eww-download-callback): Fix download URL
+       file name.  Previously this wasn't handling download URLs
+       correctly, resulting in all downloaded pages being named
+       "!", "!(1)", etc.  (Bug#34291)
+
+2019-02-08  Nick Drozd  <address@hidden>
+
+       * doc/misc/eww.texi (Basics): Fix eww keybindings.  (Bug#34291)
+
+2019-02-08  Robert Pluim  <address@hidden>
+
+       Fix process-thread docstring
+
+       * src/process.c (Fprocess_thread): Correct docstring.
+
+2019-02-08  Eli Zaretskii  <address@hidden>
+
+       Fix failures of vc-find-revision with non-ASCII file names
+
+       * lisp/vc/vc.el (vc-find-revision): Instead of binding
+       coding-system-for-write, make the buffer-file-coding-system of
+       the temporary buffer be no-conversion.  This avoids the
+       unwanted side effect of not encoding the command-line
+       arguments of the VCS commands invoked by the backend.
+       (Bug#34350)
+
+2019-02-07  Eli Zaretskii  <address@hidden>
+
+       * doc/lispref/tips.texi (Documentation Tips): Fix quotes.  (Bug#34372)
+
+2019-02-05  Alex Branham  <address@hidden>
+
+       Add documentation for tabulated-list functions in the elisp manual
+
+       * doc/lispref/modes.texi: Add documentation for
+         'tabulated-list-delete-entry', 'tabulated-list-get-id',
+         'tabulated-list-get-entry', 'tabulated-list-header-overlay-p',
+         'tabulated-list-put-tag', and 'tabulated-list-set-col'.
+
+       Bug#21074
+
+2019-02-03  Jean-Christophe Helary  <address@hidden>
+
+       Fix URL in ucs-normalize.el
+
+       * lisp/international/ucs-normalize.el: Fix URL of the HFS
+       normalization reference.  (Bug#34300)
+
+2019-02-03  Alan Mackenzie  <address@hidden>
+
+       * etc/PROBLEMS: Amend entry for profiler bug #34235 to mention kernel 
4.14.97
+
+2019-02-02  Glenn Morris  <address@hidden>
+
+       * make-dist: Remove references to src/stamp-h.in.
+
+       This file was removed two years ago in 2f89350.
+       No need to merge to master.
+
+2019-02-02  Paul Eggert  <address@hidden>
+
+       * etc/PROBLEMS: Mention profiler-report bug (Bug#34235).
+
+2019-02-01  Eli Zaretskii  <address@hidden>
+
+       Correct the docs of inserting kmacro counter
+
+       * doc/emacs/kmacro.texi (Keyboard Macro Counter): Correct the
+       description of the affect "C-u" has on inserting the macro
+       counter.  Define "previous counter value".
+
+       * lisp/kmacro.el (kmacro-insert-counter)
+       (kmacro-start-macro-or-insert-counter): Fix the doc strings
+       regarding the effect of "C-u".  (Bug#34263)
+
+2019-02-01  Nicholas Drozd  <address@hidden>
+
+       * doc/misc/calc.texi (Algebraic Tutorial): Fix a typo.  (Bug#34273)
+
+2019-02-01  Eli Zaretskii  <address@hidden>
+
+       Avoid errors in 'rmail-get-new-mail'
+
+       * lisp/mail/rmail.el (rmail-insert-inbox-text): Don't assume
+       the Rmail protocol is always a string when calling
+       'rmail-remote-proto-p'.  (Bug#34252)
+
+2019-01-31  Paul Eggert  <address@hidden>
+
+       Fix process-contact bug with TCP connections
+
+       This fixes a regression from Emacs 25.3 (Bug#34134).
+       * src/process.c (server_accept_connection):
+       Set host correctly, fixing a bug introduced in
+       2017-09-16T21:29:address@hidden
+       when working around a GCC bug.
+
+2019-01-29  Eli Zaretskii  <address@hidden>
+
+       Minor copyedits in last manual change
+
+       * doc/emacs/custom.texi (Authentication): Improve markup,
+       indexing, and wording.
+
+2019-01-29  Eli Zaretskii  <address@hidden>
+
+       Improve documentation of face numbers
+
+       * doc/lispref/display.texi (Face Functions): Mention where the
+       face number is used and that it depends on the 'face' property
+       of the face symbol.  Improve indexing.
+
+2019-01-27  Michael Albinus  <address@hidden>
+
+       * doc/emacs/custom.texi (Authentication): Refer to the "Help for users" 
node.
+
+2019-01-26  Michael Albinus  <address@hidden>
+
+       New node Authentication in the Emacs manual
+
+       * doc/emacs/custom.texi (Customization):
+       * doc/emacs/emacs.texi (Top): Add node Authentication.
+
+2019-01-25  Alan Mackenzie  <address@hidden>
+
+       Fix a loop in c-fl-decl-start.  This fixes bug #34186.
+
+       * lisp/progmodes/cc-mode.el (c-fl-decl-start) In the pair of operations
+       c-syntactic-skip-backward and c-forward-syntactic-ws, ensure the latter
+       doesn't come back to the position before the former, and break out of 
the
+       enclosing loop if it does.
+
+2019-01-25  Eli Zaretskii  <address@hidden>
+
+       Fix LaTeX output of month and day from cal-tex.el
+
+       * lisp/calendar/cal-tex.el (cal-tex-cursor-week-iso)
+       (cal-tex-week-hours): Escape a lone blank, to make it through
+       LaTeX.  (Bug#34148)
+
+2019-01-25  Daniel Kahn Gillmor  <address@hidden>  (tiny change)
+
+       Avoid elisp crash for OpenPGP User IDs with no e-mail address
+
+       * lisp/gnus/mml-sec.el (mml-secure-check-user-id): Verify that
+       there is an e-mail address in the current User ID before trying
+       to downcase it.  (Bug#34121)
+
+2019-01-25  Benjamin Riefenstahl  <address@hidden>
+
+       image-mode: Do not use default scaling (bug#33990)
+
+       * lisp/image-mode.el (image-toggle-display-image): Set :scale == 1 so
+       that create-image does not apply additional scaling.
+
+2019-01-25  Benjamin Riefenstahl  <address@hidden>
+
+       create-image: Expand documentation (bug#33990)
+
+       * lisp/image.el (create-image): Discuss default for :scale in the doc
+       string.
+
+2019-01-21  Eli Zaretskii  <address@hidden>
+
+       Improve documentation of 'isearch-filter-predicate'
+
+       * lisp/isearch.el (isearch-filter-predicate)
+       (isearch-filter-visible): Doc fixes.  (Bug#34150)
+
+2019-01-19  Trevor Spiteri  <address@hidden>  (tiny change)
+
+       Fix cursor column positioning on Grep hits
+
+       * lisp/progmodes/grep.el (grep-match-face): Move before first
+       use, to avoid byte-compilation warning.
+       (grep-regexp-alist): Don't quote grep-match-face.  (Bug#34068)
+
+2019-01-18  Eli Zaretskii  <address@hidden>
+
+       Fix a typo in ELisp manual
+
+       * doc/lispref/nonascii.texi (Converting Representations): Fix
+       inconsistency between @defun and the argument description of
+       'byte-to-string'.  (Bug#34119)
+
+2019-01-15  Alan Third  <address@hidden>
+
+       Prevent redrawing if frame is garbaged
+
+       * src/nsterm.m ([EmacsView viewWillDraw]): Cancel drawing if the frame
+       has been garbaged.
+       * src/xdisp.c (expose_window_tree, expose_frame): Remove NS only
+       exceptions.
+
+2019-01-14  Eli Zaretskii  <address@hidden>
+
+       Attempt to fix hangs on MS-Windows due to C-g
+
+       * src/w32uniscribe.c (uniscribe_otf_capability): Set
+       inhibit-quit around calls to otf_features, because the latter
+       cons Lisp data structures while we are in a critical section.
+       * src/xdisp.c (ALLOCATE_HDC) [HAVE_NTGUI]: Set inhibit-quit.
+       (RELEASE_HDC) [HAVE_NTGUI]: Restore inhibit-quit.
+       (OPTIONAL_HDC, DECLARE_HDC): Remove macros, their job is now
+       done by ALLOCATE_HDC and by a single #ifdef.
+       (draw_glyphs): Adapt to the above changes in macros.
+       (Bug#34059)
+
+2019-01-13  Eli Zaretskii  <address@hidden>
+
+       Fix Calc graph output on MS-Windows
+
+       The previous code relied on "pgnuplot" executable, which is
+       no longer provided with Gnuplot 5.x.
+       * lisp/calc/calc.el (calc-gnuplot-name): Set to "pgnuplot" on
+       MS-Windows only if such an executable exists.
+       * lisp/calc/calc-graph.el (calc-graph-w32-p): New defsubst.
+       (calc-graph-plot, calc-graph-command, calc-gnuplot-command)
+       (calc-graph-init): Call calc-graph-w32-p wherever we need to
+       do something special for invoking gnuplot on MS-Windows,
+       instead of comparing against calc-gnuplot-name.
+       (calc-graph-plot): Set the terminal to "qt" on MS-Windows when
+       pgnuplot.exe is not available.
+       (calc-graph-kill): Delete the temporary files only after
+       killing the gnuplot process, otherwise the deletion might fail
+       on MS-Windows because the files are still in use.
+
+2019-01-13  Eli Zaretskii  <address@hidden>
+
+       Fix a minor mistake in ELisp manual
+
+       * doc/lispref/buffers.texi (Modification Time): Fix
+       documentation of 'visited-file-modtime'.  (Bug#34055)
+
+2019-01-12  Stephen Berman  <address@hidden>
+
+       * etc/tutorials/TUTORIAL: Fix typo (bug#34049)
+
+2019-01-12  Devon Sean McCullough  <address@hidden>
+
+       Fix UI of Buffer-menu
+
+       * lisp/buff-menu.el (Buffer-menu-execute): Don't remove
+       entries of buffers whose killing the user didn't confirm.
+       (Bug#33669)
+
+2019-01-12  Philip K  <address@hidden>  (tiny change)
+
+       Reinitialize ispell-really-enchant when changing the speller
+
+       * lisp/textmodes/ispell.el (ispell-check-version): Reset also
+       ispell-really-enchant.  (Bug#34019)
+
+2019-01-07  Leo Liu  <address@hidden>
+
+       Speed up loading css-mode
+
+       lisp/textmodes/css-mode.el: Remove (require 'eww) which is redundant
+       and slow.  (Bug#33939)
+
+2019-01-07  Michael Albinus  <address@hidden>
+
+       Adapt filenotify-tests for emba
+
+       * .gitlab-ci.yml (test): Add EMACS_EMBA_CI variable.
+
+       * test/lisp/filenotify-tests.el (file-notify-test03-events)
+       (file-notify-test05-file-validity)
+       (file-notify-test06-dir-validity)
+       (file-notify-test07-many-events)
+       (file-notify-test09-watched-file-in-watched-dir): Adapt tests for emba.
+
+2019-01-07  Nicolas Petton  <address@hidden>
+
+       Bump Emacs version to 26.1.91
+
+       * README:
+       * configure.ac:
+       * msdos/sed2v2.inp:
+       * nt/README.W32: Bump Emacs version to 26.1.91.
+
+2019-01-07  Nicolas Petton  <address@hidden>
+
+       * etc/AUTHORS: Update.
+
+2019-01-07  Leo Liu  <address@hidden>
+
+       * lisp/textmodes/mhtml-mode.el: Avoid loading flyspell.  (Bug#33939)
+
+2019-01-07  Paul Eggert  <address@hidden>
+
+       Improve GC+Cairo workaround
+
+       Suggested by Eli Zaretskii (Bug#20890#31).
+       * src/font.h (font_data_structures_may_be_ill_formed): New function.
+       * src/ftfont.c (ftfont_close):
+       * src/ftcrfont.c (ftcrfont_close): Use it.
+
+       (cherry picked from commit d02fd482fbeaf6ed551e78223b538495cb0c3541)
+
+2019-01-07  Paul Eggert  <address@hidden>
+
+       Work around GC+Cairo bug
+
+       Workaround suggested by Robert Pluim (Bug#20890#13).
+       * src/ftfont.c (ftfont_close) [USE_CAIRO]:
+       Do nothing if GC is in progress.
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Improve commentary in font.h
+
+       * src/font.h (struct font, struct font_driver): Fix typos and
+       wording in comments.  Document all driver methods.
+
+2019-01-07  Martin Rudalics  <address@hidden>
+
+       Fix definition of Qwindow_point_insertion_type (Bug#33871)
+
+       * src/window.c (Qwindow_point_insertion_type): Fix definition
+       (Bug#33871).
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Improve documentation of 'server-name'
+
+       * doc/emacs/misc.texi (Emacs Server, TCP Emacs server)
+       (emacsclient Options):
+       * lisp/server.el (server-name):  Document the usage of
+       'server-name' to specify the server file as an absolute file
+       name.  Do not merge to master.  (Bug#33934)
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Update Unicode copyright notice
+
+       * admin/unidata/copyright.html: Updated version from the
+       Unicode Consortium's site.
+
+2019-01-07  Michael Albinus  <address@hidden>
+
+       Handle quoted file names in filenotify.el
+
+       * lisp/filenotify.el (file-notify-add-watch): Do not save
+       quoted file names in `file-notify-descriptors'.
+
+       * test/lisp/files-tests.el
+       (files-file-name-non-special-notify-handlers): Do not expect
+       to fail.
+
+2019-01-07  Paul Eggert  <address@hidden>
+
+       Fix copyright years by hand
+
+       These are dates that admin/update-copyright did not update, or
+       updated incorrectly.
+
+2019-01-07  Paul Eggert  <address@hidden>
+
+       Update copyright year to 2019
+
+       Run 'TZ=UTC0 admin/update-copyright $(git ls-files)'.
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       * doc/man/emacs.1.in: Fix value of default frame height.  (Bug#33921)
+
+2019-01-07  Martin Rudalics  <address@hidden>
+
+       In user manual fix value of default frame height (Bug#33921)
+
+       * doc/emacs/cmdargs.texi (Window Size X): Fix value of default
+       frame height (Bug#33921).
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Improve documentation of 'file-local-name' and related APIs
+
+       * doc/lispref/files.texi (Unique File Names)
+       (Magic File Names, File Name Expansion): Improve documentation
+       of the "local part" of a remote file name.
+       * doc/lispref/processes.texi (Synchronous Processes)
+       (Asynchronous Processes): State explicitly that program and
+       file names passed to functions that start remote processes
+       need to be relative or obtained by 'file-local-name'.
+
+       * lisp/files.el (file-local-name):
+       * lisp/simple.el (start-file-process, process-file): Improve
+       the documentation of the "local part" of a remote file name,
+       and its use in APIs that start remote processes.
+
+2019-01-07  Michael Albinus  <address@hidden>
+
+       Fix Bug#31704.  Do not merge
+
+       * lisp/net/tramp.el (tramp-eshell-directory-change):
+       Use `path-separator' as it does eshell.  (Bug#31704)
+
+2019-01-07  Michael Albinus  <address@hidden>
+
+       Fix Bug#31704.  Do not merge
+
+       * lisp/eshell/esh-proc.el (eshell-gather-process-output): Do not
+       let `expand-file-name' prefix remote file names with MS Windows
+       volume letter.
+
+       * lisp/net/tramp.el (tramp-eshell-directory-change):
+       Use `path-separator' as it does eshell.  (Bug#31704)
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       * lisp/files.el (cd): Fix last change.  (Bug#33791)
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Fix remote directories in Eshell on MS-Windows
+
+       * lisp/files.el (cd): Support remote directory names on
+       MS-Windows.  (Bug#33791)
+
+2019-01-07  Drew Adams  <address@hidden>
+
+       Fix :type 'group' in defcustom
+
+       * lisp/wid-edit.el (group): Fix the :format spec.  (Bug#33566)
+
+2019-01-07  Alan Third  <address@hidden>
+
+       Fix NS fringe bitmap drawing bug (bug#33864)
+
+       * src/nsterm.m (ns_draw_fringe_bitmap): Check the rectangle to clear
+       correctly.
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Fix commentary in dispnew.c
+
+       * src/dispnew.c (buffer_posn_from_coords): Fix inaccuracies in
+       the commentary.
+
+2019-01-07  Paul Eggert  <address@hidden>
+
+       Improve accept-process-process doc
+
+       * doc/lispref/processes.texi (Accepting Output):
+       * src/process.c (Faccept_process_output):
+       Document that (accept-process-output P) can return non-nil
+       even after P has exited, and that it can return nil even if P
+       is still running (Bug#33839).
+
+2019-01-07  Stephen Leake  <address@hidden>
+
+       Fix a simple bug in display-buffer-use-some-frame
+
+       * lisp/window.el (display-buffer-use-some-frame): Simplify the
+       predicate, fix TYPE arg to window--display-buffer.
+
+2019-01-07  Michael Albinus  <address@hidden>
+
+       Clarify thread switching while waiting for process output
+
+       * doc/lispref/threads.texi (Threads): Clarify, that thread
+       switching happens when waiting for process output from
+       asynchronous processes.
+
+2019-01-07  Charles A. Roelli  <address@hidden>
+
+       Improve process doc. with respect to handling of large input (Bug#33191)
+
+       * src/process.c (Fprocess_send_region, Fprocess_send_string):
+       Document that process input longer than the process input
+       buffer may be split into bunches.  Remove an outdated
+       reference to a 500 character split boundary.
+       * doc/lispref/processes.texi (Asynchronous Processes): Remove
+       mention of "stray character injections" in PTY processes.  See
+       also the comment about ICANON in src/sysdep.c, function
+       child_setup_tty.
+
+2019-01-07  Terrence Brannon  <address@hidden>
+
+       Minor copyedits in landmark.el
+
+       * lisp/obsolete/landmark.el: Fix author's email and commentary.
+
+2019-01-07  Alan Mackenzie  <address@hidden>
+
+       Check result from c-backward-token-2 to avoid infinite loop
+
+       This fixes bug #33784.
+
+       * lisp/progmodes/cc-fonts.el (c-get-fontification-context): While 
moving back
+       over enclosing parentheses, check that c-backward-token-2 actually 
moves.
+
+2019-01-07  Paul Eggert  <address@hidden>
+
+       cl-make-random-state was not copying its arg
+
+       Problem reported by Xu Chunyang (Bug#33731).
+       * lisp/emacs-lisp/cl-extra.el (cl-make-random-state):
+       Use copy-sequence, not copy-tree, so that the record is copied.
+       * test/lisp/emacs-lisp/cl-extra-tests.el:
+       (cl-extra-test-cl-make-random-state): New test.
+
+2019-01-07  Glenn Morris  <address@hidden>
+
+       Skip a vc-bzr test if run as root
+
+       * test/lisp/vc/vc-bzr-tests.el (vc-bzr-test-faulty-bzr-autoloads):
+       Skip this test when run as root.  This works around a race
+       condition in root-specific code in vc-mode-line when deleting a file.
+
+2019-01-07  Chris Feng  <address@hidden>
+
+       Backport: Handle unread-command-events consistently (bug#23980)
+
+       * src/keyboard.c (read_char): Events put into `unread-command-events'
+       with the form (t . EVENT) should always have the t stripped when read
+       out.
+       * test/src/keyboard-tests.el: New tests for `unread-command-events'.
+
+       (cherry picked from commit 1f3f4b1296613b8cdc0632a68fde86e86ddad866)
+
+2019-01-07  Glenn Morris  <address@hidden>
+
+       Restrict downcasing in elisp xref tests (bug#25534)
+
+       The tests happen to not fail at the moment because find-library-name
+       now has an extra feature, find-library--from-load-history, which
+       happens to do a case-insensitive regexp match; but still it seems
+       better not to rely on this.
+
+       * test/lisp/progmodes/elisp-mode-tests.el (xref--case-insensitive):
+       New variable.
+       (xref-elisp-test-run, emacs-test-dir): Only downcase if the
+       filesystem seems to be case-insensitive.
+
+2019-01-07  Rob Browning  <address@hidden>
+
+       Avoid test failures if directory name looks like a regexp
+
+       Taken from <https://sources.debian.org/patches/emacs/1:26.1+1-1>
+       * test/lisp/ibuffer-tests.el (ibuffer-filter-inclusion-3):
+       * test/lisp/net/tramp-tests.el (tramp-test42-remote-load-path):
+       Regexp-quote file names to avoid failures with directory names
+       of the form "build/emacs-i87jK3/emacs-26.1+1/...".
+
+2019-01-07  Michael Albinus  <address@hidden>
+
+       Fix Bug#33524
+
+       * lisp/progmodes/flymake-proc.el
+       (flymake-proc-create-temp-with-folder-structure):
+       Unquote file-name.  (Bug#33524)
+
+2019-01-07  Glenn Morris  <address@hidden>
+
+       * doc/lispintro/emacs-lisp-intro.texi (Finding More): Fix xref.
+
+2019-01-07  Paul Eggert  <address@hidden>
+
+       More porting to GCC 8 of --enable-gcc-warnings
+
+       Backport from master.
+       I ran into this when building Emacs 26 with GCC 8 on Fedora 29 x86.
+       * lwlib/lwlib-Xaw.h (xaw_update_one_value, xaw_popup_menu):
+       * lwlib/lwlib-Xlw.h (xlw_update_one_value, xlw_pop_instance):
+       * lwlib/lwlib.h (lw_allow_resizing, lw_set_main_areas) [!USE_MOTIF]:
+       No longer const.
+       * src/emacs-module.c: Ignore -Wcast-function-type.
+
+2019-01-07  Glenn Morris  <address@hidden>
+
+       Fix an epg test for recent GnuPG versions (bug#33439)
+
+       * test/lisp/epg-tests.el (epg-decrypt-1):
+       Tell recent GnuPG (e.g. 2.2.11) not to worry about missing MDC.
+
+2019-01-07  Robert Pluim  <address@hidden>
+
+       Document font structure layout constraints
+
+       This has to be the same as in src/ftcrfont.c and src/ftfont.c
+
+       * src/xftfont.c (struct xftfont_info): Document layout constraints.
+
+2019-01-07  Robert Pluim  <address@hidden>
+
+       Document font structure layout constraints
+
+       The layout of the initial members of ftcrfont_info must match
+       ftfont_info
+
+       * src/ftcrfont.c (struct ftcrfont_info): Likewise.
+
+       * src/ftfont.c (struct ftfont_info): Document layout constraints.
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Fix display of line numbers in empty lines beyond EOB
+
+       * src/xdisp.c (maybe_produce_line_number): When the current
+       line is at EOB, use the 'line-number-current-line' face only
+       on that single line, but not on the rest of empty lines beyond
+       EOB.  (Bug#33732)
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Fix redisplay when a window's scroll bar or fringes are changed
+
+       * src/window.c (set_window_fringes, set_window_scroll_bars):
+       Set windows_or_buffers_changed flag to cause immediate
+       thorough redisplay of a window when scroll bars or fringes are
+       changed.  (Bug#33694)
+
+2019-01-07  Martin Rudalics  <address@hidden>
+
+       Tiny markup fix in Elisp manual
+
+       * doc/lispref/lists.texi (Building Lists): Use '@var' instead
+       of '@code' for argument.
+
+2019-01-07  Alan Mackenzie  <address@hidden>
+
+       CC Mode: stop extra parens on expression causing false fontification as 
type
+
+       * lisp/progmodes/cc-fonts.el (c-get-fontification-context): recognize
+       arithmetic operator followed by several open parentheses, not just one, 
as not
+       being an argument list.
+
+2019-01-07  Ari Roponen  <address@hidden>
+
+       Fix cairo scrolling for side-by-side windows
+
+       Backport: Fixes Bug#33442.
+
+       * src/xterm.c (x_scroll_run) [USE_CAIRO]: Fix scrolling for
+       side-by-side split windows.  (Bug#31288)
+
+       (cherry picked from commit 6e362a32bc9d21f73a0f29ca6f45481edeea6f29)
+
+2019-01-07  Alan Mackenzie  <address@hidden>
+
+       CC Mode: stop wrongly recognizing "func(a * 9)" as "pointer to type a"
+
+       * lisp/progmodes/cc-engine.el (c-forward-decl-or-cast-1): When testing 
for an
+       identifier after "a *", on failure additionally check for a digit, 
setting a
+       new flag variable got-number if one is found.  In the test for CASE 18, 
check
+       this flag.
+
+2019-01-07  Stefan Monnier  <address@hidden>
+
+       * lisp/emacs-lisp/cursor-sensor.el: Add motivation
+
+2019-01-07  Raimon Grau  <address@hidden>
+
+       Guard occur against an undefined orig-line
+
+       * lisp/replace.el (occur-engine): Avoid inserting the current line if
+       orig-line is nil.  This happens, for example, when reverting an occur
+       buffer with `list-matching-lines-jump-to-current-line' set to t.
+       (Bug#33476)
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Indexing followup to recent changes
+
+       * doc/lispref/text.texi (Special Properties): Index
+       'cursor-sensor-inhibit'.  (Bug#33664)
+
+2019-01-07  Stefan Monnier  <address@hidden>
+
+       Improve documentation of cursor-sensor.el (bug#33664)
+
+       * doc/lispref/text.texi (Special Properties): Mention 
cursor-sensor-inhibit.
+       * lisp/emacs-lisp/cursor-sensor.el (Commentary): Add cursor-sensor-mode.
+       (cursor-sensor-inhibit): Add docstring.
+
+2019-01-07  Stefan Monnier  <address@hidden>
+
+       * doc/lispref/commands.texi (Adjusting Point): Bug#33662
+
+       Tweak text to clarify intangibility.
+
+2019-01-07  Michael Albinus  <address@hidden>
+
+       Tramp multi-hop methods must be inline
+
+       * doc/misc/tramp.texi (Ad-hoc multi-hops): Involved methods must
+       be inline methods.
+
+2019-01-07  Ari Roponen  <address@hidden>
+
+       Fix scaling problem in Cairo builds
+
+       * src/xterm.c (x_begin_cr_clip) [USE_GTK]:
+       (x_update_begin) [USE_CAIRO && USE_GTK]: Support scaling.
+       (Bug#33442)
+
+2019-01-07  Juri Linkov  <address@hidden>
+
+       * lisp/simple.el (next-line-or-history-element): Use current-column
+
+       in all position calculations.
+       (previous-line-or-history-element): Idem.  (Bug#33640)
+
+2019-01-07  Martin Rudalics  <address@hidden>
+
+       A few further fixes of window internals description
+
+       * doc/lispref/internals.texi (Window Internals): Add a few
+       more items and clarify description of some others.
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Revert "Revert "Fix infloop in GC mark_kboards""
+
+       This reverts commit c418c85617babbe7b63730fefb71e2c87a0141af.
+       This reinstates the original fix, as it had nothing to do
+       with the behavior reported in bug#33571, which seems to be
+       the expected behavior.
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Revert "Fix infloop in GC mark_kboards"
+
+       This reverts commit af914fc26db273d8788e7efa57c569f0f778d037,
+       since it caused unintended adverse effects on echoing of keys.
+       (Bug#33571)
+
+2019-01-07  Glenn Morris  <address@hidden>
+
+       * lisp/emacs-lisp/subr-x.el (if-let, when-let): Doc fix: active voice.
+
+2019-01-07  Paul Eggert  <address@hidden>
+
+       Fix infloop in GC mark_kboards
+
+       Do not merge to master, as I have a more systematic fix there.
+       * src/keyboard.c (mark_kboards): Fix infloop (Bug#33547).
+
+2019-01-07  Alan Third  <address@hidden>
+
+       Fix macOS run-time feature check
+
+       * src/nsterm.m (x_set_parent_frame) [NS_IMPL_COCOA]: Fix run-time
+       feature check.
+
+2019-01-07  Stefan Monnier  <address@hidden>
+
+       * etc/NEWS-*: Fix capitalization of "Emacs"
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Fix "M-x man" when there's no 'man' program on PATH
+
+       * lisp/man.el (Man-bgproc-sentinel): Make sure the process
+       buffer is not read-only when inserting a message into it.
+       (Bug#33510)
+
+2019-01-07  Paul Eggert  <address@hidden>
+
+       Fix core dump in dbus-message-internal
+
+       Backport from master.
+       * src/dbusbind.c (Fdbus_message_internal):
+       Don’t go past array end (Bug#33530).
+
+2019-01-07  Michael Albinus  <address@hidden>
+
+       * doc/misc/dbus.texi (Type Conversion): Fix typo.  (Bug#33551)
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Improve documentation of gdb-mi.el
+
+       * lisp/progmodes/gdb-mi.el (gdb-show-changed-values)
+       (gdb-max-children): Doc fixes.
+
+       * doc/emacs/building.texi (Source Buffers, Stack Buffer)
+       (GDB User Interface Layout): Mention some additional
+       customizable variables.  (Bug#33548)
+
+2019-01-07  Thomas Fitzsimmons  <address@hidden>
+
+       LDAP: Set process-connection-type to t on Darwin
+
+       * lisp/net/ldap.el (ldap-search-internal): Set
+       process-connection-type to t on Darwin.  Do not merge to
+       master.  (Bug#33050)
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Fix a typo in a doc string
+
+       * lisp/emacs-lisp/map-ynp.el (read-answer-short): Fix typo.
+       (Bug#33528)
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Minor markup fix in frames.texi
+
+       * doc/lispref/frames.texi (Frame Layout): Fix markup of @table
+       entries.  (Bug#33531)
+
+2019-01-07  Glenn Morris  <address@hidden>
+
+       * lisp/net/trampver.el (customize-package-emacs-version-alist):
+       Add 2.3.3.
+
+       * lisp/mh-e/mh-e.el (customize-package-emacs-version-alist): Additions.
+
+2019-01-07  Glenn Morris  <address@hidden>
+
+       * lisp/emacs-lisp/map-ynp.el (map-y-or-n-p): Pass format to message.
+
+2019-01-07  Robert Pluim  <address@hidden>
+
+       Don't call xwidget functions until GTK has been initialized
+
+       Follow up fix to Bug#33294.
+
+       * src/gtkutil.c: Define xg_gtk_initialized.
+       (xg_initialize): Set it when GTK has finished initializing.
+
+       * src/gtkutil.h: Declare xg_gtk_initialized.
+
+       * src/xwidget.c (Fmake_xwidget): Error out if GTK has not been
+       initialized.
+       (xwidget_init_view): Likewise.
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Improve documentation of Ediff wordwise commands
+
+       * lisp/vc/ediff.el (ediff-windows-wordwise)
+       (ediff-windows-linewise, ediff-regions-wordwise): Update and
+       clarify the doc strings.
+
+       * doc/misc/ediff.texi (Major Entry Points): Update and clarify
+       the documentation of 'ediff-windows-wordwise' and
+       'ediff-regions-wordwise'.  See the discussion starting at
+       https://lists.gnu.org/archive/html/help-gnu-emacs/2018-11/msg00197.html
+       for the details.
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Support Hunspell 1.7.0 in ispell.el
+
+       * lisp/textmodes/ispell.el
+       (ispell-find-hunspell-dictionaries): Invoke Hunspell with an
+       additional command-line argument, to work around a misfeature
+       in Hunspell 1.7.0 that prevents it from reporting the loaded
+       dictionary.  (Bug#33493)
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Avoid clearing echo-area message by auto-save-visited-file-name
+
+       * lisp/emacs-lisp/map-ynp.el (map-y-or-n-p): Record the
+       previous echo-area message, if any, and restore it before
+       exiting.  (Bug#33490)
+
+2019-01-07  Alan Third  <address@hidden>
+
+       Set tooltip text color (bug#33452)
+
+
+       * src/nsmenu.m: ([EmacsTooltip init]): Set text color to black.
+
+2019-01-07  Alan Third  <address@hidden>
+
+       Fix more drawing bugs in NS port (bug#32932)
+
+       * src/nsterm.m (ns_row_rect): New function.
+       (ns_clip_to_row): Remove function.
+       (ns_copy_bits): Fix mistake.
+       (ns_shift_glyphs_for_insert): Mark the frame as dirty instead of
+       directly copying.
+       (ns_draw_fringe_bitmap): Stop using ns_clip_to_row.
+       (ns_draw_window_cursor): Stop using ns_clip_to_row and perform a
+       display when not in redisplay.
+       (ns_update_window_begin): Remove redundant code that never executes.
+       ([EmacsView drawRect:]): Show the rectangle being exposed in NSTRACE.
+       * src/xdisp.c (expose_window_tree) [HAVE_NS]:
+       (expose_frame) [HAVE_NS]: Redraw even if the frame is garbaged.
+
+2019-01-07  Alan Mackenzie  <address@hidden>
+
+       Fix bug #33416, where typing a ) in a comment at EOB caused a loop (CC 
Mode).
+
+       * lisp/progmodes/cc-mode.el (c-fl-decl-start): A c-forward-syntactic-ws 
leaves
+       point inside whitespace when moving over a comment at EOB which has no
+       terminating LF.  Check this possibility and correct for it.
+
+2019-01-07  Ulrich Müller  <address@hidden>
+
+       Update the calc units table
+
+       On 2018-11-16, the 26th meeting of the General Conference on Weights
+       and Measures (CGPM) has redefined the International System of Units by
+       adopting fixed values for the Planck constant, the elementary charge,
+       the Boltzmann constant, and the Avogadro constant:
+       https://www.bipm.org/utils/en/pdf/CGPM/Draft-Resolution-A-EN.pdf
+
+       * lisp/calc/calc-units.el (math-standard-units): Update according
+       to redefinition of the SI in 2018.  (Bug#33412)
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Improve indexing in the ELisp manual
+
+       * doc/lispref/control.texi (Control Structures, Sequencing)
+       (Conditionals, Iteration, Catch and Throw, Handling Errors)
+       (Cleanups):
+       * doc/lispref/eval.texi (Self-Evaluating Forms)
+       (Symbol Forms, Function Forms, Macro Forms, Special Forms)
+       (Quoting, Backquote): Add index entries that begin with
+       "forms".  (Bug#33440)
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       More Symbola-related extensions for default fontset
+
+       * lisp/international/fontset.el (setup-default-fontset): Add
+       few more blocks of symbols and punctuation supported by latest
+       Symbola.
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Better support for display of U+1F900..U+1F9FF block
+
+       * lisp/international/fontset.el (setup-default-fontset): Add
+       the [#x1F900..#x1F9FF] block to those supported by Symbola.
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Improve documentation of 'edit-abbrevs-mode'
+
+       * lisp/abbrev.el (edit-abbrevs-mode): Refer to 'edit-abbrevs'
+       for more detailed usage information.  (Bug#33443)
+       (edit-abbrevs): Doc fix.
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Improve documentation of 'dired-do-compress'
+
+       * lisp/dired-aux.el (dired-do-compress): Describe in the doc
+       string the effect on directories and on compressed archive.
+       (Bug#33450)
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Improve doc string and display of 'describe-character'
+
+       * lisp/descr-text.el (describe-char): Explain how does the
+       function obtain the various data about the character.  Don't
+       display "preferred" before "charset": it tends to confuse
+       people.
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       * etc/NEWS: Clarify what 'Z' does in Dired.  (Bug#33450)
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Update the docs of object internals
+
+       * doc/lispref/internals.texi (Buffer Internals)
+       (Window Internals, Process Internals): Update the descriptions
+       of Lisp objects.
+
+2019-01-07  Stephen Berman  <address@hidden>
+
+       Fix two Edebug defcustoms (bug#33428)
+
+       * lisp/emacs-lisp/edebug.el (edebug-print-length)
+       (edebug-print-level): Fix customization type to allow setting
+       the documented valid value nil via the Customize interface.
+
+2019-01-07  Michael Albinus  <address@hidden>
+
+       Fix Bug#33141
+
+       * lisp/net/tramp.el (tramp-make-tramp-file-name): Avoid check for
+       empty method with simplified `tramp-syntax'.  (Bug#33141)
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Improve documentation of the window tree
+
+       * doc/lispref/windows.texi (Windows and Frames): More accurate
+       wording regarding the relation of a mini-window to its frame's
+       window tree.
+
+       * src/window.h (struct window): Improve commentary to some
+       fields.
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Fix window scrolling on TTY frames when there's no mode line
+
+       * src/window.c (window_internal_height): Remove tests for
+       next, prev, and parent pointers, as they are unrelated to
+       whether a window has a mode line.  (Bug#33363)
+
+2019-01-07  Eli Zaretskii  <address@hidden>
+
+       Fix decoding XML files encoded in ISO-8859
+
+       * lisp/international/mule.el (sgml-xml-auto-coding-function):
+       Avoid signaling an error from coding-system-equal when the XML
+       encoding tag specifies an encoding whose type is 'charset'.
+       (Bug#33429)
+
+2019-01-07  Nicolas Petton  <address@hidden>
+
+       * etc/AUTHORS: Update.
+
 2018-11-18  Martin Rudalics  <address@hidden>
 
        Fix description of some window hooks
@@ -63448,14 +65091,14 @@
 
 This file records repository revisions from
 commit 9d56a21e6a696ad19ac65c4b405aeca44785884a (exclusive) to
-commit 72525076996cd709086b1afb47ab0d095322e9b7 (inclusive).
+commit 85829363f728c410e33ffdc3839202977b2115cc (inclusive).
 See ChangeLog.1 for earlier changes.
 
 ;; Local Variables:
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 2015-2018 Free Software Foundation, Inc.
+  Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/GNUmakefile b/GNUmakefile
index 0c1a757..a67624e 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -1,6 +1,6 @@
 # Build Emacs from a fresh tarball or version-control checkout.
 
-# Copyright (C) 2011-2018 Free Software Foundation, Inc.
+# Copyright (C) 2011-2019 Free Software Foundation, Inc.
 #
 # This file is part of GNU Emacs.
 #
@@ -27,10 +27,10 @@
 # newly-built Makefile.  If the source tree is already configured,
 # this file defers to the existing Makefile.
 
-# If you are using a non-GNU 'make', or if you want non-default build
-# options, or if you want to build in an out-of-source tree, please
-# run "configure" by hand.  But run autogen.sh first, if the source
-# was checked out directly from the repository.
+# If you want non-default build options, or if you want to build in an
+# out-of-source tree, you should run 'configure' before running 'make'.
+# But run 'autogen.sh' first, if the source was checked out directly
+# from the repository.
 
 # If a Makefile already exists, just use it.
 
diff --git a/INSTALL b/INSTALL
index 0c56fff..8022385 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,5 @@
 GNU Emacs Installation Guide
-Copyright (C) 1992, 1994, 1996-1997, 2000-2018 Free Software Foundation,
+Copyright (C) 1992, 1994, 1996-1997, 2000-2019 Free Software Foundation,
 Inc.
 See the end of the file for license conditions.
 
@@ -318,6 +318,12 @@ features enabled, you can combine --without-all with 
--with-FEATURE.
 For example, you can use --without-all --without-x --with-dbus to
 build with D-Bus support and nothing more.
 
+Use --with-gnutls=ifavailable to use GnuTLS if available but go ahead
+and build without it if not available.  This overrides Emacs's default
+behavior of refusing to build if GnuTLS is absent.  When X11 support
+is enabled, the libraries for gif, jpeg, png, tiff, and xpm are in the
+same strongly-recommended category as GnuTLS, and have similar options.
+
 Use --with-wide-int to implement Emacs values with the type 'long long',
 even on hosts where a narrower type would do.  With this option, on a
 typical 32-bit host, Emacs integers have 62 bits instead of 30.
diff --git a/INSTALL.REPO b/INSTALL.REPO
index caa46b4..6dca9dd 100644
--- a/INSTALL.REPO
+++ b/INSTALL.REPO
@@ -76,7 +76,7 @@ never platform-specific.
 
 
 
-Copyright (C) 2002-2018 Free Software Foundation, Inc.
+Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/Makefile.in b/Makefile.in
index f0b2b66..88cbb3d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,6 +1,6 @@
 ### @configure_input@
 
-# Copyright (C) 1992-2018 Free Software Foundation, Inc.
+# Copyright (C) 1992-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
@@ -66,6 +66,8 @@
 
 SHELL = @SHELL@
 
address@hidden@
+
 # This only matters when inheriting a CDPATH not starting with the
 # current directory.
 CDPATH=
@@ -318,7 +320,7 @@ SUBDIR_MAKEFILES = $(patsubst 
${srcdir}/%,%,${SUBDIR_MAKEFILES_IN:.in=})
 # Non-makefile files created by config.status.
 CONFIG_STATUS_FILES_IN = \
  ${srcdir}/nt/emacs.rc.in ${srcdir}/nt/emacsclient.rc.in \
- ${srcdir}/doc/man/emacs.1.in
+ ${srcdir}/doc/man/emacs.1.in ${srcdir}/src/emacs-module.h.in
 
 # Subdirectories to install, and where they'll go.  lib-src's and nt's
 # makefiles know how to install them, so we don't do that here.
@@ -491,6 +493,9 @@ install-arch-dep: src install-arch-indep install-etcdoc 
install-$(NTDIR)
        $(MAKE) -C lib-src install
 ifeq (${ns_self_contained},no)
        ${INSTALL_PROGRAM} $(INSTALL_STRIP) src/emacs${EXEEXT} 
"$(DESTDIR)${bindir}/$(EMACSFULL)"
+ifeq (${DUMPING},pdumper)
+       ${INSTALL_DATA} src/emacs.pdmp 
"$(DESTDIR)${libexecdir}/emacs/${version}/${configuration}"/emacs.pdmp
+endif
        -chmod 755 "$(DESTDIR)${bindir}/$(EMACSFULL)"
 ifndef NO_BIN_LINK
        rm -f "$(DESTDIR)${bindir}/$(EMACS)"
@@ -864,7 +869,7 @@ top_bootclean=\
 top_distclean=\
        ${top_bootclean}; \
        rm -f config.status config.log~ \
-         Makefile lib/gnulib.mk ${SUBDIR_MAKEFILES}
+         Makefile makefile lib/gnulib.mk ${SUBDIR_MAKEFILES}
 
 distclean_dirs = $(clean_dirs) leim lisp
 
@@ -939,7 +944,9 @@ extraclean: $(extraclean_dirs:=_extraclean)
 # The src subdir knows how to do the right thing
 # even when the build directory and source dir are different.
 .PHONY: TAGS tags
-TAGS tags: lib lib-src src
+# FIXME: We used to include `src` in the dependencies, not sure why.
+# I removed it because it causes `make tags` to build Emacs.
+TAGS tags: lib lib-src # src
        $(MAKE) -C src tags
 
 .PHONY: have-tests
diff --git a/README b/README
index 25adcfd..7236816 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 
diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES
index 0e75b4d..ea99d50 100644
--- a/admin/CPP-DEFINES
+++ b/admin/CPP-DEFINES
@@ -104,7 +104,6 @@ HAVE_ALLOCA_H
 HAVE_ALSA
 HAVE_BDFFONT
 HAVE_BOXES
-HAVE_C99_STRTOLD
 HAVE_CFMAKERAW
 HAVE_CFSETSPEED
 HAVE_CLOCK_GETTIME
diff --git a/admin/ChangeLog.1 b/admin/ChangeLog.1
index c318750..6889407 100644
--- a/admin/ChangeLog.1
+++ b/admin/ChangeLog.1
@@ -2577,7 +2577,7 @@
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/admin/README b/admin/README
index 58e3c5b..54b79ab 100644
--- a/admin/README
+++ b/admin/README
@@ -1,4 +1,4 @@
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 
diff --git a/admin/admin.el b/admin/admin.el
index 3fc50af..030bd54 100644
--- a/admin/admin.el
+++ b/admin/admin.el
@@ -1,6 +1,6 @@
 ;;; admin.el --- utilities for Emacs administration
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -138,13 +138,16 @@ Root must be the root of an Emacs source tree."
                               (if (eq 2 (length newversion)) 0 1))))
          (majorbump (and oldversion (not (equal oldmajor newmajor))))
          (minorbump (and oldversion (not majorbump)
-                         (not (equal (cadr oldversion) (cadr newversion)))))
+                         (or (not (equal (cadr oldversion)
+                                         (cadr newversion)))
+                             (and (equal (cadr oldversion) (cadr newversion))
+                                  (equal (nth 2 newversion) 50)))))
          (newsfile (expand-file-name "etc/NEWS" root))
          (oldnewsfile (expand-file-name (format "etc/NEWS.%s" oldmajor) root)))
     (unless (> (length newversion) 2)   ; pretest or release candidate?
       (with-temp-buffer
         (insert-file-contents newsfile)
-        (if (re-search-forward "^\\(+++ *\\|--- *\\)$" nil t)
+        (if (re-search-forward "^\\(\\+\\+\\+ *\\|--- *\\)$" nil t)
             (display-warning 'admin
                              "NEWS file still contains temporary markup.
 Documentation changes might not have been completed!"))))
@@ -696,6 +699,7 @@ style=\"text-align:left\">")
     (if (file-directory-p stem)
        (delete-directory stem t))
     (make-directory stem)
+    (setq stem (file-name-as-directory stem))
     (copy-file "../doc/misc/texinfo.tex" stem)
     (unless (equal type "emacs")
       (copy-file "../doc/emacs/emacsver.texi" stem)
@@ -718,7 +722,7 @@ style=\"text-align:left\">")
          (setq ats t)
          (message "Unexpanded: %s" (match-string 0)))
        (if ats (error "Unexpanded configure variables in Makefile?")))
-      (write-region nil nil (expand-file-name (format "%s/Makefile" stem))
+      (write-region nil nil (expand-file-name (format "%sMakefile" stem))
                    nil 'silent))
     (call-process "tar" nil nil nil "-cf" tarfile stem)
     (delete-directory stem t)
diff --git a/admin/alloc-colors.c b/admin/alloc-colors.c
index e1a344b..5f47acc 100644
--- a/admin/alloc-colors.c
+++ b/admin/alloc-colors.c
@@ -1,6 +1,6 @@
 /* Allocate X colors.  Used for testing with dense colormaps.
 
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/admin/authors.el b/admin/authors.el
index 1ff98fa..a3f8bdd 100644
--- a/admin/authors.el
+++ b/admin/authors.el
@@ -1,7 +1,7 @@
 
 ;;; authors.el --- utility for maintaining Emacs's AUTHORS file
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Gerd Moellmann <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/admin/automerge b/admin/automerge
index 8bf9817..405fd9e 100755
--- a/admin/automerge
+++ b/admin/automerge
@@ -1,7 +1,7 @@
 #!/bin/bash
 ### automerge - automatically merge the Emacs release branch to master
 
-## Copyright (C) 2018 Free Software Foundation, Inc.
+## Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ## Author: Glenn Morris <address@hidden>
 
diff --git a/admin/build-configs b/admin/build-configs
index 3739d4b..09800fc 100755
--- a/admin/build-configs
+++ b/admin/build-configs
@@ -1,7 +1,7 @@
 #! /usr/bin/perl
 # Build Emacs in several different configurations.
 
-# Copyright (C) 2001-2018 Free Software Foundation, Inc.
+# Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
diff --git a/admin/charsets/Makefile.in b/admin/charsets/Makefile.in
index 8755c18..0327a5d 100644
--- a/admin/charsets/Makefile.in
+++ b/admin/charsets/Makefile.in
@@ -1,6 +1,6 @@
 ### @configure_input@
 
-# Copyright (C) 2015-2018 Free Software Foundation, Inc.
+# Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 # Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 #   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/admin/charsets/mapconv b/admin/charsets/mapconv
index c7e7aa7..8e19972 100755
--- a/admin/charsets/mapconv
+++ b/admin/charsets/mapconv
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# Copyright (C) 2015-2018 Free Software Foundation, Inc.
+# Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 # Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 #   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/admin/charsets/mapfiles/README b/admin/charsets/mapfiles/README
index 825ec62..7e4493b 100644
--- a/admin/charsets/mapfiles/README
+++ b/admin/charsets/mapfiles/README
@@ -1,4 +1,4 @@
-Copyright (C) 2009-2018 Free Software Foundation, Inc.
+Copyright (C) 2009-2019 Free Software Foundation, Inc.
 Copyright (C) 2009, 2010, 2011
   National Institute of Advanced Industrial Science and Technology (AIST)
   Registration Number H13PRO009
diff --git a/admin/cus-test.el b/admin/cus-test.el
index 13d777d..f9fd53d 100644
--- a/admin/cus-test.el
+++ b/admin/cus-test.el
@@ -1,6 +1,6 @@
 ;;; cus-test.el --- tests for custom types and load problems
 
-;; Copyright (C) 1998, 2000, 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2000, 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Markus Rost <address@hidden>
 ;; Maintainer: Markus Rost <address@hidden>
diff --git a/admin/diff-tar-files b/admin/diff-tar-files
index 87446fb..79a035b 100755
--- a/admin/diff-tar-files
+++ b/admin/diff-tar-files
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-# Copyright (C) 2001-2018 Free Software Foundation, Inc.
+# Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
diff --git a/admin/find-gc.el b/admin/find-gc.el
index e8cc113..bf93c4e 100644
--- a/admin/find-gc.el
+++ b/admin/find-gc.el
@@ -1,6 +1,6 @@
 ;;; find-gc.el --- detect functions that call the garbage collector
 
-;; Copyright (C) 1992, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 
diff --git a/admin/gitmerge.el b/admin/gitmerge.el
index 6dedee8..edf4379 100644
--- a/admin/gitmerge.el
+++ b/admin/gitmerge.el
@@ -1,6 +1,6 @@
 ;;; gitmerge.el --- help merge one Emacs branch into another
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Authors: David Engster <address@hidden>
 ;;          Stefan Monnier <address@hidden>
@@ -51,7 +51,7 @@
   ;; We used to include "sync" in there, but in my experience it only
   ;; caused false positives.  --Stef
   (let ((skip "back[- ]?port\\|cherry picked from commit\\|\
-\\(do\\( no\\|n['’]\\)t\\|no need to\\) merge\\|\
+\\(do\\( no\\|n['’]\\)t\\|no need to\\) merge\\|not to be merged\\|\
 bump \\(Emacs \\)?version\\|Auto-commit"))
     (if noninteractive skip
       ;; "Regenerate" is quite prone to false positives.
@@ -294,7 +294,7 @@ Returns non-nil if conflicts remain."
            ((derived-mode-p 'change-log-mode)
             ;; Fix up dates before resolving the conflicts.
             (goto-char (point-min))
-            (let ((diff-auto-refine-mode nil))
+            (let ((diff-refine nil))
               (while (re-search-forward smerge-begin-re nil t)
                 (smerge-match-conflict)
                 (smerge-ensure-match 3)
diff --git a/admin/grammars/Makefile.in b/admin/grammars/Makefile.in
index 1f6a863..2d9d0e8 100644
--- a/admin/grammars/Makefile.in
+++ b/admin/grammars/Makefile.in
@@ -1,6 +1,6 @@
 ### @configure_input@
 
-## Copyright (C) 2013-2018 Free Software Foundation, Inc.
+## Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ## This file is part of GNU Emacs.
 
diff --git a/admin/grammars/c.by b/admin/grammars/c.by
index 3755c32..bd1b6a5 100644
--- a/admin/grammars/c.by
+++ b/admin/grammars/c.by
@@ -1,5 +1,5 @@
 ;;; c.by -- LL grammar for C/C++ language specification
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Eric M. Ludlam <address@hidden>
 ;;         David Ponce <address@hidden>
diff --git a/admin/grammars/grammar.wy b/admin/grammars/grammar.wy
index d8647f9..f7664de 100644
--- a/admin/grammars/grammar.wy
+++ b/admin/grammars/grammar.wy
@@ -1,6 +1,6 @@
 ;;; semantic-grammar.wy -- LALR grammar of Semantic input grammars
 ;;
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: David Ponce <address@hidden>
 ;; Maintainer: David Ponce <address@hidden>
diff --git a/admin/grammars/java-tags.wy b/admin/grammars/java-tags.wy
index b3c23d5..88beafe 100644
--- a/admin/grammars/java-tags.wy
+++ b/admin/grammars/java-tags.wy
@@ -1,6 +1,6 @@
 ;;; java-tags.wy -- Semantic LALR grammar for Java
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: David Ponce <address@hidden>
 ;; Maintainer: David Ponce <address@hidden>
diff --git a/admin/grammars/js.wy b/admin/grammars/js.wy
index 653d2b0..441fd41 100644
--- a/admin/grammars/js.wy
+++ b/admin/grammars/js.wy
@@ -1,6 +1,6 @@
 ;;; javascript-jv.wy -- LALR grammar for Javascript
 
-;; Copyright (C) 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1998-2011 Ecma International.
 
 ;; Author: Joakim Verona
diff --git a/admin/grammars/make.by b/admin/grammars/make.by
index da1320d..423c952 100644
--- a/admin/grammars/make.by
+++ b/admin/grammars/make.by
@@ -1,6 +1,6 @@
 ;;; make.by -- BY notation for Makefiles.
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Eric M. Ludlam <address@hidden>
 ;;         David Ponce <address@hidden>
diff --git a/admin/grammars/python.wy b/admin/grammars/python.wy
index 1f02d43..5e5bdc1 100644
--- a/admin/grammars/python.wy
+++ b/admin/grammars/python.wy
@@ -1,6 +1,6 @@
 ;;; python.wy -- LALR grammar for Python
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 ;; Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
 ;; 2009, 2010 Python Software Foundation; All Rights Reserved
 
diff --git a/admin/grammars/scheme.by b/admin/grammars/scheme.by
index 5ea2550..76ded7f 100644
--- a/admin/grammars/scheme.by
+++ b/admin/grammars/scheme.by
@@ -1,6 +1,6 @@
 ;;; scheme.by -- Scheme BNF language specification
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/admin/grammars/srecode-template.wy 
b/admin/grammars/srecode-template.wy
index de52ede..fb56d23 100644
--- a/admin/grammars/srecode-template.wy
+++ b/admin/grammars/srecode-template.wy
@@ -1,6 +1,6 @@
 ;;; srecode-template.wy --- Semantic Recoder Template parser
 
-;; Copyright (C) 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Ludlam <address@hidden>
 ;; Keywords: syntax
diff --git a/admin/last-chance.el b/admin/last-chance.el
index c536ca8..5f993be 100644
--- a/admin/last-chance.el
+++ b/admin/last-chance.el
@@ -1,6 +1,6 @@
 ;;; last-chance.el --- dangling deterrence     -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Thien-Thi Nguyen <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/admin/make-emacs b/admin/make-emacs
index 5ff2f5a..b7cca06 100755
--- a/admin/make-emacs
+++ b/admin/make-emacs
@@ -2,7 +2,7 @@
 # Build Emacs with various options for profiling, debugging,
 # with and without warnings enabled etc.
 
-# Copyright (C) 2001-2018 Free Software Foundation, Inc.
+# Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
diff --git a/admin/make-manuals b/admin/make-manuals
index 7b9f6a2..4e65d3d 100755
--- a/admin/make-manuals
+++ b/admin/make-manuals
@@ -1,7 +1,7 @@
 #!/bin/bash
 ### make-manuals - create the Emacs manuals to upload to the gnu.org website
 
-## Copyright 2018 Free Software Foundation, Inc.
+## Copyright 2018-2019 Free Software Foundation, Inc.
 
 ## Author: Glenn Morris <address@hidden>
 
diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index ab0d34e..4a69310 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -4,7 +4,7 @@
 #
 #      admin/merge-gnulib
 
-# Copyright 2012-2018 Free Software Foundation, Inc.
+# Copyright 2012-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
@@ -36,7 +36,7 @@ GNULIB_MODULES='
   filemode filevercmp flexmember fpieee fstatat fsusage fsync
   getloadavg getopt-gnu gettime gettimeofday gitlog-to-changelog
   ieee754-h ignore-value intprops largefile lstat
-  manywarnings memrchr minmax mkostemp mktime nstrftime
+  manywarnings memmem-simple memrchr minmax mkostemp mktime nstrftime
   pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat regex
   sig2str socklen stat-time std-gnu11 stdalign stddef stdio
   stpcpy strtoimax symlink sys_stat sys_time
@@ -47,7 +47,7 @@ GNULIB_MODULES='
 
 AVOIDED_MODULES='
   btowc close dup fchdir fstat langinfo lock
-  malloc-posix mbrtowc mbsinit mkdir msvc-inval msvc-nothrow nl_langinfo
+  malloc-posix mbrtowc mbsinit memchr mkdir msvc-inval msvc-nothrow nl_langinfo
   openat-die opendir raise
   save-cwd select setenv sigprocmask stat stdarg stdbool
   threadlib tzset unsetenv utime utime-h
diff --git a/admin/merge-pkg-config b/admin/merge-pkg-config
index a7d7122..61f96e5 100755
--- a/admin/merge-pkg-config
+++ b/admin/merge-pkg-config
@@ -4,7 +4,7 @@
 #
 #      admin/merge-pkg-config
 
-# Copyright 2014-2018 Free Software Foundation, Inc.
+# Copyright 2014-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
diff --git a/admin/notes/bugtracker b/admin/notes/bugtracker
index f3bc304..92ae326 100644
--- a/admin/notes/bugtracker
+++ b/admin/notes/bugtracker
@@ -241,21 +241,29 @@ report, and Bcc: the control server (note the commands 
have no effect
 if you just send them to the bug-report number).  Bcc: is better than Cc:
 in case people use Reply-To-All in response.
 
+For the full documentation of control commands, see
+https://debbugs.gnu.org/server-control.html
+
 Some useful control commands:
 
+*** To close a bug and indicate in what Emacs version it was fixed
+close 123 VERSION
+
+where VERSION is XX.YY numerical version number, like 42.1.
+
 *** To reopen a closed bug:
 reopen 123
 
 *** Bugs can be tagged in various ways (eg wontfix, patch, etc).
 The available tags are:
-patch wontfix moreinfo unreproducible fixed notabug
+patch wontfix moreinfo unreproducible fixed notabug security confirmed
 See https://debbugs.gnu.org/Developer#tags
 The list of tags can be prefixed with +, - or =, meaning to add (the
 default), remove, or reset the tags. E.g.:
 
 tags 123 + wontfix
 
-** URL shortcuts
+*** URL shortcuts
 
 https://debbugs.gnu.org/...
 
@@ -266,7 +274,7 @@ from:address@hidden
 severity:severity      # all bugs of given severity
 tag:tag                # all bugs with given tag
 
-** Usertags
+*** Usertags
 
 See <http://wiki.debian.org/bugs.debian.org/usertags>
 
@@ -410,21 +418,21 @@ reassign 1234 emacs
 Note that reassigning clears the list of found versions, even if the
 new packages includes the original one.
 
-** To remove spam from the tracker, move it to the 'spam' pseudo-package:
+*** To remove spam from the tracker, move it to the 'spam' pseudo-package:
 reassign 123 spam
 
 (Should not be necessary any more, now that the input is moderated.)
 
-** To change the title of a bug:
+*** To change the title of a bug:
 retitle 123 Some New Title
 
-** To change the submitter address:
+*** To change the submitter address:
 submitter 123 address@hidden
 
 Note that it does not seem to work to specify "Submitter:" in the
 pseudo-header when first reporting a bug.
 
-** How does archiving work?
+*** How does archiving work?
 You can still send mail to a bug after it is closed.  After 28 days with
 no activity, the bug is archived, at which point no more changes can
 be made.  If you try to send mail to the bug after that (or merge with
diff --git a/admin/notes/copyright b/admin/notes/copyright
index 246950e..e22db6b 100644
--- a/admin/notes/copyright
+++ b/admin/notes/copyright
@@ -1,4 +1,4 @@
-Copyright (C) 2007-2018 Free Software Foundation, Inc.
+Copyright (C) 2007-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 
@@ -161,9 +161,6 @@ etc/letter.pbm,letter.xpm
   - trivial, no notice needed.
 <https://lists.gnu.org/r/emacs-devel/2007-02/msg00324.html>
 
-etc/FTP, ORDERS
-  - trivial (at time of writing), no license needed
-
 etc/HELLO
   standard notices. Just a note that although the file itself is not
   really copyrightable, in the wider context of it being part of
diff --git a/admin/notes/emba b/admin/notes/emba
new file mode 100644
index 0000000..cb0dbc4
--- /dev/null
+++ b/admin/notes/emba
@@ -0,0 +1,64 @@
+-*- mode: outline; coding: utf-8 -*-
+
+Copyright (C) 2019 Free Software Foundation, Inc.
+See the end of the file for license conditions.
+
+NOTES FOR EMACS CONTINUOUS BUILD ON EMBA
+
+A continuous build for Emacs can be found at
+<https://emba.gnu.org/emacs/emacs>, a Gitlab instance.  It watches the
+Emacs git repository and starts a pipeline (jobset) if there are new
+changes.  This happens for all Emacs branches.
+
+* Mail notifications
+
+In addition to the web interface, emba can send notifications by email
+when a job fails.  It sends notifications about test status to
+<address@hidden>.
+
+If you want to receive these notifications, please subscribe at
+<https://lists.gnu.org/mailman/listinfo/emacs-buildstatus>.
+
+Alternatively, these notifications can be read via gmane at
+<nntp+news.gmane.org:gmane.emacs.buildstatus>.
+
+The messages contain a URL to the log file of the failed job, like
+<https://emba.gnu.org/emacs/emacs/-/jobs/739/raw>.
+
+* Emacs jobset
+
+The Emacs jobset is defined in the Emacs source tree, file
+'.gitlab-ci.yml'.  It could be adapted for every Emacs branch, see
+<https://emba.gnu.org/help/ci/yaml/README.md>.
+
+Every job runs in a Debian docker container.  It uses the local clone
+of the Emacs git repository to perform a bootstrap and test of Emacs.
+This could happen for several jobs with changed configuration, compile
+and test parameters.
+
+* Emba configuration
+
+The emba configuration files are hosted on
+<https://gitlab.com/emacs-ci/emba-ansible>.
+
+* Identifying emba
+
+Lisp packages, Makefiles, scripts, and other software could determine
+whether they run on emba by checking for the environment variable
+EMACS_EMBA_CI.
+
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
diff --git a/admin/notes/font-backend b/admin/notes/font-backend
index fcb9c37..eef7439 100644
--- a/admin/notes/font-backend
+++ b/admin/notes/font-backend
@@ -1,4 +1,4 @@
-Copyright (C) 2002-2018 Free Software Foundation, Inc.
+Copyright (C) 2002-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 
diff --git a/admin/notes/hydra b/admin/notes/hydra
index 5fe8332..da8d986 100644
--- a/admin/notes/hydra
+++ b/admin/notes/hydra
@@ -1,6 +1,6 @@
 -*- mode: outline; coding: utf-8 -*-
 
-Copyright (C) 2013-2018 Free Software Foundation, Inc.
+Copyright (C) 2013-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 NOTES FOR EMACS CONTINUOUS BUILD ON HYDRA
@@ -10,8 +10,6 @@ https://hydra.nixos.org/jobset/gnu/emacs-trunk
 
 * It builds Emacs on various platforms.
 Sometimes jobs fail due to hydra problems rather than Emacs problems.
-Eg it seems like the darwin build will never work again.
-https://lists.gnu.org/r/hydra-users/2016-01/msg00000.html
 
 * Mail notifications
 In addition to the web interface, Hydra can send notifications by
@@ -22,6 +20,8 @@ Emacs trunk to address@hidden
 If you want to receive these notifications, please subscribe at
 https://lists.gnu.org/mailman/listinfo/emacs-buildstatus
 
+(This feature seems to have been broken for ages.)
+
 * The Emacs jobset consists of the following jobs:
 
 ** The 'tarball' job
diff --git a/admin/notes/multi-tty b/admin/notes/multi-tty
index 619af8e..e15a25b 100644
--- a/admin/notes/multi-tty
+++ b/admin/notes/multi-tty
@@ -1,6 +1,6 @@
 -*- coding: utf-8; mode: text; -*-
 
-Copyright (C) 2007-2018 Free Software Foundation, Inc.
+Copyright (C) 2007-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 From README.multi-tty in the multi-tty branch.
diff --git a/admin/notes/unicode b/admin/notes/unicode
index 40f93fc..4d6aa6e 100644
--- a/admin/notes/unicode
+++ b/admin/notes/unicode
@@ -1,6 +1,6 @@
                                             -*-mode: text; coding: utf-8;-*-
 
-Copyright (C) 2002-2018 Free Software Foundation, Inc.
+Copyright (C) 2002-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 Importing a new Unicode Standard version into Emacs
@@ -11,15 +11,20 @@ Emacs uses the following files from the Unicode Character 
Database
 
   . UnicodeData.txt
   . Blocks.txt
-  . BidiMirroring.txt
   . BidiBrackets.txt
+  . BidiCharacterTest.txt
+  . BidiMirroring.txt
   . IVD_Sequences.txt
   . NormalizationTest.txt
   . SpecialCasing.txt
-  . BidiCharacterTest.txt
 
 First, the first 7 files need to be copied into admin/unidata/, and
-then Emacs should be rebuilt for them to take effect.  Rebuilding
+the file https://www.unicode.org/copyright.html should be copied over
+copyright.html in admin/unidata (that file might need trailing
+whitespace removed before it can be committed to the Emacs
+repository).
+
+Then Emacs should be rebuilt for them to take effect.  Rebuilding
 Emacs updates several derived files elsewhere in the Emacs source
 tree, mainly in lisp/international/.
 
@@ -28,7 +33,10 @@ files, pay attention to any warning or error messages.  In 
particular,
 admin/unidata/unidata-gen.el will complain if UnicodeData.txt defines
 new bidirectional attributes of characters, because unidata-gen.el,
 bidi.c and dispextern.h need to be updated in that case; failure to do
-so will cause aborts in redisplay.
+so will cause aborts in redisplay.  unidata-gen.el will also complain
+if the format of the Unicode Copyright notice in copyright.html
+changed in significant ways; in that case, update the regular
+expression in unidata-gen-file used to extract the copyright string.
 
 Next, review the changes in UnicodeData.txt vs the previous version
 used by Emacs.  Any changes, be it introduction of new scripts or
@@ -40,7 +48,12 @@ and see if any changes in admin/unidata/blocks.awk are 
required.
 
 The setting of char-width-table around line 1200 of characters.el
 should be checked against the latest version of the Unicode file
-EastAsianWidth.txt, and any discrepancies fixed.
+EastAsianWidth.txt, and any discrepancies fixed: double-width
+characters are those marked with W or F in that file.  Zero-width
+characters are not taken from EastAsianWidth.txt, they are those whose
+Unicode General Category property is one of Mn, Me, or Cf, and also
+Hangul jungseong and jongseong characters (a.k.a. "Jamo medial vowels"
+and "Jamo final consonants").
 
 Any new scripts added by UnicodeData.txt will also need updates to
 script-representative-chars defined in fontset.el, and also the list
@@ -230,37 +243,21 @@ nontrivial changes to the build process.
 
        admin/charsets/mapfiles/cns2ucsdkw.txt
 
- * iso-2022-7bit
+ * iso-2022-jp
 
-     Each of these files contains just one CJK charset, but Emacs
-     currently has no easy way to specify set-charset-priority on a
-     per-file basis, so converting any of these files to UTF-8 might
-     change the file's appearance when viewed by an Emacs that is
-     operating in some other language environment.
+     This contains just one CJK charset, but Emacs currently has no
+     easy way to specify set-charset-priority on a per-file basis, so
+     converting this file to UTF-8 might change the file's appearance
+     when viewed by an Emacs that is operating in some other language
+     environment.
 
        etc/tutorials/TUTORIAL.ja
-       lisp/international/ja-dic-cnv.el
-       lisp/international/ja-dic-utl.el
-       lisp/international/kinsoku.el
-       lisp/international/kkc.el
-       lisp/international/titdic-cnv.el
-       lisp/language/japan-util.el
-       lisp/language/japanese.el
-       lisp/leim/quail/cyril-jis.el
-       lisp/leim/quail/hanja-jis.el
-       lisp/leim/quail/japanese.el
-       lisp/leim/quail/py-punct.el
-       lisp/leim/quail/pypunct-b5.el
-
-     This file contains just Chinese characters, and has same problem.
-     Also, it contains characters that cannot be encoded in UTF-8.
-
-       lisp/international/titdic-cnv.el
 
  * utf-8-emacs
 
      These files contain characters that cannot be encoded in UTF-8.
 
+       lisp/international/titdic-cnv.el
        lisp/language/ethio-util.el
        lisp/language/ethiopic.el
        lisp/language/ind-util.el
diff --git a/admin/notes/www b/admin/notes/www
index 2652ecc..ed2349d 100644
--- a/admin/notes/www
+++ b/admin/notes/www
@@ -1,6 +1,6 @@
 -*- outline -*-
 
-Copyright (C) 2013-2018 Free Software Foundation, Inc.
+Copyright (C) 2013-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 NOTES FOR EMACS WWW PAGES
diff --git a/admin/nt/README-UNDUMP.W32 b/admin/nt/README-UNDUMP.W32
index e54e208..d692a30 100644
--- a/admin/nt/README-UNDUMP.W32
+++ b/admin/nt/README-UNDUMP.W32
@@ -1,4 +1,4 @@
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
                           Emacs for Windows
diff --git a/admin/nt/README-ftp-server b/admin/nt/README-ftp-server
index 3378820..0c68d99 100644
--- a/admin/nt/README-ftp-server
+++ b/admin/nt/README-ftp-server
@@ -1,4 +1,4 @@
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
                      Precompiled Distributions of
diff --git a/admin/nt/dist-build/build-dep-zips.py 
b/admin/nt/dist-build/build-dep-zips.py
index e6c1ce8..5a5bfe7 100755
--- a/admin/nt/dist-build/build-dep-zips.py
+++ b/admin/nt/dist-build/build-dep-zips.py
@@ -1,6 +1,6 @@
 #!/usr/bin/python3
 
-## Copyright (C) 2017-2018 Free Software Foundation, Inc.
+## Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ## This file is part of GNU Emacs.
 
diff --git a/admin/nt/dist-build/build-zips.sh 
b/admin/nt/dist-build/build-zips.sh
index 7ffa862..4404c77 100755
--- a/admin/nt/dist-build/build-zips.sh
+++ b/admin/nt/dist-build/build-zips.sh
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-## Copyright (C) 2017-2018 Free Software Foundation, Inc.
+## Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ## This file is part of GNU Emacs.
 
diff --git a/admin/quick-install-emacs b/admin/quick-install-emacs
index e2e00d5..71c4431 100755
--- a/admin/quick-install-emacs
+++ b/admin/quick-install-emacs
@@ -1,7 +1,7 @@
 #!/bin/sh
 ### quick-install-emacs --- do a halfway-decent job of installing emacs quickly
 
-## Copyright (C) 2001-2018 Free Software Foundation, Inc.
+## Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ## Author: Miles Bader <address@hidden>
 
diff --git a/admin/unidata/BidiBrackets.txt b/admin/unidata/BidiBrackets.txt
index c505861..9e51834 100644
--- a/admin/unidata/BidiBrackets.txt
+++ b/admin/unidata/BidiBrackets.txt
@@ -1,5 +1,5 @@
-# BidiBrackets-11.0.0.txt
-# Date: 2018-02-18, 05:50:00 GMT [AG, LI, KW]
+# BidiBrackets-12.0.0.txt
+# Date: 2018-11-02, 16:32:00 GMT [AG, LI, KW]
 # © 2018 Unicode®, Inc.
 # Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in 
the U.S. and other countries.
 # For terms of use, see http://www.unicode.org/terms_of_use.html
diff --git a/admin/unidata/BidiMirroring.txt b/admin/unidata/BidiMirroring.txt
index b3135c0..80dab88 100644
--- a/admin/unidata/BidiMirroring.txt
+++ b/admin/unidata/BidiMirroring.txt
@@ -1,5 +1,5 @@
-# BidiMirroring-11.0.0.txt
-# Date: 2018-05-07, 18:02:00 GMT [KW, LI, RP]
+# BidiMirroring-12.0.0.txt
+# Date: 2018-11-02, 16:33:00 GMT [KW, LI, RP]
 # © 2018 Unicode®, Inc.
 # For terms of use, see http://www.unicode.org/terms_of_use.html
 #
@@ -15,7 +15,7 @@
 # value, for which there is another Unicode character that typically has a 
glyph
 # that is the mirror image of the original character's glyph.
 #
-# The repertoire covered by the file is Unicode 11.0.0.
+# The repertoire covered by the file is Unicode 12.0.0.
 #
 # The file contains a list of lines with mappings from one code point
 # to another one for character-based mirroring.
diff --git a/admin/unidata/Blocks.txt b/admin/unidata/Blocks.txt
index 3579820..7216614 100644
--- a/admin/unidata/Blocks.txt
+++ b/admin/unidata/Blocks.txt
@@ -1,6 +1,6 @@
-# Blocks-11.0.0.txt
-# Date: 2017-10-16, 24:39:00 GMT [KW]
-# © 2017 Unicode®, Inc.
+# Blocks-12.0.0.txt
+# Date: 2018-07-30, 19:40:00 GMT [KW]
+# © 2018 Unicode®, Inc.
 # For terms of use, see http://www.unicode.org/terms_of_use.html
 #
 # Unicode Character Database
@@ -239,6 +239,7 @@ FFF0..FFFF; Specials
 10E60..10E7F; Rumi Numeral Symbols
 10F00..10F2F; Old Sogdian
 10F30..10F6F; Sogdian
+10FE0..10FFF; Elymaic
 11000..1107F; Brahmi
 11080..110CF; Kaithi
 110D0..110FF; Sora Sompeng
@@ -259,6 +260,7 @@ FFF0..FFFF; Specials
 11700..1173F; Ahom
 11800..1184F; Dogra
 118A0..118FF; Warang Citi
+119A0..119FF; Nandinagari
 11A00..11A4F; Zanabazar Square
 11A50..11AAF; Soyombo
 11AC0..11AFF; Pau Cin Hau
@@ -267,10 +269,12 @@ FFF0..FFFF; Specials
 11D00..11D5F; Masaram Gondi
 11D60..11DAF; Gunjala Gondi
 11EE0..11EFF; Makasar
+11FC0..11FFF; Tamil Supplement
 12000..123FF; Cuneiform
 12400..1247F; Cuneiform Numbers and Punctuation
 12480..1254F; Early Dynastic Cuneiform
 13000..1342F; Egyptian Hieroglyphs
+13430..1343F; Egyptian Hieroglyph Format Controls
 14400..1467F; Anatolian Hieroglyphs
 16800..16A3F; Bamum Supplement
 16A40..16A6F; Mro
@@ -283,6 +287,7 @@ FFF0..FFFF; Specials
 18800..18AFF; Tangut Components
 1B000..1B0FF; Kana Supplement
 1B100..1B12F; Kana Extended-A
+1B130..1B16F; Small Kana Extension
 1B170..1B2FF; Nushu
 1BC00..1BC9F; Duployan
 1BCA0..1BCAF; Shorthand Format Controls
@@ -295,9 +300,12 @@ FFF0..FFFF; Specials
 1D400..1D7FF; Mathematical Alphanumeric Symbols
 1D800..1DAAF; Sutton SignWriting
 1E000..1E02F; Glagolitic Supplement
+1E100..1E14F; Nyiakeng Puachue Hmong
+1E2C0..1E2FF; Wancho
 1E800..1E8DF; Mende Kikakui
 1E900..1E95F; Adlam
 1EC70..1ECBF; Indic Siyaq Numbers
+1ED00..1ED4F; Ottoman Siyaq Numbers
 1EE00..1EEFF; Arabic Mathematical Alphabetic Symbols
 1F000..1F02F; Mahjong Tiles
 1F030..1F09F; Domino Tiles
@@ -313,6 +321,7 @@ FFF0..FFFF; Specials
 1F800..1F8FF; Supplemental Arrows-C
 1F900..1F9FF; Supplemental Symbols and Pictographs
 1FA00..1FA6F; Chess Symbols
+1FA70..1FAFF; Symbols and Pictographs Extended-A
 20000..2A6DF; CJK Unified Ideographs Extension B
 2A700..2B73F; CJK Unified Ideographs Extension C
 2B740..2B81F; CJK Unified Ideographs Extension D
diff --git a/admin/unidata/Makefile.in b/admin/unidata/Makefile.in
index 818404f..31efba0 100644
--- a/admin/unidata/Makefile.in
+++ b/admin/unidata/Makefile.in
@@ -1,6 +1,6 @@
 ### @configure_input@
 
-# Copyright (C) 2012-2018 Free Software Foundation, Inc.
+# Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 # Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
 #   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/admin/unidata/NormalizationTest.txt 
b/admin/unidata/NormalizationTest.txt
index 72a31bc..04c935c 100644
--- a/admin/unidata/NormalizationTest.txt
+++ b/admin/unidata/NormalizationTest.txt
@@ -1,6 +1,6 @@
-# NormalizationTest-11.0.0.txt
-# Date: 2018-02-19, 18:33:08 GMT
-# © 2018 Unicode®, Inc.
+# NormalizationTest-12.0.0.txt
+# Date: 2019-01-22, 08:18:33 GMT
+# © 2019 Unicode®, Inc.
 # Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in 
the U.S. and other countries.
 # For terms of use, see http://www.unicode.org/terms_of_use.html
 #
@@ -16363,6 +16363,7 @@ FFEE;FFEE;FFEE;25CB;25CB; # (○; ○; ○; ○; ○; ) HALFWIDTH 
WHITE CIRCLE
 1F14F;1F14F;1F14F;0057 0043;0057 0043; # (🅏; 🅏; 🅏; WC; WC; ) SQUARED WC
 1F16A;1F16A;1F16A;004D 0043;004D 0043; # (🅪; 🅪; 🅪; MC; MC; ) RAISED MC SIGN
 1F16B;1F16B;1F16B;004D 0044;004D 0044; # (🅫; 🅫; 🅫; MD; MD; ) RAISED MD SIGN
+1F16C;1F16C;1F16C;004D 0052;004D 0052; # (🅬; 🅬; 🅬; MR; MR; ) RAISED MR SIGN
 1F190;1F190;1F190;0044 004A;0044 004A; # (🆐; 🆐; 🆐; DJ; DJ; ) SQUARE DJ
 1F200;1F200;1F200;307B 304B;307B 304B; # (🈀; 🈀; 🈀; ほか; ほか; ) SQUARE HIRAGANA 
HOKA
 1F201;1F201;1F201;30B3 30B3;30B3 30B3; # (🈁; 🈁; 🈁; ココ; ココ; ) SQUARED KATAKANA 
KOKO
@@ -17685,6 +17686,8 @@ FFEE;FFEE;FFEE;25CB;25CB; # (○; ○; ○; ○; ○; ) HALFWIDTH 
WHITE CIRCLE
 0061 0EB8 0EC8 0EB8 0E48 0062;0061 0E48 0EB8 0EB8 0EC8 0062;0061 0E48 0EB8 
0EB8 0EC8 0062;0061 0E48 0EB8 0EB8 0EC8 0062;0061 0E48 0EB8 0EB8 0EC8 0062; # 
(a◌ຸ◌່◌ຸ◌่b; a◌่◌ຸ◌ຸ◌່b; a◌่◌ຸ◌ຸ◌່b; a◌่◌ຸ◌ຸ◌່b; a◌่◌ຸ◌ຸ◌່b; ) LATIN SMALL 
LETTER A, LAO VOWEL SIGN U, LAO TONE MAI EK, LAO VOWEL SIGN U, THAI CHARACTER 
MAI EK, LATIN SMALL LETTER B
 0061 0EC8 0EB8 0E48 0EB9 0062;0061 0E48 0EB8 0EB9 0EC8 0062;0061 0E48 0EB8 
0EB9 0EC8 0062;0061 0E48 0EB8 0EB9 0EC8 0062;0061 0E48 0EB8 0EB9 0EC8 0062; # 
(a◌່◌ຸ◌่◌ູb; a◌่◌ຸ◌ູ◌່b; a◌่◌ຸ◌ູ◌່b; a◌่◌ຸ◌ູ◌່b; a◌่◌ຸ◌ູ◌່b; ) LATIN SMALL 
LETTER A, LAO TONE MAI EK, LAO VOWEL SIGN U, THAI CHARACTER MAI EK, LAO VOWEL 
SIGN UU, LATIN SMALL LETTER B
 0061 0EB9 0EC8 0EB8 0E48 0062;0061 0E48 0EB9 0EB8 0EC8 0062;0061 0E48 0EB9 
0EB8 0EC8 0062;0061 0E48 0EB9 0EB8 0EC8 0062;0061 0E48 0EB9 0EB8 0EC8 0062; # 
(a◌ູ◌່◌ຸ◌่b; a◌่◌ູ◌ຸ◌່b; a◌่◌ູ◌ຸ◌່b; a◌่◌ູ◌ຸ◌່b; a◌่◌ູ◌ຸ◌່b; ) LATIN SMALL 
LETTER A, LAO VOWEL SIGN UU, LAO TONE MAI EK, LAO VOWEL SIGN U, THAI CHARACTER 
MAI EK, LATIN SMALL LETTER B
+0061 05B0 094D 3099 0EBA 0062;0061 3099 094D 0EBA 05B0 0062;0061 3099 094D 
0EBA 05B0 0062;0061 3099 094D 0EBA 05B0 0062;0061 3099 094D 0EBA 05B0 0062; # 
(a◌ְ◌्◌゙◌຺b; a◌゙◌्◌຺◌ְb; a◌゙◌्◌຺◌ְb; a◌゙◌्◌຺◌ְb; a◌゙◌्◌຺◌ְb; ) LATIN SMALL 
LETTER A, HEBREW POINT SHEVA, DEVANAGARI SIGN VIRAMA, COMBINING 
KATAKANA-HIRAGANA VOICED SOUND MARK, LAO SIGN PALI VIRAMA, LATIN SMALL LETTER B
+0061 0EBA 05B0 094D 3099 0062;0061 3099 0EBA 094D 05B0 0062;0061 3099 0EBA 
094D 05B0 0062;0061 3099 0EBA 094D 05B0 0062;0061 3099 0EBA 094D 05B0 0062; # 
(a◌຺◌ְ◌्◌゙b; a◌゙◌຺◌्◌ְb; a◌゙◌຺◌्◌ְb; a◌゙◌຺◌्◌ְb; a◌゙◌຺◌्◌ְb; ) LATIN SMALL 
LETTER A, LAO SIGN PALI VIRAMA, HEBREW POINT SHEVA, DEVANAGARI SIGN VIRAMA, 
COMBINING KATAKANA-HIRAGANA VOICED SOUND MARK, LATIN SMALL LETTER B
 0061 0F71 0EC8 0EB8 0EC8 0062;0061 0EB8 0EC8 0EC8 0F71 0062;0061 0EB8 0EC8 
0EC8 0F71 0062;0061 0EB8 0EC8 0EC8 0F71 0062;0061 0EB8 0EC8 0EC8 0F71 0062; # 
(a◌ཱ◌່◌ຸ◌່b; a◌ຸ◌່◌່◌ཱb; a◌ຸ◌່◌່◌ཱb; a◌ຸ◌່◌່◌ཱb; a◌ຸ◌່◌່◌ཱb; ) LATIN SMALL 
LETTER A, TIBETAN VOWEL SIGN AA, LAO TONE MAI EK, LAO VOWEL SIGN U, LAO TONE 
MAI EK, LATIN SMALL LETTER B
 0061 0EC8 0F71 0EC8 0EB8 0062;0061 0EB8 0EC8 0EC8 0F71 0062;0061 0EB8 0EC8 
0EC8 0F71 0062;0061 0EB8 0EC8 0EC8 0F71 0062;0061 0EB8 0EC8 0EC8 0F71 0062; # 
(a◌່◌ཱ◌່◌ຸb; a◌ຸ◌່◌່◌ཱb; a◌ຸ◌່◌່◌ཱb; a◌ຸ◌່◌່◌ཱb; a◌ຸ◌່◌່◌ཱb; ) LATIN SMALL 
LETTER A, LAO TONE MAI EK, TIBETAN VOWEL SIGN AA, LAO TONE MAI EK, LAO VOWEL 
SIGN U, LATIN SMALL LETTER B
 0061 0F71 0EC8 0EB8 0EC9 0062;0061 0EB8 0EC8 0EC9 0F71 0062;0061 0EB8 0EC8 
0EC9 0F71 0062;0061 0EB8 0EC8 0EC9 0F71 0062;0061 0EB8 0EC8 0EC9 0F71 0062; # 
(a◌ཱ◌່◌ຸ◌້b; a◌ຸ◌່◌້◌ཱb; a◌ຸ◌່◌້◌ཱb; a◌ຸ◌່◌້◌ཱb; a◌ຸ◌່◌້◌ཱb; ) LATIN SMALL 
LETTER A, TIBETAN VOWEL SIGN AA, LAO TONE MAI EK, LAO VOWEL SIGN U, LAO TONE 
MAI THO, LATIN SMALL LETTER B
@@ -18453,6 +18456,8 @@ FFEE;FFEE;FFEE;25CB;25CB; # (○; ○; ○; ○; ○; ) HALFWIDTH 
WHITE CIRCLE
 0061 11839 05B0 094D 3099 0062;0061 3099 11839 094D 05B0 0062;0061 3099 11839 
094D 05B0 0062;0061 3099 11839 094D 05B0 0062;0061 3099 11839 094D 05B0 0062; # 
(a◌𑠹◌ְ◌्◌゙b; a◌゙◌𑠹◌्◌ְb; a◌゙◌𑠹◌्◌ְb; a◌゙◌𑠹◌्◌ְb; a◌゙◌𑠹◌्◌ְb; ) LATIN SMALL 
LETTER A, DOGRA SIGN VIRAMA, HEBREW POINT SHEVA, DEVANAGARI SIGN VIRAMA, 
COMBINING KATAKANA-HIRAGANA VOICED SOUND MARK, LATIN SMALL LETTER B
 0061 3099 093C 0334 1183A 0062;0061 0334 093C 1183A 3099 0062;0061 0334 093C 
1183A 3099 0062;0061 0334 093C 1183A 3099 0062;0061 0334 093C 1183A 3099 0062; 
# (a◌゙◌़◌̴◌𑠺b; a◌̴◌़◌𑠺◌゙b; a◌̴◌़◌𑠺◌゙b; a◌̴◌़◌𑠺◌゙b; a◌̴◌़◌𑠺◌゙b; ) LATIN SMALL 
LETTER A, COMBINING KATAKANA-HIRAGANA VOICED SOUND MARK, DEVANAGARI SIGN NUKTA, 
COMBINING TILDE OVERLAY, DOGRA SIGN NUKTA, LATIN SMALL LETTER B
 0061 1183A 3099 093C 0334 0062;0061 0334 1183A 093C 3099 0062;0061 0334 1183A 
093C 3099 0062;0061 0334 1183A 093C 3099 0062;0061 0334 1183A 093C 3099 0062; # 
(a◌𑠺◌゙◌़◌̴b; a◌̴◌𑠺◌़◌゙b; a◌̴◌𑠺◌़◌゙b; a◌̴◌𑠺◌़◌゙b; a◌̴◌𑠺◌़◌゙b; ) LATIN SMALL 
LETTER A, DOGRA SIGN NUKTA, COMBINING KATAKANA-HIRAGANA VOICED SOUND MARK, 
DEVANAGARI SIGN NUKTA, COMBINING TILDE OVERLAY, LATIN SMALL LETTER B
+0061 05B0 094D 3099 119E0 0062;0061 3099 094D 119E0 05B0 0062;0061 3099 094D 
119E0 05B0 0062;0061 3099 094D 119E0 05B0 0062;0061 3099 094D 119E0 05B0 0062; 
# (a◌ְ◌्◌゙◌𑧠b; a◌゙◌्◌𑧠◌ְb; a◌゙◌्◌𑧠◌ְb; a◌゙◌्◌𑧠◌ְb; a◌゙◌्◌𑧠◌ְb; ) LATIN SMALL 
LETTER A, HEBREW POINT SHEVA, DEVANAGARI SIGN VIRAMA, COMBINING 
KATAKANA-HIRAGANA VOICED SOUND MARK, NANDINAGARI SIGN VIRAMA, LATIN SMALL 
LETTER B
+0061 119E0 05B0 094D 3099 0062;0061 3099 119E0 094D 05B0 0062;0061 3099 119E0 
094D 05B0 0062;0061 3099 119E0 094D 05B0 0062;0061 3099 119E0 094D 05B0 0062; # 
(a◌𑧠◌ְ◌्◌゙b; a◌゙◌𑧠◌्◌ְb; a◌゙◌𑧠◌्◌ְb; a◌゙◌𑧠◌्◌ְb; a◌゙◌𑧠◌्◌ְb; ) LATIN SMALL 
LETTER A, NANDINAGARI SIGN VIRAMA, HEBREW POINT SHEVA, DEVANAGARI SIGN VIRAMA, 
COMBINING KATAKANA-HIRAGANA VOICED SOUND MARK, LATIN SMALL LETTER B
 0061 05B0 094D 3099 11A34 0062;0061 3099 094D 11A34 05B0 0062;0061 3099 094D 
11A34 05B0 0062;0061 3099 094D 11A34 05B0 0062;0061 3099 094D 11A34 05B0 0062; 
# (a◌ְ◌्◌゙◌𑨴b; a◌゙◌्◌𑨴◌ְb; a◌゙◌्◌𑨴◌ְb; a◌゙◌्◌𑨴◌ְb; a◌゙◌्◌𑨴◌ְb; ) LATIN SMALL 
LETTER A, HEBREW POINT SHEVA, DEVANAGARI SIGN VIRAMA, COMBINING 
KATAKANA-HIRAGANA VOICED SOUND MARK, ZANABAZAR SQUARE SIGN VIRAMA, LATIN SMALL 
LETTER B
 0061 11A34 05B0 094D 3099 0062;0061 3099 11A34 094D 05B0 0062;0061 3099 11A34 
094D 05B0 0062;0061 3099 11A34 094D 05B0 0062;0061 3099 11A34 094D 05B0 0062; # 
(a◌𑨴◌ְ◌्◌゙b; a◌゙◌𑨴◌्◌ְb; a◌゙◌𑨴◌्◌ְb; a◌゙◌𑨴◌्◌ְb; a◌゙◌𑨴◌्◌ְb; ) LATIN SMALL 
LETTER A, ZANABAZAR SQUARE SIGN VIRAMA, HEBREW POINT SHEVA, DEVANAGARI SIGN 
VIRAMA, COMBINING KATAKANA-HIRAGANA VOICED SOUND MARK, LATIN SMALL LETTER B
 0061 05B0 094D 3099 11A47 0062;0061 3099 094D 11A47 05B0 0062;0061 3099 094D 
11A47 05B0 0062;0061 3099 094D 11A47 05B0 0062;0061 3099 094D 11A47 05B0 0062; 
# (a◌ְ◌्◌゙◌𑩇b; a◌゙◌्◌𑩇◌ְb; a◌゙◌्◌𑩇◌ְb; a◌゙◌्◌𑩇◌ְb; a◌゙◌्◌𑩇◌ְb; ) LATIN SMALL 
LETTER A, HEBREW POINT SHEVA, DEVANAGARI SIGN VIRAMA, COMBINING 
KATAKANA-HIRAGANA VOICED SOUND MARK, ZANABAZAR SQUARE SUBJOINER, LATIN SMALL 
LETTER B
@@ -18637,6 +18642,28 @@ FFEE;FFEE;FFEE;25CB;25CB; # (○; ○; ○; ○; ○; ) 
HALFWIDTH WHITE CIRCLE
 0061 1E029 0315 0300 05AE 0062;0061 05AE 1E029 0300 0315 0062;0061 05AE 1E029 
0300 0315 0062;0061 05AE 1E029 0300 0315 0062;0061 05AE 1E029 0300 0315 0062; # 
(a◌𞀩◌̕◌̀◌֮b; a◌֮◌𞀩◌̀◌̕b; a◌֮◌𞀩◌̀◌̕b; a◌֮◌𞀩◌̀◌̕b; a◌֮◌𞀩◌̀◌̕b; ) LATIN SMALL 
LETTER A, COMBINING GLAGOLITIC LETTER IOTATED BIG YUS, COMBINING COMMA ABOVE 
RIGHT, COMBINING GRAVE ACCENT, HEBREW ACCENT ZINOR, LATIN SMALL LETTER B
 0061 0315 0300 05AE 1E02A 0062;00E0 05AE 1E02A 0315 0062;0061 05AE 0300 1E02A 
0315 0062;00E0 05AE 1E02A 0315 0062;0061 05AE 0300 1E02A 0315 0062; # 
(a◌̕◌̀◌֮◌𞀪b; à◌֮◌𞀪◌̕b; a◌֮◌̀◌𞀪◌̕b; à◌֮◌𞀪◌̕b; a◌֮◌̀◌𞀪◌̕b; ) LATIN SMALL LETTER 
A, COMBINING COMMA ABOVE RIGHT, COMBINING GRAVE ACCENT, HEBREW ACCENT ZINOR, 
COMBINING GLAGOLITIC LETTER FITA, LATIN SMALL LETTER B
 0061 1E02A 0315 0300 05AE 0062;0061 05AE 1E02A 0300 0315 0062;0061 05AE 1E02A 
0300 0315 0062;0061 05AE 1E02A 0300 0315 0062;0061 05AE 1E02A 0300 0315 0062; # 
(a◌𞀪◌̕◌̀◌֮b; a◌֮◌𞀪◌̀◌̕b; a◌֮◌𞀪◌̀◌̕b; a◌֮◌𞀪◌̀◌̕b; a◌֮◌𞀪◌̀◌̕b; ) LATIN SMALL 
LETTER A, COMBINING GLAGOLITIC LETTER FITA, COMBINING COMMA ABOVE RIGHT, 
COMBINING GRAVE ACCENT, HEBREW ACCENT ZINOR, LATIN SMALL LETTER B
+0061 0315 0300 05AE 1E130 0062;00E0 05AE 1E130 0315 0062;0061 05AE 0300 1E130 
0315 0062;00E0 05AE 1E130 0315 0062;0061 05AE 0300 1E130 0315 0062; # 
(a◌̕◌̀◌֮◌𞄰b; à◌֮◌𞄰◌̕b; a◌֮◌̀◌𞄰◌̕b; à◌֮◌𞄰◌̕b; a◌֮◌̀◌𞄰◌̕b; ) LATIN SMALL LETTER 
A, COMBINING COMMA ABOVE RIGHT, COMBINING GRAVE ACCENT, HEBREW ACCENT ZINOR, 
NYIAKENG PUACHUE HMONG TONE-B, LATIN SMALL LETTER B
+0061 1E130 0315 0300 05AE 0062;0061 05AE 1E130 0300 0315 0062;0061 05AE 1E130 
0300 0315 0062;0061 05AE 1E130 0300 0315 0062;0061 05AE 1E130 0300 0315 0062; # 
(a◌𞄰◌̕◌̀◌֮b; a◌֮◌𞄰◌̀◌̕b; a◌֮◌𞄰◌̀◌̕b; a◌֮◌𞄰◌̀◌̕b; a◌֮◌𞄰◌̀◌̕b; ) LATIN SMALL 
LETTER A, NYIAKENG PUACHUE HMONG TONE-B, COMBINING COMMA ABOVE RIGHT, COMBINING 
GRAVE ACCENT, HEBREW ACCENT ZINOR, LATIN SMALL LETTER B
+0061 0315 0300 05AE 1E131 0062;00E0 05AE 1E131 0315 0062;0061 05AE 0300 1E131 
0315 0062;00E0 05AE 1E131 0315 0062;0061 05AE 0300 1E131 0315 0062; # 
(a◌̕◌̀◌֮◌𞄱b; à◌֮◌𞄱◌̕b; a◌֮◌̀◌𞄱◌̕b; à◌֮◌𞄱◌̕b; a◌֮◌̀◌𞄱◌̕b; ) LATIN SMALL LETTER 
A, COMBINING COMMA ABOVE RIGHT, COMBINING GRAVE ACCENT, HEBREW ACCENT ZINOR, 
NYIAKENG PUACHUE HMONG TONE-M, LATIN SMALL LETTER B
+0061 1E131 0315 0300 05AE 0062;0061 05AE 1E131 0300 0315 0062;0061 05AE 1E131 
0300 0315 0062;0061 05AE 1E131 0300 0315 0062;0061 05AE 1E131 0300 0315 0062; # 
(a◌𞄱◌̕◌̀◌֮b; a◌֮◌𞄱◌̀◌̕b; a◌֮◌𞄱◌̀◌̕b; a◌֮◌𞄱◌̀◌̕b; a◌֮◌𞄱◌̀◌̕b; ) LATIN SMALL 
LETTER A, NYIAKENG PUACHUE HMONG TONE-M, COMBINING COMMA ABOVE RIGHT, COMBINING 
GRAVE ACCENT, HEBREW ACCENT ZINOR, LATIN SMALL LETTER B
+0061 0315 0300 05AE 1E132 0062;00E0 05AE 1E132 0315 0062;0061 05AE 0300 1E132 
0315 0062;00E0 05AE 1E132 0315 0062;0061 05AE 0300 1E132 0315 0062; # 
(a◌̕◌̀◌֮◌𞄲b; à◌֮◌𞄲◌̕b; a◌֮◌̀◌𞄲◌̕b; à◌֮◌𞄲◌̕b; a◌֮◌̀◌𞄲◌̕b; ) LATIN SMALL LETTER 
A, COMBINING COMMA ABOVE RIGHT, COMBINING GRAVE ACCENT, HEBREW ACCENT ZINOR, 
NYIAKENG PUACHUE HMONG TONE-J, LATIN SMALL LETTER B
+0061 1E132 0315 0300 05AE 0062;0061 05AE 1E132 0300 0315 0062;0061 05AE 1E132 
0300 0315 0062;0061 05AE 1E132 0300 0315 0062;0061 05AE 1E132 0300 0315 0062; # 
(a◌𞄲◌̕◌̀◌֮b; a◌֮◌𞄲◌̀◌̕b; a◌֮◌𞄲◌̀◌̕b; a◌֮◌𞄲◌̀◌̕b; a◌֮◌𞄲◌̀◌̕b; ) LATIN SMALL 
LETTER A, NYIAKENG PUACHUE HMONG TONE-J, COMBINING COMMA ABOVE RIGHT, COMBINING 
GRAVE ACCENT, HEBREW ACCENT ZINOR, LATIN SMALL LETTER B
+0061 0315 0300 05AE 1E133 0062;00E0 05AE 1E133 0315 0062;0061 05AE 0300 1E133 
0315 0062;00E0 05AE 1E133 0315 0062;0061 05AE 0300 1E133 0315 0062; # 
(a◌̕◌̀◌֮◌𞄳b; à◌֮◌𞄳◌̕b; a◌֮◌̀◌𞄳◌̕b; à◌֮◌𞄳◌̕b; a◌֮◌̀◌𞄳◌̕b; ) LATIN SMALL LETTER 
A, COMBINING COMMA ABOVE RIGHT, COMBINING GRAVE ACCENT, HEBREW ACCENT ZINOR, 
NYIAKENG PUACHUE HMONG TONE-V, LATIN SMALL LETTER B
+0061 1E133 0315 0300 05AE 0062;0061 05AE 1E133 0300 0315 0062;0061 05AE 1E133 
0300 0315 0062;0061 05AE 1E133 0300 0315 0062;0061 05AE 1E133 0300 0315 0062; # 
(a◌𞄳◌̕◌̀◌֮b; a◌֮◌𞄳◌̀◌̕b; a◌֮◌𞄳◌̀◌̕b; a◌֮◌𞄳◌̀◌̕b; a◌֮◌𞄳◌̀◌̕b; ) LATIN SMALL 
LETTER A, NYIAKENG PUACHUE HMONG TONE-V, COMBINING COMMA ABOVE RIGHT, COMBINING 
GRAVE ACCENT, HEBREW ACCENT ZINOR, LATIN SMALL LETTER B
+0061 0315 0300 05AE 1E134 0062;00E0 05AE 1E134 0315 0062;0061 05AE 0300 1E134 
0315 0062;00E0 05AE 1E134 0315 0062;0061 05AE 0300 1E134 0315 0062; # 
(a◌̕◌̀◌֮◌𞄴b; à◌֮◌𞄴◌̕b; a◌֮◌̀◌𞄴◌̕b; à◌֮◌𞄴◌̕b; a◌֮◌̀◌𞄴◌̕b; ) LATIN SMALL LETTER 
A, COMBINING COMMA ABOVE RIGHT, COMBINING GRAVE ACCENT, HEBREW ACCENT ZINOR, 
NYIAKENG PUACHUE HMONG TONE-S, LATIN SMALL LETTER B
+0061 1E134 0315 0300 05AE 0062;0061 05AE 1E134 0300 0315 0062;0061 05AE 1E134 
0300 0315 0062;0061 05AE 1E134 0300 0315 0062;0061 05AE 1E134 0300 0315 0062; # 
(a◌𞄴◌̕◌̀◌֮b; a◌֮◌𞄴◌̀◌̕b; a◌֮◌𞄴◌̀◌̕b; a◌֮◌𞄴◌̀◌̕b; a◌֮◌𞄴◌̀◌̕b; ) LATIN SMALL 
LETTER A, NYIAKENG PUACHUE HMONG TONE-S, COMBINING COMMA ABOVE RIGHT, COMBINING 
GRAVE ACCENT, HEBREW ACCENT ZINOR, LATIN SMALL LETTER B
+0061 0315 0300 05AE 1E135 0062;00E0 05AE 1E135 0315 0062;0061 05AE 0300 1E135 
0315 0062;00E0 05AE 1E135 0315 0062;0061 05AE 0300 1E135 0315 0062; # 
(a◌̕◌̀◌֮◌𞄵b; à◌֮◌𞄵◌̕b; a◌֮◌̀◌𞄵◌̕b; à◌֮◌𞄵◌̕b; a◌֮◌̀◌𞄵◌̕b; ) LATIN SMALL LETTER 
A, COMBINING COMMA ABOVE RIGHT, COMBINING GRAVE ACCENT, HEBREW ACCENT ZINOR, 
NYIAKENG PUACHUE HMONG TONE-G, LATIN SMALL LETTER B
+0061 1E135 0315 0300 05AE 0062;0061 05AE 1E135 0300 0315 0062;0061 05AE 1E135 
0300 0315 0062;0061 05AE 1E135 0300 0315 0062;0061 05AE 1E135 0300 0315 0062; # 
(a◌𞄵◌̕◌̀◌֮b; a◌֮◌𞄵◌̀◌̕b; a◌֮◌𞄵◌̀◌̕b; a◌֮◌𞄵◌̀◌̕b; a◌֮◌𞄵◌̀◌̕b; ) LATIN SMALL 
LETTER A, NYIAKENG PUACHUE HMONG TONE-G, COMBINING COMMA ABOVE RIGHT, COMBINING 
GRAVE ACCENT, HEBREW ACCENT ZINOR, LATIN SMALL LETTER B
+0061 0315 0300 05AE 1E136 0062;00E0 05AE 1E136 0315 0062;0061 05AE 0300 1E136 
0315 0062;00E0 05AE 1E136 0315 0062;0061 05AE 0300 1E136 0315 0062; # 
(a◌̕◌̀◌֮◌𞄶b; à◌֮◌𞄶◌̕b; a◌֮◌̀◌𞄶◌̕b; à◌֮◌𞄶◌̕b; a◌֮◌̀◌𞄶◌̕b; ) LATIN SMALL LETTER 
A, COMBINING COMMA ABOVE RIGHT, COMBINING GRAVE ACCENT, HEBREW ACCENT ZINOR, 
NYIAKENG PUACHUE HMONG TONE-D, LATIN SMALL LETTER B
+0061 1E136 0315 0300 05AE 0062;0061 05AE 1E136 0300 0315 0062;0061 05AE 1E136 
0300 0315 0062;0061 05AE 1E136 0300 0315 0062;0061 05AE 1E136 0300 0315 0062; # 
(a◌𞄶◌̕◌̀◌֮b; a◌֮◌𞄶◌̀◌̕b; a◌֮◌𞄶◌̀◌̕b; a◌֮◌𞄶◌̀◌̕b; a◌֮◌𞄶◌̀◌̕b; ) LATIN SMALL 
LETTER A, NYIAKENG PUACHUE HMONG TONE-D, COMBINING COMMA ABOVE RIGHT, COMBINING 
GRAVE ACCENT, HEBREW ACCENT ZINOR, LATIN SMALL LETTER B
+0061 0315 0300 05AE 1E2EC 0062;00E0 05AE 1E2EC 0315 0062;0061 05AE 0300 1E2EC 
0315 0062;00E0 05AE 1E2EC 0315 0062;0061 05AE 0300 1E2EC 0315 0062; # 
(a◌̕◌̀◌֮◌𞋬b; à◌֮◌𞋬◌̕b; a◌֮◌̀◌𞋬◌̕b; à◌֮◌𞋬◌̕b; a◌֮◌̀◌𞋬◌̕b; ) LATIN SMALL LETTER 
A, COMBINING COMMA ABOVE RIGHT, COMBINING GRAVE ACCENT, HEBREW ACCENT ZINOR, 
WANCHO TONE TUP, LATIN SMALL LETTER B
+0061 1E2EC 0315 0300 05AE 0062;0061 05AE 1E2EC 0300 0315 0062;0061 05AE 1E2EC 
0300 0315 0062;0061 05AE 1E2EC 0300 0315 0062;0061 05AE 1E2EC 0300 0315 0062; # 
(a◌𞋬◌̕◌̀◌֮b; a◌֮◌𞋬◌̀◌̕b; a◌֮◌𞋬◌̀◌̕b; a◌֮◌𞋬◌̀◌̕b; a◌֮◌𞋬◌̀◌̕b; ) LATIN SMALL 
LETTER A, WANCHO TONE TUP, COMBINING COMMA ABOVE RIGHT, COMBINING GRAVE ACCENT, 
HEBREW ACCENT ZINOR, LATIN SMALL LETTER B
+0061 0315 0300 05AE 1E2ED 0062;00E0 05AE 1E2ED 0315 0062;0061 05AE 0300 1E2ED 
0315 0062;00E0 05AE 1E2ED 0315 0062;0061 05AE 0300 1E2ED 0315 0062; # 
(a◌̕◌̀◌֮◌𞋭b; à◌֮◌𞋭◌̕b; a◌֮◌̀◌𞋭◌̕b; à◌֮◌𞋭◌̕b; a◌֮◌̀◌𞋭◌̕b; ) LATIN SMALL LETTER 
A, COMBINING COMMA ABOVE RIGHT, COMBINING GRAVE ACCENT, HEBREW ACCENT ZINOR, 
WANCHO TONE TUPNI, LATIN SMALL LETTER B
+0061 1E2ED 0315 0300 05AE 0062;0061 05AE 1E2ED 0300 0315 0062;0061 05AE 1E2ED 
0300 0315 0062;0061 05AE 1E2ED 0300 0315 0062;0061 05AE 1E2ED 0300 0315 0062; # 
(a◌𞋭◌̕◌̀◌֮b; a◌֮◌𞋭◌̀◌̕b; a◌֮◌𞋭◌̀◌̕b; a◌֮◌𞋭◌̀◌̕b; a◌֮◌𞋭◌̀◌̕b; ) LATIN SMALL 
LETTER A, WANCHO TONE TUPNI, COMBINING COMMA ABOVE RIGHT, COMBINING GRAVE 
ACCENT, HEBREW ACCENT ZINOR, LATIN SMALL LETTER B
+0061 0315 0300 05AE 1E2EE 0062;00E0 05AE 1E2EE 0315 0062;0061 05AE 0300 1E2EE 
0315 0062;00E0 05AE 1E2EE 0315 0062;0061 05AE 0300 1E2EE 0315 0062; # 
(a◌̕◌̀◌֮◌𞋮b; à◌֮◌𞋮◌̕b; a◌֮◌̀◌𞋮◌̕b; à◌֮◌𞋮◌̕b; a◌֮◌̀◌𞋮◌̕b; ) LATIN SMALL LETTER 
A, COMBINING COMMA ABOVE RIGHT, COMBINING GRAVE ACCENT, HEBREW ACCENT ZINOR, 
WANCHO TONE KOI, LATIN SMALL LETTER B
+0061 1E2EE 0315 0300 05AE 0062;0061 05AE 1E2EE 0300 0315 0062;0061 05AE 1E2EE 
0300 0315 0062;0061 05AE 1E2EE 0300 0315 0062;0061 05AE 1E2EE 0300 0315 0062; # 
(a◌𞋮◌̕◌̀◌֮b; a◌֮◌𞋮◌̀◌̕b; a◌֮◌𞋮◌̀◌̕b; a◌֮◌𞋮◌̀◌̕b; a◌֮◌𞋮◌̀◌̕b; ) LATIN SMALL 
LETTER A, WANCHO TONE KOI, COMBINING COMMA ABOVE RIGHT, COMBINING GRAVE ACCENT, 
HEBREW ACCENT ZINOR, LATIN SMALL LETTER B
+0061 0315 0300 05AE 1E2EF 0062;00E0 05AE 1E2EF 0315 0062;0061 05AE 0300 1E2EF 
0315 0062;00E0 05AE 1E2EF 0315 0062;0061 05AE 0300 1E2EF 0315 0062; # 
(a◌̕◌̀◌֮◌𞋯b; à◌֮◌𞋯◌̕b; a◌֮◌̀◌𞋯◌̕b; à◌֮◌𞋯◌̕b; a◌֮◌̀◌𞋯◌̕b; ) LATIN SMALL LETTER 
A, COMBINING COMMA ABOVE RIGHT, COMBINING GRAVE ACCENT, HEBREW ACCENT ZINOR, 
WANCHO TONE KOINI, LATIN SMALL LETTER B
+0061 1E2EF 0315 0300 05AE 0062;0061 05AE 1E2EF 0300 0315 0062;0061 05AE 1E2EF 
0300 0315 0062;0061 05AE 1E2EF 0300 0315 0062;0061 05AE 1E2EF 0300 0315 0062; # 
(a◌𞋯◌̕◌̀◌֮b; a◌֮◌𞋯◌̀◌̕b; a◌֮◌𞋯◌̀◌̕b; a◌֮◌𞋯◌̀◌̕b; a◌֮◌𞋯◌̀◌̕b; ) LATIN SMALL 
LETTER A, WANCHO TONE KOINI, COMBINING COMMA ABOVE RIGHT, COMBINING GRAVE 
ACCENT, HEBREW ACCENT ZINOR, LATIN SMALL LETTER B
 0061 059A 0316 302A 1E8D0 0062;0061 302A 0316 1E8D0 059A 0062;0061 302A 0316 
1E8D0 059A 0062;0061 302A 0316 1E8D0 059A 0062;0061 302A 0316 1E8D0 059A 0062; 
# (a◌֚◌̖◌〪◌𞣐b; a◌〪◌̖◌𞣐◌֚b; a◌〪◌̖◌𞣐◌֚b; a◌〪◌̖◌𞣐◌֚b; a◌〪◌̖◌𞣐◌֚b; ) LATIN SMALL 
LETTER A, HEBREW ACCENT YETIV, COMBINING GRAVE ACCENT BELOW, IDEOGRAPHIC LEVEL 
TONE MARK, MENDE KIKAKUI COMBINING NUMBER TEENS, LATIN SMALL LETTER B
 0061 1E8D0 059A 0316 302A 0062;0061 302A 1E8D0 0316 059A 0062;0061 302A 1E8D0 
0316 059A 0062;0061 302A 1E8D0 0316 059A 0062;0061 302A 1E8D0 0316 059A 0062; # 
(a◌𞣐◌֚◌̖◌〪b; a◌〪◌𞣐◌̖◌֚b; a◌〪◌𞣐◌̖◌֚b; a◌〪◌𞣐◌̖◌֚b; a◌〪◌𞣐◌̖◌֚b; ) LATIN SMALL 
LETTER A, MENDE KIKAKUI COMBINING NUMBER TEENS, HEBREW ACCENT YETIV, COMBINING 
GRAVE ACCENT BELOW, IDEOGRAPHIC LEVEL TONE MARK, LATIN SMALL LETTER B
 0061 059A 0316 302A 1E8D1 0062;0061 302A 0316 1E8D1 059A 0062;0061 302A 0316 
1E8D1 059A 0062;0061 302A 0316 1E8D1 059A 0062;0061 302A 0316 1E8D1 059A 0062; 
# (a◌֚◌̖◌〪◌𞣑b; a◌〪◌̖◌𞣑◌֚b; a◌〪◌̖◌𞣑◌֚b; a◌〪◌̖◌𞣑◌֚b; a◌〪◌̖◌𞣑◌֚b; ) LATIN SMALL 
LETTER A, HEBREW ACCENT YETIV, COMBINING GRAVE ACCENT BELOW, IDEOGRAPHIC LEVEL 
TONE MARK, MENDE KIKAKUI COMBINING NUMBER TENS, LATIN SMALL LETTER B
diff --git a/admin/unidata/SpecialCasing.txt b/admin/unidata/SpecialCasing.txt
index c90d09a..7db2e31 100644
--- a/admin/unidata/SpecialCasing.txt
+++ b/admin/unidata/SpecialCasing.txt
@@ -1,6 +1,6 @@
-# SpecialCasing-11.0.0.txt
-# Date: 2018-02-22, 06:16:47 GMT
-# © 2018 Unicode®, Inc.
+# SpecialCasing-12.0.0.txt
+# Date: 2019-01-22, 08:18:50 GMT
+# © 2019 Unicode®, Inc.
 # Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in 
the U.S. and other countries.
 # For terms of use, see http://www.unicode.org/terms_of_use.html
 #
diff --git a/admin/unidata/UnicodeData.txt b/admin/unidata/UnicodeData.txt
index ec32faf..d88a601 100644
--- a/admin/unidata/UnicodeData.txt
+++ b/admin/unidata/UnicodeData.txt
@@ -640,7 +640,7 @@
 027F;LATIN SMALL LETTER REVERSED R WITH FISHHOOK;Ll;0;L;;;;;N;LATIN SMALL 
LETTER REVERSED FISHHOOK R;;;;
 0280;LATIN LETTER SMALL CAPITAL R;Ll;0;L;;;;;N;;;01A6;;01A6
 0281;LATIN LETTER SMALL CAPITAL INVERTED R;Ll;0;L;;;;;N;;;;;
-0282;LATIN SMALL LETTER S WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER S HOOK;;;;
+0282;LATIN SMALL LETTER S WITH HOOK;Ll;0;L;;;;;N;LATIN SMALL LETTER S 
HOOK;;A7C5;;A7C5
 0283;LATIN SMALL LETTER ESH;Ll;0;L;;;;;N;;;01A9;;01A9
 0284;LATIN SMALL LETTER DOTLESS J WITH STROKE AND HOOK;Ll;0;L;;;;;N;LATIN 
SMALL LETTER DOTLESS J BAR HOOK;;;;
 0285;LATIN SMALL LETTER SQUAT REVERSED ESH;Ll;0;L;;;;;N;;;;;
@@ -2809,6 +2809,7 @@
 0C6D;TELUGU DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;
 0C6E;TELUGU DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;
 0C6F;TELUGU DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;
+0C77;TELUGU SIGN SIDDHAM;Po;0;L;;;;;N;;;;;
 0C78;TELUGU FRACTION DIGIT ZERO FOR ODD POWERS OF FOUR;No;0;ON;;;;0;N;;;;;
 0C79;TELUGU FRACTION DIGIT ONE FOR ODD POWERS OF FOUR;No;0;ON;;;;1;N;;;;;
 0C7A;TELUGU FRACTION DIGIT TWO FOR ODD POWERS OF FOUR;No;0;ON;;;;2;N;;;;;
@@ -3203,14 +3204,24 @@
 0E81;LAO LETTER KO;Lo;0;L;;;;;N;;;;;
 0E82;LAO LETTER KHO SUNG;Lo;0;L;;;;;N;;;;;
 0E84;LAO LETTER KHO TAM;Lo;0;L;;;;;N;;;;;
+0E86;LAO LETTER PALI GHA;Lo;0;L;;;;;N;;;;;
 0E87;LAO LETTER NGO;Lo;0;L;;;;;N;;;;;
 0E88;LAO LETTER CO;Lo;0;L;;;;;N;;;;;
+0E89;LAO LETTER PALI CHA;Lo;0;L;;;;;N;;;;;
 0E8A;LAO LETTER SO TAM;Lo;0;L;;;;;N;;;;;
+0E8C;LAO LETTER PALI JHA;Lo;0;L;;;;;N;;;;;
 0E8D;LAO LETTER NYO;Lo;0;L;;;;;N;;;;;
+0E8E;LAO LETTER PALI NYA;Lo;0;L;;;;;N;;;;;
+0E8F;LAO LETTER PALI TTA;Lo;0;L;;;;;N;;;;;
+0E90;LAO LETTER PALI TTHA;Lo;0;L;;;;;N;;;;;
+0E91;LAO LETTER PALI DDA;Lo;0;L;;;;;N;;;;;
+0E92;LAO LETTER PALI DDHA;Lo;0;L;;;;;N;;;;;
+0E93;LAO LETTER PALI NNA;Lo;0;L;;;;;N;;;;;
 0E94;LAO LETTER DO;Lo;0;L;;;;;N;;;;;
 0E95;LAO LETTER TO;Lo;0;L;;;;;N;;;;;
 0E96;LAO LETTER THO SUNG;Lo;0;L;;;;;N;;;;;
 0E97;LAO LETTER THO TAM;Lo;0;L;;;;;N;;;;;
+0E98;LAO LETTER PALI DHA;Lo;0;L;;;;;N;;;;;
 0E99;LAO LETTER NO;Lo;0;L;;;;;N;;;;;
 0E9A;LAO LETTER BO;Lo;0;L;;;;;N;;;;;
 0E9B;LAO LETTER PO;Lo;0;L;;;;;N;;;;;
@@ -3218,13 +3229,17 @@
 0E9D;LAO LETTER FO TAM;Lo;0;L;;;;;N;;;;;
 0E9E;LAO LETTER PHO TAM;Lo;0;L;;;;;N;;;;;
 0E9F;LAO LETTER FO SUNG;Lo;0;L;;;;;N;;;;;
+0EA0;LAO LETTER PALI BHA;Lo;0;L;;;;;N;;;;;
 0EA1;LAO LETTER MO;Lo;0;L;;;;;N;;;;;
 0EA2;LAO LETTER YO;Lo;0;L;;;;;N;;;;;
 0EA3;LAO LETTER LO LING;Lo;0;L;;;;;N;;;;;
 0EA5;LAO LETTER LO LOOT;Lo;0;L;;;;;N;;;;;
 0EA7;LAO LETTER WO;Lo;0;L;;;;;N;;;;;
+0EA8;LAO LETTER SANSKRIT SHA;Lo;0;L;;;;;N;;;;;
+0EA9;LAO LETTER SANSKRIT SSA;Lo;0;L;;;;;N;;;;;
 0EAA;LAO LETTER SO SUNG;Lo;0;L;;;;;N;;;;;
 0EAB;LAO LETTER HO SUNG;Lo;0;L;;;;;N;;;;;
+0EAC;LAO LETTER PALI LLA;Lo;0;L;;;;;N;;;;;
 0EAD;LAO LETTER O;Lo;0;L;;;;;N;;;;;
 0EAE;LAO LETTER HO TAM;Lo;0;L;;;;;N;;;;;
 0EAF;LAO ELLIPSIS;Lo;0;L;;;;;N;;;;;
@@ -3238,6 +3253,7 @@
 0EB7;LAO VOWEL SIGN YY;Mn;0;NSM;;;;;N;;;;;
 0EB8;LAO VOWEL SIGN U;Mn;118;NSM;;;;;N;;;;;
 0EB9;LAO VOWEL SIGN UU;Mn;118;NSM;;;;;N;;;;;
+0EBA;LAO SIGN PALI VIRAMA;Mn;9;NSM;;;;;N;;;;;
 0EBB;LAO VOWEL SIGN MAI KON;Mn;0;NSM;;;;;N;;;;;
 0EBC;LAO SEMIVOWEL SIGN LO;Mn;0;NSM;;;;;N;;;;;
 0EBD;LAO SEMIVOWEL SIGN NYO;Lo;0;L;;;;;N;;;;;
@@ -5079,7 +5095,7 @@
 166A;CANADIAN SYLLABICS CARRIER TTSEE;Lo;0;L;;;;;N;;;;;
 166B;CANADIAN SYLLABICS CARRIER TTSI;Lo;0;L;;;;;N;;;;;
 166C;CANADIAN SYLLABICS CARRIER TTSA;Lo;0;L;;;;;N;;;;;
-166D;CANADIAN SYLLABICS CHI SIGN;Po;0;L;;;;;N;;;;;
+166D;CANADIAN SYLLABICS CHI SIGN;So;0;L;;;;;N;;;;;
 166E;CANADIAN SYLLABICS FULL STOP;Po;0;L;;;;;N;;;;;
 166F;CANADIAN SYLLABICS QAI;Lo;0;L;;;;;N;;;;;
 1670;CANADIAN SYLLABICS NGAI;Lo;0;L;;;;;N;;;;;
@@ -6488,14 +6504,15 @@
 1CEF;VEDIC SIGN LONG ANUSVARA;Lo;0;L;;;;;N;;;;;
 1CF0;VEDIC SIGN RTHANG LONG ANUSVARA;Lo;0;L;;;;;N;;;;;
 1CF1;VEDIC SIGN ANUSVARA UBHAYATO MUKHA;Lo;0;L;;;;;N;;;;;
-1CF2;VEDIC SIGN ARDHAVISARGA;Mc;0;L;;;;;N;;;;;
-1CF3;VEDIC SIGN ROTATED ARDHAVISARGA;Mc;0;L;;;;;N;;;;;
+1CF2;VEDIC SIGN ARDHAVISARGA;Lo;0;L;;;;;N;;;;;
+1CF3;VEDIC SIGN ROTATED ARDHAVISARGA;Lo;0;L;;;;;N;;;;;
 1CF4;VEDIC TONE CANDRA ABOVE;Mn;230;NSM;;;;;N;;;;;
 1CF5;VEDIC SIGN JIHVAMULIYA;Lo;0;L;;;;;N;;;;;
 1CF6;VEDIC SIGN UPADHMANIYA;Lo;0;L;;;;;N;;;;;
 1CF7;VEDIC SIGN ATIKRAMA;Mc;0;L;;;;;N;;;;;
 1CF8;VEDIC TONE RING ABOVE;Mn;230;NSM;;;;;N;;;;;
 1CF9;VEDIC TONE DOUBLE RING ABOVE;Mn;230;NSM;;;;;N;;;;;
+1CFA;VEDIC SIGN DOUBLE ANUSVARA ANTARGOMUKHA;Lo;0;L;;;;;N;;;;;
 1D00;LATIN LETTER SMALL CAPITAL A;Ll;0;L;;;;;N;;;;;
 1D01;LATIN LETTER SMALL CAPITAL AE;Ll;0;L;;;;;N;;;;;
 1D02;LATIN SMALL LETTER TURNED AE;Ll;0;L;;;;;N;;;;;
@@ -6638,7 +6655,7 @@
 1D8B;LATIN SMALL LETTER ESH WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;
 1D8C;LATIN SMALL LETTER V WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;
 1D8D;LATIN SMALL LETTER X WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;
-1D8E;LATIN SMALL LETTER Z WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;
+1D8E;LATIN SMALL LETTER Z WITH PALATAL HOOK;Ll;0;L;;;;;N;;;A7C6;;A7C6
 1D8F;LATIN SMALL LETTER A WITH RETROFLEX HOOK;Ll;0;L;;;;;N;;;;;
 1D90;LATIN SMALL LETTER ALPHA WITH RETROFLEX HOOK;Ll;0;L;;;;;N;;;;;
 1D91;LATIN SMALL LETTER D WITH HOOK AND TAIL;Ll;0;L;;;;;N;;;;;
@@ -10165,6 +10182,7 @@
 2BC6;BLACK MEDIUM DOWN-POINTING TRIANGLE CENTRED;So;0;ON;;;;;N;;;;;
 2BC7;BLACK MEDIUM LEFT-POINTING TRIANGLE CENTRED;So;0;ON;;;;;N;;;;;
 2BC8;BLACK MEDIUM RIGHT-POINTING TRIANGLE CENTRED;So;0;ON;;;;;N;;;;;
+2BC9;NEPTUNE FORM TWO;So;0;ON;;;;;N;;;;;
 2BCA;TOP HALF BLACK CIRCLE;So;0;ON;;;;;N;;;;;
 2BCB;BOTTOM HALF BLACK CIRCLE;So;0;ON;;;;;N;;;;;
 2BCC;LIGHT FOUR POINTED BLACK CUSP;So;0;ON;;;;;N;;;;;
@@ -10218,6 +10236,7 @@
 2BFC;DOUBLED SYMBOL;So;0;ON;;;;;N;;;;;
 2BFD;PASSED SYMBOL;So;0;ON;;;;;N;;;;;
 2BFE;REVERSED RIGHT ANGLE;So;0;ON;;;;;Y;;;;;
+2BFF;HELLSCHREIBER PAUSE SYMBOL;So;0;ON;;;;;N;;;;;
 2C00;GLAGOLITIC CAPITAL LETTER AZU;Lu;0;L;;;;;N;;;;2C30;
 2C01;GLAGOLITIC CAPITAL LETTER BUKY;Lu;0;L;;;;;N;;;;2C31;
 2C02;GLAGOLITIC CAPITAL LETTER VEDE;Lu;0;L;;;;;N;;;;2C32;
@@ -10756,6 +10775,7 @@
 2E4C;MEDIEVAL COMMA;Po;0;ON;;;;;N;;;;;
 2E4D;PARAGRAPHUS MARK;Po;0;ON;;;;;N;;;;;
 2E4E;PUNCTUS ELEVATUS MARK;Po;0;ON;;;;;N;;;;;
+2E4F;CORNISH VERSE DIVIDER;Po;0;ON;;;;;N;;;;;
 2E80;CJK RADICAL REPEAT;So;0;ON;;;;;N;;;;;
 2E81;CJK RADICAL CLIFF;So;0;ON;;;;;N;;;;;
 2E82;CJK RADICAL SECOND ONE;So;0;ON;;;;;N;;;;;
@@ -14060,7 +14080,7 @@ A790;LATIN CAPITAL LETTER N WITH 
DESCENDER;Lu;0;L;;;;;N;;;;A791;
 A791;LATIN SMALL LETTER N WITH DESCENDER;Ll;0;L;;;;;N;;;A790;;A790
 A792;LATIN CAPITAL LETTER C WITH BAR;Lu;0;L;;;;;N;;;;A793;
 A793;LATIN SMALL LETTER C WITH BAR;Ll;0;L;;;;;N;;;A792;;A792
-A794;LATIN SMALL LETTER C WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;
+A794;LATIN SMALL LETTER C WITH PALATAL HOOK;Ll;0;L;;;;;N;;;A7C4;;A7C4
 A795;LATIN SMALL LETTER H WITH PALATAL HOOK;Ll;0;L;;;;;N;;;;;
 A796;LATIN CAPITAL LETTER B WITH FLOURISH;Lu;0;L;;;;;N;;;;A797;
 A797;LATIN SMALL LETTER B WITH FLOURISH;Ll;0;L;;;;;N;;;A796;;A796
@@ -14098,6 +14118,17 @@ A7B6;LATIN CAPITAL LETTER OMEGA;Lu;0;L;;;;;N;;;;A7B7;
 A7B7;LATIN SMALL LETTER OMEGA;Ll;0;L;;;;;N;;;A7B6;;A7B6
 A7B8;LATIN CAPITAL LETTER U WITH STROKE;Lu;0;L;;;;;N;;;;A7B9;
 A7B9;LATIN SMALL LETTER U WITH STROKE;Ll;0;L;;;;;N;;;A7B8;;A7B8
+A7BA;LATIN CAPITAL LETTER GLOTTAL A;Lu;0;L;;;;;N;;;;A7BB;
+A7BB;LATIN SMALL LETTER GLOTTAL A;Ll;0;L;;;;;N;;;A7BA;;A7BA
+A7BC;LATIN CAPITAL LETTER GLOTTAL I;Lu;0;L;;;;;N;;;;A7BD;
+A7BD;LATIN SMALL LETTER GLOTTAL I;Ll;0;L;;;;;N;;;A7BC;;A7BC
+A7BE;LATIN CAPITAL LETTER GLOTTAL U;Lu;0;L;;;;;N;;;;A7BF;
+A7BF;LATIN SMALL LETTER GLOTTAL U;Ll;0;L;;;;;N;;;A7BE;;A7BE
+A7C2;LATIN CAPITAL LETTER ANGLICANA W;Lu;0;L;;;;;N;;;;A7C3;
+A7C3;LATIN SMALL LETTER ANGLICANA W;Ll;0;L;;;;;N;;;A7C2;;A7C2
+A7C4;LATIN CAPITAL LETTER C WITH PALATAL HOOK;Lu;0;L;;;;;N;;;;A794;
+A7C5;LATIN CAPITAL LETTER S WITH HOOK;Lu;0;L;;;;;N;;;;0282;
+A7C6;LATIN CAPITAL LETTER Z WITH PALATAL HOOK;Lu;0;L;;;;;N;;;;1D8E;
 A7F7;LATIN EPIGRAPHIC LETTER SIDEWAYS I;Lo;0;L;;;;;N;;;;;
 A7F8;MODIFIER LETTER CAPITAL H WITH STROKE;Lm;0;L;<super> 0126;;;;N;;;;;
 A7F9;MODIFIER LETTER SMALL LIGATURE OE;Lm;0;L;<super> 0153;;;;N;;;;;
@@ -14506,7 +14537,7 @@ A9B9;JAVANESE VOWEL SIGN SUKU MENDUT;Mn;0;NSM;;;;;N;;;;;
 A9BA;JAVANESE VOWEL SIGN TALING;Mc;0;L;;;;;N;;;;;
 A9BB;JAVANESE VOWEL SIGN DIRGA MURE;Mc;0;L;;;;;N;;;;;
 A9BC;JAVANESE VOWEL SIGN PEPET;Mn;0;NSM;;;;;N;;;;;
-A9BD;JAVANESE CONSONANT SIGN KERET;Mc;0;L;;;;;N;;;;;
+A9BD;JAVANESE CONSONANT SIGN KERET;Mn;0;NSM;;;;;N;;;;;
 A9BE;JAVANESE CONSONANT SIGN PENGKAL;Mc;0;L;;;;;N;;;;;
 A9BF;JAVANESE CONSONANT SIGN CAKRA;Mc;0;L;;;;;N;;;;;
 A9C0;JAVANESE PANGKON;Mc;9;L;;;;;N;;;;;
@@ -14863,6 +14894,8 @@ AB62;LATIN SMALL LETTER OPEN OE;Ll;0;L;;;;;N;;;;;
 AB63;LATIN SMALL LETTER UO;Ll;0;L;;;;;N;;;;;
 AB64;LATIN SMALL LETTER INVERTED ALPHA;Ll;0;L;;;;;N;;;;;
 AB65;GREEK LETTER SMALL CAPITAL OMEGA;Ll;0;L;;;;;N;;;;;
+AB66;LATIN SMALL LETTER DZ DIGRAPH WITH RETROFLEX HOOK;Ll;0;L;;;;;N;;;;;
+AB67;LATIN SMALL LETTER TS DIGRAPH WITH RETROFLEX HOOK;Ll;0;L;;;;;N;;;;;
 AB70;CHEROKEE SMALL LETTER A;Ll;0;L;;;;;N;;;13A0;;13A0
 AB71;CHEROKEE SMALL LETTER E;Ll;0;L;;;;;N;;;13A1;;13A1
 AB72;CHEROKEE SMALL LETTER I;Ll;0;L;;;;;N;;;13A2;;13A2
@@ -19105,6 +19138,29 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 10F57;SOGDIAN PUNCTUATION CIRCLE WITH DOT;Po;0;AL;;;;;N;;;;;
 10F58;SOGDIAN PUNCTUATION TWO CIRCLES WITH DOTS;Po;0;AL;;;;;N;;;;;
 10F59;SOGDIAN PUNCTUATION HALF CIRCLE WITH DOT;Po;0;AL;;;;;N;;;;;
+10FE0;ELYMAIC LETTER ALEPH;Lo;0;R;;;;;N;;;;;
+10FE1;ELYMAIC LETTER BETH;Lo;0;R;;;;;N;;;;;
+10FE2;ELYMAIC LETTER GIMEL;Lo;0;R;;;;;N;;;;;
+10FE3;ELYMAIC LETTER DALETH;Lo;0;R;;;;;N;;;;;
+10FE4;ELYMAIC LETTER HE;Lo;0;R;;;;;N;;;;;
+10FE5;ELYMAIC LETTER WAW;Lo;0;R;;;;;N;;;;;
+10FE6;ELYMAIC LETTER ZAYIN;Lo;0;R;;;;;N;;;;;
+10FE7;ELYMAIC LETTER HETH;Lo;0;R;;;;;N;;;;;
+10FE8;ELYMAIC LETTER TETH;Lo;0;R;;;;;N;;;;;
+10FE9;ELYMAIC LETTER YODH;Lo;0;R;;;;;N;;;;;
+10FEA;ELYMAIC LETTER KAPH;Lo;0;R;;;;;N;;;;;
+10FEB;ELYMAIC LETTER LAMEDH;Lo;0;R;;;;;N;;;;;
+10FEC;ELYMAIC LETTER MEM;Lo;0;R;;;;;N;;;;;
+10FED;ELYMAIC LETTER NUN;Lo;0;R;;;;;N;;;;;
+10FEE;ELYMAIC LETTER SAMEKH;Lo;0;R;;;;;N;;;;;
+10FEF;ELYMAIC LETTER AYIN;Lo;0;R;;;;;N;;;;;
+10FF0;ELYMAIC LETTER PE;Lo;0;R;;;;;N;;;;;
+10FF1;ELYMAIC LETTER SADHE;Lo;0;R;;;;;N;;;;;
+10FF2;ELYMAIC LETTER QOPH;Lo;0;R;;;;;N;;;;;
+10FF3;ELYMAIC LETTER RESH;Lo;0;R;;;;;N;;;;;
+10FF4;ELYMAIC LETTER SHIN;Lo;0;R;;;;;N;;;;;
+10FF5;ELYMAIC LETTER TAW;Lo;0;R;;;;;N;;;;;
+10FF6;ELYMAIC LIGATURE ZAYIN-YODH;Lo;0;R;;;;;N;;;;;
 11000;BRAHMI SIGN CANDRABINDU;Mc;0;L;;;;;N;;;;;
 11001;BRAHMI SIGN ANUSVARA;Mn;0;NSM;;;;;N;;;;;
 11002;BRAHMI SIGN VISARGA;Mc;0;L;;;;;N;;;;;
@@ -19887,6 +19943,7 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 1145B;NEWA PLACEHOLDER MARK;Po;0;L;;;;;N;;;;;
 1145D;NEWA INSERTION SIGN;Po;0;L;;;;;N;;;;;
 1145E;NEWA SANDHI MARK;Mn;230;NSM;;;;;N;;;;;
+1145F;NEWA LETTER VEDIC ANUSVARA;Lo;0;L;;;;;N;;;;;
 11480;TIRHUTA ANJI;Lo;0;L;;;;;N;;;;;
 11481;TIRHUTA LETTER A;Lo;0;L;;;;;N;;;;;
 11482;TIRHUTA LETTER AA;Lo;0;L;;;;;N;;;;;
@@ -20209,6 +20266,7 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 116B5;TAKRI VOWEL SIGN AU;Mn;0;NSM;;;;;N;;;;;
 116B6;TAKRI SIGN VIRAMA;Mc;9;L;;;;;N;;;;;
 116B7;TAKRI SIGN NUKTA;Mn;7;NSM;;;;;N;;;;;
+116B8;TAKRI LETTER ARCHAIC KHA;Lo;0;L;;;;;N;;;;;
 116C0;TAKRI DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;
 116C1;TAKRI DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;
 116C2;TAKRI DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;
@@ -20421,6 +20479,71 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 118F1;WARANG CITI NUMBER EIGHTY;No;0;L;;;;80;N;;;;;
 118F2;WARANG CITI NUMBER NINETY;No;0;L;;;;90;N;;;;;
 118FF;WARANG CITI OM;Lo;0;L;;;;;N;;;;;
+119A0;NANDINAGARI LETTER A;Lo;0;L;;;;;N;;;;;
+119A1;NANDINAGARI LETTER AA;Lo;0;L;;;;;N;;;;;
+119A2;NANDINAGARI LETTER I;Lo;0;L;;;;;N;;;;;
+119A3;NANDINAGARI LETTER II;Lo;0;L;;;;;N;;;;;
+119A4;NANDINAGARI LETTER U;Lo;0;L;;;;;N;;;;;
+119A5;NANDINAGARI LETTER UU;Lo;0;L;;;;;N;;;;;
+119A6;NANDINAGARI LETTER VOCALIC R;Lo;0;L;;;;;N;;;;;
+119A7;NANDINAGARI LETTER VOCALIC RR;Lo;0;L;;;;;N;;;;;
+119AA;NANDINAGARI LETTER E;Lo;0;L;;;;;N;;;;;
+119AB;NANDINAGARI LETTER AI;Lo;0;L;;;;;N;;;;;
+119AC;NANDINAGARI LETTER O;Lo;0;L;;;;;N;;;;;
+119AD;NANDINAGARI LETTER AU;Lo;0;L;;;;;N;;;;;
+119AE;NANDINAGARI LETTER KA;Lo;0;L;;;;;N;;;;;
+119AF;NANDINAGARI LETTER KHA;Lo;0;L;;;;;N;;;;;
+119B0;NANDINAGARI LETTER GA;Lo;0;L;;;;;N;;;;;
+119B1;NANDINAGARI LETTER GHA;Lo;0;L;;;;;N;;;;;
+119B2;NANDINAGARI LETTER NGA;Lo;0;L;;;;;N;;;;;
+119B3;NANDINAGARI LETTER CA;Lo;0;L;;;;;N;;;;;
+119B4;NANDINAGARI LETTER CHA;Lo;0;L;;;;;N;;;;;
+119B5;NANDINAGARI LETTER JA;Lo;0;L;;;;;N;;;;;
+119B6;NANDINAGARI LETTER JHA;Lo;0;L;;;;;N;;;;;
+119B7;NANDINAGARI LETTER NYA;Lo;0;L;;;;;N;;;;;
+119B8;NANDINAGARI LETTER TTA;Lo;0;L;;;;;N;;;;;
+119B9;NANDINAGARI LETTER TTHA;Lo;0;L;;;;;N;;;;;
+119BA;NANDINAGARI LETTER DDA;Lo;0;L;;;;;N;;;;;
+119BB;NANDINAGARI LETTER DDHA;Lo;0;L;;;;;N;;;;;
+119BC;NANDINAGARI LETTER NNA;Lo;0;L;;;;;N;;;;;
+119BD;NANDINAGARI LETTER TA;Lo;0;L;;;;;N;;;;;
+119BE;NANDINAGARI LETTER THA;Lo;0;L;;;;;N;;;;;
+119BF;NANDINAGARI LETTER DA;Lo;0;L;;;;;N;;;;;
+119C0;NANDINAGARI LETTER DHA;Lo;0;L;;;;;N;;;;;
+119C1;NANDINAGARI LETTER NA;Lo;0;L;;;;;N;;;;;
+119C2;NANDINAGARI LETTER PA;Lo;0;L;;;;;N;;;;;
+119C3;NANDINAGARI LETTER PHA;Lo;0;L;;;;;N;;;;;
+119C4;NANDINAGARI LETTER BA;Lo;0;L;;;;;N;;;;;
+119C5;NANDINAGARI LETTER BHA;Lo;0;L;;;;;N;;;;;
+119C6;NANDINAGARI LETTER MA;Lo;0;L;;;;;N;;;;;
+119C7;NANDINAGARI LETTER YA;Lo;0;L;;;;;N;;;;;
+119C8;NANDINAGARI LETTER RA;Lo;0;L;;;;;N;;;;;
+119C9;NANDINAGARI LETTER LA;Lo;0;L;;;;;N;;;;;
+119CA;NANDINAGARI LETTER VA;Lo;0;L;;;;;N;;;;;
+119CB;NANDINAGARI LETTER SHA;Lo;0;L;;;;;N;;;;;
+119CC;NANDINAGARI LETTER SSA;Lo;0;L;;;;;N;;;;;
+119CD;NANDINAGARI LETTER SA;Lo;0;L;;;;;N;;;;;
+119CE;NANDINAGARI LETTER HA;Lo;0;L;;;;;N;;;;;
+119CF;NANDINAGARI LETTER LLA;Lo;0;L;;;;;N;;;;;
+119D0;NANDINAGARI LETTER RRA;Lo;0;L;;;;;N;;;;;
+119D1;NANDINAGARI VOWEL SIGN AA;Mc;0;L;;;;;N;;;;;
+119D2;NANDINAGARI VOWEL SIGN I;Mc;0;L;;;;;N;;;;;
+119D3;NANDINAGARI VOWEL SIGN II;Mc;0;L;;;;;N;;;;;
+119D4;NANDINAGARI VOWEL SIGN U;Mn;0;NSM;;;;;N;;;;;
+119D5;NANDINAGARI VOWEL SIGN UU;Mn;0;NSM;;;;;N;;;;;
+119D6;NANDINAGARI VOWEL SIGN VOCALIC R;Mn;0;NSM;;;;;N;;;;;
+119D7;NANDINAGARI VOWEL SIGN VOCALIC RR;Mn;0;NSM;;;;;N;;;;;
+119DA;NANDINAGARI VOWEL SIGN E;Mn;0;NSM;;;;;N;;;;;
+119DB;NANDINAGARI VOWEL SIGN AI;Mn;0;NSM;;;;;N;;;;;
+119DC;NANDINAGARI VOWEL SIGN O;Mc;0;L;;;;;N;;;;;
+119DD;NANDINAGARI VOWEL SIGN AU;Mc;0;L;;;;;N;;;;;
+119DE;NANDINAGARI SIGN ANUSVARA;Mc;0;L;;;;;N;;;;;
+119DF;NANDINAGARI SIGN VISARGA;Mc;0;L;;;;;N;;;;;
+119E0;NANDINAGARI SIGN VIRAMA;Mn;9;NSM;;;;;N;;;;;
+119E1;NANDINAGARI SIGN AVAGRAHA;Lo;0;L;;;;;N;;;;;
+119E2;NANDINAGARI SIGN SIDDHAM;Po;0;L;;;;;N;;;;;
+119E3;NANDINAGARI HEADSTROKE;Lo;0;L;;;;;N;;;;;
+119E4;NANDINAGARI VOWEL SIGN PRISHTHAMATRA E;Mc;0;L;;;;;N;;;;;
 11A00;ZANABAZAR SQUARE LETTER A;Lo;0;L;;;;;N;;;;;
 11A01;ZANABAZAR SQUARE VOWEL SIGN I;Mn;0;NSM;;;;;N;;;;;
 11A02;ZANABAZAR SQUARE VOWEL SIGN UE;Mn;0;NSM;;;;;N;;;;;
@@ -20545,6 +20668,8 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 11A81;SOYOMBO LETTER SA;Lo;0;L;;;;;N;;;;;
 11A82;SOYOMBO LETTER HA;Lo;0;L;;;;;N;;;;;
 11A83;SOYOMBO LETTER KSSA;Lo;0;L;;;;;N;;;;;
+11A84;SOYOMBO SIGN JIHVAMULIYA;Lo;0;L;;;;;N;;;;;
+11A85;SOYOMBO SIGN UPADHMANIYA;Lo;0;L;;;;;N;;;;;
 11A86;SOYOMBO CLUSTER-INITIAL LETTER RA;Lo;0;L;;;;;N;;;;;
 11A87;SOYOMBO CLUSTER-INITIAL LETTER LA;Lo;0;L;;;;;N;;;;;
 11A88;SOYOMBO CLUSTER-INITIAL LETTER SHA;Lo;0;L;;;;;N;;;;;
@@ -20959,6 +21084,57 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 11EF6;MAKASAR VOWEL SIGN O;Mc;0;L;;;;;N;;;;;
 11EF7;MAKASAR PASSIMBANG;Po;0;L;;;;;N;;;;;
 11EF8;MAKASAR END OF SECTION;Po;0;L;;;;;N;;;;;
+11FC0;TAMIL FRACTION ONE THREE-HUNDRED-AND-TWENTIETH;No;0;L;;;;1/320;N;;;;;
+11FC1;TAMIL FRACTION ONE ONE-HUNDRED-AND-SIXTIETH;No;0;L;;;;1/160;N;;;;;
+11FC2;TAMIL FRACTION ONE EIGHTIETH;No;0;L;;;;1/80;N;;;;;
+11FC3;TAMIL FRACTION ONE SIXTY-FOURTH;No;0;L;;;;1/64;N;;;;;
+11FC4;TAMIL FRACTION ONE FORTIETH;No;0;L;;;;1/40;N;;;;;
+11FC5;TAMIL FRACTION ONE THIRTY-SECOND;No;0;L;;;;1/32;N;;;;;
+11FC6;TAMIL FRACTION THREE EIGHTIETHS;No;0;L;;;;3/80;N;;;;;
+11FC7;TAMIL FRACTION THREE SIXTY-FOURTHS;No;0;L;;;;3/64;N;;;;;
+11FC8;TAMIL FRACTION ONE TWENTIETH;No;0;L;;;;1/20;N;;;;;
+11FC9;TAMIL FRACTION ONE SIXTEENTH-1;No;0;L;;;;1/16;N;;;;;
+11FCA;TAMIL FRACTION ONE SIXTEENTH-2;No;0;L;;;;1/16;N;;;;;
+11FCB;TAMIL FRACTION ONE TENTH;No;0;L;;;;1/10;N;;;;;
+11FCC;TAMIL FRACTION ONE EIGHTH;No;0;L;;;;1/8;N;;;;;
+11FCD;TAMIL FRACTION THREE TWENTIETHS;No;0;L;;;;3/20;N;;;;;
+11FCE;TAMIL FRACTION THREE SIXTEENTHS;No;0;L;;;;3/16;N;;;;;
+11FCF;TAMIL FRACTION ONE FIFTH;No;0;L;;;;1/5;N;;;;;
+11FD0;TAMIL FRACTION ONE QUARTER;No;0;L;;;;1/4;N;;;;;
+11FD1;TAMIL FRACTION ONE HALF-1;No;0;L;;;;1/2;N;;;;;
+11FD2;TAMIL FRACTION ONE HALF-2;No;0;L;;;;1/2;N;;;;;
+11FD3;TAMIL FRACTION THREE QUARTERS;No;0;L;;;;3/4;N;;;;;
+11FD4;TAMIL FRACTION DOWNSCALING FACTOR KIIZH;No;0;L;;;;1/320;N;;;;;
+11FD5;TAMIL SIGN NEL;So;0;ON;;;;;N;;;;;
+11FD6;TAMIL SIGN CEVITU;So;0;ON;;;;;N;;;;;
+11FD7;TAMIL SIGN AAZHAAKKU;So;0;ON;;;;;N;;;;;
+11FD8;TAMIL SIGN UZHAKKU;So;0;ON;;;;;N;;;;;
+11FD9;TAMIL SIGN MUUVUZHAKKU;So;0;ON;;;;;N;;;;;
+11FDA;TAMIL SIGN KURUNI;So;0;ON;;;;;N;;;;;
+11FDB;TAMIL SIGN PATHAKKU;So;0;ON;;;;;N;;;;;
+11FDC;TAMIL SIGN MUKKURUNI;So;0;ON;;;;;N;;;;;
+11FDD;TAMIL SIGN KAACU;Sc;0;ET;;;;;N;;;;;
+11FDE;TAMIL SIGN PANAM;Sc;0;ET;;;;;N;;;;;
+11FDF;TAMIL SIGN PON;Sc;0;ET;;;;;N;;;;;
+11FE0;TAMIL SIGN VARAAKAN;Sc;0;ET;;;;;N;;;;;
+11FE1;TAMIL SIGN PAARAM;So;0;ON;;;;;N;;;;;
+11FE2;TAMIL SIGN KUZHI;So;0;ON;;;;;N;;;;;
+11FE3;TAMIL SIGN VELI;So;0;ON;;;;;N;;;;;
+11FE4;TAMIL WET CULTIVATION SIGN;So;0;ON;;;;;N;;;;;
+11FE5;TAMIL DRY CULTIVATION SIGN;So;0;ON;;;;;N;;;;;
+11FE6;TAMIL LAND SIGN;So;0;ON;;;;;N;;;;;
+11FE7;TAMIL SALT PAN SIGN;So;0;ON;;;;;N;;;;;
+11FE8;TAMIL TRADITIONAL CREDIT SIGN;So;0;ON;;;;;N;;;;;
+11FE9;TAMIL TRADITIONAL NUMBER SIGN;So;0;ON;;;;;N;;;;;
+11FEA;TAMIL CURRENT SIGN;So;0;ON;;;;;N;;;;;
+11FEB;TAMIL AND ODD SIGN;So;0;ON;;;;;N;;;;;
+11FEC;TAMIL SPENT SIGN;So;0;ON;;;;;N;;;;;
+11FED;TAMIL TOTAL SIGN;So;0;ON;;;;;N;;;;;
+11FEE;TAMIL IN POSSESSION SIGN;So;0;ON;;;;;N;;;;;
+11FEF;TAMIL STARTING FROM SIGN;So;0;ON;;;;;N;;;;;
+11FF0;TAMIL SIGN MUTHALIYA;So;0;ON;;;;;N;;;;;
+11FF1;TAMIL SIGN VAKAIYARAA;So;0;ON;;;;;N;;;;;
+11FFF;TAMIL PUNCTUATION END OF TEXT;Po;0;L;;;;;N;;;;;
 12000;CUNEIFORM SIGN A;Lo;0;L;;;;;N;;;;;
 12001;CUNEIFORM SIGN A TIMES A;Lo;0;L;;;;;N;;;;;
 12002;CUNEIFORM SIGN A TIMES BAD;Lo;0;L;;;;;N;;;;;
@@ -23264,6 +23440,15 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 1342C;EGYPTIAN HIEROGLYPH AA030;Lo;0;L;;;;;N;;;;;
 1342D;EGYPTIAN HIEROGLYPH AA031;Lo;0;L;;;;;N;;;;;
 1342E;EGYPTIAN HIEROGLYPH AA032;Lo;0;L;;;;;N;;;;;
+13430;EGYPTIAN HIEROGLYPH VERTICAL JOINER;Cf;0;L;;;;;N;;;;;
+13431;EGYPTIAN HIEROGLYPH HORIZONTAL JOINER;Cf;0;L;;;;;N;;;;;
+13432;EGYPTIAN HIEROGLYPH INSERT AT TOP START;Cf;0;L;;;;;N;;;;;
+13433;EGYPTIAN HIEROGLYPH INSERT AT BOTTOM START;Cf;0;L;;;;;N;;;;;
+13434;EGYPTIAN HIEROGLYPH INSERT AT TOP END;Cf;0;L;;;;;N;;;;;
+13435;EGYPTIAN HIEROGLYPH INSERT AT BOTTOM END;Cf;0;L;;;;;N;;;;;
+13436;EGYPTIAN HIEROGLYPH OVERLAY MIDDLE;Cf;0;L;;;;;N;;;;;
+13437;EGYPTIAN HIEROGLYPH BEGIN SEGMENT;Cf;0;L;;;;;N;;;;;
+13438;EGYPTIAN HIEROGLYPH END SEGMENT;Cf;0;L;;;;;N;;;;;
 14400;ANATOLIAN HIEROGLYPH A001;Lo;0;L;;;;;N;;;;;
 14401;ANATOLIAN HIEROGLYPH A002;Lo;0;L;;;;;N;;;;;
 14402;ANATOLIAN HIEROGLYPH A003;Lo;0;L;;;;;N;;;;;
@@ -24782,6 +24967,13 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 16F42;MIAO LETTER WA;Lo;0;L;;;;;N;;;;;
 16F43;MIAO LETTER AH;Lo;0;L;;;;;N;;;;;
 16F44;MIAO LETTER HHA;Lo;0;L;;;;;N;;;;;
+16F45;MIAO LETTER BRI;Lo;0;L;;;;;N;;;;;
+16F46;MIAO LETTER SYI;Lo;0;L;;;;;N;;;;;
+16F47;MIAO LETTER DZYI;Lo;0;L;;;;;N;;;;;
+16F48;MIAO LETTER TE;Lo;0;L;;;;;N;;;;;
+16F49;MIAO LETTER TSE;Lo;0;L;;;;;N;;;;;
+16F4A;MIAO LETTER RTE;Lo;0;L;;;;;N;;;;;
+16F4F;MIAO SIGN CONSONANT MODIFIER BAR;Mn;0;NSM;;;;;N;;;;;
 16F50;MIAO LETTER NASALIZATION;Lo;0;L;;;;;N;;;;;
 16F51;MIAO SIGN ASPIRATION;Mc;0;L;;;;;N;;;;;
 16F52;MIAO SIGN REFORMED VOICING;Mc;0;L;;;;;N;;;;;
@@ -24829,6 +25021,15 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 16F7C;MIAO VOWEL SIGN OU;Mc;0;L;;;;;N;;;;;
 16F7D;MIAO VOWEL SIGN N;Mc;0;L;;;;;N;;;;;
 16F7E;MIAO VOWEL SIGN NG;Mc;0;L;;;;;N;;;;;
+16F7F;MIAO VOWEL SIGN UOG;Mc;0;L;;;;;N;;;;;
+16F80;MIAO VOWEL SIGN YUI;Mc;0;L;;;;;N;;;;;
+16F81;MIAO VOWEL SIGN OG;Mc;0;L;;;;;N;;;;;
+16F82;MIAO VOWEL SIGN OER;Mc;0;L;;;;;N;;;;;
+16F83;MIAO VOWEL SIGN VW;Mc;0;L;;;;;N;;;;;
+16F84;MIAO VOWEL SIGN IG;Mc;0;L;;;;;N;;;;;
+16F85;MIAO VOWEL SIGN EA;Mc;0;L;;;;;N;;;;;
+16F86;MIAO VOWEL SIGN IONG;Mc;0;L;;;;;N;;;;;
+16F87;MIAO VOWEL SIGN UI;Mc;0;L;;;;;N;;;;;
 16F8F;MIAO TONE RIGHT;Mn;0;NSM;;;;;N;;;;;
 16F90;MIAO TONE TOP RIGHT;Mn;0;NSM;;;;;N;;;;;
 16F91;MIAO TONE ABOVE;Mn;0;NSM;;;;;N;;;;;
@@ -24848,8 +25049,10 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 16F9F;MIAO LETTER REFORMED TONE-8;Lm;0;L;;;;;N;;;;;
 16FE0;TANGUT ITERATION MARK;Lm;0;L;;;;;N;;;;;
 16FE1;NUSHU ITERATION MARK;Lm;0;L;;;;;N;;;;;
+16FE2;OLD CHINESE HOOK MARK;Po;0;ON;;;;;N;;;;;
+16FE3;OLD CHINESE ITERATION MARK;Lm;0;L;;;;;N;;;;;
 17000;<Tangut Ideograph, First>;Lo;0;L;;;;;N;;;;;
-187F1;<Tangut Ideograph, Last>;Lo;0;L;;;;;N;;;;;
+187F7;<Tangut Ideograph, Last>;Lo;0;L;;;;;N;;;;;
 18800;TANGUT COMPONENT-001;Lo;0;L;;;;;N;;;;;
 18801;TANGUT COMPONENT-002;Lo;0;L;;;;;N;;;;;
 18802;TANGUT COMPONENT-003;Lo;0;L;;;;;N;;;;;
@@ -25892,6 +26095,13 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 1B11C;HENTAIGANA LETTER WO-7;Lo;0;L;;;;;N;;;;;
 1B11D;HENTAIGANA LETTER N-MU-MO-1;Lo;0;L;;;;;N;;;;;
 1B11E;HENTAIGANA LETTER N-MU-MO-2;Lo;0;L;;;;;N;;;;;
+1B150;HIRAGANA LETTER SMALL WI;Lo;0;L;;;;;N;;;;;
+1B151;HIRAGANA LETTER SMALL WE;Lo;0;L;;;;;N;;;;;
+1B152;HIRAGANA LETTER SMALL WO;Lo;0;L;;;;;N;;;;;
+1B164;KATAKANA LETTER SMALL WI;Lo;0;L;;;;;N;;;;;
+1B165;KATAKANA LETTER SMALL WE;Lo;0;L;;;;;N;;;;;
+1B166;KATAKANA LETTER SMALL WO;Lo;0;L;;;;;N;;;;;
+1B167;KATAKANA LETTER SMALL N;Lo;0;L;;;;;N;;;;;
 1B170;NUSHU CHARACTER-1B170;Lo;0;L;;;;;N;;;;;
 1B171;NUSHU CHARACTER-1B171;Lo;0;L;;;;;N;;;;;
 1B172;NUSHU CHARACTER-1B172;Lo;0;L;;;;;N;;;;;
@@ -28820,6 +29030,136 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 1E028;COMBINING GLAGOLITIC LETTER BIG YUS;Mn;230;NSM;;;;;N;;;;;
 1E029;COMBINING GLAGOLITIC LETTER IOTATED BIG YUS;Mn;230;NSM;;;;;N;;;;;
 1E02A;COMBINING GLAGOLITIC LETTER FITA;Mn;230;NSM;;;;;N;;;;;
+1E100;NYIAKENG PUACHUE HMONG LETTER MA;Lo;0;L;;;;;N;;;;;
+1E101;NYIAKENG PUACHUE HMONG LETTER TSA;Lo;0;L;;;;;N;;;;;
+1E102;NYIAKENG PUACHUE HMONG LETTER NTA;Lo;0;L;;;;;N;;;;;
+1E103;NYIAKENG PUACHUE HMONG LETTER TA;Lo;0;L;;;;;N;;;;;
+1E104;NYIAKENG PUACHUE HMONG LETTER HA;Lo;0;L;;;;;N;;;;;
+1E105;NYIAKENG PUACHUE HMONG LETTER NA;Lo;0;L;;;;;N;;;;;
+1E106;NYIAKENG PUACHUE HMONG LETTER XA;Lo;0;L;;;;;N;;;;;
+1E107;NYIAKENG PUACHUE HMONG LETTER NKA;Lo;0;L;;;;;N;;;;;
+1E108;NYIAKENG PUACHUE HMONG LETTER CA;Lo;0;L;;;;;N;;;;;
+1E109;NYIAKENG PUACHUE HMONG LETTER LA;Lo;0;L;;;;;N;;;;;
+1E10A;NYIAKENG PUACHUE HMONG LETTER SA;Lo;0;L;;;;;N;;;;;
+1E10B;NYIAKENG PUACHUE HMONG LETTER ZA;Lo;0;L;;;;;N;;;;;
+1E10C;NYIAKENG PUACHUE HMONG LETTER NCA;Lo;0;L;;;;;N;;;;;
+1E10D;NYIAKENG PUACHUE HMONG LETTER NTSA;Lo;0;L;;;;;N;;;;;
+1E10E;NYIAKENG PUACHUE HMONG LETTER KA;Lo;0;L;;;;;N;;;;;
+1E10F;NYIAKENG PUACHUE HMONG LETTER DA;Lo;0;L;;;;;N;;;;;
+1E110;NYIAKENG PUACHUE HMONG LETTER NYA;Lo;0;L;;;;;N;;;;;
+1E111;NYIAKENG PUACHUE HMONG LETTER NRA;Lo;0;L;;;;;N;;;;;
+1E112;NYIAKENG PUACHUE HMONG LETTER VA;Lo;0;L;;;;;N;;;;;
+1E113;NYIAKENG PUACHUE HMONG LETTER NTXA;Lo;0;L;;;;;N;;;;;
+1E114;NYIAKENG PUACHUE HMONG LETTER TXA;Lo;0;L;;;;;N;;;;;
+1E115;NYIAKENG PUACHUE HMONG LETTER FA;Lo;0;L;;;;;N;;;;;
+1E116;NYIAKENG PUACHUE HMONG LETTER RA;Lo;0;L;;;;;N;;;;;
+1E117;NYIAKENG PUACHUE HMONG LETTER QA;Lo;0;L;;;;;N;;;;;
+1E118;NYIAKENG PUACHUE HMONG LETTER YA;Lo;0;L;;;;;N;;;;;
+1E119;NYIAKENG PUACHUE HMONG LETTER NQA;Lo;0;L;;;;;N;;;;;
+1E11A;NYIAKENG PUACHUE HMONG LETTER PA;Lo;0;L;;;;;N;;;;;
+1E11B;NYIAKENG PUACHUE HMONG LETTER XYA;Lo;0;L;;;;;N;;;;;
+1E11C;NYIAKENG PUACHUE HMONG LETTER NPA;Lo;0;L;;;;;N;;;;;
+1E11D;NYIAKENG PUACHUE HMONG LETTER DLA;Lo;0;L;;;;;N;;;;;
+1E11E;NYIAKENG PUACHUE HMONG LETTER NPLA;Lo;0;L;;;;;N;;;;;
+1E11F;NYIAKENG PUACHUE HMONG LETTER HAH;Lo;0;L;;;;;N;;;;;
+1E120;NYIAKENG PUACHUE HMONG LETTER MLA;Lo;0;L;;;;;N;;;;;
+1E121;NYIAKENG PUACHUE HMONG LETTER PLA;Lo;0;L;;;;;N;;;;;
+1E122;NYIAKENG PUACHUE HMONG LETTER GA;Lo;0;L;;;;;N;;;;;
+1E123;NYIAKENG PUACHUE HMONG LETTER RRA;Lo;0;L;;;;;N;;;;;
+1E124;NYIAKENG PUACHUE HMONG LETTER A;Lo;0;L;;;;;N;;;;;
+1E125;NYIAKENG PUACHUE HMONG LETTER AA;Lo;0;L;;;;;N;;;;;
+1E126;NYIAKENG PUACHUE HMONG LETTER I;Lo;0;L;;;;;N;;;;;
+1E127;NYIAKENG PUACHUE HMONG LETTER U;Lo;0;L;;;;;N;;;;;
+1E128;NYIAKENG PUACHUE HMONG LETTER O;Lo;0;L;;;;;N;;;;;
+1E129;NYIAKENG PUACHUE HMONG LETTER OO;Lo;0;L;;;;;N;;;;;
+1E12A;NYIAKENG PUACHUE HMONG LETTER E;Lo;0;L;;;;;N;;;;;
+1E12B;NYIAKENG PUACHUE HMONG LETTER EE;Lo;0;L;;;;;N;;;;;
+1E12C;NYIAKENG PUACHUE HMONG LETTER W;Lo;0;L;;;;;N;;;;;
+1E130;NYIAKENG PUACHUE HMONG TONE-B;Mn;230;NSM;;;;;N;;;;;
+1E131;NYIAKENG PUACHUE HMONG TONE-M;Mn;230;NSM;;;;;N;;;;;
+1E132;NYIAKENG PUACHUE HMONG TONE-J;Mn;230;NSM;;;;;N;;;;;
+1E133;NYIAKENG PUACHUE HMONG TONE-V;Mn;230;NSM;;;;;N;;;;;
+1E134;NYIAKENG PUACHUE HMONG TONE-S;Mn;230;NSM;;;;;N;;;;;
+1E135;NYIAKENG PUACHUE HMONG TONE-G;Mn;230;NSM;;;;;N;;;;;
+1E136;NYIAKENG PUACHUE HMONG TONE-D;Mn;230;NSM;;;;;N;;;;;
+1E137;NYIAKENG PUACHUE HMONG SIGN FOR PERSON;Lm;0;L;;;;;N;;;;;
+1E138;NYIAKENG PUACHUE HMONG SIGN FOR THING;Lm;0;L;;;;;N;;;;;
+1E139;NYIAKENG PUACHUE HMONG SIGN FOR LOCATION;Lm;0;L;;;;;N;;;;;
+1E13A;NYIAKENG PUACHUE HMONG SIGN FOR ANIMAL;Lm;0;L;;;;;N;;;;;
+1E13B;NYIAKENG PUACHUE HMONG SIGN FOR INVERTEBRATE;Lm;0;L;;;;;N;;;;;
+1E13C;NYIAKENG PUACHUE HMONG SIGN XW XW;Lm;0;L;;;;;N;;;;;
+1E13D;NYIAKENG PUACHUE HMONG SYLLABLE LENGTHENER;Lm;0;L;;;;;N;;;;;
+1E140;NYIAKENG PUACHUE HMONG DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;
+1E141;NYIAKENG PUACHUE HMONG DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;
+1E142;NYIAKENG PUACHUE HMONG DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;
+1E143;NYIAKENG PUACHUE HMONG DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;
+1E144;NYIAKENG PUACHUE HMONG DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;
+1E145;NYIAKENG PUACHUE HMONG DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;
+1E146;NYIAKENG PUACHUE HMONG DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;
+1E147;NYIAKENG PUACHUE HMONG DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;
+1E148;NYIAKENG PUACHUE HMONG DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;
+1E149;NYIAKENG PUACHUE HMONG DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;
+1E14E;NYIAKENG PUACHUE HMONG LOGOGRAM NYAJ;Lo;0;L;;;;;N;;;;;
+1E14F;NYIAKENG PUACHUE HMONG CIRCLED CA;So;0;L;;;;;N;;;;;
+1E2C0;WANCHO LETTER AA;Lo;0;L;;;;;N;;;;;
+1E2C1;WANCHO LETTER A;Lo;0;L;;;;;N;;;;;
+1E2C2;WANCHO LETTER BA;Lo;0;L;;;;;N;;;;;
+1E2C3;WANCHO LETTER CA;Lo;0;L;;;;;N;;;;;
+1E2C4;WANCHO LETTER DA;Lo;0;L;;;;;N;;;;;
+1E2C5;WANCHO LETTER GA;Lo;0;L;;;;;N;;;;;
+1E2C6;WANCHO LETTER YA;Lo;0;L;;;;;N;;;;;
+1E2C7;WANCHO LETTER PHA;Lo;0;L;;;;;N;;;;;
+1E2C8;WANCHO LETTER LA;Lo;0;L;;;;;N;;;;;
+1E2C9;WANCHO LETTER NA;Lo;0;L;;;;;N;;;;;
+1E2CA;WANCHO LETTER PA;Lo;0;L;;;;;N;;;;;
+1E2CB;WANCHO LETTER TA;Lo;0;L;;;;;N;;;;;
+1E2CC;WANCHO LETTER THA;Lo;0;L;;;;;N;;;;;
+1E2CD;WANCHO LETTER FA;Lo;0;L;;;;;N;;;;;
+1E2CE;WANCHO LETTER SA;Lo;0;L;;;;;N;;;;;
+1E2CF;WANCHO LETTER SHA;Lo;0;L;;;;;N;;;;;
+1E2D0;WANCHO LETTER JA;Lo;0;L;;;;;N;;;;;
+1E2D1;WANCHO LETTER ZA;Lo;0;L;;;;;N;;;;;
+1E2D2;WANCHO LETTER WA;Lo;0;L;;;;;N;;;;;
+1E2D3;WANCHO LETTER VA;Lo;0;L;;;;;N;;;;;
+1E2D4;WANCHO LETTER KA;Lo;0;L;;;;;N;;;;;
+1E2D5;WANCHO LETTER O;Lo;0;L;;;;;N;;;;;
+1E2D6;WANCHO LETTER AU;Lo;0;L;;;;;N;;;;;
+1E2D7;WANCHO LETTER RA;Lo;0;L;;;;;N;;;;;
+1E2D8;WANCHO LETTER MA;Lo;0;L;;;;;N;;;;;
+1E2D9;WANCHO LETTER KHA;Lo;0;L;;;;;N;;;;;
+1E2DA;WANCHO LETTER HA;Lo;0;L;;;;;N;;;;;
+1E2DB;WANCHO LETTER E;Lo;0;L;;;;;N;;;;;
+1E2DC;WANCHO LETTER I;Lo;0;L;;;;;N;;;;;
+1E2DD;WANCHO LETTER NGA;Lo;0;L;;;;;N;;;;;
+1E2DE;WANCHO LETTER U;Lo;0;L;;;;;N;;;;;
+1E2DF;WANCHO LETTER LLHA;Lo;0;L;;;;;N;;;;;
+1E2E0;WANCHO LETTER TSA;Lo;0;L;;;;;N;;;;;
+1E2E1;WANCHO LETTER TRA;Lo;0;L;;;;;N;;;;;
+1E2E2;WANCHO LETTER ONG;Lo;0;L;;;;;N;;;;;
+1E2E3;WANCHO LETTER AANG;Lo;0;L;;;;;N;;;;;
+1E2E4;WANCHO LETTER ANG;Lo;0;L;;;;;N;;;;;
+1E2E5;WANCHO LETTER ING;Lo;0;L;;;;;N;;;;;
+1E2E6;WANCHO LETTER ON;Lo;0;L;;;;;N;;;;;
+1E2E7;WANCHO LETTER EN;Lo;0;L;;;;;N;;;;;
+1E2E8;WANCHO LETTER AAN;Lo;0;L;;;;;N;;;;;
+1E2E9;WANCHO LETTER NYA;Lo;0;L;;;;;N;;;;;
+1E2EA;WANCHO LETTER UEN;Lo;0;L;;;;;N;;;;;
+1E2EB;WANCHO LETTER YIH;Lo;0;L;;;;;N;;;;;
+1E2EC;WANCHO TONE TUP;Mn;230;NSM;;;;;N;;;;;
+1E2ED;WANCHO TONE TUPNI;Mn;230;NSM;;;;;N;;;;;
+1E2EE;WANCHO TONE KOI;Mn;230;NSM;;;;;N;;;;;
+1E2EF;WANCHO TONE KOINI;Mn;230;NSM;;;;;N;;;;;
+1E2F0;WANCHO DIGIT ZERO;Nd;0;L;;0;0;0;N;;;;;
+1E2F1;WANCHO DIGIT ONE;Nd;0;L;;1;1;1;N;;;;;
+1E2F2;WANCHO DIGIT TWO;Nd;0;L;;2;2;2;N;;;;;
+1E2F3;WANCHO DIGIT THREE;Nd;0;L;;3;3;3;N;;;;;
+1E2F4;WANCHO DIGIT FOUR;Nd;0;L;;4;4;4;N;;;;;
+1E2F5;WANCHO DIGIT FIVE;Nd;0;L;;5;5;5;N;;;;;
+1E2F6;WANCHO DIGIT SIX;Nd;0;L;;6;6;6;N;;;;;
+1E2F7;WANCHO DIGIT SEVEN;Nd;0;L;;7;7;7;N;;;;;
+1E2F8;WANCHO DIGIT EIGHT;Nd;0;L;;8;8;8;N;;;;;
+1E2F9;WANCHO DIGIT NINE;Nd;0;L;;9;9;9;N;;;;;
+1E2FF;WANCHO NGUN SIGN;Sc;0;ET;;;;;N;;;;;
 1E800;MENDE KIKAKUI SYLLABLE M001 KI;Lo;0;R;;;;;N;;;;;
 1E801;MENDE KIKAKUI SYLLABLE M002 KA;Lo;0;R;;;;;N;;;;;
 1E802;MENDE KIKAKUI SYLLABLE M003 KU;Lo;0;R;;;;;N;;;;;
@@ -29108,6 +29448,7 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 1E948;ADLAM CONSONANT MODIFIER;Mn;230;NSM;;;;;N;;;;;
 1E949;ADLAM GEMINATE CONSONANT MODIFIER;Mn;230;NSM;;;;;N;;;;;
 1E94A;ADLAM NUKTA;Mn;7;NSM;;;;;N;;;;;
+1E94B;ADLAM NASALIZATION MARK;Lm;0;R;;;;;N;;;;;
 1E950;ADLAM DIGIT ZERO;Nd;0;R;;0;0;0;N;;;;;
 1E951;ADLAM DIGIT ONE;Nd;0;R;;1;1;1;N;;;;;
 1E952;ADLAM DIGIT TWO;Nd;0;R;;2;2;2;N;;;;;
@@ -29188,6 +29529,67 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 1ECB2;INDIC SIYAQ NUMBER ALTERNATE TWO;No;0;AL;;;;2;N;;;;;
 1ECB3;INDIC SIYAQ NUMBER ALTERNATE TEN THOUSAND;No;0;AL;;;;10000;N;;;;;
 1ECB4;INDIC SIYAQ ALTERNATE LAKH MARK;No;0;AL;;;;100000;N;;;;;
+1ED01;OTTOMAN SIYAQ NUMBER ONE;No;0;AL;;;;1;N;;;;;
+1ED02;OTTOMAN SIYAQ NUMBER TWO;No;0;AL;;;;2;N;;;;;
+1ED03;OTTOMAN SIYAQ NUMBER THREE;No;0;AL;;;;3;N;;;;;
+1ED04;OTTOMAN SIYAQ NUMBER FOUR;No;0;AL;;;;4;N;;;;;
+1ED05;OTTOMAN SIYAQ NUMBER FIVE;No;0;AL;;;;5;N;;;;;
+1ED06;OTTOMAN SIYAQ NUMBER SIX;No;0;AL;;;;6;N;;;;;
+1ED07;OTTOMAN SIYAQ NUMBER SEVEN;No;0;AL;;;;7;N;;;;;
+1ED08;OTTOMAN SIYAQ NUMBER EIGHT;No;0;AL;;;;8;N;;;;;
+1ED09;OTTOMAN SIYAQ NUMBER NINE;No;0;AL;;;;9;N;;;;;
+1ED0A;OTTOMAN SIYAQ NUMBER TEN;No;0;AL;;;;10;N;;;;;
+1ED0B;OTTOMAN SIYAQ NUMBER TWENTY;No;0;AL;;;;20;N;;;;;
+1ED0C;OTTOMAN SIYAQ NUMBER THIRTY;No;0;AL;;;;30;N;;;;;
+1ED0D;OTTOMAN SIYAQ NUMBER FORTY;No;0;AL;;;;40;N;;;;;
+1ED0E;OTTOMAN SIYAQ NUMBER FIFTY;No;0;AL;;;;50;N;;;;;
+1ED0F;OTTOMAN SIYAQ NUMBER SIXTY;No;0;AL;;;;60;N;;;;;
+1ED10;OTTOMAN SIYAQ NUMBER SEVENTY;No;0;AL;;;;70;N;;;;;
+1ED11;OTTOMAN SIYAQ NUMBER EIGHTY;No;0;AL;;;;80;N;;;;;
+1ED12;OTTOMAN SIYAQ NUMBER NINETY;No;0;AL;;;;90;N;;;;;
+1ED13;OTTOMAN SIYAQ NUMBER ONE HUNDRED;No;0;AL;;;;100;N;;;;;
+1ED14;OTTOMAN SIYAQ NUMBER TWO HUNDRED;No;0;AL;;;;200;N;;;;;
+1ED15;OTTOMAN SIYAQ NUMBER THREE HUNDRED;No;0;AL;;;;300;N;;;;;
+1ED16;OTTOMAN SIYAQ NUMBER FOUR HUNDRED;No;0;AL;;;;400;N;;;;;
+1ED17;OTTOMAN SIYAQ NUMBER FIVE HUNDRED;No;0;AL;;;;500;N;;;;;
+1ED18;OTTOMAN SIYAQ NUMBER SIX HUNDRED;No;0;AL;;;;600;N;;;;;
+1ED19;OTTOMAN SIYAQ NUMBER SEVEN HUNDRED;No;0;AL;;;;700;N;;;;;
+1ED1A;OTTOMAN SIYAQ NUMBER EIGHT HUNDRED;No;0;AL;;;;800;N;;;;;
+1ED1B;OTTOMAN SIYAQ NUMBER NINE HUNDRED;No;0;AL;;;;900;N;;;;;
+1ED1C;OTTOMAN SIYAQ NUMBER ONE THOUSAND;No;0;AL;;;;1000;N;;;;;
+1ED1D;OTTOMAN SIYAQ NUMBER TWO THOUSAND;No;0;AL;;;;2000;N;;;;;
+1ED1E;OTTOMAN SIYAQ NUMBER THREE THOUSAND;No;0;AL;;;;3000;N;;;;;
+1ED1F;OTTOMAN SIYAQ NUMBER FOUR THOUSAND;No;0;AL;;;;4000;N;;;;;
+1ED20;OTTOMAN SIYAQ NUMBER FIVE THOUSAND;No;0;AL;;;;5000;N;;;;;
+1ED21;OTTOMAN SIYAQ NUMBER SIX THOUSAND;No;0;AL;;;;6000;N;;;;;
+1ED22;OTTOMAN SIYAQ NUMBER SEVEN THOUSAND;No;0;AL;;;;7000;N;;;;;
+1ED23;OTTOMAN SIYAQ NUMBER EIGHT THOUSAND;No;0;AL;;;;8000;N;;;;;
+1ED24;OTTOMAN SIYAQ NUMBER NINE THOUSAND;No;0;AL;;;;9000;N;;;;;
+1ED25;OTTOMAN SIYAQ NUMBER TEN THOUSAND;No;0;AL;;;;10000;N;;;;;
+1ED26;OTTOMAN SIYAQ NUMBER TWENTY THOUSAND;No;0;AL;;;;20000;N;;;;;
+1ED27;OTTOMAN SIYAQ NUMBER THIRTY THOUSAND;No;0;AL;;;;30000;N;;;;;
+1ED28;OTTOMAN SIYAQ NUMBER FORTY THOUSAND;No;0;AL;;;;40000;N;;;;;
+1ED29;OTTOMAN SIYAQ NUMBER FIFTY THOUSAND;No;0;AL;;;;50000;N;;;;;
+1ED2A;OTTOMAN SIYAQ NUMBER SIXTY THOUSAND;No;0;AL;;;;60000;N;;;;;
+1ED2B;OTTOMAN SIYAQ NUMBER SEVENTY THOUSAND;No;0;AL;;;;70000;N;;;;;
+1ED2C;OTTOMAN SIYAQ NUMBER EIGHTY THOUSAND;No;0;AL;;;;80000;N;;;;;
+1ED2D;OTTOMAN SIYAQ NUMBER NINETY THOUSAND;No;0;AL;;;;90000;N;;;;;
+1ED2E;OTTOMAN SIYAQ MARRATAN;So;0;AL;;;;;N;;;;;
+1ED2F;OTTOMAN SIYAQ ALTERNATE NUMBER TWO;No;0;AL;;;;2;N;;;;;
+1ED30;OTTOMAN SIYAQ ALTERNATE NUMBER THREE;No;0;AL;;;;3;N;;;;;
+1ED31;OTTOMAN SIYAQ ALTERNATE NUMBER FOUR;No;0;AL;;;;4;N;;;;;
+1ED32;OTTOMAN SIYAQ ALTERNATE NUMBER FIVE;No;0;AL;;;;5;N;;;;;
+1ED33;OTTOMAN SIYAQ ALTERNATE NUMBER SIX;No;0;AL;;;;6;N;;;;;
+1ED34;OTTOMAN SIYAQ ALTERNATE NUMBER SEVEN;No;0;AL;;;;7;N;;;;;
+1ED35;OTTOMAN SIYAQ ALTERNATE NUMBER EIGHT;No;0;AL;;;;8;N;;;;;
+1ED36;OTTOMAN SIYAQ ALTERNATE NUMBER NINE;No;0;AL;;;;9;N;;;;;
+1ED37;OTTOMAN SIYAQ ALTERNATE NUMBER TEN;No;0;AL;;;;10;N;;;;;
+1ED38;OTTOMAN SIYAQ ALTERNATE NUMBER FOUR HUNDRED;No;0;AL;;;;400;N;;;;;
+1ED39;OTTOMAN SIYAQ ALTERNATE NUMBER SIX HUNDRED;No;0;AL;;;;600;N;;;;;
+1ED3A;OTTOMAN SIYAQ ALTERNATE NUMBER TWO THOUSAND;No;0;AL;;;;2000;N;;;;;
+1ED3B;OTTOMAN SIYAQ ALTERNATE NUMBER TEN THOUSAND;No;0;AL;;;;10000;N;;;;;
+1ED3C;OTTOMAN SIYAQ FRACTION ONE HALF;No;0;AL;;;;1/2;N;;;;;
+1ED3D;OTTOMAN SIYAQ FRACTION ONE SIXTH;No;0;AL;;;;1/6;N;;;;;
 1EE00;ARABIC MATHEMATICAL ALEF;Lo;0;AL;<font> 0627;;;;N;;;;;
 1EE01;ARABIC MATHEMATICAL BEH;Lo;0;AL;<font> 0628;;;;N;;;;;
 1EE02;ARABIC MATHEMATICAL JEEM;Lo;0;AL;<font> 062C;;;;N;;;;;
@@ -29662,6 +30064,7 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 1F169;NEGATIVE CIRCLED LATIN CAPITAL LETTER Z;So;0;L;;;;;N;;;;;
 1F16A;RAISED MC SIGN;So;0;ON;<super> 004D 0043;;;;N;;;;;
 1F16B;RAISED MD SIGN;So;0;ON;<super> 004D 0044;;;;N;;;;;
+1F16C;RAISED MR SIGN;So;0;ON;<super> 004D 0052;;;;N;;;;;
 1F170;NEGATIVE SQUARED LATIN CAPITAL LETTER A;So;0;L;;;;;N;;;;;
 1F171;NEGATIVE SQUARED LATIN CAPITAL LETTER B;So;0;L;;;;;N;;;;;
 1F172;NEGATIVE SQUARED LATIN CAPITAL LETTER C;So;0;L;;;;;N;;;;;
@@ -30794,6 +31197,7 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 1F6D2;SHOPPING TROLLEY;So;0;ON;;;;;N;;;;;
 1F6D3;STUPA;So;0;ON;;;;;N;;;;;
 1F6D4;PAGODA;So;0;ON;;;;;N;;;;;
+1F6D5;HINDU TEMPLE;So;0;ON;;;;;N;;;;;
 1F6E0;HAMMER AND WRENCH;So;0;ON;;;;;N;;;;;
 1F6E1;SHIELD;So;0;ON;;;;;N;;;;;
 1F6E2;OIL DRUM;So;0;ON;;;;;N;;;;;
@@ -30817,6 +31221,7 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 1F6F7;SLED;So;0;ON;;;;;N;;;;;
 1F6F8;FLYING SAUCER;So;0;ON;;;;;N;;;;;
 1F6F9;SKATEBOARD;So;0;ON;;;;;N;;;;;
+1F6FA;AUTO RICKSHAW;So;0;ON;;;;;N;;;;;
 1F700;ALCHEMICAL SYMBOL FOR QUINTESSENCE;So;0;ON;;;;;N;;;;;
 1F701;ALCHEMICAL SYMBOL FOR AIR;So;0;ON;;;;;N;;;;;
 1F702;ALCHEMICAL SYMBOL FOR FIRE;So;0;ON;;;;;N;;;;;
@@ -31022,6 +31427,18 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 1F7D6;NEGATIVE CIRCLED TRIANGLE;So;0;ON;;;;;N;;;;;
 1F7D7;CIRCLED SQUARE;So;0;ON;;;;;N;;;;;
 1F7D8;NEGATIVE CIRCLED SQUARE;So;0;ON;;;;;N;;;;;
+1F7E0;LARGE ORANGE CIRCLE;So;0;ON;;;;;N;;;;;
+1F7E1;LARGE YELLOW CIRCLE;So;0;ON;;;;;N;;;;;
+1F7E2;LARGE GREEN CIRCLE;So;0;ON;;;;;N;;;;;
+1F7E3;LARGE PURPLE CIRCLE;So;0;ON;;;;;N;;;;;
+1F7E4;LARGE BROWN CIRCLE;So;0;ON;;;;;N;;;;;
+1F7E5;LARGE RED SQUARE;So;0;ON;;;;;N;;;;;
+1F7E6;LARGE BLUE SQUARE;So;0;ON;;;;;N;;;;;
+1F7E7;LARGE ORANGE SQUARE;So;0;ON;;;;;N;;;;;
+1F7E8;LARGE YELLOW SQUARE;So;0;ON;;;;;N;;;;;
+1F7E9;LARGE GREEN SQUARE;So;0;ON;;;;;N;;;;;
+1F7EA;LARGE PURPLE SQUARE;So;0;ON;;;;;N;;;;;
+1F7EB;LARGE BROWN SQUARE;So;0;ON;;;;;N;;;;;
 1F800;LEFTWARDS ARROW WITH SMALL TRIANGLE ARROWHEAD;So;0;ON;;;;;N;;;;;
 1F801;UPWARDS ARROW WITH SMALL TRIANGLE ARROWHEAD;So;0;ON;;;;;N;;;;;
 1F802;RIGHTWARDS ARROW WITH SMALL TRIANGLE ARROWHEAD;So;0;ON;;;;;N;;;;;
@@ -31182,6 +31599,9 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 1F909;DOWNWARD FACING NOTCHED HOOK;So;0;ON;;;;;N;;;;;
 1F90A;DOWNWARD FACING HOOK WITH DOT;So;0;ON;;;;;N;;;;;
 1F90B;DOWNWARD FACING NOTCHED HOOK WITH DOT;So;0;ON;;;;;N;;;;;
+1F90D;WHITE HEART;So;0;ON;;;;;N;;;;;
+1F90E;BROWN HEART;So;0;ON;;;;;N;;;;;
+1F90F;PINCHING HAND;So;0;ON;;;;;N;;;;;
 1F910;ZIPPER-MOUTH FACE;So;0;ON;;;;;N;;;;;
 1F911;MONEY-MOUTH FACE;So;0;ON;;;;;N;;;;;
 1F912;FACE WITH THERMOMETER;So;0;ON;;;;;N;;;;;
@@ -31229,6 +31649,7 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 1F93C;WRESTLERS;So;0;ON;;;;;N;;;;;
 1F93D;WATER POLO;So;0;ON;;;;;N;;;;;
 1F93E;HANDBALL;So;0;ON;;;;;N;;;;;
+1F93F;DIVING MASK;So;0;ON;;;;;N;;;;;
 1F940;WILTED FLOWER;So;0;ON;;;;;N;;;;;
 1F941;DRUM WITH DRUMSTICKS;So;0;ON;;;;;N;;;;;
 1F942;CLINKING GLASSES;So;0;ON;;;;;N;;;;;
@@ -31278,11 +31699,13 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 1F96E;MOON CAKE;So;0;ON;;;;;N;;;;;
 1F96F;BAGEL;So;0;ON;;;;;N;;;;;
 1F970;SMILING FACE WITH SMILING EYES AND THREE HEARTS;So;0;ON;;;;;N;;;;;
+1F971;YAWNING FACE;So;0;ON;;;;;N;;;;;
 1F973;FACE WITH PARTY HORN AND PARTY HAT;So;0;ON;;;;;N;;;;;
 1F974;FACE WITH UNEVEN EYES AND WAVY MOUTH;So;0;ON;;;;;N;;;;;
 1F975;OVERHEATED FACE;So;0;ON;;;;;N;;;;;
 1F976;FREEZING FACE;So;0;ON;;;;;N;;;;;
 1F97A;FACE WITH PLEADING EYES;So;0;ON;;;;;N;;;;;
+1F97B;SARI;So;0;ON;;;;;N;;;;;
 1F97C;LAB COAT;So;0;ON;;;;;N;;;;;
 1F97D;GOGGLES;So;0;ON;;;;;N;;;;;
 1F97E;HIKING BOOT;So;0;ON;;;;;N;;;;;
@@ -31322,6 +31745,14 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 1F9A0;MICROBE;So;0;ON;;;;;N;;;;;
 1F9A1;BADGER;So;0;ON;;;;;N;;;;;
 1F9A2;SWAN;So;0;ON;;;;;N;;;;;
+1F9A5;SLOTH;So;0;ON;;;;;N;;;;;
+1F9A6;OTTER;So;0;ON;;;;;N;;;;;
+1F9A7;ORANGUTAN;So;0;ON;;;;;N;;;;;
+1F9A8;SKUNK;So;0;ON;;;;;N;;;;;
+1F9A9;FLAMINGO;So;0;ON;;;;;N;;;;;
+1F9AA;OYSTER;So;0;ON;;;;;N;;;;;
+1F9AE;GUIDE DOG;So;0;ON;;;;;N;;;;;
+1F9AF;PROBING CANE;So;0;ON;;;;;N;;;;;
 1F9B0;EMOJI COMPONENT RED HAIR;So;0;ON;;;;;N;;;;;
 1F9B1;EMOJI COMPONENT CURLY HAIR;So;0;ON;;;;;N;;;;;
 1F9B2;EMOJI COMPONENT BALD;So;0;ON;;;;;N;;;;;
@@ -31332,9 +31763,26 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 1F9B7;TOOTH;So;0;ON;;;;;N;;;;;
 1F9B8;SUPERHERO;So;0;ON;;;;;N;;;;;
 1F9B9;SUPERVILLAIN;So;0;ON;;;;;N;;;;;
+1F9BA;SAFETY VEST;So;0;ON;;;;;N;;;;;
+1F9BB;EAR WITH HEARING AID;So;0;ON;;;;;N;;;;;
+1F9BC;MOTORIZED WHEELCHAIR;So;0;ON;;;;;N;;;;;
+1F9BD;MANUAL WHEELCHAIR;So;0;ON;;;;;N;;;;;
+1F9BE;MECHANICAL ARM;So;0;ON;;;;;N;;;;;
+1F9BF;MECHANICAL LEG;So;0;ON;;;;;N;;;;;
 1F9C0;CHEESE WEDGE;So;0;ON;;;;;N;;;;;
 1F9C1;CUPCAKE;So;0;ON;;;;;N;;;;;
 1F9C2;SALT SHAKER;So;0;ON;;;;;N;;;;;
+1F9C3;BEVERAGE BOX;So;0;ON;;;;;N;;;;;
+1F9C4;GARLIC;So;0;ON;;;;;N;;;;;
+1F9C5;ONION;So;0;ON;;;;;N;;;;;
+1F9C6;FALAFEL;So;0;ON;;;;;N;;;;;
+1F9C7;WAFFLE;So;0;ON;;;;;N;;;;;
+1F9C8;BUTTER;So;0;ON;;;;;N;;;;;
+1F9C9;MATE DRINK;So;0;ON;;;;;N;;;;;
+1F9CA;ICE CUBE;So;0;ON;;;;;N;;;;;
+1F9CD;STANDING PERSON;So;0;ON;;;;;N;;;;;
+1F9CE;KNEELING PERSON;So;0;ON;;;;;N;;;;;
+1F9CF;DEAF PERSON;So;0;ON;;;;;N;;;;;
 1F9D0;FACE WITH MONOCLE;So;0;ON;;;;;N;;;;;
 1F9D1;ADULT;So;0;ON;;;;;N;;;;;
 1F9D2;CHILD;So;0;ON;;;;;N;;;;;
@@ -31383,6 +31831,90 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 1F9FD;SPONGE;So;0;ON;;;;;N;;;;;
 1F9FE;RECEIPT;So;0;ON;;;;;N;;;;;
 1F9FF;NAZAR AMULET;So;0;ON;;;;;N;;;;;
+1FA00;NEUTRAL CHESS KING;So;0;ON;;;;;N;;;;;
+1FA01;NEUTRAL CHESS QUEEN;So;0;ON;;;;;N;;;;;
+1FA02;NEUTRAL CHESS ROOK;So;0;ON;;;;;N;;;;;
+1FA03;NEUTRAL CHESS BISHOP;So;0;ON;;;;;N;;;;;
+1FA04;NEUTRAL CHESS KNIGHT;So;0;ON;;;;;N;;;;;
+1FA05;NEUTRAL CHESS PAWN;So;0;ON;;;;;N;;;;;
+1FA06;WHITE CHESS KNIGHT ROTATED FORTY-FIVE DEGREES;So;0;ON;;;;;N;;;;;
+1FA07;BLACK CHESS KNIGHT ROTATED FORTY-FIVE DEGREES;So;0;ON;;;;;N;;;;;
+1FA08;NEUTRAL CHESS KNIGHT ROTATED FORTY-FIVE DEGREES;So;0;ON;;;;;N;;;;;
+1FA09;WHITE CHESS KING ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA0A;WHITE CHESS QUEEN ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA0B;WHITE CHESS ROOK ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA0C;WHITE CHESS BISHOP ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA0D;WHITE CHESS KNIGHT ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA0E;WHITE CHESS PAWN ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA0F;BLACK CHESS KING ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA10;BLACK CHESS QUEEN ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA11;BLACK CHESS ROOK ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA12;BLACK CHESS BISHOP ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA13;BLACK CHESS KNIGHT ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA14;BLACK CHESS PAWN ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA15;NEUTRAL CHESS KING ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA16;NEUTRAL CHESS QUEEN ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA17;NEUTRAL CHESS ROOK ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA18;NEUTRAL CHESS BISHOP ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA19;NEUTRAL CHESS KNIGHT ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA1A;NEUTRAL CHESS PAWN ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA1B;WHITE CHESS KNIGHT ROTATED ONE HUNDRED THIRTY-FIVE 
DEGREES;So;0;ON;;;;;N;;;;;
+1FA1C;BLACK CHESS KNIGHT ROTATED ONE HUNDRED THIRTY-FIVE 
DEGREES;So;0;ON;;;;;N;;;;;
+1FA1D;NEUTRAL CHESS KNIGHT ROTATED ONE HUNDRED THIRTY-FIVE 
DEGREES;So;0;ON;;;;;N;;;;;
+1FA1E;WHITE CHESS TURNED KING;So;0;ON;;;;;N;;;;;
+1FA1F;WHITE CHESS TURNED QUEEN;So;0;ON;;;;;N;;;;;
+1FA20;WHITE CHESS TURNED ROOK;So;0;ON;;;;;N;;;;;
+1FA21;WHITE CHESS TURNED BISHOP;So;0;ON;;;;;N;;;;;
+1FA22;WHITE CHESS TURNED KNIGHT;So;0;ON;;;;;N;;;;;
+1FA23;WHITE CHESS TURNED PAWN;So;0;ON;;;;;N;;;;;
+1FA24;BLACK CHESS TURNED KING;So;0;ON;;;;;N;;;;;
+1FA25;BLACK CHESS TURNED QUEEN;So;0;ON;;;;;N;;;;;
+1FA26;BLACK CHESS TURNED ROOK;So;0;ON;;;;;N;;;;;
+1FA27;BLACK CHESS TURNED BISHOP;So;0;ON;;;;;N;;;;;
+1FA28;BLACK CHESS TURNED KNIGHT;So;0;ON;;;;;N;;;;;
+1FA29;BLACK CHESS TURNED PAWN;So;0;ON;;;;;N;;;;;
+1FA2A;NEUTRAL CHESS TURNED KING;So;0;ON;;;;;N;;;;;
+1FA2B;NEUTRAL CHESS TURNED QUEEN;So;0;ON;;;;;N;;;;;
+1FA2C;NEUTRAL CHESS TURNED ROOK;So;0;ON;;;;;N;;;;;
+1FA2D;NEUTRAL CHESS TURNED BISHOP;So;0;ON;;;;;N;;;;;
+1FA2E;NEUTRAL CHESS TURNED KNIGHT;So;0;ON;;;;;N;;;;;
+1FA2F;NEUTRAL CHESS TURNED PAWN;So;0;ON;;;;;N;;;;;
+1FA30;WHITE CHESS KNIGHT ROTATED TWO HUNDRED TWENTY-FIVE 
DEGREES;So;0;ON;;;;;N;;;;;
+1FA31;BLACK CHESS KNIGHT ROTATED TWO HUNDRED TWENTY-FIVE 
DEGREES;So;0;ON;;;;;N;;;;;
+1FA32;NEUTRAL CHESS KNIGHT ROTATED TWO HUNDRED TWENTY-FIVE 
DEGREES;So;0;ON;;;;;N;;;;;
+1FA33;WHITE CHESS KING ROTATED TWO HUNDRED SEVENTY DEGREES;So;0;ON;;;;;N;;;;;
+1FA34;WHITE CHESS QUEEN ROTATED TWO HUNDRED SEVENTY DEGREES;So;0;ON;;;;;N;;;;;
+1FA35;WHITE CHESS ROOK ROTATED TWO HUNDRED SEVENTY DEGREES;So;0;ON;;;;;N;;;;;
+1FA36;WHITE CHESS BISHOP ROTATED TWO HUNDRED SEVENTY DEGREES;So;0;ON;;;;;N;;;;;
+1FA37;WHITE CHESS KNIGHT ROTATED TWO HUNDRED SEVENTY DEGREES;So;0;ON;;;;;N;;;;;
+1FA38;WHITE CHESS PAWN ROTATED TWO HUNDRED SEVENTY DEGREES;So;0;ON;;;;;N;;;;;
+1FA39;BLACK CHESS KING ROTATED TWO HUNDRED SEVENTY DEGREES;So;0;ON;;;;;N;;;;;
+1FA3A;BLACK CHESS QUEEN ROTATED TWO HUNDRED SEVENTY DEGREES;So;0;ON;;;;;N;;;;;
+1FA3B;BLACK CHESS ROOK ROTATED TWO HUNDRED SEVENTY DEGREES;So;0;ON;;;;;N;;;;;
+1FA3C;BLACK CHESS BISHOP ROTATED TWO HUNDRED SEVENTY DEGREES;So;0;ON;;;;;N;;;;;
+1FA3D;BLACK CHESS KNIGHT ROTATED TWO HUNDRED SEVENTY DEGREES;So;0;ON;;;;;N;;;;;
+1FA3E;BLACK CHESS PAWN ROTATED TWO HUNDRED SEVENTY DEGREES;So;0;ON;;;;;N;;;;;
+1FA3F;NEUTRAL CHESS KING ROTATED TWO HUNDRED SEVENTY DEGREES;So;0;ON;;;;;N;;;;;
+1FA40;NEUTRAL CHESS QUEEN ROTATED TWO HUNDRED SEVENTY 
DEGREES;So;0;ON;;;;;N;;;;;
+1FA41;NEUTRAL CHESS ROOK ROTATED TWO HUNDRED SEVENTY DEGREES;So;0;ON;;;;;N;;;;;
+1FA42;NEUTRAL CHESS BISHOP ROTATED TWO HUNDRED SEVENTY 
DEGREES;So;0;ON;;;;;N;;;;;
+1FA43;NEUTRAL CHESS KNIGHT ROTATED TWO HUNDRED SEVENTY 
DEGREES;So;0;ON;;;;;N;;;;;
+1FA44;NEUTRAL CHESS PAWN ROTATED TWO HUNDRED SEVENTY DEGREES;So;0;ON;;;;;N;;;;;
+1FA45;WHITE CHESS KNIGHT ROTATED THREE HUNDRED FIFTEEN 
DEGREES;So;0;ON;;;;;N;;;;;
+1FA46;BLACK CHESS KNIGHT ROTATED THREE HUNDRED FIFTEEN 
DEGREES;So;0;ON;;;;;N;;;;;
+1FA47;NEUTRAL CHESS KNIGHT ROTATED THREE HUNDRED FIFTEEN 
DEGREES;So;0;ON;;;;;N;;;;;
+1FA48;WHITE CHESS EQUIHOPPER;So;0;ON;;;;;N;;;;;
+1FA49;BLACK CHESS EQUIHOPPER;So;0;ON;;;;;N;;;;;
+1FA4A;NEUTRAL CHESS EQUIHOPPER;So;0;ON;;;;;N;;;;;
+1FA4B;WHITE CHESS EQUIHOPPER ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA4C;BLACK CHESS EQUIHOPPER ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA4D;NEUTRAL CHESS EQUIHOPPER ROTATED NINETY DEGREES;So;0;ON;;;;;N;;;;;
+1FA4E;WHITE CHESS KNIGHT-QUEEN;So;0;ON;;;;;N;;;;;
+1FA4F;WHITE CHESS KNIGHT-ROOK;So;0;ON;;;;;N;;;;;
+1FA50;WHITE CHESS KNIGHT-BISHOP;So;0;ON;;;;;N;;;;;
+1FA51;BLACK CHESS KNIGHT-QUEEN;So;0;ON;;;;;N;;;;;
+1FA52;BLACK CHESS KNIGHT-ROOK;So;0;ON;;;;;N;;;;;
+1FA53;BLACK CHESS KNIGHT-BISHOP;So;0;ON;;;;;N;;;;;
 1FA60;XIANGQI RED GENERAL;So;0;ON;;;;;N;;;;;
 1FA61;XIANGQI RED MANDARIN;So;0;ON;;;;;N;;;;;
 1FA62;XIANGQI RED ELEPHANT;So;0;ON;;;;;N;;;;;
@@ -31397,6 +31929,22 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
 1FA6B;XIANGQI BLACK CHARIOT;So;0;ON;;;;;N;;;;;
 1FA6C;XIANGQI BLACK CANNON;So;0;ON;;;;;N;;;;;
 1FA6D;XIANGQI BLACK SOLDIER;So;0;ON;;;;;N;;;;;
+1FA70;BALLET SHOES;So;0;ON;;;;;N;;;;;
+1FA71;ONE-PIECE SWIMSUIT;So;0;ON;;;;;N;;;;;
+1FA72;BRIEFS;So;0;ON;;;;;N;;;;;
+1FA73;SHORTS;So;0;ON;;;;;N;;;;;
+1FA78;DROP OF BLOOD;So;0;ON;;;;;N;;;;;
+1FA79;ADHESIVE BANDAGE;So;0;ON;;;;;N;;;;;
+1FA7A;STETHOSCOPE;So;0;ON;;;;;N;;;;;
+1FA80;YO-YO;So;0;ON;;;;;N;;;;;
+1FA81;KITE;So;0;ON;;;;;N;;;;;
+1FA82;PARACHUTE;So;0;ON;;;;;N;;;;;
+1FA90;RINGED PLANET;So;0;ON;;;;;N;;;;;
+1FA91;CHAIR;So;0;ON;;;;;N;;;;;
+1FA92;RAZOR;So;0;ON;;;;;N;;;;;
+1FA93;AXE;So;0;ON;;;;;N;;;;;
+1FA94;DIYA LAMP;So;0;ON;;;;;N;;;;;
+1FA95;BANJO;So;0;ON;;;;;N;;;;;
 20000;<CJK Ideograph Extension B, First>;Lo;0;L;;;;;N;;;;;
 2A6D6;<CJK Ideograph Extension B, Last>;Lo;0;L;;;;;N;;;;;
 2A700;<CJK Ideograph Extension C, First>;Lo;0;L;;;;;N;;;;;
diff --git a/admin/unidata/blocks.awk b/admin/unidata/blocks.awk
index ea62d87..a7ee134 100755
--- a/admin/unidata/blocks.awk
+++ b/admin/unidata/blocks.awk
@@ -1,6 +1,6 @@
 #!/usr/bin/awk -f
 
-## Copyright (C) 2015-2018 Free Software Foundation, Inc.
+## Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ## Author: Glenn Morris <address@hidden>
 
@@ -115,14 +115,15 @@ function name2alias(name   , w, w2) {
     else if (name ~ /duployan|shorthand/) return "duployan-shorthand"
     else if (name ~ /sutton signwriting/) return "sutton-sign-writing"
 
-    sub(/ (extended|extensions|supplement).*/, "", name)
+    sub(/^small /, "", name)
+    sub(/ (extended|extensions*|supplement).*/, "", name)
     sub(/numbers/, "number", name)
     sub(/numerals/, "numeral", name)
     sub(/symbols/, "symbol", name)
     sub(/forms$/, "form", name)
     sub(/tiles$/, "tile", name)
     sub(/^new /, "", name)
-    sub(/ (characters|hieroglyphs|cursive)$/, "", name)
+    sub(/ (characters|hieroglyphs|cursive|hieroglyph format controls)$/, "", 
name)
     gsub(/ /, "-", name)
 
     return name
diff --git a/admin/unidata/copyright.html b/admin/unidata/copyright.html
index 0df59c1..2f5c88d 100644
--- a/admin/unidata/copyright.html
+++ b/admin/unidata/copyright.html
@@ -36,7 +36,7 @@ pre {
  <td class="icon"><a href="http://www.unicode.org/";><img border="0"
           src="http://www.unicode.org/webscripts/logo60s2.gif"; align="middle"
           alt="[Unicode]" width="34" height="33"></a>&nbsp;&nbsp;<a class="bar"
-          href="http://www.unicode.org/copyright.html";><font size="3">Terms of
+          href="https://www.unicode.org/copyright.html";><font size="3">Terms of
           Use</font></a></td>
           <td class="bar"><a href="http://www.unicode.org"; class="bar">Home</a>
           | <a href="http://www.unicode.org/sitemap/"; class="bar">Site Map</a> 
|
@@ -59,46 +59,48 @@ pre {
           <td valign="top" class="navColCell"><a href="#1">Unicode 
Copyright</a></td>
         </tr>
         <tr>
-          <td valign="top" class="navColCell"><a href="#2">Restricted Rights
-          Legend</a></td>
+          <td valign="top" class="navColCell"><a href="#6">Definitions</a></td>
         </tr>
         <tr>
-          <td valign="top" class="navColCell"><a href="#3">Warranties &amp;
-          Disclaimers</a></td>
+          <td valign="top" class="navColCell"><a href="#8">Terms of 
Use</a></td>
+        </tr>
+        <tr>
+          <td valign="top" class="navColCell"><a href="#2">Restricted Rights 
Legend</a></td>
+        </tr>
+        <tr>
+          <td valign="top" class="navColCell"><a href="#3">Warranties &amp; 
Disclaimers</a></td>
         </tr>
         <tr>
           <td valign="top" class="navColCell"><a href="#4">Waiver of 
Damages</a></td>
         </tr>
         <tr>
-          <td valign="top" class="navColCell"><a href="#5">Trademarks & 
Logos</a></td>
+          <td valign="top" class="navColCell"><a href="#5">Trademarks &amp; 
Logos</a></td>
         </tr>
         <tr>
           <td valign="top" class="navColCell"><a 
href="#7">Miscellaneous</a></td>
         </tr>
         <tr>
-          <td valign="top" class="navColCell"><a href="#License">Data Files and
-          Software License Agreement (Exhibit 1)</a></td>
+          <td class="navColTitle">Unicode License</td>
         </tr>
         <tr>
-          <td valign="top" class="navColCell">&nbsp;</td>
+          <td valign="top" class="navColCell">
+        <a href="https://www.unicode.org/license.html";>Unicode Data Files and 
Software License</a></td>
         </tr>
-      </table>
-      <table class="navColTable" border="0" width="100%" cellspacing="4"
-      cellpadding="0">
         <tr>
           <td class="navColTitle">Related Links</td>
         </tr>
         <tr>
           <td valign="top" class="navColCell">
-        <a href="http://www.unicode.org/policies/logo_policy.html";>Trademark 
Policy</a></td>
+        <a href="https://www.unicode.org/policies/privacy_policy.html";>Privacy 
Policy</a></td>
         </tr>
         <tr>
           <td valign="top" class="navColCell">
-          <a href="http://www.unicode.org/policies/policies.html";>Unicode
-          Policies</a></td>
+        <a href="https://www.unicode.org/policies/logo_policy.html";>Trademark 
Policy</a></td>
         </tr>
         <tr>
-          <td valign="top" class="navColCell"></td>
+          <td valign="top" class="navColCell">
+          <a href="https://www.unicode.org/policies/policies.html";>Unicode
+          Policies</a></td>
         </tr>
       </table>
 
@@ -108,30 +110,41 @@ pre {
       <td>
 
 <blockquote>
-            <h1>Unicode® Terms of Use</h1>
+            <h1>Unicode® Copyright and Terms of Use</h1>
 
             <p>For the general privacy policy governing access to this site, 
see
             the&nbsp;
             <a href="http://www.unicode.org/policies/privacy_policy.html";>
-            Unicode Privacy Policy</a>. For trademark usage, see
-            <a href="http://www.unicode.org/policies/logo_policy.html";>the
-        Unicode® Consortium Name and Trademark Usage Policy</a>.</p>
-
-            <table class="sidebar" align="right" width="50%" id="table1">
-              <tr>
-                <td class="sidebarTitle">Notice to End User: Terms of Use</td>
-              </tr>
-              <tr>
-                <td class="sidebar">Carefully read the following legal 
agreement
-                (&quot;Agreement&quot;). Use or copying of the software and/or 
codes
-                provided with this agreement (The &quot;Software&quot;) 
constitutes your
-                acceptance of these terms. If you have any questions about 
these terms of use, please <a 
href="http://www.unicode.org/contacts.html";>contact the Unicode 
Consortium</a>.</td>
-              </tr>
-            </table>
+            Unicode Privacy Policy</a>.</p>
+
             <ol type="A">
-              <li><u><a name="1"></a>Unicode Copyright.</u>
+              <li><u><a name="1"></a>Unicode Copyright</u>
+              <ol>
+                <li>Copyright © 1991-2019 Unicode, Inc. All rights 
reserved.</li>
+              </ol>
+              </li>
+
+              <li><u><a name="6"></a>Definitions</u>
+<pre>
+Unicode Data Files ("DATA FILES") include all data files under the directories:
+https://www.unicode.org/Public/
+https://www.unicode.org/reports/
+https://www.unicode.org/ivd/data/
+
+Unicode Data Files do not include PDF online code charts under the directory:
+https://www.unicode.org/Public/
+
+Unicode Software ("SOFTWARE") includes any source code published in the 
Unicode Standard
+or any source code or compiled code under the directories:
+https://www.unicode.org/Public/PROGRAMS/
+https://www.unicode.org/Public/cldr/
+https://site.icu-project.org/download/
+</pre>
+              </li>
+
+              <li><u><a name="8"></a>Terms of Use</u>
               <ol>
-                <li>Copyright © 1991-2018 Unicode, Inc. All rights 
reserved.</li>
+
                 <li>Certain documents and files on this website contain a 
legend
                 indicating that &quot;Modification is permitted.&quot; Any 
person is
                 hereby authorized, without fee, to modify such documents and
@@ -141,22 +154,26 @@ pre {
                 reproduce, and distribute all documents and files, subject to 
the Terms and Conditions
                 herein.</li>
                 <li>Further specifications of rights and restrictions 
pertaining
-                to the use of the particular set of data files known as the
-                &quot;Unicode Character Database&quot; can be found in the
-                <a href="#License">License</a>.</li>
+                to the use of the Unicode DATA FILES and SOFTWARE can be found 
in the
+                <a href="https://www.unicode.org/license.html";>Unicode Data 
Files and Software License</a>.</li>
                 <li>Each version of the Unicode Standard has further
                 specifications of rights and restrictions of use. For the book
                 editions (Unicode 5.0 and earlier), these are found on the back
                 of the
-                               <a 
href="http://www.unicode.org/versions/Unicode5.0.0/Title.pdf";>title page</a>.
-                The online code charts carry specific restrictions. All other 
files, including online documentation  of the core specification for Unicode 
6.0 and later, are covered under these  general Terms of Use.</li>
+                               <a 
href="http://www.unicode.org/versions/Unicode5.0.0/Title.pdf";>title 
page</a>.</li>
+                <li>
+                The Unicode PDF <a 
href="https://www.unicode.org/charts/";>online code charts</a> carry specific 
restrictions. Those restrictions are incorporated as the
+                first page of each PDF code chart.</li>
+                <li>All other files, including online documentation of the 
core specification for Unicode 6.0 and later, are covered under these general 
Terms of Use.</li>
                 <li>No license is granted to &quot;mirror&quot; the Unicode 
website where
                 a fee is charged for access to the &quot;mirror&quot; 
site.</li>
                 <li>Modification is not permitted with respect to this 
document.
                 All copies of this document must be verbatim.</li>
               </ol>
               </li>
-              <li><u><a name="2"></a>Restricted Rights Legend</u>. Any 
technical
+              <li><u><a name="2"></a>Restricted Rights Legend</u>
+              <ol>
+                <li>Any technical
               data or software which is licensed to the United States of
               America, its agencies and/or instrumentalities under this
               Agreement is commercial technical data or commercial computer
@@ -169,66 +186,71 @@ pre {
               227-7202, as applicable, use, duplication or disclosure by the
               Government is subject to the restrictions set forth in this
               Agreement.</li>
-              <li><u><a name="3"></a>Warranties and Disclaimers</u>.
+              </ol>
+              </li>
+              <li><u><a name="3"></a>Warranties and Disclaimers</u>
               <ol>
                 <li>This publication and/or website may include technical or
-                typographical errors or other inaccuracies . Changes are
+                typographical errors or other inaccuracies. Changes are
                 periodically added to the information herein; these changes 
will
                 be incorporated in new editions of the publication and/or
-                website. Unicode may make improvements and/or changes in the
+                website. Unicode, Inc. may make improvements and/or changes in 
the
                 product(s) and/or program(s) described in this publication
                 and/or website at any time.</li>
                 <li>If this file has been purchased on magnetic or optical 
media
                 from Unicode, Inc. the sole and exclusive remedy for any claim
                 will be exchange of the defective media within ninety (90) days
                 of original purchase.</li>
-                <li>EXCEPT AS PROVIDED IN SECTION&nbsp;C.2, THIS PUBLICATION 
AND/OR
+                <li>EXCEPT AS PROVIDED IN SECTION&nbsp;E.2, THIS PUBLICATION 
AND/OR
                 SOFTWARE IS PROVIDED &quot;AS IS&quot; WITHOUT WARRANTY OF ANY 
KIND EITHER
                 EXPRESS, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO,
                 ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-                PURPOSE, OR NON-INFRINGEMENT. UNICODE AND ITS LICENSORS ASSUME
+                PURPOSE, OR NON-INFRINGEMENT. UNICODE, INC. AND ITS LICENSORS 
ASSUME
                 NO RESPONSIBILITY FOR ERRORS OR OMISSIONS IN THIS PUBLICATION
                 AND/OR SOFTWARE OR OTHER DOCUMENTS WHICH ARE REFERENCED BY OR
                 LINKED TO THIS PUBLICATION OR THE UNICODE WEBSITE.</li>
               </ol>
               </li>
-              <li><u><a name="4"></a>Waiver of Damages.</u> In no event shall
-              Unicode or its licensors be liable for any special, incidental,
+              <li><u><a name="4"></a>Waiver of Damages</u>
+              <ol>
+                <li>In no event shall
+              Unicode, Inc. or its licensors be liable for any special, 
incidental,
               indirect or consequential damages of any kind, or any damages
-              whatsoever, whether or not Unicode was advised of the possibility
+              whatsoever, whether or not Unicode, Inc. was advised of the 
possibility
               of the damage, including, without limitation, those resulting 
from
               the following: loss of use, data or profits, in connection with
               the use, modification or distribution of this information or its
               derivatives.</li>
-              <li><u><a name="5"></a>Trademarks &amp; Logos.</u>
+              </ol>
+              </li>
+              <li><u><a name="5"></a>Trademarks &amp; Logos</u>
                 <ol>
                 <li>The Unicode Word Mark and the Unicode Logo are trademarks 
of Unicode, Inc.  “The Unicode Consortium” and “Unicode, Inc.” are trade names 
of Unicode, Inc.  Use of the information and materials found on this website 
indicates your acknowledgement of Unicode, Inc.’s exclusive worldwide rights in 
the Unicode Word Mark, the Unicode Logo, and the Unicode trade names.</li>
 <li><a href="http://www.unicode.org/policies/logo_policy.html";>The Unicode 
Consortium Name and Trademark Usage Policy</a> (“Trademark Policy”) are 
incorporated herein by reference and you agree to abide by the provisions of 
the Trademark Policy, which may be changed from time to time in the sole 
discretion of Unicode, Inc.</li>
-<li>All third party trademarks referenced herein are the property of their 
respective owners.
-</li>
+<li>All third party trademarks referenced herein are the property of their 
respective owners.</li>
               </ol>
               </li>
 
-              <li><u><a name="7"></a>Miscellaneous</u>.
+              <li><u><a name="7"></a>Miscellaneous</u>
               <ol>
-                <li><u>Jurisdiction and Venue</u>. This server is operated from
+                <li><u>Jurisdiction and Venue</u>. This website is operated 
from
                                a location in the State of California, United 
States of America.
-                               Unicode makes no representation that the 
materials are
+                               Unicode, Inc. makes no representation that the 
materials are
                                appropriate for use in other locations. If you 
access this
-                               server from other locations, you are 
responsible for compliance
-                               with local laws. This Agreement, all use of 
this site and any
-                               claims and damages resulting from use of this 
site are governed
+                               website from other locations, you are 
responsible for compliance
+                               with local laws. This Agreement, all use of 
this website and any
+                               claims and damages resulting from use of this 
website are governed
                                solely by the laws of the State of California 
without regard to
                                any principles which would apply the laws of a 
different
                                jurisdiction. The user agrees that any disputes 
regarding this
-                               site shall be resolved solely in the courts 
located in Santa
+                               website shall be resolved solely in the courts 
located in Santa
                                Clara County, California. The user agrees said 
courts have
                                personal jurisdiction and agree to waive any 
right to transfer
-                               the dispute to any other forum. </li>
-                <li><u>Modification by Unicode </u>Unicode shall have the right
-                to modify this Agreement at any time by posting it to this 
site.
+                               the dispute to any other forum.</li>
+                <li><u>Modification by Unicode, Inc.</u> Unicode, Inc. shall 
have the right
+                to modify this Agreement at any time by posting it to this 
website.
                 The user may not assign any part of this Agreement without
-                Unicode’s prior written consent.</li>
+                Unicode, Inc.’s prior written consent.</li>
                 <li><u>Taxes.</u> The user agrees to pay any taxes arising from
                 access to this website or use of the information herein, except
                 for those based on Unicode’s net income.</li>
@@ -240,70 +262,7 @@ pre {
               </ol>
               </li>
             </ol>
-</blockquote>
-            <hr width="95%">
 
-<blockquote>
-<h3 align="center"><a name="Exhibit1">EXHIBIT 1</a><br>
-<a name="License">UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND 
SOFTWARE</a></h3>
-
-<pre>
-Unicode Data Files include all data files under the directories
-http://www.unicode.org/Public/, http://www.unicode.org/reports/,
-http://www.unicode.org/cldr/data/, http://source.icu-project.org/repos/icu/, 
and
-http://www.unicode.org/utility/trac/browser/.
-
-Unicode Data Files do not include PDF online code charts under the
-directory http://www.unicode.org/Public/.
-
-Software includes any source code published in the Unicode Standard
-or under the directories
-http://www.unicode.org/Public/, http://www.unicode.org/reports/,
-http://www.unicode.org/cldr/data/, http://source.icu-project.org/repos/icu/, 
and
-http://www.unicode.org/utility/trac/browser/.
-
-NOTICE TO USER: Carefully read the following legal agreement.
-BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S
-DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"),
-YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
-TERMS AND CONDITIONS OF THIS AGREEMENT.
-IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE
-THE DATA FILES OR SOFTWARE.
-
-COPYRIGHT AND PERMISSION NOTICE
-
-Copyright © 1991-2018 Unicode, Inc. All rights reserved.
-Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of the Unicode data files and any associated documentation
-(the "Data Files") or Unicode software and any associated documentation
-(the "Software") to deal in the Data Files or Software
-without restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, and/or sell copies of
-the Data Files or Software, and to permit persons to whom the Data Files
-or Software are furnished to do so, provided that either
-(a) this copyright and permission notice appear with all copies
-of the Data Files or Software, or
-(b) this copyright and permission notice appear in associated
-Documentation.
-
-THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
-ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT OF THIRD PARTY RIGHTS.
-IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS
-NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
-DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
-DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
-TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-PERFORMANCE OF THE DATA FILES OR SOFTWARE.
-
-Except as contained in this notice, the name of a copyright holder
-shall not be used in advertising or otherwise to promote the sale,
-use or other dealings in these Data Files or Software without prior
-written authorization of the copyright holder.
-</pre>
 
 </blockquote>
 
diff --git a/admin/unidata/unidata-gen.el b/admin/unidata/unidata-gen.el
index e520d18..1a3afd3 100644
--- a/admin/unidata/unidata-gen.el
+++ b/admin/unidata/unidata-gen.el
@@ -1,6 +1,6 @@
 ;; unidata-gen.el -- Create files containing character property data.
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -1413,7 +1413,7 @@ Property value is a symbol `o' (Open), `c' (Close), or 
`n' (None)."
         (copyright (with-temp-buffer
                      (insert-file-contents
                       (expand-file-name "copyright.html" unidata-dir))
-                     (re-search-forward "^Copyright .*Unicode, Inc.")
+                     (re-search-forward "Copyright .*Unicode, Inc.")
                      (match-string 0))))
     (or unidata-list (unidata-setup-list unidata-text-file))
     (let* ((basename (file-name-nondirectory file))
diff --git a/admin/unidata/uvs.el b/admin/unidata/uvs.el
index 4c14439..ad2b654 100644
--- a/admin/unidata/uvs.el
+++ b/admin/unidata/uvs.el
@@ -1,6 +1,6 @@
 ;;; uvs.el --- utility for UVS (format 14) cmap subtables in OpenType fonts.
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: YAMAMOTO Mitsuharu <address@hidden>
 
diff --git a/admin/update-copyright b/admin/update-copyright
index d3ffb47..44cb84d 100755
--- a/admin/update-copyright
+++ b/admin/update-copyright
@@ -7,7 +7,7 @@
 # By default, this script uses the local-time calendar year.
 # Set the UPDATE_COPYRIGHT_YEAR environment variable to override the default.
 
-# Copyright 2013-2018 Free Software Foundation, Inc.
+# Copyright 2013-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
diff --git a/admin/update_autogen b/admin/update_autogen
index f4c2c39..bb831a0 100755
--- a/admin/update_autogen
+++ b/admin/update_autogen
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 ### update_autogen - update some auto-generated files in the Emacs tree
 
-## Copyright (C) 2011-2018 Free Software Foundation, Inc.
+## Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ## Author: Glenn Morris <address@hidden>
 
diff --git a/admin/upload-manuals b/admin/upload-manuals
index 1aa7d8b..08b47d7 100755
--- a/admin/upload-manuals
+++ b/admin/upload-manuals
@@ -2,7 +2,7 @@
 
 ### upload-manuals - upload the Emacs manuals to the gnu.org website
 
-## Copyright 2018 Free Software Foundation, Inc.
+## Copyright 2018-2019 Free Software Foundation, Inc.
 
 ## Author: Glenn Morris <address@hidden>
 
diff --git a/autogen.sh b/autogen.sh
index 2d52f9e..40d0c37 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 ### autogen.sh - tool to help build Emacs from a repository checkout
 
-## Copyright (C) 2011-2018 Free Software Foundation, Inc.
+## Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ## Author: Glenn Morris <address@hidden>
 ## Maintainer: address@hidden
diff --git a/build-aux/config.guess b/build-aux/config.guess
index 47d7bed..79d1317 100755
--- a/build-aux/config.guess
+++ b/build-aux/config.guess
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright 1992-2018 Free Software Foundation, Inc.
+#   Copyright 1992-2019 Free Software Foundation, Inc.
 
-timestamp='2018-11-28'
+timestamp='2019-03-04'
 
 # 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
@@ -50,7 +50,7 @@ version="\
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright 1992-2018 Free Software Foundation, Inc.
+Copyright 1992-2019 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -96,8 +96,7 @@ fi
 
 tmp=
 # shellcheck disable=SC2172
-trap 'test -z "$tmp" || rm -fr "$tmp"' 1 2 13 15
-trap 'exitcode=$?; test -z "$tmp" || rm -fr "$tmp"; exit $exitcode' 0
+trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
 
 set_cc_for_build() {
     : "${TMPDIR=/tmp}"
@@ -392,15 +391,20 @@ case 
"$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
        echo i386-pc-auroraux"$UNAME_RELEASE"
        exit ;;
     i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
-       UNAME_REL="`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
-       case `isainfo -b` in
-           32)
-               echo i386-pc-solaris2"$UNAME_REL"
-               ;;
-           64)
-               echo x86_64-pc-solaris2"$UNAME_REL"
-               ;;
-       esac
+       set_cc_for_build
+       SUN_ARCH=i386
+       # If there is a compiler, see if it is configured for 64-bit objects.
+       # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+       # This test works for both compilers.
+       if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
+           if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+               (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+               grep IS_64BIT_ARCH >/dev/null
+           then
+               SUN_ARCH=x86_64
+           fi
+       fi
+       echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
        exit ;;
     sun4*:SunOS:6*:*)
        # According to config.sub, this is the proper way to canonicalize
@@ -981,22 +985,50 @@ EOF
        exit ;;
     mips:Linux:*:* | mips64:Linux:*:*)
        set_cc_for_build
+       IS_GLIBC=0
+       test x"${LIBC}" = xgnu && IS_GLIBC=1
        sed 's/^        //' << EOF > "$dummy.c"
        #undef CPU
-       #undef ${UNAME_MACHINE}
-       #undef ${UNAME_MACHINE}el
+       #undef mips
+       #undef mipsel
+       #undef mips64
+       #undef mips64el
+       #if ${IS_GLIBC} && defined(_ABI64)
+       LIBCABI=gnuabi64
+       #else
+       #if ${IS_GLIBC} && defined(_ABIN32)
+       LIBCABI=gnuabin32
+       #else
+       LIBCABI=${LIBC}
+       #endif
+       #endif
+
+       #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && 
__mips_isa_rev>=6
+       CPU=mipsisa64r6
+       #else
+       #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && 
__mips_isa_rev>=6
+       CPU=mipsisa32r6
+       #else
+       #if defined(__mips64)
+       CPU=mips64
+       #else
+       CPU=mips
+       #endif
+       #endif
+       #endif
+
        #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || 
defined(MIPSEL)
-       CPU=${UNAME_MACHINE}el
+       MIPS_ENDIAN=el
        #else
        #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || 
defined(MIPSEB)
-       CPU=${UNAME_MACHINE}
+       MIPS_ENDIAN=
        #else
-       CPU=
+       MIPS_ENDIAN=
        #endif
        #endif
 EOF
-       eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`"
-       test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; }
+       eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep 
'^CPU\|^MIPS_ENDIAN\|^LIBCABI'`"
+       test "x$CPU" != x && { echo 
"$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
        ;;
     mips64el:Linux:*:*)
        echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
@@ -1109,7 +1141,7 @@ EOF
            *Pentium)        UNAME_MACHINE=i586 ;;
            *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
        esac
-       echo 
"$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}"
+       echo 
"$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}"
        exit ;;
     i*86:*:3.2:*)
        if test -f /usr/options/cb.name; then
@@ -1429,6 +1461,130 @@ EOF
        exit ;;
 esac
 
+# No uname command or uname output not recognized.
+set_cc_for_build
+cat > "$dummy.c" <<EOF
+#ifdef _SEQUENT_
+#include <sys/types.h>
+#include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+  "4"
+#else
+  ""
+#endif
+  ); exit (0);
+#endif
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+  struct utsname un;
+
+  uname(&un);
+  if (strncmp(un.version, "V2", 2) == 0) {
+    printf ("i386-sequent-ptx2\n"); exit (0);
+  }
+  if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+    printf ("i386-sequent-ptx1\n"); exit (0);
+  }
+  printf ("i386-sequent-ptx\n"); exit (0);
+#endif
+
+#if defined (vax)
+#if !defined (ultrix)
+#include <sys/param.h>
+#if defined (BSD)
+#if BSD == 43
+  printf ("vax-dec-bsd4.3\n"); exit (0);
+#else
+#if BSD == 199006
+  printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#else
+  printf ("vax-dec-bsd\n"); exit (0);
+#endif
+#endif
+#else
+  printf ("vax-dec-bsd\n"); exit (0);
+#endif
+#else
+  printf ("vax-dec-ultrix\n"); exit (0);
+#endif
+#endif
+#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || 
defined(__ultrix__)
+#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || 
defined(__MIPS__)
+#include <signal.h>
+#if defined(_SIZE_T_) /* >= ULTRIX4 */
+  printf ("mips-dec-ultrix4\n"); exit (0);
+#else
+#if defined(ULTRIX3) || defined(ultrix3) || defined(SIGLOST)
+  printf ("mips-dec-ultrix3\n"); exit (0);
+#endif
+#endif
+#endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+       { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
+
 echo "$0: unable to guess system type" >&2
 
 case "$UNAME_MACHINE:$UNAME_SYSTEM" in
diff --git a/build-aux/config.sub b/build-aux/config.sub
index 4670805..f53af5a 100755
--- a/build-aux/config.sub
+++ b/build-aux/config.sub
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Configuration validation subroutine script.
-#   Copyright 1992-2018 Free Software Foundation, Inc.
+#   Copyright 1992-2019 Free Software Foundation, Inc.
 
-timestamp='2018-11-28'
+timestamp='2019-01-05'
 
 # 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
@@ -67,7 +67,7 @@ Report bugs and patches to <address@hidden>."
 version="\
 GNU config.sub ($timestamp)
 
-Copyright 1992-2018 Free Software Foundation, Inc.
+Copyright 1992-2019 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -111,7 +111,8 @@ case $# in
 esac
 
 # Split fields of configuration type
-IFS="-" read -r field1 field2 field3 field4 <<EOF
+# shellcheck disable=SC2162
+IFS="-" read field1 field2 field3 field4 <<EOF
 $1
 EOF
 
@@ -821,7 +822,9 @@ case $basic_machine in
                cpu=m68k
                vendor=next
                case $os in
-                   nextstep* )
+                   openstep*)
+                       ;;
+                   nextstep*)
                        ;;
                    ns2*)
                      os=nextstep2
@@ -918,7 +921,8 @@ case $basic_machine in
                ;;
 
        *-*)
-               IFS="-" read -r cpu vendor <<EOF
+               # shellcheck disable=SC2162
+               IFS="-" read cpu vendor <<EOF
 $basic_machine
 EOF
                ;;
@@ -1183,13 +1187,13 @@ case $cpu-$vendor in
                        | le32 | le64 \
                        | lm32 \
                        | m32c | m32r | m32rle \
-                       | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | 
m68k | v70 | w65 \
-                       | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx 
| picochip \
+                       | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | 
m68k \
+                       | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
                        | m88110 | m88k | maxq | mb | mcore | mep | metag \
                        | microblaze | microblazeel \
                        | mips | mipsbe | mipseb | mipsel | mipsle \
                        | mips16 \
-                       | mips64 | mips64el \
+                       | mips64 | mips64eb | mips64el \
                        | mips64octeon | mips64octeonel \
                        | mips64orion | mips64orionel \
                        | mips64r5900 | mips64r5900el \
@@ -1216,11 +1220,12 @@ case $cpu-$vendor in
                        | nds32 | nds32le | nds32be \
                        | nfp \
                        | nios | nios2 | nios2eb | nios2el \
-                       | none | np1 | ns16k | ns32k \
+                       | none | np1 | ns16k | ns32k | nvptx \
                        | open8 \
                        | or1k* \
                        | or32 \
                        | orion \
+                       | picochip \
                        | pdp10 | pdp11 | pj | pjl | pn | power \
                        | powerpc | powerpc64 | powerpc64le | powerpcle | 
powerpcspe \
                        | pru \
@@ -1228,7 +1233,8 @@ case $cpu-$vendor in
                        | riscv | riscv32 | riscv64 \
                        | rl78 | romp | rs6000 | rx \
                        | score \
-                       | sh | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | 
she[lb] | sh[lb]e \
+                       | sh | shl \
+                       | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] 
| sh[lb]e \
                        | sh[1234]e[lb] |  sh[12345][lb]e | sh[23]ele | sh64 | 
sh64le \
                        | sparc | sparc64 | sparc64b | sparc64v | sparc86x | 
sparclet \
                        | sparclite \
@@ -1238,10 +1244,11 @@ case $cpu-$vendor in
                        | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
                        | tron \
                        | ubicom32 \
-                       | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
+                       | v70 | v850 | v850e | v850e1 | v850es | v850e2 | 
v850e2v3 \
                        | vax \
                        | visium \
-                       | wasm32 \
+                       | w65 \
+                       | wasm32 | wasm64 \
                        | we32k \
                        | x86 | x86_64 | xc16x | xgate | xps100 \
                        | xstormy16 | xtensa* \
@@ -1361,7 +1368,7 @@ case $os in
             | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
             | skyos* | haiku* | rdos* | toppers* | drops* | es* \
             | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
-            | midnightbsd* | amdhsa* | unleashed*)
+            | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi*)
        # Remember, each alternative MUST END IN *, to match a version number.
                ;;
        qnx*)
diff --git a/build-aux/git-hooks/commit-msg b/build-aux/git-hooks/commit-msg
index 1ce4cee..4ed2614 100755
--- a/build-aux/git-hooks/commit-msg
+++ b/build-aux/git-hooks/commit-msg
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Check the format of GNU Emacs change log entries.
 
-# Copyright 2014-2018 Free Software Foundation, Inc.
+# Copyright 2014-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
diff --git a/build-aux/git-hooks/pre-commit b/build-aux/git-hooks/pre-commit
index c0455fb..e29a69f 100755
--- a/build-aux/git-hooks/pre-commit
+++ b/build-aux/git-hooks/pre-commit
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Check file names in git commits for GNU Emacs.
 
-# Copyright 2014-2018 Free Software Foundation, Inc.
+# Copyright 2014-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index 1e73f42..deddef2 100755
--- a/build-aux/gitlog-to-changelog
+++ b/build-aux/gitlog-to-changelog
@@ -9,7 +9,7 @@ my $VERSION = '2018-03-07 03:47'; # UTC
 # If you change this file with Emacs, please let the write hook
 # do its job.  Otherwise, update this string manually.
 
-# Copyright (C) 2008-2018 Free Software Foundation, Inc.
+# Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 # 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
diff --git a/build-aux/gitlog-to-emacslog b/build-aux/gitlog-to-emacslog
index bdf4536..7cd7c58 100755
--- a/build-aux/gitlog-to-emacslog
+++ b/build-aux/gitlog-to-emacslog
@@ -2,7 +2,7 @@
 
 # Convert git log output to ChangeLog format for GNU Emacs.
 
-# Copyright (C) 2014-2018 Free Software Foundation, Inc.
+# Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 # Author: Paul Eggert
 
diff --git a/build-aux/make-info-dir b/build-aux/make-info-dir
index cf8ffab..2dcac87 100755
--- a/build-aux/make-info-dir
+++ b/build-aux/make-info-dir
@@ -2,7 +2,7 @@
 
 ### make-info-dir - create info/dir, for systems without install-info
 
-## Copyright (C) 2013-2018 Free Software Foundation, Inc.
+## Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ## Author: Glenn Morris <address@hidden>
 ## Maintainer: address@hidden
diff --git a/build-aux/move-if-change b/build-aux/move-if-change
index 5da3eae..9073f1a 100755
--- a/build-aux/move-if-change
+++ b/build-aux/move-if-change
@@ -8,7 +8,7 @@ VERSION='2018-03-07 03:47'; # UTC
 # If you change this file with Emacs, please let the write hook
 # do its job.  Otherwise, update this string manually.
 
-# Copyright (C) 2002-2018 Free Software Foundation, Inc.
+# Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 # 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
@@ -36,9 +36,10 @@ The variable CMPPROG can be used to specify an alternative 
to 'cmp'.
 
 Report bugs to <address@hidden>."
 
+year=`expr "$VERSION" : '\([^-]*\)'`
 version=`expr "$VERSION" : '\([^ ]*\)'`
 version="move-if-change (gnulib) $version
-Copyright (C) 2011 Free Software Foundation, Inc.
+Copyright $year Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law."
diff --git a/build-aux/msys-to-w32 b/build-aux/msys-to-w32
index ca23302..758d172 100755
--- a/build-aux/msys-to-w32
+++ b/build-aux/msys-to-w32
@@ -2,7 +2,7 @@
 # Convert a MSYS path list to Windows-native format.
 # Status is zero if successful, nonzero otherwise.
 
-# Copyright (C) 2013-2018 Free Software Foundation, Inc.
+# Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 # 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
diff --git a/build-aux/update-copyright b/build-aux/update-copyright
index f2fc97e..d80549e 100755
--- a/build-aux/update-copyright
+++ b/build-aux/update-copyright
@@ -5,7 +5,7 @@ eval '(exit $?0)' && eval 'exec perl -wS -0777 -pi "$0" "$@"'
 
 my $VERSION = '2018-03-07.03:47'; # UTC
 
-# Copyright (C) 2009-2018 Free Software Foundation, Inc.
+# Copyright (C) 2009-2019 Free Software Foundation, Inc.
 #
 # 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
diff --git a/build-aux/update-subdirs b/build-aux/update-subdirs
index 8bc4f1a..7550995 100755
--- a/build-aux/update-subdirs
+++ b/build-aux/update-subdirs
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Write into $1/subdirs.el a list of subdirs of directory $1.
 
-# Copyright (C) 1994-1995, 1997, 1999, 2001-2018 Free Software
+# Copyright (C) 1994-1995, 1997, 1999, 2001-2019 Free Software
 # Foundation, Inc.
 
 # This file is part of GNU Emacs.
diff --git a/config.bat b/config.bat
index e5b3a08..3f8f73f 100644
--- a/config.bat
+++ b/config.bat
@@ -1,7 +1,7 @@
 @echo off
 rem   ----------------------------------------------------------------------
 rem   Configuration script for MSDOS
-rem   Copyright (C) 1994-1999, 2001-2018 Free Software Foundation, Inc.
+rem   Copyright (C) 1994-1999, 2001-2019 Free Software Foundation, Inc.
 
 rem   This file is part of GNU Emacs.
 
diff --git a/configure.ac b/configure.ac
index 991ab55..26ffc3e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@ dnl     autoconf
 dnl in the directory containing this script.
 dnl If you changed any AC_DEFINES, also run autoheader.
 dnl
-dnl Copyright (C) 1994-1996, 1999-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 1994-1996, 1999-2019 Free Software Foundation, Inc.
 dnl
 dnl  This file is part of GNU Emacs.
 dnl
@@ -311,6 +311,84 @@ this option's value should be 'yes', 'no', 'alsa', 'oss', 
or 'bsd-ossaudio'.])
   ],
   [with_sound=$with_features])
 
+AC_ARG_WITH([pdumper],
+  AS_HELP_STRING(
+    [--with-pdumper=VALUE],
+    [enable pdumper support unconditionally
+      ('yes', 'no', or 'auto': default 'auto')]),
+    [ case "${withval}" in
+        yes|no|auto) val=$withval ;;
+        *) AC_MSG_ERROR(
+           ['--with-pdumper=$withval' is invalid;
+this option's value should be 'yes' or 'no'.]) ;;
+      esac
+      with_pdumper=$val
+    ],
+    [with_pdumper=auto])
+
+AC_ARG_WITH([unexec],
+  AS_HELP_STRING(
+    [--with-unexec=VALUE],
+    [enable unexec support unconditionally
+      ('yes', 'no', or 'auto': default 'auto')]),
+    [ case "${withval}" in
+        yes|no|auto) val=$withval ;;
+        *) AC_MSG_ERROR(
+           ['--with-unexec=$withval' is invalid;
+this option's value should be 'yes' or 'no'.]) ;;
+      esac
+      with_unexec=$val
+    ],
+    [with_unexec=auto])
+
+AC_ARG_WITH([dumping],[AS_HELP_STRING([--with-dumping=VALUE],
+    [kind of dumping to use for initial Emacs build
+(VALUE one of: pdumper, unexec, none; default pdumper)])],
+    [ case "${withval}" in
+        pdumper|unexec|none) val=$withval ;;
+        *) AC_MSG_ERROR(['--with-dumping=$withval is invalid;
+this option's value should be 'pdumper', 'unexec', or 'none'.])
+        ;;
+      esac
+      with_dumping=$val
+    ],
+    [with_dumping=pdumper])
+
+if test "$with_pdumper" = "auto"; then
+  if test "$with_dumping" = "pdumper"; then
+    with_pdumper=yes
+  else
+    with_pdumper=no
+  fi
+fi
+
+if test "$with_unexec" = "auto"; then
+  if test "$with_dumping" = "unexec"; then
+    with_unexec=yes
+  else
+    with_unexec=no
+  fi
+fi
+
+if test "$with_dumping" = "pdumper" && test "$with_pdumper" = "no"; then
+  AC_MSG_ERROR(['--with-dumping=pdumper' requires pdumper support])
+fi
+
+if test "$with_dumping" = "unexec" && test "$with_unexec" = "no"; then
+  AC_MSG_ERROR(['--with-dumping=unexec' requires unexec support])
+fi
+
+if test "$with_pdumper" = "yes"; then
+  AC_DEFINE([HAVE_PDUMPER], 1, [Define to build with portable dumper support])
+  HAVE_PDUMPER=yes
+else
+  HAVE_PDUMPER=no
+fi
+AC_SUBST([HAVE_PDUMPER])
+
+DUMPING=$with_dumping
+AC_SUBST(DUMPING)
+
 dnl FIXME currently it is not the last.
 dnl This should be the last --with option, because --with-x is
 dnl added later on when we find the file name of X, and it's best to
@@ -464,38 +542,36 @@ fi)
 
 AC_ARG_ENABLE(checking,
 [AS_HELP_STRING([--enable-checking@<:@=LIST@:>@],
-               [enable expensive run-time checks.  With LIST,
+               [enable expensive checks.  With LIST,
                 enable only specific categories of checks.
                 Categories are: all,yes,no.
                 Flags are: stringbytes, stringoverrun, stringfreelist,
-                xmallocoverrun, conslist, glyphs])],
+                structs, glyphs])],
 [ac_checking_flags="${enableval}"],[])
 IFS="${IFS=    }"; ac_save_IFS="$IFS"; IFS="$IFS,"
+CHECK_STRUCTS=false
 for check in $ac_checking_flags
 do
        case $check in
        # these set all the flags to specific states
        yes)            ac_enable_checking=1 ;;
        no)             ac_enable_checking= ;
+                       CHECK_STRUCTS=false
                        ac_gc_check_stringbytes= ;
                        ac_gc_check_string_overrun= ;
                        ac_gc_check_string_free_list= ;
-                       ac_xmalloc_overrun= ;
-                       ac_gc_check_cons_list= ;
                        ac_glyphs_debug= ;;
        all)            ac_enable_checking=1 ;
+                       CHECK_STRUCTS=true
                        ac_gc_check_stringbytes=1 ;
                        ac_gc_check_string_overrun=1 ;
                        ac_gc_check_string_free_list=1 ;
-                       ac_xmalloc_overrun=1 ;
-                       ac_gc_check_cons_list=1 ;
                        ac_glyphs_debug=1 ;;
        # these enable particular checks
        stringbytes)    ac_gc_check_stringbytes=1 ;;
        stringoverrun)  ac_gc_check_string_overrun=1 ;;
        stringfreelist) ac_gc_check_string_free_list=1 ;;
-       xmallocoverrun) ac_xmalloc_overrun=1 ;;
-       conslist)       ac_gc_check_cons_list=1 ;;
+       structs)        CHECK_STRUCTS=true ;;
        glyphs)         ac_glyphs_debug=1 ;;
        *)      AC_MSG_ERROR(unknown check category $check) ;;
        esac
@@ -506,6 +582,15 @@ if test x$ac_enable_checking != x ; then
   AC_DEFINE(ENABLE_CHECKING, 1,
 [Define to 1 if expensive run-time data type and consistency checks are 
enabled.])
 fi
+if $CHECK_STRUCTS; then
+  AC_DEFINE([CHECK_STRUCTS], 1,
+    [Define this to check whether someone updated the portable dumper
+     code after changing the layout of a structure that it uses.
+     If you change one of these structures, check that the pdumper.c
+     code is still valid, and update the pertinent hash in pdumper.c
+     by manually copying the hash from the newly-generated dmpstruct.h.])
+fi
+AC_SUBST([CHECK_STRUCTS])
 if test x$ac_gc_check_stringbytes != x ; then
   AC_DEFINE(GC_CHECK_STRING_BYTES, 1,
 [Define this temporarily to hunt a bug.  If defined, the size of
@@ -520,14 +605,6 @@ if test x$ac_gc_check_string_free_list != x ; then
   AC_DEFINE(GC_CHECK_STRING_FREE_LIST, 1,
 [Define this to check the string free list.])
 fi
-if test x$ac_xmalloc_overrun != x ; then
-  AC_DEFINE(XMALLOC_OVERRUN_CHECK, 1,
-[Define this to check for malloc buffer overrun.])
-fi
-if test x$ac_gc_check_cons_list != x ; then
-  AC_DEFINE(GC_CHECK_CONS_LIST, 1,
-[Define this to check for errors in cons list.])
-fi
 if test x$ac_glyphs_debug != x ; then
   AC_DEFINE(GLYPH_DEBUG, 1,
 [Define this to enable glyphs debugging code.])
@@ -711,7 +788,9 @@ case "${canonical}" in
     opsys=qnxnto
     test -z "$CC" && CC=qcc
     CFLAGS="$CFLAGS -D__NO_EXT_QNX"
-    LDFLAGS="-N2MB $LDFLAGS"
+    if test "$with_unexec" = yes; then
+      LDFLAGS="-N2MB $LDFLAGS"
+    fi
   ;;
 
   ## Intel 386 machines where we don't care about the manufacturer.
@@ -976,6 +1055,9 @@ AS_IF([test $gl_gcc_warnings = no],
   # Emacs's use of alloca inhibits protecting the stack.
   nw="$nw -Wstack-protector"
 
+  # Emacs's use of __attribute__ ((cold)) causes false alarms with this option.
+  nw="$nw -Wsuggest-attribute=cold"
+
   # Emacs's use of partly-const functions such as Fgnutls_available_p
   # make this option problematic.
   nw="$nw -Wsuggest-attribute=const"
@@ -1216,6 +1298,10 @@ AC_PATH_PROG(GZIP_PROG, gzip)
 test $with_compress_install != yes && test -n "$GZIP_PROG" && \
    GZIP_PROG=" # $GZIP_PROG # (disabled by configure 
--without-compress-install)"
 
+if test "$with_dumping" = "unexec" && test "$opsys" = "nacl"; then
+  AC_MSG_ERROR([nacl is not compatible with --with-dumping=unexec])
+fi
+
 AC_CACHE_CHECK([for 'find' args to delete a file],
   [emacs_cv_find_delete],
   [if touch conftest.tmp && find conftest.tmp -delete 2>/dev/null &&
@@ -1228,25 +1314,21 @@ AC_SUBST([FIND_DELETE])
 
 PAXCTL_dumped=
 PAXCTL_notdumped=
-if test "$CANNOT_DUMP" != yes; then
-  if test $opsys = gnu-linux; then
-    if test "${SETFATTR+set}" != set; then
-      AC_CACHE_CHECK([for setfattr],
-       [emacs_cv_prog_setfattr],
-       [touch conftest.tmp
-        if (setfattr -n user.pax.flags conftest.tmp) >/dev/null 2>&1; then
-          emacs_cv_prog_setfattr=yes
-        else
-          emacs_cv_prog_setfattr=no
-        fi])
-      if test "$emacs_cv_prog_setfattr" = yes; then
-       PAXCTL_notdumped='$(SETFATTR) -n user.pax.flags -v er'
-       SETFATTR=setfattr
-      else
-       SETFATTR=
-      fi
-      rm -f conftest.tmp
-      AC_SUBST([SETFATTR])
+if test $with_unexec = yes && test $opsys = gnu-linux; then
+  if test "${SETFATTR+set}" != set; then
+    AC_CACHE_CHECK([for setfattr],
+      [emacs_cv_prog_setfattr],
+      [touch conftest.tmp
+       if (setfattr -n user.pax.flags conftest.tmp) >/dev/null 2>&1; then
+        emacs_cv_prog_setfattr=yes
+       else
+        emacs_cv_prog_setfattr=no
+       fi])
+    if test "$emacs_cv_prog_setfattr" = yes; then
+      PAXCTL_notdumped='$(SETFATTR) -n user.pax.flags -v er'
+      SETFATTR=setfattr
+    else
+      SETFATTR=
     fi
   fi
   case $opsys,$PAXCTL_notdumped,$emacs_uname_r in
@@ -1276,6 +1358,7 @@ if test "$CANNOT_DUMP" != yes; then
 fi
 AC_SUBST([PAXCTL_dumped])
 AC_SUBST([PAXCTL_notdumped])
+AC_SUBST([SETFATTR])
 
 # Makeinfo on macOS is ancient, check whether there is a more recent
 # version installed by Homebrew.
@@ -1352,7 +1435,7 @@ else
 fi
 
 AC_CACHE_CHECK([for -znocombreloc], [emacs_cv_znocombreloc],
-  [if test "$CANNOT_DUMP" = "yes"; then
+  [if test $with_unexec = no; then
      emacs_cv_znocombreloc='not needed'
    else
      save_LDFLAGS=$LDFLAGS
@@ -1383,23 +1466,16 @@ AC_CACHE_CHECK([whether addresses are sanitized],
      [emacs_cv_sanitize_address=yes],
      [emacs_cv_sanitize_address=no])])
 
-dnl The function dump-emacs will not be defined and temacs will do
-dnl (load "loadup") automatically unless told otherwise.
-test "x$CANNOT_DUMP" = "x" && CANNOT_DUMP=no
-case "$opsys" in
-  nacl) CANNOT_DUMP=yes ;;
-esac
-
-if test "$CANNOT_DUMP" = "yes"; then
-  AC_DEFINE(CANNOT_DUMP, 1, [Define if Emacs cannot be dumped on your system.])
-elif test "$emacs_cv_sanitize_address" = yes; then
-  AC_MSG_WARN([[Addresses are sanitized; suggest CANNOT_DUMP=yes]])
+if test $with_unexec = yes; then
+  AC_DEFINE([HAVE_UNEXEC], 1, [Define if Emacs supports unexec.])
+  if test "$emacs_cv_sanitize_address" = yes; then
+    AC_MSG_WARN([[Addresses are sanitized; suggest --without-unexec]])
+  fi
 fi
 
-AC_SUBST(CANNOT_DUMP)
 
-
-UNEXEC_OBJ=unexelf.o
+UNEXEC_OBJ=
+test $with_unexec = yes &&
 case "$opsys" in
   # MSDOS uses unexcoff.o
   aix4-2)
@@ -1427,11 +1503,13 @@ case "$opsys" in
    # not been tested, so for now this change is for Solaris 10 or newer.
    UNEXEC_OBJ=unexsol.o
    ;;
+  *)
+   UNEXEC_OBJ=unexelf.o
+   ;;
 esac
-test "$CANNOT_DUMP" = "yes" && UNEXEC_OBJ=
 
 LD_SWITCH_SYSTEM=
-case "$opsys" in
+test "$with_unexec" = no || case "$opsys" in
   freebsd|dragonfly)
    ## Let 'ld' find image libs and similar things in /usr/local/lib.
    ## The system compiler, GCC, has apparently been modified to not
@@ -1477,8 +1555,9 @@ case "$opsys" in
    LD_SWITCH_SYSTEM="\$(LD_SWITCH_X_SITE_RPATH) $LD_SWITCH_SYSTEM" ;;
 esac
 
-
 C_SWITCH_MACHINE=
+
+test $with_unexec = yes &&
 case $canonical in
  alpha*)
   AC_CHECK_DECL([__ELF__])
@@ -2237,7 +2316,7 @@ doug_lea_malloc=$emacs_cv_var_doug_lea_malloc
 hybrid_malloc=
 system_malloc=yes
 
-test "$CANNOT_DUMP" = yes ||
+test $with_unexec = yes &&
 case "$opsys" in
   ## darwin ld insists on the use of malloc routines in the System framework.
   darwin | mingw32 | nacl | sol2-10) ;;
@@ -2599,8 +2678,8 @@ check_gtk2=no
 gtk3_pkg_errors=
 if test "${opsys}" != "mingw32"; then
   if test "${with_gtk3}" = "yes" || test "${with_gtk}" = "yes" || test 
"$USE_X_TOOLKIT" = "maybe"; then
-    GLIB_REQUIRED=2.28
-    GTK_REQUIRED=3.0
+    GLIB_REQUIRED=2.37.5
+    GTK_REQUIRED=3.10
     GTK_MODULES="gtk+-3.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
 
     dnl Checks for libraries.
@@ -2627,8 +2706,8 @@ if test "${opsys}" != "mingw32"; then
   fi
 
   if test "${with_gtk2}" = "yes" || test "$check_gtk2" = "yes"; then
-    GLIB_REQUIRED=2.10
-    GTK_REQUIRED=2.10
+    GLIB_REQUIRED=2.28
+    GTK_REQUIRED=2.24
     GTK_MODULES="gtk+-2.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED"
 
     dnl Checks for libraries.
@@ -2703,44 +2782,25 @@ if test "${HAVE_GTK}" = "yes"; then
     with_toolkit_scroll_bars=yes
   fi
 
-  dnl  Check if we have the old file selection dialog declared and
-  dnl  in the link library.  In 2.x it may be in the library,
-  dnl  but not declared if deprecated featured has been selected out.
-  dnl  AC_CHECK_DECL checks for a macro, so check for GTK_TYPE_FILE_SELECTION.
-  HAVE_GTK_FILE_SELECTION=no
-  AC_CHECK_DECL(GTK_TYPE_FILE_SELECTION, HAVE_GTK_FILE_SELECTION=yes,
-                   HAVE_GTK_FILE_SELECTION=no, [AC_INCLUDES_DEFAULT
-#include <gtk/gtk.h>])
-  if test "$HAVE_GTK_FILE_SELECTION" = yes; then
-    AC_CHECK_FUNCS(gtk_file_selection_new)
-  fi
+  term_header=gtkutil.h
 
-  dnl Same as above for gtk_handle_box.
-  HAVE_GTK_HANDLE_BOX=no
-  AC_CHECK_DECL(GTK_TYPE_HANDLE_BOX, HAVE_GTK_HANDLE_BOX=yes,
-                   HAVE_GTK_HANDLE_BOX=no, [AC_INCLUDES_DEFAULT
-#include <gtk/gtk.h>])
-  if test "$HAVE_GTK_HANDLE_BOX" = yes; then
-    AC_CHECK_FUNCS(gtk_handle_box_new)
-  fi
+  if test "${USE_GTK_TOOLKIT}" = GTK2; then
 
-  dnl Same as above for gtk_tearoff_menu_item.
-  HAVE_GTK_TEAROFF_MENU_ITEM=no
-  AC_CHECK_DECL(GTK_TYPE_TEAROFF_MENU_ITEM, HAVE_GTK_TEAROFF_MENU_ITEM=yes,
-                   HAVE_GTK_TEAROFF_MENU_ITEM=no, [AC_INCLUDES_DEFAULT
+    dnl  Check if we have the old file selection dialog declared and
+    dnl  in the link library.  In 2.x it may be in the library,
+    dnl  but not declared if deprecated featured has been selected out.
+    dnl  AC_CHECK_DECL checks for a macro, so check for 
GTK_TYPE_FILE_SELECTION.
+    HAVE_GTK_FILE_SELECTION=no
+    AC_CHECK_DECL(GTK_TYPE_FILE_SELECTION, HAVE_GTK_FILE_SELECTION=yes,
+                     HAVE_GTK_FILE_SELECTION=no, [AC_INCLUDES_DEFAULT
 #include <gtk/gtk.h>])
-  if test "$HAVE_GTK_TEAROFF_MENU_ITEM" = yes; then
-    AC_CHECK_FUNCS(gtk_tearoff_menu_item_new)
-  fi
-
-  dnl Check for functions introduced in 2.14 and later.
-  AC_CHECK_FUNCS(gtk_widget_get_window gtk_widget_set_has_window \
-                 gtk_dialog_get_action_area gtk_widget_get_sensitive \
-                 gtk_widget_get_mapped gtk_adjustment_get_page_size \
-                 gtk_orientable_set_orientation \
-                gtk_window_set_has_resize_grip)
+    if test "$HAVE_GTK_FILE_SELECTION" = yes; then
+      AC_CHECK_FUNCS(gtk_file_selection_new)
+    fi
 
- term_header=gtkutil.h
+    dnl This procedure causes a bug on certain Ubuntu GTK+2 builds
+    AC_CHECK_FUNCS(gtk_window_set_has_resize_grip)
+  fi
 fi
 
 
@@ -2869,7 +2929,7 @@ fi
 AC_SUBST(LIBSELINUX_LIBS)
 
 HAVE_GNUTLS=no
-if test "${with_gnutls}" = "yes" ; then
+if test "${with_gnutls}" != "no" ; then
   EMACS_CHECK_MODULES([LIBGNUTLS], [gnutls >= 2.12.2],
     [HAVE_GNUTLS=yes], [HAVE_GNUTLS=no])
   if test "${HAVE_GNUTLS}" = "yes"; then
@@ -3242,12 +3302,55 @@ either XPointer or XPointer*.])dnl
   CFLAGS=$late_CFLAGS
 fi
 
+# Check for XRender
+HAVE_XRENDER=no
+if test "${HAVE_X11}" = "yes"; then
+  AC_CHECK_LIB(Xrender, XRenderQueryExtension, HAVE_XRENDER=yes)
+  if test $HAVE_XRENDER = yes; then
+    XRENDER_LIBS="-lXrender"
+    AC_SUBST(XRENDER_LIBS)
+    AC_DEFINE([HAVE_XRENDER], 1, [Define to 1 if XRender is available.])
+  fi
+fi
+
+HAVE_CAIRO=no
+if test "${HAVE_X11}" = "yes"; then
+  if test "${with_cairo}" != "no"; then
+    CAIRO_REQUIRED=1.12.0
+    CAIRO_MODULE="cairo >= $CAIRO_REQUIRED"
+    EMACS_CHECK_MODULES(CAIRO, $CAIRO_MODULE)
+    if test $HAVE_CAIRO = yes; then
+      AC_DEFINE(USE_CAIRO, 1, [Define to 1 if using cairo.])
+    else
+      AC_MSG_ERROR([cairo requested but not found.])
+    fi
+
+    CFLAGS="$CFLAGS $CAIRO_CFLAGS"
+    LIBS="$LIBS $CAIRO_LIBS"
+    AC_SUBST(CAIRO_CFLAGS)
+    AC_SUBST(CAIRO_LIBS)
+  fi
+fi
+
 ### Start of font-backend (under any platform) section.
 # (nothing here yet -- this is a placeholder)
 ### End of font-backend (under any platform) section.
 
 ### Start of font-backend (under X11) section.
 if test "${HAVE_X11}" = "yes"; then
+  if test $HAVE_CAIRO = yes; then
+    dnl Strict linkers fail with
+    dnl ftfont.o: undefined reference to symbol 'FT_New_Face'
+    dnl if -lfreetype is not specified.
+    dnl The following is needed to set FREETYPE_LIBS.
+    EMACS_CHECK_MODULES([FREETYPE], [freetype2])
+
+    test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(cairo requires libfreetype)
+
+    EMACS_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.2.0])
+
+    test "$HAVE_FONTCONFIG" = "no" && AC_MSG_ERROR(cairo requires 
libfontconfig)
+  else
     ## Use -lXft if available, unless '--with-xft=no'.
     HAVE_XFT=maybe
     if test "x${with_x}" = "xno"; then
@@ -3264,15 +3367,12 @@ if test "${HAVE_X11}" = "yes"; then
       EMACS_CHECK_MODULES([XFT], [xft >= 0.13.0], [], [HAVE_XFT=no])
       ## Because xterm.c uses XRenderQueryExtension when XFT is
       ## enabled, we also need to link to -lXrender.
-      HAVE_XRENDER=no
-      AC_CHECK_LIB(Xrender, XRenderQueryExtension, HAVE_XRENDER=yes)
       if test "$HAVE_XFT" != no && test "$HAVE_XRENDER" != no; then
        OLD_CPPFLAGS="$CPPFLAGS"
        OLD_CFLAGS="$CFLAGS"
        OLD_LIBS="$LIBS"
        CPPFLAGS="$CPPFLAGS $XFT_CFLAGS"
        CFLAGS="$CFLAGS $XFT_CFLAGS"
-       XFT_LIBS="-lXrender $XFT_LIBS"
        LIBS="$XFT_LIBS $LIBS"
        AC_CHECK_HEADER(X11/Xft/Xft.h,
          AC_CHECK_LIB(Xft, XftFontOpen, HAVE_XFT=yes, , $XFT_LIBS) , ,
@@ -3307,6 +3407,7 @@ if test "${HAVE_X11}" = "yes"; then
 
        test "$HAVE_FREETYPE" = "no" && AC_MSG_ERROR(libxft requires 
libfreetype)
     fi
+  fi                             # $HAVE_CAIRO != yes
 
     HAVE_HARFBUZZ=no
     HAVE_LIBOTF=no
@@ -3370,25 +3471,6 @@ AC_SUBST(LIBOTF_LIBS)
 AC_SUBST(M17N_FLT_CFLAGS)
 AC_SUBST(M17N_FLT_LIBS)
 
-HAVE_CAIRO=no
-if test "${HAVE_X11}" = "yes"; then
-  if test "${with_cairo}" != "no"; then
-    CAIRO_REQUIRED=1.12.0
-    CAIRO_MODULE="cairo >= $CAIRO_REQUIRED"
-    EMACS_CHECK_MODULES(CAIRO, $CAIRO_MODULE)
-    if test $HAVE_CAIRO = yes; then
-      AC_DEFINE(USE_CAIRO, 1, [Define to 1 if using cairo.])
-    else
-      AC_MSG_ERROR([cairo requested but not found.])
-    fi
-
-    CFLAGS="$CFLAGS $CAIRO_CFLAGS"
-    LIBS="$LIBS $CAIRO_LIBS"
-    AC_SUBST(CAIRO_CFLAGS)
-    AC_SUBST(CAIRO_LIBS)
-  fi
-fi
-
 if test "${HAVE_X11}" = "yes"; then
   AC_CHECK_HEADER(X11/Xlib-xcb.h,
     AC_CHECK_LIB(xcb, xcb_translate_coordinates, HAVE_XCB=yes))
@@ -3442,7 +3524,10 @@ fi
 
 if test "${HAVE_X11}" = "yes"; then
   dnl Avoid Xpm on AIX unless requested, as it crashes; see Bug#17598.
-  test "$opsys$with_xpm_set" = aix4-2 && with_xpm=no
+  case $opsys,$with_xpm_set,$with_xpm in
+    aix4-2,set,yes) ;;
+    aix4-2,*) with_xpm=no;;
+  esac
 
   if test "${with_xpm}" != "no"; then
     AC_CHECK_HEADER(X11/xpm.h,
@@ -3619,8 +3704,10 @@ AC_SUBST(MODULES_SUFFIX)
 AC_CONFIG_FILES([src/emacs-module.h])
 AC_SUBST_FILE([module_env_snippet_25])
 AC_SUBST_FILE([module_env_snippet_26])
+AC_SUBST_FILE([module_env_snippet_27])
 module_env_snippet_25="$srcdir/src/module-env-25.h"
 module_env_snippet_26="$srcdir/src/module-env-26.h"
+module_env_snippet_27="$srcdir/src/module-env-27.h"
 
 ### Use -lpng if available, unless '--with-png=no'.
 HAVE_PNG=no
@@ -3758,28 +3845,46 @@ AC_SUBST(LIBGIF)
 
 dnl Check for required libraries.
 MISSING=
-WITH_NO=
+WITH_IFAVAILABLE=
 if test "${HAVE_X11}" = "yes"; then
-  test "${with_xpm}" != "no" && test "${HAVE_XPM}" != "yes" &&
-    MISSING="libXpm" && WITH_NO="--with-xpm=no"
-  test "${with_jpeg}" != "no" && test "${HAVE_JPEG}" != "yes" &&
-    MISSING="$MISSING libjpeg" && WITH_NO="$WITH_NO --with-jpeg=no"
-  test "${with_png}" != "no" && test "${HAVE_PNG}" != "yes" &&
-    MISSING="$MISSING libpng" && WITH_NO="$WITH_NO --with-png=no"
-  test "${with_gif}" != "no" && test "${HAVE_GIF}" != "yes" &&
-    MISSING="$MISSING libgif/libungif" && WITH_NO="$WITH_NO --with-gif=no"
-  test "${with_tiff}" != "no" && test "${HAVE_TIFF}" != "yes" &&
-    MISSING="$MISSING libtiff" && WITH_NO="$WITH_NO --with-tiff=no"
-fi
-test "${with_gnutls}" != "no" && test "${HAVE_GNUTLS}" != "yes" &&
-  MISSING="$MISSING gnutls" && WITH_NO="$WITH_NO --with-gnutls=no"
+  case $with_xpm,$HAVE_XPM in
+    no,* | ifavailable,* | *,yes) ;;
+    *) MISSING="libXpm"
+       WITH_IFAVAILABLE="--with-xpm=ifavailable";;
+  esac
+  case $with_jpeg,$HAVE_JPEG in
+    no,* | ifavailable,* | *,yes) ;;
+    *) MISSING="$MISSING libjpeg"
+       WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-jpeg=ifavailable";;
+  esac
+  case $with_png,$HAVE_PNG in
+    no,* | ifavailable,* | *,yes) ;;
+    *) MISSING="$MISSING libpng"
+       WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-png=ifavailable";;
+  esac
+  case $with_gif,$HAVE_GIF in
+    no,* | ifavailable,* | *,yes) ;;
+    *) MISSING="$MISSING libgif/libungif"
+       WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-gif=ifavailable";;
+  esac
+  case $with_tiff,$HAVE_TIFF in
+    no,* | ifavailable,* | *,yes) ;;
+    *) MISSING="$MISSING libtiff"
+       WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-tiff=ifavailable";;
+  esac
+fi
+case $with_gnutls,$HAVE_GNUTLS in
+  no,* | ifavailable,* | *,yes) ;;
+  *) MISSING="$MISSING gnutls"
+     WITH_IFAVAILABLE="$WITH_IFAVAILABLE --with-gnutls=ifavailable";;
+esac
 if test "X${MISSING}" != X; then
   AC_MSG_ERROR([The following required libraries were not found:
     $MISSING
 Maybe some development libraries/packages are missing?
-If you don't want to link with them give
-    $WITH_NO
-as options to configure])
+To build anyway, give:
+    $WITH_IFAVAILABLE
+as options to configure.])
 fi
 
 ### Use -lgpm if available, unless '--with-gpm=no'.
@@ -4056,7 +4161,7 @@ getrusage get_current_dir_name \
 lrand48 random rint trunc \
 select getpagesize setlocale newlocale \
 getrlimit setrlimit shutdown \
-pthread_sigmask strsignal setitimer \
+pthread_sigmask strsignal setitimer timer_getoverrun \
 sendto recvfrom getsockname getifaddrs freeifaddrs \
 gai_strerror sync \
 getpwent endpwent getgrent endgrent \
@@ -4067,6 +4172,9 @@ dnl No need to check for posix_memalign if aligned_alloc 
works.
 AC_CHECK_FUNCS([aligned_alloc posix_memalign], [break])
 AC_CHECK_DECLS([aligned_alloc], [], [], [[#include <stdlib.h>]])
 
+# Dump loading
+AC_CHECK_FUNCS([posix_madvise])
+
 dnl Cannot use AC_CHECK_FUNCS
 AC_CACHE_CHECK([for __builtin_frame_address],
   [emacs_cv_func___builtin_frame_address],
@@ -4122,7 +4230,8 @@ AC_CACHE_CHECK([for library containing tputs], 
[emacs_cv_tputs_lib],
   emacs_cv_tputs_lib='none required'
 else
   # curses precedes termcap because of AIX (Bug#9736#35) and OpenIndiana.
-  for tputs_library in '' tinfo ncurses terminfo curses termcap; do
+  tputs_libraries='tinfo ncurses terminfo curses termcap tinfow ncursesw'
+  for tputs_library in '' $tputs_libraries; do
     OLIBS=$LIBS
     if test -z "$tputs_library"; then
       emacs_cv_tputs_lib='none required'
@@ -4418,15 +4527,27 @@ fi
 AC_SUBST(XGSELOBJ)
 
 dnl Adapted from Haible's version.
-AC_CACHE_CHECK([for nl_langinfo and CODESET], emacs_cv_langinfo_codeset,
+AC_CACHE_CHECK([for nl_langinfo and CODESET], [emacs_cv_langinfo_codeset],
   [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]],
-    [[char* cs = nl_langinfo(CODESET);]])],
-    emacs_cv_langinfo_codeset=yes,
-    emacs_cv_langinfo_codeset=no)
+    [[char *cs = nl_langinfo(CODESET);]])],
+    [emacs_cv_langinfo_codeset=yes],
+    [emacs_cv_langinfo_codeset=no])
   ])
-if test $emacs_cv_langinfo_codeset = yes; then
-  AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
-    [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
+if test "$emacs_cv_langinfo_codeset" = yes; then
+  AC_DEFINE([HAVE_LANGINFO_CODESET], 1,
+    [Define if you have <langinfo.h> and nl_langinfo (CODESET).])
+
+  AC_CACHE_CHECK([for nl_langinfo and _NL_PAPER_WIDTH],
+    [emacs_cv_langinfo__nl_paper_width],
+    [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]],
+      [[char *cs = nl_langinfo (_NL_PAPER_WIDTH);]])],
+      [emacs_cv_langinfo__nl_paper_width=yes],
+      [emacs_cv_langinfo__nl_paper_width=no])
+    ])
+  if test "$emacs_cv_langinfo__nl_paper_width" = yes; then
+    AC_DEFINE([HAVE_LANGINFO__NL_PAPER_WIDTH], 1,
+      [Define if you have <langinfo.h> and nl_langinfo (_NL_PAPER_WIDTH).])
+  fi
 fi
 
 AC_TYPE_MBSTATE_T
@@ -5049,7 +5170,7 @@ fi
 
 version=$PACKAGE_VERSION
 
-copyright="Copyright (C) 2018 Free Software Foundation, Inc."
+copyright="Copyright (C) 2019 Free Software Foundation, Inc."
 AC_DEFINE_UNQUOTED(COPYRIGHT, ["$copyright"],
   [Short copyright string for this version of Emacs.])
 AC_SUBST(copyright)
@@ -5306,6 +5427,15 @@ case "$opsys" in
   cygwin) LD_SWITCH_SYSTEM_TEMACS="-Wl,-stack,0x00800000" ;;
 
   darwin)
+   if test "$HAVE_NS" = "yes"; then
+     libs_nsgui="-framework AppKit"
+     if test "$NS_IMPL_COCOA" = "yes"; then
+        libs_nsgui="$libs_nsgui -framework IOKit -framework Carbon"
+     fi
+   else
+     libs_nsgui=
+   fi
+   LD_SWITCH_SYSTEM_TEMACS=$libs_nsgui
    ## The -headerpad option tells ld (see man page) to leave room at the
    ## end of the header for adding load commands.  Needed for dumping.
    ## 0x1000 is enough for roughly 52 load commands on the x86_64
@@ -5314,15 +5444,9 @@ case "$opsys" in
    ## about 14 to about 34. Setting it high gets us plenty of slop and
    ## only costs about 1.5K of wasted binary space.
    headerpad_extra=1000
-   if test "$HAVE_NS" = "yes"; then
-     libs_nsgui="-framework AppKit"
-     if test "$NS_IMPL_COCOA" = "yes"; then
-        libs_nsgui="$libs_nsgui -framework IOKit -framework Carbon"
-     fi
-   else
-     libs_nsgui=
+   if test "$with_unexec" = yes; then
+     LD_SWITCH_SYSTEM_TEMACS="-fno-pie $LD_SWITCH_SYSTEM_TEMACS -Xlinker 
-headerpad -Xlinker $headerpad_extra"
    fi
-   LD_SWITCH_SYSTEM_TEMACS="-fno-pie -prebind $libs_nsgui -Xlinker -headerpad 
-Xlinker $headerpad_extra"
 
    ## This is here because src/Makefile.in did some extra fiddling around
    ## with LD_SWITCH_SYSTEM.  It seems cleaner to put this in
@@ -5362,7 +5486,7 @@ esac
 AC_CACHE_CHECK(
   [for $CC option to disable position independent executables],
   [emacs_cv_prog_cc_no_pie],
-  [if test "$CANNOT_DUMP" = yes; then
+  [if test $with_unexec = no; then
      emacs_cv_prog_cc_no_pie='not needed'
    else
      emacs_save_c_werror_flag=$ac_c_werror_flag
@@ -5404,7 +5528,7 @@ AC_SUBST(WINDOW_SYSTEM_OBJ)
 
 AH_TOP([/* GNU Emacs site configuration template file.
 
-Copyright (C) 1988, 1993-1994, 1999-2002, 2004-2018
+Copyright (C) 1988, 1993-1994, 1999-2002, 2004-2019
   Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -5474,10 +5598,11 @@ emacs_config_features=
 for opt in XAW3D XPM JPEG TIFF GIF PNG RSVG CAIRO IMAGEMAGICK SOUND GPM DBUS \
   GCONF GSETTINGS GLIB NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ 
M17N_FLT \
   LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS X_TOOLKIT OLDXMENU X11 XDBE XIM \
-  NS MODULES THREADS XWIDGETS LIBSYSTEMD JSON CANNOT_DUMP LCMS2 GMP; do
+  NS MODULES THREADS XWIDGETS LIBSYSTEMD JSON PDUMPER UNEXEC LCMS2 GMP; do
 
     case $opt in
-      CANNOT_DUMP) eval val=\${$opt} ;;
+      PDUMPER) val=${with_pdumper} ;;
+      UNEXEC) val=${with_unexec} ;;
       GLIB) val=${emacs_cv_links_glib} ;;
       NOTIFY|ACL) eval val=\${${opt}_SUMMARY} ;;
       TOOLKIT_SCROLL_BARS|X_TOOLKIT) eval val=\${USE_$opt} ;;
@@ -5543,6 +5668,9 @@ AS_ECHO(["  Does Emacs use -lXaw3d?                       
          ${HAVE_XAW3D
   Does Emacs use toolkit scroll bars?                     
${USE_TOOLKIT_SCROLL_BARS}
   Does Emacs support Xwidgets (requires gtk3)?            ${HAVE_XWIDGETS}
   Does Emacs have threading support in lisp?              ${threads_enabled}
+  Does Emacs support the portable dumper?                 ${with_pdumper}
+  Does Emacs support legacy unexec dumping?               ${with_unexec}
+  Which dumping strategy does Emacs use?                  ${with_dumping}
 "])
 
 if test -n "${EMACSDATA}"; then
@@ -5712,4 +5840,12 @@ you can continue to support by using '$0 --with-pop'.])
   esac
 fi
 
-test "$MAKE" = make || AC_MSG_NOTICE([Now you can run '$MAKE'.])
+# Let plain 'make' work.
+test "$MAKE" = make || test -f makefile || cat >makefile <<EOF
+.POSIX:
+MAKE = $MAKE
+all:
+       \$(MAKE) -f Makefile \$?
+.DEFAULT:
+       \$(MAKE) -f Makefile \$<
+EOF
diff --git a/doc/emacs/ChangeLog.1 b/doc/emacs/ChangeLog.1
index 26a0d3e..b9f7e49 100644
--- a/doc/emacs/ChangeLog.1
+++ b/doc/emacs/ChangeLog.1
@@ -83,7 +83,7 @@
 
 2014-12-08  Eric S. Raymond  <address@hidden>
 
-       * maintaining.texi: Suopport fo Arch has been moved to obosolete,
+       * maintaining.texi: Support for Arch has been moved to obsolete,
        remove references that imply otherwise.
 
 2014-11-29  Paul Eggert  <address@hidden>
@@ -10919,7 +10919,7 @@
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 1993-1999, 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 1993-1999, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/doc/emacs/Makefile.in b/doc/emacs/Makefile.in
index 54e173f..01c6700 100644
--- a/doc/emacs/Makefile.in
+++ b/doc/emacs/Makefile.in
@@ -1,6 +1,6 @@
 ### @configure_input@
 
-# Copyright (C) 1994, 1996-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994, 1996-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
diff --git a/doc/emacs/abbrevs.texi b/doc/emacs/abbrevs.texi
index 00b9e56..9c8a280 100644
--- a/doc/emacs/abbrevs.texi
+++ b/doc/emacs/abbrevs.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Abbrevs
diff --git a/doc/emacs/ack.texi b/doc/emacs/ack.texi
index 20c8d4e..0e4a982 100644
--- a/doc/emacs/ack.texi
+++ b/doc/emacs/ack.texi
@@ -1,6 +1,6 @@
 @c -*- coding: utf-8 -*-
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1994-1997, 1999-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 1994-1997, 1999-2019 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @node Acknowledgments
@@ -829,8 +829,8 @@ command with its arguments.
 Richard Mlynarik wrote @file{cl-indent.el}, a package for indenting
 Common Lisp code; @file{ebuff-menu.el}, an electric browser for
 buffer listings; @file{ehelp.el}, bindings for browsing help screens;
-and @file{rfc822.el}, a parser for E-mail addresses in the RFC-822 format,
-used in mail messages and news articles.
+and @file{rfc822.el}, a parser for E-mail addresses in the format
+used in mail messages and news articles (Internet RFC 822 and its successors).
 
 @item
 Gerd Möllmann was the Emacs maintainer from the beginning of Emacs 21
diff --git a/doc/emacs/anti.texi b/doc/emacs/anti.texi
index b915163..9eac08c 100644
--- a/doc/emacs/anti.texi
+++ b/doc/emacs/anti.texi
@@ -1,6 +1,6 @@
 @c -*- coding: utf-8 -*-
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 2005-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 2005-2019 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 
 @node Antinews
diff --git a/doc/emacs/arevert-xtra.texi b/doc/emacs/arevert-xtra.texi
index 45fca1f..cd7c1ff 100644
--- a/doc/emacs/arevert-xtra.texi
+++ b/doc/emacs/arevert-xtra.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 2004-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 2004-2019 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @c This file is included either in emacs-xtra.texi (when producing the
diff --git a/doc/emacs/basic.texi b/doc/emacs/basic.texi
index f911c67..86403b7 100644
--- a/doc/emacs/basic.texi
+++ b/doc/emacs/basic.texi
@@ -1,6 +1,6 @@
 @c -*- coding: utf-8 -*-
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Basic
diff --git a/doc/emacs/buffers.texi b/doc/emacs/buffers.texi
index dd7a653..27fcb73 100644
--- a/doc/emacs/buffers.texi
+++ b/doc/emacs/buffers.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Buffers
diff --git a/doc/emacs/building.texi b/doc/emacs/building.texi
index 64fbbe8..518d157 100644
--- a/doc/emacs/building.texi
+++ b/doc/emacs/building.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Building
@@ -151,6 +151,20 @@ with the mouse (@pxref{Mouse References}), to visit the 
@dfn{locus} of
 the error message in a separate window.  The locus is the specific
 position in a file where that error occurred.
 
address@hidden compilation mode faces
address@hidden compilation-error
address@hidden compilation-warning
+  The appearance of the @file{*compilation*} buffer can be controlled
+by customizing the faces which are used to highlight parts of the
address@hidden buffer, e.g., @code{compilation-error} or
address@hidden, for error and warning messages
+respectively.  Note that since those faces inherit from the
address@hidden and @code{warning} faces, it is also possible to
+customize the parent face directly instead.
+
+  Use @address@hidden customize-group RET compilation}} to see the entire
+list of customization variables and faces.
+
 @findex compile-goto-error
 @vindex compilation-auto-jump-to-first-error
   If you change the variable
diff --git a/doc/emacs/cal-xtra.texi b/doc/emacs/cal-xtra.texi
index 80e9b85..7fa20de 100644
--- a/doc/emacs/cal-xtra.texi
+++ b/doc/emacs/cal-xtra.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.  -*- coding: utf-8 -*-
address@hidden Copyright (C) 2004-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 2004-2019 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @c This file is included either in emacs-xtra.texi (when producing the
diff --git a/doc/emacs/calendar.texi b/doc/emacs/calendar.texi
index 7021146..138a24f 100644
--- a/doc/emacs/calendar.texi
+++ b/doc/emacs/calendar.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.  -*- coding: utf-8 -*-
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Calendar/Diary
diff --git a/doc/emacs/cmdargs.texi b/doc/emacs/cmdargs.texi
index 960398d..00d5be7 100644
--- a/doc/emacs/cmdargs.texi
+++ b/doc/emacs/cmdargs.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Emacs Invocation
@@ -383,6 +383,21 @@ verify that their module conforms to the module API 
requirements.  The
 option makes Emacs abort if a module-related assertion triggers.
 @xref{Writing Dynamic Modules,, Writing Dynamically-Loaded Modules,
 elisp, The GNU Emacs Lisp Reference Manual}.
+
address@hidden address@hidden
address@hidden --dump-file
address@hidden specify dump file
+Load the dumped Emacs state from the named @var{file}.  By default, an
+installed Emacs will look for its dump state in a file named
address@hidden@var{emacs}.pdmp} in the directory where the Emacs installation
+puts the architecture-dependent files; the variable
address@hidden holds the name of that directory.  @var{emacs}
+is the name of the Emacs executable file, normally just @file{emacs}.
+(When you invoke Emacs from the @file{src} directory where it was
+built without installing it, it will look for the dump file in the
+directory of the executable.)  If you rename or move the dump file to
+a different place, you can use this option to tell Emacs where to find
+that file.
 @end table
 
 @node Command Example
@@ -1034,7 +1049,7 @@ specifies a window 164 columns wide, enough for two 
ordinary width
 windows side by side, and 55 lines tall.
 
   The default frame width is 80 characters and the default height is
-40 lines.  You can omit either the width or the height or both.  If
+36 lines.  You can omit either the width or the height or both.  If
 you start the geometry with an integer, Emacs interprets it as the
 width.  If you start with an @samp{x} followed by an integer, Emacs
 interprets it as the height.  Thus, @samp{81} specifies just the
diff --git a/doc/emacs/commands.texi b/doc/emacs/commands.texi
index a992ded..4773d76 100644
--- a/doc/emacs/commands.texi
+++ b/doc/emacs/commands.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @iftex
diff --git a/doc/emacs/custom.texi b/doc/emacs/custom.texi
index 3dbe8f8..c649c17 100644
--- a/doc/emacs/custom.texi
+++ b/doc/emacs/custom.texi
@@ -1,6 +1,6 @@
 @c -*- coding: utf-8 -*-
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Customization
@@ -32,6 +32,8 @@ Reference Manual}.
                           By changing them, you can redefine keys.
 * Init File::           How to write common customizations in the
                           initialization file.
+* Authentication::      Keeping persistent authentication information.
+
 @end menu
 
 @node Easy Customization
@@ -763,6 +765,8 @@ expects (@pxref{Examining}).
 * Locals::              Per-buffer values of variables.
 * File Variables::      How files can specify variable values.
 * Directory Variables:: How variable values can be specified by directory.
+* Connection Variables:: Variables which are valid for buffers with a
+                           remote default directory.
 @end menu
 
 @node Examining
@@ -1419,6 +1423,52 @@ variables are handled in the same way as unsafe 
file-local variables
 do not visit a file directly but perform work within a directory, such
 as Dired buffers (@pxref{Dired}).
 
address@hidden Connection Variables
address@hidden Per-Connection Local Variables
address@hidden local variables, for all remote connections
address@hidden connection-local variables
address@hidden per-connection local variables
+
+  Most of the variables reflect the situation on the local machine.
+Often, they must use a different value when you operate in buffers
+with a remote default directory.  Think about the shell to be applied
+when calling @code{shell} -- it might be @file{/bin/bash} on your
+local machine, and @file{/bin/ksh} on a remote machine.
+
+  This can be accomplished with @dfn{connection-local variables}.
+Directory and file local variables override connection-local
+variables.  Unsafe connection-local variables are handled in the same
+way as unsafe file-local variables (@pxref{Safe File Variables}).
+
address@hidden connection-local-set-profile-variables
address@hidden connection-local-set-profiles
+  Connection-local variables are declared as a group of
+variables/value pairs in a @dfn{profile}, using the
address@hidden function.  The function
address@hidden activates profiles for a given
+criteria, identifying a remote machine:
+
address@hidden
+(connection-local-set-profile-variables 'remote-ksh
+   '((shell-file-name . "/bin/ksh")
+     (shell-command-switch . "-c")))
+
+(connection-local-set-profile-variables 'remote-bash
+   '((shell-file-name . "/bin/bash")
+     (shell-command-switch . "-c")))
+
+(connection-local-set-profiles
+   '(:application tramp :machine "remotemachine") 'remote-ksh)
address@hidden example
+
+  This code declares two different profiles, @code{remote-ksh} and
address@hidden The profile @code{remote-ksh} is applied to all
+buffers which have a remote default directory matching the regexp
address@hidden"remotemachine} as host name.  Such a criteria can also
+discriminate for the properties @code{:protocol} (this is the Tramp
+method) or @code{:user} (a remote user name).  The @code{nil} criteria
+matches all buffers with a remote default directory.
+
 @node Key Bindings
 @section Customizing Key Bindings
 @cindex key bindings
@@ -2639,3 +2689,40 @@ provided by the Emacs startup, such as 
@code{window-setup-hook} or
 
   For more information on the early init file, @pxref{Init File,,,
 elisp, The Emacs Lisp Reference Manual}.
+
address@hidden Authentication
address@hidden Keeping Persistent Authentication Information
+
+  Some Emacs packages, which connect to other services, require
+authentication (@pxref{Passwords}), e.g., see @ref{Top, Gnus,, gnus, The
+Gnus Manual}, or @ref{Top, Tramp,, tramp, The Tramp Manual}.  Because
+it might be annoying to provide the same user name and password again
+and again, Emacs offers to keep this information persistent via the
address@hidden library.
+
address@hidden @file{~/.authinfo} file
address@hidden @file{~/.authinfo.gpg} file
address@hidden ~/.netrc file
+  By default, the authentication information is taken from the file
address@hidden/.authinfo} or @file{~/.authinfo.gpg} or @file{~/.netrc}.
+These files have a syntax similar to netrc files as known from the
address@hidden program, like this:
+
address@hidden
+machine @var{mymachine} login @var{myloginname} password @var{mypassword} port 
@var{myport}
address@hidden example
+
+  Similarly, the @file{auth-source} library supports multiple storage
+backend, currently either the classic netrc backend, JSON files, the
+Secret Service API, and pass, the standard unix password manager.
+
address@hidden auth-sources
+  All these alternatives can be customized via the user option
address@hidden, see @ref{Help for users, Emacs auth-source,,
+auth, Emacs auth-source}.
+
address@hidden auth-source-save-behavior
+  When a password is entered interactively, which is not found via the
+configured backend, some of the backends offer to save it
+persistently.  This can be changed by customizing the user option
address@hidden
diff --git a/doc/emacs/dired-xtra.texi b/doc/emacs/dired-xtra.texi
index 4412e47..025da21 100644
--- a/doc/emacs/dired-xtra.texi
+++ b/doc/emacs/dired-xtra.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 2004-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 2004-2019 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @c This file is included either in emacs-xtra.texi (when producing the
diff --git a/doc/emacs/dired.texi b/doc/emacs/dired.texi
index 1612fc7..9f454ea 100644
--- a/doc/emacs/dired.texi
+++ b/doc/emacs/dired.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Dired
diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index d9a08b9..f464a3a 100644
--- a/doc/emacs/display.texi
+++ b/doc/emacs/display.texi
@@ -1,6 +1,6 @@
 @c -*- coding: utf-8 -*-
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2019 Free Software
 @c Foundation, Inc.
 
 @c See file emacs.texi for copying conditions.
diff --git a/doc/emacs/emacs-xtra.texi b/doc/emacs/emacs-xtra.texi
index 3c46d72..dcd8fae 100644
--- a/doc/emacs/emacs-xtra.texi
+++ b/doc/emacs/emacs-xtra.texi
@@ -16,7 +16,7 @@
 @copying
 This manual describes specialized features of Emacs.
 
-Copyright @copyright{} 2004--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2004--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi
index b64a59d..58ec373 100644
--- a/doc/emacs/emacs.texi
+++ b/doc/emacs/emacs.texi
@@ -27,7 +27,7 @@ This is the @cite{GNU Emacs Manual},
 @end ifnottex
 updated for Emacs version @value{EMACSVER}.
 
-Copyright @copyright{} 1985--1987, 1993--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1985--1987, 1993--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -1114,6 +1114,7 @@ Customization
                           By changing them, you can redefine keys.
 * Init File::           How to write common customizations in the
                           initialization file.
+* Authentication::      Keeping persistent authentication information.
 
 Easy Customization Interface
 
@@ -1134,6 +1135,8 @@ Variables
 * Locals::              Per-buffer values of variables.
 * File Variables::      How files can specify variable values.
 * Directory Variables:: How variable values can be specified by directory.
+* Connection Variables:: Variables which are valid for buffers with a
+                           remote default directory.
 
 Local Variables in Files
 
@@ -1481,7 +1484,7 @@ Stevens, Andy Stewart, Jonathan Stigelman, Martin 
Stjernholm, Kim F.
 Storm, Steve Strassmann, Christopher Suckling, Olaf Sylvester, Naoto
 Takahashi, Steven Tamm, Jan Tatarik, Luc Teirlinck, Jean-Philippe Theberge, 
Jens
 T. Berger Thielemann, Spencer Thomas, Jim Thompson, Toru Tomabechi,
-David O'Toole, Markus Triska, Tom Tromey, Enami Tsugutomo, Eli
+David O'Toole, Markus Triska, Tom Tromey, Eli
 Tziperman, Daiki Ueno, Masanobu Umeda, Rajesh Vaidheeswarran, Neil
 W. Van Dyke, Didier Verna, Joakim Verona, Ulrik Vieth, Geoffrey
 Voelker, Johan Vromans, Inge Wallin, John Paul Wallington, Colin
diff --git a/doc/emacs/emerge-xtra.texi b/doc/emacs/emerge-xtra.texi
index 1d81712..6c5e46b 100644
--- a/doc/emacs/emerge-xtra.texi
+++ b/doc/emacs/emerge-xtra.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 2004-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 2004-2019 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @c This file is included either in emacs-xtra.texi (when producing the
diff --git a/doc/emacs/entering.texi b/doc/emacs/entering.texi
index 84b3e5d..4362553 100644
--- a/doc/emacs/entering.texi
+++ b/doc/emacs/entering.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 2001-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @iftex
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index b47be51..a574282 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 1999-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 1999-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Files
@@ -1461,26 +1461,19 @@ manipulate and apply parts of patches:
 Move to the next hunk-start (@code{diff-hunk-next}).  With prefix
 argument @var{n}, move forward to the @var{n}th next hunk.
 
address@hidden diff-auto-refine-mode
address@hidden mode, Diff Auto-Refine
address@hidden Diff Auto-Refine mode
-This command has a side effect: it @dfn{refines} the hunk you move to,
-highlighting its changes with better granularity.  To disable this
-feature, type @kbd{M-x diff-auto-refine-mode} to toggle off the minor
-mode Diff Auto-Refine mode.  To disable Diff Auto-Refine mode by
-default, add this to your init file (@pxref{Hooks}):
-
address@hidden
-(add-hook 'diff-mode-hook
-          (lambda () (diff-auto-refine-mode -1)))
address@hidden example
address@hidden diff-refine
+By default, Diff mode @dfn{refines} hunks as Emacs displays them,
+highlighting their changes with better granularity.  Alternatively, if
+you set @code{diff-refine} to the symbol @code{navigation}, Diff mode
+only refines the hunk you move to with this command or with
address@hidden
 
 @item M-p
 @findex diff-hunk-prev
 Move to the previous hunk-start (@code{diff-hunk-prev}).  With prefix
 argument @var{n}, move back to the @var{n}th previous hunk.  Like
address@hidden, this has the side-effect of refining the hunk you move to,
-unless you disable Diff Auto-Refine mode.
address@hidden, this command refines the hunk you move to if you set
address@hidden to the symbol @code{navigation}.
 
 @item address@hidden
 @findex diff-file-next
@@ -1518,6 +1511,11 @@ Highlight the changes of the hunk at point with a finer 
granularity
 (@code{diff-refine-hunk}).  This allows you to see exactly which parts
 of each changed line were actually changed.
 
address@hidden diff-refine
+By default, Diff mode refines hunks as Emacs displays them, so you may
+find this command useful if you customize @code{diff-refine} to a
+non-default value.
+
 @item C-c C-c
 @findex diff-goto-source
 @vindex diff-jump-to-old-file
@@ -1617,6 +1615,10 @@ displayed in the echo area).  With a prefix argument, it 
tries to
 modify the original (``old'') source files rather than the patched
 (``new'') source files.
 
address@hidden diff-font-lock-syntax
+  If address@hidden, fragments of source in hunks are highlighted
+according to the appropriate major mode.
+
 @node Copying and Naming
 @section Copying, Naming and Renaming Files
 
diff --git a/doc/emacs/fixit.texi b/doc/emacs/fixit.texi
index 8277278..fc61058 100644
--- a/doc/emacs/fixit.texi
+++ b/doc/emacs/fixit.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Fixit
diff --git a/doc/emacs/fortran-xtra.texi b/doc/emacs/fortran-xtra.texi
index fa5a3e6..30f7c42 100644
--- a/doc/emacs/fortran-xtra.texi
+++ b/doc/emacs/fortran-xtra.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 2004-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 2004-2019 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @c This file is included either in emacs-xtra.texi (when producing the
diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi
index 6bbaae2..6001096 100644
--- a/doc/emacs/frames.texi
+++ b/doc/emacs/frames.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 1999-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 1999-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Frames
@@ -899,6 +899,16 @@ input stream for each server.  Each server also has its 
own selected
 frame.  The commands you enter with a particular X server apply to
 that server's selected frame.
 
+  On multi-monitor displays it is possible to use the command
address@hidden:
+
address@hidden make-frame-on-monitor
address@hidden @kbd
address@hidden M-x make-frame-on-monitor @key{RET} @var{monitor} @key{RET}
+Create a new frame on monitor @var{monitor} whose screen area is
+a part of the current display.
address@hidden table
+
 @node Frame Parameters
 @section Frame Parameters
 @vindex default-frame-alist
diff --git a/doc/emacs/glossary.texi b/doc/emacs/glossary.texi
index 0293967..ad16d72 100644
--- a/doc/emacs/glossary.texi
+++ b/doc/emacs/glossary.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Glossary
diff --git a/doc/emacs/gnu.texi b/doc/emacs/gnu.texi
index 4a42a64..fef4f71 100644
--- a/doc/emacs/gnu.texi
+++ b/doc/emacs/gnu.texi
@@ -1,4 +1,4 @@
address@hidden Copyright (C) 1985-1987, 1993, 1995, 2001-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993, 1995, 2001-2019 Free Software
 @c Foundation, Inc.
 @c
 @c Permission is granted to anyone to make or distribute verbatim copies
diff --git a/doc/emacs/help.texi b/doc/emacs/help.texi
index 66673eb..4851659 100644
--- a/doc/emacs/help.texi
+++ b/doc/emacs/help.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Help
diff --git a/doc/emacs/indent.texi b/doc/emacs/indent.texi
index bf43909..5f40acb 100644
--- a/doc/emacs/indent.texi
+++ b/doc/emacs/indent.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Indentation
@@ -110,6 +110,10 @@ parentheses, or if the junction follows another newline.
 If there is a fill prefix, @kbd{M-^} deletes the fill prefix if it
 appears after the newline that is deleted.  @xref{Fill Prefix}.
 
+With a prefix argument, join the current line line to the following
+line.  If the region is active, and no prefix argument is given, join
+all lines in the region instead.
+
 @item C-M-\
 @kindex C-M-\
 @findex indent-region
diff --git a/doc/emacs/killing.texi b/doc/emacs/killing.texi
index 4c47c8b..2d56f1d 100644
--- a/doc/emacs/killing.texi
+++ b/doc/emacs/killing.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 
diff --git a/doc/emacs/kmacro.texi b/doc/emacs/kmacro.texi
index 0151c81..65387ae 100644
--- a/doc/emacs/kmacro.texi
+++ b/doc/emacs/kmacro.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Keyboard Macros
@@ -241,10 +241,17 @@ determined by the customizable variable 
@code{kmacro-ring-max}.
 @section The Keyboard Macro Counter
 
   Each keyboard macro has an associated counter, which is initialized
-to 0 when you start defining the macro.  This counter allows you to
-insert a number into the buffer that depends on the number of times
-the macro has been called.  The counter is incremented each time its
-value is inserted into the buffer.
+to 0 when you start defining the macro.  This @dfn{current counter}
+allows you to insert a number into the buffer that depends on the
+number of times the macro has been called.  The counter is normally
+incremented each time its value is inserted into the buffer.
+
+In addition to the current counter, keyboard macros also maintain the
address@hidden counter}, which records the value the current counter
+had last time it was incremented or set.  Note that incrementing the
+current counter by zero, e.g., with @address@hidden 0 C-x C-k C-i}}, also
+records the value of the current counter as the previous counter
+value.
 
 @table @kbd
 @item @key{F3}
@@ -270,8 +277,8 @@ value of the keyboard macro's counter into the buffer, and 
increments
 the counter by 1.  (If you are not defining a macro, @key{F3} begins a
 macro definition instead.  @xref{Basic Keyboard Macro}.)  You can use
 a numeric prefix argument to specify a different increment.  If you
-just specify a @kbd{C-u} prefix, that is the same as an increment of
-zero: it inserts the current counter value without changing it.
+just specify a @kbd{C-u} prefix, that inserts the previous counter
+value, and doesn't change the current value.
 
   As an example, let us show how the keyboard macro counter can be
 used to build a numbered list.  Consider the following key sequence:
diff --git a/doc/emacs/m-x.texi b/doc/emacs/m-x.texi
index adf46ff..2b2be38 100644
--- a/doc/emacs/m-x.texi
+++ b/doc/emacs/m-x.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node M-x
diff --git a/doc/emacs/macos.texi b/doc/emacs/macos.texi
index 34b645d..d992095 100644
--- a/doc/emacs/macos.texi
+++ b/doc/emacs/macos.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 2000-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 2000-2019 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Mac OS / GNUstep
 @appendix Emacs and macOS / GNUstep
@@ -170,8 +170,25 @@ the requested line (@code{ns-open-file-select-line}).
 This event occurs when a user drags an object from another application
 into an Emacs frame.  The default behavior is to open a file in the
 window under the mouse, or to insert text at point of the window under
-the mouse.  It may sometimes be necessary to use the @key{Meta} key in
-conjunction with dragging to force text insertion.
+the mouse.
+
+The sending application has some limited ability to decide how Emacs
+handles the sent object, but the user may override the default
+behaviour by holding one or more modifier key.
+
address@hidden @kbd
address@hidden control
+Insert as text in the current buffer.  If the object is a file, this
+will insert the filename.
address@hidden alt/option
+Attempt to open the object as though it is a file or URL.
address@hidden super/command
+Perform the default action for the type.  This can be useful when an
+application is overriding the default behaviour.
address@hidden table
+
+The modifier keys listed above are defined by macOS and are unaffected
+by user changes to the modifiers in Emacs.
 
 @item ns-change-font
 This event occurs when the user selects a font in a Nextstep font
diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi
index 4527c23..4986c11 100644
--- a/doc/emacs/maintaining.texi
+++ b/doc/emacs/maintaining.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual., Abbrevs, This is part of the Emacs 
manual., Top
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 1999-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 1999-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Maintaining
@@ -831,6 +831,14 @@ working tree containing the current VC fileset).  If you 
invoke this
 command from a Dired buffer, it applies to the working tree containing
 the directory.
 
address@hidden vc-root-version-diff
address@hidden C-u C-x v D
+  To compare two arbitrary revisions of the whole trees, call
address@hidden with a prefix argument: @kbd{C-u C-x v D}.  This
+prompts for two revision IDs (@pxref{VCS Concepts}), and displays a
+diff between those versions of the entire version-controlled directory
+trees (RCS, SCCS, CVS, and SRC do not support this feature).
+
 @vindex vc-diff-switches
   You can customize the @command{diff} options that @kbd{C-x v =} and
 @kbd{C-x v D} use for generating diffs.  The options used are taken
@@ -963,6 +971,7 @@ and the maximum number of revisions to display.
 Directory Mode}) or a Dired buffer (@pxref{Dired}), it applies to the
 file listed on the current line.
 
address@hidden C-x v L
 @findex vc-print-root-log
 @findex log-view-toggle-entry-display
   @kbd{C-x v L} (@code{vc-print-root-log}) displays a
@@ -1084,8 +1093,7 @@ started editing, and asks for confirmation for discarding 
the changes.
 If you agree, the fileset is reverted.  If you don't want @kbd{C-x v
 u} to show a diff, set the variable @code{vc-revert-show-diff} to
 @code{nil} (you can still view the diff directly with @kbd{C-x v =};
address@hidden Revisions}).  Note that @kbd{C-x v u} cannot be reversed
-with the usual undo commands (@pxref{Undo}), so use it with care.
address@hidden Revisions}).
 
   On locking-based version control systems, @kbd{C-x v u} leaves files
 unlocked; you must lock again to resume editing.  You can also use
@@ -1981,7 +1989,7 @@ table.
 @item M-x tags-query-replace @key{RET} @var{regexp} @key{RET} 
@var{replacement} @key{RET}
 Perform a @code{query-replace-regexp} on each file in the selected tags table.
 
address@hidden M-x multifile-continue
address@hidden M-x fileloop-continue
 Restart one of the last 2 commands above, from the current location of point.
 @end table
 
@@ -2017,9 +2025,9 @@ you can follow its progress.  As soon as it finds an 
occurrence,
 @code{tags-search} returns.  This command requires tags tables to be
 available (@pxref{Tags Tables}).
 
address@hidden multifile-continue
address@hidden fileloop-continue
   Having found one match with @code{tags-search}, you probably want to
-find all the rest.  @kbd{M-x multifile-continue} resumes the
+find all the rest.  @kbd{M-x fileloop-continue} resumes the
 @code{tags-search}, finding one more match.  This searches the rest of
 the current buffer, followed by the remaining files of the tags table.
 
@@ -2042,10 +2050,10 @@ default is to use the same setting as the value of
 single invocation of @kbd{M-x tags-query-replace}.  But often it is
 useful to exit temporarily, which you can do with any input event that
 has no special query replace meaning.  You can resume the query
-replace subsequently by typing @kbd{M-x multifile-continue}; this
+replace subsequently by typing @kbd{M-x fileloop-continue}; this
 command resumes the last tags search or replace command that you did.
 For instance, to skip the rest of the current file, you can type
address@hidden@kbd{M-> M-x multifile-continue}}.
address@hidden@kbd{M-> M-x fileloop-continue}}.
 
   Note that the commands described above carry out much broader
 searches than the @code{xref-find-definitions} family.  The
diff --git a/doc/emacs/mark.texi b/doc/emacs/mark.texi
index 626f9dd..5ffe726 100644
--- a/doc/emacs/mark.texi
+++ b/doc/emacs/mark.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Mark
@@ -76,7 +76,7 @@ Set point and the mark around the text you drag across.
 @item mouse-3
 Set the mark at point, then move point to where you click
 (@code{mouse-save-then-kill}).
address@hidden @samp{Shifted cursor motion keys}
address@hidden @r{Shifted cursor motion keys}
 Set the mark at point if the mark is inactive, then move point.
 @xref{Shift Selection}.
 @end table
diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi
index 6fc2890..820d3ba 100644
--- a/doc/emacs/mini.texi
+++ b/doc/emacs/mini.texi
@@ -1,6 +1,6 @@
 @c -*- coding: utf-8 -*-
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Minibuffer
diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index ab33caf..7d7065a 100644
--- a/doc/emacs/misc.texi
+++ b/doc/emacs/misc.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @iftex
@@ -795,6 +795,10 @@ to @command{gpg}.  This will output the list of keys to the
 name is relative, Emacs searches the directories listed in
 @code{exec-path} (@pxref{Shell}).
 
+  If the default directory is remote (@pxref{Remote Files}), the
+default value is @file{/bin/sh}.  This can be changed by declaring
address@hidden connection-local (@pxref{Connection Variables}).
+
   To specify a coding system for @kbd{M-!} or @kbd{M-|}, use the command
 @kbd{C-x @key{RET} c} immediately beforehand.  @xref{Communication Coding}.
 
@@ -1693,7 +1697,9 @@ each one a unique @dfn{server name}, using the variable
 @code{server-name}.  For example, @kbd{M-x set-variable @key{RET}
 server-name @key{RET} "foo" @key{RET}} sets the server name to
 @samp{foo}.  The @code{emacsclient} program can specify a server by
-name, using the @samp{-s} option (@pxref{emacsclient Options}).
+name, using the @samp{-s} or the @samp{-f} option (@pxref{emacsclient
+Options}), depending on whether or not the server uses a TCP socket
+(@pxref{TCP Emacs server}).
 
   If you want to run multiple Emacs daemons (@pxref{Initial Options}),
 you can give each daemon its own server name like this:
@@ -1758,21 +1764,23 @@ use @kbd{M-x server-generate-key} to get a random key.
   When you start a TCP Emacs server, Emacs creates a @dfn{server file}
 containing the TCP information to be used by @command{emacsclient} to
 connect to the server.  The variable @code{server-auth-dir} specifies
-the directory containing the server file; by default, this is
+the default directory containing the server file; by default, this is
 @file{~/.emacs.d/server/}.  In the absence of a local socket with file
 permissions, the permissions of this directory determine which users
 can have their @command{emacsclient} processes talk to the Emacs
-server.
+server.  If @code{server-name} is an absolute file name, the server
+file is created where specified by that file name.
 
 @vindex address@hidden, environment variable}
   To tell @command{emacsclient} to connect to the server over TCP with
 a specific server file, use the @samp{-f} or @samp{--server-file}
 option, or set the @env{EMACS_SERVER_FILE} environment variable
 (@pxref{emacsclient Options}).  If @code{server-auth-dir} is set to a
-non-standard value, @command{emacsclient} needs an absolute file name
-to the server file, as the default @code{server-auth-dir} is
-hard-coded in @command{emacsclient} to be used as the directory for
-resolving relative filenames.
+non-standard value, or if @code{server-name} is set to an absolute
+file name, @command{emacsclient} needs an absolute file name to the
+server file, as the default @code{server-auth-dir} is hard-coded in
address@hidden to be used as the directory for resolving
+relative filenames.
 
 @node Invoking emacsclient
 @subsection Invoking @code{emacsclient}
@@ -1961,10 +1969,13 @@ evaluation performed is for side-effect rather than 
result.
 
 @item -s @var{server-name}
 @itemx address@hidden
-Connect to the Emacs server named @var{server-name}.  The server name
-is given by the variable @code{server-name} on the Emacs server.  If
-this option is omitted, @command{emacsclient} connects to the first
-server it finds.  (This option is not supported on MS-Windows.)
+Connect to the Emacs server named @var{server-name}.  (This option is
+not supported on MS-Windows.)  The server name is given by the
+variable @code{server-name} on the Emacs server.  If this option is
+omitted, @command{emacsclient} connects to the first server it finds.
+If you set @code{server-name} of the Emacs server to an absolute file
+name, give the same absolute file name as @var{server-name} to this
+option to instruct @command{emacsclient} to connect to that server.
 
 Alternatively, you can set the @env{EMACS_SOCKET_NAME} environment
 variable to point to the server socket.  (The command-line option
diff --git a/doc/emacs/modes.texi b/doc/emacs/modes.texi
index 2bbc17b..4505bb5 100644
--- a/doc/emacs/modes.texi
+++ b/doc/emacs/modes.texi
@@ -1,6 +1,6 @@
 @c -*- coding: utf-8 -*-
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Modes
diff --git a/doc/emacs/msdos-xtra.texi b/doc/emacs/msdos-xtra.texi
index 64ce841..e0d3bcd 100644
--- a/doc/emacs/msdos-xtra.texi
+++ b/doc/emacs/msdos-xtra.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 2004-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 2004-2019 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @c This file is included either in emacs-xtra.texi (when producing the
diff --git a/doc/emacs/msdos.texi b/doc/emacs/msdos.texi
index c69c7d3..9fc4b62 100644
--- a/doc/emacs/msdos.texi
+++ b/doc/emacs/msdos.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Microsoft Windows
diff --git a/doc/emacs/mule.texi b/doc/emacs/mule.texi
index 6c0c5b2..6a26667 100644
--- a/doc/emacs/mule.texi
+++ b/doc/emacs/mule.texi
@@ -1,6 +1,6 @@
 @c -*- coding: utf-8 -*-
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1997, 1999-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 1997, 1999-2019 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node International
 @chapter International Character Set Support
@@ -397,7 +397,7 @@ messages.  But if your locale matches an entry in the 
variable
 coding system instead.  For example, if the locale @samp{ja_JP.PCK}
 matches @code{japanese-shift-jis} in
 @code{locale-preferred-coding-systems}, Emacs uses that encoding even
-though it might normally use @code{japanese-iso-8bit}.
+though it might normally use @code{utf-8}.
 
   You can override the language environment chosen at startup with
 explicit use of the command @code{set-language-environment}, or with
diff --git a/doc/emacs/package.texi b/doc/emacs/package.texi
index 43f5a84..26e6424 100644
--- a/doc/emacs/package.texi
+++ b/doc/emacs/package.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Packages
diff --git a/doc/emacs/picture-xtra.texi b/doc/emacs/picture-xtra.texi
index 9ebc78e..704cff1 100644
--- a/doc/emacs/picture-xtra.texi
+++ b/doc/emacs/picture-xtra.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 2004-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 2004-2019 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @c This file is included either in emacs-xtra.texi (when producing the
diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi
index cfeb61e..c1ad5b5 100644
--- a/doc/emacs/programs.texi
+++ b/doc/emacs/programs.texi
@@ -1,6 +1,6 @@
 @c -*- coding: utf-8 -*-
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 1999-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 1999-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Programs
diff --git a/doc/emacs/regs.texi b/doc/emacs/regs.texi
index 98eed06..1881b49 100644
--- a/doc/emacs/regs.texi
+++ b/doc/emacs/regs.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Registers
diff --git a/doc/emacs/rmail.texi b/doc/emacs/rmail.texi
index c975b58..4901ca9 100644
--- a/doc/emacs/rmail.texi
+++ b/doc/emacs/rmail.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Rmail
diff --git a/doc/emacs/screen.texi b/doc/emacs/screen.texi
index 8f2be4b..67da9da 100644
--- a/doc/emacs/screen.texi
+++ b/doc/emacs/screen.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Screen
diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi
index 8ea80cb..a1c987c 100644
--- a/doc/emacs/search.texi
+++ b/doc/emacs/search.texi
@@ -1,6 +1,6 @@
 @c -*- coding: utf-8 -*-
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Search
@@ -684,6 +684,8 @@ matching}) has no effect on them.
 @kindex M-s M-w
 @findex eww-search-words
 @vindex eww-search-prefix
address@hidden Internet search
address@hidden search Internet for keywords
   To search the Web for the text in region, type @kbd{M-s M-w}.  This
 command performs an Internet search for the words in region using the
 search engine whose @acronym{URL} is specified by the variable
@@ -972,11 +974,10 @@ character class inside a character alternative.  For 
instance,
 elisp, The Emacs Lisp Reference Manual}, for a list of character
 classes.
 
-To include a @samp{]} in a character set, you must make it the first
-character.  For example, @samp{[]a]} matches @samp{]} or @samp{a}.  To
-include a @samp{-}, write @samp{-} as the first or last character of the
-set, or put it after a range.  Thus, @samp{[]-]} matches both @samp{]}
-and @samp{-}.
+To include a @samp{]} in a character set, you must make it the first character.
+For example, @samp{[]a]} matches @samp{]} or @samp{a}.  To include a @samp{-},
+write @samp{-} as the last character of the set, tho you can also put it first
+or after a range.  Thus, @samp{[]-]} matches both @samp{]} and @samp{-}.
 
 To include @samp{^} in a set, put it anywhere but at the beginning of
 the set.  (At the beginning, it complements the set---see below.)
@@ -1872,11 +1873,13 @@ region instead.
 @findex flush-lines
 @item M-x flush-lines
 Prompt for a regexp, and delete each line that contains a match for
-it, operating on the text after point.  This command deletes the
-current line if it contains a match starting after point.  If the
-region is active, it operates on the region instead; if a line
-partially contained in the region contains a match entirely contained
-in the region, it is deleted.
+it, operating on the text after point.  When the command finishes,
+it prints the number of deleted matching lines.
+
+This command deletes the current line if it contains a match starting
+after point.  If the region is active, it operates on the region
+instead; if a line partially contained in the region contains a match
+entirely contained in the region, it is deleted.
 
 If a match is split across lines, @code{flush-lines} deletes all those
 lines.  It deletes the lines before starting to look for the next
diff --git a/doc/emacs/sending.texi b/doc/emacs/sending.texi
index 00b3c4d..c6b8912 100644
--- a/doc/emacs/sending.texi
+++ b/doc/emacs/sending.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Sending Mail
diff --git a/doc/emacs/text.texi b/doc/emacs/text.texi
index 1e96163..9649278 100644
--- a/doc/emacs/text.texi
+++ b/doc/emacs/text.texi
@@ -1,6 +1,6 @@
 @c -*- coding: utf-8 -*-
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Text
diff --git a/doc/emacs/trouble.texi b/doc/emacs/trouble.texi
index bb05378..2fe5487 100644
--- a/doc/emacs/trouble.texi
+++ b/doc/emacs/trouble.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @iftex
@@ -1400,9 +1400,10 @@ to the address@hidden  For the reasons behind this, see
 @url{https://www.gnu.org/licenses/why-assign.html}.
 
 Copyright assignment is a simple process.  Residents of some countries
-can do it entirely electronically.  We can help you get started, and
-answer any questions you may have (or point you to the people with the
-answers), at the @email{emacs-devel@@gnu.org} mailing list.
+can do it entirely electronically.  We can help you get started,
+including sending you the forms you should fill, and answer any
+questions you may have (or point you to the people with the answers),
+at the @email{emacs-devel@@gnu.org} mailing list.
 
 (Please note: general discussion about why some GNU projects ask
 for a copyright assignment is off-topic for emacs-devel.
diff --git a/doc/emacs/vc-xtra.texi b/doc/emacs/vc-xtra.texi
index 17d6a3b..ca919e8 100644
--- a/doc/emacs/vc-xtra.texi
+++ b/doc/emacs/vc-xtra.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 2004-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 2004-2019 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @c This file is included in emacs-xtra.texi when producing the printed
diff --git a/doc/emacs/vc1-xtra.texi b/doc/emacs/vc1-xtra.texi
index 35dd6d1..1c17695 100644
--- a/doc/emacs/vc1-xtra.texi
+++ b/doc/emacs/vc1-xtra.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 2004-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 2004-2019 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @c
 @c This file is included either in vc-xtra.texi (when producing the
diff --git a/doc/emacs/windows.texi b/doc/emacs/windows.texi
index 93a68e9..ece5313 100644
--- a/doc/emacs/windows.texi
+++ b/doc/emacs/windows.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2018 Free Software
address@hidden Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Windows
@@ -262,6 +262,8 @@ Delete all windows in the selected frame except the 
selected window
 Delete the selected window and kill the buffer that was showing in it
 (@code{kill-buffer-and-window}).  The last character in this key
 sequence is a zero.
address@hidden M-x delete-windows-on @key{RET} @var{buffer} @key{RET}
+Delete windows showing the specified @var{buffer}.
 @item C-x ^
 Make selected window taller (@code{enlarge-window}).
 @item C-x @}
@@ -297,6 +299,11 @@ selected window.
 whole frame.  (This command cannot be used while the minibuffer window
 is active; attempting to do so signals an error.)
 
+  @kbd{M-x delete-windows-on} deletes windows that show a specific
+buffer.  It prompts for the buffer, defaulting to the current buffer.
+With prefix argument of zero, @kbd{C-u 0}, this command deletes
+windows only on the current display's frames.
+
 @cindex resize window
 @cindex resizing windows
 @kindex C-x ^
diff --git a/doc/emacs/xresources.texi b/doc/emacs/xresources.texi
index 903090f..d8b70ef 100644
--- a/doc/emacs/xresources.texi
+++ b/doc/emacs/xresources.texi
@@ -1,5 +1,5 @@
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 1987, 1993-1995, 1997, 2001-2018 Free Software
address@hidden Copyright (C) 1987, 1993-1995, 1997, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node X Resources
diff --git a/doc/lispintro/ChangeLog.1 b/doc/lispintro/ChangeLog.1
index 9e15544..2df76f4 100644
--- a/doc/lispintro/ChangeLog.1
+++ b/doc/lispintro/ChangeLog.1
@@ -782,7 +782,7 @@
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/doc/lispintro/Makefile.in b/doc/lispintro/Makefile.in
index e2a1229..37fffb8 100644
--- a/doc/lispintro/Makefile.in
+++ b/doc/lispintro/Makefile.in
@@ -1,6 +1,6 @@
 ### @configure_input@
 
-# Copyright (C) 1994-1999, 2001-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994-1999, 2001-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
diff --git a/doc/lispintro/README b/doc/lispintro/README
index c39f6d2..fd4ede1 100644
--- a/doc/lispintro/README
+++ b/doc/lispintro/README
@@ -1,4 +1,4 @@
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 
diff --git a/doc/lispintro/cons-1.eps b/doc/lispintro/cons-1.eps
index cc1d5c7..dff7130 100644
--- a/doc/lispintro/cons-1.eps
+++ b/doc/lispintro/cons-1.eps
@@ -4,7 +4,7 @@
 %%CreationDate: Wed Mar  8 14:26:58 1995
 %%Creator: Tgif-2.16-p4 by William Chia-Wei Cheng (address@hidden)
 
-% Copyright (C) 1995, 1997, 2001-2018 Free Software Foundation, Inc.
+% Copyright (C) 1995, 1997, 2001-2019 Free Software Foundation, Inc.
 %
 % This file is part of GNU Emacs.
 %
diff --git a/doc/lispintro/cons-2.eps b/doc/lispintro/cons-2.eps
index 00d08e4..ccba320 100644
--- a/doc/lispintro/cons-2.eps
+++ b/doc/lispintro/cons-2.eps
@@ -4,7 +4,7 @@
 %%CreationDate: Wed Mar  8 14:26:39 1995
 %%Creator: Tgif-2.16-p4 by William Chia-Wei Cheng (address@hidden)
 
-% Copyright (C) 1995, 1997, 2001-2018 Free Software Foundation, Inc.
+% Copyright (C) 1995, 1997, 2001-2019 Free Software Foundation, Inc.
 %
 % This file is part of GNU Emacs.
 %
diff --git a/doc/lispintro/cons-2a.eps b/doc/lispintro/cons-2a.eps
index 26f690a..3beaa5b 100644
--- a/doc/lispintro/cons-2a.eps
+++ b/doc/lispintro/cons-2a.eps
@@ -4,7 +4,7 @@
 %%CreationDate: Tue Mar 14 15:09:30 1995
 %%Creator: Tgif-2.16-p4 by William Chia-Wei Cheng (address@hidden)
 
-% Copyright (C) 1995, 1997, 2001-2018 Free Software Foundation, Inc.
+% Copyright (C) 1995, 1997, 2001-2019 Free Software Foundation, Inc.
 %
 % This file is part of GNU Emacs.
 %
diff --git a/doc/lispintro/cons-3.eps b/doc/lispintro/cons-3.eps
index d75620e..6bae8f7 100644
--- a/doc/lispintro/cons-3.eps
+++ b/doc/lispintro/cons-3.eps
@@ -4,7 +4,7 @@
 %%CreationDate: Wed Mar  8 14:25:41 1995
 %%Creator: Tgif-2.16-p4 by William Chia-Wei Cheng (address@hidden)
 
-% Copyright (C) 1995, 1997, 2001-2018 Free Software Foundation, Inc.
+% Copyright (C) 1995, 1997, 2001-2019 Free Software Foundation, Inc.
 %
 % This file is part of GNU Emacs.
 %
diff --git a/doc/lispintro/cons-4.eps b/doc/lispintro/cons-4.eps
index 154df88..fd056b5 100644
--- a/doc/lispintro/cons-4.eps
+++ b/doc/lispintro/cons-4.eps
@@ -4,7 +4,7 @@
 %%CreationDate: Wed Mar  8 14:25:06 1995
 %%Creator: Tgif-2.16-p4 by William Chia-Wei Cheng (address@hidden)
 
-% Copyright (C) 1995, 1997, 2001-2018 Free Software Foundation, Inc.
+% Copyright (C) 1995, 1997, 2001-2019 Free Software Foundation, Inc.
 %
 % This file is part of GNU Emacs.
 %
diff --git a/doc/lispintro/cons-5.eps b/doc/lispintro/cons-5.eps
index d5c08ac..d3f7581 100644
--- a/doc/lispintro/cons-5.eps
+++ b/doc/lispintro/cons-5.eps
@@ -4,7 +4,7 @@
 %%CreationDate: Wed Mar  8 14:27:28 1995
 %%Creator: Tgif-2.16-p4 by William Chia-Wei Cheng (address@hidden)
 
-% Copyright (C) 1995, 1997, 2001-2018 Free Software Foundation, Inc.
+% Copyright (C) 1995, 1997, 2001-2019 Free Software Foundation, Inc.
 %
 % This file is part of GNU Emacs.
 %
diff --git a/doc/lispintro/drawers.eps b/doc/lispintro/drawers.eps
index e3a7f0a..4569b21 100644
--- a/doc/lispintro/drawers.eps
+++ b/doc/lispintro/drawers.eps
@@ -9,7 +9,7 @@
 %%EndComments
 %%BeginProlog
 
-% Copyright (C) 2001-2018 Free Software Foundation, Inc.
+% Copyright (C) 2001-2019 Free Software Foundation, Inc.
 %
 % This file is part of GNU Emacs.
 %
diff --git a/doc/lispintro/emacs-lisp-intro.texi 
b/doc/lispintro/emacs-lisp-intro.texi
index 0b0c0a1..519decb 100644
--- a/doc/lispintro/emacs-lisp-intro.texi
+++ b/doc/lispintro/emacs-lisp-intro.texi
@@ -113,7 +113,7 @@ Edition @value{edition-number}, @value{update-date}
 Distributed with Emacs version @value{EMACSVER}.
 @end ifnottex
 @sp 1
-Copyright @copyright{} 1990--1995, 1997, 2001--2018 Free Software
+Copyright @copyright{} 1990--1995, 1997, 2001--2019 Free Software
 Foundation, Inc.
 @sp 1
 
@@ -4636,7 +4636,7 @@ languages, not just Lisp, and C, and it works with 
non-programming
 text as well.  For example, @code{xref-find-definitions} will jump to
 the various nodes in the Texinfo source file of this document
 (provided that you've run the @command{etags} utility to record all
-the nodes in the manuals that come with Emacs; @pxref{Create tags
+the nodes in the manuals that come with Emacs; @pxref{Create Tags
 Table,,, emacs, The GNU Emacs Manual}).
 
 To use the @code{xref-find-definitions} command, type @kbd{M-.}
@@ -14825,7 +14825,7 @@ According to its documentation as shown by @kbd{C-h f} 
(the
 @code{describe-function} command), the @code{find-file-noselect}
 function reads the named file into a buffer and returns the buffer.
 (Its most recent version includes an optional @var{wildcards} argument,
-too, as well as another to read a file literally and an other you
+too, as well as another to read a file literally and another to
 suppress warning messages.  These optional arguments are irrelevant.)
 
 However, the @code{find-file-noselect} function does not select the
@@ -15599,7 +15599,7 @@ like this:
    (recursive-lengths-list-many-files
     (files-in-below-directory "/usr/local/src/emacs/lisp/"))
    '<)
-  (insert (format "%s" (current-time-string))))
+  (insert (current-time-string)))
 @end ignore
 
 @node Counting function definitions
diff --git a/doc/lispintro/lambda-1.eps b/doc/lispintro/lambda-1.eps
index 4b6d827..a78a60c 100644
--- a/doc/lispintro/lambda-1.eps
+++ b/doc/lispintro/lambda-1.eps
@@ -4,7 +4,7 @@
 %%CreationDate: Wed Mar  8 14:31:53 1995
 %%Creator: Tgif-2.16-p4 by William Chia-Wei Cheng (address@hidden)
 
-% Copyright (C) 1995, 1997, 2001-2018 Free Software Foundation, Inc.
+% Copyright (C) 1995, 1997, 2001-2019 Free Software Foundation, Inc.
 %
 % This file is part of GNU Emacs.
 %
diff --git a/doc/lispintro/lambda-2.eps b/doc/lispintro/lambda-2.eps
index 473785c..a7c2e7b 100644
--- a/doc/lispintro/lambda-2.eps
+++ b/doc/lispintro/lambda-2.eps
@@ -4,7 +4,7 @@
 %%CreationDate: Wed Mar  8 14:33:09 1995
 %%Creator: Tgif-2.16-p4 by William Chia-Wei Cheng (address@hidden)
 
-% Copyright (C) 1995, 1997, 2001-2018 Free Software Foundation, Inc.
+% Copyright (C) 1995, 1997, 2001-2019 Free Software Foundation, Inc.
 %
 % This file is part of GNU Emacs.
 %
diff --git a/doc/lispintro/lambda-3.eps b/doc/lispintro/lambda-3.eps
index c1a2516..d73a9d6 100644
--- a/doc/lispintro/lambda-3.eps
+++ b/doc/lispintro/lambda-3.eps
@@ -4,7 +4,7 @@
 %%CreationDate: Wed Mar  8 14:33:49 1995
 %%Creator: Tgif-2.16-p4 by William Chia-Wei Cheng (address@hidden)
 
-% Copyright (C) 1995, 1997, 2001-2018 Free Software Foundation, Inc.
+% Copyright (C) 1995, 1997, 2001-2019 Free Software Foundation, Inc.
 %
 % This file is part of GNU Emacs.
 %
diff --git a/doc/lispref/ChangeLog.1 b/doc/lispref/ChangeLog.1
index 42240ae..a271d21 100644
--- a/doc/lispref/ChangeLog.1
+++ b/doc/lispref/ChangeLog.1
@@ -13989,7 +13989,7 @@
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 1998-2018 Free Software Foundation, Inc.
+  Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/doc/lispref/Makefile.in b/doc/lispref/Makefile.in
index 221f4f9..5de04a7 100644
--- a/doc/lispref/Makefile.in
+++ b/doc/lispref/Makefile.in
@@ -1,6 +1,6 @@
 ### @configure_input@
 
-# Copyright (C) 1990-1996, 1998-2018 Free Software Foundation, Inc.
+# Copyright (C) 1990-1996, 1998-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
diff --git a/doc/lispref/README b/doc/lispref/README
index cca4338..3e121bf 100644
--- a/doc/lispref/README
+++ b/doc/lispref/README
@@ -1,4 +1,4 @@
-Copyright (C) 2001-2018 Free Software Foundation, Inc.  -*- outline -*-
+Copyright (C) 2001-2019 Free Software Foundation, Inc.  -*- outline -*-
 See the end of the file for license conditions.
 
 
diff --git a/doc/lispref/abbrevs.texi b/doc/lispref/abbrevs.texi
index 1e9471b..b67c014 100644
--- a/doc/lispref/abbrevs.texi
+++ b/doc/lispref/abbrevs.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1994, 1999, 2001-2018 Free Software 
Foundation,
address@hidden Copyright (C) 1990-1994, 1999, 2001-2019 Free Software 
Foundation,
 @c Inc.
 @c See the file elisp.texi for copying conditions.
 @node Abbrevs
@@ -473,7 +473,7 @@ Set the property @var{prop} of abbrev table @var{table} to 
value @var{val}.
 
 @defun abbrev-table-get table prop
 Return the property @var{prop} of abbrev table @var{table}, or @code{nil}
-if the abbrev has no such property.
+if @var{table} has no such property.
 @end defun
 
 The following properties have special meaning:
diff --git a/doc/lispref/anti.texi b/doc/lispref/anti.texi
index 556203b..6066e26 100644
--- a/doc/lispref/anti.texi
+++ b/doc/lispref/anti.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1999, 2002-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 1999, 2002-2019 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 
 @c This node must have no pointers.
diff --git a/doc/lispref/back.texi b/doc/lispref/back.texi
index df39479..c4c3466 100644
--- a/doc/lispref/back.texi
+++ b/doc/lispref/back.texi
@@ -1,6 +1,6 @@
 \input texinfo  @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 2001-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 2001-2019 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @c
 @c %**start of header
diff --git a/doc/lispref/backups.texi b/doc/lispref/backups.texi
index 8ce8f61..6a5b6d1 100644
--- a/doc/lispref/backups.texi
+++ b/doc/lispref/backups.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1999, 2001-2018 Free Software 
Foundation,
address@hidden Copyright (C) 1990-1995, 1999, 2001-2019 Free Software 
Foundation,
 @c Inc.
 @c See the file elisp.texi for copying conditions.
 @node Backups and Auto-Saving
diff --git a/doc/lispref/buffers.texi b/doc/lispref/buffers.texi
index b2a4b0e..260f159 100644
--- a/doc/lispref/buffers.texi
+++ b/doc/lispref/buffers.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Buffers
@@ -573,7 +573,6 @@ echo area; use @code{set-buffer-modified-p} (above) instead.
 This function returns @var{buffer}'s modification-count.  This is a
 counter that increments every time the buffer is modified.  If
 @var{buffer} is @code{nil} (or omitted), the current buffer is used.
-The counter can wrap around occasionally.
 @end defun
 
 @defun buffer-chars-modified-tick &optional buffer
@@ -658,7 +657,8 @@ visiting a file or if the time has been explicitly cleared 
by
 too.  For instance, in a Dired buffer listing a directory, it returns
 the last modification time of that directory, as recorded by Dired.
 
-If the buffer is not visiting a file, this function returns @minus{}1.
+If the buffer is visiting a file that doesn't exist, this function
+returns @minus{}1.
 @end defun
 
 @defun set-visited-file-modtime &optional time
@@ -935,6 +935,10 @@ This is a normal hook run whenever the buffer list 
changes.  Functions
 (@pxref{Creating Buffers}), @code{rename-buffer} (@pxref{Buffer Names}),
 @code{kill-buffer} (@pxref{Killing Buffers}), @code{bury-buffer} (see
 above) and @code{select-window} (@pxref{Selecting Windows}).
+
+Functions run by this hook should avoid calling @code{select-window}
+with a nil @var{norecord} argument or @code{with-temp-buffer} since
+either may lead to infinite recursion.
 @end defvar
 
 @node Creating Buffers
diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi
index 427379b..cd44c1c 100644
--- a/doc/lispref/commands.texi
+++ b/doc/lispref/commands.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Command Loop
@@ -1012,7 +1012,8 @@ If the last event came from a keyboard macro, the value 
is @code{macro}.
 sequence of text that has the @code{display} or @code{composition}
 property, or is invisible.  Therefore, after a command finishes and
 returns to the command loop, if point is within such a sequence, the
-command loop normally moves point to the edge of the sequence.
+command loop normally moves point to the edge of the sequence, making this
+sequence effectively intangible.
 
   A command can inhibit this feature by setting the variable
 @code{disable-point-adjustment}:
@@ -2879,6 +2880,14 @@ command's key sequence (as returned by, e.g., 
@code{this-command-keys}),
 as the events will already have been added once as they were read for
 the first time.  An element of the form @address@hidden(t . @var{event})}}
 forces @var{event} to be added to the current command's key sequence.
+
address@hidden not recording input events
address@hidden input events, prevent recording
+Elements read from this list are normally recorded by the
+record-keeping features (@pxref{Recording Input}) and while defining a
+keyboard macro (@pxref{Keyboard Macros}).  However, an element of the
+form @address@hidden(no-record . @var{event})}} causes @var{event} to be
+processed normally without recording it.
 @end defvar
 
 @defun listify-key-sequence key
diff --git a/doc/lispref/compile.texi b/doc/lispref/compile.texi
index 6d21ca3..d9db55e 100644
--- a/doc/lispref/compile.texi
+++ b/doc/lispref/compile.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1994, 2001-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 1990-1994, 2001-2019 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Byte Compilation
 @chapter Byte Compilation
diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi
index 6fe0018..5d4184e 100644
--- a/doc/lispref/control.texi
+++ b/doc/lispref/control.texi
@@ -1,6 +1,6 @@
 @c -*- mode: texinfo; coding: utf-8 -*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Control Structures
diff --git a/doc/lispref/customize.texi b/doc/lispref/customize.texi
index 1cc7cb6..02eefe0 100644
--- a/doc/lispref/customize.texi
+++ b/doc/lispref/customize.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1997-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 1997-2019 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Customization
 @chapter Customization Settings
@@ -950,10 +950,10 @@ possibilities:
 
 @itemize @bullet
 @item
-A predicate---that is, a function of one argument that has no side
-effects, and returns either @code{nil} or address@hidden according to
-the argument.  Using a predicate in the list says that objects for which
-the predicate returns address@hidden are acceptable.
+A predicate---that is, a function of one argument that returns either
address@hidden or address@hidden according to the argument.  Using a
+predicate in the list says that objects for which the predicate
+returns address@hidden are acceptable.
 
 @item
 A quoted constant---that is, @code{'@var{object}}.  This sort of element
diff --git a/doc/lispref/debugging.texi b/doc/lispref/debugging.texi
index 89927db..9e43343 100644
--- a/doc/lispref/debugging.texi
+++ b/doc/lispref/debugging.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1994, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1994, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Debugging
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index b4a4d6c..a2ed4b3 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -1,6 +1,6 @@
 @c -*- mode: texinfo; coding: utf-8 -*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 1990-1995, 1998-2019 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Display
 @chapter Emacs Display
@@ -1034,8 +1034,8 @@ hiding certain lines on the screen.
 @cindex explicit selective display
   The first variant, explicit selective display, was designed for use in a Lisp
 program: it controls which lines are hidden by altering the text.  This kind of
-hiding is now obsolete; instead you can get the same effect with the
address@hidden property (@pxref{Invisible Text}).
+hiding is now obsolete and deprecated; instead you should use the
address@hidden property (@pxref{Invisible Text}) to get the same effect.
 
   In the second variant, the choice of lines to hide is made
 automatically based on indentation.  This variant is designed to be a
@@ -3079,10 +3079,17 @@ value, which inherits from @var{face}'s global 
definition.
 This function returns a list of all defined face names.
 @end defun
 
address@hidden face number
address@hidden face property of face symbols
 @defun face-id face
 This function returns the @dfn{face number} of face @var{face}.  This
 is a number that uniquely identifies a face at low levels within
 Emacs.  It is seldom necessary to refer to a face by its face number.
+However, functions that manipulate glyphs, such as
address@hidden and @code{glyph-face} (@pxref{Glyphs}) access
+the face numbers internally.  Note that the face number is stored as
+the value of the @code{face} property of the face symbol, so we
+recommend not to set that property of a face to any value of your own.
 @end defun
 
 @defun face-documentation face
@@ -3950,6 +3957,9 @@ fringe, and likewise @var{right} for the right fringe.  A 
value of
 @var{outside-margins} is address@hidden, that specifies that fringes
 should appear outside of the display margins.
 
+If @var{window} is not large enough to accommodate fringes of the
+desired width, this leaves the fringes of @var{window} unchanged.
+
 The values specified here may be later overridden by invoking
 @code{set-window-buffer} (@pxref{Buffers and Windows}) on @var{window}
 with its @var{keep-margins} argument @code{nil} or omitted.
@@ -4371,6 +4381,9 @@ vertical scroll bar.
 The possible values are @code{bottom}, @code{t}, which means to use the
 frame's default, and @code{nil} for no horizontal scroll bar.
 
+If @var{window} is not large enough to accommodate a scroll bar of the
+desired dimension, this leaves the corresponding scroll bar unchanged.
+
 The values specified here may be later overridden by invoking
 @code{set-window-buffer} (@pxref{Buffers and Windows}) on @var{window}
 with its @var{keep-margins} argument @code{nil} or omitted.
@@ -4887,6 +4900,16 @@ and the buffer position where the @code{display} 
property was found,
 respectively.  Both positions can be different when @code{object} is a
 string.
 
+Note that @var{condition} will only be evaluated when redisplay
+examines the text where this display spec is located, so this feature
+is best suited for conditions that are relatively stable, i.e.@:
+yield, for each particular buffer position, the same results on every
+evaluation.  If the results change for the same text location, e.g.,
+if the result depends on the position of point, then the conditional
+specification might not do what you want, because redisplay examines
+only those parts of buffer text where it has reasons to assume that
+something changed since the last display cycle.
+
 @node Display Margins
 @subsection Displaying in the Margins
 @cindex display margins
@@ -4950,6 +4973,9 @@ This function specifies the margin widths for window 
@var{window}, in
 character cell units.  The argument @var{left} controls the left
 margin, and @var{right} controls the right margin (default @code{0}).
 
+If @var{window} is not large enough to accommodate margins of the
+desired width, this leaves the margins of @var{window} unchanged.
+
 The values specified here may be later overridden by invoking
 @code{set-window-buffer} (@pxref{Buffers and Windows}) on @var{window}
 with its @var{keep-margins} argument @code{nil} or omitted.
@@ -5112,6 +5138,47 @@ This adds a shadow rectangle around the image.  The 
value,
 @var{relief} is negative, shadows are drawn so that the image appears
 as a pressed button; otherwise, it appears as an unpressed button.
 
address@hidden :width @var{width}, :height @var{height}
+The @code{:width} and @code{:height} keywords are used for scaling the
+image.  If only one of them is specified, the other one will be
+calculated so as to preserve the aspect ratio.  If both are specified,
+aspect ratio may not be preserved.
+
address@hidden :max-width @var{max-width}, :max-height @var{max-height}
+The @code{:max-width} and @code{:max-height} keywords are used for
+scaling if the size of the image exceeds these values.  If
address@hidden:width} is set, it will have precedence over @code{max-width},
+and if @code{:height} is set, it will have precedence over
address@hidden, but you can otherwise mix these keywords as you
+wish.
+
+If both @code{:max-width} and @code{:height} are specified, but
address@hidden:width} is not, preserving the aspect ratio might require that
+width exceeds @code{:max-width}.  If this happens, scaling will use a
+smaller value for the height so as to preserve the aspect ratio while
+not exceeding @code{:max-width}.  Similarly when both
address@hidden:max-height} and @code{:width} are specified, but @code{:height}
+is not.  For example, if you have a 200x100 image and specify that
address@hidden:width} should be 400 and @code{:max-height} should be 150,
+you'll end up with an image that is 300x150: Preserving the aspect
+ratio and not exceeding the ``max'' setting.  This combination of
+parameters is a useful way of saying ``display this image as large as
+possible, but no larger than the available display area''.
+
address@hidden :scale @var{scale}
+This should be a number, where values higher than 1 means to increase
+the size, and lower means to decrease the size, by multiplying both
+the width and height.  For instance, a value of 0.25 will make the
+image a quarter size of what it originally was.  If the scaling makes
+the image larger than specified by @code{:max-width} or
address@hidden:max-height}, the resulting size will not exceed those two
+values.  If both @code{:scale} and @code{:height}/@code{:width} are
+specified, the height/width will be adjusted by the specified scaling
+factor.
+
address@hidden :index @var{frame}
address@hidden Images}.
+
 @item :conversion @var{algorithm}
 This specifies a conversion algorithm that should be applied to the
 image before it is displayed; the value, @var{algorithm}, specifies
@@ -5251,6 +5318,16 @@ This function returns @code{t} if image @var{spec} has a 
mask bitmap.
 (@pxref{Input Focus}).
 @end defun
 
address@hidden image-scaling-p &optional frame
+This function returns @code{t} if @var{frame} supports image scaling.
address@hidden @code{nil} or omitted means to use the selected frame
+(@pxref{Input Focus}).
+
+If image scaling is not supported, @code{:width}, @code{:height},
address@hidden:scale}, @code{:max-width} and @code{:max-height} will only be
+usable through ImageMagick, if available (@pxref{ImageMagick Images}).
address@hidden defun
+
 @node XBM Images
 @subsection XBM Images
 @cindex XBM
@@ -5387,42 +5464,6 @@ color, which is used as the image's background color if 
the image
 supports transparency.  If the value is @code{nil}, it defaults to the
 frame's background color.
 
address@hidden :width @var{width}, :height @var{height}
-The @code{:width} and @code{:height} keywords are used for scaling the
-image.  If only one of them is specified, the other one will be
-calculated so as to preserve the aspect ratio.  If both are specified,
-aspect ratio may not be preserved.
-
address@hidden :max-width @var{max-width}, :max-height @var{max-height}
-The @code{:max-width} and @code{:max-height} keywords are used for
-scaling if the size of the image of the image exceeds these values.
-If @code{:width} is set it will have precedence over @code{max-width},
-and if @code{:height} is set it will have precedence over
address@hidden, but you can otherwise mix these keywords as you
-wish.  @code{:max-width} and @code{:max-height} will always preserve
-the aspect ratio.
-
-If both @code{:width} and @code{:max-height} has been set (but
address@hidden:height} has not been set), then @code{:max-height} will have
-precedence.  The same is the case for the opposite combination: The
-``max'' keyword has precedence.  That is, if you have a 200x100 image
-and specify that @code{:width} should be 400 and @code{:max-height}
-should be 150, you'll end up with an image that is 300x150: Preserving
-the aspect ratio and not exceeding the ``max'' setting.  This
-combination of parameters is a useful way of saying ``display this
-image as large as possible, but no larger than the available display
-area''.
-
address@hidden :scale @var{scale}
-This should be a number, where values higher than 1 means to increase
-the size, and lower means to decrease the size.  For instance, a value
-of 0.25 will make the image a quarter size of what it originally was.
-If the scaling makes the image larger than specified by
address@hidden:max-width} or @code{:max-height}, the resulting size will not
-exceed those two values.  If both @code{:scale} and
address@hidden:height}/@code{:width} are specified, the height/width will be
-adjusted by the specified scaling factor.
-
 @item :format @var{type}
 The value, @var{type}, should be a symbol specifying the type of the
 image data, as found in @code{image-format-suffixes}.  This is used
@@ -5431,9 +5472,6 @@ hint to ImageMagick to help it detect the image type.
 
 @item :rotation @var{angle}
 Specifies a rotation angle in degrees.
-
address@hidden :index @var{frame}
address@hidden Images}.
 @end table
 
 @node SVG Images
@@ -5871,8 +5909,8 @@ This function returns the size of an image as a pair
 specification.  @var{pixels} address@hidden means return sizes measured
 in pixels, otherwise return sizes measured in the default character size
 of @var{frame} (@pxref{Frame Font}).  @var{frame} is the frame on which
-the image will be displayed.  @var{frame} null or omitted means use the
-selected frame (@pxref{Input Focus}).
+the image will be displayed.  @var{frame} @code{nil} or omitted means
+use the selected frame (@pxref{Input Focus}).
 @end defun
 
 @defvar max-image-size
diff --git a/doc/lispref/edebug.texi b/doc/lispref/edebug.texi
index 2aace03..2c0ee39 100644
--- a/doc/lispref/edebug.texi
+++ b/doc/lispref/edebug.texi
@@ -1,6 +1,6 @@
 @comment -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1992-1994, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1992-1994, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi
index 08414e6..e187596 100644
--- a/doc/lispref/elisp.texi
+++ b/doc/lispref/elisp.texi
@@ -99,7 +99,7 @@ This is the @cite{GNU Emacs Lisp Reference Manual}
 @end ifnottex
 corresponding to Emacs version @value{EMACSVER}.
 
-Copyright @copyright{} 1990--1996, 1998--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1990--1996, 1998--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/lispref/errors.texi b/doc/lispref/errors.texi
index e61ea98..aa99b2b 100644
--- a/doc/lispref/errors.texi
+++ b/doc/lispref/errors.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1993, 1999, 2001-2018 Free Software 
Foundation,
address@hidden Copyright (C) 1990-1993, 1999, 2001-2019 Free Software 
Foundation,
 @c Inc.
 @c See the file elisp.texi for copying conditions.
 @node Standard Errors
diff --git a/doc/lispref/eval.texi b/doc/lispref/eval.texi
index ea8e671..39c5a1ec 100644
--- a/doc/lispref/eval.texi
+++ b/doc/lispref/eval.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1994, 1998, 2001-2018 Free Software 
Foundation,
address@hidden Copyright (C) 1990-1994, 1998, 2001-2019 Free Software 
Foundation,
 @c Inc.
 @c See the file elisp.texi for copying conditions.
 @node Evaluation
@@ -87,6 +87,7 @@ also temporarily alter the environment by binding variables
 (@pxref{Local Variables}).
 
 @cindex side effect
address@hidden of side effect}
   Evaluating a form may also make changes that persist; these changes
 are called @dfn{side effects}.  An example of a form that produces a
 side effect is @code{(setq foo 1)}.
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index b795864..af16b1c 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Files
@@ -16,7 +16,7 @@ described in @ref{Backups and Auto-Saving}.
 names.  A file name is a string.  Most of these functions expand file
 name arguments using the function @code{expand-file-name}, so that
 @file{~} is handled correctly, as are relative file names (including
address@hidden/}).  @xref{File Name Expansion}.
address@hidden/} and the empty string).  @xref{File Name Expansion}.
 
   In addition, certain @dfn{magic} file names are handled specially.
 For example, when a remote file name is specified, Emacs accesses the
@@ -550,7 +550,7 @@ the functions in the list 
@code{after-insert-file-functions}.
 (@pxref{Coding Systems}) used for decoding the file's contents,
 including end-of-line conversion.  However, if the file contains null
 bytes, it is by default visited without any code conversions.
address@hidden and Coding Systems, inhibit-null-byte-detection}.
address@hidden and Coding Systems, inhibit-nul-byte-detection}.
 
 If @var{visit} is address@hidden, this function additionally marks the
 buffer as unmodified and sets up various fields in the buffer so that it
@@ -1306,7 +1306,7 @@ The file's @acronym{GID}, likewise 
(@code{file-attribute-group-id}).
 
 @item
 The time of last access as a Lisp timestamp
-(@code{file-attribute-status-change-time}).  The timestamp is in the
+(@code{file-attribute-access-time}).  The timestamp is in the
 style of @code{current-time} (@pxref{Time of Day}) and is truncated
 to that of the filesystem's timestamp resolution; for example, on some
 FAT-based filesystems, only the date of last access is recorded, so
@@ -2402,6 +2402,17 @@ This is for the sake of filesystems that have the 
concept of a
 superroot above the root directory @file{/}.  On other filesystems,
 @file{/../} is interpreted exactly the same as @file{/}.
 
+Expanding @file{.} or the empty string returns the default directory:
+
address@hidden
address@hidden
+(expand-file-name "." "/usr/spool/")
+     @result{} "/usr/spool"
+(expand-file-name "" "/usr/spool/")
+     @result{} "/usr/spool"
address@hidden group
address@hidden example
+
 Note that @code{expand-file-name} does @emph{not} expand environment
 variables; only @code{substitute-in-file-name} does that:
 
@@ -2512,9 +2523,9 @@ with @samp{/:}.
 @defmac file-name-quote name
 This macro adds the quotation prefix @samp{/:} to the file @var{name}.
 For a local file @var{name}, it prefixes @var{name} with @samp{/:}.
-If @var{name} is a remote file name, the local part of @var{name} is
-quoted.  If @var{name} is already a quoted file name, @var{name} is
-returned unchanged.
+If @var{name} is a remote file name, the local part of @var{name}
+(@pxref{Magic File Names}) is quoted.  If @var{name} is already a
+quoted file name, @var{name} is returned unchanged.
 
 @example
 @group
@@ -2693,8 +2704,8 @@ that remote host.  If such a directory does not exist, or
 @code{temporary-file-directory} is returned.
 @end defun
 
-In order to extract the local part of the path name from a temporary
-file, @code{file-local-name} could be used.
+In order to extract the local part of the file's name of a temporary
+file, use @code{file-local-name} (@pxref{Magic File Names}).
 
 @node File Name Completion
 @subsection File Name Completion
@@ -3067,7 +3078,7 @@ expression to define the class of names (all those that 
match the
 regular expression), plus a handler that implements all the primitive
 Emacs file operations for file names that match.
 
address@hidden file handler
address@hidden file name handler
 @vindex file-name-handler-alist
   The variable @code{file-name-handler-alist} holds a list of handlers,
 together with regular expressions that determine when to apply each
@@ -3171,6 +3182,7 @@ first, before handlers for jobs such as remote file 
access.
 @code{make-directory},
 @code{make-directory-internal},
 @code{make-nearby-temp-file},
address@hidden,
 @code{make-symbolic-link},@*
 @code{process-file},
 @code{rename-file}, @code{set-file-acl}, @code{set-file-modes},
@@ -3227,6 +3239,7 @@ first, before handlers for jobs such as remote file 
access.
 @code{make-auto-save-file-name},
 @address@hidden,
 @address@hidden,
address@hidden,
 @code{make-symbolic-link},
 @code{process-file},
 @code{rename-file}, @code{set-file-acl}, @code{set-file-modes},
@@ -3354,8 +3367,8 @@ If @code{file-remote-p} returns the same identifier for 
two different
 filenames, that means they are stored on the same file system and can
 be accessed locally with respect to each other.  This means, for
 example, that it is possible to start a remote process accessing both
-files at the same time.  Implementers of file handlers need to ensure
-this principle is valid.
+files at the same time.  Implementers of file name handlers need to
+ensure this principle is valid.
 
 @var{identification} specifies which part of the identifier shall be
 returned as string.  @var{identification} can be the symbol
@@ -3383,11 +3396,24 @@ non-magic directory to serve as its current directory, 
and this function
 is a good way to come up with one.
 @end defun
 
address@hidden local part of remote file name
 @defun file-local-name filename
-This function returns the local part of file @var{filename}.  For a
-remote @var{filename}, it returns a file name which could be used
-directly as argument of a remote process.  If @var{filename} is local,
-this function returns the file name.
+This function returns the @dfn{local part} of @var{filename}.  This is
+the part of the file's name that identifies it on the remote host, and
+is typically obtained by removing from the remote file name the parts
+that specify the remote host and the method of accessing it.  For
+example:
+
address@hidden
+(file-local-name "/ssh:@var{user}@@@var{host}:/foo/bar")
+     @result{} "/foo/bar"
address@hidden smallexample
+
+For a remote @var{filename}, this function returns a file name which
+could be used directly as an argument of a remote process
+(@pxref{Asynchronous Processes}, and @pxref{Synchronous Processes}),
+and as the program to run on the remote host.  If @var{filename} is
+local, this function returns it unchanged.
 @end defun
 
 @defopt remote-file-name-inhibit-cache
diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi
index b961d68..9b3e02f 100644
--- a/doc/lispref/frames.texi
+++ b/doc/lispref/frames.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Frames
@@ -440,6 +440,17 @@ This function returns the attributes of the physical 
monitor
 dominating (see above) @var{frame}, which defaults to the selected frame.
 @end defun
 
+On multi-monitor displays it is possible to use the command
address@hidden to make frames on the specified monitor.
+
address@hidden Command make-frame-on-monitor monitor &optional display 
parameters
+This function creates and returns a new frame on @var{monitor} located
+on @var{display}, taking the other frame parameters from the alist
address@hidden  @var{monitor} should be the name of the physical
+monitor, the same string as returned by the function
address@hidden in the attribute @code{name}.
address@hidden should be the name of an X display (a string).
address@hidden deffn
 
 @node Frame Geometry
 @section Frame Geometry
@@ -1873,6 +1884,12 @@ minibuffer window to @code{t} and vice-versa, or from 
@code{t} to
 @code{nil}.  If the parameter specifies a minibuffer window already,
 setting it to @code{nil} has no effect.
 
+The special value @code{child-frame} means to make a minibuffer-only
+child frame (@pxref{Child Frames}) whose parent becomes the frame
+created.  As if specified as @code{nil}, Emacs will set this parameter
+to the minibuffer window of the child frame but will not select the
+child frame after its creation.
+
 @vindex address@hidden, a frame parameter}
 @item buffer-predicate
 The buffer-predicate function for this frame.  The function
@@ -3203,9 +3220,17 @@ top-level frame which also always appears on top of its 
parent
 window---the desktop's root window.  When a parent frame is iconified or
 made invisible (@pxref{Visibility of Frames}), its child frames are made
 invisible.  When a parent frame is deiconified or made visible, its
-child frames are made visible.  When a parent frame is about to be
-deleted (@pxref{Deleting Frames}), its child frames are recursively
-deleted before it.
+child frames are made visible.
+
+  When a parent frame is about to be deleted (@pxref{Deleting
+Frames}), its child frames are recursively deleted before it.  There
+is one exception to this rule: When the child frame serves as a
+surrogate minibuffer frame (@pxref{Minibuffers and Frames}) for
+another frame, it is retained until the parent frame has been deleted.
+If, at this time, no remaining frame uses the child frame as its
+minibuffer frame, Emacs will try to delete the child frame too.  If
+that deletion fails for whatever reason, the child frame is made a
+top-level frame.
 
   Whether a child frame can have a menu or tool bar is window-system or
 window manager dependent.  Most window-systems explicitly disallow menus
diff --git a/doc/lispref/functions.texi b/doc/lispref/functions.texi
index bf0354c..97f7fb9 100644
--- a/doc/lispref/functions.texi
+++ b/doc/lispref/functions.texi
@@ -1,6 +1,6 @@
 @c -*- mode: texinfo; coding: utf-8 -*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Functions
@@ -38,11 +38,16 @@ define them.
 @cindex return value
 @cindex value of function
 @cindex argument
address@hidden pure function
   In a general sense, a function is a rule for carrying out a
 computation given input values called @dfn{arguments}.  The result of
 the computation is called the @dfn{value} or @dfn{return value} of the
 function.  The computation can also have side effects, such as lasting
-changes in the values of variables or the contents of data structures.
+changes in the values of variables or the contents of data structures
+(@pxref{Definition of side effect}).  A @dfn{pure function} is a
+function which, in addition to having no side effects, always returns
+the same value for the same combination of arguments, regardless of
+external factors such as machine type or system state.
 
   In most computer languages, every function has a name.  But in Lisp,
 a function in the strictest sense has no name: it is an object which
diff --git a/doc/lispref/hash.texi b/doc/lispref/hash.texi
index 9c4b56d..5aaf312 100644
--- a/doc/lispref/hash.texi
+++ b/doc/lispref/hash.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1999, 2001-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 1999, 2001-2019 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Hash Tables
 @chapter Hash Tables
diff --git a/doc/lispref/help.texi b/doc/lispref/help.texi
index 2688a2b..63a782c 100644
--- a/doc/lispref/help.texi
+++ b/doc/lispref/help.texi
@@ -1,6 +1,6 @@
 @c -*- mode: texinfo; coding: utf-8 -*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Documentation
diff --git a/doc/lispref/hooks.texi b/doc/lispref/hooks.texi
index 0d50a29..7199246 100644
--- a/doc/lispref/hooks.texi
+++ b/doc/lispref/hooks.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1993, 1998, 2001-2018 Free Software 
Foundation,
address@hidden Copyright (C) 1990-1993, 1998, 2001-2019 Free Software 
Foundation,
 @c Inc.
 @c See the file elisp.texi for copying conditions.
 @node Standard Hooks
diff --git a/doc/lispref/internals.texi b/doc/lispref/internals.texi
index a2f7e8c..5ae71af 100644
--- a/doc/lispref/internals.texi
+++ b/doc/lispref/internals.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1993, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1993, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node GNU Emacs Internals
@@ -48,24 +48,63 @@ environment.  After this step, the Emacs executable is no 
longer
 @dfn{bare}.
 
 @cindex dumping Emacs
address@hidden @option{--temacs} option, and dumping method
   Because it takes some time to load the standard Lisp files, the
 @file{temacs} executable usually isn't run directly by users.
-Instead, as one of the last steps of building Emacs, the command
address@hidden -batch -l loadup dump} is run.  The special @samp{dump}
-argument causes @command{temacs} to dump out an executable program,
-called @file{emacs}, which has all the standard Lisp files preloaded.
-(The @samp{-batch} argument prevents @file{temacs} from trying to
-initialize any of its data on the terminal, so that the tables of
-terminal information are empty in the dumped Emacs.)
+Instead, one of the last steps of building Emacs runs the command
address@hidden@samp{temacs -batch -l loadup address@hidden  The
+special option @option{--temacs} tells @command{temacs} how to record
+all the standard preloaded Lisp functions and variables, so that when
+you subsequently run Emacs, it will start much faster.  The
address@hidden option requires an argument @var{dump-method}, which
+can be one of the following:
+
address@hidden @samp
address@hidden pdump
address@hidden portable dump file
+Record the preloaded Lisp data in a @dfn{portable dump} file.  This
+method produces an additional data file which Emacs will load at
+startup.  The portable dump file is usually called @file{emacs.pdmp},
+and is installed in the Emacs @code{exec-directory} (@pxref{Help
+Functions}).  This method is the most preferred one, as it does not
+require Emacs to employ any special techniques of memory allocation,
+which might get in the way of various memory-layout techniques used by
+modern systems to enhance security and privacy.
+
address@hidden pbootstrap
address@hidden bootstrapping Emacs
+Like @samp{pdump}, but used while @dfn{bootstrapping} Emacs, when no
+previous Emacs binary and no @file{*.elc} byte-compiled Lisp files are
+available.  The produced portable dump file is usually named
address@hidden in this case.
+
address@hidden dump
address@hidden unexec
+This method causes @command{temacs} to dump out an executable program,
+called @file{emacs}, which has all the standard Lisp files already
+preloaded into it.  (The @samp{-batch} argument prevents
address@hidden from trying to initialize any of its data on the
+terminal, so that the tables of terminal information are empty in the
+dumped Emacs.)  This method is also known as @dfn{unexec}, because it
+produces a program file from a running process, and thus is in some
+sense the opposite of executing a program to start a process.
+
address@hidden bootstrap
+Like @samp{dump}, but used when bootstrapping Emacs with the
address@hidden method.
address@hidden table
 
 @cindex preloaded Lisp files
 @vindex preloaded-file-list
   The dumped @file{emacs} executable (also called a @dfn{pure} Emacs)
-is the one which is installed.  The variable
address@hidden stores a list of the Lisp files preloaded
-into the dumped Emacs.  If you port Emacs to a new operating system,
-and are not able to implement dumping, then Emacs must load
address@hidden each time it starts.
+is the one which is installed.  If the portable dumping was used to
+build Emacs, the @file{emacs} executable is actually an exact copy of
address@hidden, and the corresponding @file{emacs.pdmp} file is
+installed as well.  The variable @code{preloaded-file-list} stores a
+list of the preloaded Lisp files recorded in the portable dump file or
+in the dumped Emacs executable.  If you port Emacs to a new operating
+system, and are not able to implement dumping of any kind, then Emacs
+must load @file{loadup.el} each time it starts.
 
 @cindex build details
 @cindex deterministic build
@@ -161,14 +200,41 @@ In the unlikely event that you need a more general 
functionality than
 @code{custom-initialize-delay} provides, you can use
 @code{before-init-hook} (@pxref{Startup Summary}).
 
address@hidden dump-emacs-portable to-file &optional track-referrers
+This function dumps the current state of Emacs into a portable dump
+file @var{to-file}, using the @code{pdump} method.  Normally, the
+portable dump file is called @address@hidden, where
address@hidden is the name of the Emacs executable file.  The
+optional argument @var{track-referrers}, if address@hidden, causes the
+portable dumping process keep additional information to help track
+down the provenance of object types that are not yet supported by the
address@hidden method.
+
+If you want to use this function in an Emacs that was already dumped,
+you must run Emacs with the @samp{-batch} option.
address@hidden defun
+
 @defun dump-emacs to-file from-file
 @cindex unexec
 This function dumps the current state of Emacs into an executable file
address@hidden  It takes symbols from @var{from-file} (this is normally
-the executable file @file{temacs}).
address@hidden, using the @code{unexec} method.  It takes symbols from
address@hidden (this is normally the executable file @file{temacs}).
 
-If you want to use this function in an Emacs that was already dumped,
-you must run Emacs with @samp{-batch}.
+This function cannot be used in an Emacs that was already dumped.  If
+Emacs was built without @code{unexec} support, this function will not
+be available.
address@hidden defun
+
address@hidden pdumper-stats
+If the current Emacs session restored its state from a portable dump
+file, this function returns information about the dump file and the
+time it took to restore the Emacs state.  The value is an alist
address@hidden@code{((dumped-with-pdumper . t) (load-time . @var{time})
+(dump-file-name . @var{file}))}},
+where @var{file} is the name of the dump file, and @var{time} is the
+time in seconds it took to restore the state from the dump file.
+If the current session was not restored from a portable dump file, the
+value is nil.
 @end defun
 
 @node Pure Storage
@@ -965,10 +1031,9 @@ number of arguments.  They work by calling 
@code{Ffuncall}.
 @file{lisp.h} contains the definitions for some important macros and
 functions.
 
-  If you define a function which is side-effect free, update the code
-in @file{byte-opt.el} that binds @code{side-effect-free-fns} and
address@hidden so that the compiler optimizer
-knows about it.
+  If you define a function which is side-effect free or pure, give it
+a address@hidden @code{side-effect-free} or @code{pure} property,
+respectively (@pxref{Standard Properties}).
 
 @node Writing Dynamic Modules
 @section Writing Dynamically-Loaded Modules
@@ -1312,7 +1377,9 @@ can be used to obtain the type of a @code{emacs_value} 
object.
 This function returns the value of a Lisp integer specified by
 @var{arg}.  The C data type of the return value, @code{intmax_t}, is
 the widest integral data type supported by the C compiler, typically
address@hidden@code{long long}}.
address@hidden@code{long long}}.  If the value of @var{arg} doesn't fit into an
address@hidden, the function signals an error using the error symbol
address@hidden
 @end deftypefn
 
 @deftypefn Function double extract_float (emacs_env address@hidden, 
emacs_value @var{arg})
@@ -1320,6 +1387,38 @@ This function returns the value of a Lisp float 
specified by
 @var{arg}, as a C @code{double} value.
 @end deftypefn
 
address@hidden Function struct timespec extract_time (emacs_env address@hidden, 
emacs_value @var{time})
+This function, which is available since Emacs 27, interprets
address@hidden as an Emacs Lisp time value and returns the corresponding
address@hidden timespec}.  @xref{Time of Day}.  @code{struct timespec}
+represents a timestamp with nanosecond precision.  It has the
+following members:
+
address@hidden @code
address@hidden time_t tv_sec
+Whole number of seconds.
address@hidden long tv_nsec
+Fractional seconds as number of nanoseconds, always less than one
+billion.
address@hidden table
+
address@hidden
address@hidden Time,,,libc}.
+
+If @var{time} has higher precision than nanoseconds, then this
+function truncates it to nanosecond precision towards negative
+infinity.  This function signals an error if @var{time} (truncated to
+nanoseconds) cannot be represented by @code{struct timespec}.  For
+example, if @code{time_t} is a 32-bit integral type, then a @var{time}
+value of ten billion seconds would signal an error, but a @var{time}
+value of 600 picoseconds would get truncated to zero.
+
+If you need to deal with time values that are not representable by
address@hidden timespec}, or if you want higher precision, call the Lisp
+function @code{encode-time} and work with its return value.
address@hidden Conversion}.
address@hidden deftypefn
+
 @deftypefn Function bool copy_string_contents (emacs_env address@hidden, 
emacs_value @var{arg}, char address@hidden, ptrdiff_t address@hidden)
 This function stores the UTF-8 encoded text of a Lisp string specified
 by @var{arg} in the array of @code{char} pointed by @var{buf}, which
@@ -1374,11 +1473,10 @@ objects from basic C data types.  They all return the 
created
 
 @deftypefn Function emacs_value make_integer (emacs_env address@hidden, 
intmax_t @var{n})
 This function takes an integer argument @var{n} and returns the
-corresponding @code{emacs_value} object.  It raises the
address@hidden error condition if the value of @var{n} cannot
-be represented as an Emacs integer, i.e.@: is not inside the limits
-set by @code{most-negative-fixnum} and @code{most-positive-fixnum}
-(@pxref{Integer Basics}).
+corresponding @code{emacs_value} object.  It returns either a fixnum
+or a bignum depending on whether the value of @var{n} is inside the
+limits set by @code{most-negative-fixnum} and
address@hidden (@pxref{Integer Basics}).
 @end deftypefn
 
 @deftypefn Function emacs_value make_float (emacs_env address@hidden, double 
@var{d})
@@ -1386,6 +1484,18 @@ This function takes a @code{double} argument @var{d} and 
returns the
 corresponding Emacs floating-point value.
 @end deftypefn
 
address@hidden Function emacs_value make_time (emacs_env address@hidden, struct 
timespec @var{time})
+This function, which is available since Emacs 27, takes a @code{struct
+timespec} argument @var{time} and returns the corresponding Emacs
+timestamp as a pair @code{(@var{ticks} . @var{hz})}.  @xref{Time of
+Day}.  The return value represents exactly the same timestamp as
address@hidden: all input values are representable, and there is never a
+loss of precision.  @address@hidden and
address@hidden@var{time}.tv_nsec} can be arbitrary values.  In particular,
+there's no requirement that @var{time} be normalized.  This means that
address@hidden@var{time}.tv_nsec} can be negative or larger than 999,999,999.
address@hidden deftypefn
+
 @deftypefn Function emacs_value make_string (emacs_env address@hidden, const 
char address@hidden, ptrdiff_t @var{strlen})
 This function creates an Emacs string from C text string pointed by
 @var{str} whose length in bytes, not including the terminating null
@@ -1398,6 +1508,66 @@ function raises the @code{overflow-error} error 
condition if
 string.
 @end deftypefn
 
+If you define the preprocessor macro @code{EMACS_MODULE_GMP} before
+including the header @file{emacs-module.h}, you can also convert
+between Emacs integers and GMP @code{mpz_t} values.  @xref{GMP
+Basics,,,gmp}.  If @code{EMACS_MODULE_GMP} is defined,
address@hidden wraps @code{mpz_t} in the following structure:
+
address@hidden struct emacs_mpz value
+struct emacs_mpz @{ mpz_t value; @};
address@hidden deftp
+
address@hidden
+Then you can use the following additional functions:
+
address@hidden Function bool extract_big_integer (emacs_env address@hidden, 
emacs_value @var{arg}, struct emacs_mpz address@hidden)
+This function, which is available since Emacs 27, extracts the
+integral value of @var{arg} into @var{result}.  @var{result} must not
+be @code{NULL}.  @address@hidden>value} must be an initialized
address@hidden object.  @xref{Initializing Integers,,,gmp}.  If
address@hidden is an integer, Emacs will store its value into
address@hidden@var{result}->value}.  After you have finished using
address@hidden@var{result}->value}, you should free it using @code{mpz_clear}
+or similar.
address@hidden deftypefn
+
address@hidden Function emacs_value make_big_integer (emacs_env address@hidden, 
const struct emacs_mpz address@hidden)
+This function, which is available since Emacs 27, takes an
+arbitrary-sized integer argument and returns a corresponding
address@hidden object.  @var{value} must not be @code{NULL}.
address@hidden@var{value}->value} must be an initialized @code{mpz_t} object.
address@hidden Integers,,,gmp}.  Emacs will return a corresponding
+integral object.  After you have finished using
address@hidden@var{value}->value}, you should free it using @code{mpz_clear}
+or similar.
address@hidden deftypefn
+
+The following example uses GMP to calculate the next probable prime
+after a given integer:
+
address@hidden
+#include <assert.h>
+#include <gmp.h>
+
+#define EMACS_MODULE_GMP
+#include <emacs-module.h>
+
+static emacs_value
+next_prime (emacs_env *env, ptrdiff_t nargs, emacs_value *args,
+            void *data)
address@hidden
+  assert (nargs == 1);
+  emacs_mpz p;
+  mpz_init (p.value);
+  env->extract_big_integer (env, args[0], &p);
+  mpz_nextprime (p.value, p.value);
+  emacs_value result = env->make_big_integer (env, &p);
+  mpz_clear (p.value);
+  return result;
address@hidden
address@hidden example
+
 The @acronym{API} does not provide functions to manipulate Lisp data
 structures, for example, create lists with @code{cons} and @code{list}
 (@pxref{Building Lists}), extract list members with @code{car} and
@@ -1557,7 +1727,27 @@ purpose.
 @deftypefn Function bool should_quit (emacs_env address@hidden)
 This function returns @code{true} if the user wants to quit.  In that
 case, we recommend that your module function aborts any on-going
-processing and returns as soon as possible.
+processing and returns as soon as possible.  In most cases, use
address@hidden instead.
address@hidden deftypefn
+
+To process input events in addition to checking whether the user wants
+to quit, use the following function, which is available since Emacs
+27.1.
+
address@hidden
address@hidden Function enum emacs_process_input_result process_input 
(emacs_env address@hidden)
+This function processes pending input events.  It returns
address@hidden if the user wants to quit or an error
+occurred while processing signals.  In that case, we recommend that
+your module function aborts any on-going processing and returns as
+soon as possible.  If the module code may continue running,
address@hidden returns @code{emacs_process_input_continue}.  The
+return value is @code{emacs_process_input_continue} if and only if
+there is no pending nonlocal exit in @code{env}.  If the module
+continues after calling @code{process_input}, global state such as
+variable values and buffer content may have been modified in arbitrary
+ways.
 @end deftypefn
 
 @node Module Nonlocal
@@ -1622,7 +1812,7 @@ The last @acronym{API} function exited via @code{throw}.
 @end vtable
 @end deftypefn
 
address@hidden Function emacs_funcall_exit non_local_exit_get (emacs_env 
address@hidden, emacs_value address@hidden, emacs_value address@hidden)
address@hidden Function enum emacs_funcall_exit non_local_exit_get (emacs_env 
address@hidden, emacs_value address@hidden, emacs_value address@hidden)
 This function returns the kind of nonlocal exit condition stored in
 @var{env}, like @code{non_local_exit_check} does, but it also returns
 the full information about the nonlocal exit, if any.  If the return
@@ -2033,45 +2223,76 @@ if that window no longer displays this buffer.
 The frame that this window is on, as a Lisp object.
 
 @item mini
-Non-zero if this window is a minibuffer window.
+Non-zero if this window is a minibuffer window, a window showing the
+minibuffer or the echo area.
+
address@hidden pseudo_window_p
address@hidden pseudo window
+Non-zero if this window is a @dfn{pseudo window}.  A pseudo window is
+either a window used to display the menu bar or the tool bar (when
+Emacs uses toolkits that don't display their own menu bar and tool
+bar) or a window showing a tooltip on a tooltip frame.  Pseudo windows
+are in general not accessible from Lisp code.
 
 @item parent
-Internally, Emacs arranges windows in a tree; each group of siblings has
-a parent window whose area includes all the siblings.  This field points
-to a window's parent, as a Lisp object.
+Internally, Emacs arranges windows in a tree; each group of siblings
+has a parent window whose area includes all the siblings.  This field
+points to the window's parent in that tree, as a Lisp object.  For the
+root window of the tree and a minibuffer window this is always
address@hidden
 
 Parent windows do not display buffers, and play little role in display
-except to shape their child windows.  Emacs Lisp programs usually have
-no access to the parent windows; they operate on the windows at the
+except to shape their child windows.  Emacs Lisp programs cannot
+directly manipulate parent windows; they operate on the windows at the
 leaves of the tree, which actually display buffers.
 
address@hidden contents
+For a leaf window and windows showing a tooltip, this is the buffer,
+as a Lisp object, that the window is displaying.  For an internal
+(``parent'') window, this is its first child window.  For a pseudo
+window showing a menu or tool bar this is @code{nil}.  It is also
address@hidden for a window that has been deleted.
+
 @item next
 @itemx prev
-The next sibling and previous sibling of this window.  @code{next} is
address@hidden if the window is the right-most or bottom-most in its group;
address@hidden is @code{nil} if it is the left-most or top-most in its
-group.  Whether the sibling is left/right or up/down is determined by
-the @code{horizontal} field: if it's non-zero, the siblings are
-arranged horizontally.
+The next and previous sibling of this window as Lisp objects.
address@hidden is @code{nil} if the window is the right-most or
+bottom-most in its group; @code{prev} is @code{nil} if it is the
+left-most or top-most in its group.  Whether the sibling is left/right
+or up/down is determined by the @code{horizontal} field of the
+sibling's parent: if it's non-zero, the siblings are arranged
+horizontally.
+
+As a special case, @code{next} of a frame's root window points to the
+frame's minibuffer window, provided this is not a minibuffer-only or
+minibuffer-less frame.  On such frames @code{prev} of the minibuffer
+window points to that frame's root window.  In any other case, the
+root window's @code{next} and the minibuffer window's (if present)
address@hidden fields are @code{nil}.
 
 @item left_col
 The left-hand edge of the window, measured in columns, relative to the
-leftmost column in the frame (column 0).
+leftmost column (column 0) of the window's native frame.
 
 @item top_line
 The top edge of the window, measured in lines, relative to the topmost
-line in the frame (line 0).
+line (line 0) of the window's native frame.
+
address@hidden pixel_left
address@hidden pixel_top
+The left-hand and top edges of this window, measured in pixels,
+relative to the top-left corner (0, 0) of the window's native frame.
 
 @item total_cols
 @itemx total_lines
-The width and height of the window, measured in columns and lines
-respectively.  The width includes the scroll bar and fringes, and/or
-the separator line on the right of the window (if any).
+The total width and height of the window, measured in columns and
+lines respectively.  The values include scroll bars and fringes,
+dividers and/or the separator line on the right of the window (if
+any).
 
address@hidden contents
-For leaf windows, this is the buffer, as a Lisp object, that the
-window is displaying.  For an internal (``parent'') window, this is
-its child window.  It can also be @code{nil}, for a pseudo-window.
address@hidden pixel_width;
address@hidden pixel_height;
+The total width and height of the window measured in pixels.
 
 @item start
 A marker pointing to the position in the buffer that is the first
@@ -2125,8 +2346,14 @@ in this window.
 A non-zero value means the window's buffer was modified when the
 window was last updated.
 
address@hidden vertical_scroll_bar
-This window's vertical scroll bar, a Lisp object.
address@hidden vertical_scroll_bar_type
address@hidden horizontal_scroll_bar_type
+The types of this window's vertical and horizontal scroll bars.
+
address@hidden scroll_bar_width
address@hidden scroll_bar_height
+The width of this window's vertical scroll bar and the height of this
+window's horizontal scroll bar, in pixels.
 
 @item left_margin_cols
 @itemx right_margin_cols
@@ -2210,6 +2437,14 @@ Vertical scroll amount, in pixels.  Normally, this is 0.
 @item dedicated
 address@hidden if this window is dedicated to its buffer.
 
address@hidden combination_limit
+This window's combination limit, meaningful only for a parent window.
+If this is @code{t}, then it is not allowed to delete this window and
+recombine its child windows with other siblings of this window.
+
address@hidden window_parameters
+The alist of this window's parameters.
+
 @item display_table
 The window's display table, or @code{nil} if none is specified for it.
 
@@ -2234,11 +2469,6 @@ the line number as long as the window shows that buffer.
 The column number currently displayed in this window's mode line, or
 @minus{}1 if column numbers are not being displayed.
 
address@hidden pseudo_window_p
-This is non-zero for windows that display the menu bar and the tool
-bar (when Emacs uses toolkits that don't display their own menu bar
-and tool bar).
-
 @item current_matrix
 @itemx desired_matrix
 Glyph matrices describing the current and desired display of this window.
diff --git a/doc/lispref/intro.texi b/doc/lispref/intro.texi
index 2353cf9..2596e87 100644
--- a/doc/lispref/intro.texi
+++ b/doc/lispref/intro.texi
@@ -1,6 +1,6 @@
 @c -*-coding: utf-8-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1994, 2001-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 1990-1994, 2001-2019 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 
 @node Introduction
diff --git a/doc/lispref/keymaps.texi b/doc/lispref/keymaps.texi
index d9d213d..6ad665a 100644
--- a/doc/lispref/keymaps.texi
+++ b/doc/lispref/keymaps.texi
@@ -1,6 +1,6 @@
 @c -*- mode: texinfo; coding: utf-8 -*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1994, 1998-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 1990-1994, 1998-2019 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Keymaps
 @chapter Keymaps
@@ -2502,7 +2502,7 @@ can do it this way:
 
   Emacs usually shows a @dfn{menu bar} at the top of each frame.
 @xref{Menu Bars,,,emacs, The GNU Emacs Manual}.  Menu bar items are
-subcommands of the fake function key @code{menu-bar}, as defined
+subcommands of the fake function key @key{MENU-BAR}, as defined
 in the active keymaps.
 
   To add an item to the menu bar, invent a fake function key of your
@@ -2554,9 +2554,10 @@ bar item:
 @end example
 
 @noindent
-Here, @code{edit} is the fake function key used by the global map for
-the @samp{Edit} menu bar item.  The main reason to suppress a global
-menu bar item is to regain space for mode-specific items.
+Here, @code{edit} is the symbol produced by a fake function key, it is
+used by the global map for the @samp{Edit} menu bar item.  The main
+reason to suppress a global menu bar item is to regain space for
+mode-specific items.
 
 @defvar menu-bar-final-items
 Normally the menu bar shows global items followed by items defined by the
@@ -2601,7 +2602,7 @@ If the value is @code{grow-only}, the tool bar expands 
automatically,
 but does not contract automatically.
 
   The tool bar contents are controlled by a menu keymap attached to a
-fake function key called @code{tool-bar} (much like the way the menu
+fake function key called @key{TOOL-BAR} (much like the way the menu
 bar is controlled).  So you define a tool bar item using
 @code{define-key}, like this:
 
diff --git a/doc/lispref/lay-flat.texi b/doc/lispref/lay-flat.texi
index da22159..1f12efe 100644
--- a/doc/lispref/lay-flat.texi
+++ b/doc/lispref/lay-flat.texi
@@ -1,6 +1,6 @@
 \input texinfo    @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 2001-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 2001-2019 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @c
 @comment %**start of header
diff --git a/doc/lispref/lists.texi b/doc/lispref/lists.texi
index 1548dd4..746b464 100644
--- a/doc/lispref/lists.texi
+++ b/doc/lispref/lists.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Lists
@@ -656,7 +656,7 @@ resulting list.  Instead, the sequence becomes the final 
@sc{cdr}, like
 any other non-list final argument.
 
 @defun copy-tree tree &optional vecp
-This function returns a copy of the tree @code{tree}.  If @var{tree} is a
+This function returns a copy of the tree @var{tree}.  If @var{tree} is a
 cons cell, this makes a new cons cell with the same @sc{car} and
 @sc{cdr}, then recursively copies the @sc{car} and @sc{cdr} in the
 same way.
@@ -667,8 +667,20 @@ address@hidden, it copies vectors too (and operates 
recursively on
 their elements).
 @end defun
 
address@hidden flatten-tree tree
+This function returns a ``flattened'' copy of @var{tree}, that is,
+a list containing all the address@hidden terminal nodes, or leaves, of
+the tree of cons cells rooted at @var{tree}.  Leaves in the returned
+list are in the same order as in @var{tree}.
address@hidden defun
+
address@hidden
+(flatten-tree '(1 (2 . 3) nil (4 5 (6)) 7))
+    @result{}(1 2 3 4 5 6 7)
address@hidden example
+
 @defun number-sequence from &optional to separation
-This returns a list of numbers starting with @var{from} and
+This function returns a list of numbers starting with @var{from} and
 incrementing by @var{separation}, and ending at or just before
 @var{to}.  @var{separation} can be positive or negative and defaults
 to 1.  If @var{to} is @code{nil} or numerically equal to @var{from},
diff --git a/doc/lispref/loading.texi b/doc/lispref/loading.texi
index 6f15cd9..6f1213f 100644
--- a/doc/lispref/loading.texi
+++ b/doc/lispref/loading.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Loading
diff --git a/doc/lispref/macros.texi b/doc/lispref/macros.texi
index dbd35b4..a422ba9 100644
--- a/doc/lispref/macros.texi
+++ b/doc/lispref/macros.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998, 2001-2018 Free Software 
Foundation,
address@hidden Copyright (C) 1990-1995, 1998, 2001-2019 Free Software 
Foundation,
 @c Inc.
 @c See the file elisp.texi for copying conditions.
 @node Macros
diff --git a/doc/lispref/maps.texi b/doc/lispref/maps.texi
index fc40f28..bcf8f17 100644
--- a/doc/lispref/maps.texi
+++ b/doc/lispref/maps.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1993, 1999, 2001-2018 Free Software 
Foundation,
address@hidden Copyright (C) 1990-1993, 1999, 2001-2019 Free Software 
Foundation,
 @c Inc.
 @c See the file elisp.texi for copying conditions.
 @node Standard Keymaps
diff --git a/doc/lispref/markers.texi b/doc/lispref/markers.texi
index 349ec12..27fe141 100644
--- a/doc/lispref/markers.texi
+++ b/doc/lispref/markers.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Markers
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi
index 5c66055..cfea336 100644
--- a/doc/lispref/minibuf.texi
+++ b/doc/lispref/minibuf.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Minibuffers
@@ -1108,11 +1108,11 @@ different function to completely override the normal 
behavior of
 in the minibuffer to do completion.
 
 @defvar minibuffer-completion-table
-The value of this variable is the completion table used for completion
-in the minibuffer.  This is the global variable that contains what
address@hidden passes to @code{try-completion}.  It is used by
-minibuffer completion commands such as
address@hidden
+The value of this variable is the completion table (@pxref{Basic
+Completion}) used for completion in the minibuffer.  This is the
+global variable that contains what @code{completing-read} passes to
address@hidden  It is used by minibuffer completion commands
+such as @code{minibuffer-complete-word}.
 @end defvar
 
 @defvar minibuffer-completion-predicate
@@ -1333,7 +1333,8 @@ is a string, @code{read-command} interns it before 
returning it.
 If it is a list, @code{read-command} interns the first element of this list.
 If @var{default} is @code{nil}, that means no default has been
 specified; then if the user enters null input, the return value is
address@hidden(intern "")}, that is, a symbol whose name is an empty string.
address@hidden(intern "")}, that is, a symbol whose name is an empty string,
+and whose printed representation is @code{##} (@pxref{Symbol Type}).
 
 @example
 (read-command "Command name? ")
@@ -1770,7 +1771,8 @@ possible match, and ignore the match if the predicate 
returns
 @code{nil}.
 
 @item
-A flag specifying the type of completion operation to perform.  This
+A flag specifying the type of completion operation to perform; see
address@hidden Completion}, for the details of those operations.  This
 flag may be one of the following values.
 
 @table @code
@@ -1841,17 +1843,26 @@ the same as for @code{display-sort-function}.
 
 @defun completion-table-dynamic function &optional switch-buffer
 This function is a convenient way to write a function that can act as
-a programmed completion function.  The argument @var{function} should be
-a function that takes one argument, a string, and returns an alist of
-possible completions of it.  It is allowed to ignore the argument and
-return a full list of all possible completions.  You can think of
address@hidden as a transducer between that interface
+a programmed completion function.  The argument @var{function} should
+be a function that takes one argument, a string, and returns a
+completion table (@pxref{Basic Completion}) containing all the
+possible completions.  The table returned by @var{function} can also
+include elements that don't match the string argument; they are
+automatically filtered out by @code{completion-table-dynamic}.  In
+particular, @var{function} can ignore its argument and return a full
+list of all possible completions.  You can think of
address@hidden as a transducer between @var{function}
 and the interface for programmed completion functions.
 
 If the optional argument @var{switch-buffer} is address@hidden, and
 completion is performed in the minibuffer, @var{function} will be
 called with current buffer set to the buffer from which the minibuffer
 was entered.
+
+The return value of @code{completion-table-dynamic} is a function that
+can be used as the 2nd argument to @code{try-completion} and
address@hidden  Note that this function will always return
+empty metadata and trivial boundaries (@pxref{Programmed Completion}).
 @end defun
 
 @defun completion-table-with-cache function &optional ignore-case
@@ -1876,9 +1887,10 @@ Emacs Manual}.  This command uses the abnormal hook 
variable
 
 @defvar completion-at-point-functions
 The value of this abnormal hook should be a list of functions, which
-are used to compute a completion table for completing the text at
-point.  It can be used by major modes to provide mode-specific
-completion tables (@pxref{Major Mode Conventions}).
+are used to compute a completion table (@pxref{Basic Completion}) for
+completing the text at point.  It can be used by major modes to
+provide mode-specific completion tables (@pxref{Major Mode
+Conventions}).
 
 When the command @code{completion-at-point} runs, it calls the
 functions in the list one by one, without any argument.  Each function
@@ -2391,6 +2403,25 @@ will not work.  If you want to prevent resizing of 
minibuffer windows
 when displaying long messages, bind the @code{message-truncate-lines}
 variable instead (@pxref{Echo Area Customization}).
 
+The option @code{resize-mini-windows} does not affect the behavior of
+minibuffer-only frames (@pxref{Frame Layout}).  The following option
+allows to automatically resize such frames as well.
+
address@hidden resize-mini-frames
+If this is @code{nil}, minibuffer-only frames are never resized
+automatically.
+
+If this is a function, that function is called with the
+minibuffer-only frame to be resized as sole argument.  At the time
+this function is called, the buffer of the minibuffer window of that
+frame is the buffer whose contents will be shown the next time that
+window is redisplayed.  The function is expected to fit the frame to
+the buffer in some appropriate way.
+
+Any other address@hidden value means to resize minibuffer-only frames
+by calling @code{fit-frame-to-buffer} (@pxref{Resizing Windows}).
address@hidden defopt
+
 
 @node Minibuffer Contents
 @section Minibuffer Contents
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index 49b7e1e..4315b70 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Modes
@@ -1015,6 +1015,29 @@ list-processes}).  The listing command should create or 
switch to a
 buffer, turn on the derived mode, specify the tabulated data, and
 finally call @code{tabulated-list-print} to populate the buffer.
 
address@hidden tabulated-list-gui-sort-indicator-asc
+This variable specifies the character to be used on GUI frames as an
+indication that the column is sorted in the ascending order.
+
+Whenever you change the sort direction in Tabulated List buffers, this
+indicator toggles between ascending (``asc'') and descending (``desc'').
address@hidden defopt
+
address@hidden tabulated-list-gui-sort-indicator-desc
+Like @code{tabulated-list-gui-sort-indicator-asc}, but used when the
+column is sorted in the descending order.
address@hidden defopt
+
address@hidden tabulated-list-tty-sort-indicator-asc
+Like @code{tabulated-list-gui-sort-indicator-asc}, but used for
+text-mode frames.
address@hidden defopt
+
address@hidden tabulated-list-tty-sort-indicator-desc
+Like @code{tabulated-list-tty-sort-indicator-asc}, but used when the
+column is sorted in the descending order.
address@hidden defopt
+
 @defvar tabulated-list-format
 This buffer-local variable specifies the format of the Tabulated List
 data.  Its value should be a vector.  Each element of the vector
@@ -1121,6 +1144,65 @@ that tags placed via @code{tabulated-list-put-tag} will 
not be removed
 from entries that haven't changed (normally all tags are removed).
 @end defun
 
address@hidden tabulated-list-delete-entry
+This function deletes the entry at point.
+
+It returns a list @code{(@var{id} @var{cols})}, where @var{id} is the
+ID of the deleted entry and @var{cols} is a vector of its column
+descriptors.  It moves point to the beginning of the current line.  It
+returns @code{nil} if there is no entry at point.
+
+Note that this function only changes the buffer contents; it does not
+alter @code{tabulated-list-entries}.
address@hidden defun
+
address@hidden tabulated-list-get-id &optional pos
+This @code{defsubst} returns the ID object from
address@hidden (if that is a list) or from the list
+returned by @code{tabulated-list-entries} (if it is a function).  If
+omitted or @code{nil}, @var{pos} defaults to point.
address@hidden defun
+
address@hidden tabulated-list-get-entry &optional pos
+This @code{defsubst} returns the entry object from
address@hidden (if that is a list) or from the list
+returned by @code{tabulated-list-entries} (if it is a function).  This
+will be a vector for the ID at @var{pos}.  If there is no entry at
address@hidden, then the function returns @code{nil}.
address@hidden defun
+
address@hidden tabulated-list-use-header-line
address@hidden tabulated-list-header-overlay-p &optional POS
+This @code{defsubst} returns non-nil if there is a fake header at
address@hidden  A fake header is used if
address@hidden is @code{nil} to put the column
+names at the beginning of the buffer.  If omitted or @code{nil},
address@hidden defaults to @code{point-min}.
address@hidden defun
+
address@hidden tabulated-list-padding
address@hidden tabulated-list-put-tag tag &optional advance
+This function puts @var{tag} in the padding area of the current line.
+The padding area can be empty space at the beginning of the line, the
+width of which is governed by @code{tabulated-list-padding}.
address@hidden should be a string, with a length less than or equal to
address@hidden  If @var{advance} is non-nil, this
+function advances point by one line.
address@hidden defun
+
address@hidden tabulated-list-set-col col desc &optional change-entry-data
+This function changes the tabulated list entry at point, setting
address@hidden to @var{desc}.  @var{col} is the column number to change, or
+the name of the column to change.  @var{desc} is the new column
+descriptor, which is inserted via @code{tabulated-list-print-col}.
+
+If @var{change-entry-data} is non-nil, this function modifies the
+underlying data (usually the column descriptor in the list
address@hidden) by setting the column descriptor of the
+vector to @code{desc}.
address@hidden defun
+
+
 @node Generic Modes
 @subsection Generic Modes
 @cindex generic mode
@@ -1178,6 +1260,7 @@ the conventions listed above:
     (modify-syntax-entry ?\\ ".   " st)
     ;; Add 'p' so M-c on 'hello' leads to 'Hello', not 'hello'.
     (modify-syntax-entry ?' "w p" st)
+    @dots{}
     st)
   "Syntax table used while in `text-mode'.")
 @end group
@@ -1187,6 +1270,7 @@ the conventions listed above:
 (defvar text-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map "\e\t" 'ispell-complete-word)
+    @dots{}
     map)
   "Keymap for `text-mode'.
 Many other modes, such as `mail-mode', `outline-mode' and
@@ -1207,17 +1291,11 @@ You can thus get the full benefit of adaptive filling
 Turning on Text mode runs the normal hook `text-mode-hook'."
 @end group
 @group
-  (set (make-local-variable 'text-mode-variant) t)
-  (set (make-local-variable 'require-final-newline)
-       mode-require-final-newline)
-  (set (make-local-variable 'indent-line-function) 'indent-relative))
+  (setq-local text-mode-variant t)
+  (setq-local require-final-newline mode-require-final-newline))
 @end group
 @end smallexample
 
address@hidden
-(The last line is redundant nowadays, since @code{indent-relative} is
-the default value, and we'll delete it in a future version.)
-
 @cindex @file{lisp-mode.el}
   The three Lisp modes (Lisp mode, Emacs Lisp mode, and Lisp Interaction
 mode) have more features than Text mode and the code is correspondingly
@@ -1230,11 +1308,11 @@ illustrate how these modes are written.
 @smallexample
 @group
 ;; @r{Create mode-specific table variables.}
-(defvar lisp-mode-abbrev-table nil)
-(define-abbrev-table 'lisp-mode-abbrev-table ())
+(define-abbrev-table 'lisp-mode-abbrev-table ()
+  "Abbrev table for Lisp mode.")
 
 (defvar lisp-mode-syntax-table
-  (let ((table (copy-syntax-table emacs-lisp-mode-syntax-table)))
+  (let ((table (make-syntax-table lisp--mode-syntax-table)))
     (modify-syntax-entry ?\[ "_   " table)
     (modify-syntax-entry ?\] "_   " table)
     (modify-syntax-entry ?# "' 14" table)
@@ -1249,10 +1327,9 @@ each calls the following function to set various 
variables:
 
 @smallexample
 @group
-(defun lisp-mode-variables (&optional syntax keywords-case-insensitive)
+(defun lisp-mode-variables (&optional syntax keywords-case-insensitive elisp)
   (when syntax
     (set-syntax-table lisp-mode-syntax-table))
-  (setq local-abbrev-table lisp-mode-abbrev-table)
   @dots{}
 @end group
 @end smallexample
@@ -1263,8 +1340,7 @@ variable to handle Lisp comments:
 
 @smallexample
 @group
-  (make-local-variable 'comment-start)
-  (setq comment-start ";")
+  (setq-local comment-start ";")
   @dots{}
 @end group
 @end smallexample
@@ -1278,6 +1354,7 @@ common.  The following code sets up the common commands:
 @group
 (defvar lisp-mode-shared-map
   (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map prog-mode-map)
     (define-key map "\e\C-q" 'indent-sexp)
     (define-key map "\177" 'backward-delete-char-untabify)
     map)
@@ -1292,7 +1369,7 @@ And here is the code to set up the keymap for Lisp mode:
 @group
 (defvar lisp-mode-map
   (let ((map (make-sparse-keymap))
-       (menu-map (make-sparse-keymap "Lisp")))
+        (menu-map (make-sparse-keymap "Lisp")))
     (set-keymap-parent map lisp-mode-shared-map)
     (define-key map "\e\C-x" 'lisp-eval-defun)
     (define-key map "\C-c\C-z" 'run-lisp)
@@ -1316,17 +1393,13 @@ Blank lines separate paragraphs.  Semicolons start 
comments.
 
 address@hidden@}
 Note that `run-lisp' may be used either to start an inferior Lisp job
-or to switch back to an existing one.
+or to switch back to an existing one."
 @end group
-
 @group
-Entry to this mode calls the value of `lisp-mode-hook'
-if that value is non-nil."
   (lisp-mode-variables nil t)
-  (set (make-local-variable 'find-tag-default-function)
-       'lisp-find-tag-default)
-  (set (make-local-variable 'comment-start-skip)
-       "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *")
+  (setq-local find-tag-default-function 'lisp-find-tag-default)
+  (setq-local comment-start-skip
+              "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\)\\(;+\\|#|\\) *")
   (setq imenu-case-fold-search t))
 @end group
 @end smallexample
@@ -1366,7 +1439,7 @@ The value of this variable is a list of all minor mode 
commands.
 @cindex conventions for writing minor modes
 
   There are conventions for writing minor modes just as there are for
-major modes.  These conventions are described below.  The easiest way to
+major modes (@pxref{Major Modes}).  These conventions are described below.  
The easiest way to
 follow them is to use the macro @code{define-minor-mode}.
 @xref{Defining Minor Modes}.
 
@@ -1477,10 +1550,10 @@ or like this, using @code{add-to-list} (@pxref{List 
Variables}):
 @end smallexample
 @end itemize
 
-  In addition, several major mode conventions apply to minor modes as
-well: those regarding the names of global symbols, the use of a hook at
-the end of the initialization function, and the use of keymaps and other
-tables.
+  In addition, several major mode conventions (@pxref{Major Mode
+Conventions}) apply to minor modes as well: those regarding the names
+of global symbols, the use of a hook at the end of the initialization
+function, and the use of keymaps and other tables.
 
   The minor mode should, if possible, support enabling and disabling via
 Custom (@pxref{Customization}).  To do this, the mode variable should be
diff --git a/doc/lispref/nonascii.texi b/doc/lispref/nonascii.texi
index 9fb5587..9c64c3c 100644
--- a/doc/lispref/nonascii.texi
+++ b/doc/lispref/nonascii.texi
@@ -1,6 +1,6 @@
 @c -*- mode: texinfo; coding: utf-8 -*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1998-1999, 2001-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 1998-1999, 2001-2019 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Non-ASCII Characters
 @chapter address@hidden Characters
@@ -287,12 +287,11 @@ unibyte string, it is returned unchanged.  Use this 
function for
 characters.
 @end defun
 
address@hidden FIXME: Should '@var{character}' be '@var{byte}'?
 @defun byte-to-string byte
 @cindex byte to string
 This function returns a unibyte string containing a single byte of
-character data, @var{character}.  It signals an error if
address@hidden is not an integer between 0 and 255.
+character data, @var{byte}.  It signals an error if @var{byte} is not
+an integer between 0 and 255.
 @end defun
 
 @defun multibyte-char-to-unibyte char
@@ -1379,7 +1378,7 @@ operates on the contents of @var{string} instead of bytes 
in the buffer.
 @end defun
 
 @cindex null bytes, and decoding text
address@hidden inhibit-null-byte-detection
address@hidden inhibit-nul-byte-detection
 If this variable has a address@hidden value, null bytes are ignored
 when detecting the encoding of a region or a string.  This allows the
 encoding of text that contains null bytes to be correctly detected,
@@ -1633,11 +1632,16 @@ coding system for a file based on its undecoded 
contents.
 
 Each function in this list should be written to look at text in the
 current buffer, but should not modify it in any way.  The buffer will
-contain undecoded text of parts of the file.  Each function should
-take one argument, @var{size}, which tells it how many characters to
-look at, starting from point.  If the function succeeds in determining
-a coding system for the file, it should return that coding system.
-Otherwise, it should return @code{nil}.
+contain the text of parts of the file.  Each function should take one
+argument, @var{size}, which tells it how many characters to look at,
+starting from point.  If the function succeeds in determining a coding
+system for the file, it should return that coding system.  Otherwise,
+it should return @code{nil}.
+
+The functions in this list could be called either when the file is
+visited and Emacs wants to decode its contents, and/or when the file's
+buffer is about to be saved and Emacs wants to determine how to encode
+its contents.
 
 If a file has a @samp{coding:} tag, that takes precedence, so these
 functions won't be called.
@@ -2116,9 +2120,9 @@ Return a 12-element vector of month names (locale items 
@code{MON_1}
 through @code{MON_12}).
 
 @item paper
-Return a list @code{(@var{width} @var{height})} for the default paper
-size measured in millimeters (locale items @code{PAPER_WIDTH} and
address@hidden).
+Return a list @address@hidden(@var{width} @var{height})}} of 2 integers, for
+the default paper size measured in millimeters (locale items
address@hidden and @code{_NL_PAPER_HEIGHT}).
 @end table
 
 If the system can't provide the requested information, or if
diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi
index d031136..fbdd83f 100644
--- a/doc/lispref/numbers.texi
+++ b/doc/lispref/numbers.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Numbers
@@ -313,14 +313,18 @@ and returns the result.  @var{x1} and @var{x2} must be 
floating point.
 
 @defun logb x
 This function returns the binary exponent of @var{x}.  More
-precisely, the value is the logarithm base 2 of @math{|x|}, rounded
-down to an integer.
+precisely, if @var{x} is finite and nonzero, the value is the
+logarithm base 2 of @math{|x|}, rounded down to an integer.
+If @var{x} is zero, infinite, or a NaN, the value is minus infinity,
+plus infinity, or a NaN respectively.
 
 @example
 (logb 10)
      @result{} 3
 (logb 10.0e20)
      @result{} 69
+(logb 0)
+     @result{} -1.0e+INF
 @end example
 @end defun
 
diff --git a/doc/lispref/objects.texi b/doc/lispref/objects.texi
index a094003..745baac 100644
--- a/doc/lispref/objects.texi
+++ b/doc/lispref/objects.texi
@@ -1,6 +1,6 @@
 @c -*- mode: texinfo; coding: utf-8 -*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Lisp Data Types
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index 4175385..59cd5a8 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node System Interface
@@ -1313,9 +1313,10 @@ This function returns the current time and date as a 
human-readable
 string.  The format does not vary for the initial part of the string,
 which contains the day of week, month, day of month, and time of day
 in that order: the number of characters used for these fields is
-always the same, so you can reliably
-use @code{substring} to extract them.  You should count
-characters from the beginning of the string rather than from the end,
+always the same, although (unless you require English weekday or
+month abbreviations regardless of locale) it is typically more
+convenient to use @code{format-time-string} than to extract
+fields from the output of @code{current-time-string},
 as the year might not have exactly four digits, and additional
 information may some day be added at the end.
 
@@ -1543,7 +1544,28 @@ Time values include @code{nil}, numbers, and Lisp 
timestamps
 
 @defun date-to-time string
 This function parses the time-string @var{string} and returns the
-corresponding Lisp timestamp.
+corresponding Lisp timestamp.  The argument @var{string} should represent
+a date-time, and should be in one of the forms recognized by
address@hidden (see below).  This function assumes the GMT
+timezone if @var{string} lacks an explicit timezone information.
address@hidden defun
+
address@hidden parse-time-string string
+This function parses the time-string @var{string} into a list of the
+following form:
+
address@hidden
+(@var{sec} @var{min} @var{hour} @var{day} @var{mon} @var{year} @var{dow} 
@var{dst} @var{tz})
address@hidden example
+
address@hidden
+The format of this list is the same as what @code{decode-time} accepts
+(@pxref{Time Conversion}), and is described in more detail there.  Any
+element that cannot be determined from the input will be set to
address@hidden  The argument @var{string} should resemble an RFC 822 (or later) 
or
+ISO 8601 string, like ``Fri, 25 Mar 2016 16:24:56 +0100'' or
+``1998-09-12T12:21:54-0200'', but this function will attempt to parse
+less well-formed time strings as well.
 @end defun
 
 @defun format-time-string format-string &optional time zone
@@ -1578,7 +1600,9 @@ This is a synonym for @samp{%m/%d/%y}.
 @item %e
 This stands for the day of month, blank-padded.
 @item %F
-This stands for the ISO 8601 date format, i.e., @samp{"%Y-%m-%d"}.
+This stands for the ISO 8601 date format, which is like
address@hidden except that any flags or field width override the
address@hidden and (after subtracting 6) the @samp{4}.
 @item %g
 This stands for the year corresponding to the ISO week within the century.
 @item %G
@@ -1658,7 +1682,9 @@ This stands for a single @samp{%}.
 @end table
 
 One or more flag characters can appear immediately after the @samp{%}.
address@hidden pads with zeros, @samp{_} pads with blanks, @samp{-}
address@hidden pads with zeros, @samp{+} pads with zeros and also puts
address@hidden before nonnegative year numbers with more than four digits,
address@hidden pads with blanks, @samp{-}
 suppresses padding, @samp{^} upper-cases letters, and @samp{#}
 reverses the case of letters.
 
diff --git a/doc/lispref/package.texi b/doc/lispref/package.texi
index 37c1ee6..7244efb 100644
--- a/doc/lispref/package.texi
+++ b/doc/lispref/package.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 2010-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 2010-2019 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Packaging
 @chapter Preparing Lisp code for distribution
@@ -22,6 +22,7 @@ user-level features of the packaging system.
 * Simple Packages::         How to package a single .el file.
 * Multi-file Packages::     How to package multiple files.
 * Package Archives::        Maintaining package archives.
+* Archive Web Server::      Interfacing to an archive web server.
 @end menu
 
 @node Packaging Basics
@@ -249,7 +250,8 @@ dependency's version (a string).
 @end defun
 
   If the content directory contains a file named @file{README}, this
-file is used as the long description.
+file is used as the long description (overriding any @samp{;;;
+Commentary:} section).
 
   If the content directory contains a file named @file{dir}, this is
 assumed to be an Info directory file made with @command{install-info}.
@@ -311,8 +313,8 @@ access.  Such local archives are mainly useful for testing.
 
   A package archive is simply a directory in which the package files,
 and associated files, are stored.  If you want the archive to be
-reachable via HTTP, this directory must be accessible to a web server.
-How to accomplish this is beyond the scope of this manual.
+reachable via HTTP, this directory must be accessible to a web server;
address@hidden Web Server}.
 
   A convenient way to set up and update a package archive is via the
 @code{package-x} library.  This is included with Emacs, but not loaded
@@ -393,3 +395,28 @@ manual.  For more information on cryptographic keys and 
signing,
 @pxref{Top,, GnuPG, gnupg, The GNU Privacy Guard Manual}.  Emacs comes
 with an interface to GNU Privacy Guard, @pxref{Top,, EasyPG, epa,
 Emacs EasyPG Assistant Manual}.
+
address@hidden Archive Web Server
address@hidden Interfacing to an archive web server
address@hidden archive web server
+
+A web server providing access to a package archive must support the
+following queries:
+
address@hidden @asis
address@hidden archive-contents
+Return a lisp form describing the archive contents. The form is a list
+of 'package-desc' structures (see @file{package.el}), except the first
+element of the list is the archive version.
+
address@hidden <package name>-readme.txt
+Return the long description of the package.
+
address@hidden <file name>.sig
+Return the signature for the file.
+
address@hidden <file name>
+Return the file. This will be the tarball for a multi-file
+package, or the single file for a simple package.
+
address@hidden table
diff --git a/doc/lispref/positions.texi b/doc/lispref/positions.texi
index a09b6b6..527a3ab 100644
--- a/doc/lispref/positions.texi
+++ b/doc/lispref/positions.texi
@@ -1,6 +1,6 @@
 @c -*- mode: texinfo; coding: utf-8 -*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 1990-1995, 1998-2019 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Positions
 @chapter Positions
diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi
index d88c7fb..69f781e 100644
--- a/doc/lispref/processes.texi
+++ b/doc/lispref/processes.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Processes
@@ -423,27 +423,27 @@ be found in the definition of the @code{insert-directory} 
function:
 
 @defun process-file program &optional infile buffer display &rest args
 This function processes files synchronously in a separate process.  It
-is similar to @code{call-process}, but may invoke a file handler based
-on the value of the variable @code{default-directory}, which specifies
-the current working directory of the subprocess.
+is similar to @code{call-process}, but may invoke a file name handler
+based on the value of the variable @code{default-directory}, which
+specifies the current working directory of the subprocess.
 
 The arguments are handled in almost the same way as for
 @code{call-process}, with the following differences:
 
-Some file handlers may not support all combinations and forms of the
+Some file name handlers may not support all combinations and forms of the
 arguments @var{infile}, @var{buffer}, and @var{display}.  For example,
-some file handlers might behave as if @var{display} were @code{nil},
+some file name handlers might behave as if @var{display} were @code{nil},
 regardless of the value actually passed.  As another example, some
-file handlers might not support separating standard output and error
+file name handlers might not support separating standard output and error
 output by way of the @var{buffer} argument.
 
-If a file handler is invoked, it determines the program to run based
+If a file name handler is invoked, it determines the program to run based
 on the first argument @var{program}.  For instance, suppose that a
 handler for remote files is invoked.  Then the path that is used for
 searching for the program might be different from @code{exec-path}.
 
-The second argument @var{infile} may invoke a file handler.  The file
-handler could be different from the handler chosen for the
+The second argument @var{infile} may invoke a file name handler.  The file
+name handler could be different from the handler chosen for the
 @code{process-file} function itself.  (For example,
 @code{default-directory} could be on one remote host, and
 @var{infile} on a different remote host.  Or @code{default-directory}
@@ -459,7 +459,9 @@ present in @var{args}.  To avoid confusion, it may be best 
to avoid
 absolute file names in @var{args}, but rather to specify all file
 names as relative to @code{default-directory}.  The function
 @code{file-relative-name} is useful for constructing such relative
-file names.
+file names.  Alternatively, you can use @code{file-local-name}
+(@pxref{Magic File Names}) to obtain an absolute file name as seen
+from the remote host's perspective.
 @end defun
 
 @defvar process-file-side-effects
@@ -468,7 +470,7 @@ remote files.
 
 By default, this variable is always set to @code{t}, meaning that a
 call of @code{process-file} could potentially change any file on a
-remote host.  When set to @code{nil}, a file handler could optimize
+remote host.  When set to @code{nil}, a file name handler could optimize
 its behavior with respect to remote file attribute caching.
 
 You should only ever change this variable with a let-binding; never
@@ -612,10 +614,9 @@ these features.  However, for subprocesses used by Lisp 
programs for
 internal purposes (i.e., no user interaction with the subprocess is
 required), where significant amounts of data need to be exchanged
 between the subprocess and the Lisp program, it is often better to use
-a pipe, because pipes are more efficient, and because they are immune
-to stray character injections that ptys introduce for large (around
-500 byte) messages.  Also, the total number of ptys is limited on many
-systems, and it is good not to waste them unnecessarily.
+a pipe, because pipes are more efficient.  Also, the total number of
+ptys is limited on many systems, and it is good not to waste them
+unnecessarily.
 
 @defun make-process &rest args
 This function is the basic low-level primitive for starting
@@ -677,8 +678,11 @@ Initialize the process query flag to @var{query-flag}.
 @xref{Query Before Exit}.
 
 @item :stop @var{stopped}
-If @var{stopped} is address@hidden, start the process in the
-stopped state.
+If provided, @var{stopped} must be @code{nil}; it is an error to use
+any address@hidden value.  The @code{:stop} key is ignored otherwise
+and is retained for compatibility with other process types such as
+pipe processes.  Asynchronous subprocesses never start in the stopped
+state.
 
 @item :filter @var{filter}
 Initialize the process filter to @var{filter}.  If not specified, a
@@ -696,6 +700,25 @@ address@hidden value should be either a buffer or a pipe 
process
 created with @code{make-pipe-process}, described below.  If
 @var{stderr} is @code{nil}, standard error is mixed with standard
 output, and both are sent to @var{buffer} or @var{filter}.
+
address@hidden standard error process
+If @var{stderr} is a buffer, Emacs will create a pipe process, the
address@hidden error process}.  This process will have the default
+filter (@pxref{Filter Functions}), sentinel (@pxref{Sentinels}), and
+coding systems (@pxref{Default Coding Systems}).  On the other hand,
+it will use @var{query-flag} as its query-on-exit flag (@pxref{Query
+Before Exit}).  It will be associated with the @var{stderr} buffer
+(@pxref{Process Buffers}) and send its output (which is the standard
+error of the main process) there.
+
+If @var{stderr} is a pipe process, Emacs will use it as standard error
+process for the new process.
+
address@hidden :file-handler @var{file-handler}
+If @var{file-handler} is address@hidden, then look for a file name
+handler for the current buffer's @code{default-directory}, and invoke
+that file name handler to make the process.  If there is no such
+handler, proceed as if @var{file-handler} were @code{nil}.
 @end table
 
 The original argument list, modified with the actual connection
@@ -703,9 +726,22 @@ information, is available via the @code{process-contact} 
function.
 
 The current working directory of the subprocess is set to the current
 buffer's value of @code{default-directory} if that is local (as
-determined by `unhandled-file-name-directory'), or "~" otherwise.  If
-you want to run a process in a remote directory use
address@hidden
+determined by @code{unhandled-file-name-directory}), or @file{~}
+otherwise.  If you want to run a process in a remote directory, pass
address@hidden:file-handler t} to @code{make-process}.  In that case, the
+current working directory is the local name component of
address@hidden (as determined by @code{file-local-name}).
+
+Depending on the implementation of the file name handler, it might not
+be possible to apply @var{filter} or @var{sentinel} to the resulting
+process object.  The @code{:stderr} argument cannot be a pipe process,
+file name handlers do not support pipe processes for this.  A buffer
+as @code{:stderr} argument is accepted, its contents is shown without
+the use of pipe processes.  @xref{Filter Functions}, @ref{Sentinels},
+and @ref{Accepting Output}.
+
+Some file name handlers may not support @code{make-process}.  In such
+cases, this function does nothing and returns @code{nil}.
 @end defun
 
 @defun make-pipe-process &rest args
@@ -821,22 +857,27 @@ subprocess running @var{program} in it, and returns its 
process
 object.
 
 The difference from @code{start-process} is that this function may
-invoke a file handler based on the value of @code{default-directory}.
+invoke a file name handler based on the value of @code{default-directory}.
 This handler ought to run @var{program}, perhaps on the local host,
 perhaps on a remote host that corresponds to @code{default-directory}.
 In the latter case, the local part of @code{default-directory} becomes
 the working directory of the process.
 
 This function does not try to invoke file name handlers for
address@hidden or for the rest of @var{args}.
-
-Depending on the implementation of the file handler, it might not be
address@hidden or for the rest of @var{args}.  For that reason, if
address@hidden or any of @var{args} use the remote-file syntax
+(@pxref{Magic File Names}), they must be converted either to file
+names relative to @code{default-directory}, or to names that identify
+the files locally on the remote host, by running them through
address@hidden
+
+Depending on the implementation of the file name handler, it might not be
 possible to apply @code{process-filter} or @code{process-sentinel} to
 the resulting process object.  @xref{Filter Functions}, and @ref{Sentinels}.
 
 @c FIXME  Can we find a better example (i.e., a more modern function
 @c that is actually documented).
-Some file handlers may not support @code{start-file-process} (for
+Some file name handlers may not support @code{start-file-process} (for
 example the function @code{ange-ftp-hook-function}).  In such cases,
 this function does nothing and returns @code{nil}.
 @end defun
@@ -1768,7 +1809,7 @@ system comes from @code{coding-system-for-read}, if that 
is
 address@hidden; or else from the defaulting mechanism (@pxref{Default
 Coding Systems}).  If the text output by a process contains null
 bytes, Emacs by default uses @code{no-conversion} for it; see
address@hidden and Coding Systems, inhibit-null-byte-detection}, for how to
address@hidden and Coding Systems, inhibit-nul-byte-detection}, for how to
 control this behavior.
 
   @strong{Warning:} Coding systems such as @code{undecided}, which
@@ -1806,7 +1847,8 @@ until output arrives from a process.
 This function allows Emacs to read pending output from processes.  The
 output is given to their filter functions.  If @var{process} is
 address@hidden then this function does not return until some output
-has been received from @var{process}.
+has been received from @var{process} or @var{process} has closed the
+connection.
 
 The arguments @var{seconds} and @var{millisec} let you specify timeout
 periods.  The former specifies a period measured in seconds and the
@@ -1831,10 +1873,48 @@ speech synthesis.
 
 The function @code{accept-process-output} returns address@hidden if it
 got output from @var{process}, or from any process if @var{process} is
address@hidden  It returns @code{nil} if the timeout expired before output
address@hidden; this can occur even after a process has exited if the
+corresponding connection contains buffered data.  The function returns
address@hidden if the timeout expired or the connection was closed before output
 arrived.
 @end defun
 
+If a connection from a process contains buffered data,
address@hidden can return address@hidden even after the
+process has exited.  Therefore, although the following loop:
+
address@hidden
+;; This loop contains a bug.
+(while (process-live-p process)
+  (accept-process-output process))
address@hidden example
+
address@hidden
+will often read all output from @var{process}, it has a race condition
+and can miss some output if @code{process-live-p} returns @code{nil}
+while the connection still contains data.  Better is to write the loop
+like this:
+
address@hidden
+(while (accept-process-output process))
address@hidden example
+
+If you have passed a address@hidden @var{stderr} to
address@hidden, it will have a standard error process.
address@hidden Processes}.  In that case, waiting for process
+output from the main process doesn't wait for output from the standard
+error process.  To make sure you have received both all of standard
+output and all of standard error from a process, use the following
+code:
+
address@hidden
+(while (accept-process-output process))
+(while (accept-process-output stderr-process))
address@hidden example
+
+Reading pending standard error from a process running on a remote host
+is not possible this way.
+
 @node Processes and Threads
 @subsection Processes and Threads
 @cindex processes, threads
@@ -2596,7 +2676,9 @@ Specify the host to connect to.  @var{host} should be a 
host name or
 Internet address, as a string, or the symbol @code{local} to specify
 the local host.  If you specify @var{host} for a server, it must
 specify a valid address for the local host, and only clients
-connecting to that address will be accepted.
+connecting to that address will be accepted.  When using @code{local},
+by default IPv4 will be used, specify a @var{family} of @code{ipv6} to
+override this.
 
 @item :service @var{service}
 @var{service} specifies a port number to connect to; or, for a server,
diff --git a/doc/lispref/records.texi b/doc/lispref/records.texi
index 81a5234..3a89b68 100644
--- a/doc/lispref/records.texi
+++ b/doc/lispref/records.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 2017-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 2017-2019 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Records
 @chapter Records
diff --git a/doc/lispref/searching.texi b/doc/lispref/searching.texi
index 1b6b80d..8775254 100644
--- a/doc/lispref/searching.texi
+++ b/doc/lispref/searching.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Searching and Matching
@@ -391,39 +391,9 @@ writing the starting and ending characters with a @samp{-} 
between them.
 Thus, @samp{[a-z]} matches any lower-case @acronym{ASCII} letter.
 Ranges may be intermixed freely with individual characters, as in
 @samp{[a-z$%.]}, which matches any lower case @acronym{ASCII} letter
-or @samp{$}, @samp{%} or period.
-
-If @code{case-fold-search} is address@hidden, @samp{[a-z]} also
-matches upper-case letters.  Note that a range like @samp{[a-z]} is
-not affected by the locale's collation sequence, it always represents
-a sequence in @acronym{ASCII} order.
address@hidden This wasn't obvious to me, since, e.g., the grep manual 
"Character
address@hidden Classes and Bracket Expressions" specifically notes the opposite
address@hidden behavior.  But by experiment Emacs seems unaffected by LC_COLLATE
address@hidden in this regard.
-
-Note also that the usual regexp special characters are not special inside a
-character alternative.  A completely different set of characters is
-special inside character alternatives: @samp{]}, @samp{-} and @samp{^}.
-
-To include a @samp{]} in a character alternative, you must make it the
-first character.  For example, @samp{[]a]} matches @samp{]} or @samp{a}.
-To include a @samp{-}, write @samp{-} as the first or last character of
-the character alternative, or put it after a range.  Thus, @samp{[]-]}
-matches both @samp{]} and @samp{-}.  (As explained below, you cannot
-use @samp{\]} to include a @samp{]} inside a character alternative,
-since @samp{\} is not special there.)
-
-To include @samp{^} in a character alternative, put it anywhere but at
-the beginning.
-
address@hidden What if it starts with a multibyte and ends with a unibyte?
address@hidden That doesn't seem to match anything...?
-If a range starts with a unibyte character @var{c} and ends with a
-multibyte character @var{c2}, the range is divided into two parts: one
-spans the unibyte characters @address@hidden, the other the
-multibyte characters @address@hidden@var{c2}}, where @var{c1} is the
-first character of the charset to which @var{c2} belongs.
+or @samp{$}, @samp{%} or period.  However, the ending character of one
+range should not be the starting point of another one; for example,
address@hidden should be avoided.
 
 A character alternative can also specify named character classes
 (@pxref{Char Classes}).  This is a POSIX feature.  For example,
@@ -431,12 +401,80 @@ A character alternative can also specify named character 
classes
 Using a character class is equivalent to mentioning each of the
 characters in that class; but the latter is not feasible in practice,
 since some classes include thousands of different characters.
+A character class should not appear as the lower or upper bound
+of a range.
+
+The usual regexp special characters are not special inside a
+character alternative.  A completely different set of characters is
+special: @samp{]}, @samp{-} and @samp{^}.
+To include @samp{]} in a character alternative, put it at the
+beginning.  To include @samp{^}, put it anywhere but at the beginning.
+To include @samp{-}, put it at the end.  Thus, @samp{[]^-]} matches
+all three of these special characters.  You cannot use @samp{\} to
+escape these three characters, since @samp{\} is not special here.
+
+The following aspects of ranges are specific to Emacs, in that POSIX
+allows but does not require this behavior and programs other than
+Emacs may behave differently:
+
address@hidden
address@hidden
+If @code{case-fold-search} is address@hidden, @samp{[a-z]} also
+matches upper-case letters.
+
address@hidden
+A range is not affected by the locale's collation sequence: it always
+represents the set of characters with codepoints ranging between those
+of its bounds, so that @samp{[a-z]} matches only ASCII letters, even
+outside the C or POSIX locale.
+
address@hidden
+If the lower bound of a range is greater than its upper bound, the
+range is empty and represents no characters.  Thus, @samp{[z-a]}
+always fails to match, and @samp{[^z-a]} matches any character,
+including newline.  However, a reversed range should always be from
+the letter @samp{z} to the letter @samp{a} to make it clear that it is
+not a typo; for example, @samp{[+-*/]} should be avoided, because it
+matches only @samp{/} rather than the likely-intended four characters.
address@hidden enumerate
+
+Some kinds of character alternatives are not the best style even
+though they have a well-defined meaning in Emacs.  They include:
+
address@hidden
address@hidden
+Although a range's bound can be almost any character, it is better
+style to stay within natural sequences of ASCII letters and digits
+because most people have not memorized character code tables.
+For example, @samp{[.-9]} is less clear than @samp{[./0-9]},
+and @samp{[`-~]} is less clear than @address@hidden|@}~]}.
+Unicode character escapes can help here; for example, for most programmers
address@hidden is less clear than @samp{[\u0E01-\u0E3A\u0E3F-\u0E5B]}.
+
address@hidden
+Although a character alternative can include duplicates, it is better
+style to avoid them.  For example, @samp{[XYa-yYb-zX]} is less clear
+than @samp{[XYa-z]}.
+
address@hidden
+Although a range can denote just one, two, or three characters, it
+is simpler to list the characters.  For example,
address@hidden is less clear than @samp{[a0]}, @samp{[i-j]} is less clear
+than @samp{[ij]}, and @samp{[i-k]} is less clear than @samp{[ijk]}.
+
address@hidden
+Although a @samp{-} can appear at the beginning of a character
+alternative or as the upper bound of a range, it is better style to
+put @samp{-} by itself at the end of a character alternative.  For
+example, although @samp{[-a-z]} is valid, @samp{[a-z-]} is better
+style; and although @samp{[*--]} is valid, @samp{[*+,-]} is clearer.
address@hidden enumerate
 
 @item @samp{[^ @dots{} ]}
 @cindex @samp{^} in regexp
 @samp{[^} begins a @dfn{complemented character alternative}.  This
 matches any character except the ones specified.  Thus,
address@hidden matches all characters @emph{except} letters and
address@hidden matches all characters @emph{except} ASCII letters and
 digits.
 
 @samp{^} is not special in a character alternative unless it is the first
@@ -559,7 +597,7 @@ tabs, and other characters whose Unicode 
@samp{general-category}
 property (@pxref{Character Properties}) indicates they are spacing
 separators.
 @item [:cntrl:]
-This matches any @acronym{ASCII} control character.
+This matches any character whose code is in the range 0--31.
 @item [:digit:]
 This matches @samp{0} through @samp{9}.  Thus, @samp{[-+[:digit:]]}
 matches any digit, as well as @samp{+} and @samp{-}.
@@ -950,7 +988,7 @@ whitespace:
 @end defun
 
 @cindex optimize regexp
address@hidden regexp-opt strings &optional paren
address@hidden regexp-opt strings &optional paren keep-order
 This function returns an efficient regular expression that will match
 any of the strings in the list @var{strings}.  This is useful when you
 need to make matching or searching as fast as possible---for example,
@@ -960,6 +998,9 @@ possible.  A hand-tuned regular expression can sometimes be 
slightly
 more efficient, but is almost never worth the effort.}.
 @c E.g., see https://debbugs.gnu.org/2816
 
+If @var{strings} is the empty list, the return value is a regexp that
+never matches anything.
+
 The optional argument @var{paren} can be any of the following:
 
 @table @asis
@@ -985,8 +1026,15 @@ if it is necessary to ensure that a postfix operator 
appended to
 it will apply to the whole expression.
 @end table
 
-The resulting regexp of @code{regexp-opt} is equivalent to but usually
-more efficient than that of a simplified version:
+The optional argument @var{keep-order}, if @code{nil} or omitted,
+allows the returned regexp to match the strings in any order.  If
address@hidden, the match is guaranteed to be performed in the order
+given, as if the strings were made into a regexp by joining them with
+the @samp{\|} operator.
+
+Up to reordering, the resulting regexp of @code{regexp-opt} is
+equivalent to but usually more efficient than that of a simplified
+version:
 
 @example
 (defun simplified-regexp-opt (strings &optional paren)
@@ -997,9 +1045,9 @@ more efficient than that of a simplified version:
          ((eq paren 'symbols) '("\\_<\\(" . "\\)\\_>"))
          ((null paren)          '("\\(?:" . "\\)"))
          (t                       '("\\(" . "\\)")))))
-   (concat (car paren)
+   (concat (car parens)
            (mapconcat 'regexp-quote strings "\\|")
-           (cdr paren))))
+           (cdr parens))))
 @end example
 @end defun
 
diff --git a/doc/lispref/sequences.texi b/doc/lispref/sequences.texi
index 955ad66..a7f270c 100644
--- a/doc/lispref/sequences.texi
+++ b/doc/lispref/sequences.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Sequences Arrays Vectors
@@ -782,10 +782,11 @@ before being sorted.  @var{function} is a function of one 
argument.
 @end defun
 
 
address@hidden seq-contains sequence elt &optional function
-  This function returns the first element in @var{sequence} that is equal to
address@hidden  If the optional argument @var{function} is address@hidden,
-it is a function of two arguments to use instead of the default @code{equal}.
address@hidden seq-contains-p sequence elt &optional function
+  This function returns address@hidden if at least one element in
address@hidden is equal to @var{elt}.  If the optional argument
address@hidden is address@hidden, it is a function of two arguments to
+use instead of the default @code{equal}.
 
 @example
 @group
diff --git a/doc/lispref/streams.texi b/doc/lispref/streams.texi
index 032669c..600639f 100644
--- a/doc/lispref/streams.texi
+++ b/doc/lispref/streams.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1994, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1994, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Read and Print
diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi
index 3558f17..521f163 100644
--- a/doc/lispref/strings.texi
+++ b/doc/lispref/strings.texi
@@ -1,6 +1,6 @@
 @c -*- mode: texinfo; coding: utf-8 -*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Strings and Characters
diff --git a/doc/lispref/symbols.texi b/doc/lispref/symbols.texi
index 11e92f6..5d71fb3 100644
--- a/doc/lispref/symbols.texi
+++ b/doc/lispref/symbols.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Symbols
@@ -558,9 +558,12 @@ deleted from the local value of a hook variable when 
changing major
 modes.  @xref{Setting Hooks}.
 
 @item pure
address@hidden @code{pure} property
 If the value is address@hidden, the named function is considered to be
-side-effect free.  Calls with constant arguments can be evaluated at
-compile time.  This may shift run time errors to compile time.
+pure (@pxref{What Is a Function}).  Calls with constant arguments can
+be evaluated at compile time.  This may shift run time errors to
+compile time.  Not to be confused with pure storage (@pxref{Pure
+Storage}).
 
 @item risky-local-variable
 If the value is address@hidden, the named variable is considered risky
@@ -579,9 +582,13 @@ The value specifies a function for determining safe 
file-local values
 for the named variable.  @xref{File Local Variables}.
 
 @item side-effect-free
address@hidden @code{side-effect-free} property
 A address@hidden value indicates that the named function is free of
-side-effects, for determining function safety (@pxref{Function
-Safety}) as well as for byte compiler optimizations.  Do not set it.
+side effects (@pxref{What Is a Function}), so the byte compiler may
+ignore a call whose value is unused.  If the property's value is
address@hidden, the byte compiler may even delete such unused
+calls.  In addition to byte compiler optimizations, this property is
+also used for determining function safety (@pxref{Function Safety}).
 
 @item variable-documentation
 If address@hidden, this specifies the named variable's documentation
diff --git a/doc/lispref/syntax.texi b/doc/lispref/syntax.texi
index dcfade3..b0c04ef 100644
--- a/doc/lispref/syntax.texi
+++ b/doc/lispref/syntax.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Syntax Tables
@@ -556,8 +556,8 @@ the current syntax table in the usual way.
 
 @defvar parse-sexp-lookup-properties
 If this is address@hidden, the syntax scanning functions, like
address@hidden, pay attention to syntax text properties.
-Otherwise they use only the current syntax table.
address@hidden, pay attention to @code{syntax-table} text
+properties.  Otherwise they use only the current syntax table.
 @end defvar
 
 @defvar syntax-propertize-function
@@ -927,9 +927,9 @@ nicely.
 
 @defvar multibyte-syntax-as-symbol
 If this variable is address@hidden, @code{scan-sexps} treats all
address@hidden characters as symbol constituents regardless
-of what the syntax table says about them.  (However, text properties
-can still override the syntax.)
address@hidden characters as symbol constituents regardless of
+what the syntax table says about them.  (However, @code{syntax-table
+}text properties can still override the syntax.)
 @end defvar
 
 @defopt parse-sexp-ignore-comments
@@ -939,7 +939,6 @@ whitespace by the functions in this section and by 
@code{forward-sexp},
 @code{scan-lists} and @code{scan-sexps}.
 @end defopt
 
address@hidden parse-sexp-lookup-properties
 The behavior of @code{parse-partial-sexp} is also affected by
 @code{parse-sexp-lookup-properties} (@pxref{Syntax Properties}).
 
@@ -1042,8 +1041,8 @@ This function returns the syntax code for the raw syntax 
descriptor
 @var{syntax-code} component, masks off the high 16 bits which record
 the syntax flags, and returns the resulting integer.
 
-If @var{syntax} is @code{nil}, the return value is returns @code{nil}.
-This is so that the expression
+If @var{syntax} is @code{nil}, the return value is @code{nil}.  This
+is so that the expression
 
 @example
 (syntax-class (syntax-after pos))
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index 51d2753..500df1f 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 1990-1995, 1998-2019 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Text
 @chapter Text
@@ -723,12 +723,18 @@ You thought
 @end example
 @end deffn
 
address@hidden Command delete-indentation &optional join-following-p
address@hidden Command delete-indentation &optional join-following-p beg end
 This function joins the line point is on to the previous line, deleting
 any whitespace at the join and in some cases replacing it with one
 space.  If @var{join-following-p} is address@hidden,
 @code{delete-indentation} joins this line to the following line
-instead.  The function returns @code{nil}.
+instead.  Otherwise, if @var{beg} and @var{end} are address@hidden,
+this function joins all lines in the region they define.
+
+In an interactive call, @var{join-following-p} is the prefix argument,
+and @var{beg} and @var{end} are, respectively, the start and end of
+the region if it is active, else @code{nil}.  The function returns
address@hidden
 
 If there is a fill prefix, and the second of the lines being joined
 starts with the prefix, then @code{delete-indentation} deletes the
@@ -2571,11 +2577,11 @@ The quick brown fox jum  @point{}ped.
 @end example
 @end deffn
 
address@hidden Command indent-relative-maybe
address@hidden Command indent-relative-first-indent-point
 @comment !!SourceFile indent.el
 This command indents the current line like the previous nonblank line,
 by calling @code{indent-relative} with @code{t} as the
address@hidden argument.  The return value is unpredictable.
address@hidden argument.  The return value is unpredictable.
 
 If the previous nonblank line has no indent points beyond the current
 column, this command does nothing.
@@ -3496,9 +3502,14 @@ property is obsolete; use the @code{cursor-intangible} 
property instead.
 @kindex cursor-intangible @r{(text property)}
 @findex cursor-intangible-mode
 When the minor mode @code{cursor-intangible-mode} is turned on, point
-is moved away of any position that has a address@hidden
+is moved away from any position that has a address@hidden
 @code{cursor-intangible} property, just before redisplay happens.
 
address@hidden cursor-sensor-inhibit
+When the variable @code{cursor-sensor-inhibit} is address@hidden, the
address@hidden property and the
address@hidden property (described below) are ignored.
+
 @item field
 @kindex field @r{(text property)}
 Consecutive characters with the same @code{field} property constitute a
@@ -3680,6 +3691,9 @@ depending on whether the cursor is entering the text that 
has this
 property or leaving it.  The functions are called only when the minor
 mode @code{cursor-sensor-mode} is turned on.
 
+When the variable @code{cursor-sensor-inhibit} is address@hidden, the
address@hidden property is ignored.
+
 @item composition
 @kindex composition @r{(text property)}
 This text property is used to display a sequence of characters as a
@@ -4428,22 +4442,59 @@ all markers unrelocated.
   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
address@hidden Command replace-buffer-contents source &optional max-secs 
max-costs
 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
 @code{replace-buffer-contents} 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}.
+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 @code{delete-region} and @code{insert-buffer-substring}
+would destroy these properties.  However, the latter combination is
+typically faster (@xref{Deletion}, and @ref{Insertion}).
+
+For its working, @code{replace-buffer-contents} needs to compare the
+contents of the original buffer with that of @code{source} which is a
+costly operation if the buffers are huge and there is a high number of
+differences between them.  In order to keep
address@hidden's runtime in bounds, it has two
+optional arguments.
+
address@hidden defines a hard boundary in terms of seconds.  If given
+and exceeded, it will fall back to @code{delete-region} and
address@hidden
+
address@hidden defines the quality of the difference computation.
+If the actual costs exceed this limit, heuristics are used to provide
+a faster but suboptimal solution.  The default value is 1000000.
+
address@hidden returns t if a non-destructive
+replacement could be performed.  Otherwise, i.e., if @code{max-secs}
+was exceeded, it returns nil.
 @end deffn
 
address@hidden replace-region-contents beg end replace-fn &optional max-secs 
max-costs
+This function replaces the region between @code{beg} and @code{end}
+using the given @code{replace-fn}.  The function @code{replace-fn} is
+run in the current buffer narrowed to the specified region and it
+should return either a string or a buffer replacing the region.
+
+The replacement is performed using @code{replace-buffer-contents} (see
+above) which also describes the @code{max-secs} and @code{max-costs}
+arguments and the return value.
+
+Note: If the replacement is a string, it will be placed in a temporary
+buffer so that @code{replace-buffer-contents} can operate on it.
+Therefore, if you already have the replacement in a buffer, it makes
+no sense to convert it to a string using @code{buffer-substring} or
+similar.
address@hidden defun
+
 @node Decompression
 @section Dealing With Compressed Data
 
@@ -4462,14 +4513,17 @@ This function returns address@hidden if built-in zlib 
decompression is
 available.
 @end defun
 
address@hidden zlib-decompress-region start end
address@hidden zlib-decompress-region start end &optional allow-partial
 This function decompresses the region between @var{start} and
 @var{end}, using built-in zlib decompression.  The region should
 contain data that were compressed with gzip or zlib.  On success, the
 function replaces the contents of the region with the decompressed
-data.  On failure, the function leaves the region unchanged and
-returns @code{nil}.  This function can be called only in unibyte
-buffers.
+data.  If @var{allow-partial} is @code{nil} or omitted, then on
+failure, the function leaves the region unchanged and returns
address@hidden  Otherwise, it returns the number of bytes that were not
+decompressed and replaces the region text by whatever data was
+successfully decompressed.  This function can be called only in
+unibyte buffers.
 @end defun
 
 
@@ -5102,8 +5156,11 @@ as in @code{json-parse-string}.
 
 @defun json-parse-string string &rest args
 This function parses the JSON value in @var{string}, which must be a
-Lisp string.  The argument @var{args} is a list of keyword/argument
-pairs.  The following keywords are accepted:
+Lisp string.  If @var{string} doesn't contain a valid JSON object,
+this function signals the @code{json-parse-error} error.
+
+The argument @var{args} is a list of keyword/argument pairs.  The
+following keywords are accepted:
 
 @table @code
 @item :object-type
@@ -5113,6 +5170,11 @@ key-value mappings of a JSON object.  It can be either
 keys; @code{alist} to use alists with symbols as keys; or @code{plist}
 to use plists with keyword symbols as keys.
 
address@hidden :array-type
+The value decides which Lisp object to use for representing a JSON
+array.  It can be either @code{array}, the default, to use Lisp
+arrays; or @code{list} to use lists.
+
 @item :null-object
 The value decides which Lisp object to use to represent the JSON
 keyword @code{null}.  It defaults to the symbol @code{:null}.
@@ -5127,19 +5189,20 @@ keyword @code{false}.  It defaults to the symbol 
@code{:false}.
 @defun json-parse-buffer &rest args
 This function reads the next JSON value from the current buffer,
 starting at point.  It moves point to the position immediately after
-the value if a value could be read and converted to Lisp; otherwise it
-doesn't move point.  The arguments @var{args} are interpreted as in
address@hidden
+the value if contains a valid JSON object; otherwise it signals the
address@hidden error and doesn't move point.  The arguments
address@hidden are interpreted as in @code{json-parse-string}.
 @end defun
 
 @node JSONRPC
 @section JSONRPC communication
 @cindex JSON remote procedure call protocol
address@hidden JSONRPC
 
 The @code{jsonrpc} library implements the @acronym{JSONRPC}
 specification, version 2.0, as it is described in
 @uref{http://www.jsonrpc.org/}.  As the name suggests, JSONRPC is a
-generic @code{Remote Procedure Call} protocol designed around
+generic @dfn{Remote Procedure Call} protocol designed around
 @acronym{JSON} objects, which you can convert to and from Lisp objects
 (@pxref{Parsing JSON}).
 
@@ -5158,81 +5221,96 @@ transport agnostic in that the concepts can be used 
within the same
 process, over sockets, over http, or in many various message passing
 environments."
 
address@hidden jsonrpc-connection
 To model this agnosticism, the @code{jsonrpc} library uses objects of
-a @code{jsonrpc-connection} class, which represent a connection the
+a @code{jsonrpc-connection} class, which represent a connection to a
 remote JSON endpoint (for details on Emacs's object system,
 @pxref{Top,EIEIO,,eieio,EIEIO}).  In modern object-oriented parlance,
-this class is ``abstract'', i.e. the actual class of a useful
-connection object used is always a subclass of it.  Nevertheless, we
-can define two distinct API's around the @code{jsonrpc-connection}
-class:
+this class is ``abstract'', i.e.@: the actual class of a useful
+connection object is always a subclass of @code{jsonrpc-connection}.
+Nevertheless, we can define two distinct APIs around the
address@hidden class:
 
address@hidden JSONRPC application interfaces
 @enumerate
 
 @item A user interface for building JSONRPC applications
 
-In this scenario, the JSONRPC application instantiates
address@hidden objects of one of its concrete subclasses
-using @code{make-instance}.  To initiate a contact to the remote
-endpoint, the JSONRPC application passes this object to the functions
address@hidden'}, @code{jsonrpc-request} and
address@hidden :request-dispatcher
address@hidden :notification-dispatcher
address@hidden jsonrpc-notify
address@hidden jsonrpc-request
address@hidden jsonrpc-async-request
+In this scenario, the JSONRPC application selects a concrete subclass
+of @code{jsonrpc-connection}, and proceeds to create objects of that
+subclass using @code{make-instance}.  To initiate a contact to the
+remote endpoint, the JSONRPC application passes this object to the
+functions @code{jsonrpc-notify}, @code{jsonrpc-request}, and/or
 @code{jsonrpc-async-request}.  For handling remotely initiated
 contacts, which generally come in asynchronously, the instantiation
 should include @code{:request-dispatcher} and
 @code{:notification-dispatcher} initargs, which are both functions of
 3 arguments: the connection object; a symbol naming the JSONRPC method
-invoked remotely; and a JSONRPC "params" object.
+invoked remotely; and a JSONRPC @code{params} object.
 
address@hidden jsonrpc-error
 The function passed as @code{:request-dispatcher} is responsible for
 handling the remote endpoint's requests, which expect a reply from the
 local endpoint (in this case, the program you're building).  Inside
-that function, you may either return locally (normally) or non-locally
-(error).  A local return value must be a Lisp object serializable as
-JSON (@pxref{Parsing JSON}).  This determines a success response, and
-the object is forwarded to the server as the JSONRPC "result" object.
-A non-local return, achieved by calling the function
address@hidden, causes an error response to be sent to the
-server.  The details of the accompanying JSONRPC "error" are filled
-out with whatever was passed to @code{jsonrpc-error}.  A non-local
-return triggered by an unexpected error of any other type also causes
-an error response to be sent (unless you have set
address@hidden, in which case this should land you in the
-debugger, @pxref{Error Debugging}).
+that function, you may either return locally (a normal return) or
+non-locally (an error return).  A local return value must be a Lisp
+object that can be serialized as JSON (@pxref{Parsing JSON}).  This
+determines a success response, and the object is forwarded to the
+server as the JSONRPC @code{result} object.  A non-local return,
+achieved by calling the function @code{jsonrpc-error}, causes an error
+response to be sent to the server.  The details of the accompanying
+JSONRPC @code{error} are filled out with whatever was passed to
address@hidden  A non-local return triggered by an unexpected
+error of any other type also causes an error response to be sent
+(unless you have set @code{debug-on-error}, in which case this calls
+the Lisp debugger, @pxref{Error Debugging}).
 
 @item A inheritance interface for building JSONRPC transport implementations
 
 In this scenario, @code{jsonrpc-connection} is subclassed to implement
 a different underlying transport strategy (for details on how to
-subclass, @pxref{Inheritance,Inheritance,,eieio}).  Users of the
+subclass, see @ref{Inheritance,Inheritance,,eieio}.).  Users of the
 application-building interface can then instantiate objects of this
 concrete class (using the @code{make-instance} function) and connect
 to JSONRPC endpoints using that strategy.
 
 This API has mandatory and optional parts.
 
address@hidden jsonrpc-connection-send
 To allow its users to initiate JSONRPC contacts (notifications or
-requests) or reply to endpoint requests, the method
address@hidden must be implemented for the subclass.
+requests) or reply to endpoint requests, the subclass must have an
+implementation of the @code{jsonrpc-connection-send} method.
 
address@hidden jsonrpc-connection-receive
 Likewise, for handling the three types of remote contacts (requests,
-notifications and responses to local requests) the transport
+notifications, and responses to local requests), the transport
 implementation must arrange for the function
 @code{jsonrpc-connection-receive} to be called after noticing a new
 JSONRPC message on the wire (whatever that "wire" may be).
 
address@hidden jsonrpc-shutdown
address@hidden jsonrpc-running-p
 Finally, and optionally, the @code{jsonrpc-connection} subclass should
-implement @code{jsonrpc-shutdown} and @code{jsonrpc-running-p} if
-these concepts apply to the transport.  If they do, then any system
-resources (e.g. processes, timers, etc..) used listen for messages on
-the wire should be released in @code{jsonrpc-shutdown}, i.e. they
-should only be needed while @code{jsonrpc-running-p} is non-nil.
+implement the @code{jsonrpc-shutdown} and @code{jsonrpc-running-p}
+methods if these concepts apply to the transport.  If they do, then
+any system resources (e.g.@: processes, timers, etc.) used to listen for
+messages on the wire should be released in @code{jsonrpc-shutdown},
+i.e.@: they should only be needed while @code{jsonrpc-running-p} is
+non-nil.
 
 @end enumerate
 
 @node Process-based JSONRPC connections
 @subsection Process-based JSONRPC connections
address@hidden JSONRPC process-based connections
 
-For convenience, the @code{jsonrpc} library comes built-in with a
address@hidden jsonrpc-process-connection
+For convenience, the @code{jsonrpc} library comes with a built-in
 @code{jsonrpc-process-connection} transport implementation that can
 talk to local subprocesses (using the standard input and standard
 output); or TCP hosts (using sockets); or any other remote endpoint
@@ -5247,6 +5325,7 @@ JSONRPC, see the
 @uref{https://microsoft.github.io/language-server-protocol/specification,
 Language Server Protocol}.
 
address@hidden JSONRPC connection initargs
 Along with the mandatory @code{:request-dispatcher} and
 @code{:notification-dispatcher} initargs, users of the
 @code{jsonrpc-process-connection} class should pass the following
@@ -5255,29 +5334,32 @@ initargs as keyword-value pairs to @code{make-instance}:
 @table @code
 @item :process
 Value must be a live process object or a function of no arguments
-producing one such object.  If passed a process object, that is
-expected to contain an pre-established connection; otherwise, the
+producing one such object.  If passed a process object, the object is
+expected to contain a pre-established connection; otherwise, the
 function is called immediately after the object is made.
 
 @item :on-shutdown
 Value must be a function of a single argument, the
 @code{jsonrpc-process-connection} object.  The function is called
 after the underlying process object has been deleted (either
-deliberately by @code{jsonrpc-shutdown} or unexpectedly, because of
+deliberately by @code{jsonrpc-shutdown}, or unexpectedly, because of
 some external cause).
 @end table
 
 @node JSONRPC JSON object format
address@hidden JSON object format
address@hidden JSONRPC JSON object format
address@hidden JSONRPC object format
 
-JSON objects are exchanged as Lisp plists (@pxref{Parsing JSON}):
-JSON-compatible plists are handed to the dispatcher functions and,
-likewise, JSON-compatible plists should be given to
address@hidden, @code{jsonrpc-request} and
+JSONRPC JSON objects are exchanged as Lisp plists (@pxref{Property
+Lists}): JSON-compatible plists are handed to the dispatcher functions
+and, likewise, JSON-compatible plists should be given to
address@hidden, @code{jsonrpc-request}, and
 @code{jsonrpc-async-request}.
 
-To facilitate handling plists, this library make liberal use of
address@hidden library and suggests (but doesn't force) its clients to
address@hidden jsonrpc-lambda
+To facilitate handling plists, this library makes liberal use of
address@hidden library (@pxref{Top,cl-lib,,cl,Common Lisp Extensions
+for GNU Emacs Lisp}) and suggests (but doesn't force) its clients to
 do the same.  A macro @code{jsonrpc-lambda} can be used to create a
 lambda for destructuring a JSON-object like in this example:
 
@@ -5293,7 +5375,8 @@ lambda for destructuring a JSON-object like in this 
example:
 @end example
 
 @node JSONRPC deferred requests
address@hidden Deferred requests
address@hidden Deferred JSONRPC requests
address@hidden JSONRPC deferred requests
 
 In many @acronym{RPC} situations, synchronization between the two
 communicating endpoints is a matter of correctly designing the RPC
@@ -5305,6 +5388,7 @@ is still uncertainty about the state of the remote 
endpoint.
 Furthermore, acting on these events may only sometimes demand
 synchronization, depending on the event's specific nature.
 
address@hidden :address@hidden, JSONRPC keyword}
 The @code{:deferred} keyword argument to @code{jsonrpc-request} and
 @code{jsonrpc-async-request} is designed to let the caller indicate
 that the specific request needs synchronization and its actual
@@ -5315,9 +5399,10 @@ isn't sent immediately, @code{jsonrpc} will make renewed 
efforts to
 send it at certain key times during communication, such as when
 receiving or sending other messages to the endpoint.
 
address@hidden jsonrpc-connection-ready-p
 Before any attempt to send the request, the application-specific
-conditions are checked.  Since the @code{jsonrpc} library can't known
-what these conditions are, the programmer may use the
+conditions are checked.  Since the @code{jsonrpc} library can't know
+what these conditions are, the program can use the
 @code{jsonrpc-connection-ready-p} generic function (@pxref{Generic
 Functions}) to specify them.  The default method for this function
 returns @code{t}, but you can add overriding methods that return
diff --git a/doc/lispref/threads.texi b/doc/lispref/threads.texi
index c9d5f79..db68f91 100644
--- a/doc/lispref/threads.texi
+++ b/doc/lispref/threads.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 2012-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 2012-2019 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Threads
 @chapter Threads
@@ -17,9 +17,9 @@ correct programs should not rely on cooperative threading.
 
   Currently, thread switching will occur upon explicit request via
 @code{thread-yield}, when waiting for keyboard input or for process
-output (e.g., during @code{accept-process-output}), or during blocking
-operations relating to threads, such as mutex locking or
address@hidden
+output from asynchronous processes (e.g., during
address@hidden), or during blocking operations relating
+to threads, such as mutex locking or @code{thread-join}.
 
   Emacs Lisp provides primitives to create and control threads, and
 also to create and control mutexes and condition variables, useful for
diff --git a/doc/lispref/tips.texi b/doc/lispref/tips.texi
index 08cc10d..d41fe82 100644
--- a/doc/lispref/tips.texi
+++ b/doc/lispref/tips.texi
@@ -1,6 +1,6 @@
 @c -*- mode: texinfo; coding: utf-8 -*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1993, 1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1993, 1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Tips
@@ -679,10 +679,15 @@ starting double-quote is not part of the string!
 @cindex curly quotes
 @cindex curved quotes
 When a documentation string refers to a Lisp symbol, write it as it
-would be printed (which usually means in lower case), surrounding
-it with curved single quotes (@t{‘} and @t{’}).  There are
-two exceptions: write @code{t} and @code{nil} without surrounding
-punctuation.  For example: @samp{CODE can be ‘lambda’, nil, or t}.
+would be printed (which usually means in lower case), surrounding it
+with curved single quotes (@t{‘..’}).  There are two exceptions: write
address@hidden and @code{nil} without surrounding punctuation.  For example:
+
address@hidden
+ CODE can be ‘lambda’, nil, or t.
address@hidden example
+
address@hidden
 @xref{Quotation Marks,,, emacs, The GNU Emacs Manual}, for how to
 enter curved single quotes.
 
@@ -942,7 +947,7 @@ explains these conventions, starting with an example:
 @group
 ;;; foo.el --- Support for the Foo programming language
 
-;; Copyright (C) 2010-2018 Your Name
+;; Copyright (C) 2010-2019 Your Name
 @end group
 
 ;; Author: Your Name <yourname@@example.com>
diff --git a/doc/lispref/two-volume-cross-refs.txt 
b/doc/lispref/two-volume-cross-refs.txt
index b5379df..e3db8ff 100644
--- a/doc/lispref/two-volume-cross-refs.txt
+++ b/doc/lispref/two-volume-cross-refs.txt
@@ -1,4 +1,4 @@
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 See end for copying conditions.
 
 Two Volume Cross References
diff --git a/doc/lispref/two-volume.make b/doc/lispref/two-volume.make
index 07a6d2c..63c97c2 100644
--- a/doc/lispref/two-volume.make
+++ b/doc/lispref/two-volume.make
@@ -1,4 +1,4 @@
-# Copyright (C) 2007-2018 Free Software Foundation, Inc.
+# Copyright (C) 2007-2019 Free Software Foundation, Inc.
 # See end for copying conditions.
 
 # although it would be nice to use tex rather than pdftex to avoid
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index 6560660..aca7d2f 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 1990-1995, 1998-2019 Free Software Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Variables
 @chapter Variables
@@ -2191,9 +2191,9 @@ This function looks for connection-local variables 
according to
 @var{criteria}, and immediately applies them in the current buffer.
 @end defun
 
address@hidden with-connection-local-profiles profiles &rest body
-All connection-local variables, which are specified by a connection
-profile in @var{profiles}, are applied.
address@hidden with-connection-local-variables &rest body
+All connection-local variables, which are specified by
address@hidden, are applied.
 
 After that, @var{body} is executed, and the connection-local variables
 are unwound.  Example:
@@ -2207,8 +2207,15 @@ are unwound.  Example:
 @end group
 
 @group
-(with-connection-local-profiles '(remote-perl)
-  do something useful)
+(connection-local-set-profiles
+  '(:application 'tramp :protocol "ssh" :machine "remotehost")
+  'remote-perl)
address@hidden group
+
address@hidden
+(let ((default-directory "/ssh:remotehost:/working/dir/"))
+  (with-connection-local-variables
+    do something useful))
 @end group
 @end example
 @end defmac
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index eb05766..32e8c2a 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Emacs Lisp Reference Manual.
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2018 Free Software
address@hidden Copyright (C) 1990-1995, 1998-1999, 2001-2019 Free Software
 @c Foundation, Inc.
 @c See the file elisp.texi for copying conditions.
 @node Windows
@@ -568,12 +568,6 @@ its pixel height is the pixel height of the screen areas 
spanned by its
 children.
 @end defun
 
address@hidden window-pixel-height-before-size-change &optional Lisp_Object 
&optional window
-This function returns the height of window @var{window} in pixels at the
-time @code{window-size-change-functions} was run for the last time on
address@hidden's frame (@pxref{Window Hooks}).
address@hidden defun
-
 @cindex window pixel width
 @cindex pixel width of a window
 @cindex total pixel width of a window
@@ -588,12 +582,6 @@ If @var{window} is an internal window, its pixel width is 
the width of
 the screen areas spanned by its children.
 @end defun
 
address@hidden window-pixel-width-before-size-change &optional Lisp_Object 
&optional window
-This function returns the width of window @var{window} in pixels at the
-time @code{window-size-change-functions} was run for the last time on
address@hidden's frame (@pxref{Window Hooks}).
address@hidden defun
-
 @cindex full-width window
 @cindex full-height window
   The following functions can be used to determine whether a given
@@ -1770,7 +1758,7 @@ raise the frame or make sure input focus is directed to 
that frame.
 @xref{Input Focus}.
 @end defun
 
address@hidden select window hook
address@hidden select window hooks
 @cindex running a hook when a window gets selected
 For historical reasons, Emacs does not run a separate hook whenever a
 window gets selected.  Applications and internal routines often
@@ -1786,8 +1774,8 @@ useful.
   However, when its @var{norecord} argument is @code{nil},
 @code{select-window} updates the buffer list and thus indirectly runs
 the normal hook @code{buffer-list-update-hook} (@pxref{Buffer List}).
-Consequently, that hook provides a reasonable way to run a function
-whenever a window gets selected more ``permanently''.
+Consequently, that hook provides one way to run a function whenever a
+window gets selected more ``permanently''.
 
   Since @code{buffer-list-update-hook} is also run by functions that are
 not related to window management, it will usually make sense to save the
@@ -1799,6 +1787,13 @@ temporarily passes a address@hidden @var{norecord} 
argument.  If
 possible, the macro @code{with-selected-window} (see below) should be
 used in such cases.
 
+  Emacs also runs the hook @code{window-selection-change-functions}
+whenever the redisplay routine detects that another window has been
+selected since last redisplay.  @xref{Window Hooks}, for a detailed
+explanation.  @code{window-state-change-functions} (described in the
+same section) is another abnormal hook run after a different window
+has been selected but is triggered by other window changes as well.
+
 @cindex most recently selected windows
   The sequence of calls to @code{select-window} with a address@hidden
 @var{norecord} argument determines an ordering of windows by their
@@ -1956,7 +1951,13 @@ The optional argument @var{all-frames} has the same 
meaning as in
 @code{next-window}.
 
 This function does not select a window that has a address@hidden
address@hidden window parameter (@pxref{Window Parameters}).
address@hidden window parameter (@pxref{Window Parameters}),
+provided that @code{ignore-window-parameters} is @code{nil}.
+
+If the @code{other-window} parameter of the selected window is a
+function, and @code{ignore-window-parameters} is @code{nil}, that
+function will be called with the arguments @var{count} and
address@hidden instead of the normal operation of this function.
 @end deffn
 
 @defun walk-windows fun &optional minibuf all-frames
@@ -2263,6 +2264,12 @@ selected window or never appeared in it before, or if
 buffer.
 @end defopt
 
address@hidden switch-to-buffer-obey-display-actions
+If this variable is address@hidden, @code{switch-to-buffer} respects
+display actions specified by @code{display-buffer-overriding-action},
address@hidden and other display related variables.
address@hidden defopt
+
 The next two commands are similar to @code{switch-to-buffer}, except for
 the described features.
 
@@ -2875,6 +2882,13 @@ Frames}) to avoid changing the width of other, unrelated 
windows.
 Also, this entry should be processed under only certain conditions
 which are specified right below this list.
 
address@hidden address@hidden, a buffer display action alist entry}
address@hidden dedicated
+If address@hidden, such an entry tells @code{display-buffer} to mark
+any window it creates as dedicated to its buffer (@pxref{Dedicated
+Windows}).  It does that by calling @code{set-window-dedicated-p} with
+the chosen window as first argument and the entry's value as second.
+
 @vindex address@hidden, a buffer display action alist entry}
 @item preserve-size
 If address@hidden such an entry tells Emacs to preserve the size of
@@ -3894,6 +3908,9 @@ display.  Other functions do not treat @code{t} 
differently from any
 address@hidden value.
 @end defun
 
+You can also tell @code{display-buffer} to mark a window it creates as
+dedicated to its buffer by providing a suitable @code{dedicated}
+action alist entry (@pxref{Buffer Display Action Alists}).
 
 @node Quitting Windows
 @section Quitting Windows
@@ -3925,8 +3942,33 @@ described next to deal with the window and its buffer.
 This function handles @var{window} and its buffer after quitting.  The
 optional argument @var{window} must be a live window and defaults to
 the selected one. The function's behavior is determined by the four
-elements of the @code{quit-restore} window parameter (@pxref{Window
-Parameters}), which is set to @code{nil} afterwards.
+elements of the list specified by the @code{quit-restore} window
+parameter (@pxref{Window Parameters}), which is set to @code{nil}
+afterwards.
+
+The first element of the @code{quit-restore} parameter is one of the
+symbols @code{window}, meaning that the window has been specially
+created by @code{display-buffer}; @code{frame}, a separate frame has
+been created; @code{same}, the window has only ever displayed this
+buffer; or @code{other}, the window showed another buffer before.
address@hidden and @code{window} affect how the window is quit, while
address@hidden and @code{other} affect the redisplay of buffers
+previously shown in this window.
+
+The second element is either one of the symbols @code{window} or
address@hidden, or a list whose elements are the buffer shown in the
+window before, that buffer's window start and window point positions,
+and the window's height at that time.  If that buffer is still live
+when the window is quit, then the function @code{quit-restore-window}
+reuses the window to display the buffer.
+
+The third element is the window selected at the time the parameter was
+created.  If @code{quit-restore-window} deletes the window passed to
+it as argument, it then tries to reselect this window.
+
+The fourth element is the buffer whose display caused the creation of
+this parameter.  @code{quit-restore-window} deletes the specified window
+only if it still shows that buffer.
 
 The window is deleted entirely if: 1) the first element of the
 @code{quit-restore} parameter is one of 'window or 'frame, 2) the
@@ -4616,13 +4658,14 @@ This function sets the display-start position of 
@var{window} to
 @var{position} in @var{window}'s buffer.  It returns @var{position}.
 
 The display routines insist that the position of point be visible when a
-buffer is displayed.  Normally, they change the display-start position
-(that is, scroll the window) whenever necessary to make point visible.
-However, if you specify the start position with this function using
address@hidden for @var{noforce}, it means you want display to start at
address@hidden even if that would put the location of point off the
-screen.  If this does place point off screen, the display routines move
-point to the left margin on the middle line in the window.
+buffer is displayed.  Normally, they select the display-start position
+according to their internal logic (and scroll the window if necessary)
+to make point visible.  However, if you specify the start position
+with this function using @code{nil} for @var{noforce}, it means you
+want display to start at @var{position} even if that would put the
+location of point off the screen.  If this does place point off
+screen, the display routines attempt to move point to the left margin
+on the middle line in the window.
 
 For example, if point @w{is 1} and you set the start of the window
 @w{to 37}, the start of the next line, point will be above the top
@@ -4669,6 +4712,13 @@ it is still 1 when redisplay occurs.  Here is an example:
 @end group
 @end example
 
+If the attempt to make point visible (i.e., in a fully-visible screen
+line) fails, the display routines will disregard the requested
+window-start position and compute a new one anyway.  Thus, for
+reliable results Lisp programs that call this function should always
+move point to be inside the window whose display starts at
address@hidden
+
 If @var{noforce} is address@hidden, and @var{position} would place point
 off screen at the next redisplay, then redisplay computes a new window-start
 position that works well with point, and thus @var{position} is not used.
@@ -5689,10 +5739,6 @@ prevent the code in @var{forms} from opening new 
windows, because new
 windows might be opened in other frames (@pxref{Choosing Window}), and
 @code{save-window-excursion} only saves and restores the window
 configuration on the current frame.
-
-Do not use this macro in @code{window-size-change-functions}; exiting
-the macro triggers execution of @code{window-size-change-functions},
-leading to an endless loop.
 @end defmac
 
 @defun window-configuration-p object
@@ -5789,8 +5835,8 @@ and heights, if possible.  Frames are not resized by this 
function.
 @section Window Parameters
 @cindex window parameters
 
-This section describes how window parameters can be used to associate
-additional information with windows.
+This section describes the window parameters that can be used to
+associate additional information with windows.
 
 @defun window-parameter window parameter
 This function returns @var{window}'s value for @var{parameter}.  The
@@ -5811,10 +5857,10 @@ This function sets @var{window}'s value of 
@var{parameter} to
 is the selected window.
 @end defun
 
-By default, the functions that save and restore window configurations or the
-states of windows (@pxref{Window Configurations}) do not care about
-window parameters.  This means that when you change the value of a
-parameter within the body of a @code{save-window-excursion}, the
+By default, the functions that save and restore window configurations
+or the states of windows (@pxref{Window Configurations}) do not care
+about window parameters.  This means that when you change the value of
+a parameter within the body of a @code{save-window-excursion}, the
 previous value is not restored when that macro exits.  It also means
 that when you restore via @code{window-state-put} a window state saved
 earlier by @code{window-state-get}, all cloned windows have their
@@ -5923,44 +5969,21 @@ parameter is installed and updated by the function
 @vindex address@hidden, a window parameter}
 This parameter is installed by the buffer display functions
 (@pxref{Choosing Window}) and consulted by @code{quit-restore-window}
-(@pxref{Quitting Windows}).  It contains four elements:
+(@pxref{Quitting Windows}).  It is a list of four elements, see the
+description of @code{quit-restore-window} in @ref{Quitting Windows}
+for details.
 
-The first element is one of the symbols @code{window}, meaning that
-the window has been specially created by @code{display-buffer};
address@hidden, a separate frame has been created; @code{same}, the
-window has only ever displayed this buffer; or @code{other}, the
-window showed another buffer before.  @code{frame} and @code{window}
-affect how the window is quit, while @code{same} and @code{other}
-affect the redisplay of buffers previously shown in this window.
-
-The second element is either one of the symbols @code{window} or
address@hidden, or a list whose elements are the buffer shown in the
-window before, that buffer's window start and window point positions,
-and the window's height at that time.  If that buffer is still live
-when the window is quit, then the function @code{quit-restore-window}
-reuses the window to display the buffer.
-
-The third element is the window selected at the time the parameter was
-created.  If @code{quit-restore-window} deletes the window passed to
-it as argument, it then tries to reselect this window.
-
-The fourth element is the buffer whose display caused the creation of
-this parameter.  @code{quit-restore-window} deletes the specified window
-only if it still shows that buffer.
-
-See the description of @code{quit-restore-window} in @ref{Quitting
-Windows} for details.
-
address@hidden window-side window-slot
address@hidden window-side
address@hidden window-slot
 @vindex address@hidden, a window parameter}
 @vindex address@hidden, a window parameter}
-These parameters are used for implementing side windows (@pxref{Side
-Windows}).
+These parameters are used internally for implementing side windows
+(@pxref{Side Windows}).
 
 @item window-atom
 @vindex address@hidden, a window parameter}
-This parameter is used for implementing atomic windows, see @ref{Atomic
-Windows}.
+This parameter is used internally for implementing atomic windows, see
address@hidden Windows}.
 
 @item mode-line-format
 @vindex address@hidden, a window parameter}
@@ -5982,11 +6005,12 @@ affected.
 
 @item min-margins
 @vindex address@hidden, a window parameter}
-The value of this parameter is a cons cell whose @sc{car} and @sc{cdr},
-if address@hidden, specify the minimum values (in columns) for the left
-and right margin of this window.  When present, Emacs will use these
-values instead of the actual margin widths for determining whether a
-window can be split or shrunk horizontally.
+The value of this parameter is a cons cell whose @sc{car} and
address@hidden, if address@hidden, specify the minimum values (in columns)
+for the left and right margin of this window (@pxref{Display Margins}.
+When present, Emacs will use these values instead of the actual margin
+widths for determining whether a window can be split or shrunk
+horizontally.
 
 Emacs never auto-adjusts the margins of any window after splitting or
 resizing it.  It is the sole responsibility of any application setting
@@ -6003,27 +6027,26 @@ applications.  It might be replaced by an improved 
solution in future
 versions of Emacs.
 @end table
 
+
 @node Window Hooks
 @section Hooks for Window Scrolling and Changes
 @cindex hooks for window operations
 
-This section describes how a Lisp program can take action whenever a
-window displays a different part of its buffer or a different buffer.
-There are three actions that can change this: scrolling the window,
-switching buffers in the window, and changing the size of the window.
-The first two actions run @code{window-scroll-functions}; the last runs
address@hidden
+This section describes how Lisp programs can take action after a
+window has been scrolled or other window modifications occurred.  We
+first consider the case where a window shows a different part of its
+buffer.
 
 @defvar window-scroll-functions
 This variable holds a list of functions that Emacs should call before
-redisplaying a window with scrolling.  Displaying a different buffer in
-the window also runs these functions.
+redisplaying a window with scrolling.  Displaying a different buffer
+in a window and making a new window also call these functions.
 
-This variable is not a normal hook, because each function is called with
-two arguments: the window, and its new display-start position.  At the
-time of the call, the display-start position of the window argument is
-already set to its new value, and the buffer to be displayed in the
-window is already set as the current buffer.
+This variable is not a normal hook, because each function is called
+with two arguments: the window, and its new display-start position.
+At the time of the call, the display-start position of the argument
+window is already set to its new value, and the buffer to be displayed
+in the window is set as the current buffer.
 
 These functions must take care when using @code{window-end}
 (@pxref{Window Start and End}); if you need an up-to-date value, you
@@ -6034,63 +6057,294 @@ is scrolled.  It's not designed for that, and such use 
probably won't
 work.
 @end defvar
 
address@hidden run-window-scroll-functions &optional window
-This function calls @code{window-scroll-functions} for the specified
address@hidden, which defaults to the selected window.
address@hidden defun
+In addition, you can use @code{jit-lock-register} to register a Font
+Lock fontification function, which will be called whenever parts of a
+buffer are (re)fontified because a window was scrolled or its size
+changed.  @xref{Other Font Lock Variables}.
+
address@hidden window change functions
+   The remainder of this section covers six hooks that are called
+during redisplay provided a significant, non-scrolling change of a
+window has been detected.  For simplicity, these hooks and the
+functions they call will be collectively referred to as @dfn{window
+change functions}.
+
address@hidden window buffer change
+The first of these hooks is run after a @dfn{window buffer change} is
+detected, which means that a window was created, deleted or assigned
+another buffer.
+
address@hidden window-buffer-change-functions
+This variable specifies functions called during redisplay when window
+buffers have changed.  The value should be a list of functions that
+take one argument.
+
+Functions specified buffer-locally are called for any window showing
+the corresponding buffer if that window has been created or assigned
+that buffer since the last time window change functions were run.  In
+this case the window is passed as argument.
+
+Functions specified by the default value are called for a frame if at
+least one window on that frame has been added, deleted or assigned
+another buffer since the last time window change functions were run.
+In this case the frame is passed as argument.
address@hidden defvar
+
address@hidden window size change
+The second of these hooks is run when a @dfn{window size change} has
+been detected which means that a window was created, assigned another
+buffer, or changed its total size or that of its text area.
 
 @defvar window-size-change-functions
-This variable holds a list of functions to be called if the size of any
-window changes for any reason.  The functions are called once per
-redisplay, and once for each frame on which size changes have occurred.
-
-Each function receives the frame as its sole argument.  To find out
-whether a specific window has changed size, compare the return values of
address@hidden and
address@hidden respectively
address@hidden and
address@hidden for that window (@pxref{Window Sizes}).
-
-The buffer-local value of this hook is run once for the buffer and the
-frame in question, provided at least one window showing the buffer on
-that frame has changed its size.  As it still receives the frame as
-its sole argument, any function called on a buffer-local basis will be
-oblivious to which window(s) showing the buffer changed its (their)
-size and has to check out these windows by using the method described
-in the previous paragraph.
-
-These function are usually only called when at least one window was
-added or has changed size since the last time this hook was run for
-the associated frame.  In some rare cases this hook also runs when a
-window that was added intermittently has been deleted afterwards.  In
-these cases none of the windows on the frame will appear to have
-changed its size.
+This variable specifies functions called during redisplay when a
+window size change occurred.  The value should be a list of functions
+that take one argument.
+
+Functions specified buffer-locally are called for any window showing
+the corresponding buffer if that window has been added or assigned
+another buffer or changed its total or body size since the last time
+window change functions were run.  In this case the window is passed
+as argument.
+
+Functions specified by the default value are called for a frame if at
+least one window on that frame has been added or assigned another
+buffer or changed its total or body size since the last time window
+change functions were run.  In this case the frame is passed as
+argument.
 @end defvar
 
address@hidden window selection change
+The third of these hooks is run when a @dfn{window selection change}
+has selected another window since the last redisplay.
+
address@hidden window-selection-change-functions
+This variable specifies functions called during redisplay when the
+selected window or a frame's selected window has changed.  The value
+should be a list of functions that take one argument.
+
+Functions specified buffer-locally are called for any window showing
+the corresponding buffer if that window has been selected or
+deselected (among all windows or among all windows on its frame) since
+the last time window change functions were run.  In this case the
+window is passed as argument.
+
+Functions specified by the default value are called for a frame if
+that frame has been selected or deselected or the frame's selected
+window has changed since the last time window change functions were
+run.  In this case the frame is passed as argument.
address@hidden defvar
+
address@hidden window state change
+The fourth of these hooks is run when a @dfn{window state change} has
+been detected, which means that at least one of the three preceding
+window changes has occurred.
+
address@hidden window-state-change-functions
+This variable specifies functions called during redisplay when a
+window buffer or size change occurred or the selected window or a
+frame's selected window has changed.  The value should be a list of
+functions that take one argument.
+
+Functions specified buffer-locally are called for any window showing
+the corresponding buffer if that window has been added or assigned
+another buffer, changed its total or body size or has been selected or
+deselected (among all windows or among all windows on its frame) since
+the last time window change functions were run.  In this case the
+window is passed as argument.
+
+Functions specified by the default value are called for a frame if at
+least one window on that frame has been added, deleted or assigned
+another buffer, changed its total or body size or that frame has been
+selected or deselected or the frame's selected window has changed
+since the last time window change functions were run.  In this case
+the frame is passed as argument.
+
+Functions specified by the default value are also run for a frame when
+that frame's window state change flag (see below) has been set since
+last redisplay.
address@hidden defvar
+
address@hidden window configuration change
+The fifth of these hooks is run when a @dfn{window configuration
+change} has been detected which means that either the buffer or the
+size of a window changed.  It differs from the four preceding hooks in
+the way it is run.
+
 @defvar window-configuration-change-hook
-A normal hook that is run every time the window configuration of a
-frame changes.  Window configuration changes include splitting and
-deleting windows, and the display of a different buffer in a window.
-
-The hook can be also used for tracking changes of window sizes.  It
-is, however, not run when the size of a frame changes or automatic
-resizing of a minibuffer window (@pxref{Minibuffer Windows}) changes
-the size of another window.  As a rule, adding a function to
address@hidden, see above, is the recommended way
-for reliably tracking size changes of any window.
-
-The buffer-local value of this hook is run once for each window on the
-affected frame, with the relevant window selected and its buffer
-current.  The global value of this hook is run once for the modified
-frame, with that frame selected.
+This variable specifies functions called during redisplay when either
+the buffer or the size of a window has changed.  The value should be a
+list of functions that take no argument.
+
+Functions specified buffer-locally are called for any window showing
+the corresponding buffer if at least one window on that frame has been
+added, deleted or assigned another buffer or changed its total or
+body size since the last time window change functions were run.  Each
+call is performed with the window showing the buffer temporarily
+selected and its buffer current.
+
+Functions specified by the default value are called for each frame if
+at least one window on that frame has been added, deleted or assigned
+another buffer or changed its total or body size since the last time
+window change functions were run.  Each call is performed with the
+frame temporarily selected and the selected window's buffer current.
address@hidden defvar
+
+Finally, Emacs runs a normal hook that generalizes the behavior of
address@hidden
+
address@hidden window-state-change-hook
+The default value of this variable specifies functions called during
+redisplay when a window state change has been detected or the window
+state change flag has been set on at least one frame.  The value
+should be a list of functions that take no argument.
+
+Applications should put a function on this hook only if they want to
+react to changes that happened on (or have been signaled for) two or
+more frames since last redisplay.  In every other case, putting the
+function on @code{window-state-change-functions} should be preferred.
 @end defvar
 
address@hidden run-window-configuration-change-hook &optional frame
-This function runs @code{window-configuration-change-hook} for the
-specified @var{frame}, which defaults to the selected frame.
+Window change functions are called during redisplay for each frame as
+follows: First, any buffer-local window buffer change function, window
+size change function, selected window change and window state change
+functions are called in this order.  Next, the default values for
+these functions are called in the same order.  Then any buffer-local
+window configuration change functions are called followed by functions
+specified by the default value of those functions.  Finally, functions
+on @code{window-state-change-hook} are run.
+
+   Window change functions are run for a specific frame only if a
+corresponding change was registered for that frame earlier.  Such
+changes include the creation or deletion of a window or the assignment
+of another buffer or size to a window.  Note that even when such a
+change has been registered, this does not mean that any of the hooks
+described above is run.  If, for example, a change was registered
+within the scope of a window excursion (@pxref{Window
+Configurations}), this will trigger a call of window change functions
+only if that excursion still persists at the time change functions are
+run.  If it is exited earlier, hooks will be run only if registered by
+a change outside the scope of that excursion.
+
address@hidden window state change flag
+   The @dfn{window state change flag} of a frame, if set, will cause
+the default values of @code{window-state-change-functions} (for that
+frame) and @code{window-state-change-hook} to be run during next
+redisplay regardless of whether a window state change actually
+occurred for that frame or not.  After running any functions on these
+hooks, the flag is reset for each frame.  Applications can set that
+flag and inspect its value using the following functions.
+
address@hidden set-frame-window-state-change &optional frame arg
+This function sets @var{frame}'s window state change flag if @var{arg}
+is address@hidden and resets it otherwise.  @var{frame} must be a live
+frame and defaults to the selected one.
 @end defun
 
-  In addition, you can use @code{jit-lock-register} to register a Font
-Lock fontification function, which will be called whenever parts of a
-buffer are (re)fontified because a window was scrolled or its size
-changed.  @xref{Other Font Lock Variables}.
address@hidden frame-window-state-change &optional frame
+This functions returns @code{t} if @var{frame}'s window state change
+flag is set and @code{nil} otherwise.  @var{frame} must be a live
+frame and defaults to the selected one.
address@hidden defun
+
+   While window change functions are run, the functions described next
+can be called to get more insight into what has changed for a specific
+window or frame since the last redisplay.  All these functions take a
+live window as single, optional argument, defaulting to the selected
+window.
+
address@hidden window-old-buffer &optional window
+This function returns the buffer shown in @var{window} at the last
+time window change functions were run for @var{window}'s frame.  If it
+returns @code{nil}, @var{window} has been created after that.  If it
+returns @code{t}, @var{window} was not shown at that time but has been
+restored from a previously saved window configuration afterwards.
+Otherwise, the return value is the buffer shown by @code{window} at
+that time.
address@hidden defun
+
address@hidden window-old-pixel-width &optional window
+This function returns the total pixel width of @var{window} the
+last time window change functions found @code{window} live on its
+frame.  It is zero if @code{window} was created after that.
address@hidden defun
+
address@hidden window-old-pixel-height &optional window
+This function returns the total pixel height of @var{window} the last
+time window change functions found @code{window} live on its frame.
+It is zero if @code{window} was created after that.
address@hidden defun
+
address@hidden window-old-body-pixel-width &optional window
+This function returns the pixel width of @var{window}'s text area the
+last time window change functions found @code{window} live on its
+frame.  It is zero if @code{window} was created after that.
address@hidden defun
+
address@hidden window-old-body-pixel-height &optional window
+This function returns the pixel height of @var{window}'s text area the
+last time window change functions found @code{window} live on its
+frame.  It is zero if @code{window} was created after that.
address@hidden defun
+
+In order to find out which window or frame was selected the last time
+window change functions were run, the following functions can be used:
+
address@hidden frame-old-selected-window &optional frame
+This function returns the selected window of @var{frame} at the last
+time window change functions were run.  If omitted or @code{nil}
address@hidden defaults to the selected frame.
address@hidden defun
+
address@hidden old-selected-window
+This function returns the selected window at the last time window
+change functions were run.
address@hidden defun
+
address@hidden old-selected-frame
+This function returns the selected frame at the last time window
+change functions were run.
address@hidden defun
+
+Note that window change functions provide no information about which
+windows have been deleted since the last time they were run.  If
+necessary, applications should remember any window showing a specific
+buffer in a local variable of that buffer and update it in a function
+run by the default values of any of the hooks that are run when a
+window buffer change was detected.
+
+   The following caveats should be considered when adding a function
+to window change functions:
+
address@hidden @bullet
address@hidden
+Some operations will not trigger a call of window change functions.
+These include showing another buffer in a minibuffer window or any
+change of a tooltip window.
+
address@hidden
+Window change functions should not create or delete windows or change
+the buffer, size or selection status of any window because there is no
+guarantee that the information about such a change will be propagated
+to other window change functions.  If at all, any such change should
+be executed only by the last function listed by the default value of
address@hidden
+
address@hidden
+Macros like @code{save-window-excursion}, @code{with-selected-window}
+or @code{with-current-buffer} can be used when running window change
+functions.
+
address@hidden
+Running window change functions does not save and restore match data.
+Unless running @code{window-configuration-change-hook} it does not
+save or restore the selected window or frame or the current buffer
+either.
+
address@hidden
+Any redisplay triggering the run of window change functions may be
+aborted.  If the abort occurs before window change functions have run
+to their completion, they will be run again with the previous values,
+that is, as if redisplay had not been performed.  If aborted later,
+they will be run with the new values, that is, as if redisplay had
+been actually performed.
address@hidden itemize
diff --git a/doc/man/ChangeLog.1 b/doc/man/ChangeLog.1
index b72837f..68e4112 100644
--- a/doc/man/ChangeLog.1
+++ b/doc/man/ChangeLog.1
@@ -176,7 +176,7 @@
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 2007-2018 Free Software Foundation, Inc.
+  Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/doc/man/ebrowse.1 b/doc/man/ebrowse.1
index c0245f8..b0448d4 100644
--- a/doc/man/ebrowse.1
+++ b/doc/man/ebrowse.1
@@ -82,7 +82,7 @@ should give you access to the complete manual.
 was written by Gerd Moellmann.
 .
 .SH COPYING
-Copyright 2008-2018 Free Software Foundation, Inc.
+Copyright 2008-2019 Free Software Foundation, Inc.
 .PP
 Permission is granted to make and distribute verbatim copies of this
 document provided the copyright notice and this permission notice are
diff --git a/doc/man/emacs.1.in b/doc/man/emacs.1.in
index e332fb4..11a3390 100644
--- a/doc/man/emacs.1.in
+++ b/doc/man/emacs.1.in
@@ -279,8 +279,8 @@ window's width, height, and position as specified.
 The geometry specification is in the standard X format; see
 .BR X (7)
 for more information.
-The width and height are specified in characters; the default is
-80 by 24.
+The width and height are specified in characters; the default for GUI
+frames is 80 by 36.
 See the Emacs manual, section "Options for Window Size and Position",
 for information on how window sizes interact
 with selecting or deselecting the tool bar and menu bar.
@@ -653,7 +653,7 @@ For detailed credits and acknowledgments, see the GNU Emacs 
manual.
 .
 .
 .SH COPYING
-Copyright 1995, 1999-2018 Free Software Foundation, Inc.
+Copyright 1995, 1999-2019 Free Software Foundation, Inc.
 .PP
 Permission is granted to make and distribute verbatim copies of this
 document provided the copyright notice and this permission notice are
diff --git a/doc/man/etags.1 b/doc/man/etags.1
index 558b249..7cc501c 100644
--- a/doc/man/etags.1
+++ b/doc/man/etags.1
@@ -281,7 +281,7 @@ Stallman.
 .BR vi ( 1 ).
 
 .SH COPYING
-Copyright 1992, 1999, 2001-2018 Free Software Foundation, Inc.
+Copyright 1992, 1999, 2001-2019 Free Software Foundation, Inc.
 .PP
 Permission is granted to make and distribute verbatim copies of this
 document provided the copyright notice and this permission notice are
diff --git a/doc/misc/ChangeLog.1 b/doc/misc/ChangeLog.1
index 9ef3f0e..9b25c90 100644
--- a/doc/misc/ChangeLog.1
+++ b/doc/misc/ChangeLog.1
@@ -12116,7 +12116,7 @@
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 1993-1999, 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 1993-1999, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/doc/misc/Makefile.in b/doc/misc/Makefile.in
index fd07ea4..a03efaf 100644
--- a/doc/misc/Makefile.in
+++ b/doc/misc/Makefile.in
@@ -1,6 +1,6 @@
 ### @configure_input@
 
-# Copyright (C) 1994, 1996-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994, 1996-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
diff --git a/doc/misc/ada-mode.texi b/doc/misc/ada-mode.texi
index ca62145..1ac90cd 100644
--- a/doc/misc/ada-mode.texi
+++ b/doc/misc/ada-mode.texi
@@ -4,7 +4,7 @@
 @include docstyle.texi
 
 @copying
-Copyright @copyright{} 1999--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1999--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/auth.texi b/doc/misc/auth.texi
index fcbc83e..a46e3d7 100644
--- a/doc/misc/auth.texi
+++ b/doc/misc/auth.texi
@@ -1,7 +1,5 @@
 \input texinfo                  @c -*-texinfo-*-
 
address@hidden gnus-overrides.texi
-
 @set VERSION 0.3
 
 @setfilename ../../info/auth.info
@@ -11,7 +9,7 @@
 @copying
 This file describes the Emacs auth-source library.
 
-Copyright @copyright{} 2008--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2008--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -109,6 +107,15 @@ The @code{user} is the user name.  It's known as 
@var{:user} in
 @code{auth-source-search} queries.  You can also use @code{login} and
 @code{account}.
 
+You can also use this file to specify client certificates to use when
+setting up TLS connections.  The format is:
address@hidden
+machine @var{mymachine} port @var{myport} key @var{key} cert @var{cert}
address@hidden example
+
address@hidden and @var{cert} are filenames containing the key and
+certificate to use respectively.
+
 You can use spaces inside a password or other token by surrounding the
 token with either single or double quotes.
 
diff --git a/doc/misc/autotype.texi b/doc/misc/autotype.texi
index 7e2476c..5eb45e2 100644
--- a/doc/misc/autotype.texi
+++ b/doc/misc/autotype.texi
@@ -11,7 +11,7 @@
 @c  @cindex autotypist
 
 @copying
-Copyright @copyright{} 1994--1995, 1999, 2001--2018
+Copyright @copyright{} 1994--1995, 1999, 2001--2019
 Free Software Foundation, Inc.
 
 @quotation
diff --git a/doc/misc/bovine.texi b/doc/misc/bovine.texi
index fc744eb..f138c47 100644
--- a/doc/misc/bovine.texi
+++ b/doc/misc/bovine.texi
@@ -24,7 +24,7 @@
 @c %**end of header
 
 @copying
-Copyright @copyright{} 1999--2004, 2012--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1999--2004, 2012--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/calc.texi b/doc/misc/calc.texi
index f7b23d3..75bbae5 100644
--- a/doc/misc/calc.texi
+++ b/doc/misc/calc.texi
@@ -95,7 +95,7 @@ This file documents Calc, the GNU Emacs calculator, included 
with
 GNU Emacs @value{EMACSVER}.
 @end ifnotinfo
 
-Copyright @copyright{} 1990--1991, 2001--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1990--1991, 2001--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -1775,7 +1775,7 @@ evaluated first, then @samp{*}, then @samp{/}, then 
finally
 is equivalent to
 
 @example
-2 + ((3*4*5) / (6*(7^8)) - 9
+2 + ((3*4*5) / (6*(7^8))) - 9
 @end example
 
 @noindent
@@ -2026,7 +2026,7 @@ You can also ``unstore'' a variable when you are through 
with it:
 
 @smallexample
 @group
-2:  2 + 5 => 5
+2:  2 + 3 => 5
 1:  2 a + 2 b => 2 a + 2 b
     .
 
@@ -14661,7 +14661,7 @@ conventions of Yacas, a free computer algebra system.  
While the
 operators and functions in Yacas are similar to those of Calc, the names
 of built-in functions in Yacas are capitalized.  The Calc formula
 @samp{sin(2 x)}, for example, is entered and displayed @samp{Sin(2 x)}
-in Yacas mode,  and address@hidden(x^2)} is @samp{ArcSin(x^2)} in Yacas
+in Yacas mode,  and @samp{arcsin(x^2)} is @samp{ArcSin(x^2)} in Yacas
 mode.  Complex numbers are written  are written @samp{3 + 4 I}.
 The standard special constants are written @code{Pi}, @code{E},
 @code{I}, @code{GoldenRatio} and @code{Gamma}.  @code{Infinity}
diff --git a/doc/misc/cc-mode.texi b/doc/misc/cc-mode.texi
index 5a229c1..6db2c96 100644
--- a/doc/misc/cc-mode.texi
+++ b/doc/misc/cc-mode.texi
@@ -148,7 +148,17 @@ CC Mode
 @comment !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
 @comment Define an index for syntactic symbols.
address@hidden Version for Texinfo <= 4.x
address@hidden txicommandconditionals
address@hidden @c In texi2dvi, the @defindex would create an empty cc-mode.ss
+          @c For Info, unlike tex, @syncodeindex needs a matching @defindex.
 @defindex ss
address@hidden ifnottex
address@hidden ifclear
address@hidden Version for Texinfo >= 5.x
address@hidden txicommandconditionals
address@hidden ss
address@hidden ifset
 
 @comment Combine key, syntactic symbol and concept indices into one.
 @syncodeindex ss cp
@@ -157,7 +167,7 @@ CC Mode
 @copying
 This manual is for CC Mode in Emacs.
 
-Copyright @copyright{} 1995--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1995--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -2130,7 +2140,10 @@ with @code{c-doc-comment-style}: Supply a variable or 
function
 in @code{c-doc-comment-style}.  If it's a variable, it's prepended to
 @code{font-lock-keywords}.  If it's a function, it's called at mode
 initialization and the result is prepended.  For an example, see
address@hidden in @file{cc-fonts.el}.
address@hidden in @file{cc-fonts.el}.  It is even
+possible, to a limited extent, to fontify constructs inside a doc
+comment with other faces.  For an example, see pike autodoc comment
+style towards the end of @file{cc-fonts-el}.
 
 If you add support for another doc comment style, please consider
 contributing it: send a note to @email{bug-cc-mode@@gnu.org}.
@@ -2282,6 +2295,8 @@ method, ``Top-level commands or the customization 
interface''.
 
 If you make conflicting settings in several of these ways, the way
 that takes precedence is the one that appears latest in this list:
address@hidden Version of list for Texinfo <= 4.x
address@hidden txicommandconditionals
 @itemize @w{}
 @item
 @table @asis
@@ -2292,6 +2307,18 @@ that takes precedence is the one that appears latest in 
this list:
 @itemx File Local Variable setting
 @end table
 @end itemize
address@hidden ifclear
address@hidden Version of list for Texinfo >= 5.x
address@hidden txicommandconditionals
address@hidden @w{}
address@hidden Style
address@hidden File address@hidden earlier versions of @ccmode{}, a File Style 
setting took precedence over any other setting apart from a File Local Variable 
setting.}
address@hidden Top-level command or ``customization interface''
address@hidden Hook
address@hidden File Local Variable setting
address@hidden itemize
address@hidden ifset
+
 
 Here is a summary of the different ways of writing your configuration
 settings:
@@ -2548,7 +2575,7 @@ Basics}).
 @item
 The style variable @code{c-offsets-alist} (@pxref{c-offsets-alist}) is
 an association list with an element for each syntactic symbol.  It's
-handled a little differently from the other style variables.  It's
+handled a little differently from the other style variables.  Its
 default global binding is the empty list @code{nil}, rather than
 @code{set-from-style}.  Before the style system is initialized, you
 can add individual elements to @code{c-offsets-alist} by calling
@@ -5286,7 +5313,7 @@ The simplest and most used kind of ``offset'' setting in
 @defopt c-basic-offset
 @vindex basic-offset @r{(c-)}
 This style variable holds the basic offset between indentation levels.
-It's factory default is 4, but all the built-in styles set it
+Its factory default is 4, but all the built-in styles set it
 themselves, to some value between 2 (for @code{gnu} style) and 8 (for
 @code{bsd}, @code{linux}, and @code{python} styles).
 @end defopt
@@ -5614,9 +5641,9 @@ any problems writing custom line-up functions for AWK 
mode.
 
 The calling convention for line-up functions is described fully in
 @ref{Custom Line-Up}.  Roughly speaking, the return value is either an
-offset itself (such as @code{+} or @code{[0]}) or it's @code{nil},
-meaning ``this function is inappropriate in this case; try a
-different one''.  @xref{c-offsets-alist}.
+offset itself (such as @code{+} or @code{[0]}), another line-up
+function, or it's @code{nil}, meaning ``this function is inappropriate
+in this case - try a different one''.  @xref{c-offsets-alist}.
 
 The subsections below describe all the standard line-up functions,
 categorized by the sort of token the lining-up centers around.  For
@@ -5971,6 +5998,125 @@ brace block.
 
 @comment ------------------------------------------------------------
 
address@hidden c-lineup-2nd-brace-entry-in-arglist
address@hidden lineup-2nd-brace-entry-in-arglist (c-)
+Line up the second entry of a brace block under the first, when the
+first line is also contained in an arglist or an enclosing brace
address@hidden that line}.
+
+I.e. handle something like the following:
+
address@hidden
address@hidden
+set_line (line_t @address@hidden, address@hidden,
+                  address@hidden, address@hidden,       
@hereFn{brace-list-intro}
+                  address@hidden);
+         ^ enclosing parenthesis.
address@hidden group
address@hidden example
+                      
+
+The middle line of that example will have a syntactic context with
+three syntactic symbols, @code{arglist-cont-nonempty},
address@hidden, and @code{brace-list-entry} (@pxref{Brace
+List Symbols}).
+
+This function is intended for use in a list.  If the construct being
+analyzed isn't like the preceding, the function returns nil.
+Otherwise it returns the function
address@hidden, which the caller then uses
+to perform indentation.
+
address@hidden @code{brace-list-intro}.
address@hidden defun
+
address@hidden ------------------------------------------------------------
+
address@hidden c-lineup-class-decl-init-+
address@hidden lineup-class-decl-init-+ (c-)
+Line up the second entry of a class (etc.) initializer
address@hidden characters in from the identifier when:
address@hidden
address@hidden
+The type is a class, struct, union, etc. (but not an enum);
address@hidden
+There is a brace block in the type declaration, specifying it; and
address@hidden
+The first element of the initializer is on the same line as its
+opening brace.
address@hidden enumerate
+
+I.e. we have a construct like this:
+
address@hidden
address@hidden
+struct STR @{
+    int i; float f;
address@hidden str_1 = @{1, address@hidden,
+    str_2 = @{2,
+         3.1          @hereFn{brace-list-intro}
+    @};
+    @sssTBasicOffset{}
address@hidden group
address@hidden example
+        
+
+Note that the syntactic context of the @code{brace-list-intro} line
+also has a syntactic element with the symbol @code{brace-list-entry}
+(@pxref{Brace List Symbols}).
+
+This function is intended for use in a list.  If the above structure
+isn't present, the function returns nil, allowing a different offset
+specification to indent the line.
+
address@hidden @code{brace-list-intro}.
address@hidden defun
+
address@hidden ------------------------------------------------------------
+
address@hidden c-lineup-class-decl-init-after-brace
address@hidden lineup-class-decl-init-after-brace (c-)
+Line up the second entry of a class (etc.) initializer after its
+opening brace when:
address@hidden
address@hidden
+The type is a class, struct, union, etc. (but not an enum);
address@hidden
+There is a brace block in the type declaration, specifying it; and
address@hidden
+The first element of the initializer is on the same line as its
+opening brace.
address@hidden enumerate
+
+I.e. we have a construct like this:
+
address@hidden
address@hidden
+struct STR @{
+    int i; float f;
address@hidden str_1 = @{1, address@hidden,
+    str_2 = @{2,
+             3.1      @hereFn{brace-list-intro}
+    @};
address@hidden group
address@hidden example
+        
+
+Note that the syntactic context of the @code{brace-list-intro} line
+also has a syntactic element with the symbol @code{brace-list-entry}
+(@pxref{Brace List Symbols}).  Also note that this function works by
+returning the symbol @code{c-lineup-arglist-intro-after-paren}, which
+the caller then uses to perform the indentation.
+
+This function is intended for use in a list.  If the above structure
+isn't present, the function returns nil, allowing a different offset
+specification to indent the line.
+
address@hidden @code{brace-list-intro}.
address@hidden defun
+
address@hidden ------------------------------------------------------------
+
 @defun c-lineup-multi-inher
 @findex lineup-multi-inher @r{(c-)}
 Line up the classes in C++ multiple inheritance clauses and member
diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi
index 6985f19..eb06791 100644
--- a/doc/misc/cl.texi
+++ b/doc/misc/cl.texi
@@ -7,7 +7,7 @@
 @copying
 This file documents the GNU Emacs Common Lisp emulation package.
 
-Copyright @copyright{} 1993, 2001--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1993, 2001--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -4149,7 +4149,7 @@ package, @code{cl-typep} simply looks for a function 
called
 only if they used the default predicate name.
 
 @item :include
-This option implements a very limited form of C++-style inheritance.
+This option implements a very limited form of address@hidden inheritance.
 The argument is the name of another structure type previously
 created with @code{cl-defstruct}.  The effect is to cause the new
 structure type to inherit all of the included structure's slots
@@ -4194,6 +4194,10 @@ of a @code{person}, plus extra slots that are specific to
 astronauts.  Operations that work on people (like @code{person-name})
 work on astronauts just like other people.
 
address@hidden :noinline
+If this option is present, this structure's functions will not be
+inlined, even functions that normally would.
+
 @item :print-function
 In full Common Lisp, this option allows you to specify a function
 that is called to print an instance of the structure type.  The
diff --git a/doc/misc/dbus.texi b/doc/misc/dbus.texi
index f55a11d..c7d4998 100644
--- a/doc/misc/dbus.texi
+++ b/doc/misc/dbus.texi
@@ -10,7 +10,7 @@
 @syncodeindex fn cp
 
 @copying
-Copyright @copyright{} 2007--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2007--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/dired-x.texi b/doc/misc/dired-x.texi
index f65542f..b6a9d23 100644
--- a/doc/misc/dired-x.texi
+++ b/doc/misc/dired-x.texi
@@ -20,7 +20,7 @@
 @comment %**end of header (This is for running Texinfo on a region.)
 
 @copying
-Copyright @copyright{} 1994--1995, 1999, 2001--2018
+Copyright @copyright{} 1994--1995, 1999, 2001--2019
 Free Software Foundation, Inc.
 
 @quotation
diff --git a/doc/misc/ebrowse.texi b/doc/misc/ebrowse.texi
index b6f2c18..0d4a44e 100644
--- a/doc/misc/ebrowse.texi
+++ b/doc/misc/ebrowse.texi
@@ -11,7 +11,7 @@
 @copying
 This file documents Ebrowse, a C++ class browser for GNU Emacs.
 
-Copyright @copyright{} 2000--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2000--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/ede.texi b/doc/misc/ede.texi
index 42bedb1..7ab386c 100644
--- a/doc/misc/ede.texi
+++ b/doc/misc/ede.texi
@@ -6,7 +6,7 @@
 @copying
 This file describes EDE, the Emacs Development Environment.
 
-Copyright @copyright{} 1998--2001, 2004--2005, 2008--2018
+Copyright @copyright{} 1998--2001, 2004--2005, 2008--2019
 Free Software Foundation, Inc.
 
 @quotation
@@ -1038,7 +1038,7 @@ details on using @eieio{} to extending classes, and 
writing methods.
 
 If you intend to extend @ede{}, it is most likely that a new target type is
 needed in one of the existing project types.  The rest of this chapter
-will discuss extending the @code{ede-project} class, and it's targets.
+will discuss extending the @code{ede-project} class, and its targets.
 See @file{project-am.el} for basic details on adding targets to it.
 
 For the @code{ede-project} type, the core target class is called
@@ -1477,7 +1477,7 @@ Get the inode of the directory project @var{PROJ} is in.
 @end deffn
 
 @deffn Method ede-project-root :AFTER this
-If a project knows it's root, return it here.
+If a project knows its root, return it here.
 Allows for one-project-object-for-a-tree type systems.
 @end deffn
 
@@ -1486,7 +1486,7 @@ Find a subproject of @var{PROJ} that corresponds to 
@var{DIR}.
 @end deffn
 
 @deffn Method ede-project-root-directory :AFTER this &optional file
-If a project knows it's root, return it here.
+If a project knows its root, return it here.
 Allows for one-project-object-for-a-tree type systems.
 Optional @var{FILE} is the file to test.  It is ignored in preference
 of the anchor file for the project.
@@ -2516,7 +2516,7 @@ In sources for @var{THIS}, change version numbers to 
@var{VERSION}.
 @end deffn
 
 @deffn Method project-delete-target :AFTER ot
-Delete the current target @var{OT} from it's parent project.
+Delete the current target @var{OT} from its parent project.
 @end deffn
 
 @deffn Method ede-target-sourcecode :AFTER this
@@ -2715,7 +2715,7 @@ Converts all symbols into the objects to be used.
 @end deffn
 
 @deffn Method project-delete-target :AFTER this
-Delete the current target @var{THIS} from it's parent project.
+Delete the current target @var{THIS} from its parent project.
 @end deffn
 
 @deffn Method ede-proj-makefile-target-name :AFTER this
@@ -4013,7 +4013,7 @@ Type: @code{list}
 
 The commands used to execute this compiler.
 The object which uses this compiler will place these commands after
-it's rule definition.
+its rule definition.
 
 @item :autoconf
 Type: @code{list} @*
@@ -4125,7 +4125,7 @@ Type: @code{list}
 
 The commands used to execute this compiler.
 The object which uses this compiler will place these commands after
-it's rule definition.
+its rule definition.
 
 @item :objectextention
 Type: @code{string}
@@ -4265,7 +4265,7 @@ Type: @code{list}
 
 The commands used to execute this compiler.
 The object which uses this compiler will place these commands after
-it's rule definition.
+its rule definition.
 
 @item :objectextention
 Type: @code{string}
diff --git a/doc/misc/ediff.texi b/doc/misc/ediff.texi
index cce8321..c4ef1da 100644
--- a/doc/misc/ediff.texi
+++ b/doc/misc/ediff.texi
@@ -26,7 +26,7 @@
 This file documents Ediff, a comprehensive visual interface to Unix diff
 and patch utilities.
 
-Copyright @copyright{} 1995--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1995--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -1147,7 +1147,7 @@ file (unlike what the @code{patch} utility would usually 
do).  Instead, the
 source file retains its name and the result of applying the patch is placed
 in a temporary file that has the suffix @file{_patched} attached.
 Generally, this applies to files that are handled using black magic, such
-as special file handlers (ange-ftp and some compression and encryption
+as special file name handlers (ange-ftp and some compression and encryption
 packages also use this method).
 
 Regular files are treated by the @code{patch} utility in the usual manner,
diff --git a/doc/misc/edt.texi b/doc/misc/edt.texi
index 754e3c8..74224e9 100644
--- a/doc/misc/edt.texi
+++ b/doc/misc/edt.texi
@@ -6,7 +6,7 @@
 @copying
 This file documents the EDT emulation package for Emacs.
 
-Copyright @copyright{} 1986, 1992, 1994--1995, 1999--2018
+Copyright @copyright{} 1986, 1992, 1994--1995, 1999--2019
 Free Software Foundation, Inc.
 
 @quotation
diff --git a/doc/misc/efaq-w32.texi b/doc/misc/efaq-w32.texi
index e18bb73..8e067a7 100644
--- a/doc/misc/efaq-w32.texi
+++ b/doc/misc/efaq-w32.texi
@@ -15,7 +15,7 @@ Answers to Frequently asked Questions about using Emacs on 
Microsoft Windows.
 @include emacsver.texi
 
 @copying
-Copyright @copyright{} 2008, 2010-2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2008, 2010-2019 Free Software Foundation, Inc.
 
 @quotation
 This list of frequently asked questions about GNU Emacs on MS Windows
diff --git a/doc/misc/efaq.texi b/doc/misc/efaq.texi
index 18a857f..485776e 100644
--- a/doc/misc/efaq.texi
+++ b/doc/misc/efaq.texi
@@ -12,7 +12,7 @@
 @c appreciate a notice if you do).
 
 @copying
-Copyright @copyright{} 2001--2018 Free Software Foundation, address@hidden
+Copyright @copyright{} 2001--2019 Free Software Foundation, address@hidden
 Copyright @copyright{} 1994, 1995, 1996, 1997, 1998, 1999, 2000
 Reuven M. address@hidden
 Copyright @copyright{} 1992, 1993 Steven address@hidden
diff --git a/doc/misc/eieio.texi b/doc/misc/eieio.texi
index 689ff72..f56b2b6 100644
--- a/doc/misc/eieio.texi
+++ b/doc/misc/eieio.texi
@@ -12,7 +12,7 @@
 @copying
 This manual documents EIEIO, an object framework for Emacs Lisp.
 
-Copyright @copyright{} 2007--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2007--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -88,11 +88,11 @@ framework for writing object-oriented applications in Emacs.
 use @eieio{} to create classes, methods for those classes, and
 instances of classes.
 
-Here is a simple example of a class named @code{record}, containing
+Here is a simple example of a class named @code{person}, containing
 three slots named @code{name}, @code{birthday}, and @code{phone}:
 
 @example
-(defclass record () ; No superclasses
+(defclass person () ; No superclasses
   ((name :initarg :name
          :initform ""
          :type string
@@ -106,23 +106,23 @@ three slots named @code{name}, @code{birthday}, and 
@code{phone}:
    (phone :initarg :phone
           :initform ""
           :documentation "Phone number."))
-  "A single record for tracking people I know.")
+  "A class for tracking people I know.")
 @end example
 
 Each class can have methods, which are defined like this:
 
 @example
-(cl-defmethod call-record ((rec record) &optional scriptname)
-  "Dial the phone for the record REC.
+(cl-defmethod call-person ((pers person) &optional scriptname)
+  "Dial the phone for the person PERS.
 Execute the program SCRIPTNAME to dial the phone."
-  (message "Dialing the phone for %s"  (oref rec name))
+  (message "Dialing the phone for %s"  (oref pers name))
   (shell-command (concat (or scriptname "dialphone.sh")
                          " "
-                         (oref rec phone))))
+                         (oref pers phone))))
 @end example
 
 @noindent
-In this example, the first argument to @code{call-record} is a list,
+In this example, the first argument to @code{call-person} is a list,
 of the form (@var{varname} @var{classname}).  @var{varname} is the
 name of the variable used for the first argument; @var{classname} is
 the name of the class that is expected as the first argument for this
@@ -130,17 +130,17 @@ method.
 
 @eieio{} dispatches methods based on the type of the first argument.
 You can have multiple methods with the same name for different classes
-of object.  When the @code{call-record} method is called, the first
+of object.  When the @code{call-person} method is called, the first
 argument is examined to determine the class of that argument, and the
 method matching the input type is then executed.
 
 Once the behavior of a class is defined, you can create a new
-object of type @code{record}.  Objects are created by calling the
+object of type @code{person}.  Objects are created by calling the
 constructor.  The constructor is a function with the same name as your
 class which returns a new instance of that class.  Here is an example:
 
 @example
-(setq rec (record :name "Eric" :birthday "June" :phone "555-5555"))
+(setq pers (person :name "Eric" :birthday "June" :phone "555-5555"))
 @end example
 
 @noindent
@@ -157,19 +157,19 @@ first argument should be an object of a class which has 
had this
 method defined for it.  In this example it would look like this:
 
 @example
-(call-record rec)
+(call-person pers)
 @end example
 
 @noindent
 or
 
 @example
-(call-record rec "my-call-script")
+(call-person pers "my-call-script")
 @end example
 
 In these examples, @eieio{} automatically examines the class of
address@hidden, and ensures that the method defined above is called.  If
address@hidden is some other class lacking a @code{call-record} method, or
address@hidden, and ensures that the method defined above is called.  If
address@hidden is some other class lacking a @code{call-person} method, or
 some other data type, Emacs signals a @code{cl-no-applicable-method}
 error.  @ref{Signals}.
 
@@ -270,10 +270,18 @@ by a symbol with the name @var{class-name}.  @eieio{} 
stores the structure of
 the class as a symbol property of @var{class-name} (@pxref{Symbol
 Components,,,elisp,GNU Emacs Lisp Reference Manual}).
 
+When defining a class, @eieio{} overwrites any preexisting variable or
+function bindings for the symbol @var{class-name}, which may lead to
+undesired consequences.  Before naming a new class, you should check
+for name conflicts.  To help avoid cross-package conflicts you should
+choose a name with the same prefix you chose for the rest of your
+package's functions and variables (@pxref{Coding
+Conventions,,,elisp,GNU Emacs Lisp Reference Manual}).
+
 The @var{class-name} symbol's variable documentation string is a
 modified version of the doc string found in @var{options-and-doc}.
 Each time a method is defined, the symbol's documentation string is
-updated to include the methods documentation as well.
+updated to include the method's documentation as well.
 
 The parent classes for @var{class-name} is @var{superclass-list}.
 Each element of @var{superclass-list} must be a class.  These classes
@@ -625,10 +633,10 @@ function of @code{:initform}.
 @node Making New Objects
 @chapter Making New Objects
 
-Suppose we have a simple class is defined, such as:
+Suppose we have defined a simple class, such as:
 
 @example
-(defclass record ()
+(defclass my-class ()
    ( ) "Doc String")
 @end example
 
@@ -636,10 +644,10 @@ Suppose we have a simple class is defined, such as:
 It is now possible to create objects of that class type.
 
 Calling @code{defclass} has defined two new functions.  One is the
-constructor @var{record}, and the other is the predicate,
address@hidden
+constructor @var{my-class}, and the other is the predicate,
address@hidden
 
address@hidden record object-name &rest slots
address@hidden my-class object-name &rest slots
 
 This creates and returns a new object.  This object is not assigned to
 anything, and will be garbage collected if not saved.  This object
@@ -657,7 +665,7 @@ can do any valid Lispy thing you want with it, such as
 Example of creating an object from a class:
 
 @example
-(record :value 3 :reference nil)
+(my-class :value 3 :reference nil)
 @end example
 
 @end defun
diff --git a/doc/misc/emacs-gnutls.texi b/doc/misc/emacs-gnutls.texi
index a690ccf..add79d1 100644
--- a/doc/misc/emacs-gnutls.texi
+++ b/doc/misc/emacs-gnutls.texi
@@ -9,7 +9,7 @@
 @copying
 This file describes the Emacs GnuTLS integration.
 
-Copyright @copyright{} 2012--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2012--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -179,17 +179,35 @@ Just use @code{open-protocol-stream} or 
@code{open-network-stream}
 You should not have to use the @file{gnutls.el} functions directly.
 But you can test them with @code{open-gnutls-stream}.
 
address@hidden open-gnutls-stream name buffer host service &optional nowait
address@hidden open-gnutls-stream name buffer host service &optional parameters
 This function creates a buffer connected to a specific @var{host} and
address@hidden (port number or service name).  The parameters and their
-syntax are the same as those given to @code{open-network-stream}
-(@pxref{Network,, Network Connections, elisp, The Emacs Lisp Reference
-Manual}).  The connection process is called @var{name} (made unique if
-necessary).  This function returns the connection process.
-
-The @var{nowait} parameter means that the socket should be
-asynchronous, and the connection process will be returned to the
-caller before TLS negotiation has happened.
address@hidden (port number or service name).  The mandatory arguments
+and their syntax are the same as those given to
address@hidden (@pxref{Network,, Network Connections,
+elisp, The Emacs Lisp Reference Manual}).  The connection process is
+called @var{name} (made unique if necessary).  This function returns
+the connection process.
+
+The optional @var{parameters} argument is a list of keywords and
+values.  The only keywords which currently have any effect are
address@hidden:client-certificate} and @code{:nowait}.
+
+Passing @address@hidden:client certificate t}} triggers looking up of client
+certificates matching @var{host} and @var{service} using the
address@hidden library.  Any resulting client certificates are passed
+down to the lower TLS layers.  The format used by @file{.authinfo} to
+specify the per-server keys is described in @ref{Help for
+users,,auth-source, auth, Emacs auth-source Library}.
+
+Passing @address@hidden:nowait t}} means that the socket should be 
asynchronous,
+and the connection process will be returned to the caller before TLS
+negotiation has happened.
+
+For historical reasons @var{parameters} can also be a symbol, which is
+interpreted the same as passing a list containing @code{:nowait} and
+the value of that symbol.
+
+Example calls:
 
 @lisp
 ;; open a HTTPS connection
diff --git a/doc/misc/emacs-mime.texi b/doc/misc/emacs-mime.texi
index f46b2a7..dd651ff 100644
--- a/doc/misc/emacs-mime.texi
+++ b/doc/misc/emacs-mime.texi
@@ -1,7 +1,5 @@
 \input texinfo
 
address@hidden gnus-overrides.texi
-
 @setfilename ../../info/emacs-mime.info
 @settitle Emacs MIME Manual
 @include docstyle.texi
@@ -12,7 +10,7 @@
 @copying
 This file documents the Emacs MIME interface functionality.
 
-Copyright @copyright{} 1998--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1998--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -698,13 +696,15 @@ Translation}.
 A description of the part (@code{Content-Description}).
 
 @item creation-date
-RFC822 date when the part was created (@code{Content-Disposition}).
+Date when the part was created (@code{Content-Disposition}).
+This uses the format of RFC 822 or its successors.
 
 @item modification-date
-RFC822 date when the part was modified (@code{Content-Disposition}).
+RFC 822 (or later) date when the part was modified
+(@code{Content-Disposition}).
 
 @item read-date
-RFC822 date when the part was read (@code{Content-Disposition}).
+RFC 822 (or later) date when the part was read (@code{Content-Disposition}).
 
 @item recipients
 Who to encrypt/sign the part to.  This field is used to override any
@@ -754,7 +754,7 @@ be obtained.  Values include @samp{ftp}, @samp{anon-ftp}, 
@samp{tftp},
 @samp{localfile}, and @samp{mailserver}.  (@code{Content-Type}.)
 
 @item expiration
-The RFC822 date after which the file may no longer be fetched.
+RFC 822 (or later) date after which the file may no longer be fetched.
 (@code{Content-Type}.)
 
 @item size
@@ -1301,7 +1301,7 @@ on.  High-level functionality is dealt with in the first 
chapter
 @menu
 * rfc2045::      Encoding @code{Content-Type} headers.
 * rfc2231::      Parsing @code{Content-Type} headers.
-* ietf-drums::   Handling mail headers defined by RFC822bis.
+* ietf-drums::   Handling mail headers defined by RFC 2822.
 * rfc2047::      En/decoding encoded words in headers.
 * time-date::    Functions for parsing dates and manipulating time.
 * qp::           Quoted-Printable en/decoding.
@@ -1385,8 +1385,8 @@ Encode a parameter in headers likes @code{Content-Type} 
and
 @node ietf-drums
 @section ietf-drums
 
address@hidden is an IETF working group that is working on the replacement
-for RFC822.
address@hidden was an IETF working group that worked on Internet RFC 2822,
+the first successor to RFC 822 and a predecessor of the current email standard.
 
 The functions provided by this library include:
 
@@ -1597,7 +1597,7 @@ The five data representations used are the following:
 
 @table @var
 @item date
-An RFC822 (or similar) date string.  For instance: @code{"Sat Sep 12
+An RFC 822 (or similar) date string.  For instance: @code{"Sat Sep 12
 12:21:54 1998 +0200"}.
 
 @item time
@@ -1889,55 +1889,55 @@ in @file{/etc/mailcap} will ``win'' over an 
@samp{image/*} setting in
 The Emacs @acronym{MIME} library implements handling of various elements
 according to a (somewhat) large number of RFCs, drafts and standards
 documents.  This chapter lists the relevant ones.  They can all be
-fetched from @uref{http://quimby.gnus.org/notes/}.
+fetched from @uref{https://www.rfc-editor.org}.
 
 @table @dfn
address@hidden RFC822
address@hidden STD11
-Standard for the Format of ARPA Internet Text Messages.
address@hidden RFC 5322
+Internet Message Format
 
address@hidden RFC1036
-Standard for Interchange of USENET Messages
address@hidden RFC 5536
+Netnews Article Format
 
address@hidden RFC2045
address@hidden RFC 2045
 Format of Internet Message Bodies
 
address@hidden RFC2046
address@hidden RFC 2046
 Media Types
 
address@hidden RFC2047
address@hidden RFC 2047
 Message Header Extensions for address@hidden Text
 
address@hidden RFC2048
-Registration Procedures
address@hidden RFC 6838
+Media Type Specifications and Registration Procedures
 
address@hidden RFC2049
address@hidden RFC 4289
+Registration Procedures (obsoleting RFC 2048)
+
address@hidden RFC 2049
 Conformance Criteria and Examples
 
address@hidden RFC2231
address@hidden RFC 2231
 @acronym{MIME} Parameter Value and Encoded Word Extensions: Character Sets,
 Languages, and Continuations
 
address@hidden RFC1843
address@hidden RFC 1843
 HZ---A Data Format for Exchanging Files of Arbitrarily Mixed Chinese and
 @acronym{ASCII} characters
 
address@hidden draft-ietf-drums-msg-fmt-05.txt
-Draft for the successor of RFC822
-
address@hidden RFC2112
address@hidden RFC 2387
 The @acronym{MIME} Multipart/Related Content-type
 
address@hidden RFC1892
-The Multipart/Report Content Type for the Reporting of Mail System
address@hidden RFC 6522
address@hidden STD 73
+The Multipart/Report Media Type for the Reporting of Mail System
 Administrative Messages
 
address@hidden RFC2183
address@hidden RFC 2183
 Communicating Presentation Information in Internet Messages: The
 Content-Disposition Header Field
 
address@hidden RFC2646
-Documentation of the text/plain format parameter for flowed text.
address@hidden RFC 3676
+The Text/Plain Format and DelSp Parameters
 
 @end table
 
diff --git a/doc/misc/epa.texi b/doc/misc/epa.texi
index d5dfe70..330ce70 100644
--- a/doc/misc/epa.texi
+++ b/doc/misc/epa.texi
@@ -10,7 +10,7 @@
 @copying
 This file describes EasyPG Assistant @value{VERSION}.
 
-Copyright @copyright{} 2007--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2007--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/erc.texi b/doc/misc/erc.texi
index 55556c5..e1d2217 100644
--- a/doc/misc/erc.texi
+++ b/doc/misc/erc.texi
@@ -10,7 +10,7 @@
 @copying
 This manual is for ERC as distributed with Emacs @value{EMACSVER}.
 
-Copyright @copyright{} 2005--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2005--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/ert.texi b/doc/misc/ert.texi
index 6a34f5c..d2d8655 100644
--- a/doc/misc/ert.texi
+++ b/doc/misc/ert.texi
@@ -15,7 +15,7 @@
 @end direntry
 
 @copying
-Copyright @copyright{} 2008, 2010--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2008, 2010--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi
index c19d5e1..716b4b7 100644
--- a/doc/misc/eshell.texi
+++ b/doc/misc/eshell.texi
@@ -10,7 +10,7 @@
 @copying
 This manual is for Eshell, the Emacs shell.
 
-Copyright @copyright{} 1999--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1999--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -213,8 +213,8 @@ available in the Emacs Lisp library.  It does this by 
transforming the
 input line into a callable Lisp address@hidden see the Lisp form that will be 
invoked, type: @samp{eshell-parse-command "echo hello"}}
 
 The command can be either an Elisp function or an external command.
-Eshell looks first for an @ref{Aliases, alias} with the same name as the
-command, then a @ref{Built-ins, built-in command} or a function with the
+Eshell looks first for an alias (@pxref{Aliases}) with the same name as the
+command, then a built-in (@pxref{Built-ins}) or a function with the
 same name; if there is no match, it then tries to execute it as an
 external command.
 
@@ -253,7 +253,7 @@ eshell/ls is a compiled Lisp function in `em-ls.el'
 @end example
 
 If you want to discard a given built-in command, you could declare an
-alias, @ref{Aliases}.  Example:
+alias (@pxref{Aliases}).  Example:
 
 @example
 ~ $ which sudo
@@ -280,8 +280,7 @@ with no arguments, prints the current paths in this 
variable.
 
 @item alias
 @cmindex alias
-Define an alias (@pxref{Aliases}).  This does not add it to the aliases
-file.
+Define an alias (@pxref{Aliases}).  This adds it to the aliases file.
 
 @item clear
 @cmindex clear
@@ -419,7 +418,7 @@ Lisp functions, based on successful completion).
 
 @end table
 
address@hidden for the built-in variables @samp{$*}, @samp{$1},
address@hidden, for the built-in variables @samp{$*}, @samp{$1},
 @samp{$2}, @dots{}, in alias definitions.
 
 @node Variables
@@ -500,15 +499,14 @@ be directories @emph{and} files.  Eshell provides 
predefined completions
 for the built-in functions and some common external commands, and you
 can define your own for any command.
 
-Eshell completion also works for lisp forms and glob patterns. If the
-point is on a lisp form, then @key{TAB} will behave similarly to completion
-in @code{elisp-mode} and @code{lisp-interaction-mode}.  For glob
-patterns, If there are few enough possible completions of the patterns,
-they will be cycled when @key{TAB} is pressed, otherwise it will be removed
-from the input line and the possible completions will be listed.
+Eshell completion also works for lisp forms and glob patterns. If the point is
+on a lisp form, then @key{TAB} will behave similarly to completion in
address@hidden and @code{lisp-interaction-mode}.  For glob patterns, the
+pattern will be removed from the input line, and replaced by the
+completion.
 
-If you want to see the entire list of possible completions when it's
-below the cycling threshold, press @kbd{M-?}.
+If you want to see the entire list of possible completions (e.g. when it's
+below the @code{completion-cycle-threshold}), press @kbd{M-?}.
 
 @subsection pcomplete
 Pcomplete, short for programmable completion, is the completion
@@ -630,8 +628,8 @@ to @code{"hello"}.
 Eshell's globbing syntax is very similar to that of Zsh.  Users coming
 from Bash can still use Bash-style globbing, as there are no
 incompatibilities.  Most globbing is pattern-based expansion, but there
-is also predicate-based expansion.  See
address@hidden Generation, , , zsh, The Z Shell Manual}
+is also predicate-based expansion.  @xref{Filename Generation, , ,
+zsh, The Z Shell Manual},
 for full syntax.  To customize the syntax and behavior of globbing in
 Eshell see the address@hidden@xref{Easy Customization, , , emacs,
 The GNU Emacs Manual}.}
diff --git a/doc/misc/eudc.texi b/doc/misc/eudc.texi
index e41be86..117b62e 100644
--- a/doc/misc/eudc.texi
+++ b/doc/misc/eudc.texi
@@ -14,7 +14,7 @@ This file documents EUDC version 1.40.0.
 EUDC is the Emacs Unified Directory Client, a common interface to
 directory servers and contact information.
 
-Copyright @copyright{} 1998, 2000--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1998, 2000--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/eww.texi b/doc/misc/eww.texi
index aa17eee..8dc58e8 100644
--- a/doc/misc/eww.texi
+++ b/doc/misc/eww.texi
@@ -8,7 +8,7 @@
 @copying
 This file documents the GNU Emacs Web Wowser (EWW) package.
 
-Copyright @copyright{} 2014--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2014--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -85,6 +85,10 @@ searched via @code{eww-search-prefix}.  The default search 
engine is
 either prefix the file name with @code{file://} or use the command
 @kbd{M-x eww-open-file}.
 
+  If you invoke @code{eww} with a prefix argument, as in @address@hidden
+M-x eww}}, it will create a new EWW buffer instead of reusing the
+default one, which is normally called @file{*eww*}.
+
 @findex eww-quit
 @findex eww-reload
 @findex eww-copy-page-url
@@ -118,16 +122,17 @@ variable-pitch fonts or not.  This sets the 
@code{shr-use-fonts} variable.
 @findex eww-toggle-colors
 @findex shr-use-colors
 @kindex F
-  The @kbd{C} command (@code{eww-toggle-colors}) toggles whether to use
+  The @kbd{M-C} command (@code{eww-toggle-colors}) toggles whether to use
 HTML-specified colors or not.  This sets the @code{shr-use-colors} variable.
 
 @findex eww-download
 @vindex eww-download-directory
 @kindex d
 @cindex Download
-  A URL under the point can be downloaded with @kbd{d}
-(@code{eww-download}).  The file will be written to the directory
-specified in @code{eww-download-directory} (Default: @file{~/Downloads/}).
+  A URL can be downloaded with @kbd{d} (@code{eww-download}).  This
+will download the link under point if there is one, or else the URL of
+the current page.  The file will be written to the directory specified
+in @code{eww-download-directory} (default: @file{~/Downloads/}).
 
 @findex eww-back-url
 @findex eww-forward-url
diff --git a/doc/misc/flymake.texi b/doc/misc/flymake.texi
index bda7e14..894203c 100644
--- a/doc/misc/flymake.texi
+++ b/doc/misc/flymake.texi
@@ -14,7 +14,7 @@
 This manual is for GNU Flymake (version @value{VERSION}, @value{UPDATED}),
 which is a universal on-the-fly syntax checker for GNU Emacs.
 
-Copyright @copyright{} 2004--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2004--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/forms.texi b/doc/misc/forms.texi
index 7046341..d669ed6 100644
--- a/doc/misc/forms.texi
+++ b/doc/misc/forms.texi
@@ -19,7 +19,7 @@
 @copying
 This file documents Forms mode, a form-editing major mode for GNU Emacs.
 
-Copyright @copyright{} 1989, 1997, 2001--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1989, 1997, 2001--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/gnus-coding.texi b/doc/misc/gnus-coding.texi
index 4590524..6affea4 100644
--- a/doc/misc/gnus-coding.texi
+++ b/doc/misc/gnus-coding.texi
@@ -8,7 +8,7 @@
 @syncodeindex pg cp
 
 @copying
-Copyright @copyright{} 2004--2005, 2007--2018 Free Software
+Copyright @copyright{} 2004--2005, 2007--2019 Free Software
 Foundation, Inc.
 
 @quotation
@@ -141,7 +141,7 @@ There are no Gnus dependencies in this file.
 There are no Gnus dependencies in this file.
 
 @item ietf-drums.el
-Functions for parsing RFC822bis headers.
+Functions for parsing RFC 2822 headers.
 @c As of 2005-10-21...
 There are no Gnus dependencies in this file.
 
@@ -227,161 +227,6 @@ ends (probably @file{nnml.el}, @file{nnfolder.el} and
 @c requires nnheader.
 
 
address@hidden Compatibility
-
-No Gnus and Gnus 5.10.10 and up should work on:
address@hidden @bullet
address@hidden
-Emacs 21.1 and up.
address@hidden
-XEmacs 21.4 and up.
address@hidden itemize
-
-Gnus 5.10.8 and below should work on:
address@hidden @bullet
address@hidden
-Emacs 20.7 and up.
address@hidden
-XEmacs 21.1 and up.
address@hidden itemize
-
address@hidden Gnus Maintenance Guide
address@hidden Gnus Maintenance Guide
-
address@hidden Stable and development versions
-
-The development of Gnus normally is done on the Git repository trunk
-as of April 19, 2010 (formerly it was done in CVS; the repository is
-at http://git.gnus.org), i.e., there are no separate branches to
-develop and test new features.  Most of the time, the trunk is
-developed quite actively with more or less daily changes.  Only after
-a new major release, e.g., 5.10.1, there's usually a feature period of
-several months.  After the release of Gnus 5.10.6 the development of
-new features started again on the trunk while the 5.10 series is
-continued on the stable branch (v5-10) from which more stable releases
-will be done when needed (5.10.8, @dots{}).  @ref{Gnus Development,
-,Gnus Development, gnus, The Gnus Newsreader}
-
-Stable releases of Gnus finally become part of Emacs.  E.g., Gnus 5.8
-became a part of Emacs 21 (relabeled to Gnus 5.9).  The 5.10 series
-became part of Emacs 22 as Gnus 5.11.
-
address@hidden Syncing
-
address@hidden Some MIDs related to this follow.  Use 
http://thread.gmane.org/MID
address@hidden (and click on the subject) to get the thread on Gmane.
-
address@hidden Some quotes from Miles Bader follow...
-
address@hidden <address@hidden>
address@hidden <address@hidden>
-
-In the past, the inclusion of Gnus into Emacs was quite cumbersome.  For
-each change made to Gnus in Emacs repository, it had to be checked that
-it was applied to the new Gnus version, too.  Else, bug fixes done in
-Emacs repository might have been lost.
-
-With the inclusion of Gnus 5.10, Miles Bader has set up an Emacs-Gnus
-gateway to ensure the bug fixes from Emacs CVS are propagated to Gnus
-CVS semi-automatically.
-
-After Emacs moved to bzr and Gnus moved to git, Katsumi Yamaoka has
-taken over the chore of keeping Emacs and Gnus in sync.  In general,
-changes made to one repository will usually be replicated in the other
-within a few days.
-
-Basically the idea is that the gateway will cause all common files in
-Emacs and Gnus v5-13 to be identical except when there's a very good
-reason (e.g., the Gnus version string in Emacs says @samp{5.11}, but
-the v5-13 version string remains @samp{5.13.x}).  Furthermore, all
-changes in these files in either Emacs or the v5-13 branch will be
-installed into the Gnus git trunk, again except where there's a good
-reason.
-
address@hidden (typically so far the only exception has been that the changes
address@hidden already exist in the trunk in modified form).
-Because of this, when the next major version of Gnus will be included in
-Emacs, it should be very easy---just plonk in the files from the Gnus
-trunk without worrying about lost changes from the Emacs tree.
-
-The effect of this is that as hacker, you should generally only have to
-make changes in one place:
-
address@hidden
address@hidden
-If it's a file which is thought of as being outside of Gnus (e.g., the
-new @file{encrypt.el}), you should probably make the change in the Emacs
-tree, and it will show up in the Gnus tree a few days later.
-
-If you don't have Emacs repository access (or it's inconvenient), you
-can change such a file in the v5-10 branch, and it should propagate to
-the Emacs repository---however, it will get some extra scrutiny (by
-Miles) to see if the changes are possibly controversial and need
-discussion on the mailing list.  Many changes are obvious bug-fixes
-however, so often there won't be any problem.
-
address@hidden
-If it's to a Gnus file, and it's important enough that it should be part
-of Emacs and the v5-10 branch, then you can make the change on the v5-10
-branch, and it will go into Emacs and the Gnus git trunk (a few days
-later).  The most prominent examples for such changes are bug-fixed
-including improvements on the documentation.
-
-If you know that there will be conflicts (perhaps because the affected
-source code is different in v5-10 and the Gnus git trunk), then you can
-install your change in both places, and when I try to sync them, there
-will be a conflict---however, since in most such cases there would be a
-conflict @emph{anyway}, it's often easier for me to resolve it simply if
-I see two @samp{identical} changes, and can just choose the proper one,
-rather than having to actually fix the code.
-
address@hidden
-For general Gnus development changes, of course you just make the
-change on the Gnus Git trunk and it goes into Emacs a few years
-later... :-)
-
address@hidden itemize
-
-Of course in any case, if you just can't wait for me to sync your
-change, you can commit it in more than one place and probably there will
-be no problem; usually the changes are textually identical anyway, so
-can be easily resolved automatically (sometimes I notice silly things in
-such multiple commits, like whitespace differences, and unify those ;-).
-
-
address@hidden I do Emacs->Gnus less often (than Gnus->Emacs) because it tends 
to
address@hidden require more manual work.
-
address@hidden By default I sync about once a week.  I also try to follow any 
Gnus
address@hidden threads on the mailing lists and make sure any changes being 
discussed
address@hidden are kept more up-to-date (so say 1-2 days delay for "topical" 
changes).
-
address@hidden <address@hidden>
-
address@hidden BTW, just to add even more verbose explanation about the syncing 
thing:
-
address@hidden Miscellanea
-
address@hidden @file{GNUS-NEWS}
-
-The @file{etc/GNUS-NEWS} is created from
address@hidden/misc/gnus-news.texi}.  Don't edit @file{etc/GNUS-NEWS}.
-Edit @file{doc/misc/gnus-news.texi}, type @command{make
-update-gnus-news} in the @file{lisp} directory and commit
address@hidden/GNUS-NEWS} and @file{doc/misc/gnus-news.texi}.
-
address@hidden Conventions for version information in defcustoms
-
-For new customizable variables introduced in Oort Gnus (including the
-v5-10 branch) use @code{:version "22.1" ;; Oort Gnus} (including the
-comment) or, e.g., @code{:version "22.2" ;; Gnus 5.10.10} if the feature
-was added for Emacs 22.2 and Gnus 5.10.10.
address@hidden
-If the variable is new in No Gnus use @code{:version "23.1" ;; No Gnus}.
-
-The same applies for customizable variables when its default value was
-changed.
-
 @node GNU Free Documentation License
 @appendix GNU Free Documentation License
 @include doclicense.texi
diff --git a/doc/misc/gnus-faq.texi b/doc/misc/gnus-faq.texi
index 2ae5a0a..075f521 100644
--- a/doc/misc/gnus-faq.texi
+++ b/doc/misc/gnus-faq.texi
@@ -1,7 +1,7 @@
 @c \input texinfo @c -*-texinfo-*-
 @c Uncomment 1st line before texing this file alone.
 @c %**start of header
address@hidden Copyright (C) 1995, 2001-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 1995, 2001-2019 Free Software Foundation, Inc.
 @c
 @c @setfilename gnus-faq.info
 @c @settitle Frequently Asked Questions
@@ -284,7 +284,7 @@ what's this?
 @subsubheading Answer
 
 You get the message described in the q/a pair above while
-starting Gnus, right? It's an other symptom for the same
+starting Gnus, right? It's another symptom for the same
 problem, so read the answer above.
 
 @node FAQ 2-3
diff --git a/doc/misc/gnus-news.el b/doc/misc/gnus-news.el
deleted file mode 100644
index 301ea93..0000000
--- a/doc/misc/gnus-news.el
+++ /dev/null
@@ -1,115 +0,0 @@
-;;; gnus-news.el --- a hack to create GNUS-NEWS from texinfo source
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
-
-;; Author: Reiner Steib  <address@hidden>
-;; Keywords: tools
-
-;; This file is part of GNU Emacs.
-
-;; GNU Emacs is free software: you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation, either version 3 of the License, or
-;; (at your option) any later version.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;;; Code:
-
-(defvar gnus-news-header-disclaimer
-"GNUS NEWS -- history of user-visible changes.
-
-Copyright (C) 1999-2018 Free Software Foundation, Inc.
-See the end of the file for license conditions.
-
-Please send Gnus bug reports to address@hidden
-For older news, see Gnus info node \"New Features\".\n\n")
-
-(defvar gnus-news-trailer
-"
-* For older news, see Gnus info node \"New Features\".
-
-----------------------------------------------------------------------
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-\(at your option) any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
-
-\nLocal variables:\nmode: outline
-paragraph-separate: \"[        ]*$\"\nend:\n")
-
-(defvar gnus-news-makeinfo-command "makeinfo")
-
-(defvar gnus-news-fill-column 80)
-
-(defvar gnus-news-makeinfo-switches
-  (concat " --no-headers --paragraph-indent=0"
-         " --no-validate" ;; Allow unresolved references.
-         " --fill-column=" (number-to-string
-                            (+ 3 ;; will strip leading spaces later
-                               (or gnus-news-fill-column 80)))))
-
-(defun batch-gnus-news ()
-  "Make GNUS-NEWS in batch mode."
-  (let (infile outfile)
-    (setq infile (car command-line-args-left)
-         command-line-args-left (cdr command-line-args-left)
-         outfile (car command-line-args-left)
-         command-line-args-left nil)
-    (if (and infile outfile)
-       (message "Creating `%s' from `%s'..." outfile infile)
-      (error "Not enough files given."))
-    (gnus-news-translate-file infile outfile)))
-
-(defun gnus-news-translate-file (infile outfile)
-  "Translate INFILE (texinfo) to OUTFILE (GNUS-NEWS)."
-  (let* ((dir (concat (or (getenv "srcdir") ".") "/"))
-        (infile (concat dir infile))
-        (buffer (find-file-noselect (concat dir outfile))))
-    (with-temp-buffer
-      ;; Could be done using 'texinfmt' stuff as in 'infohack.el'.
-      (insert
-       (shell-command-to-string
-       (concat gnus-news-makeinfo-command " "
-               gnus-news-makeinfo-switches " " infile)))
-      (goto-char (point-max))
-      (delete-char -1)
-      (goto-char (point-min))
-      (save-excursion
-       (while (re-search-forward "^   \\* " nil t)
-         (replace-match "\f\n* ")))
-      (save-excursion
-       (while (re-search-forward "^        \\* " nil t)
-         (replace-match "** ")))
-      (save-excursion
-       (while (re-search-forward "^     " nil t)
-         (replace-match "")))
-      ;; Avoid '*' from @ref at beginning of line:
-      (save-excursion
-       (while (re-search-forward "^\\*Note" nil t)
-         (replace-match " \\&")))
-      (goto-char (point-min))
-      (insert gnus-news-header-disclaimer)
-      (goto-char (point-max))
-      (insert gnus-news-trailer)
-      (write-region (point-min) (point-max) outfile))))
-
-;;; gnus-news.el ends here
diff --git a/doc/misc/gnus-news.texi b/doc/misc/gnus-news.texi
deleted file mode 100644
index 171f59a..0000000
--- a/doc/misc/gnus-news.texi
+++ /dev/null
@@ -1,371 +0,0 @@
address@hidden -*-texinfo-*-
-
address@hidden Copyright (C) 2004-2018 Free Software Foundation, Inc.
-
address@hidden    Permission is granted to anyone to make or distribute 
verbatim copies
address@hidden    of this document as received, in any medium, provided that the
address@hidden    copyright notice and this permission notice are preserved,
address@hidden    thus giving the recipient permission to redistribute in turn.
-
address@hidden    Permission is granted to distribute modified versions
address@hidden    of this document, or of portions of it,
address@hidden    under the above conditions, provided also that they
address@hidden    carry prominent notices stating who last changed them.
-
address@hidden This file contains a list of news features Gnus.  It is supposed 
to be
address@hidden included in 'gnus.texi'.  'GNUS-NEWS' is automatically generated 
from
address@hidden this file (see 'gnus-news.el').
-
address@hidden @bullet
-
address@hidden Supported Emacs versions
-The following Emacs versions are supported by No Gnus:
address@hidden @bullet
-
address@hidden Emacs 22 and up
address@hidden XEmacs 21.4
address@hidden XEmacs 21.5
address@hidden SXEmacs
-
address@hidden itemize
-
address@hidden Installation changes
-
address@hidden @bullet
address@hidden Upgrading from previous (stable) version if you have used No 
Gnus.
-
-If you have tried No Gnus (the unstable Gnus branch leading to this
-release) but went back to a stable version, be careful when upgrading
-to this version.  In particular, you will probably want to remove the
address@hidden/News/marks} directory (perhaps selectively), so that flags are
-read from your @file{~/.newsrc.eld} instead of from the stale marks
-file, where this release will store flags for nntp.  See a later entry
-for more information about nntp marks.  Note that downgrading isn't
-safe in general.
-
address@hidden Incompatibility when switching from Emacs 23 to Emacs 22
-In Emacs 23, Gnus uses Emacs's new internal coding system @code{utf-8-emacs}
-for saving articles drafts and @file{~/.newsrc.eld}.  These files may not
-be read correctly in Emacs 22 and below.  If you want to use Gnus across
-different Emacs versions, you may set @code{mm-auto-save-coding-system}
-to @code{emacs-mule}.
address@hidden FIXME: Untested.  (Or did anyone test it?)
address@hidden Cf. 
http://thread.gmane.org/gmane.emacs.gnus.general/66251/focus=66344
-
address@hidden Lisp files are now installed in @file{.../site-lisp/gnus/} by 
default.
-It defaulted to @file{.../site-lisp/} formerly.  In addition to this,
-the new installer issues a warning if other Gnus installations which
-will shadow the latest one are detected.  You can then remove those
-shadows manually or remove them using @code{make
-remove-installed-shadows}.
-
address@hidden The installation directory's name is allowed to have spaces 
and/or tabs.
address@hidden itemize
-
address@hidden New packages and libraries within Gnus
-
address@hidden @bullet
-
address@hidden New version of @code{nnimap}
-
address@hidden has been reimplemented in a mostly-compatible way.  See
-the Gnus manual for a description of the new interface.  In
-particular, @code{nnimap-inbox} and the client side split method has
-changed.
-
address@hidden Gnus includes the Emacs Lisp @acronym{SASL} library.
-
-This provides a clean @acronym{API} to @acronym{SASL} mechanisms from
-within Emacs.  The user visible aspects of this, compared to the earlier
-situation, include support for @address@hidden and
address@hidden   @xref{Top, ,Emacs SASL, sasl, Emacs SASL}.
-
address@hidden ManageSieve connections uses the @acronym{SASL} library by 
default.
-
-The primary change this brings is support for @acronym{DIGEST-MD5} and
address@hidden, when the server supports it.
-
address@hidden Gnus includes a password cache mechanism in password.el.
-
-It is enabled by default (see @code{password-cache}), with a short
-timeout of 16 seconds (see @code{password-cache-expiry}).  If
address@hidden is used as the @acronym{PGP} back end, the @acronym{PGP}
-passphrase is managed by this mechanism.  Passwords for ManageSieve
-connections are managed by this mechanism, after querying the user
-about whether to do so.
-
address@hidden Using EasyPG with Gnus
-When EasyPG, is available, Gnus will use it instead of @acronym{PGG}.
-EasyPG is an Emacs user interface to GNU Privacy Guard.  @xref{Top,
-,EasyPG Assistant user's manual, epa, EasyPG Assistant user's manual}.
-EasyPG is included in Emacs 23 and available separately as well.
address@hidden itemize
-
address@hidden Changes in group mode
address@hidden ************************
-
address@hidden @bullet
-
address@hidden
-Symbols like @code{gcc-self} now have the same precedence rules in
address@hidden as other ``real'' variables: The last match
-wins instead of the first match.
-
address@hidden
-Old intermediate incoming mail files (@file{Incoming*}) are deleted
-after a couple of days, not immediately.  @xref{Mail Source
-Customization}.
-(New in Gnus 5.10.10 / No Gnus 0.8)
address@hidden This entry is also present in the node "Oort Gnus".
-
address@hidden itemize
-
address@hidden Changes in summary and article mode
-
address@hidden @bullet
-
address@hidden There's now only one variable that determines how @acronym{HTML}
-is rendered: @code{mm-text-html-renderer}.
-
address@hidden Gnus now supports sticky article buffers.  Those are article 
buffers
-that are not reused when you select another article.  @xref{Sticky
-Articles}.
-
address@hidden @item Bookmarks
address@hidden FIXME: To be added
-
address@hidden Gnus can selectively display @samp{text/html} articles
-with a WWW browser with @kbd{K H}.  @xref{MIME Commands}.
-
address@hidden gnus-registry-marks
address@hidden FIXME: To be added
-
address@hidden International host names (@acronym{IDNA}) can now be decoded
-inside article bodies using @kbd{W i}
-(@code{gnus-summary-idna-message}).  This requires that GNU Libidn
-(@url{https://www.gnu.org/software/libidn/}) has been installed.
address@hidden FIXME: Also mention @code{message-use-idna}?
-
address@hidden The address@hidden group names handling has been much
-improved.  The back ends that fully support address@hidden group
-names are now @code{nntp}, @code{nnml}, and @code{nnrss}.  Also the
-agent, the cache, and the marks features work with those back ends.
address@hidden Group Names}.
-
address@hidden Gnus now displays @acronym{DNS} master files sent as text/dns
-using dns-mode.
-
address@hidden Gnus supports new limiting commands in the Summary buffer:
address@hidden/ r} (@code{gnus-summary-limit-to-replied}) and @kbd{/ R}
-(@code{gnus-summary-limit-to-recipient}).  @xref{Limiting}.
-
address@hidden You can now fetch all ticked articles from the server using
address@hidden t} (@code{gnus-summary-insert-ticked-articles}).  @xref{Summary
-Generation Commands}.
-
address@hidden Gnus supports a new sort command in the Summary buffer:
address@hidden C-s C-t} (@code{gnus-summary-sort-by-recipient}).  @xref{Summary
-Sorting}.
-
address@hidden @acronym{S/MIME} now features @acronym{LDAP} user certificate 
searches.
-You need to configure the server in @code{smime-ldap-host-list}.
-
address@hidden URLs inside address@hidden headers are retrieved and imported
-to your PGP key ring when you click on them.
-
address@hidden
-Picons can be displayed right from the textual address, see
address@hidden  @xref{Picons}.
-
address@hidden @acronym{ANSI} @acronym{SGR} control sequences can be transformed
-using @kbd{W A}.
-
address@hidden sequences are used in some Chinese hierarchies for
-highlighting articles (@code{gnus-article-treat-ansi-sequences}).
-
address@hidden Gnus now MIME decodes articles even when they lack 
"MIME-Version" header.
-This changes the default of @code{gnus-article-loose-mime}.
-
address@hidden @code{gnus-decay-scores} can be a regexp matching score files.
-For example, set it to @samp{\\.ADAPT\\'} and only adaptive score files
-will be decayed.  @xref{Score Decays}.
-
address@hidden Strings prefixing to the @code{To} and @code{Newsgroup} headers 
in
-summary lines when using @code{gnus-ignored-from-addresses} can be
-customized with @code{gnus-summary-to-prefix} and
address@hidden  @xref{To From Newsgroups}.
-
address@hidden You can replace @acronym{MIME} parts with external bodies.
-See @code{gnus-mime-replace-part} and @code{gnus-article-replace-part}.
address@hidden Commands}, @ref{Using MIME}.
-
address@hidden
-The option @code{mm-fill-flowed} can be used to disable treatment of
-format=flowed messages.  Also, flowed text is disabled when sending
-inline @acronym{PGP} signed messages.  @xref{Flowed text, ,Flowed text,
-emacs-mime, The Emacs MIME Manual}.  (New in Gnus 5.10.7)
address@hidden This entry is also present in the node "Oort Gnus".
-
address@hidden Now the new command @kbd{S W}
-(@code{gnus-article-wide-reply-with-original}) for a wide reply in the
-article buffer yanks a text that is in the active region, if it is set,
-as well as the @kbd{R} (@code{gnus-article-reply-with-original}) command.
-Note that the @kbd{R} command in the article buffer no longer accepts a
-prefix argument, which was used to make it do a wide reply.
address@hidden Keymap}.
-
address@hidden The new command @kbd{C-h b}
-(@code{gnus-article-describe-bindings}) used in the article buffer now
-shows not only the article commands but also the real summary commands
-that are accessible from the article buffer.
-
address@hidden itemize
-
address@hidden Changes in Message mode
-
address@hidden @bullet
address@hidden Gnus now defaults to saving all outgoing messages in per-month
-nnfolder archives.
-
address@hidden Gnus now supports the ``hashcash'' client puzzle anti-spam 
mechanism.
-Use @code{(setq message-generate-hashcash t)} to enable.
address@hidden
-
address@hidden You can now drag and drop attachments to the Message buffer.
-See @code{mml-dnd-protocol-alist} and @code{mml-dnd-attach-options}.
address@hidden, ,MIME, message, Message Manual}.
-
address@hidden The option @code{message-yank-empty-prefix} now controls how
-empty lines are prefixed in cited text.  @xref{Insertion Variables,
-,Insertion Variables, message, Message Manual}.
-
address@hidden Gnus uses narrowing to hide headers in Message buffers.
-The @code{References} header is hidden by default.  To make all
-headers visible, use @code{(setq message-hidden-headers nil)}.
address@hidden Headers, ,Message Headers, message, Message Manual}.
-
address@hidden You can highlight different levels of citations like in the
-article buffer.  See @code{gnus-message-highlight-citation}.
-
address@hidden @code{auto-fill-mode} is enabled by default in Message mode.
-See @code{message-fill-column}.  @xref{Various Message Variables, ,
-Message Headers, message, Message Manual}.
-
address@hidden You can now store signature files in a special directory
-named @code{message-signature-directory}.
-
address@hidden The option @code{message-citation-line-format} controls the 
format
-of the "Whomever writes:" line.  You need to set
address@hidden to
address@hidden as well.
address@hidden itemize
-
address@hidden Changes in Browse Server mode
-
address@hidden @bullet
address@hidden Gnus' sophisticated subscription methods are now available in
-Browse Server buffers as well using the variable
address@hidden
-
address@hidden itemize
-
-
address@hidden Changes in back ends
-
address@hidden @bullet
address@hidden The nntp back end stores article marks in @file{~/News/marks}.
-
-The directory can be changed using the (customizable) variable
address@hidden, and marks can be disabled using the
-(back end) variable @code{nntp-marks-is-evil}.  The advantage of this
-is that you can copy @file{~/News/marks} (using rsync, scp or
-whatever) to another Gnus installation, and it will realize what
-articles you have read and marked.  The data in @file{~/News/marks}
-has priority over the same data in @file{~/.newsrc.eld}.
-
address@hidden
-You can import and export your @acronym{RSS} subscriptions from
address@hidden files.  @xref{RSS}.
-
address@hidden @acronym{IMAP} identity (@acronym{RFC} 2971) is supported.
-
-By default, Gnus does not send any information about itself, but you can
-customize it using the variable @code{nnimap-id}.
-
address@hidden The @code{nnrss} back end now supports multilingual text.
address@hidden group names for the @code{nnrss} groups are also
-supported.  @xref{RSS}.
-
address@hidden Retrieving mail with @acronym{POP3} is supported over 
@acronym{SSL}/@acronym{TLS} and with StartTLS.
-
address@hidden The nnml back end allows other compression programs beside 
@file{gzip}
-for compressed message files.  @xref{Mail Spool}.
-
address@hidden The nnml back end supports group compaction.
-
-This feature, accessible via the functions
address@hidden (@kbd{G z} in the group buffer) and
address@hidden (@kbd{z} in the server buffer)
-renumbers all articles in a group, starting from 1 and removing gaps.
-As a consequence, you get a correct total article count (until
-messages are deleted again).
-
address@hidden @item nnmairix.el
address@hidden FIXME
-
address@hidden @item nnir.el
address@hidden FIXME
-
address@hidden itemize
-
address@hidden Appearance
address@hidden Maybe it's not worth to separate this from "Miscellaneous"?
-
address@hidden @bullet
-
address@hidden The tool bar has been updated to use GNOME icons.
-You can also customize the tool bars: @kbd{M-x customize-apropos @key{RET}
--tool-bar$} should get you started.  (Only for Emacs, not in XEmacs.)
address@hidden FIXME: Document this in the manual
-
address@hidden The tool bar icons are now (de)activated correctly
-in the group buffer, see the variable @code{gnus-group-update-tool-bar}.
-Its default value depends on your Emacs version.
address@hidden FIXME: Document this in the manual
-
address@hidden You can change the location of XEmacs's toolbars in Gnus buffers.
-See @code{gnus-use-toolbar} and @code{message-use-toolbar}.
-
address@hidden itemize
-
address@hidden Miscellaneous changes
-
address@hidden @bullet
address@hidden Having edited the select-method for the foreign server in the
-server buffer is immediately reflected to the subscription of the groups
-which use the server in question.  For instance, if you change
address@hidden into @samp{bar.example.com} from
address@hidden, Gnus will connect to the news host by way of the
-intermediate host @samp{bar.example.com} from next time.
-
address@hidden The @file{all.SCORE} file can be edited from the group buffer
-using @kbd{W e}.
-
address@hidden You can set 
@code{gnus-mark-copied-or-moved-articles-as-expirable}
-to a address@hidden value so that articles that have been read may be
-marked as expirable automatically when copying or moving them to a group
-that has auto-expire turned on.  The default is @code{nil} and copying
-and moving of articles behave as before; i.e., the expirable marks will
-be unchanged except that the marks will be removed when copying or
-moving articles to a group that has not turned auto-expire on.
address@hidden Mail}.
-
address@hidden NoCeM support has been removed.
-
address@hidden Carpal mode has been removed.
-
address@hidden itemize
-
address@hidden itemize
-
address@hidden gnus-news.texi ends here.
diff --git a/doc/misc/gnus-overrides.texi b/doc/misc/gnus-overrides.texi
deleted file mode 100644
index e69de29..0000000
diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
index d1c746c..b9c91a0 100644
--- a/doc/misc/gnus.texi
+++ b/doc/misc/gnus.texi
@@ -1,7 +1,5 @@
 \input texinfo
 
address@hidden gnus-overrides.texi
-
 @setfilename ../../info/gnus.info
 @settitle Gnus Manual
 @include docstyle.texi
@@ -10,7 +8,7 @@
 @syncodeindex pg cp
 
 @copying
-Copyright @copyright{} 1995--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1995--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -9418,7 +9416,7 @@ function must return @code{mid}, @code{mail}, 
@code{invalid} or
 @item gnus-button-mid-or-mail-heuristic
 @findex gnus-button-mid-or-mail-heuristic
 Function that guesses whether its argument is a message ID or a mail
-address.  Returns @code{mid} if it's a message IDs, @code{mail} if
+address.  Returns @code{mid} if it's a message ID, @code{mail} if
 it's a mail address, @code{ask} if unsure and @code{invalid} if the
 string is invalid.
 
@@ -9679,7 +9677,7 @@ Each article is divided into two parts---the head and the 
body.  The
 body can be divided into a signature part and a text part.  The variable
 that says what is to be considered a signature is
 @code{gnus-signature-separator}.  This is normally the standard
address@hidden $} as mandated by son-of-RFC 1036.  However, many people use
address@hidden $} as mandated by RFC 5536.  However, many people use
 non-standard signature separators, so this variable can also be a list
 of regular expressions to be tested, one by one.  (Searches are done
 from the end of the body towards the beginning.)  One likely value is:
@@ -15991,8 +15989,9 @@ Mailers and list servers are notorious for doing all 
sorts of really,
 really stupid things with mail.  ``Hey, RFC 822 doesn't explicitly
 prohibit us from adding the string @code{wE aRe ElItE!!!!!1!!} to the
 end of all lines passing through our server, so let's do that!!!!1!''
-Yes, but RFC 822 wasn't designed to be read by morons.  Things that were
-considered to be self-evident were not discussed.  So.  Here we are.
+Yes, but RFC 822 and its successors weren't designed to be read by
+morons.  Things that were considered to be self-evident were not
+discussed.  So.  Here we are.
 
 Case in point:  The German version of Microsoft Exchange adds @samp{AW:
 } to the subjects of replies instead of @samp{Re: }.  I could pretend to
@@ -17374,7 +17373,7 @@ Announcement messages from LANL Gov Announce.
 
 @cindex forwarded messages
 @item rfc822-forward
-A message forwarded according to RFC822.
+A message forwarded according to RFC 822 or its successors.
 
 @item outlook
 The Outlook mail box.
@@ -26721,18 +26720,20 @@ with, of course.
 
 @table @strong
 
address@hidden RFC (2)822
address@hidden RFC 822
 @cindex RFC 822
 @cindex RFC 2822
-There are no known breaches of this standard.
address@hidden RFC 5322
+There are no known breaches of this standard or its successors
+(currently RFCs 2822 and 5322).
 
 @item RFC 1036
 @cindex RFC 1036
-There are no known breaches of this standard, either.
+There are no known breaches of this (now-obsolete) standard, either.
 
address@hidden Son-of-RFC 1036
address@hidden Son-of-RFC 1036
-We do have some breaches to this one.
address@hidden RFC 5536
address@hidden RFC 5536
+We do have some breaches of this standard, the successor of RFC 1036.
 
 @table @emph
 
@@ -26747,10 +26748,9 @@ it wasn't for the @code{X-Newsreader} header.
 
 @item USEFOR
 @cindex USEFOR
-USEFOR is an IETF working group writing a successor to RFC 1036, based
-on Son-of-RFC 1036.  They have produced a number of drafts proposing
-various changes to the format of news articles.  The Gnus towers will
-look into implementing the changes when the draft is accepted as an RFC.
+USEFOR was an IETF working group that produced Internet RFCs 5536 and 5537.
+The Gnus towers will look into implementing the changes embodied by these
+standards.
 
 @item MIME---RFC 2045--2049 etc
 @cindex @acronym{MIME}
@@ -27216,6 +27216,8 @@ actually are people who are using Gnus.  Who'd'a thunk 
it!
 * Ma Gnus::                     Celebrating 25 years of Gnus.
 @end menu
 
+For summaries of more recent changes, see the normal Emacs @file{NEWS} files.
+
 These lists are, of course, just @emph{short} overviews of the
 @emph{most} important new features.  No, really.  There are tons more.
 Yes, we have feeping creaturism in full effect.
@@ -28586,7 +28588,358 @@ A new command which starts Gnus offline in slave mode.
 New features in No Gnus:
 @c FIXME: Gnus 5.12?
 
address@hidden gnus-news.texi
address@hidden @bullet
+
address@hidden Supported Emacs versions
+The following Emacs versions are supported by No Gnus:
address@hidden @bullet
+
address@hidden Emacs 22 and up
address@hidden XEmacs 21.4
address@hidden XEmacs 21.5
address@hidden SXEmacs
+
address@hidden itemize
+
address@hidden Installation changes
+
address@hidden @bullet
address@hidden Upgrading from previous (stable) version if you have used No 
Gnus.
+
+If you have tried No Gnus (the unstable Gnus branch leading to this
+release) but went back to a stable version, be careful when upgrading
+to this version.  In particular, you will probably want to remove the
address@hidden/News/marks} directory (perhaps selectively), so that flags are
+read from your @file{~/.newsrc.eld} instead of from the stale marks
+file, where this release will store flags for nntp.  See a later entry
+for more information about nntp marks.  Note that downgrading isn't
+safe in general.
+
address@hidden Incompatibility when switching from Emacs 23 to Emacs 22
+In Emacs 23, Gnus uses Emacs's new internal coding system @code{utf-8-emacs}
+for saving articles drafts and @file{~/.newsrc.eld}.  These files may not
+be read correctly in Emacs 22 and below.  If you want to use Gnus across
+different Emacs versions, you may set @code{mm-auto-save-coding-system}
+to @code{emacs-mule}.
address@hidden FIXME: Untested.  (Or did anyone test it?)
address@hidden Cf. 
http://thread.gmane.org/gmane.emacs.gnus.general/66251/focus=66344
+
address@hidden Lisp files are now installed in @file{.../site-lisp/gnus/} by 
default.
+It defaulted to @file{.../site-lisp/} formerly.  In addition to this,
+the new installer issues a warning if other Gnus installations which
+will shadow the latest one are detected.  You can then remove those
+shadows manually or remove them using @code{make
+remove-installed-shadows}.
+
address@hidden The installation directory's name is allowed to have spaces 
and/or tabs.
address@hidden itemize
+
address@hidden New packages and libraries within Gnus
+
address@hidden @bullet
+
address@hidden New version of @code{nnimap}
+
address@hidden has been reimplemented in a mostly-compatible way.  See
+the Gnus manual for a description of the new interface.  In
+particular, @code{nnimap-inbox} and the client side split method has
+changed.
+
address@hidden Gnus includes the Emacs Lisp @acronym{SASL} library.
+
+This provides a clean @acronym{API} to @acronym{SASL} mechanisms from
+within Emacs.  The user visible aspects of this, compared to the earlier
+situation, include support for @address@hidden and
address@hidden   @xref{Top, ,Emacs SASL, sasl, Emacs SASL}.
+
address@hidden ManageSieve connections uses the @acronym{SASL} library by 
default.
+
+The primary change this brings is support for @acronym{DIGEST-MD5} and
address@hidden, when the server supports it.
+
address@hidden Gnus includes a password cache mechanism in password.el.
+
+It is enabled by default (see @code{password-cache}), with a short
+timeout of 16 seconds (see @code{password-cache-expiry}).  If
address@hidden is used as the @acronym{PGP} back end, the @acronym{PGP}
+passphrase is managed by this mechanism.  Passwords for ManageSieve
+connections are managed by this mechanism, after querying the user
+about whether to do so.
+
address@hidden Using EasyPG with Gnus
+When EasyPG, is available, Gnus will use it instead of @acronym{PGG}.
+EasyPG is an Emacs user interface to GNU Privacy Guard.  @xref{Top,
+,EasyPG Assistant user's manual, epa, EasyPG Assistant user's manual}.
+EasyPG is included in Emacs 23 and available separately as well.
address@hidden itemize
+
address@hidden Changes in group mode
address@hidden ************************
+
address@hidden @bullet
+
address@hidden
+Symbols like @code{gcc-self} now have the same precedence rules in
address@hidden as other ``real'' variables: The last match
+wins instead of the first match.
+
address@hidden
+Old intermediate incoming mail files (@file{Incoming*}) are deleted
+after a couple of days, not immediately.  @xref{Mail Source
+Customization}.
+(New in Gnus 5.10.10 / No Gnus 0.8)
address@hidden This entry is also present in the node "Oort Gnus".
+
address@hidden itemize
+
address@hidden Changes in summary and article mode
+
address@hidden @bullet
+
address@hidden There's now only one variable that determines how @acronym{HTML}
+is rendered: @code{mm-text-html-renderer}.
+
address@hidden Gnus now supports sticky article buffers.  Those are article 
buffers
+that are not reused when you select another article.  @xref{Sticky
+Articles}.
+
address@hidden @item Bookmarks
address@hidden FIXME: To be added
+
address@hidden Gnus can selectively display @samp{text/html} articles
+with a WWW browser with @kbd{K H}.  @xref{MIME Commands}.
+
address@hidden gnus-registry-marks
address@hidden FIXME: To be added
+
address@hidden International host names (@acronym{IDNA}) can now be decoded
+inside article bodies using @kbd{W i}
+(@code{gnus-summary-idna-message}).  This requires that GNU Libidn
+(@url{https://www.gnu.org/software/libidn/}) has been installed.
address@hidden FIXME: Also mention @code{message-use-idna}?
+
address@hidden The address@hidden group names handling has been much
+improved.  The back ends that fully support address@hidden group
+names are now @code{nntp}, @code{nnml}, and @code{nnrss}.  Also the
+agent, the cache, and the marks features work with those back ends.
address@hidden Group Names}.
+
address@hidden Gnus now displays @acronym{DNS} master files sent as text/dns
+using dns-mode.
+
address@hidden Gnus supports new limiting commands in the Summary buffer:
address@hidden/ r} (@code{gnus-summary-limit-to-replied}) and @kbd{/ R}
+(@code{gnus-summary-limit-to-recipient}).  @xref{Limiting}.
+
address@hidden You can now fetch all ticked articles from the server using
address@hidden t} (@code{gnus-summary-insert-ticked-articles}).  @xref{Summary
+Generation Commands}.
+
address@hidden Gnus supports a new sort command in the Summary buffer:
address@hidden C-s C-t} (@code{gnus-summary-sort-by-recipient}).  @xref{Summary
+Sorting}.
+
address@hidden @acronym{S/MIME} now features @acronym{LDAP} user certificate 
searches.
+You need to configure the server in @code{smime-ldap-host-list}.
+
address@hidden URLs inside address@hidden headers are retrieved and imported
+to your PGP key ring when you click on them.
+
address@hidden
+Picons can be displayed right from the textual address, see
address@hidden  @xref{Picons}.
+
address@hidden @acronym{ANSI} @acronym{SGR} control sequences can be transformed
+using @kbd{W A}.
+
address@hidden sequences are used in some Chinese hierarchies for
+highlighting articles (@code{gnus-article-treat-ansi-sequences}).
+
address@hidden Gnus now MIME decodes articles even when they lack 
"MIME-Version" header.
+This changes the default of @code{gnus-article-loose-mime}.
+
address@hidden @code{gnus-decay-scores} can be a regexp matching score files.
+For example, set it to @samp{\\.ADAPT\\'} and only adaptive score files
+will be decayed.  @xref{Score Decays}.
+
address@hidden Strings prefixing to the @code{To} and @code{Newsgroup} headers 
in
+summary lines when using @code{gnus-ignored-from-addresses} can be
+customized with @code{gnus-summary-to-prefix} and
address@hidden  @xref{To From Newsgroups}.
+
address@hidden You can replace @acronym{MIME} parts with external bodies.
+See @code{gnus-mime-replace-part} and @code{gnus-article-replace-part}.
address@hidden Commands}, @ref{Using MIME}.
+
address@hidden
+The option @code{mm-fill-flowed} can be used to disable treatment of
+format=flowed messages.  Also, flowed text is disabled when sending
+inline @acronym{PGP} signed messages.  @xref{Flowed text, ,Flowed text,
+emacs-mime, The Emacs MIME Manual}.  (New in Gnus 5.10.7)
address@hidden This entry is also present in the node "Oort Gnus".
+
address@hidden Now the new command @kbd{S W}
+(@code{gnus-article-wide-reply-with-original}) for a wide reply in the
+article buffer yanks a text that is in the active region, if it is set,
+as well as the @kbd{R} (@code{gnus-article-reply-with-original}) command.
+Note that the @kbd{R} command in the article buffer no longer accepts a
+prefix argument, which was used to make it do a wide reply.
address@hidden Keymap}.
+
address@hidden The new command @kbd{C-h b}
+(@code{gnus-article-describe-bindings}) used in the article buffer now
+shows not only the article commands but also the real summary commands
+that are accessible from the article buffer.
+
address@hidden itemize
+
address@hidden Changes in Message mode
+
address@hidden @bullet
address@hidden Gnus now defaults to saving all outgoing messages in per-month
+nnfolder archives.
+
address@hidden Gnus now supports the ``hashcash'' client puzzle anti-spam 
mechanism.
+Use @code{(setq message-generate-hashcash t)} to enable.
address@hidden
+
address@hidden You can now drag and drop attachments to the Message buffer.
+See @code{mml-dnd-protocol-alist} and @code{mml-dnd-attach-options}.
address@hidden, ,MIME, message, Message Manual}.
+
address@hidden The option @code{message-yank-empty-prefix} now controls how
+empty lines are prefixed in cited text.  @xref{Insertion Variables,
+,Insertion Variables, message, Message Manual}.
+
address@hidden Gnus uses narrowing to hide headers in Message buffers.
+The @code{References} header is hidden by default.  To make all
+headers visible, use @code{(setq message-hidden-headers nil)}.
address@hidden Headers, ,Message Headers, message, Message Manual}.
+
address@hidden You can highlight different levels of citations like in the
+article buffer.  See @code{gnus-message-highlight-citation}.
+
address@hidden @code{auto-fill-mode} is enabled by default in Message mode.
+See @code{message-fill-column}.  @xref{Various Message Variables, ,
+Message Headers, message, Message Manual}.
+
address@hidden You can now store signature files in a special directory
+named @code{message-signature-directory}.
+
address@hidden The option @code{message-citation-line-format} controls the 
format
+of the "Whomever writes:" line.  You need to set
address@hidden to
address@hidden as well.
address@hidden itemize
+
address@hidden Changes in Browse Server mode
+
address@hidden @bullet
address@hidden Gnus' sophisticated subscription methods are now available in
+Browse Server buffers as well using the variable
address@hidden
+
address@hidden itemize
+
+
address@hidden Changes in back ends
+
address@hidden @bullet
address@hidden The nntp back end stores article marks in @file{~/News/marks}.
+
+The directory can be changed using the (customizable) variable
address@hidden, and marks can be disabled using the
+(back end) variable @code{nntp-marks-is-evil}.  The advantage of this
+is that you can copy @file{~/News/marks} (using rsync, scp or
+whatever) to another Gnus installation, and it will realize what
+articles you have read and marked.  The data in @file{~/News/marks}
+has priority over the same data in @file{~/.newsrc.eld}.
+
address@hidden
+You can import and export your @acronym{RSS} subscriptions from
address@hidden files.  @xref{RSS}.
+
address@hidden @acronym{IMAP} identity (@acronym{RFC} 2971) is supported.
+
+By default, Gnus does not send any information about itself, but you can
+customize it using the variable @code{nnimap-id}.
+
address@hidden The @code{nnrss} back end now supports multilingual text.
address@hidden group names for the @code{nnrss} groups are also
+supported.  @xref{RSS}.
+
address@hidden Retrieving mail with @acronym{POP3} is supported over 
@acronym{SSL}/@acronym{TLS} and with StartTLS.
+
address@hidden The nnml back end allows other compression programs beside 
@file{gzip}
+for compressed message files.  @xref{Mail Spool}.
+
address@hidden The nnml back end supports group compaction.
+
+This feature, accessible via the functions
address@hidden (@kbd{G z} in the group buffer) and
address@hidden (@kbd{z} in the server buffer)
+renumbers all articles in a group, starting from 1 and removing gaps.
+As a consequence, you get a correct total article count (until
+messages are deleted again).
+
address@hidden @item nnmairix.el
address@hidden FIXME
+
address@hidden @item nnir.el
address@hidden FIXME
+
address@hidden itemize
+
address@hidden Appearance
address@hidden Maybe it's not worth to separate this from "Miscellaneous"?
+
address@hidden @bullet
+
address@hidden The tool bar has been updated to use GNOME icons.
+You can also customize the tool bars: @kbd{M-x customize-apropos @key{RET}
+-tool-bar$} should get you started.  (Only for Emacs, not in XEmacs.)
address@hidden FIXME: Document this in the manual
+
address@hidden The tool bar icons are now (de)activated correctly
+in the group buffer, see the variable @code{gnus-group-update-tool-bar}.
+Its default value depends on your Emacs version.
address@hidden FIXME: Document this in the manual
+
address@hidden You can change the location of XEmacs's toolbars in Gnus buffers.
+See @code{gnus-use-toolbar} and @code{message-use-toolbar}.
+
address@hidden itemize
+
address@hidden Miscellaneous changes
+
address@hidden @bullet
address@hidden Having edited the select-method for the foreign server in the
+server buffer is immediately reflected to the subscription of the groups
+which use the server in question.  For instance, if you change
address@hidden into @samp{bar.example.com} from
address@hidden, Gnus will connect to the news host by way of the
+intermediate host @samp{bar.example.com} from next time.
+
address@hidden The @file{all.SCORE} file can be edited from the group buffer
+using @kbd{W e}.
+
address@hidden You can set 
@code{gnus-mark-copied-or-moved-articles-as-expirable}
+to a address@hidden value so that articles that have been read may be
+marked as expirable automatically when copying or moving them to a group
+that has auto-expire turned on.  The default is @code{nil} and copying
+and moving of articles behave as before; i.e., the expirable marks will
+be unchanged except that the marks will be removed when copying or
+moving articles to a group that has not turned auto-expire on.
address@hidden Mail}.
+
address@hidden NoCeM support has been removed.
+
address@hidden Carpal mode has been removed.
+
address@hidden itemize
+
address@hidden itemize
+
 
 @node Ma Gnus
 @subsubsection Ma Gnus
@@ -29529,7 +29882,8 @@ header         = <text> eol
 @end example
 
 @cindex BNF
-(The version of BNF used here is the one used in RFC822.)
+(The version of extended BNF used here is ABNF, the one used in Internet RFCs.
+See RFC 5234.)
 
 If the return value is @code{nov}, the data buffer should contain
 @dfn{network overview database} lines.  These are basically fields
@@ -30327,7 +30681,7 @@ almost suspect that the author looked at the 
@acronym{NOV} specification and
 just shamelessly @emph{stole} the entire thing, and one would be right.
 
 @dfn{Header} is a severely overloaded term.  ``Header'' is used in
-RFC 1036 to talk about lines in the head of an article (e.g.,
+RFC 5536 to talk about lines in the head of an article (e.g.,
 @code{From}).  It is used by many people as a synonym for
 ``head''---``the header and the body''.  (That should be avoided, in my
 opinion.)  And Gnus uses a format internally that it calls ``header'',
diff --git a/doc/misc/htmlfontify.texi b/doc/misc/htmlfontify.texi
index c4cf7da..f1da878 100644
--- a/doc/misc/htmlfontify.texi
+++ b/doc/misc/htmlfontify.texi
@@ -10,7 +10,7 @@
 This manual documents Htmlfontify, a source code -> crosslinked +
 formatted + syntax colorized html transformer.
 
-Copyright @copyright{} 2002-2003, 2013-2018 Free Software Foundation,
+Copyright @copyright{} 2002-2003, 2013-2019 Free Software Foundation,
 Inc.
 
 @quotation
diff --git a/doc/misc/idlwave.texi b/doc/misc/idlwave.texi
index ca4d89c..fd48bc0 100644
--- a/doc/misc/idlwave.texi
+++ b/doc/misc/idlwave.texi
@@ -23,7 +23,7 @@ Emacs, and interacting with an IDL shell run as a subprocess.
 This is edition @value{EDITION} of the IDLWAVE User Manual for IDLWAVE
 @value{VERSION}.
 
-Copyright @copyright{} 1999--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1999--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/ido.texi b/doc/misc/ido.texi
index 098b28e..bb7e723 100644
--- a/doc/misc/ido.texi
+++ b/doc/misc/ido.texi
@@ -7,7 +7,7 @@
 @copying
 This file documents the Ido package for GNU Emacs.
 
-Copyright @copyright{} 2013-2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2013-2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/info.texi b/doc/misc/info.texi
index e277b13..e69779a 100644
--- a/doc/misc/info.texi
+++ b/doc/misc/info.texi
@@ -15,7 +15,7 @@
 This file describes how to use Info, the menu-driven GNU
 documentation system.
 
-Copyright @copyright{} 1989, 1992, 1996--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1989, 1992, 1996--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/mairix-el.texi b/doc/misc/mairix-el.texi
index 8d620c7..c45ed11 100644
--- a/doc/misc/mairix-el.texi
+++ b/doc/misc/mairix-el.texi
@@ -5,7 +5,7 @@
 @include docstyle.texi
 
 @copying
-Copyright @copyright{} 2008--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2008--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/message.texi b/doc/misc/message.texi
index 61eca75..7089bb5 100644
--- a/doc/misc/message.texi
+++ b/doc/misc/message.texi
@@ -1,7 +1,5 @@
 \input texinfo                  @c -*-texinfo-*-
 
address@hidden gnus-overrides.texi
-
 @setfilename ../../info/message.info
 @settitle Message Manual
 @include docstyle.texi
@@ -11,7 +9,7 @@
 @copying
 This file documents Message, the Emacs message composition mode.
 
-Copyright @copyright{} 1996--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1996--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/mh-e.texi b/doc/misc/mh-e.texi
index 8545525..25dd53c 100644
--- a/doc/misc/mh-e.texi
+++ b/doc/misc/mh-e.texi
@@ -25,7 +25,7 @@
 This is version @address@hidden of @cite{The MH-E
 Manual}, last updated @value{UPDATED}.
 
-Copyright @copyright{} 1995, 2001--2003, 2005--2018 Free Software
+Copyright @copyright{} 1995, 2001--2003, 2005--2019 Free Software
 Foundation, Inc.
 
 @c This dual license has been agreed upon by the FSF.
@@ -6287,24 +6287,24 @@ Emacs navigational keys (like the arrow keys, or 
@kbd{C-n}) to move
 the cursor over the desired folder and then use the shortcuts for the
 menu items listed in the table below.
 
address@hidden @samp
address@hidden @asis
 @findex mh-speed-view
address@hidden Visit Folder (@key{RET})
address@hidden @samp{Visit Folder} (@key{RET})
 Visits the selected folder just as if you had used @kbd{F v}
 (@code{mh-speed-view}).
 @c -------------------------
 @findex mh-speed-expand-folder
address@hidden Expand Nested Folders (@kbd{+})
address@hidden @samp{Expand Nested Folders} (@kbd{+})
 Expands the selected folder in the speedbar, exposing the children
 folders inside it (@code{mh-speed-expand-folder}).
 @c -------------------------
 @findex mh-speed-contract-folder
address@hidden Contract Nested Folders (@kbd{-})
address@hidden @samp{Contract Nested Folders} (@kbd{-})
 Contracts or collapses the selected folder in the speedbar, hiding the
 children folders inside it (@code{mh-speed-contract-folder}).
 @c -------------------------
 @findex mh-speed-refresh
address@hidden Refresh Speedbar (@kbd{r})
address@hidden @samp{Refresh Speedbar} (@kbd{r})
 Regenerates the list of folders in the speedbar. Run this command if
 you've added or deleted a folder, or want to update the unseen message
 count before the next automatic update (@code{mh-speed-refresh}).
diff --git a/doc/misc/newsticker.texi b/doc/misc/newsticker.texi
index ac29ced..5db3f43 100644
--- a/doc/misc/newsticker.texi
+++ b/doc/misc/newsticker.texi
@@ -15,7 +15,7 @@ This manual documents Newsticker, a feed reader for Emacs.  It
 corresponds to Emacs version @value{EMACSVER}.
 
 @noindent
-Copyright @copyright{} 2004--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2004--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/nxml-mode.texi b/doc/misc/nxml-mode.texi
index 32b873e..2b2c241 100644
--- a/doc/misc/nxml-mode.texi
+++ b/doc/misc/nxml-mode.texi
@@ -9,7 +9,7 @@
 This manual documents nXML mode, an Emacs major mode for editing
 XML with RELAX NG support.
 
-Copyright @copyright{} 2007--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2007--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -250,7 +250,7 @@ xml:lang                           xmlns
 If you input @kbd{xmlns}, the result will be:
 
 @example
-<html xmlns="@point{}
+<html xmlns="@point{}"
 @end example
 
 @noindent
diff --git a/doc/misc/octave-mode.texi b/doc/misc/octave-mode.texi
index 927a15d..d409b90 100644
--- a/doc/misc/octave-mode.texi
+++ b/doc/misc/octave-mode.texi
@@ -6,7 +6,7 @@
 @c %**end of header
 
 @copying
-Copyright @copyright{} 1996--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1996--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/org.texi b/doc/misc/org.texi
index 9ea78f5..7862713 100644
--- a/doc/misc/org.texi
+++ b/doc/misc/org.texi
@@ -260,7 +260,7 @@
 @copying
 This manual is for Org version @value{VERSION}.
 
-Copyright @copyright{} 2004--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2004--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -13789,7 +13789,7 @@ Copyright information is printed on the back of the 
title page.
 
   This is a short example of a complete Texinfo file, version 1.0.
 
-  Copyright \copy 2018 Free Software Foundation, Inc.
+  Copyright \copy 2019 Free Software Foundation, Inc.
 @end example
 
 @node Info directory file
@@ -14066,7 +14066,7 @@ This manual is for GNU Sample (version 
@address@hidden@address@hidden@address@hidden,
   This manual is for GNU Sample (version 
@address@hidden@address@hidden@address@hidden,
   @address@hidden@address@hidden@address@hidden), which is an example in the 
Texinfo documentation.
 
-  Copyright \copy 2018 Free Software Foundation, Inc.
+  Copyright \copy 2019 Free Software Foundation, Inc.
 
   #+BEGIN_QUOTE
   Permission is granted to copy, distribute and/or modify this
diff --git a/doc/misc/pcl-cvs.texi b/doc/misc/pcl-cvs.texi
index fe50154..3379783 100644
--- a/doc/misc/pcl-cvs.texi
+++ b/doc/misc/pcl-cvs.texi
@@ -7,7 +7,7 @@
 @c %**end of header
 
 @copying
-Copyright @copyright{} 1991--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1991--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/pgg.texi b/doc/misc/pgg.texi
index e5fe2fa..2fac24a 100644
--- a/doc/misc/pgg.texi
+++ b/doc/misc/pgg.texi
@@ -1,7 +1,5 @@
 \input texinfo                  @c -*-texinfo-*-
 
address@hidden gnus-overrides.texi
-
 @setfilename ../../info/pgg.info
 
 @set VERSION 0.1
@@ -12,7 +10,7 @@
 This file describes PGG @value{VERSION}, an Emacs interface to various
 PGP implementations.
 
-Copyright @copyright{} 2001, 2003--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2001, 2003--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/rcirc.texi b/doc/misc/rcirc.texi
index 0287054..bbcd0ed 100644
--- a/doc/misc/rcirc.texi
+++ b/doc/misc/rcirc.texi
@@ -6,7 +6,7 @@
 @c %**end of header
 
 @copying
-Copyright @copyright{} 2006--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2006--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/reftex.texi b/doc/misc/reftex.texi
index 4367d77..baa8de4 100644
--- a/doc/misc/reftex.texi
+++ b/doc/misc/reftex.texi
@@ -46,7 +46,7 @@ This manual documents @RefTeX{} (version @value{VERSION}), a 
package
 to do labels, references, citations and indices for LaTeX documents
 with Emacs.
 
-Copyright @copyright{} 1997--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1997--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/remember.texi b/doc/misc/remember.texi
index 8e42708..e692f14 100644
--- a/doc/misc/remember.texi
+++ b/doc/misc/remember.texi
@@ -9,7 +9,7 @@
 @copying
 This manual is for Remember Mode, version 2.0
 
-Copyright @copyright{} 2001, 2004--2005, 2007--2018
+Copyright @copyright{} 2001, 2004--2005, 2007--2019
 Free Software Foundation, Inc.
 
 @quotation
diff --git a/doc/misc/sasl.texi b/doc/misc/sasl.texi
index 00e25f4..1d31150 100644
--- a/doc/misc/sasl.texi
+++ b/doc/misc/sasl.texi
@@ -1,7 +1,5 @@
 \input texinfo                  @c -*-texinfo-*-
 
address@hidden gnus-overrides.texi
-
 @setfilename ../../info/sasl.info
 
 @set VERSION 0.2
@@ -11,7 +9,7 @@
 @copying
 This file describes the Emacs SASL library, version @value{VERSION}.
 
-Copyright @copyright{} 2000, 2004--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2000, 2004--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/sc.texi b/doc/misc/sc.texi
index 453ccf2..d10bdc6 100644
--- a/doc/misc/sc.texi
+++ b/doc/misc/sc.texi
@@ -15,7 +15,7 @@
 This document describes Supercite, an Emacs package for citing and
 attributing replies to mail and news messages.
 
-Copyright @copyright{} 1993, 2001--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1993, 2001--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -249,10 +249,10 @@ And that's what I think too.
 @end menu
 
 Note that multiple inclusions of the original messages result in a
-nesting of the @address@hidden>}} characters.  This can sometimes be quite
+nesting of the @samp{>} characters.  This can sometimes be quite
 confusing when many levels of citations are included since it may be
 difficult or impossible to figure out who actually participated in the
-thread, and multiple nesting of @address@hidden>}} characters can sometimes
+thread, and multiple nesting of @samp{>} characters can sometimes
 make the message very difficult for the eye to scan.
 
 @cindex non-nested citations
@@ -851,7 +851,8 @@ scanned.  Info key-value pairs are created for each header 
found.  Also,
 such useful information as the author's name and email address are
 extracted.  If the variable @code{sc-mail-warn-if-non-rfc822-p} is
 address@hidden, then Supercite will warn you if it finds a mail header
-that does not conform to RFC822.  This is rare and indicates a problem
+that does not conform to RFC 822 (or later).
+This is rare and indicates a problem
 either with your MUA or the original author's MUA, or some MTA (mail
 transport agent) along the way.
 
diff --git a/doc/misc/sem-user.texi b/doc/misc/sem-user.texi
index 8484a7b..3fe104a 100644
--- a/doc/misc/sem-user.texi
+++ b/doc/misc/sem-user.texi
@@ -1,5 +1,5 @@
 @c This is part of the Semantic manual.
address@hidden Copyright (C) 1999-2005, 2007, 2009-2018 Free Software 
Foundation,
address@hidden Copyright (C) 1999-2005, 2007, 2009-2019 Free Software 
Foundation,
 @c Inc.
 @c See file semantic.texi for copying conditions.
 
diff --git a/doc/misc/semantic.texi b/doc/misc/semantic.texi
index 8d4920c..34afcba 100644
--- a/doc/misc/semantic.texi
+++ b/doc/misc/semantic.texi
@@ -25,7 +25,7 @@
 @copying
 This manual documents the Semantic library and utilities.
 
-Copyright @copyright{} 1999--2005, 2007, 2009--2018 Free Software
+Copyright @copyright{} 1999--2005, 2007, 2009--2019 Free Software
 Foundation, Inc.
 
 @quotation
diff --git a/doc/misc/ses.texi b/doc/misc/ses.texi
index aa4fe81..f98a3b1 100644
--- a/doc/misc/ses.texi
+++ b/doc/misc/ses.texi
@@ -12,7 +12,7 @@
 @copying
 This file documents @acronym{SES}: the Simple Emacs Spreadsheet.
 
-Copyright @copyright{} 2002--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2002--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/sieve.texi b/doc/misc/sieve.texi
index cad3cd8..2d07b0a 100644
--- a/doc/misc/sieve.texi
+++ b/doc/misc/sieve.texi
@@ -1,7 +1,5 @@
 \input texinfo                  @c -*-texinfo-*-
 
address@hidden gnus-overrides.texi
-
 @setfilename ../../info/sieve.info
 @settitle Emacs Sieve Manual
 @include docstyle.texi
@@ -12,7 +10,7 @@
 @copying
 This file documents the Emacs Sieve package, for server-side mail filtering.
 
-Copyright @copyright{} 2001--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2001--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/smtpmail.texi b/doc/misc/smtpmail.texi
index c338705..365f557 100644
--- a/doc/misc/smtpmail.texi
+++ b/doc/misc/smtpmail.texi
@@ -4,7 +4,7 @@
 @include docstyle.texi
 @syncodeindex vr fn
 @copying
-Copyright @copyright{} 2003--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2003--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/speedbar.texi b/doc/misc/speedbar.texi
index d67c4e6..503f9cd 100644
--- a/doc/misc/speedbar.texi
+++ b/doc/misc/speedbar.texi
@@ -5,7 +5,7 @@
 @syncodeindex fn cp
 
 @copying
-Copyright @copyright{} 1999--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1999--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/srecode.texi b/doc/misc/srecode.texi
index 7d8416e..9df11b4 100644
--- a/doc/misc/srecode.texi
+++ b/doc/misc/srecode.texi
@@ -16,7 +16,7 @@
 @c %**end of header
 
 @copying
-Copyright @copyright{} 2007--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2007--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/texinfo.tex b/doc/misc/texinfo.tex
index 5840aff..192284c 100644
--- a/doc/misc/texinfo.tex
+++ b/doc/misc/texinfo.tex
@@ -3,12 +3,10 @@
 % Load plain if necessary, i.e., if running under initex.
 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
 %
-\def\texinfoversion{2018-09-21.20}
+\def\texinfoversion{2019-03-03.15}
+
 %
-% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
-% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-% 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
-% Free Software Foundation, Inc.
+% Copyright 1985, 1986, 1988, 1990-2019 Free Software Foundation, Inc.
 %
 % This texinfo.tex file is free software: you can redistribute it and/or
 % modify it under the terms of the GNU General Public License as
@@ -244,17 +242,7 @@
 %
 \def\finalout{\overfullrule=0pt }
 
-% Do @cropmarks to get crop marks.
-%
-\newif\ifcropmarks
-\let\cropmarks = \cropmarkstrue
-%
-% Dimensions to add cropmarks at corners.
-% Added by P. A. MacKay, 12 Nov. 1986
-%
 \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
-\newdimen\cornerlong  \cornerlong=1pc
-\newdimen\cornerthick \cornerthick=.3pt
 \newdimen\topandbottommargin \topandbottommargin=.75in
 
 % Output a mark which sets \thischapter, \thissection and \thiscolor.
@@ -270,8 +258,8 @@
 
 % \domark is called twice inside \chapmacro, to add one
 % mark before the section break, and one after.
-%   In the second call \prevchapterdefs is the same as \lastchapterdefs,
-% and \prevsectiondefs is the same as \lastsectiondefs.
+%   In the second call \prevchapterdefs is the same as \currentchapterdefs,
+% and \prevsectiondefs is the same as \currentsectiondefs.
 %   Then if the page is not broken at the mark, some of the previous
 % section appears on the page, and we can get the name of this section
 % from \firstmark for @everyheadingmarks top.
@@ -279,11 +267,11 @@
 %
 % See page 260 of The TeXbook.
 \def\domark{%
-  \toks0=\expandafter{\lastchapterdefs}%
-  \toks2=\expandafter{\lastsectiondefs}%
+  \toks0=\expandafter{\currentchapterdefs}%
+  \toks2=\expandafter{\currentsectiondefs}%
   \toks4=\expandafter{\prevchapterdefs}%
   \toks6=\expandafter{\prevsectiondefs}%
-  \toks8=\expandafter{\lastcolordefs}%
+  \toks8=\expandafter{\currentcolordefs}%
   \mark{%
                    \the\toks0 \the\toks2  % 0: marks for @everyheadingmarks top
       \noexpand\or \the\toks4 \the\toks6  % 1: for @everyheadingmarks bottom
@@ -300,19 +288,19 @@
 % @setcolor (or @url, or @link, etc.) between @contents and the very
 % first @chapter.
 \def\gettopheadingmarks{%
-  \ifcase0\topmark\fi
+  \ifcase0\the\savedtopmark\fi
   \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
 }
 \def\getbottomheadingmarks{\ifcase1\botmark\fi}
-\def\getcolormarks{\ifcase2\topmark\fi}
+\def\getcolormarks{\ifcase2\the\savedtopmark\fi}
 
 % Avoid "undefined control sequence" errors.
-\def\lastchapterdefs{}
-\def\lastsectiondefs{}
-\def\lastsection{}
+\def\currentchapterdefs{}
+\def\currentsectiondefs{}
+\def\currentsection{}
 \def\prevchapterdefs{}
 \def\prevsectiondefs{}
-\def\lastcolordefs{}
+\def\currentcolordefs{}
 
 % Margin to add to right of even pages, to left of odd pages.
 \newdimen\bindingoffset
@@ -322,39 +310,57 @@
 % Main output routine.
 %
 \chardef\PAGE = 255
-\output = {\onepageout{\pagecontents\PAGE}}
+\newtoks\defaultoutput
+\defaultoutput = {\savetopmark\onepageout{\pagecontents\PAGE}}
+\output=\expandafter{\the\defaultoutput}
 
 \newbox\headlinebox
 \newbox\footlinebox
 
+% When outputting the double column layout for indices, an output routine
+% is run several times, which hides the original value of \topmark.  This
+% can lead to a page heading being output and duplicating the chapter heading
+% of the index.  Hence, save the contents of \topmark at the beginning of
+% the output routine.  The saved contents are valid until we actually
+% \shipout a page.
+%
+% (We used to run a short output routine to actually set \topmark and 
+% \firstmark to the right values, but if this was called with an empty page 
+% containing whatsits for writing index entries, the whatsits would be thrown 
+% away and the index auxiliary file would remain empty.)
+%
+\newtoks\savedtopmark
+\newif\iftopmarksaved
+\topmarksavedtrue
+\def\savetopmark{%
+  \iftopmarksaved\else
+    \global\savedtopmark=\expandafter{\topmark}%
+    \global\topmarksavedtrue
+  \fi
+}
+
 % \onepageout takes a vbox as an argument.
-% \shipout a vbox for a single page, adding an optional header, footer,
-% cropmarks, and footnote.  This also causes index entries for this page
-% to be written to the auxiliary files.
+% \shipout a vbox for a single page, adding an optional header, footer
+% and footnote.  This also causes index entries for this page to be written
+% to the auxiliary files.
 %
 \def\onepageout#1{%
-  \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
+  \hoffset=\normaloffset
   %
   \ifodd\pageno  \advance\hoffset by \bindingoffset
   \else \advance\hoffset by -\bindingoffset\fi
   %
-  % Common context changes for both heading and footing.
-  % Do this outside of the \shipout so @code etc. will be expanded in
-  % the headline as they should be, not taken literally (outputting ''code).
-  \def\commmonheadfootline{\let\hsize=\txipagewidth \texinfochars}
-  %
   % Retrieve the information for the headings from the marks in the page,
   % and call Plain TeX's \makeheadline and \makefootline, which use the
   % values in \headline and \footline.
   %
   % This is used to check if we are on the first page of a chapter.
-  \ifcase1\topmark\fi
+  \ifcase1\the\savedtopmark\fi
   \let\prevchaptername\thischaptername
   \ifcase0\firstmark\fi
   \let\curchaptername\thischaptername
   %
   \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
-  \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
   %
   \ifx\curchaptername\prevchaptername
     \let\thischapterheading\thischapter
@@ -365,7 +371,14 @@
     \def\thischapterheading{}%
   \fi
   %
+  % Common context changes for both heading and footing.
+  % Do this outside of the \shipout so @code etc. will be expanded in
+  % the headline as they should be, not taken literally (outputting ''code).
+  \def\commmonheadfootline{\let\hsize=\txipagewidth \texinfochars}
+  %
   \global\setbox\headlinebox = \vbox{\commmonheadfootline \makeheadline}%
+  %
+  \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
   \global\setbox\footlinebox = \vbox{\commmonheadfootline \makefootline}%
   %
   {%
@@ -386,25 +399,6 @@
       % Do this early so pdf references go to the beginning of the page.
       \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
       %
-      \ifcropmarks \vbox to \outervsize\bgroup
-        \hsize = \outerhsize
-        \vskip-\topandbottommargin
-        \vtop to0pt{%
-          \line{\ewtop\hfil\ewtop}%
-          \nointerlineskip
-          \line{%
-            \vbox{\moveleft\cornerthick\nstop}%
-            \hfill
-            \vbox{\moveright\cornerthick\nstop}%
-          }%
-          \vss}%
-        \vskip\topandbottommargin
-        \line\bgroup
-          \hfil % center the page within the outer (page) hsize.
-          \ifodd\pageno\hskip\bindingoffset\fi
-          \vbox\bgroup
-      \fi
-      %
       \unvbox\headlinebox
       \pagebody{#1}%
       \ifdim\ht\footlinebox > 0pt
@@ -415,24 +409,9 @@
         \unvbox\footlinebox
       \fi
       %
-      \ifcropmarks
-          \egroup % end of \vbox\bgroup
-        \hfil\egroup % end of (centering) \line\bgroup
-        \vskip\topandbottommargin plus1fill minus1fill
-        \boxmaxdepth = \cornerthick
-        \vbox to0pt{\vss
-          \line{%
-            \vbox{\moveleft\cornerthick\nsbot}%
-            \hfill
-            \vbox{\moveright\cornerthick\nsbot}%
-          }%
-          \nointerlineskip
-          \line{\ewbot\hfil\ewbot}%
-        }%
-      \egroup % \vbox from first cropmarks clause
-      \fi
-    }% end of \shipout\vbox
-  }% end of group with \indexdummies
+    }%
+  }%
+  \global\topmarksavedfalse
   \advancepageno
   \ifnum\outputpenalty>-20000 \else\dosupereject\fi
 }
@@ -451,17 +430,6 @@
 address@hidden \kern-\dimen@ \vfil \fi}
 }
 
-% Here are the rules for the cropmarks.  Note that they are
-% offset so that the space between them is truly \outerhsize or \outervsize
-% (P. A. MacKay, 12 November, 1986)
-%
-\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
-\def\nstop{\vbox
-  {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
-\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
-\def\nsbot{\vbox
-  {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
-
 
 % Argument parsing
 
@@ -1219,7 +1187,7 @@ output) for that.)}
   % Set color, and create a mark which defines \thiscolor accordingly,
   % so that \makeheadline knows which color to restore.
   \def\setcolor#1{%
-    \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
+    \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}%
     \domark
     \pdfsetcolor{#1}%
   }
@@ -1227,7 +1195,7 @@ output) for that.)}
   \def\maincolor{\rgbBlack}
   \pdfsetcolor{\maincolor}
   \edef\thiscolor{\maincolor}
-  \def\lastcolordefs{}
+  \def\currentcolordefs{}
   %
   \def\makefootline{%
     \baselineskip24pt
@@ -1605,7 +1573,7 @@ output) for that.)}
   % Set color, and create a mark which defines \thiscolor accordingly,
   % so that \makeheadline knows which color to restore.
   \def\setcolor#1{%
-    \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
+    \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}%
     \domark
     \pdfsetcolor{#1}%
   }
@@ -1613,7 +1581,7 @@ output) for that.)}
   \def\maincolor{\rgbBlack}
   \pdfsetcolor{\maincolor}
   \edef\thiscolor{\maincolor}
-  \def\lastcolordefs{}
+  \def\currentcolordefs{}
   %
   \def\makefootline{%
     \baselineskip24pt
@@ -3090,41 +3058,33 @@ end
   \global\def/{\normalslash}
 }
 
-% we put a little stretch before and after the breakable chars, to help
-% line breaking of long url's.  The unequal skips make look better in
-% cmtt at least, especially for dots.
-\def\urefprestretchamount{.13em}
-\def\urefpoststretchamount{.1em}
-\def\urefprestretch{\urefprebreak \hskip0pt plus\urefprestretchamount\relax}
-\def\urefpoststretch{\urefpostbreak \hskip0pt plus\urefprestretchamount\relax}
-%
-\def\urefcodeamp{\urefprestretch \&\urefpoststretch}
-\def\urefcodedot{\urefprestretch .\urefpoststretch}
-\def\urefcodehash{\urefprestretch \#\urefpoststretch}
-\def\urefcodequest{\urefprestretch ?\urefpoststretch}
+\def\urefcodeamp{\urefprebreak \&\urefpostbreak}
+\def\urefcodedot{\urefprebreak .\urefpostbreak}
+\def\urefcodehash{\urefprebreak \#\urefpostbreak}
+\def\urefcodequest{\urefprebreak ?\urefpostbreak}
 \def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
 {
   \catcode`\/=\active
   \global\def\urefcodeslashfinish{%
-    \urefprestretch \slashChar
+    \urefprebreak \slashChar
     % Allow line break only after the final / in a sequence of
     % slashes, to avoid line break between the slashes in http://.
-    \ifx\next/\else \urefpoststretch \fi
+    \ifx\next/\else \urefpostbreak \fi
   }
 }
 
-% One more complication: by default we'll break after the special
-% characters, but some people like to break before the special chars, so
-% allow that.  Also allow no breaking at all, for manual control.
+% By default we'll break after the special characters, but some people like to 
+% break before the special chars, so allow that.  Also allow no breaking at 
+% all, for manual control.
 % 
 \parseargdef\urefbreakstyle{%
   \def\txiarg{#1}%
   \ifx\txiarg\wordnone
     \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
   \else\ifx\txiarg\wordbefore
-    \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak}
+    \def\urefprebreak{\urefallowbreak}\def\urefpostbreak{\nobreak}
   \else\ifx\txiarg\wordafter
-    \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak}
+    \def\urefprebreak{\nobreak}\def\urefpostbreak{\urefallowbreak}
   \else
     \errhelp = \EMsimple
     \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
@@ -3134,6 +3094,14 @@ end
 \def\wordbefore{before}
 \def\wordnone{none}
 
+% Allow a ragged right output to aid breaking long URL's.  Putting stretch in 
+% between characters of the URL doesn't look good.
+\def\urefallowbreak{%
+  \hskip 0pt plus 1fil\relax
+  \allowbreak
+  \hskip 0pt plus -1fil\relax
+}
+
 \urefbreakstyle after
 
 % @url synonym for @uref, since that's how everyone uses it.
@@ -5102,8 +5070,8 @@ end
   \commondummyword\xref
 }
 
-% For testing: output @{ and @} in index sort strings as \{ and \}.
-\newif\ifusebracesinindexes
+% This does nothing, but for a time it was recommended to use
+% \usebracesinindexestrue to be able to use braces in index entries.
 
 \let\indexlbrace\relax
 \let\indexrbrace\relax
@@ -5256,34 +5224,16 @@ end
 
 \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
 
-% Most index entries go through here, but \dosubind is the general case.
 % #1 is the index name, #2 is the entry text.
-\def\doind#1#2{\dosubind{#1}{#2}{}}
-
-% There is also \dosubind {index}{topic}{subtopic}
-% which makes an entry in a two-level index such as the operation index.
-% TODO: Two-level index?  Operation index?
-
-% Workhorse for all indexes.
-% #1 is name of index, #2 is stuff to put there, #3 is subentry --
-% empty if called from \doind, as we usually are (the main exception
-% is with most defuns, which call us directly).
-%
-\def\dosubind#1#2#3{%
+\def\doind#1#2{%
   \iflinks
   {%
-    \requireopenindexfile{#1}%
-    % Store the main index entry text (including the third arg).
-    \toks0 = {#2}%
-    % If third arg is present, precede it with a space.
-    \def\thirdarg{#3}%
-    \ifx\thirdarg\empty \else
-      \toks0 = \expandafter{\the\toks0 \space #3}%
-    \fi
     %
+    \requireopenindexfile{#1}%
     \edef\writeto{\csname#1indfile\endcsname}%
     %
-    \safewhatsit\dosubindwrite
+    \def\indextext{#2}%
+    \safewhatsit\doindwrite
   }%
   \fi
 }
@@ -5312,14 +5262,7 @@ end
   @address@hidden@address@hidden
 }
 
-% Definition for writing index entry text.
-\def\sortas#1{\ignorespaces}%
-
-% Definition for writing index entry sort key.  Should occur at the at
-% the beginning of the index entry, like
-%     @cindex @sortas{september} \september
-% The \ignorespaces takes care of following space, but there's no way
-% to remove space before it.
+% Definition for writing index entry sort key.
 {
 \catcode`\-=13
 \gdef\indexwritesortas{%
@@ -5330,10 +5273,71 @@ end
   \xdef\indexsortkey{#1}\endgroup}
 }
 
+% Given index entry text like "aaa @subentry bbb @sortas{ZZZ}":
+%   * Set \bracedtext to "{aaa}{bbb}"
+%   * Set \fullindexsortkey to "aaa @subentry ZZZ"
+%
+\def\splitindexentry#1{%
+  \gdef\fullindexsortkey{}%
+  \xdef\bracedtext{}%
+  \def\sep{}%
+  \expandafter\doindexsegment#1\subentry\finish\subentry
+}
+
+% append the results from the next segment
+\def\doindexsegment#1\subentry{%
+  \def\segment{#1}%
+  \ifx\segment\isfinish
+  \else
+    %
+    % Fully expand the segment, throwing away any @sortas directives, and 
+    % trim spaces.
+    \def\sortas##1{}%
+    \edef\trimmed{\segment}%
+    \edef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}%
+    %
+    \xdef\bracedtext{\bracedtext{\trimmed}}%
+    %
+    % Get the string to sort by.  Process the segment with all
+    % font commands turned off.
+    \bgroup
+      \let\sortas\indexwritesortas
+      \indexnofonts
+      % The braces around the commands are recognized by texindex.
+      \def\lbracechar{{\indexlbrace}}%
+      \def\rbracechar{{\indexrbrace}}%
+      \let\{=\lbracechar
+      \let\}=\rbracechar
+      %
+      \let\indexsortkey\empty
+      % Execute the segment and throw away the typeset output.  This executes
+      % any @sortas commands in this segment.
+      \setbox\dummybox = \hbox{\segment}%
+      \ifx\indexsortkey\empty{%
+        \indexnonalnumdisappear
+        \xdef\trimmed{\segment}%
+        \xdef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}%
+        \xdef\indexsortkey{\trimmed}%
+        \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
+      }\fi
+      %
+      % Append to \fullindexsortkey.
+      \edef\tmp{\gdef\noexpand\fullindexsortkey{%
+                  \fullindexsortkey\sep\indexsortkey}}%
+      \tmp
+    \egroup
+    \def\sep{\subentry}%
+    %
+    \expandafter\doindexsegment
+  \fi
+}
+\def\isfinish{\finish}%
+
+\let\subentry\relax
 
 % Write the entry in \toks0 to the index file.
 %
-\def\dosubindwrite{%
+\def\doindwrite{%
   % Put the index entry in the margin if desired.
   \ifx\SETmarginindex\relax\else
     \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
@@ -5343,34 +5347,20 @@ end
   \indexdummies % Must do this here, since \bf, etc expand at this stage
   \useindexbackslash % \indexbackslash isn't defined now so it will be output 
                      % as is; and it will print as backslash.
-  % The braces around \indexbrace are recognized by texindex.
-  %
-  % Get the string to sort by, by processing the index entry with all
-  % font commands turned off.
-  {\indexnofonts
-   \def\lbracechar{{\indexlbrace}}%
-   \def\rbracechar{{\indexrbrace}}%
-   \let\{=\lbracechar
-   \let\}=\rbracechar
-   \indexnonalnumdisappear
-   \xdef\indexsortkey{}%
-   \let\sortas=\indexwritesortas
-   \edef\temp{\the\toks0}%
-   \setbox\dummybox = \hbox{\temp}% Make sure to execute any \sortas
-   \ifx\indexsortkey\empty
-     \xdef\indexsortkey{\temp}%
-     \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
-   \fi
-  }%
+  %
+  % Split the entry into primary entry and any subentries, and get the index 
+  % sort key.
+  \splitindexentry\indextext
   %
   % Set up the complete index entry, with both the sort key and
   % the original text, including any font commands.  We write
   % three arguments to \entry to the .?? file (four in the
   % subentry case), texindex reduces to two when writing the .??s
   % sorted result.
+  %
   \edef\temp{%
     \write\writeto{%
-      \string\entry{\indexsortkey}{\noexpand\folio}{\the\toks0}}%
+      \string\entry{\fullindexsortkey}{\noexpand\folio}\bracedtext}%
   }%
   \temp
 }
@@ -5476,11 +5466,6 @@ end
 \def\tindex {\tpindex}
 \def\pindex {\pgindex}
 
-\def\cindexsub {\begingroup\obeylines\cindexsub}
-{\obeylines %
-\gdef\cindexsub "#1" #2^^M{\endgroup %
-\dosubind{cp}{#2}{#1}}}
-
 % Define the macros used in formatting output of the sorted index material.
 
 % @printindex causes a particular index (the ??s file) to get printed.
@@ -5851,34 +5836,13 @@ end
 \newbox\partialpage
 \newdimen\doublecolumnhsize
 
-% Use inside an output routine to save \topmark and \firstmark
-\def\savemarks{%
-  \global\savedtopmark=\expandafter{\topmark }%
-  \global\savedfirstmark=\expandafter{\firstmark }%
-}
-\newtoks\savedtopmark
-\newtoks\savedfirstmark
-
-% Set \topmark and \firstmark for next time \output runs.
-% Can't be run from withinside \output (because any material
-% added while an output routine is active, including 
-% penalties, is saved for after it finishes).  The page so far
-% should be empty, otherwise what's on it will be thrown away.
-\def\restoremarks{%
-  \mark{\the\savedtopmark}%
-  \bgroup\output = {%
-    \setbox\dummybox=\box\PAGE
-  }abc\eject\egroup
-  % "abc" because output routine doesn't fire for a completely empty page.
-  \mark{\the\savedfirstmark}%
-}
-
 \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
   % If not much space left on page, start a new page.
   \ifdim\pagetotal>0.8\vsize\vfill\eject\fi
   %
   % Grab any single-column material above us.
   \output = {%
+    \savetopmark
     %
     % Here is a possibility not foreseen in manmac: if we accumulate a
     % whole lot of material, we might end up calling this \output
@@ -5896,15 +5860,8 @@ end
       \unvbox\PAGE
       \kern-\topskip \kern\baselineskip
     }%
-    \savemarks
   }%
   \eject % run that output routine to set \partialpage
-  \restoremarks
-  %
-  % We recover the two marks that the last output routine saved in order
-  % to propagate the information in marks added around a chapter heading,
-  % which could be otherwise be lost by the time the final page is output.
-  %
   %
   % Use the double-column output routine for subsequent pages.
   \output = {\doublecolumnout}%
@@ -5930,7 +5887,9 @@ end
     \divide\doublecolumnhsize by 2
   \hsize = \doublecolumnhsize
   %
-  % Double the \vsize as well.
+  % Get the available space for the double columns -- the normal
+  % (undoubled) page height minus any material left over from the
+  % previous page.
   \advance\vsize by -\ht\partialpage
   \vsize = 2\vsize
   %
@@ -5943,17 +5902,15 @@ end
 %
 \def\doublecolumnout{%
   %
+  \savetopmark
   \splittopskip=\topskip \splitmaxdepth=\maxdepth
-  % Get the available space for the double columns -- the normal
-  % (undoubled) page height minus any material left over from the
-  % previous page.
   \dimen@ = \vsize
   \divide\dimen@ by 2
   %
   % box0 will be the left-hand column, box2 the right.
   \setbox0=\vsplit\PAGE to\dimen@ \setbox2=\vsplit\PAGE to\dimen@
   \global\advance\vsize by 2\ht\partialpage
-  \onepageout\pagesofar
+  \onepageout\pagesofar % empty except for the first time we are called
   \unvbox\PAGE
   \penalty\outputpenalty
 }
@@ -6001,7 +5958,7 @@ end
   %
   \output = {%
     % Split the last of the double-column material.
-    \savemarks
+    \savetopmark
     \balancecolumns
   }%
   \eject % call the \output just set
@@ -6009,10 +5966,9 @@ end
     % Having called \balancecolumns once, we do not
     % want to call it again.  Therefore, reset \output to its normal
     % definition right away.
-    \global\output = {\onepageout{\pagecontents\PAGE}}%
+    \global\output=\expandafter{\the\defaultoutput}
     %
     \endgroup % started in \begindoublecolumns
-    \restoremarks
     % Leave the double-column material on the current page, no automatic
     % page break.
     \box\balancedcolumns
@@ -6036,13 +5992,14 @@ end
 \def\balancecolumns{%
   \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120.
   \dimen@ = \ht0
-  \advance\dimen@ by \topskip
-  \advance\dimen@ by-\baselineskip
-  \ifdim\dimen@<5\baselineskip
+  \ifdim\dimen@<7\baselineskip
     % Don't split a short final column in two.
     \setbox2=\vbox{}%
     \global\setbox\balancedcolumns=\vbox{\pagesofar}%
   \else
+    % double the leading vertical space
+    \advance\dimen@ by \topskip
+    \advance\dimen@ by-\baselineskip
     \divide\dimen@ by 2 % target to split to
     address@hidden = \dimen@
     \splittopskip = \topskip
@@ -6526,27 +6483,22 @@ end
   \expandafter\ifx\thisenv\titlepage\else
     \checkenv{}% chapters, etc., should not start inside an environment.
   \fi
-  % FIXME: \chapmacro is currently called from inside \titlepage when
-  % \setcontentsaftertitlepage to print the "Table of Contents" heading, but
-  % this should probably be done by \sectionheading with an option to print
-  % in chapter size.
-  %
   % Insert the first mark before the heading break (see notes for \domark).
-  \let\prevchapterdefs=\lastchapterdefs
-  \let\prevsectiondefs=\lastsectiondefs
-  \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
+  \let\prevchapterdefs=\currentchapterdefs
+  \let\prevsectiondefs=\currentsectiondefs
+  \gdef\currentsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
                         \gdef\thissection{}}%
   %
   \def\temptype{#2}%
   \ifx\temptype\Ynothingkeyword
-    \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
+    \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
                           \gdef\thischapter{\thischaptername}}%
   \else\ifx\temptype\Yomitfromtockeyword
-    \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
+    \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
                           \gdef\thischapter{}}%
   \else\ifx\temptype\Yappendixkeyword
     \toks0={#1}%
-    \xdef\lastchapterdefs{%
+    \xdef\currentchapterdefs{%
       \gdef\noexpand\thischaptername{\the\toks0}%
       \gdef\noexpand\thischapternum{\appendixletter}%
       % \noexpand\putwordAppendix avoids expanding indigestible
@@ -6557,7 +6509,7 @@ end
     }%
   \else
     \toks0={#1}%
-    \xdef\lastchapterdefs{%
+    \xdef\currentchapterdefs{%
       \gdef\noexpand\thischaptername{\the\toks0}%
       \gdef\noexpand\thischapternum{\the\chapno}%
       % \noexpand\putwordChapter avoids expanding indigestible
@@ -6577,18 +6529,18 @@ end
   %
   % Now the second mark, after the heading break.  No break points
   % between here and the heading.
-  \let\prevchapterdefs=\lastchapterdefs
-  \let\prevsectiondefs=\lastsectiondefs
+  \let\prevchapterdefs=\currentchapterdefs
+  \let\prevsectiondefs=\currentsectiondefs
   \domark
   %
   {%
     \chapfonts \rm
     \let\footnote=\errfootnoteheading % give better error message
     %
-    % Have to define \lastsection before calling \donoderef, because the
+    % Have to define \currentsection before calling \donoderef, because the
     % xref code eventually uses it.  On the other hand, it has to be called
     % after \pchapsepmacro, or the headline will change too soon.
-    \gdef\lastsection{#1}%
+    \gdef\currentsection{#1}%
     %
     % Only insert the separating space if we have a chapter/appendix
     % number, and don't print the unnumbered ``number''.
@@ -6677,10 +6629,10 @@ end
     \csname #2fonts\endcsname \rm
     %
     % Insert first mark before the heading break (see notes for \domark).
-    \let\prevsectiondefs=\lastsectiondefs
+    \let\prevsectiondefs=\currentsectiondefs
     \ifx\temptype\Ynothingkeyword
       \ifx\sectionlevel\seckeyword
-        \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
+        
\gdef\currentsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
                               \gdef\thissection{\thissectionname}}%
       \fi
     \else\ifx\temptype\Yomitfromtockeyword
@@ -6688,7 +6640,7 @@ end
     \else\ifx\temptype\Yappendixkeyword
       \ifx\sectionlevel\seckeyword
         \toks0={#1}%
-        \xdef\lastsectiondefs{%
+        \xdef\currentsectiondefs{%
           \gdef\noexpand\thissectionname{\the\toks0}%
           \gdef\noexpand\thissectionnum{#4}%
           % \noexpand\putwordSection avoids expanding indigestible
@@ -6701,7 +6653,7 @@ end
     \else
       \ifx\sectionlevel\seckeyword
         \toks0={#1}%
-        \xdef\lastsectiondefs{%
+        \xdef\currentsectiondefs{%
           \gdef\noexpand\thissectionname{\the\toks0}%
           \gdef\noexpand\thissectionnum{#4}%
           % \noexpand\putwordSection avoids expanding indigestible
@@ -6727,28 +6679,28 @@ end
     %
     % Now the second mark, after the heading break.  No break points
     % between here and the heading.
-    \global\let\prevsectiondefs=\lastsectiondefs
+    \global\let\prevsectiondefs=\currentsectiondefs
     \domark
     %
     % Only insert the space after the number if we have a section number.
     \ifx\temptype\Ynothingkeyword
       \setbox0 = \hbox{}%
       \def\toctype{unn}%
-      \gdef\lastsection{#1}%
+      \gdef\currentsection{#1}%
     \else\ifx\temptype\Yomitfromtockeyword
       % for @headings -- no section number, don't include in toc,
-      % and don't redefine \lastsection.
+      % and don't redefine \currentsection.
       \setbox0 = \hbox{}%
       \def\toctype{omit}%
       \let\sectionlevel=\empty
     \else\ifx\temptype\Yappendixkeyword
       \setbox0 = \hbox{#4\enspace}%
       \def\toctype{app}%
-      \gdef\lastsection{#1}%
+      \gdef\currentsection{#1}%
     \else
       \setbox0 = \hbox{#4\enspace}%
       \def\toctype{num}%
-      \gdef\lastsection{#1}%
+      \gdef\currentsection{#1}%
     \fi\fi\fi
     %
     % Write the toc entry (before \donoderef).  See comments in \chapmacro.
@@ -7405,13 +7357,9 @@ end
 
 
 % @raggedright does more-or-less normal line breaking but no right
-% justification.  From plain.tex.  Don't stretch around special
-% characters in urls in this environment, since the stretch at the right
-% should be enough.
+% justification.  From plain.tex.
 \envdef\raggedright{%
   \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax
-  \def\urefprestretchamount{0pt}%
-  \def\urefpoststretchamount{0pt}%
 }
 \let\Eraggedright\par
 
@@ -7573,7 +7521,7 @@ end
   \nonfillstart
   \tt % easiest (and conventionally used) font for verbatim
   % The \leavevmode here is for blank lines.  Otherwise, we would
-  % never \starttabox and the \egroup would end verbatim mode.
+  % never \starttabbox and the \egroup would end verbatim mode.
   \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
   \tabexpand
   \setupmarkupstyle{verbatim}%
@@ -7636,9 +7584,12 @@ end
   {%
     \makevalueexpandable
     \setupverbatim
-    \indexnofonts       % Allow `@@' and other weird things in file names.
-    \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
-    \input #1
+    {%
+      \indexnofonts       % Allow `@@' and other weird things in file names.
+      \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
+      \edef\tmp{\noexpand\input #1 }
+      \expandafter
+    }\tmp
     \afterenvbreak
   }%
 }
@@ -7783,6 +7734,21 @@ end
   \fi\fi
 }
 
+% \dosubind {index}{topic}{subtopic}
+%
+% If SUBTOPIC is present, precede it with a space, and call \doind.
+% (At some time during the 20th century, this made a two-level entry in an 
+% index such as the operation index.  Nobody seemed to notice the change in 
+% behaviour though.)
+\def\dosubind#1#2#3{%
+  \def\thirdarg{#3}%
+  \ifx\thirdarg\empty
+    \doind{#1}{#2}%
+  \else
+    \doind{#1}{#2\space#3}%
+  \fi
+}
+
 % Untyped functions:
 
 % @deffn category name args
@@ -7797,7 +7763,6 @@ end
 % \deffngeneral {subind}category name args
 %
 \def\deffngeneral#1#2 #3 #4\endheader{%
-  % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
   \dosubind{fn}{\code{#3}}{#1}%
   \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
 }
@@ -8809,7 +8774,7 @@ end
 
 % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
 % anchor), which consists of three parts:
-% 1) NAME-title - the current sectioning name taken from \lastsection,
+% 1) NAME-title - the current sectioning name taken from \currentsection,
 %                 or the anchor name.
 % 2) NAME-snt   - section number and type, passed as the SNT arg, or
 %                 empty for anchors.
@@ -8831,7 +8796,7 @@ end
        address@hidden #1 of \setref, expanded by the \edef
          ##1}{##2}}% these are parameters of \writexrdef
       }%
-      \toks0 = \expandafter{\lastsection}%
+      \toks0 = \expandafter{\currentsection}%
       \immediate \writexrdef{title}{\the\toks0 }%
       \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
       \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
@@ -9629,13 +9594,13 @@ end
       \global\advance\floatno by 1
       %
       {%
-        % This magic value for \lastsection is output by \setref as the
+        % This magic value for \currentsection is output by \setref as the
         % XREFLABEL-title value.  \xrefX uses it to distinguish float
         % labels (which have a completely different output format) from
         % node and anchor labels.  And \xrdef uses it to construct the
         % lists of floats.
         %
-        \edef\lastsection{\floatmagic=\safefloattype}%
+        \edef\currentsection{\floatmagic=\safefloattype}%
         \setref{\floatlabel}{Yfloat}%
       }%
     \fi
@@ -9758,7 +9723,7 @@ end
 
 % #1 is the control sequence we are passed; we expand into a conditional
 % which is true if #1 represents a float ref.  That is, the magic
-% \lastsection value which we \setref above.
+% \currentsection value which we \setref above.
 %
 \def\iffloat#1{\expandafter\doiffloat#1==\finish}
 %
@@ -11246,21 +11211,14 @@ directory should work if nowhere else does.}
    \relax
 }
 
-% define all Unicode characters we know about, for the sake of @U.
+% Define all Unicode characters we know about.  This makes UTF-8 the default
+% input encoding and allows @U to work.
 \iftxinativeunicodecapable
   \nativeunicodechardefsatu
 \else
   \utfeightchardefs
 \fi
 
-
-% Make non-ASCII characters printable again for compatibility with
-% existing Texinfo documents that may use them, even without declaring a
-% document encoding.
-%
-\setnonasciicharscatcode \other
-
-
 \message{formatting,}
 
 \newdimen\defaultparindent \defaultparindent = 15pt
diff --git a/doc/misc/todo-mode.texi b/doc/misc/todo-mode.texi
index 1e4ea85..18e5a8f 100644
--- a/doc/misc/todo-mode.texi
+++ b/doc/misc/todo-mode.texi
@@ -9,7 +9,7 @@
 @c %**end of header
 
 @copying
-Copyright @copyright{} 2013-2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2013-2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index d5a45ad..ca86458 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -2,9 +2,8 @@
 @setfilename ../../info/tramp.info
 @c %**start of header
 @include docstyle.texi
address@hidden In the Tramp repository, the version number is auto-frobbed from
address@hidden configure.ac, so you should edit that file and run
address@hidden "autoconf && ./configure" to change the version number.
address@hidden In the Tramp GIT, the version number is auto-frobbed from 
tramp.el,
address@hidden and the bug report address is auto-frobbed from configure.ac.
 @include trampver.texi
 @settitle @value{tramp} @value{trampver} User Manual
 @c %**end of header
@@ -13,7 +12,7 @@
 @footnotestyle end
 
 @copying
-Copyright @copyright{} 1999--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1999--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -28,10 +27,10 @@ copy and modify this GNU manual.''
 @end quotation
 @end copying
 
address@hidden Entries for @command{install-info} to use
address@hidden Entries for @command{install-info} to use.  We cannot use 
@value{tramp}.
 @dircategory Emacs network features
 @direntry
-* @value{tramp}: (tramp).               Transparent Remote Access, Multiple 
Protocol
+* Tramp: (tramp).               Transparent Remote Access, Multiple Protocol
                                   Emacs remote file access via ssh and scp.
 @end direntry
 
@@ -52,7 +51,7 @@ editing package for Emacs.
 
 @value{tramp} stands for ``Transparent Remote (file) Access, Multiple
 Protocol''.  This package provides remote file editing, similar to
-Ange FTP.
+Ange address@hidden
 
 The difference is that Ange FTP uses FTP to transfer files between the
 local and the remote host, whereas @value{tramp} uses a combination of
@@ -114,8 +113,8 @@ For the developer:
 
 Installing @value{tramp} with your Emacs
 
-* System Requirements::         Prerequisites for :@value{tramp} installation.
-* Basic Installation::          Installation steps.:
+* System Requirements::         Prerequisites for @value{tramp} installation.
+* Basic Installation::          Installation steps.
 * Installation parameters::     Parameters in order to control installation.
 * Testing::                     A test suite for @value{tramp}.
 * Load paths::                  How to plug-in @value{tramp} into your 
environment.
@@ -468,6 +467,40 @@ The method @option{sg} stands for ``switch group''; the 
changed group
 must be used here as user name.  The default host name is the same.
 
 
address@hidden Start Guide: @option{ssh}, @option{plink}, @option{su}, 
@option{sudo} and @option{sg} methods}
address@hidden Combining @option{ssh} or @option{plink} with @option{su} or 
@option{sudo}
address@hidden method @option{ssh}
address@hidden @option{ssh} method
address@hidden method @option{plink}
address@hidden @option{plink} method
address@hidden method @option{su}
address@hidden @option{su} method
address@hidden method @option{sudo}
address@hidden @option{sudo} method
+
+If the @option{su} or @option{sudo} option shall be performed on
+another host, it could be comnbined with a leading @option{ssh} or
address@hidden option.  That means, @value{tramp} connects first to
+the other host with non-administrative credentials, and changes to
+administrative credentials on that host afterwards.  In a simple case,
+the syntax looks like
address@hidden@address@hidden@@host|address@hidden@value{postfix}/path/to/file}.
address@hidden multi-hops}.
+
+
address@hidden Start Guide: @option{sudoedit} method}
address@hidden Using @command{sudoedit}
address@hidden method @option{sudoedit}
address@hidden @option{sudoedit} method
+
+The @option{sudoedit} method is similar to the @option{sudo} method.
+However, it is a different implementation: it does not keep an open
+session running in the background.  This is for security reasons; on
+the backside this method is less performant than the @option{sudo}
+method, it is restricted to the @samp{localhost} only, and it does not
+support external processes.
+
+
 @anchor{Quick Start Guide: @option{smb} method}
 @section Using @command{smbclient}
 @cindex method @option{smb}
@@ -571,6 +604,13 @@ installed and loaded:
 (customize-set-variable 'tramp-verbose 6 "Enable remote command traces")
 @end lisp
 
+For functions used to configure @value{tramp}, the following clause
+might be used in your init file:
+
address@hidden
+(with-eval-after-load 'tramp (tramp-change-syntax 'simplified))
address@hidden lisp
+
 
 @menu
 * Connection types::            Types of connections to remote hosts.
@@ -919,12 +959,36 @@ NAS hosts.  These dumb devices have severely restricted 
local shells,
 such as the @command{busybox} and do not host any other encode or
 decode programs.
 
address@hidden @option{sudoedit}
address@hidden method @option{sudoedit}
address@hidden @option{sudoedit} method
+
+The @option{sudoedit} method allows to edit a file as a different user
+on the local host.  You could regard this as @value{tramp}'s
+implementation of the @command{sudoedit}.  Contrary to the
address@hidden method, all magic file name functions are implemented by
+single @command{sudo @dots{}}  commands.  The purpose is to make
+editing such a file as secure as possible; there must be no session
+running in the Emacs background which could be attacked from inside
+Emacs.
+
+Consequently, external processes are not implemented.
+
+The host name of such remote file names must represent the local host.
+Since the default value is already proper, it is recommended not to
+use any host name in the remote file name, like
address@hidden@trampfn{sudoedit,,/path/to/file}} or
address@hidden@trampfn{sudoedit,user@@,/path/to/file}}.
+
+Like the @option{sudo} method, a @option{sudoedit} password expires
+after a predefined timeout.
+
 @item @option{ftp}
 @cindex method @option{ftp}
 @cindex @option{ftp} method
 
 When @value{tramp} uses @option{ftp}, it forwards requests to whatever
-ftp program is specified by Ange FTP.  This external program must be
+ftp program is specified by Ange address@hidden  This external program must be
 capable of servicing requests from @value{tramp}.
 
 @item @option{smb}
@@ -1048,8 +1112,8 @@ numbers are not applicable to Android devices connected 
through address@hidden
 The program @command{rclone} allows to access different system
 storages in the cloud, see @url{https://rclone.org/} for a list of
 supported systems.  If the @command{rclone} program isn't found in
-your @env{PATH} environment variable, you can tell Tramp its absolute
-path via the user option @code{tramp-rclone-program}.
+your @env{PATH} environment variable, you can tell @value{tramp} its
+absolute path via the user option @code{tramp-rclone-program}.
 
 A system storage must be configured via the @command{rclone config}
 command, outside Emacs.  If you have configured a storage in
@@ -1064,7 +1128,7 @@ User names are part of the @command{rclone} 
configuration, and not
 needed in the remote file name.  If a user name is contained in the
 remote file name, it is ignored.
 
-Internally, Tramp mounts the remote system storage at location
+Internally, @value{tramp} mounts the remote system storage at location
 @file{/tmp/tramp.rclone.storage}, with @file{storage} being the name
 of the configured system storage.
 
@@ -1494,8 +1558,8 @@ Host host.other.domain
 @end group
 @end example
 
address@hidden is BSD's netcat program, which establishes HTTP tunnels. Any
-other program with such a feature could be used as well.
address@hidden is BSD's netcat program, which establishes HTTP tunnels.
+Any other program with such a feature could be used as well.
 
 In the example, opening @address@hidden,host.your.domain,}} passes
 the HTTP proxy server @samp{proxy.your.domain} on port 3128.
@@ -1571,7 +1635,7 @@ Integration for LXD containers.  A container is accessed 
via
 @cindex method @option{git}
 @cindex @option{git} method
 Browing git repositories with @code{magit}.  A versioned file is accessed via
address@hidden@trampfn{git,rev@@root-dir,/path/to/file}}. @samp{rev} is a git
address@hidden@trampfn{git,rev@@root-dir,/path/to/file}}.  @samp{rev} is a git
 revision, and @samp{root-dir} is a virtual host name for the root
 directory, specified in @code{magit-tramp-hosts-alist}.
 
@@ -1942,6 +2006,39 @@ preserves the path value, which can be used to update
 shell supports the login argument @samp{-l}.
 @end defopt
 
+Starting with Emacs 26, @code{tramp-remote-path} can be set per host
+via connection-local
address@hidden
+variables, @xref{Connection Variables, , , emacs}.
address@hidden ifinfo
address@hidden
+variables.
address@hidden ifnotinfo
+You could define your own search directories like this:
+
address@hidden
address@hidden
+(connection-local-set-profile-variables 'remote-path-with-bin
+   '((tramp-remote-path . ("~/bin" tramp-default-remote-path))))
address@hidden group
+
address@hidden
+(connection-local-set-profile-variables 'remote-path-with-apply-pub-bin
+   '((tramp-remote-path . ("/appli/pub/bin" tramp-default-remote-path))))
address@hidden group
+
address@hidden
+(connection-local-set-profiles
+   '(:application tramp :machine "randomhost") 'remote-path-with-bin)
address@hidden group
+
address@hidden
+(connection-local-set-profiles
+   '(:application tramp :user "anotheruser" :machine "anotherhost")
+     'remote-path-with-apply-pub-bin)
address@hidden group
address@hidden lisp
+
 When remote search paths are changed, local @value{tramp} caches must
 be recomputed.  To force @value{tramp} to recompute afresh, call
 @kbd{M-x tramp-cleanup-this-connection @key{RET}} or friends
@@ -2565,7 +2662,7 @@ names.  Beside the @code{default} value, @var{syntax} can 
be
 @item @code{simplified}
 @cindex simplified syntax
 
-The remote file name syntax is similar to the syntax used by Ange FTP.
+The remote file name syntax is similar to the syntax used by Ange 
address@hidden
 A remote file name has the form
 @address@hidden@@address@hidden/to/file}.  The
 @code{user@@} part is optional, and the method is determined by
@@ -2594,7 +2691,7 @@ name syntax.  Its value changes after every call of
 this variable in external packages, a call of @code{file-remote-p} is
 much more appropriate.
 @ifinfo
address@hidden File Names, , , elisp}
address@hidden File Names, , , elisp}.
 @end ifinfo
 @end defvar
 @end ifset
@@ -2739,11 +2836,16 @@ proxy @samp{bird@@bastion} to a remote file on 
@samp{you@@remotehost}:
 @kbd{C-x C-f @address@hidden@@bastion|address@hidden@@address@hidden/path 
@key{RET}}
 @end example
 
+Each involved method must be an inline method (@pxref{Inline methods}).
+
 @value{tramp} adds the ad-hoc definitions on the fly to
address@hidden and is available for re-use
-during that Emacs session.  Subsequent @value{tramp} connections to
-the same remote host can then use the shortcut form:
address@hidden@trampfn{ssh,you@@remotehost,/path}}.
address@hidden and is available for re-use during
+that Emacs session.  Subsequent @value{tramp} connections to the same
+remote host can then use the shortcut form:
address@hidden@trampfn{ssh,you@@remotehost,/path}}.  Ad-hoc definitions are
+removed from @code{tramp-default-proxies-alist} via the command
address@hidden tramp-cleanup-all-connections @key{RET}} (@pxref{Cleanup
+remote connections}).
 
 @defopt tramp-save-ad-hoc-proxies
 For ad-hoc definitions to be saved automatically in
@@ -2928,7 +3030,7 @@ Starting with Emacs 26, you could use connection-local 
variables for
 setting different values of @code{explicit-shell-file-name} for
 different remote hosts.
 @ifinfo
address@hidden Local Variables, , , elisp}
address@hidden Variables, , , emacs}.
 @end ifinfo
 
 @lisp
@@ -2981,6 +3083,14 @@ host.  Example:
 @kbd{M-x auto-revert-tail-mode @key{RET}} runs similarly showing
 continuous output.
 
address@hidden uses the variables @code{shell-file-name} and
address@hidden in order to determine which shell to run.
+For remote hosts, their default values are @file{/bin/sh} and
address@hidden, respectively (except for the @option{adb} method, which
+uses @file{/system/bin/sh}).  Like the variables in the previous
+section, these variables can be changed via connection-local
+variables.
+
 
 @subsection Running @code{eshell} on a remote host
 @cindex @code{eshell}
@@ -3124,7 +3234,8 @@ interactively, this command lists active remote 
connections in the
 minibuffer.  Each connection is of the format
 @address@hidden,user@@host,}}.  Flushing remote connections also
 cleans the password cache (@pxref{Password handling}), file cache,
-connection cache (@pxref{Connection caching}), and connection buffers.
+connection cache (@pxref{Connection caching}), recentf cache
+(@pxref{File Conveniences, , , emacs}), and connection buffers.
 @end deffn
 
 @deffn Command tramp-cleanup-this-connection
@@ -3134,13 +3245,15 @@ as in @code{tramp-cleanup-connection}.
 
 @deffn Command tramp-cleanup-all-connections
 Flushes all active remote connection objects, the same as in
address@hidden
address@hidden  This command removes also ad-hoc
+proxy definitions (@pxref{Ad-hoc multi-hops}).
+
 @end deffn
 
 @deffn Command tramp-cleanup-all-buffers
 Just as for @code{tramp-cleanup-all-connections}, all remote
-connections are cleaned up in addition to killing buffers related to
-that remote connection.
+connections and ad-hoc proxy definition are cleaned up in addition to
+killing buffers related to that remote connection.
 @end deffn
 
 
@@ -3627,7 +3740,7 @@ Set @code{file-precious-flag} to @code{t} for files 
accessed by
 @value{tramp} so the file contents are checked using checksum by
 first saving to a temporary file.
 @ifinfo
address@hidden Buffers, , , elisp}
address@hidden Buffers, , , elisp}.
 @end ifinfo
 
 @lisp
@@ -3812,7 +3925,9 @@ Due to the remote shell saving tilde expansions triggered 
by
 @value{tramp} can suppress this behavior with the user option
 @code{tramp-histfile-override}.  When set to @code{t}, environment
 variable @env{HISTFILE} is unset, and environment variables
address@hidden and @env{HISTSIZE} are set to 0.
address@hidden and @env{HISTSIZE} are set to 0.  Don't use this
+with @command{bash} 5.0.0.  There is a bug in @command{bash} which
+lets @command{bash} die.
 
 Alternatively, @code{tramp-histfile-override} could be a string.
 Environment variable @env{HISTFILE} is set to this file name then.  Be
@@ -4277,7 +4392,7 @@ handlers.
 @vindex non-essential
 Sometimes, it is not convenient to open a new connection to a remote
 host, including entering the password and alike.  For example, this is
-nasty for packages providing file name completion. Such a package
+nasty for packages providing file name completion.  Such a package
 could signal to @value{tramp}, that they don't want it to establish a
 new connection.  Use the variable @code{non-essential} temporarily and
 bind it to address@hidden value.
diff --git a/doc/misc/trampver.texi b/doc/misc/trampver.texi
index aac7243..5b1408a 100644
--- a/doc/misc/trampver.texi
+++ b/doc/misc/trampver.texi
@@ -2,12 +2,12 @@
 @c texi/trampver.texi.  Generated from trampver.texi.in by configure.
 
 @c This is part of the Emacs manual.
address@hidden Copyright (C) 2003-2018 Free Software Foundation, Inc.
address@hidden Copyright (C) 2003-2019 Free Software Foundation, Inc.
 @c See file doclicense.texi for copying conditions.
 
 @c In the Tramp GIT, the version number is auto-frobbed from tramp.el,
 @c and the bug report address is auto-frobbed from configure.ac.
address@hidden trampver 2.4.1-pre
address@hidden trampver 2.4.2-pre
 @set tramp-bug-report-address tramp-devel@@gnu.org
 
 @c Other flags from configuration.
diff --git a/doc/misc/url.texi b/doc/misc/url.texi
index eaeae60..0cdfcac 100644
--- a/doc/misc/url.texi
+++ b/doc/misc/url.texi
@@ -21,7 +21,7 @@
 @copying
 This is the manual for the @code{url} Emacs Lisp library.
 
-Copyright @copyright{} 1993--1999, 2002, 2004--2018 Free Software
+Copyright @copyright{} 1993--1999, 2002, 2004--2019 Free Software
 Foundation, Inc.
 
 @quotation
diff --git a/doc/misc/vhdl-mode.texi b/doc/misc/vhdl-mode.texi
index c0efdbf..8af6586 100644
--- a/doc/misc/vhdl-mode.texi
+++ b/doc/misc/vhdl-mode.texi
@@ -10,7 +10,7 @@
 @copying
 This file documents VHDL Mode, an Emacs mode for editing VHDL code.
 
-Copyright @copyright{} 1995--2008, 2010, 2012, 2015--2018 Free Software
+Copyright @copyright{} 1995--2008, 2010, 2012, 2015--2019 Free Software
 Foundation, Inc.
 
 @quotation
diff --git a/doc/misc/vip.texi b/doc/misc/vip.texi
index 92aea38..47a3f34 100644
--- a/doc/misc/vip.texi
+++ b/doc/misc/vip.texi
@@ -4,7 +4,7 @@
 @include docstyle.texi
 
 @copying
-Copyright @copyright{} 1987, 2001--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1987, 2001--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/viper.texi b/doc/misc/viper.texi
index e67734b..922c91b 100644
--- a/doc/misc/viper.texi
+++ b/doc/misc/viper.texi
@@ -8,7 +8,7 @@
 @include docstyle.texi
 
 @copying
-Copyright @copyright{} 1995--1997, 2001--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 1995--1997, 2001--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/widget.texi b/doc/misc/widget.texi
index bf21ac3..6d94768 100644
--- a/doc/misc/widget.texi
+++ b/doc/misc/widget.texi
@@ -9,7 +9,7 @@
 @c %**end of header
 
 @copying
-Copyright @copyright{} 2000--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2000--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/doc/misc/wisent.texi b/doc/misc/wisent.texi
index 12bb09c..b404c2a 100644
--- a/doc/misc/wisent.texi
+++ b/doc/misc/wisent.texi
@@ -24,7 +24,7 @@
 @c %**end of header
 
 @copying
-Copyright @copyright{} 1988--1993, 1995, 1998--2004, 2007, 2012--2018
+Copyright @copyright{} 1988--1993, 1995, 1998--2004, 2007, 2012--2019
 Free Software Foundation, Inc.
 
 @c Since we are both GNU manuals, we do not need to ack each other here.
diff --git a/doc/misc/woman.texi b/doc/misc/woman.texi
index f8ddbd2..9c04a14 100644
--- a/doc/misc/woman.texi
+++ b/doc/misc/woman.texi
@@ -15,7 +15,7 @@
 This file documents WoMan: A program to browse Unix manual pages ``W.O.
 (without) man''.
 
-Copyright @copyright{} 2001--2018 Free Software Foundation, Inc.
+Copyright @copyright{} 2001--2019 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
diff --git a/etc/AUTHORS b/etc/AUTHORS
index 07cdf0a..2f7e015 100644
--- a/etc/AUTHORS
+++ b/etc/AUTHORS
@@ -108,9 +108,9 @@ Alan Shutko: changed diary-lib.el calendar.el bindings.el 
cal-hebrew.el
 
 Alan Third: wrote dabbrev-tests.el
 and changed nsterm.m nsfns.m nsterm.h nsmenu.m frame.el macfont.m
-  nsimage.m ns-win.el Info.plist.in conf_post.h frame.c frame.h
+  nsimage.m ns-win.el xdisp.c Info.plist.in conf_post.h frame.c frame.h
   frames.texi keyboard.c macfont.h macos.texi picture.el rect.el
-  battery.el callproc.c configure.ac and 12 other files
+  battery.el callproc.c and 12 other files
 
 Alastair Burt: changed gnus-art.el smiley.el
 
@@ -163,7 +163,7 @@ Alexandru Harsanyi: wrote soap-client.el soap-inspect.el
 and changed emacs3.py vc-hooks.el vc.el xml.el
 
 Alex Branham: changed bibtex.el dired-x.el dired.el em-rebind.el eww.el
-  imenu.el programs.texi
+  imenu.el indent.el modes.texi programs.texi text.texi
 
 Alex Coventry: changed files.el
 
@@ -366,8 +366,8 @@ Antonin Houska: changed newcomment.el
 Arash Esbati: changed reftex-vars.el reftex.el reftex-auc.el
   reftex-ref.el
 
-Ari Roponen: changed atimer.c doc.c hash.texi image.c mule.texi
-  package.el startup.el subr.el svg.el time-date.el woman.el xterm.c
+Ari Roponen: changed xterm.c atimer.c doc.c hash.texi image.c mule.texi
+  package.el startup.el subr.el svg.el time-date.el woman.el
 
 Arisawa Akihiro: changed characters.el coding.c epa-file.el japan-util.el
   language/tibetan.el message.el mm-decode.el mm-view.el ps-print.el
@@ -442,8 +442,8 @@ Bartosz Duszel: changed allout.el bib-mode.el cc-cmds.el 
hexl.el icon.el
 
 Basil L. Contovounesios: changed simple.el message.el sequences.texi
   bibtex.el css-mode-tests.el css-mode.el customize.texi display.texi
-  gnus-art.el json-tests.el json.el lists.texi man.el rcirc.el
-  shr-color.el text.texi
+  gnus-art.el json-tests.el json.el lists.texi man.el modes.texi
+  newcomment.el rcirc.el shr-color.el text.texi url-handlers.el
 
 Bastian Beischer: changed include.el mru-bookmark.el refs.el
   semantic/complete.el senator.el
@@ -471,8 +471,9 @@ Benjamin Andresen: wrote ob-screen.el
 Benjamin Drieu: wrote pong.el
 and changed org-clock.el org.el
 
-Benjamin Riefenstahl: changed w32select.c emacs.c inc/ms-w32.h lisp.h
-  mac-win.el macterm.c mule-cmds.el runemacs.c tcl.el w32.c w32.h
+Benjamin Riefenstahl: changed w32select.c emacs.c image-mode.el image.el
+  inc/ms-w32.h lisp.h mac-win.el macterm.c mule-cmds.el runemacs.c tcl.el
+  w32.c w32.h
 
 Benjamin Rutt: co-wrote gnus-dired.el
 and changed vc.el gnus-msg.el message.el diff-mode.el ffap.el nnimap.el
@@ -673,7 +674,7 @@ Chao-Hong Liu: changed TUTORIAL.cn TUTORIAL.zh
 Charles A. Roelli: changed nsterm.m display.texi isearch.el nsfns.m
   nsterm.h org-clock.el search.texi simple.el DEBUG INSTALL add-log.el
   anti.texi buffers.texi comint.el data.c diff-mode.el eldoc.el files.el
-  fill.el find-func.el flymake.el and 19 other files
+  fill.el find-func.el flymake.el and 21 other files
 
 Charles Hannum: changed aix3-1.h aix3-2.h configure ibmrs6000.h
   keyboard.c netbsd.h pop.c sysdep.c systime.h systty.h xrdb.c
@@ -703,7 +704,8 @@ and changed simple.el display.texi xdisp.c files.el 
frames.texi
 
 Chris Chase: co-wrote idlw-shell.el idlwave.el
 
-Chris Feng: changed dispnew.c autoload.el frame.c process.c
+Chris Feng: changed dispnew.c autoload.el frame.c keyboard-tests.el
+  keyboard.c process.c
 
 Chris Foote: changed progmodes/python.el
 
@@ -931,12 +933,16 @@ and changed package-test.el package-x.el ange-ftp.el
 
 Daniel Jensen: changed apropos.el
 
+Daniel Kahn Gillmor: changed mml-sec.el
+
 Daniel Koning: changed artist.el commands.texi subr.el
 
 Daniel LaLiberte: wrote cust-print.el edebug.el isearch.el
 and co-wrote hideif.el
 and changed mlconvert.el eval-region.el
 
+Daniel Lopez: changed progmodes/compile.el
+
 Daniel Lublin: changed dns-mode.el
 
 Daniel McClanahan: changed lisp-mode.el
@@ -1132,7 +1138,7 @@ and changed imenu.el pgg-def.el xterm.c
 David O'Toole: wrote ox-publish.el
 and co-wrote ob-lisp.el
 
-David Pathakjee: changed minibuf.c
+David Pathakjee: changed emacs-lisp/debug.el minibuf.c
 
 David Ponce: wrote bovine/grammar.el cedet.el comp.el java-tags.el
   mode-local.el recentf.el ruler-mode.el semantic/grammar.el
@@ -1208,7 +1214,8 @@ Derek Upham: changed nxml-mode.el
 Detlev Zundel: wrote re-builder.el
 and changed buffer.c
 
-Devon Sean McCullough: changed url-http.el comint.el ns-win.el
+Devon Sean McCullough: changed url-http.el buff-menu.el comint.el
+  ns-win.el
 
 Dhruva Krishnamurthy: changed emacsclient.c fontset.c sound.c w32proc.c
 
@@ -1293,7 +1300,7 @@ and co-wrote color.el
 and changed cus-edit.el dired.el faces.el files.el help-mode.el imenu.el
   info.el isearch.el ls-lisp.el menu-bar.el modes.texi mouse.el
   ange-ftp.el apropos.el bindings.el bookmark.el custom.el descr-text.el
-  dired.texi etags.el finder.el and 14 other files
+  dired.texi etags.el finder.el and 15 other files
 
 E. Choroba: changed simple.el
 
@@ -1347,8 +1354,8 @@ Eli Zaretskii: wrote [bidirectional display in xdisp.c]
   tty-colors.el
 and changed xdisp.c msdos.c w32.c display.texi w32fns.c simple.el
   files.el fileio.c keyboard.c w32proc.c files.texi w32term.c text.texi
-  dispnew.c emacs.c frames.texi dispextern.h lisp.h process.c term.c
-  window.c and 1121 other files
+  dispnew.c emacs.c frames.texi dispextern.h lisp.h window.c process.c
+  term.c and 1125 other files
 
 Emanuele Giaquinta: changed configure.ac rxvt.el charset.c etags.c
   fontset.c frame.el gnus-faq.texi loadup.el lread.c sh-script.el
@@ -1373,7 +1380,7 @@ Eric Abrahamsen: changed eieio-base.el registry.el 
nnimap.el
   gnus-registry.el files.el files.texi windows.texi eieio-test-persist.el
   eieio.el gnus-start.el gnus-sum.el gnus.texi nnir.el buffers.texi
   checkdoc.el files-tests.el gnus-bcklg.el gnus-group.el nnmairix.el
-  org.el org.texi and 3 other files
+  org.el org.texi and 4 other files
 
 Eric Bélanger: changed image.c
 
@@ -1675,9 +1682,9 @@ Geert Kloosterman: changed which-func.el
 Gemini Lasswell: wrote edebug-tests.el kmacro-tests.el testcover-tests.el
 and changed edebug.el cl-macs.el cl-generic.el ert-x.el cl-print.el
   edebug-test-code.el edebug.texi eieio-compat.el generator.el subr.el
-  autorevert-tests.el cl-print-tests.el emacs-lisp/debug.el eval-tests.el
-  eval.c filenotify-tests.el generator-tests.el kmacro.el lread.c
-  map-tests.el map.el and 9 other files
+  autorevert-tests.el cl-print-tests.el eieio.texi emacs-lisp/debug.el
+  eval-tests.el eval.c filenotify-tests.el generator-tests.el kmacro.el
+  lread.c map-tests.el and 10 other files
 
 Geoff Gole: changed align.el ibuffer.el whitespace.el
 
@@ -1734,7 +1741,7 @@ and changed configure.ac Makefile.in src/Makefile.in 
calendar.el
   diary-lib.el lisp/Makefile.in files.el rmail.el make-dist
   progmodes/f90.el bytecomp.el simple.el authors.el admin.el emacs.texi
   misc/Makefile.in startup.el lib-src/Makefile.in ack.texi display.texi
-  cal-menu.el and 1680 other files
+  cal-menu.el and 1681 other files
 
 Glynn Clements: wrote gamegrid.el snake.el tetris.el
 
@@ -1780,7 +1787,7 @@ Grégory Mounié: changed man.el
 
 Gregory Neil Shapiro: changed mailabbrev.el
 
-Gregor Zattler: changed emacs-lisp-intro.texi
+Gregor Zattler: changed eshell.texi emacs-lisp-intro.texi
 
 Greg Stark: changed gnus-ems.el timezone.el
 
@@ -2139,6 +2146,7 @@ and changed idlw-rinfo.el idlw-toolbar.el comint.el 
idlwave.texi vc.el
   mouse.el
 
 Jean-Christophe Helary: changed ns-win.el strings.texi subr-x.el
+  ucs-normalize.el
 
 Jean Haidouk: changed latin-alt.el latin-post.el latin-pre.el
 
@@ -2636,8 +2644,8 @@ Katsuhiro Hermit Endo: changed gnus-group.el gnus-spec.el
 
 Katsumi Yamaoka: wrote canlock.el
 and changed gnus-art.el message.el gnus-sum.el mm-decode.el gnus.texi
-  mm-util.el mm-view.el gnus-util.el gnus-group.el gnus-msg.el shr.el
-  mml.el rfc2047.el gnus-start.el gnus.el nntp.el gnus-agent.el nnrss.el
+  mm-util.el mm-view.el gnus-util.el gnus-group.el gnus-msg.el mml.el
+  shr.el rfc2047.el gnus-start.el gnus.el nntp.el gnus-agent.el nnrss.el
   mm-uu.el nnmail.el emacs-mime.texi and 160 other files
 
 Kaushal Modi: changed files.el isearch.el apropos.el calc-yank.el
@@ -2915,7 +2923,7 @@ and changed octave.el ido.el rcirc.el files.el subr.el 
lisp-mode.el
   eldoc.el simple.el flymake.el smie.el abbrev.el progmodes/python.el
   cfengine.el cl-extra.el cl-macs.el emacs-lisp/cl-lib.el fns.c
   progmodes/compile.el register.el rng-valid.el thingatpt.el
-  and 165 other files
+  and 166 other files
 
 Leonard H. Tower Jr.: changed rnews.el rnewspost.el emacsbug.el
   rmailout.el sendmail.el
@@ -3159,7 +3167,7 @@ Martin Pohlack: changed iimage.el pc-select.el
 Martin Rudalics: changed window.el window.c windows.texi frame.c
   frames.texi w32fns.c xdisp.c xterm.c w32term.c frame.el xfns.c help.el
   buffer.c display.texi cus-start.el dispnew.c frame.h mouse.el nsfns.m
-  window.h gtkutil.c and 201 other files
+  window.h gtkutil.c and 203 other files
 
 Martin Stjernholm: wrote cc-bytecomp.el
 and co-wrote cc-align.el cc-cmds.el cc-compat.el cc-defs.el cc-engine.el
@@ -3250,6 +3258,8 @@ Matt Hodges: changed textmodes/table.el faces.el 
iswitchb.el simple.el
   edebug.texi eldoc.el em-hist.el em-pred.el fixit.texi icon.el ido.el
   locate.el paragraphs.el pcomplete.el repeat.el and 3 other files
 
+Mattias Engdegård: changed subr.el
+
 Matt Lundin: changed org-agenda.el org.el org-bibtex.el org-footnote.el
   ox-publish.el org-bbdb.el org-datetree.el org-gnus.el
 
@@ -3262,7 +3272,7 @@ Matt Simmons: changed message.el
 Matt Swift: changed dired.el editfns.c lisp-mode.el mm-decode.el
   outline.el progmodes/compile.el rx.el simple.el startup.el
 
-Mauro Aranda: changed files.texi os.texi
+Mauro Aranda: changed autorevert.el files.texi os.texi
 
 Maxime Edouard Robert Froumentin: changed gnus-art.el mml.el
 
@@ -3282,7 +3292,7 @@ and changed tramp.texi tramp-adb.el trampver.el 
trampver.texi dbusbind.c
   file-notify-tests.el ange-ftp.el files.el dbus.texi files.texi
   autorevert.el tramp-fish.el kqueue.c tramp-gw.el tramp-imap.el os.texi
   configure.ac lisp.h gfilenotify.c inotify.c keyboard.c
-  and 221 other files
+  and 224 other files
 
 Michael Ben-Gershon: changed acorn.h configure.ac riscix1-1.h riscix1-2.h
   unexec.c
@@ -3546,6 +3556,8 @@ Niall Mansfield: changed etags.c
 
 Nic Ferrier: changed ert.el tramp.el
 
+Nicholas Drozd: changed calc.texi
+
 Nicholas Maniscalco: changed term.el
 
 Nick Alcock: changed control.texi customize.texi display.texi files.el
@@ -3555,6 +3567,8 @@ Nick Alcock: changed control.texi customize.texi 
display.texi files.el
 Nick Dokos: changed org-table.el ox.el icalendar.el mh-search.el
   org-mobile.el org.el ox-ascii.el url-cache.el
 
+Nick Drozd: changed eww.el eww.texi
+
 Nick Helm: changed eldoc.el help.el help.texi whitespace-tests.el
   whitespace.el
 
@@ -3586,7 +3600,7 @@ Nicolas Graner: changed message.el
 Nicolas Petton: wrote map-tests.el map.el seq-tests.el seq.el
   thunk-tests.el thunk.el
 and co-wrote auth-source-pass.el auth-source-tests.el subr-tests.el
-and changed README sequences.texi configure.ac sed2v2.inp authors.el
+and changed README configure.ac sed2v2.inp sequences.texi authors.el
   README.W32 emacs.png emacs23.png arc-mode.el cl-extra.el emacs.svg
   manoj-dark-theme.el Emacs.icns HISTORY Makefile.in auth-source.el
   emacs.ico fns.c make-tarball.txt obarray-tests.el obarray.el
@@ -3637,7 +3651,7 @@ Noam Postavsky: changed lisp-mode.el progmodes/python.el 
xdisp.c
   cl-macs.el lisp-mode-tests.el emacs-lisp/debug.el data.c simple.el
   term.el ert.el subr.el help-fns.el bytecomp.el cl-print.el
   elisp-mode.el eval.c ffap.el modes.texi search.c sh-script.el
-  cl-preloaded.el and 248 other files
+  cl-preloaded.el and 249 other files
 
 Nobuyoshi Nakada: co-wrote ruby-mode.el
 
@@ -3739,9 +3753,9 @@ and changed imenu.el make-mode.el
 Paul Eggert: wrote rcs2log
 and co-wrote cal-dst.el
 and changed lisp.h configure.ac alloc.c process.c fileio.c editfns.c
-  xdisp.c sysdep.c image.c keyboard.c emacs.c xterm.c data.c lread.c
+  xdisp.c sysdep.c keyboard.c image.c emacs.c xterm.c data.c lread.c
   fns.c callproc.c Makefile.in gnulib.mk eval.c buffer.c frame.c
-  and 1598 other files
+  and 1608 other files
 
 Paul Fisher: changed fns.c
 
@@ -3900,6 +3914,8 @@ and changed package.el pcmpl-unix.el subr.el
 
 Philip Jackson: wrote find-cmd.el org-irc.el
 
+Philip K: changed ispell.el
+
 Philippe Schnoebelen: wrote gomoku.el mpuz.el
 
 Philippe Vaucher: changed callint.c composite.el debugging.texi
@@ -3976,7 +3992,7 @@ Rafael Sepúlveda: changed TUTORIAL.es
 
 Raffael Mancini: changed misc.el
 
-Raimon Grau: changed thingatpt.el
+Raimon Grau: changed replace.el thingatpt.el
 
 Rainer Orth: changed gtkutil.c lisp/Makefile.in
 
@@ -4115,7 +4131,7 @@ Rick Frankel: changed ox-html.el ob-sql.el org.texi
 Rick Sladkey: wrote backquote.el
 and changed gud.el intervals.c intervals.h simple.el
 
-Rob Browning: changed tls.el configure.ac
+Rob Browning: changed tls.el configure.ac ibuffer-tests.el tramp-tests.el
 
 Rob Christie: changed nsmenu.m
 
@@ -4144,10 +4160,10 @@ Roberto Rodríguez: changed ada-mode.texi glossary.texi 
widget.texi
 
 Robert P. Goldman: changed org.texi ob-exp.el org.el ox-latex.el
 
-Robert Pluim: changed configure.ac files.texi gtkutil.c dired-x.texi
-  misc.texi vc-git.el xfns.c xterm.c bindings.el desktop.el efaq.texi
-  epa.texi filelock.c font.c ftfont.c gnus-agent.el gnus-demon.el
-  gnus.texi ido.el image-mode.el mail-source.el and 15 other files
+Robert Pluim: changed gtkutil.c configure.ac files.texi dired-x.texi
+  ftfont.c misc.texi process.c vc-git.el xfns.c xterm.c bindings.el
+  desktop.el efaq.texi epa.texi filelock.c font.c ftcrfont.c
+  gnus-agent.el gnus-demon.el gnus.texi gtkutil.h and 19 other files
 
 Robert Thorpe: changed cus-start.el indent.el
 
@@ -4529,8 +4545,8 @@ and co-wrote todo-mode.el
 and changed todo-mode.texi diary-lib.el dired-tests.el doc-view.el
   files.el minibuffer.el wdired-tests.el dired.el frames.texi hl-line.el
   info.el menu-bar.el mouse.el otodo-mode.el subr.el .gitattributes
-  allout.el artist.el compile.texi cus-start.el descr-text.el
-  and 41 other files
+  TUTORIAL allout.el artist.el compile.texi cus-start.el
+  and 43 other files
 
 Stephen C. Gilardi: changed configure.ac
 
@@ -4551,8 +4567,8 @@ and changed time-stamp.el mh-e.el mh-comp.el mh-utils.el 
mh-customize.el
 Stephen J. Turnbull: changed ediff-init.el strings.texi subr.el
 
 Stephen Leake: wrote elisp-mode-tests.el
-and changed ada-mode.el ada-xref.el elisp-mode.el mode-local.el xref.el
-  CONTRIBUTE vc-mtn.el window.el ada-mode.texi ada-prj.el cedet-global.el
+and changed ada-mode.el ada-xref.el elisp-mode.el mode-local.el window.el
+  xref.el CONTRIBUTE vc-mtn.el ada-mode.texi ada-prj.el cedet-global.el
   ede/generic.el ada-stmt.el cl-generic.el ede/locate.el files.texi
   project.el windows.texi INSTALL.REPO INSTALL.W64 align.el
   and 21 other files
@@ -4832,6 +4848,8 @@ and changed ibuffer.el dired-tests.el ibuf-ext.el 
dired.el dired-aux.el
 
 Titus von der Malsburg: changed simple.el window.el
 
+Tobias Bading: changed progmodes/compile.el
+
 Tobias C. Rittweiler: changed font-lock.el searching.texi sendmail.el
 
 Tobias Ringström: changed etags.c
@@ -4914,6 +4932,8 @@ Trent W. Buck: changed rcirc.el remember.el rx.el
 
 Trevor Murphy: changed gnus.texi nnimap.el org.el
 
+Trevor Spiteri: changed progmodes/grep.el
+
 Trey Jackson: changed spam-stat.el
 
 Triet Hoai Lai: changed vntelex.el viet-util.el vietnamese.el
@@ -4956,9 +4976,9 @@ and changed org-gnus.el smime.el
 Ulrich Leodolter: changed w32proc.c
 
 Ulrich Müller: changed configure.ac lib-src/Makefile.in src/Makefile.in
-  version.el doctor.el emacs.1 files.el gamegrid.el gud.el server.el
-  ChgPane.c ChgSel.c HELLO INSTALL Makefile.in XMakeAssoc.c authors.el
-  bytecomp.el calc-units.el case-table.el configure and 39 other files
+  version.el calc-units.el doctor.el emacs.1 files.el gamegrid.el gud.el
+  server.el ChgPane.c ChgSel.c HELLO INSTALL Makefile.in XMakeAssoc.c
+  authors.el bytecomp.el case-table.el configure and 39 other files
 
 Ulrich Neumerkel: changed xterm.c
 
@@ -4997,6 +5017,8 @@ Vibhav Pant: changed bytecomp.el byte-opt.el bytecode.c 
bytecomp-tests.el
   emacs-module.c erc-backend.el erc.el eshell.texi fns.c hangul.el
   image.c lisp.h lread.c print.c profiler.c xterm.c
 
+Victor J. Orlikowski: changed erc-dcc.el
+
 Victor Zandy: wrote zone.el
 
 Viktor Rosenfeld: changed ob-sql.el org.el
diff --git a/etc/CALC-NEWS b/etc/CALC-NEWS
index 04baf41..d00f136 100644
--- a/etc/CALC-NEWS
+++ b/etc/CALC-NEWS
@@ -1,4 +1,4 @@
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 Calc is an advanced desk calculator for GNU Emacs.
@@ -10,18 +10,9 @@ Originally written by:
        San Jose CA 95134
        address@hidden, uunet!synaptx!daveg
 
-Currently maintained by:
+Calc was maintained for many years by:
      Jay Belanger <address@hidden>
 
-I am anxious to hear about your experiences using Calc.  Send mail to
-"address@hidden".  A bug report is most useful if you include the
-exact input and output that occurred, any modes in effect (such as the
-current precision), and so on.  If you find Calc is difficult to operate
-in any way, or if you have other suggestions, don't hesitate to let me
-know.  If you find errors (including simple typos) in the manual, let me
-know.  Even if you find no bugs at all I would love to hear your opinions.
-
-
 Summary of changes to "Calc"
 ------- -- ------- --  ----
 
diff --git a/etc/CENSORSHIP b/etc/CENSORSHIP
deleted file mode 100644
index cd779e4..0000000
--- a/etc/CENSORSHIP
+++ /dev/null
@@ -1,8 +0,0 @@
-Censoring my Software
-
-Note added March 2014:
-
-This file is obsolete and will be removed in future.
-Please update any references to use
-
-<https://www.gnu.org/philosophy/censoring-emacs.html>
diff --git a/etc/ChangeLog.1 b/etc/ChangeLog.1
index 09a2824..24b8b39 100644
--- a/etc/ChangeLog.1
+++ b/etc/ChangeLog.1
@@ -6891,7 +6891,7 @@
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 1993-1999, 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 1993-1999, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/etc/DEBUG b/etc/DEBUG
index 1a9068b..836e820 100644
--- a/etc/DEBUG
+++ b/etc/DEBUG
@@ -1,6 +1,6 @@
 Debugging GNU Emacs
 
-Copyright (C) 1985, 2000-2018 Free Software Foundation, Inc.
+Copyright (C) 1985, 2000-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 ** Preliminaries
@@ -12,24 +12,21 @@ debugging techniques.
 *** Configuring Emacs for debugging
 
 It is best to configure and build Emacs with special options that will
-make the debugging easier.  Here's the configure-time options we
+make the debugging easier.  Here are the configure-time options we
 recommend (they are in addition to any other options you might need,
 such as --prefix):
 
   ./configure --enable-checking='yes,glyphs' --enable-check-lisp-object-type \
     CFLAGS='-O0 -g3'
 
-The CFLAGS value is important: debugging optimized code can be very
-hard.  (If the problem only happens with optimized code, you may need
-to enable optimizations.  If that happens, try using -Og first,
-instead of -O2, as the former will disable some optimizations that
-make debugging some code exceptionally hard.)
+The -O0 flag is important, as debugging optimized code can be hard.
+If the problem happens only with optimized code, you may need to
+enable optimizations.  If that happens, try using -Og first instead of
+-O2, as -Og disables some optimizations that make debugging some code
+exceptionally hard.
 
-Modern versions of GCC support more elaborate debug info that is
-available by just using the -g3 compiler switch.  Try using -gdwarf-4
-in addition to -g3, and if that fails, try -gdwarf-3.  This is
-especially important if you have to debug optimized code.  More info
-about this is available below; search for "analyze failed assertions".
+Older versions of GCC may need more than just the -g3 flag.  For more,
+search for "analyze failed assertions" below.
 
 The 2 --enable-* switches are optional.  They don't have any effect on
 debugging with GDB, but will compile additional code that might catch
@@ -184,20 +181,15 @@ Good luck!
 
 ** When you are trying to analyze failed assertions or backtraces, it
 is essential to compile Emacs with flags suitable for debugging.
-With GCC 4.8 or later, you can invoke 'make' with CFLAGS="-Og -g3".
-With older GCC or non-GCC compilers, you can use CFLAGS="-O0 -g3".
+Although CFLAGS="-O0 -g3" often suffices with modern compilers,
+you may benefit further by using CFLAGS="-O0 -g3 -gdwarf-4", replacing
+"4" by the highest version of DWARF that your compiler supports;
+this is especially important for GCC versions older than 4.8.
 With GCC and higher optimization levels such as -O2, the
 -fno-omit-frame-pointer and -fno-crossjumping options are often
 essential.  The latter prevents GCC from using the same abort call for
 all assertions in a given function, rendering the stack backtrace
 useless for identifying the specific failed assertion.
-Some versions of GCC support recent versions of the DWARF standard for
-debugging info, but default to older versions; for example, they could
-support -gdwarf-4 compiler option (for DWARF v4), but default to
-version 2 of the DWARF standard.  For best results in debugging
-abilities, find out the highest version of DWARF your GCC can support,
-and use the corresponding -gdwarf-N switch instead of just -g (you
-will still need -g3, as in "-gdwarf-4 -g3").
 
 ** It is a good idea to run Emacs under GDB (or some other suitable
 debugger) *all the time*.  Then, when Emacs crashes, you will be able
@@ -923,41 +915,97 @@ setting the new-console option before running Emacs under 
GDB:
   (gdb) set new-console 1
   (gdb) run
 
-** Running Emacs built with malloc debugging packages
+** Running Emacs with undefined-behavior sanitization
 
-If Emacs exhibits bugs that seem to be related to use of memory
-allocated off the heap, it might be useful to link Emacs with a
-special debugging library, such as Electric Fence (a.k.a. efence) or
-GNU Checker, which helps find such problems.
+Building Emacs with undefined-behavior sanitization can help find
+several kinds of low-level problems in C code, including:
 
-Emacs compiled with such packages might not run without some hacking,
-because Emacs replaces the system's memory allocation functions with
-its own versions, and because the dumping process might be
-incompatible with the way these packages use to track allocated
-memory.  Here are some of the changes you might find necessary:
+  * Out-of-bounds access of many (but not all) arrays.
+  * Signed integer overflow, e.g., (INT_MAX + 1).
+  * Integer shifts by a negative or wider-than-word value.
+  * Misaligned pointers and pointer overflow.
+  * Loading a bool or enum value that is out of range for its type.
+  * Passing NULL to or returning NULL from a function requiring nonnull.
+  * Passing a size larger than the corresponding array to memcmp etc.
+  * Passing invalid values to some builtin functions, e.g., __builtin_clz (0).
+  * Reaching __builtin_unreachable calls (in Emacs, 'eassume' failure).
 
-  - Edit configure, to set system_malloc and CANNOT_DUMP to "yes".
+To use UndefinedBehaviorSanitizer with GCC and similar compilers,
+append '-fsanitize=undefined' to CFLAGS, either when running
+'configure' or running 'make'.  When supported, you can also specify
+'bound-strict' and 'float-cast-overflow'.  For example:
 
-  - Configure with a different --prefix= option.  If you use GCC,
-    version 2.7.2 is preferred, as some malloc debugging packages
-    work a lot better with it than with 2.95 or later versions.
+  ./configure \
+    CFLAGS='-O0 -g3 -fsanitize=undefined,bounds-strict,float-cast-overflow'
 
-  - Type "make" then "make -k install".
+You may need to append '-static-libubsan' to CFLAGS if your version of
+GCC is installed in an unusual location.
 
-  - If required, invoke the package-specific command to prepare
-    src/temacs for execution.
+When using GDB to debug an executable with undefined-behavior
+sanitization, the GDB command:
 
-  - cd ..; src/temacs
+  (gdb) rbreak ^__ubsan_handle_
 
-(Note that this runs 'temacs' instead of the usual 'emacs' executable.
-This avoids problems with dumping Emacs mentioned above.)
+will let you gain control when an error is detected and before
+UndefinedBehaviorSanitizer outputs to stderr or terminates the
+program.
 
-Some malloc debugging libraries might print lots of false alarms for
-bitfields used by Emacs in some data structures.  If you want to get
-rid of the false alarms, you will have to hack the definitions of
-these data structures on the respective headers to remove the ':N'
-bitfield definitions (which will cause each such field to use a full
-int).
+** Running Emacs with address sanitization
+
+Building Emacs with address sanitization can help debug memory-use
+problems, such as freeing the same object twice.  To use
+AddressSanitizer with GCC and similar compilers, append
+'-fsanitize=address' to CFLAGS, either when running 'configure' or
+running 'make'.  Configure, build and run Emacs with
+ASAN_OPTIONS='detect_leaks=0' in the environment to suppress
+diagnostics of minor memory leaks in Emacs.  For example:
+
+  export ASAN_OPTIONS='detect_leaks=0'
+  ./configure CFLAGS='-O0 -g3 -fsanitize=address'
+  make
+  src/emacs
+
+You may need to append '-static-libasan' to CFLAGS if your version of
+GCC is installed in an unusual location.
+
+When using GDB to debug an executable with address sanitization, the
+GDB command:
+
+  (gdb) rbreak ^__asan_report_
+
+will let you gain control when an error is detected and before
+AddressSanitizer outputs to stderr or terminates the program.
+
+Address sanitization is incompatible with undefined-behavior
+sanitization, unfortunately.  Address sanitization is also
+incompatible with the --with-dumping=unexec option of 'configure'.
+
+** Running Emacs under Valgrind
+
+Valgrind <http://valgrind.org/> is free software that can be useful
+when debugging low-level Emacs problems.  Unlike GCC sanitizers,
+Valgrind does not need you to compile Emacs with special debugging
+flags, so it can be helpful in investigating problems that vanish when
+Emacs is recompiled with debugging enabled.  However, by default
+Valgrind generates many false alarms with Emacs, and you will need to
+maintain a suppressions file to suppress these false alarms and use
+Valgrind effectively.  For example, you might invoke Valgrind this
+way:
+
+   valgrind --suppressions=valgrind.supp ./emacs
+
+where valgrind.supp contains groups of lines like the following, which
+suppresses some Valgrind false alarms during Emacs garbage collection:
+
+   {
+     Fgarbage_collect Cond - conservative garbage collection
+     Memcheck:Cond
+     ...
+     fun:Fgarbage_collect
+   }
+
+Unfortunately Valgrind suppression files tend to be system-dependent,
+so you will need to keep one around that matches your system.
 
 ** How to recover buffer contents from an Emacs core dump file
 
diff --git a/etc/DISTRIB b/etc/DISTRIB
index 854b1c8..4b8e4de 100644
--- a/etc/DISTRIB
+++ b/etc/DISTRIB
@@ -1,7 +1,7 @@
                                                -*- text -*-
             GNU Emacs availability information
 
-Copyright (C) 1986-1993, 1995, 1998, 2000-2018 Free Software Foundation,
+Copyright (C) 1986-1993, 1995, 1998, 2000-2019 Free Software Foundation,
 Inc.
 See the end of the file for license conditions.
 
diff --git a/etc/ERC-NEWS b/etc/ERC-NEWS
index 864efa4..5331b9c 100644
--- a/etc/ERC-NEWS
+++ b/etc/ERC-NEWS
@@ -1,6 +1,6 @@
 ERC NEWS                                                       -*- outline -*-
 
-Copyright (C) 2006-2018 Free Software Foundation, Inc.
+Copyright (C) 2006-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 * For changes after ERC 5.3, see the main Emacs NEWS file
diff --git a/etc/ETAGS.EBNF b/etc/ETAGS.EBNF
index 23bb944..db96709 100644
--- a/etc/ETAGS.EBNF
+++ b/etc/ETAGS.EBNF
@@ -94,7 +94,7 @@ those.
 
 ===================== end of discussion of tag names =====================
 
-Copyright (C) 2002-2018 Free Software Foundation, Inc.
+Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 COPYING PERMISSIONS:
 
diff --git a/etc/ETAGS.README b/etc/ETAGS.README
index 0be4d44..82d4314 100644
--- a/etc/ETAGS.README
+++ b/etc/ETAGS.README
@@ -28,7 +28,7 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
LIABILITY, OR TORT
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
-Copyright (C) 1984, 1987-1989, 1993-1995, 1998-2018 Free Software
+Copyright (C) 1984, 1987-1989, 1993-1995, 1998-2019 Free Software
 Foundation, Inc.
 
 This file is not considered part of GNU Emacs.
diff --git a/etc/FTP b/etc/FTP
deleted file mode 100644
index ebd2695..0000000
--- a/etc/FTP
+++ /dev/null
@@ -1,9 +0,0 @@
-For information about how to download GNU Emacs, please see:
-<https://www.gnu.org/software/emacs/>
-
-For general GNU software downloading, please see
-<https://www.gnu.org/order/ftp.html>
-
-Note added January 2014:
-This file is obsolete and will be removed in future.
-Please update any links to use the above URLs.
diff --git a/etc/GNU b/etc/GNU
deleted file mode 100644
index f8078d4..0000000
--- a/etc/GNU
+++ /dev/null
@@ -1,8 +0,0 @@
-The GNU Manifesto
-
-Note added March 2014:
-
-This file is obsolete and will be removed in future.
-Please update any references to use
-  info node `(emacs)Manifesto'
-instead.
diff --git a/etc/GNUS-NEWS b/etc/GNUS-NEWS
deleted file mode 100644
index 2ca5a9d..0000000
--- a/etc/GNUS-NEWS
+++ /dev/null
@@ -1,316 +0,0 @@
-GNUS NEWS -- history of user-visible changes.
-
-Copyright (C) 1999-2018 Free Software Foundation, Inc.
-See the end of the file for license conditions.
-
-Please send Gnus bug reports to address@hidden
-For older news, see Gnus info node "New Features".
-
-
-* Supported Emacs versions The following Emacs versions are supported by No
-Gnus:
-
-** Emacs 22 and up
-** XEmacs 21.4
-** XEmacs 21.5
-** SXEmacs
-
-
-* Installation changes
-
-** Upgrading from previous (stable) version if you have used No Gnus.
-
-If you have tried No Gnus (the unstable Gnus branch leading to this
-release) but went back to a stable version, be careful when upgrading to
-this version.  In particular, you will probably want to remove the
-'~/News/marks' directory (perhaps selectively), so that flags are read
-from your '~/.newsrc.eld' instead of from the stale marks file, where
-this release will store flags for nntp.  See a later entry for more
-information about nntp marks.  Note that downgrading isn't safe in
-general.
-
-** Incompatibility when switching from Emacs 23 to Emacs 22 In Emacs 23,
-Gnus uses Emacs's new internal coding system 'utf-8-emacs' for saving
-articles drafts and '~/.newsrc.eld'.  These files may not be read
-correctly in Emacs 22 and below.  If you want to use Gnus across
-different Emacs versions, you may set 'mm-auto-save-coding-system' to
-'emacs-mule'.
-
-** Lisp files are now installed in '.../site-lisp/gnus/' by default.  It
-defaulted to '.../site-lisp/' formerly.  In addition to this, the new
-installer issues a warning if other Gnus installations which will shadow
-the latest one are detected.  You can then remove those shadows manually
-or remove them using 'make remove-installed-shadows'.
-
-** The installation directory name is allowed to have spaces and/or tabs.
-
-
-* New packages and libraries within Gnus
-
-** New version of 'nnimap'
-
-'nnimap' has been reimplemented in a mostly-compatible way.  See the Gnus
-manual for a description of the new interface.  In particular,
-'nnimap-inbox' and the client side split method has changed.
-
-** Gnus includes the Emacs Lisp SASL library.
-
-This provides a clean API to SASL mechanisms from within Emacs.  The user
-visible aspects of this, compared to the earlier situation, include
-support for DIGEST-MD5 and NTLM.  *Note Emacs SASL: (sasl)Top.
-
-** ManageSieve connections uses the SASL library by default.
-
-The primary change this brings is support for DIGEST-MD5 and NTLM, when
-the server supports it.
-
-** Gnus includes a password cache mechanism in password.el.
-
-It is enabled by default (see 'password-cache'), with a short timeout of
-16 seconds (see 'password-cache-expiry').  If PGG is used as the PGP back
-end, the PGP passphrase is managed by this mechanism.  Passwords for
-ManageSieve connections are managed by this mechanism, after querying the
-user about whether to do so.
-
-** Using EasyPG with Gnus When EasyPG, is available, Gnus will use it
-instead of PGG.  EasyPG is an Emacs user interface to GNU Privacy Guard.
- *Note EasyPG Assistant user's manual: (epa)Top.  EasyPG is included in
-Emacs 23 and available separately as well.
-
-
-* Changes in group mode
-
-** Symbols like 'gcc-self' now have the same precedence rules in
-'gnus-parameters' as other "real" variables: The last match wins instead
-of the first match.
-
-** Old intermediate incoming mail files ('Incoming*') are deleted after a
-couple of days, not immediately.  *Note Mail Source Customization::.
-(New in Gnus 5.10.10 / No Gnus 0.8)
-
-
-* Changes in summary and article mode
-
-** There's now only one variable that determines how HTML is rendered:
-'mm-text-html-renderer'.
-
-** Gnus now supports sticky article buffers.  Those are article buffers that
-are not reused when you select another article.  *Note Sticky Articles::.
-
-** Gnus can selectively display 'text/html' articles with a WWW browser with
-'K H'.  *Note MIME Commands::.
-
-** International host names (IDNA) can now be decoded inside article bodies
-using 'W i' ('gnus-summary-idna-message').  This requires that GNU Libidn
-(<https://www.gnu.org/software/libidn/>) has been installed.
-
-** The non-ASCII group names handling has been much improved.  The back ends
-that fully support non-ASCII group names are now 'nntp', 'nnml', and
-'nnrss'.  Also the agent, the cache, and the marks features work with
-those back ends.  *Note Non-ASCII Group Names::.
-
-** Gnus now displays DNS master files sent as text/dns using dns-mode.
-
-** Gnus supports new limiting commands in the Summary buffer: '/ r'
-('gnus-summary-limit-to-replied') and '/ R'
-('gnus-summary-limit-to-recipient').  *Note Limiting::.
-
-** You can now fetch all ticked articles from the server using 'Y t'
-('gnus-summary-insert-ticked-articles').  *Note Summary Generation
-Commands::.
-
-** Gnus supports a new sort command in the Summary buffer: 'C-c C-s C-t'
-('gnus-summary-sort-by-recipient').  *Note Summary Sorting::.
-
-** S/MIME now features LDAP user certificate searches.  You need to
-configure the server in 'smime-ldap-host-list'.
-
-** URLs inside OpenPGP headers are retrieved and imported to your PGP key
-ring when you click on them.
-
-** Picons can be displayed right from the textual address, see
-'gnus-picon-style'.  *Note Picons::.
-
-** ANSI SGR control sequences can be transformed using 'W A'.
-
-ANSI sequences are used in some Chinese hierarchies for highlighting
-articles ('gnus-article-treat-ansi-sequences').
-
-** Gnus now MIME decodes articles even when they lack "MIME-Version" header.
-This changes the default of 'gnus-article-loose-mime'.
-
-** 'gnus-decay-scores' can be a regexp matching score files.  For example,
-set it to '\\.ADAPT\\'' and only adaptive score files will be decayed.
- *Note Score Decays::.
-
-** Strings prefixing to the 'To' and 'Newsgroup' headers in summary lines
-when using 'gnus-ignored-from-addresses' can be customized with
-'gnus-summary-to-prefix' and 'gnus-summary-newsgroup-prefix'.  *Note To
-From Newsgroups::.
-
-** You can replace MIME parts with external bodies.  See
-'gnus-mime-replace-part' and 'gnus-article-replace-part'.  *Note MIME
-Commands::, *note Using MIME::.
-
-** The option 'mm-fill-flowed' can be used to disable treatment of
-format=flowed messages.  Also, flowed text is disabled when sending
-inline PGP signed messages.  *Note Flowed text: (emacs-mime)Flowed text.
-(New in Gnus 5.10.7)
-
-** Now the new command 'S W' ('gnus-article-wide-reply-with-original') for a
-wide reply in the article buffer yanks a text that is in the active
-region, if it is set, as well as the 'R'
-('gnus-article-reply-with-original') command.  Note that the 'R' command
-in the article buffer no longer accepts a prefix argument, which was used
-to make it do a wide reply.  *Note Article Keymap::.
-
-** The new command 'C-h b' ('gnus-article-describe-bindings') used in the
-article buffer now shows not only the article commands but also the real
-summary commands that are accessible from the article buffer.
-
-
-* Changes in Message mode
-
-** Gnus now defaults to saving all outgoing messages in per-month nnfolder
-archives.
-
-** Gnus now supports the "hashcash" client puzzle anti-spam mechanism.  Use
-'(setq message-generate-hashcash t)' to enable.  *Note Hashcash::.
-
-** You can now drag and drop attachments to the Message buffer.  See
-'mml-dnd-protocol-alist' and 'mml-dnd-attach-options'.  *Note MIME:
-(message)MIME.
-
-** The option 'message-yank-empty-prefix' now controls how empty lines are
-prefixed in cited text.  *Note Insertion Variables: (message)Insertion
-Variables.
-
-** Gnus uses narrowing to hide headers in Message buffers.  The 'References'
-header is hidden by default.  To make all headers visible, use '(setq
-message-hidden-headers nil)'.  *Note Message Headers: (message)Message
-Headers.
-
-** You can highlight different levels of citations like in the article
-buffer.  See 'gnus-message-highlight-citation'.
-
-** 'auto-fill-mode' is enabled by default in Message mode.  See
-'message-fill-column'.  *Note Message Headers: (message)Various Message
-Variables.
-
-** You can now store signature files in a special directory named
-'message-signature-directory'.
-
-** The option 'message-citation-line-format' controls the format of the
-"Whomever writes:" line.  You need to set
-'message-citation-line-function' to
-'message-insert-formatted-citation-line' as well.
-
-
-* Changes in Browse Server mode
-
-** Gnus' sophisticated subscription methods are now available in Browse
-Server buffers as well using the variable
-'gnus-browse-subscribe-newsgroup-method'.
-
-
-* Changes in back ends
-
-** The nntp back end stores article marks in '~/News/marks'.
-
-The directory can be changed using the (customizable) variable
-'nntp-marks-directory', and marks can be disabled using the (back end)
-variable 'nntp-marks-is-evil'.  The advantage of this is that you can
-copy '~/News/marks' (using rsync, scp or whatever) to another Gnus
-installation, and it will realize what articles you have read and marked.
-The data in '~/News/marks' has priority over the same data in
-'~/.newsrc.eld'.
-
-** You can import and export your RSS subscriptions from OPML files.  *Note
-RSS::.
-
-** IMAP identity (RFC 2971) is supported.
-
-By default, Gnus does not send any information about itself, but you can
-customize it using the variable 'nnimap-id'.
-
-** The 'nnrss' back end now supports multilingual text.  Non-ASCII group
-names for the 'nnrss' groups are also supported.  *Note RSS::.
-
-** Retrieving mail with POP3 is supported over SSL/TLS and with StartTLS.
-
-** The nnml back end allows other compression programs beside 'gzip' for
-compressed message files.  *Note Mail Spool::.
-
-** The nnml back end supports group compaction.
-
-This feature, accessible via the functions 'gnus-group-compact-group' ('G
-z' in the group buffer) and 'gnus-server-compact-server' ('z' in the
-server buffer) renumbers all articles in a group, starting from 1 and
-removing gaps.  As a consequence, you get a correct total article count
-(until messages are deleted again).
-
-
-* Appearance
-
-** The tool bar has been updated to use GNOME icons.  You can also customize
-the tool bars: 'M-x customize-apropos RET -tool-bar$' should get you
-started.  (Only for Emacs, not in XEmacs.)
-
-** The tool bar icons are now (de)activated correctly in the group buffer,
-see the variable 'gnus-group-update-tool-bar'.  Its default value depends
-on your Emacs version.
-
-** You can change the location of XEmacs's toolbars in Gnus buffers.  See
-'gnus-use-toolbar' and 'message-use-toolbar'.
-
-
-* Miscellaneous changes
-
-** New user option 'gnus-rcvstore-options' provides a way to
-specify additional options when saving messages to an MH folder.
-
-** Having edited the select-method for the foreign server in the server
-buffer is immediately reflected to the subscription of the groups which
-use the server in question.  For instance, if you change
-'nntp-via-address' into 'bar.example.com' from 'foo.example.com', Gnus
-will connect to the news host by way of the intermediate host
-'bar.example.com' from next time.
-
-** The 'all.SCORE' file can be edited from the group buffer using 'W e'.
-
-** You can set 'gnus-mark-copied-or-moved-articles-as-expirable' to a
-non-'nil' value so that articles that have been read may be marked as
-expirable automatically when copying or moving them to a group that has
-auto-expire turned on.  The default is 'nil' and copying and moving of
-articles behave as before; i.e., the expirable marks will be unchanged
-except that the marks will be removed when copying or moving articles to
-a group that has not turned auto-expire on.  *Note Expiring Mail::.
-
-** NoCeM support has been removed.
-
-** Carpal mode has been removed.
-
-* For older news, see Gnus info node "New Features".
-
-----------------------------------------------------------------------
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
-
-
-Local variables:
-mode: outline
-paragraph-separate: "[         ]*$"
-end:
diff --git a/etc/HELLO b/etc/HELLO
index db7fd23..a56a73b 100644
--- a/etc/HELLO
+++ b/etc/HELLO
@@ -88,17 +88,17 @@ Telugu (తెలుగు)     నమస్కారం
 
 </x-charset>
 
-Japanese (日本語) こんにちは <x-charset><param>katakana-jisx0201</param>/ コンニチハ
+<x-charset><param>japanese-jisx0208</param>Japanese (日本語)      
こんにちは</x-charset> <x-charset><param>katakana-jisx0201</param>/ コンニチハ
 </x-charset><x-charset><param>chinese-gb2312</param>Chinese (中文,普通话,汉语)        
你好
 </x-charset><x-charset><param>chinese-big5-1</param>Cantonese (粵語,廣東話) 早晨, 你好
-</x-charset>Korean (한글)        안녕하세요 / 안녕하십니까
+</x-charset><x-charset><param>korean-ksc5601</param>Korean (한글)        안녕하세요 / 
안녕하십니까
 
-<x-charset><param>korean-ksc5601</param>
+</x-charset>
 
-</x-charset><x-charset><param>unicode</param>
+<x-charset><param>unicode</param>
 
 
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 
 This file is part of GNU Emacs.
diff --git a/etc/HISTORY b/etc/HISTORY
index b239904..bf03692 100644
--- a/etc/HISTORY
+++ b/etc/HISTORY
@@ -216,6 +216,8 @@ GNU Emacs 25.3 (2017-09-11) emacs-25.3
 
 GNU Emacs 26.1 (2018-05-28) emacs-26.1
 
+GNU Emacs 26.2 (2019-04-12) emacs-26.2
+
 
 ----------------------------------------------------------------------
 This file is part of GNU Emacs.
diff --git a/etc/LINUX-GNU b/etc/LINUX-GNU
deleted file mode 100644
index 0f45e15..0000000
--- a/etc/LINUX-GNU
+++ /dev/null
@@ -1,8 +0,0 @@
-Linux and the GNU system
-
-Note added March 2014:
-
-This file is obsolete and will be removed in future.
-Please update any references to use
-
-<https://www.gnu.org/gnu/linux-and-gnu.html>
diff --git a/etc/MACHINES b/etc/MACHINES
index 0b736fb..2cb1bfd 100644
--- a/etc/MACHINES
+++ b/etc/MACHINES
@@ -1,6 +1,6 @@
 Emacs machines list
 
-Copyright (C) 1989-1990, 1992-1993, 1998, 2001-2018 Free Software
+Copyright (C) 1989-1990, 1992-1993, 1998, 2001-2019 Free Software
 Foundation, Inc.
 See the end of the file for license conditions.
 
diff --git a/etc/MH-E-NEWS b/etc/MH-E-NEWS
index f59823a..def0af1 100644
--- a/etc/MH-E-NEWS
+++ b/etc/MH-E-NEWS
@@ -1,6 +1,6 @@
 * COPYRIGHT
 
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 * Changes in MH-E 8.6
diff --git a/etc/MORE.STUFF b/etc/MORE.STUFF
deleted file mode 100644
index e3f2c16..0000000
--- a/etc/MORE.STUFF
+++ /dev/null
@@ -1,8 +0,0 @@
-More Neat Stuff for your Emacs
-
-Note added January 2014:
-
-This file is obsolete and will be removed in future.
-Please update any links to use
-  info node `(efaq)Packages that do not come with Emacs'
-instead.
diff --git a/etc/NEWS b/etc/NEWS
index 80e0f31..7f66d1d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1,6 +1,6 @@
 GNU Emacs NEWS -- history of user-visible changes.
 
-Copyright (C) 2017-2018 Free Software Foundation, Inc.
+Copyright (C) 2017-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 Please send Emacs bug reports to 'address@hidden'.
@@ -41,6 +41,12 @@ functions 'json-serialize', 'json-insert', 
'json-parse-string', and
 'json-parse-buffer' are typically much faster than their Lisp
 counterparts from json.el.
 
+** Several configure options now accept an option-argument 'ifavailable'.
+For example, './configure --with-xpm=ifavailable' now configures Emacs
+to attempt to use libxpm but to continue building even if libxpm is absent.
+The other affected options are --with-gif, --with-gnutls, --with-jpeg,
+--with-png, and --with-tiff.
+
 ** The etags program now uses the C library's regular expression matcher
 when possible, and a compatible regex substitute otherwise.  This will
 let developers maintain Emacs's own regex code without having to also
@@ -63,19 +69,41 @@ option '--enable-check-lisp-object-type' is therefore no 
longer as
 useful and so is no longer enabled by default in developer builds,
 to reduce differences between developer and production builds.
 
-** Ibuffer
++++
+** Emacs now uses a "portable dumper" instead of unexec.
+This improves compatibility with memory allocation on modern systems,
+and in particular better supports the Address Space Layout
+Randomization (ASLR) feature, a security technique used by most modern
+operating systems.
 
----
-*** All mode filters can now accept a list of symbols.
-This means you can now easily filter several major modes, as well
-as a single mode.
+Portable dumping can be disabled at configure time via the configure
+option '--with-dumping=unexec' (but we don't recommend that, unless
+the portable dumping doesn't work on your system for some
+reason---please report such systems to the Emacs developers as bugs).
 
-** Gnus
+When built with the portable dumping support (which is the default),
+Emacs looks for the 'emacs.pdmp' file, generated during the build, in
+its data directory at startup, and loads the dumped state from there.
+The new command-line argument '--dump-file=FILE' allows to specify a
+non-default '.pdmp' file to load the state from; see the node "Initial
+Options" in the Emacs manual for more information.
 
 +++
-*** The nnimap backend now has support for IMAP namespaces.
-This feature can be enabled by setting the new 'nnimap-use-namespaces'
-server variable to non-nil.
+** The new configure option '--enable-checking=structs' attempts to
+check that the portable dumper code has been updated to match the last
+change to one of the data structures that it relies on.
+
++++
+** The configure options '--enable-checking=conslist' and
+'--enable-checking=xmallocoverrun' have been withdrawn.  The former
+made Emacs irredeemably slow, and the latter made it crash.  Neither
+option was useful with modern debugging tools such as AddressSanitizer.
+(See etc/DEBUG for the details of using the modern replacements of the
+removed configure options.)
+
+---
+** Emacs now requires GTK 2.24 and GTK 3.10 for the GTK 2 and GTK 3
+builds respectively.
 
 
 * Startup Changes in Emacs 27.1
@@ -144,9 +172,20 @@ EMACS_SOCKET_NAME environment variable to an appropriate 
value.
 *** When run by root, emacsclient no longer connects to non-root sockets.
 (Instead you can use Tramp methods to run root commands in a non-root Emacs.)
 
+---
+** Control of the threshold for using the 'distant-foreground' color.
+The threshold for color distance below which the 'distant-foreground'
+color of the face will be used instead of the foreground color can now
+be controlled via the new variable 'face-near-same-color-threshold'.
+The default value is 30000, as the previously hard-coded threshold.
+
 +++
 ** The function 'read-passwd' uses '*' as default character to hide passwords.
 
+** Lexical binding is now used when evaluating interactive Elisp forms
+More specifically, lexical-binding is now used for M-:, --eval, as well
+as in the *scratch* and *ielm* buffers.
+
 ---
 ** The new option 'tooltip-resize-echo-area' avoids truncating tooltip text
 on GUI frames when tooltips are displayed in the echo area.  Instead,
@@ -204,6 +243,13 @@ or adjust the elements in that variable to only happen on 
the 'high'
 security level (assuming you use the 'medium' level).
 
 +++
+** Native GnuTLS connections can now use client certificates.
+Previously, this support was only available when using the external
+gnutls-cli command.  Call 'open-network-stream' with
+':client-certificate t' to trigger looking up of per-server
+certificates via 'auth-source'.
+
++++
 ** New function 'fill-polish-nobreak-p', to be used in 
'fill-nobreak-predicate'.
 It blocks line breaking after a one-letter word, also in the case when
 this word is preceded by a non-space, but non-alphanumeric character.
@@ -221,6 +267,18 @@ regular expression was previously invalid, but is now 
accepted:
 ---
 ** New input methods 'hawaiian-postfix' and 'hawaiian-prefix'.
 
+---
+** New input methods for several variants of the Sami language.
+The Sami input methods include: 'norwegian-sami-prefix',
+'bergsland-hasselbrink-sami-prefix', 'southern-sami-prefix',
+'ume-sami-prefix', 'northern-sami-prefix', 'inari-sami-prefix',
+'skolt-sami-prefix', and 'kildin-sami-prefix'.
+
++++
+** In Japanese environments that do not specify encodings and are not
+based on MS-Windows, the default encoding is now utf-8 instead of
+japanese-iso-8bit.
+
 +++
 ** New function 'exec-path'.
 This function by default returns the value of the corresponding
@@ -247,6 +305,45 @@ when the last screen line in a window is not fully visible.
 ** New variable 'emacs-repository-branch'.
 It reports the git branch from which Emacs was built.
 
++++
+** New user option 'switch-to-buffer-obey-display-actions'.
+When non-nil, 'switch-to-buffer' uses 'pop-to-buffer-same-window' that
+respects display actions specified by 'display-buffer-alist' and
+'display-buffer-overriding-action'.
+
+** New 'flex' completion style
+An implementation of popular "flx/fuzzy/scatter" completion which
+matches strings where the pattern appears as a subsequence.  Put
+simply, makes "foo" complete to both "barfoo" and "frodo".  Add 'flex'
+to 'completion-styles' or 'completion-category-overrides' to use it.
+
+** Connection-local variables
+
++++
+*** Connection-local variables are applied by default like file-local
+and directory-local variables.
+
++++
+*** The macro 'with-connection-local-variables' has been renamed from
+'with-connection-local-profiles'.  No argument 'profiles' needed any
+longer.
+
+---
+** New variable next-error-verbose controls when `next-error' outputs
+   a message about the error locus.
+
+---
+** New variable grep-search-path defines the directories searched for
+   grep hits (this used to be controlled by compilation-search-path).
+
+---
+** New variable emacs-lisp-compilation-search-path defines the
+   directories searched for byte-compiler error messages (this used to
+   be controlled by compilation-search-path).
+
+** Multicolor fonts such as "Noto Color Emoji" can be displayed on
+Emacs configured with Cairo drawing and linked with cairo >= 1.16.0.
+
 
 * Editing Changes in Emacs 27.1
 
@@ -305,9 +402,63 @@ write alists of variables to ".dir-locals.el".  This is 
the same
 syntax that you can see in the example of a ".dir-locals.el" file in
 the node "(emacs) Directory Variables" of the user manual.
 
++++
+** Network connections using 'local can now use IPv6.
+'make-network-process' now uses the correct loopback address when
+asked to use :host 'local and :family 'ipv6.
+
++++
+** The new function `replace-region-contents' replaces the current
+region using a given replacement-function in a non-destructive manner
+(in terms of `replace-buffer-contents').
+
++++
+** The command `replace-buffer-contents' now has two optional
+arguments mitigating performance issues when operating on huge
+buffers.
+
+** The command 'delete-indentation' now operates on the active region.
+If the region is active, the command joins all the lines in the
+region.  When there's no active region, the command works on the
+current and the previous or the next line, as before.
+
++++
 
 * Changes in Specialized Modes and Packages in Emacs 27.1
 
+** compile.el
+---
+*** In compilation-error-regexp-alist, 'line' (and 'end-line') can be functions
+
+** cl-lib
++++
+*** cl-defstruct has a new :noinline argument to prevent inlining its functions
+
+** doc-view-mode
+*** New commands doc-view-presentation and doc-view-fit-window-to-page
+*** Added support for password-protected PDF files
+
+** Ido
+*** New user option 'ido-big-directories' to mark directories whose
+names match certain regular expressions as big.  Ido won't attempt to
+list the contents of such directories when completing file names.
+
+** map.el
+*** Now also understands plists.
+*** Now defined via generic functions that can be extended via 'cl-defmethod'.
+*** Deprecate the 'map-put' macro in favor of a new 'map-put!' function.
+*** 'map-contains-key' now returns a boolean rather than the key.
+*** Deprecate the 'testfn' args of 'map-elt' and 'map-contains-key'.
+*** New generic function 'map-insert'.
+
++++
+** seq.el
+New convenience functions 'seq-first' and 'seq-rest' give easy access
+to respectively the first and all but the first elements of sequences.
+
+The new predicate function 'seq-contains-p' should be used instead of
+the now obsolete 'seq-contains'.
+
 ---
 ** Follow mode
 In the current follow group of windows, "ghost" cursors are no longer
@@ -333,18 +484,23 @@ displays the *Messages* buffer in the same window.
 
 *** Windmove also supports directional window deletion.
 The new command 'windmove-delete-default-keybindings' binds default
-keys with provided prefix (by default, C-x) and modifiers (by default,
-Shift) to the commands that delete the window in the specified
+keys with provided prefix (by default, 'C-x') and modifiers (by default,
+'Shift') to the commands that delete the window in the specified
 direction.  For example, 'C-x S-down' deletes the window below.
-With a prefix arg 'C-u', deletes the selected window and selects
-the window that was in the specified direction.
+With a prefix arg 'C-u', also kills the buffer in that window.
+With 'M-0', deletes the selected window and selects the window
+that was in the specified direction.
+
+*** New command 'windmove-swap-states-in-direction' binds default keys
+to the commands that swap the states of the selected window with the
+window in the specified direction.
 
 ** Octave mode
 The mode is automatically enabled in files that start with the
 'function' keyword.
 
 ** project.el
-*** New commands 'project-search' and 'project-query-replace'.
+*** New commands 'project-search' and 'project-query-replace-regexp'.
 
 ** Etags
 
@@ -352,11 +508,11 @@ The mode is automatically enabled in files that start 
with the
 *** 'next-file' is now an obsolete alias of 'tags-next-file'.
 
 *** 'tags-loop-revert-buffers' is an obsolete alias of
-'multifile-revert-buffers'.
+'fileloop-revert-buffers'.
 
 *** The 'tags-loop-continue' function along with the
 'tags-loop-operate' and 'tags-loop-scan' variables are now obsolete;
-use the new 'multifile-initialize' and 'multifile-continue' functions
+use the new 'fileloop-initialize' and 'fileloop-continue' functions
 instead.
 
 ** bibtex
@@ -402,9 +558,33 @@ with conflicts existed in earlier versions of Emacs, but 
incorrectly
 never detected a conflict due to invalid assumptions about cached
 values.
 
++++
+*** 'C-u C-x v D' ('vc-root-version-diff') prompts for two revisions
+and compares their entire trees.
+
+*** New user option 'vc-hg-revert-switches' specifies switches to pass
+to hg revert.
+
+*** 'C-x v M D' ('vc-diff-mergebase') and 'C-x v M L' ('vc-log-mergebase')
+print diffs and logs between the merge base (common ancestor) of two
+given revisions.
+
 ** Diff mode
-*** Hunks are now automatically refined by default.
-To disable it, set the new defcustom 'diff-font-lock-refine' to nil.
++++
+*** Hunks are now automatically refined by font-lock.
+To disable refinement, set the new defcustom 'diff-refine' to nil.
+To get back the old behavior where hunks are refined as you navigate
+through a diff, set 'diff-refine' to the symbol 'navigate'.
++++
+*** 'diff-auto-refine-mode' is deprecated in favor of 'diff-refine'.
+It is no longer enabled by default and binding it no longer has any
+effect.
+
++++
+*** Better syntax highlighting of Diff hunks.
+Fragments of source in Diff hunks are now by default highlighted
+according to the appropriate major mode.  Customize the new option
+'diff-font-lock-syntax' to nil to disable this.
 
 *** File headers can be shortened, mimicking Magit's diff format.
 To enable it, set the new defcustom 'diff-font-lock-prettify' to t.
@@ -414,6 +594,15 @@ To enable it, set the new defcustom 
'diff-font-lock-prettify' to t.
 of the file under version control if point is on an old changed line,
 or to the new revision of the file otherwise.
 
+** Texinfo
+
++++
+*** New function for inserting @pxref, @xref, or @ref commands.
+The function 'address@hidden', bound to 'C-c C-c r' by
+default, inserts one of three types of references based on the text
+surrounding point, namely @pxref near a parenthesis, @xref at the
+start of a sentence or at (point-min), else @ref.
+
 ** Browse-url
 
 *** The function 'browse-url-emacs' can now visit a URL in selected window.
@@ -445,27 +634,45 @@ end.
 
 ** SQL
 
-*** Installation of 'sql-indent' from ELPA is strongly encouraged.
-This package support sophisticated rules for properly indenting SQL
-statements.  SQL is not like other programming languages like C, Java,
-or Python where code is sparse and rules for formatting are fairly
-well established. Instead SQL is more like COBOL (from which it came)
-and code tends to be very dense and line ending decisions driven by
-syntax and line length considerations to make readable code.
-Experienced SQL developers may prefer to rely upon existing Emacs
-facilities for formatting code but the 'sql-indent' package provides
-facilities to aid more casual SQL developers layout queries and
-complex expressions.
-
-*** 'sql-use-indent-support' (default t) enables SQL indention support.
+*** SQL Indent Minor Mode
+
+SQL Mode now supports the ELPA 'sql-indent' package for assisting
+sophisticated SQL indenting rules.  Note, however, that SQL is not
+like other programming languages like C, Java, or Python where code is
+sparse and rules for formatting are fairly well established. Instead
+SQL is more like COBOL (from which it came) and code tends to be very
+dense and line ending decisions driven by syntax and line length
+considerations to make readable code.  Experienced SQL developers may
+prefer to rely upon existing Emacs facilities for formatting code but
+the 'sql-indent' package provides facilities to aid more casual SQL
+developers layout queries and complex expressions.
+
+**** 'sql-use-indent-support' (default t) enables SQL indention support.
 The 'sql-indent' package from ELPA must be installed to get the
 indentation support in 'sql-mode' and 'sql-interactive-mode'.
 
-*** 'sql-mode-hook' and 'sql-interactive-mode-hook' changed.
+**** 'sql-mode-hook' and 'sql-interactive-mode-hook' changed.
 Both hook variables have had 'sql-indent-enable' added to their
-default values. If youhave existing customizations to these variables,
+default values. If you have existing customizations to these variables,
 you should make sure that the new default entry is included.
 
+*** Connection Wallet
+
+Database passwords can now by stored in NETRC or JSON data files that
+may optionally be encrypted. When establishing an interactive session
+with the database via 'sql-connect' or a product specific function,
+like 'sql-mysql' or 'my-postgres', the password wallet will be
+searched for the password. The 'sql-product', 'sql-server',
+'sql-database', and the 'sql-username' will be used to identify the
+appropriate authorization. This eliminates the discouraged practice of
+embedding database passwords in your Emacs initialization.
+
+See the `auth-source' module for complete documentation on the file
+formats.  By default, the wallet file is expected to be in the
+`user-emacs-directory', named 'sql-wallet' or '.sql-wallet', with
+'.json' (JSON) or no (NETRC) suffix.  Both file formats can optionally
+be encrypted with GPG by adding an additional '.gpg' suffix.
+
 ** Term
 
 ---
@@ -485,6 +692,13 @@ Control whether Flymake starts checking the buffer on save.
 This enables more efficient backends.  See the docstring of
 'flymake-diagnostic-functions' or the Flymake manual for details.
 
+** Ruby
+
+*** The Rubocop Flymake diagnostic function will only run Lint cops if
+it can't find the config file.
+
+*** Rubocop is called with 'bundle exec' if Gemfile mentions it.
+
 ** Package
 
 *** New function 'package-get-version' lets packages query their own version.
@@ -521,6 +735,13 @@ mouse click event, and is intended to be bound to a mouse 
event.
 Previously, setting 'xref-marker-ring-length' would only take effect
 if set before 'xref.el' was loaded.
 
+---
+*** xref-find-definitions now sets the mark at the buffer position
+where it was invoked
+
+---
+*** New xref faces 'xref-file-header', 'xref-line-number', 'xref-match'
+
 ** Ecomplete
 
 *** The ecomplete sorting has changed to a decay-based algorithm.
@@ -531,6 +752,17 @@ Of course it will still find it if you have it in 
~/.ecompleterc
 
 ** Gnus
 
+---
+*** Gnus now maps imaps to 993 only on old MS-Windows versions.
+The nnimap backend used to do this unconditionally to work around
+problems on old versions of MS-Windows.  This is now done only for
+Windows XP and older.
+
++++
+*** The nnimap backend now has support for IMAP namespaces.
+This feature can be enabled by setting the new 'nnimap-use-namespaces'
+server variable to non-nil.
+
 +++
 *** A prefix argument to 'gnus-summary-limit-to-score' will limit reverse.
 Limit to articles with score at below.
@@ -572,6 +804,16 @@ and its value has been changed to Duck Duck Go.
 
 ** eww/shr
 
++++
+*** The 'eww' command can now create a new EWW buffer.
+Invoking the command with a prefix argument will cause it to create a
+new EWW buffer for the URL instead of reusing the default one.
+
++++
+*** The 'd' ('eww-download') command now falls back to current page's URL.
+If this command is invoked with no URL at point, it now downloads the
+current page instead of signaling an error.
+
 *** When opening external links in eww/shr (typically with the
 'C-u RET' keystroke on a link), the link will be flashed with the new
 'shr-selected-link' face to give the user feedback that the command
@@ -582,6 +824,9 @@ has been executed.
 If set, shr will not render tags with attribute 'aria-hidden="true"'.
 This attribute is meant to tell screen readers to ignore a tag.
 
+---
+*** 'shr-tag-ol' now respects the ordered list 'start' attribute.
+
 ** Htmlfontify
 
 *** The functions 'hfy-color', 'hfy-color-vals' and
@@ -642,6 +887,9 @@ directories in the destination.
 ** Help
 
 ---
+*** Description of variables and functions give an estimated first release
+
+---
 *** Output format of 'C-h l' ('view-lossage') has changed.
 For convenience, 'view-lossage' now displays the last keystrokes
 and commands in the same format as the edit buffer of
@@ -658,6 +906,11 @@ can now be searched via 'C-s'.
 ---
 *** New filter 'ibuffer-filter-by-process'; bound to '/E'.
 
+---
+*** All mode filters can now accept a list of symbols.
+This means you can now easily filter several major modes, as well
+as a single mode.
+
 ** Search and Replace
 
 *** Isearch supports a prefix argument for 'C-s' ('isearch-repeat-forward')
@@ -712,6 +965,9 @@ and case-sensitivity together with search strings in the 
search ring.
 ---
 *** Isearch now has its own tool-bar and menu-bar menu.
 
++++
+*** flush-lines prints and returns the number of deleted matching lines.
+
 ** Debugger
 
 +++
@@ -750,7 +1006,7 @@ been instrumented by Edebug.
 the XTerm window title.  This feature is experimental and is disabled
 by default.
 
-** grep
+** Grep
 
 +++
 *** rgrep, lgrep and zrgrep now hide part of the command line
@@ -812,6 +1068,11 @@ default, and not just the opening element.
 
 ** Eshell
 
+*** TAB completion uses the standard completion-at-point rather than pcomplete
+Its UI is slightly different but can be customized to behave similarly,
+e.g. Pcomplete's default cycling can be obtained with
+(setq completion-cycle-threshold 5).
+
 ---
 *** Expansion of history event designators is disabled by default.
 To restore the old behavior, use
@@ -839,7 +1100,18 @@ followed when Emacs writes the relevant history variables 
to the disk.
 ---
 *** Program name completion inside remote shells works now as expected.
 
++++
+*** The variable 'shell-file-name' can be set now as connection-local
+variable for remote shells.  It still defaults to "/bin/sh".
+
+** Single shell commands
+
+---
+*** 'shell-command-width' defines the number of display columns
+available for output of asynchronous or remote shell commands.
+
 ** Pcomplete
+
 *** The function 'pcomplete-uniquify-list' has been renamed from
 'pcomplete-uniqify-list'.
 
@@ -859,6 +1131,12 @@ or NextCloud hosted files and directories.
 storages via the 'rclone' program.  This feature is experimental.
 
 +++
+*** New connection method "sudoedit", which allows to edit local files
+with different user credentials.  Contrary to the "sudo" method, no
+session is run permanently in the background.  This is for security
+reasons.
+
++++
 *** Connection methods "obex" and "synce" are removed, because they
 are obsoleted in GVFS.
 
@@ -876,7 +1154,8 @@ Tramp for some look-alike remote file names.
 
 +++
 *** For some connection methods, like "su" or "sudo", the host name in
-ad-hoc multi-hop file names must match the previous hop.
+ad-hoc multi-hop file names must match the previous hop.  Default host
+names are adjusted to the host name from the previous hop.
 
 +++
 *** For the connection methods "sudo" and "doas" there exists a
@@ -991,10 +1270,133 @@ subexpression.
 When there is no menu for a mode, display the mode name after the
 indicator instead of just the indicator (which is sometimes cryptic).
 
+** rx
+
+---
+*** rx now handles raw bytes in character alternatives correctly,
+when given in a string.  Previously, '(any "\x80-\xff")' would match
+characters U+0080...U+00FF.  Now the expression matches raw bytes in
+the 128...255 range, as expected.
+
+** Frames
+
++++
+*** New command 'make-frame-on-monitor' makes a frame on the specified monitor.
+
++++
+*** New value of 'minibuffer' frame parameter 'child-frame'.
+This allows to create and parent immediately a minibuffer-only child
+frame when making a frame.
+
+---
+*** New predicates 'display-blink-cursor-p' and 'display-symbol-keys-p'.
+These predicates are to be preferred over 'display-graphic-p' when
+testing for blinking cursor capability and the capability to have
+symbols (e.g., [return], [tab], [backspace]) as keys respectively.
+
+** Tabulated List mode
+
++++
+*** New user options for tabulated list sort indicators.
+You can now customize which sorting indicator character to display
+near the current column in Tabulated Lists (see variables
+'tabulated-list-gui-sort-indicator-asc',
+'tabulated-list-gui-sort-indicator-desc',
+'tabulated-list-tty-sort-indicator-asc', and
+'tabulated-list-tty-sort-indicator-desc').
+
+** Text mode
+
++++
+*** 'text-mode-variant' is now obsolete, use 'derived-mode-p' instead.
+
+** CUA mode
+
+---
+*** New defcustom 'cua-rectangle-terminal-modifier-key'.
+This defcustom allows for the customization of the modifier key used
+in a terminal frame.
+
+** JS mode
+
+---
+*** JSX syntax is now automatically detected and enabled.
+If a file imports Facebook's 'React' library, or if the file uses the
+extension '.jsx', then various features supporting XML-like syntax
+will be supported in 'js-mode' and derivative modes.  ('js-jsx-mode'
+no longer needs to be enabled.)
+
+---
+*** New defcustom 'js-jsx-detect-syntax' disables automatic detection.
+This is turned on by default.
+
+---
+*** New defcustom 'js-jsx-syntax' enables JSX syntax unconditionally.
+This is off by default.
+
+---
+*** New variable 'js-jsx-regexps' controls JSX detection.
+
+---
+*** JSX syntax is now highlighted like SGML.
+
+---
+*** JSX code is properly indented in many more scenarios.
+Previously, JSX indentation usually only worked when an element was
+wrapped in parenthesis (e.g. in a 'return' statement or a function
+call).  It would also fail in many intricate cases.  Now, indentation
+should work anywhere without parenthesis; many more intricacies are
+supported; and, indentation conventions align more closely with those
+of the React developer community (see 'js-jsx-align->-with-<'),
+otherwise still adhering to SGML conventions.
+
+---
+*** New defcustom 'js-jsx-align->-with-<' controls '>' indents.
+Commonly in JSX code, a '>' on its own line is indented at the same
+level as its opening '<'.  This is the new default for JSX.  This
+behavior is slightly different than that used by SGML in Emacs, where
+'>' is indented at the same level as attributes, which was also the
+old default for JSX.
+
+This is turned on by default.  To get back the old default indentation
+behavior of aligning '>' with attributes, set 'js-jsx-align->-with-<'
+to nil.
+
+---
+*** Indentation uses 'js-indent-level' instead of 'sgml-basic-offset'.
+Since JSX is a syntax extension of JavaScript, it makes the most sense
+for JSX expressions to be indented the same number of spaces as other
+JS expressions.  This is a breaking change, but it probably aligns
+with how you'd expect this indentation to behave.  If you want JSX to
+be indented like JS, you won't need to change your config.
+
+The old behavior can be emulated by controlling JSX indentation
+independently of JS, by setting 'js-jsx-indent-level'.
+
+---
+*** New defcustom 'js-jsx-indent-level' for different JSX indentation.
+If you wish to indent JSX by a different number of spaces than JS, set
+this variable to the desired number.
+
+---
+*** New defcustom 'js-jsx-attribute-offset' for JSX attribute indents.
+
+---
+*** New variable 'js-syntactic-mode-name' controls mode name display.
+Previously, the mode name was simply 'JavaScript'.  Now, when a syntax
+extension like JSX is enabled, the mode name is 'JavaScript[JSX]'.
+Set this variable to nil to disable the new behavior.
+
+---
+*** New function 'js-use-syntactic-mode-name' for deriving modes.
+Packages deriving from 'js-mode' with 'define-derived-mode' should
+call this function to add enabled syntax extensions to their mode
+name, too.
+
 
 * New Modes and Packages in Emacs 27.1
 
-** multifile.el lets one setup multifile operations like search&replace.
+** fileloop.el lets one setup multifile operations like search&replace.
 
 +++
 ** Emacs can now visit files in archives as if they were directories.
@@ -1021,6 +1423,9 @@ documentation of the new mode and its commands.
 
 * Incompatible Lisp Changes in Emacs 27.1
 
+** In compilation-error-regexp-alist the old undocumented feature where 'line'
+could be a function of 2 arguments has been dropped.
+
 ** 'define-fringe-bitmap' is always defined, even when Emacs is built
 without any GUI support.
 
@@ -1072,6 +1477,10 @@ old-style backquotes as new-style, bind the new variable
 integer, Emacs now signals an error if the number is too large for the
 implementation to format.
 
+** logb now returns infinity when given an infinite or zero argument,
+and returns a NaN when given a NaN.  Formerly, it returned an extreme
+fixnum for such arguments.
+
 ---
 ** Some functions and variables obsolete since Emacs 22 have been removed:
 archive-mouse-extract, assoc-ignore-case, assoc-ignore-representation,
@@ -1118,11 +1527,41 @@ they are now allocated like any other pseudovector.  As 
a result, the
 'misc' component, and the 'misc-objects-consed' variable has been
 removed.
 
++++
+** Reversed character ranges are no longer permitted in rx.
+Previously, ranges where the starting character is greater than the
+ending character were silently omitted.
+For example, '(rx (any "@z-a" (?9 . ?0)))' would match '@' only.
+Now, such rx expressions generate an error.
+
++++
+** 'text-mode' no longer sets the value of 'indent-line-function'.
+The global value of 'indent-line-function', which defaults to
+'indent-relative', will no longer be reset locally when turning on
+'text-mode'.
+
+To get back the old behavior, add a function to 'text-mode-hook' which
+performs (setq-local indent-line-function #'indent-relative).
+
+** 'make-process' no longer accepts a non-nil ':stop' key.  This has
+never worked reliably, and now causes an error.
+
 
 * Lisp Changes in Emacs 27.1
 
+** New 'help-fns-describe-variable-functions' hook.
+Makes it possible to add metadata information to describe-variable.
+
+** i18n (internationalization)
+
+*** ngettext can be used now to return the right plural form
+according to the given numeric value.
+
++++
+** inhibit-null-byte-detection is renamed to inhibit-nul-byte-detection
+
 +++
-** self-insert-command takes the char to insert as (optional) argument
+** 'self-insert-command' takes the char to insert as (optional) argument.
 
 ** 'lookup-key' can take a list of keymaps as argument.
 
@@ -1187,6 +1626,12 @@ floating-point operators do.
 +++
 ** New function 'time-equal-p' compares time values for equality.
 
++++
+** 'format-time-string' supports a new conversion specifier flag '+'
+that acts like the '0' flag but also puts a '+' before nonnegative
+years containing more than four digits.  This is for compatibility
+with POSIX.1-2017.
+
 ** 'define-minor-mode' automatically documents the meaning of ARG.
 
 +++
@@ -1234,9 +1679,43 @@ displaying the same buffer.  See the node "(elisp) Face 
Remapping"
 of the Emacs Lisp Reference manual for more detail.
 
 +++
-** Special handling of buffer-local 'window-size-change-functions'.
-A buffer-local value of this hook is now run only if at least one
-window showing the buffer has changed its size.
+** Window change functions have been redesigned.
+
+Hooks reacting to window changes run now only when redisplay detects
+that a change has actually occurred.  Six hooks are now provided:
+'window-buffer-change-functions' (run after window buffers have
+changed), 'window-size-change-functions' (run after a window was
+assigned a new buffer or size), 'window-configuration-change-hook'
+(like the former but run also when a window was deleted),
+'window-selection-change-functions' (run when the selected window
+changed) and 'window-state-change-functions' and
+'window-state-change-hook' (run when any of the preceding ones is
+run).  Applications can enforce running the latter two using the new
+function 'set-frame-window-state-change'.  'window-scroll-functions'
+are unaffected by these changes.
+
+In addition, a number of functions now allow the caller to detect what
+has changed since last redisplay: 'window-old-buffer' returns for any
+window the buffer it showed at that time.  ‘old-selected-window’ and
+'old-selected-frame' return the window and frame that were selected
+during last redisplay.  'window-old-pixel-width' (renamed from
+'window-pixel-width-before-size-change'), 'window-old-pixel-height'
+(renamed from 'window-pixel-height-before-size-change'),
+'window-old-body-pixel-width' and 'window-old-body-pixel-height'
+return the total and body sizes of any window during last redisplay.
+
+See the section "(elisp) Window Hooks" in the Elisp manual for a
+detailed explanation of the new behavior.
+
++++
+*** New option 'resize-mini-frames'.
+This option allows to automatically resize minibuffer-only frames
+similarly to how minibuffer windows are resized on "normal" frames.
+
++++
+** New buffer display action alist entry 'dedicated'.
+Such an entry allows to specify the dedicated status of a window
+created by 'display-buffer'.
 
 +++
 ** New buffer display action alist entry 'window-min-height'.
@@ -1255,10 +1734,10 @@ between two strings.
 '(quote x)' instead of 'x you will have to bind it to nil where applicable.
 
 +++
-** Numbers formatted via '%o' or '%x' may now be formatted as signed integers.
+** Numbers formatted via '%o' or '%x' are now formatted as signed integers.
 This avoids problems in calls like '(read (format "#x%x" -1))', and is
-more compatible with bignums, a planned feature.  To get this
-behavior, set the experimental variable 'binary-as-unsigned' to nil,
+more compatible with bignums.  To get the traditional machine-dependent
+behavior, set the experimental variable 'binary-as-unsigned' to t,
 and if the new behavior breaks your code please email
 address@hidden  Because '%o' and '%x' can now format signed
 integers, they now support the '+' and space flags.
@@ -1347,6 +1826,18 @@ are implemented in C using the Jansson library.
 ** New function 'ring-resize'.
 'ring-resize' can be used to grow or shrink a ring.
 
++++
+** New function 'flatten-tree'.
+'flatten-list' is provided as an alias. These functions take a tree
+and 'flatten' it such that the result is a list of all the terminal
+nodes.
+
++++
+** 'zlib-decompress-region' can partially decompress corrupted data.
+If the new optional ALLOW-PARTIAL argument is passed, then the data
+that was decompressed successfully before failing will be inserted
+into the buffer.
+
 ** Mailcap
 
 ---
@@ -1376,6 +1867,13 @@ left to higher-level functions.
 some years back.  It now respects 'imagemagick-types-inhibit' as a way
 to disable that.
 
+---
+*** Some image-mode variables are now buffer-local.
+The image parameters 'image-transform-rotation',
+'image-transform-scale' and 'image-transform-resize' are now declared
+buffer-local, so each buffer could have its own values for these
+parameters.
+
 ** The function 'load' now behaves correctly when loading modules.
 Specifically, it puts the module name into 'load-history', prints
 loading messages if requested, and protects against recursive loads.
@@ -1395,6 +1893,50 @@ un-obsoleting it.
 +++
 ** New function 'group-name' returns a group name corresponding to GID.
 
++++
+** 'make-process' now takes a keyword argument ':file-handler'; if
+that is non-nil, it will look for a file name handler for the current
+buffer's 'default-directory' and invoke that file name handler to make
+the process.  That way 'make-process' can start remote processes.
+
++++
+** Emacs now supports resizing (scaling) of images without ImageMagick.
+All modern systems are supported by this feature.  (On GNU and Unix
+systems, Cairo drawing or the XRender extension to X11 is required for
+this to be available; the configure script will test for it and, if
+found, enable scaling.)
+
+The new function 'image-scaling-p' can be used to test whether any
+given frame supports resizing.
+
++++
+** (locale-info 'paper) now returns the paper size on systems that support it.
+This is currently supported on GNUish hosts and on modern versions of
+MS-Windows.
+
+** New module environment function 'process_input' to process user
+input while module code is running.
+
++++
+** The function 'regexp-opt' accepts an additional optional argument.
+By default, the regexp returned by 'regexp-opt' may match the strings
+in any order.  If the new third argument is non-nil, the match is
+guaranteed to be performed in the order given, as if the strings were
+made into a regexp by joining them with '\|'.
+
++++
+** The function 'regexp-opt', when given an empty list of strings, now
+returns a regexp that never matches anything, which is an identity for
+this operation.  Previously, the empty string was returned in this
+case.
+
+** New module environment functions 'make_time' and 'extract_time' to
+convert between timespec structures and Emacs Lisp time values.
+
+** New module environment functions 'make_big_integer' and
+'extract_big_integer' to create and extract arbitrary-size integer
+values.
+
 
 * Changes in Emacs 27.1 on Non-Free Operating Systems
 
@@ -1428,6 +1970,23 @@ versions of MS-Windows.  Set this variable to 50 if for 
some reason
 you need the old behavior (and please report such situations to Emacs
 developers).
 
+---
+** New variable 'w32-multibyte-code-page'.
+This variable holds the value of the multibyte code page used by the
+system.  It is usually zero, which indicates that 'w32-ansi-code-page'
+is being used, except in Far Eastern locales.  When this variable is
+non-zero, Emacs at startup sets 'locale-coding-system' to the
+corresponding encoding, instead of using 'w32-ansi-code-page'.
+
++++
+** On NS the behaviour of drag and drop can now be modified by use of
+modifier keys in line with Apples guidelines.  This makes the drag and
+drop behaviour more consistent, as previously the sending application
+was able to 'set' modifiers without the knowledge of the user.
+
+** On NS multicolor font display is enabled again since it is also
+implemented in Emacs on free operating systems via Cairo drawing.
+
 
 ----------------------------------------------------------------------
 This file is part of GNU Emacs.
diff --git a/etc/NEWS.1-17 b/etc/NEWS.1-17
index 0ee3a2a..1ce36fe 100644
--- a/etc/NEWS.1-17
+++ b/etc/NEWS.1-17
@@ -1,6 +1,6 @@
 GNU Emacs NEWS -- history of user-visible changes.  26-Mar-1986
 
-Copyright (C) 1985-1986, 2006-2018 Free Software Foundation, Inc.
+Copyright (C) 1985-1986, 2006-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 
@@ -2339,9 +2339,9 @@ It's Beat CCA Week.
 
 ** Lisp macros now exist.
  For example, you can write
-    (defmacro cadr (arg) (list 'car (list 'cdr arg)))
+    (defmacro mycadr (arg) (list 'car (list 'cdr arg)))
  and then the expression
-    (cadr foo)
+    (mycadr foo)
  will expand into
     (car (cdr foo))
 
diff --git a/etc/NEWS.18 b/etc/NEWS.18
index 2c014d2..fe2f8c8 100644
--- a/etc/NEWS.18
+++ b/etc/NEWS.18
@@ -1,6 +1,6 @@
 GNU Emacs NEWS -- history of user-visible changes.  17-Aug-1988
 
-Copyright (C) 1988, 2006-2018 Free Software Foundation, Inc.
+Copyright (C) 1988, 2006-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 
diff --git a/etc/NEWS.19 b/etc/NEWS.19
index 66eadb8..757d029 100644
--- a/etc/NEWS.19
+++ b/etc/NEWS.19
@@ -1,6 +1,6 @@
 GNU Emacs NEWS -- history of user-visible changes.  1992.
 
-Copyright (C) 1993-1995, 2001, 2006-2018 Free Software Foundation, Inc.
+Copyright (C) 1993-1995, 2001, 2006-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 
diff --git a/etc/NEWS.20 b/etc/NEWS.20
index d4a5b8c..931e227 100644
--- a/etc/NEWS.20
+++ b/etc/NEWS.20
@@ -1,6 +1,6 @@
 GNU Emacs NEWS -- history of user-visible changes.  2006-05-31
 
-Copyright (C) 1999-2001, 2006-2018 Free Software Foundation, Inc.
+Copyright (C) 1999-2001, 2006-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 
diff --git a/etc/NEWS.21 b/etc/NEWS.21
index 4a22109..d078fb1 100644
--- a/etc/NEWS.21
+++ b/etc/NEWS.21
@@ -1,6 +1,6 @@
 GNU Emacs NEWS -- history of user-visible changes.  2006-05-31
 
-Copyright (C) 2000-2018 Free Software Foundation, Inc.
+Copyright (C) 2000-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 
diff --git a/etc/NEWS.22 b/etc/NEWS.22
index 26054d2..675b144 100644
--- a/etc/NEWS.22
+++ b/etc/NEWS.22
@@ -1,6 +1,6 @@
 GNU Emacs NEWS -- history of user-visible changes.
 
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 Please send Emacs bug reports to address@hidden
diff --git a/etc/NEWS.23 b/etc/NEWS.23
index 181dad7..bbc81d2 100644
--- a/etc/NEWS.23
+++ b/etc/NEWS.23
@@ -1,6 +1,6 @@
 GNU Emacs NEWS -- history of user-visible changes.
 
-Copyright (C) 2007-2018 Free Software Foundation, Inc.
+Copyright (C) 2007-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 Please send Emacs bug reports to address@hidden
diff --git a/etc/NEWS.24 b/etc/NEWS.24
index 9ace7ce..9150e49 100644
--- a/etc/NEWS.24
+++ b/etc/NEWS.24
@@ -1,6 +1,6 @@
 GNU Emacs NEWS -- history of user-visible changes.
 
-Copyright (C) 2010-2018 Free Software Foundation, Inc.
+Copyright (C) 2010-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 Please send Emacs bug reports to address@hidden
diff --git a/etc/NEWS.25 b/etc/NEWS.25
index 4ae5ece..98aec3c 100644
--- a/etc/NEWS.25
+++ b/etc/NEWS.25
@@ -1,6 +1,6 @@
 GNU Emacs NEWS -- history of user-visible changes.
 
-Copyright (C) 2014-2018 Free Software Foundation, Inc.
+Copyright (C) 2014-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 Please send Emacs bug reports to address@hidden
diff --git a/etc/NEWS.26 b/etc/NEWS.26
index 043573e..aa583f4 100644
--- a/etc/NEWS.26
+++ b/etc/NEWS.26
@@ -1,6 +1,6 @@
 GNU Emacs NEWS -- history of user-visible changes.
 
-Copyright (C) 2016-2018 Free Software Foundation, Inc.
+Copyright (C) 2016-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 Please send Emacs bug reports to 'address@hidden'.
@@ -16,43 +16,60 @@ You can narrow news to a specific version by calling 
'view-emacs-news'
 with a prefix argument or by typing 'C-u C-h C-n'.
 
 
+* Installation Changes in Emacs 26.3
+
+
+* Startup Changes in Emacs 26.3
+
+
+* Changes in Emacs 26.3
+
+
+* Editing Changes in Emacs 26.3
+
+
+* Changes in Specialized Modes and Packages in Emacs 26.3
+
+
+* New Modes and Packages in Emacs 26.3
+
+
+* Incompatible Lisp Changes in Emacs 26.3
+
+
+* Lisp Changes in Emacs 26.3
+
+
+* Changes in Emacs 26.3 on Non-Free Operating Systems
+
+
 * Installation Changes in Emacs 26.2
 
----
 ** Building Emacs with the '--with-xwidgets' option now requires WebKit2.
 To build Emacs with xwidgets support, you will need to install the
 webkit2gtk-4.0 package; version 2.12 or later is required.
 (This change was actually made in Emacs 26.1, but was not called out
 in its NEWS.)
 
-+++
 ** Installing Emacs now installs the emacs-module.h file.
 The emacs-module.h file is now installed in the system-wide include
 directory as part of the Emacs installation.  This allows to build
 Emacs modules outside of the Emacs source tree.
 
 
-* Startup Changes in Emacs 26.2
-
-
 * Changes in Emacs 26.2
 
----
 ** Emacs is now compliant with the latest version 11.0 of the Unicode Standard.
 
----
 ** New variable 'xft-ignore-color-fonts'.
 Default t means don't try to load color fonts when using Xft, as they
 often cause crashes.  Set it to nil if you really need those fonts.
 
 
-* Editing Changes in Emacs 26.2
-
-
 * Changes in Specialized Modes and Packages in Emacs 26.2
 
 ** Dired
-+++
+
 *** The 'Z' command on a directory name compresses all of its files.
 It produces a compressed '.tar.gz' archive with all the files in the
 directory and all of its subdirectories.  For symmetry, 'Z' on a
@@ -65,17 +82,14 @@ partially called out in its NEWS; 'tgz' handling was added 
in 26.1.)
 
 ** Ibuffer
 
----
 *** New toggle 'ibuffer-do-toggle-lock', bound to 'L'.
 
 ** Imenu
 
----
 *** The value for 'imenu-auto-rescan-maxout' has been increased to 600000.
 
 ** Gnus
 
----
 *** Mailutils movemail will now be used if found at runtime.
 The default value of 'mail-source-movemail-program' is now "movemail".
 This ensures that the movemail program from GNU Mailutils will be used
@@ -85,12 +99,10 @@ absolute file name of the desired executable.
 
 ** Shadowfile
 
----
 *** shadowfile.el has been rewritten to support Tramp file names.
 
 ** Shell mode
 
----
 *** Shell mode buffers now have 'scroll-conservatively' set to 101.
 This is so as to better emulate the scrolling behavior of a text
 terminal when new output is added to the screen buffer.  To get back
@@ -101,13 +113,11 @@ in its NEWS.)
 
 ** VC
 
----
 *** VC support for Mercurial was improved.
 Emacs now avoids invoking 'hg' as much as possible, for faster operation.
 (This and the following changes were actually made in Emacs 26.1, but
 were not called out in its NEWS.)
 
----
 **** New vc-hg options.
 The new option 'vc-hg-parse-hg-data-structures' controls whether vc-hg
 will try parsing the Mercurial data structures directly instead of
@@ -119,7 +129,6 @@ The new option 
'vc-hg-use-file-version-for-mode-line-version' controls
 whether the version shown on the mode line is that of the visited file
 or of the repository working copy.
 
----
 **** Display of Mercurial revisions in the mode line has changed.
 Previously, the mode line displayed the local number (1, 2, 3, ...) of
 the revision.  Starting with Emacs 26.1, the default has changed, and
@@ -128,22 +137,16 @@ hash value.  To get back the previous behavior, customize 
the new
 option 'vc-hg-symbolic-revision-styles' to the value '("{rev}")'.
 
 
-* New Modes and Packages in Emacs 26.2
-
-
 * Incompatible Lisp Changes in Emacs 26.2
 
----
 ** shadowfile config files have changed their syntax.
 Existing files "~/.emacs.d/shadows" and "~/.emacs.d/shadow_todo" must
 be removed prior using the changed 'shadow-*' commands.
 
-+++
 ** 'thread-alive-p' has been renamed to 'thread-live-p'.
 The old name is an alias of the new name.  Future Emacs version will
 obsolete it.
 
----
 ** 'while-no-input' does not return due to input from subprocesses.
 Input that arrived from subprocesses while some code executed inside
 the 'while-no-input' form injected an internal buffer-switch event
@@ -156,22 +159,19 @@ remove 'buffer-switch' from the list of events in
 
 * Lisp Changes in Emacs 26.2
 
-+++
 ** The new function 'read-answer' accepts either long or short answers
 depending on the new customizable variable 'read-answer-short'.
 
-+++
 ** New function 'assoc-delete-all'.
 Like 'assq-delete-all', but uses 'equal' for comparison.
 
----
 ** The function 'thing-at-point' behaves as before Emacs 26.1.
 The behavior of 'thing-at-point' when called with argument 'list' has
 changed in Emacs 26.1, in that it didn't consider text inside comments
 and strings as a potential list.  This change is now reverted, and
 'thing-at-point' behaves like it did before Emacs 26.1.
 
-To cater to use cases where comments and strings are to be ignored
+** To cater to use cases where comments and strings are to be ignored
 when looking for a list, the function 'list-at-point' now takes an
 optional argument to do so.
 
@@ -798,6 +798,9 @@ zone name instead of the numeric form.  The '%z' format 
continues to
 be the numeric form.  The new behavior is compatible with
 'format-time-string'.
 
+*** New user option 'gnus-rcvstore-options' provides a way to
+specify additional options when saving messages to an MH folder.
+
 ** Ibuffer
 
 *** New command 'ibuffer-jump'.
diff --git a/etc/NEXTSTEP b/etc/NEXTSTEP
index f4f2c2e..e5555a9 100644
--- a/etc/NEXTSTEP
+++ b/etc/NEXTSTEP
@@ -1,4 +1,4 @@
-Copyright (C) 2008-2018 Free Software Foundation, Inc.
+Copyright (C) 2008-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 This file contains information about GNU Emacs on "Nextstep" platforms.
diff --git a/etc/NXML-NEWS b/etc/NXML-NEWS
index 250ee17..8bae9b0 100644
--- a/etc/NXML-NEWS
+++ b/etc/NXML-NEWS
@@ -1,4 +1,4 @@
-Copyright (C) 2007-2018 Free Software Foundation, Inc.
+Copyright (C) 2007-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 
diff --git a/etc/ORDERS b/etc/ORDERS
deleted file mode 100644
index 1df755d..0000000
--- a/etc/ORDERS
+++ /dev/null
@@ -1,8 +0,0 @@
-Printed copies of Emacs manuals
-
-Note added January 2014:
-
-This file is obsolete and will be removed in future.
-Please update any links to use
-  info node `(emacs)Printed Books'
-instead.
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 013c7b1..2497501 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -3,7 +3,7 @@ ORG NEWS -- history of user-visible changes.   -*- mode: org; 
coding: utf-8 -*-
 #+LINK: doc https://orgmode.org/worg/doc.html#%s
 #+LINK: git https://code.orgmode.org/bzg/org-mode/commit/%s
 
-Copyright (C) 2012-2018 Free Software Foundation, Inc.
+Copyright (C) 2012-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 Please send Org bug reports to mailto:address@hidden
diff --git a/etc/PROBLEMS b/etc/PROBLEMS
index 0cbcca4..785e6e1 100644
--- a/etc/PROBLEMS
+++ b/etc/PROBLEMS
@@ -1,6 +1,6 @@
 Known Problems with GNU Emacs
 
-Copyright (C) 1987-1989, 1993-1999, 2001-2018 Free Software Foundation,
+Copyright (C) 1987-1989, 1993-1999, 2001-2019 Free Software Foundation,
 Inc.
 See the end of the file for license conditions.
 
@@ -1833,6 +1833,12 @@ term/xterm.el) for more details.
 
 ** GNU/Linux
 
+*** GNU/Linux: profiler-report outputs nothing.
+
+A few versions of the Linux kernel have timer bugs that break CPU
+profiling; see Bug#34235.  To fix the problem, upgrade to one of the
+kernel versions 4.14.97, 4.19.19, or 4.20.6, or later.
+
 *** GNU/Linux: Process output is corrupted.
 
 There is a bug in Linux kernel 2.6.10 PTYs that can cause emacs to
diff --git a/etc/README b/etc/README
index 9a85ce1..ca6f38e 100644
--- a/etc/README
+++ b/etc/README
@@ -7,5 +7,5 @@ COPYRIGHT AND LICENSE INFORMATION FOR IMAGE FILES
 
 File: emacs.icon
   Author: Sun Microsystems, Inc
-  Copyright (C) 1999, 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 1999, 2001-2019 Free Software Foundation, Inc.
   License: GNU General Public License version 3 or later (see COPYING)
diff --git a/etc/TERMS b/etc/TERMS
index cea5932..19b8757 100644
--- a/etc/TERMS
+++ b/etc/TERMS
@@ -1,4 +1,4 @@
-Copyright (C) 1999, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1999, 2001-2019 Free Software Foundation, Inc.
 See the end of the file for copying permissions.
 
 This file describes what you must or might want to do to termcap entries
diff --git a/etc/THE-GNU-PROJECT b/etc/THE-GNU-PROJECT
deleted file mode 100644
index d2aa155..0000000
--- a/etc/THE-GNU-PROJECT
+++ /dev/null
@@ -1,8 +0,0 @@
-The GNU Project
-
-Note added March 2014:
-
-This file is obsolete and will be removed in future.
-Please update any references to use
-
-<https://www.gnu.org/gnu/thegnuproject.html>
diff --git a/etc/TODO b/etc/TODO
index de57974..ccb82cd 100644
--- a/etc/TODO
+++ b/etc/TODO
@@ -1,6 +1,6 @@
 Emacs TODO List                                                   -*-outline-*-
 
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 
diff --git a/etc/WHY-FREE b/etc/WHY-FREE
deleted file mode 100644
index cd2c2fc..0000000
--- a/etc/WHY-FREE
+++ /dev/null
@@ -1,8 +0,0 @@
-Why Software Should Not Have Owners
-
-Note added March 2014:
-
-This file is obsolete and will be removed in future.
-Please update any references to use
-
-<https://www.gnu.org/philosophy/why-free.html>
diff --git a/etc/charsets/README b/etc/charsets/README
index 6366cf7..0cf0368 100644
--- a/etc/charsets/README
+++ b/etc/charsets/README
@@ -1,6 +1,6 @@
 # README file for charset mapping files in this directory.
 
-# Copyright (C) 2003-2018 Free Software Foundation, Inc.
+# Copyright (C) 2003-2019 Free Software Foundation, Inc.
 # Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 #   National Institute of Advanced Industrial Science and Technology (AIST)
 #   Registration Number H13PRO009
diff --git a/etc/compilation.txt b/etc/compilation.txt
index 00bd0eb..eccdfa7 100644
--- a/etc/compilation.txt
+++ b/etc/compilation.txt
@@ -625,7 +625,7 @@ Compilation segmentation fault at Thu Jul 13 10:55:49
 Compilation finished at Thu Jul 21 15:02:15
 
 
-Copyright (C) 2004-2018 Free Software Foundation, Inc.
+Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 COPYING PERMISSIONS:
 
diff --git a/etc/edt-user.el b/etc/edt-user.el
index 535b066..5aede6b 100644
--- a/etc/edt-user.el
+++ b/etc/edt-user.el
@@ -1,6 +1,6 @@
 ;;; edt-user.el --- Sample user customizations for Emacs EDT emulation
 
-;; Copyright (C) 1986, 1992-1993, 2000-2018 Free Software Foundation,
+;; Copyright (C) 1986, 1992-1993, 2000-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Kevin Gallagher <address@hidden>
diff --git a/etc/emacs-buffer.gdb b/etc/emacs-buffer.gdb
index 6bb37f3..efbf75d 100644
--- a/etc/emacs-buffer.gdb
+++ b/etc/emacs-buffer.gdb
@@ -1,6 +1,6 @@
 # emacs-buffer.gdb --- gdb macros for recovering buffers from emacs coredumps
 
-# Copyright (C) 2005-2018 Free Software Foundation, Inc.
+# Copyright (C) 2005-2019 Free Software Foundation, Inc.
 
 # Author: Noah Friedman <address@hidden>
 # Created: 2005-04-28
diff --git a/etc/emacs.appdata.xml b/etc/emacs.appdata.xml
index f4ef0e7..6898de3 100644
--- a/etc/emacs.appdata.xml
+++ b/etc/emacs.appdata.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2014-2018 Free Software Foundation, Inc. -->
+<!-- Copyright (C) 2014-2019 Free Software Foundation, Inc. -->
 <component type="desktop-application">
  <id>org.gnu.emacs</id>
  <metadata_license>GFDL-1.3+</metadata_license>
diff --git a/etc/enriched.txt b/etc/enriched.txt
index bf3e91a..839dd2f 100644
--- a/etc/enriched.txt
+++ b/etc/enriched.txt
@@ -253,7 +253,7 @@ it.</indent>
 
 
 
-Copyright (C) 1995, 1997, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1995, 1997, 2001-2019 Free Software Foundation, Inc.
 
 COPYING PERMISSIONS:
 
diff --git a/etc/forms/forms-d2.el b/etc/forms/forms-d2.el
index 57ace61..eeca3c0 100644
--- a/etc/forms/forms-d2.el
+++ b/etc/forms/forms-d2.el
@@ -1,6 +1,6 @@
 ;;; forms-d2.el --- demo forms-mode
 
-;; Copyright (C) 1991, 1994-1997, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1991, 1994-1997, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Johan Vromans <address@hidden>
diff --git a/etc/gnus-tut.txt b/etc/gnus-tut.txt
index cc6f71d..d9ea4f6 100644
--- a/etc/gnus-tut.txt
+++ b/etc/gnus-tut.txt
@@ -24,7 +24,7 @@ was done by moi, yours truly, your humble servant, Lars Magne
 Ingebrigtsen.  If you have a WWW browser, you can investigate to your
 heart's delight at <URL:http://www.ifi.uio.no/~larsi/larsi.html>.
 
-;; Copyright (C) 1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
diff --git a/etc/grep.txt b/etc/grep.txt
index 75187b9..d01f994 100644
--- a/etc/grep.txt
+++ b/etc/grep.txt
@@ -97,7 +97,7 @@ grep -nH -e "xyzxyz" ../info/*
 
 
 
-Copyright (C) 2005-2018 Free Software Foundation, Inc.
+Copyright (C) 2005-2019 Free Software Foundation, Inc.
 
 COPYING PERMISSIONS:
 
diff --git a/etc/images/README b/etc/images/README
index 34e145e..5989a77 100644
--- a/etc/images/README
+++ b/etc/images/README
@@ -27,19 +27,19 @@ COPYRIGHT AND LICENSE INFORMATION FOR IMAGE FILES
 
 File: mh-logo.xpm
   Author: Satyaki Das
-  Copyright (C) 2003-2018 Free Software Foundation, Inc.
+  Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 Files: gnus.pbm
   Author: Luis Fernandes <address@hidden>
-  Copyright (C) 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 Files: splash.png, splash.svg, splash.pbm, splash.xpm
   Author: Francesc Rocher <address@hidden>
-  Copyright (C) 2008-2018 Free Software Foundation, Inc.
+  Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 Files: checked.xpm, unchecked.xpm
   Author: Chong Yidong <address@hidden>
-  Copyright (C) 2010-2018 Free Software Foundation, Inc.
+  Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 
 * The following icons are from GTK+ 2.x. They are not part of Emacs, but
diff --git a/etc/images/checked.xpm b/etc/images/checked.xpm
index 8d34be2..6ec8c5d 100644
--- a/etc/images/checked.xpm
+++ b/etc/images/checked.xpm
@@ -1,5 +1,5 @@
 /* XPM */
-/* Copyright (C) 2010-2018 Free Software Foundation, Inc.
+/* Copyright (C) 2010-2019 Free Software Foundation, Inc.
  *
  * Author: Chong Yidong <address@hidden>
  *
diff --git a/etc/images/custom/README b/etc/images/custom/README
index e28576a..498f168 100644
--- a/etc/images/custom/README
+++ b/etc/images/custom/README
@@ -6,5 +6,5 @@ COPYRIGHT AND LICENSE INFORMATION FOR IMAGE FILES
 
 Files: down.xpm down-pushed.xpm right.xpm right-pushed.xpm
 Author: Juri Linkov
-Copyright (C) 2008-2018 Free Software Foundation, Inc.
+Copyright (C) 2008-2019 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
diff --git a/etc/images/ezimage/README b/etc/images/ezimage/README
index d30b35c..512cfb9 100644
--- a/etc/images/ezimage/README
+++ b/etc/images/ezimage/README
@@ -7,5 +7,5 @@ Files: bits.xpm bitsbang.xpm box-minus.xpm box-plus.xpm
        tag-gt.xpm tag-minus.xpm tag-plus.xpm tag-type.xpm tag-v.xpm
        tag.xpm unlock.xpm
 Author: Eric M. Ludlam
-Copyright (C) 1999-2018 Free Software Foundation, Inc.
+Copyright (C) 1999-2019 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
diff --git a/etc/images/gnus/README b/etc/images/gnus/README
index a6a5274..b41a944 100644
--- a/etc/images/gnus/README
+++ b/etc/images/gnus/README
@@ -7,7 +7,7 @@ COPYRIGHT AND LICENSE INFORMATION FOR IMAGE FILES
 
 Files: important.xpm, unimportant.xpm
 Author: Simon Josefsson <address@hidden>
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 Files: catchup.pbm catchup.xpm cu-exit.pbm cu-exit.xpm
   describe-group.pbm describe-group.xpm exit-gnus.pbm exit-gnus.xpm
@@ -21,11 +21,11 @@ Files: catchup.pbm catchup.xpm cu-exit.pbm cu-exit.xpm
   unsubscribe.pbm unsubscribe.xpm uu-decode.pbm uu-decode.xpm
   uu-post.pbm uu-post.xpm
 Author: Luis Fernandes <address@hidden>
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 Files: gnus.png, gnus.svg
   Author: Francesc Rocher <address@hidden>
-  Copyright (C) 2008-2018 Free Software Foundation, Inc.
+  Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 
 * The following icons are from GNOME 2.x. They are not part of Emacs,
diff --git a/etc/images/gnus/gnus.svg b/etc/images/gnus/gnus.svg
index 4c1e9e8..ed70274 100644
--- a/etc/images/gnus/gnus.svg
+++ b/etc/images/gnus/gnus.svg
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!-- Gnu Emacs Logo
 
-   Copyright (C) 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
    Author: Francesc Rocher <address@hidden>
 
diff --git a/etc/images/gud/README b/etc/images/gud/README
index 7d36e33..dd63cce 100644
--- a/etc/images/gud/README
+++ b/etc/images/gud/README
@@ -1,7 +1,7 @@
 COPYRIGHT AND LICENSE INFORMATION FOR IMAGE FILES
 
 The following icons were created by Nick Roberts <address@hidden>.
-Copyright (C) 2002-2018 Free Software Foundation, Inc.
+Copyright (C) 2002-2019 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
 
   break.pbm, nexti.pbm, go.pbm, pp.pbm, print.pbm, pstar.pbm, remove.pbm
@@ -31,7 +31,7 @@ their copyright assignment included the icons.
 The following icons are converted from the Insight Windows style icon
 set in src/gdb/gdbtk/library/images2.
 
-Copyright (C) 2002-2018 Free Software Foundation, Inc.
+Copyright (C) 2002-2019 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
 
   cont.pbm and cont.xpm were converted from continue.gif
@@ -47,7 +47,7 @@ License: GNU General Public License version 3 or later (see 
COPYING)
 The following icons are created from the Insight Windows style icon
 set in src/gdb/gdbtk/library/images2.
 
-Copyright (C) 2002-2018 Free Software Foundation, Inc.
+Copyright (C) 2002-2019 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
 
   rcont.xpm rfinish.xpm
diff --git a/etc/images/icons/README b/etc/images/icons/README
index 6f61c0b..55bb1fa 100644
--- a/etc/images/icons/README
+++ b/etc/images/icons/README
@@ -6,7 +6,7 @@ Files: hicolor/16x16/apps/emacs.png hicolor/24x24/apps/emacs.png
        hicolor/scalable/mimetypes/emacs-document.svg
 
 Author: Nicolas Petton <address@hidden>
-Copyright (C) 2015-2018 Free Software Foundation, Inc.
+Copyright (C) 2015-2019 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
 
 Files: hicolor/16x16/apps/emacs23.png hicolor/24x24/apps/emacs23.png
@@ -14,7 +14,7 @@ Files: hicolor/16x16/apps/emacs23.png 
hicolor/24x24/apps/emacs23.png
        hicolor/128x128/apps/emacs23.png hicolor/scalable/apps/emacs23.svg
 
 Author: Kentaro Ohkouchi <address@hidden>
-Copyright (C) 2007-2018 Free Software Foundation, Inc.
+Copyright (C) 2007-2019 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
 
 
@@ -22,7 +22,7 @@ Files: hicolor/16x16/apps/emacs22.png 
hicolor/24x24/apps/emacs22.png
        hicolor/32x32/apps/emacs22.png hicolor/48x48/apps/emacs22.png
 
 Author: Andrew Zhilin <address@hidden>
-Copyright (C) 2005-2018 Free Software Foundation, Inc.
+Copyright (C) 2005-2019 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
 
 Files: allout-widgets-dark-bg/closed.png
@@ -71,5 +71,5 @@ Files: allout-widgets-dark-bg/closed.png
        allout-widgets-light-bg/through-descender.xpm
 
 Author: Ken Manheimer <address@hidden>
-Copyright (C) 2011-2018 Free Software Foundation, Inc.
+Copyright (C) 2011-2019 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
diff --git a/etc/images/icons/hicolor/scalable/apps/emacs.svg 
b/etc/images/icons/hicolor/scalable/apps/emacs.svg
index fdb7d64..e3e3b33 100644
--- a/etc/images/icons/hicolor/scalable/apps/emacs.svg
+++ b/etc/images/icons/hicolor/scalable/apps/emacs.svg
@@ -15,7 +15,7 @@
      id="metadata70"><rdf:RDF><cc:Work
          rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
            rdf:resource="http://purl.org/dc/dcmitype/StillImage"; 
/><dc:title></dc:title></cc:Work></rdf:RDF></metadata><!-- Gnu Emacs Icon
-   Copyright (C) 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
    Author: Nicolas Petton <address@hidden>
 
diff --git a/etc/images/icons/hicolor/scalable/apps/emacs23.svg 
b/etc/images/icons/hicolor/scalable/apps/emacs23.svg
index 35623e7..7303fb9 100644
--- a/etc/images/icons/hicolor/scalable/apps/emacs23.svg
+++ b/etc/images/icons/hicolor/scalable/apps/emacs23.svg
@@ -10,7 +10,7 @@
    id="svg4768"
    xml:space="preserve">
 <!-- Gnu Emacs Icon
-   Copyright (C) 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
    This file is part of GNU Emacs.
 
diff --git a/etc/images/icons/hicolor/scalable/mimetypes/emacs-document23.svg 
b/etc/images/icons/hicolor/scalable/mimetypes/emacs-document23.svg
index 12ab02a..6588596 100644
--- a/etc/images/icons/hicolor/scalable/mimetypes/emacs-document23.svg
+++ b/etc/images/icons/hicolor/scalable/mimetypes/emacs-document23.svg
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!-- Gnu Emacs Document Icon
 
-   Copyright (C) 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
    This file is part of GNU Emacs.
 
diff --git a/etc/images/mh-logo.xpm b/etc/images/mh-logo.xpm
index a627421..fe88c46 100644
--- a/etc/images/mh-logo.xpm
+++ b/etc/images/mh-logo.xpm
@@ -1,7 +1,7 @@
 /* XPM */
 /* MH-E Logo
  *
- * Copyright (C) 2003-2018 Free Software Foundation, Inc.
+ * Copyright (C) 2003-2019 Free Software Foundation, Inc.
  *
  * Author: Satyaki Das
  *
diff --git a/etc/images/mpc/README b/etc/images/mpc/README
index 8d91e24..05821ef 100644
--- a/etc/images/mpc/README
+++ b/etc/images/mpc/README
@@ -2,5 +2,5 @@ COPYRIGHT AND LICENSE INFORMATION FOR IMAGE FILES
 
 Files: add.xpm ffwd.xpm next.xpm pause.xpm play.xpm prev.xpm rewind.xpm 
stop.xpm
 Author: Stefan Monnier <address@hidden>
-Copyright (C) 2009-2018 Free Software Foundation, Inc.
+Copyright (C) 2009-2019 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
diff --git a/etc/images/newsticker/README b/etc/images/newsticker/README
index 290f714..9128e84 100644
--- a/etc/images/newsticker/README
+++ b/etc/images/newsticker/README
@@ -4,5 +4,5 @@ Files: browse-url.xpm get-all.xpm mark-immortal.xpm 
mark-read.xpm
        narrow.xpm next-feed.xpm next-item.xpm prev-feed.xpm
        prev-item.xpm rss-feed.png rss-feed.svg update.xpm
 Author: Ulf Jasper
-Copyright (C) 2011-2018 Free Software Foundation, Inc.
+Copyright (C) 2011-2019 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
diff --git a/etc/images/smilies/README b/etc/images/smilies/README
index 5387d3b..3033df3 100644
--- a/etc/images/smilies/README
+++ b/etc/images/smilies/README
@@ -3,5 +3,5 @@ Files: blink.pbm blink.xpm braindamaged.xpm cry.xpm dead.xpm 
evil.xpm
        sad.xpm smile.pbm smile.xpm wry.pbm wry.xpm
 Authors: Reiner Steib, Simon Josefsson, Kai Grossjohann, Alex
          Schroeder, Oliver Scholz, Per Abrahamsen, Kim F. Storm.
-Copyright (C) 1999-2018 Free Software Foundation, Inc.
+Copyright (C) 1999-2019 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
diff --git a/etc/images/smilies/grayscale/README 
b/etc/images/smilies/grayscale/README
index d83c059..acb2c66 100644
--- a/etc/images/smilies/grayscale/README
+++ b/etc/images/smilies/grayscale/README
@@ -3,5 +3,5 @@ Files: blink.xpm braindamaged.xpm cry.xpm dead.xpm evil.xpm 
forced.xpm
        frown.xpm grin.xpm indifferent.xpm reverse-smile.xpm sad.xpm
        smile.xpm wry.xpm
 Author: Adam Sjøgren
-Copyright (C) 2007-2018 Free Software Foundation, Inc.
+Copyright (C) 2007-2019 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
diff --git a/etc/images/smilies/medium/README b/etc/images/smilies/medium/README
index d83c059..acb2c66 100644
--- a/etc/images/smilies/medium/README
+++ b/etc/images/smilies/medium/README
@@ -3,5 +3,5 @@ Files: blink.xpm braindamaged.xpm cry.xpm dead.xpm evil.xpm 
forced.xpm
        frown.xpm grin.xpm indifferent.xpm reverse-smile.xpm sad.xpm
        smile.xpm wry.xpm
 Author: Adam Sjøgren
-Copyright (C) 2007-2018 Free Software Foundation, Inc.
+Copyright (C) 2007-2019 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
diff --git a/etc/images/splash.svg b/etc/images/splash.svg
index 9a08f16..f21f1dc 100644
--- a/etc/images/splash.svg
+++ b/etc/images/splash.svg
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!-- Gnu Emacs Logo
 
-   Copyright (C) 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
    Author: Francesc Rocher <address@hidden>
    Based on the original work by Luis Fernandes <address@hidden>
diff --git a/etc/images/tree-widget/default/README 
b/etc/images/tree-widget/default/README
index 07a1dcb..7632e16 100644
--- a/etc/images/tree-widget/default/README
+++ b/etc/images/tree-widget/default/README
@@ -5,5 +5,5 @@ Files: close.png close.xpm empty.png empty.xpm end-guide.png 
end-guide.xpm
        no-guide.png no-guide.xpm no-handle.png no-handle.xpm open.png
        open.xpm
 Author: David Ponce <address@hidden>
-Copyright (C) 2004-2018 Free Software Foundation, Inc.
+Copyright (C) 2004-2019 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
diff --git a/etc/images/tree-widget/folder/README 
b/etc/images/tree-widget/folder/README
index c4a97ff..49198e0 100644
--- a/etc/images/tree-widget/folder/README
+++ b/etc/images/tree-widget/folder/README
@@ -5,5 +5,5 @@ Files:  close.png close.xpm empty.png empty.xpm end-guide.png
         leaf.png leaf.xpm no-guide.png no-guide.xpm no-handle.png
         no-handle.xpm open.png open.xpm
 Author: David Ponce <address@hidden>
-Copyright (C) 2004-2018 Free Software Foundation, Inc.
+Copyright (C) 2004-2019 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
diff --git a/etc/images/unchecked.xpm b/etc/images/unchecked.xpm
index c364375..b51ee3d 100644
--- a/etc/images/unchecked.xpm
+++ b/etc/images/unchecked.xpm
@@ -1,5 +1,5 @@
 /* XPM */
-/* Copyright (C) 2010-2018 Free Software Foundation, Inc.
+/* Copyright (C) 2010-2019 Free Software Foundation, Inc.
  *
  * Author: Chong Yidong <address@hidden>
  *
diff --git a/etc/org/README b/etc/org/README
index 7c175e3..496ccb0 100644
--- a/etc/org/README
+++ b/etc/org/README
@@ -1,7 +1,7 @@
 The files OrgOdtContentTemplate.xml and OrgOdtStyles.xml have the
 following copyright information:
 
-Copyright (C) 2010-2018 Free Software Foundation, Inc.
+Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 These files are part of GNU Emacs.
 
diff --git a/etc/package-keyring.gpg b/etc/package-keyring.gpg
index e76e685..490dee4 100644
Binary files a/etc/package-keyring.gpg and b/etc/package-keyring.gpg differ
diff --git a/etc/ps-prin0.ps b/etc/ps-prin0.ps
index 70ed268..16ead7f 100644
--- a/etc/ps-prin0.ps
+++ b/etc/ps-prin0.ps
@@ -1,7 +1,7 @@
 % === BEGIN ps-print prologue 0
 % version: 6.0
 
-% Copyright (C) 2000-2018 Free Software Foundation, Inc.
+% Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 % This file is part of GNU Emacs.
 
diff --git a/etc/ps-prin1.ps b/etc/ps-prin1.ps
index 8ac2951..8588d5d 100644
--- a/etc/ps-prin1.ps
+++ b/etc/ps-prin1.ps
@@ -1,7 +1,7 @@
 % === BEGIN ps-print prologue 1
 % version: 6.1
 
-% Copyright (C) 2000-2018 Free Software Foundation, Inc.
+% Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 % This file is part of GNU Emacs.
 
diff --git a/etc/refcards/Makefile b/etc/refcards/Makefile
index a3c8e55..469e8fa 100644
--- a/etc/refcards/Makefile
+++ b/etc/refcards/Makefile
@@ -1,6 +1,6 @@
 ### Makefile for Emacs refcards
 
-## Copyright (C) 1993-1994, 2001-2018 Free Software Foundation, Inc.
+## Copyright (C) 1993-1994, 2001-2019 Free Software Foundation, Inc.
 
 ## This file is part of GNU Emacs.
 #
diff --git a/etc/refcards/README b/etc/refcards/README
index 1c3e5be..9e85830 100644
--- a/etc/refcards/README
+++ b/etc/refcards/README
@@ -1,4 +1,4 @@
-Copyright (C) 2013-2018 Free Software Foundation, Inc.
+Copyright (C) 2013-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 
@@ -32,7 +32,7 @@ it is reproduced here for convenience.
 
 File: gnus-logo.eps, gnus-logo.pdf
   Author: Luis Fernandes <address@hidden>
-  Copyright (C) 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 2001-2019 Free Software Foundation, Inc.
   License: GNU General Public License version 3 or later (see COPYING)
 
 
diff --git a/etc/refcards/calccard.tex b/etc/refcards/calccard.tex
index 08c9cf7..2b85536 100644
--- a/etc/refcards/calccard.tex
+++ b/etc/refcards/calccard.tex
@@ -20,7 +20,7 @@
 % Typical command to format:  tex calccard.tex
 % Typical command to print (3 cols):  dvips -t landscape calccard.dvi
 
-% Copyright (C) 1987, 1992, 2001-2018 Free Software Foundation, Inc.
+% Copyright (C) 1987, 1992, 2001-2019 Free Software Foundation, Inc.
 
 % This document is free software: you can redistribute it and/or modify
 % it under the terms of the GNU General Public License as published by
diff --git a/etc/refcards/cs-dired-ref.tex b/etc/refcards/cs-dired-ref.tex
index a0a173d..172a2c6 100644
--- a/etc/refcards/cs-dired-ref.tex
+++ b/etc/refcards/cs-dired-ref.tex
@@ -1,6 +1,6 @@
 % Reference Card for Dired -*- coding: utf-8 -*-
 
-% Copyright (C) 2000-2018 Free Software Foundation, Inc.
+% Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 % Author: Evgeny Roubinchtein <address@hidden>
 % Czech translation: Pavel Janík <address@hidden>, March 2001
diff --git a/etc/refcards/cs-refcard.tex b/etc/refcards/cs-refcard.tex
index 499e74d..ca7d833 100644
--- a/etc/refcards/cs-refcard.tex
+++ b/etc/refcards/cs-refcard.tex
@@ -1,6 +1,6 @@
 % Reference Card for GNU Emacs -*- coding: utf-8 -*-
 
-% Copyright (C) 1987, 1993, 1996-1997, 2001-2018 Free Software
+% Copyright (C) 1987, 1993, 1996-1997, 2001-2019 Free Software
 % Foundation, Inc.
 
 % Author: Stephen Gildea <address@hidden>
diff --git a/etc/refcards/cs-survival.tex b/etc/refcards/cs-survival.tex
index 574e5d2..b91c9c9 100644
--- a/etc/refcards/cs-survival.tex
+++ b/etc/refcards/cs-survival.tex
@@ -1,6 +1,6 @@
 % Title:  GNU Emacs Survival Card -*- coding: utf-8 -*-
 
-% Copyright (C) 2000-2018 Free Software Foundation, Inc.
+% Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 % Author: Wlodek Bzyl <address@hidden>
 % Czech translation: Pavel Janík <address@hidden>, March 2001
diff --git a/etc/refcards/de-refcard.tex b/etc/refcards/de-refcard.tex
index 7ea0968..06b6efe 100644
--- a/etc/refcards/de-refcard.tex
+++ b/etc/refcards/de-refcard.tex
@@ -1,6 +1,6 @@
 % Reference Card for GNU Emacs
 
-% Copyright (C) 1987, 1993, 1996, 2000-2018 Free Software Foundation,
+% Copyright (C) 1987, 1993, 1996, 2000-2019 Free Software Foundation,
 % Inc.
 
 % Author: Stephen Gildea <address@hidden>
diff --git a/etc/refcards/dired-ref.tex b/etc/refcards/dired-ref.tex
index 1e659dc..370ab84 100644
--- a/etc/refcards/dired-ref.tex
+++ b/etc/refcards/dired-ref.tex
@@ -1,6 +1,6 @@
 % Reference Card for Dired
 
-% Copyright (C) 2000-2018 Free Software Foundation, Inc.
+% Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 % Author: Evgeny Roubinchtein <address@hidden>
 
diff --git a/etc/refcards/emacsver.tex.in b/etc/refcards/emacsver.tex.in
index 674f90c..9c2680c 100644
--- a/etc/refcards/emacsver.tex.in
+++ b/etc/refcards/emacsver.tex.in
@@ -2,4 +2,4 @@
 address@hidden@}           % major version of emacs
 %% This one should not be automatically updated;
 %% M-x set-copyright in admin.el handles it.
-\def\year{2018}                             % latest copyright year
+\def\year{2019}                             % latest copyright year
diff --git a/etc/refcards/fr-dired-ref.tex b/etc/refcards/fr-dired-ref.tex
index 013f872..fbd9f89 100644
--- a/etc/refcards/fr-dired-ref.tex
+++ b/etc/refcards/fr-dired-ref.tex
@@ -1,6 +1,6 @@
 % Reference Card for Dired -*- coding: utf-8 -*-
 
-% Copyright (C) 2000-2018 Free Software Foundation, Inc.
+% Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 % Author: Evgeny Roubinchtein <address@hidden>
 % French translation: Eric Jacoboni
diff --git a/etc/refcards/fr-refcard.tex b/etc/refcards/fr-refcard.tex
index 24f3c93..0ebf791 100644
--- a/etc/refcards/fr-refcard.tex
+++ b/etc/refcards/fr-refcard.tex
@@ -1,6 +1,6 @@
 % Reference Card for GNU Emacs
 
-% Copyright (C) 1987, 1993, 1996-1997, 2001-2018 Free Software
+% Copyright (C) 1987, 1993, 1996-1997, 2001-2019 Free Software
 % Foundation, Inc.
 
 % Author: Stephen Gildea <address@hidden>
diff --git a/etc/refcards/fr-survival.tex b/etc/refcards/fr-survival.tex
index a622642..2075549 100644
--- a/etc/refcards/fr-survival.tex
+++ b/etc/refcards/fr-survival.tex
@@ -1,7 +1,7 @@
 %&tex
 % Title:  GNU Emacs Survival Card
 
-% Copyright (C) 2000-2018 Free Software Foundation, Inc.
+% Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 % Author: Wlodek Bzyl <address@hidden>
 % French translation:  \'Eric Jacoboni <address@hidden>, November 2001
diff --git a/etc/refcards/gnus-logo.eps b/etc/refcards/gnus-logo.eps
index 44a1b7b..fd2fea2 100644
--- a/etc/refcards/gnus-logo.eps
+++ b/etc/refcards/gnus-logo.eps
@@ -1,5 +1,5 @@
 %!PS-Adobe-2.0 EPSF-2.0
-% Copyright (C) 2000-2018 Free Software Foundation, Inc.
+% Copyright (C) 2000-2019 Free Software Foundation, Inc.
 %
 % Author: Luis Fernandes <address@hidden>
 %
diff --git a/etc/refcards/gnus-refcard.tex b/etc/refcards/gnus-refcard.tex
index 422c3d9..a16f48d 100644
--- a/etc/refcards/gnus-refcard.tex
+++ b/etc/refcards/gnus-refcard.tex
@@ -120,7 +120,7 @@
 %% Gnus logo by Luis Fernandes.
 \newcommand{\Copyright}{%
   \begin{center}
-    Copyright \copyright\ 1995, 2000, 2002--2018 Free Software Foundation, 
Inc.\\*
+    Copyright \copyright\ 1995, 2000, 2002--2019 Free Software Foundation, 
Inc.\\*
   \end{center}
 
   Released under the terms of the GNU General Public License version 3 or 
later.
diff --git a/etc/refcards/orgcard.tex b/etc/refcards/orgcard.tex
index 91cc03f..ae4e26c 100644
--- a/etc/refcards/orgcard.tex
+++ b/etc/refcards/orgcard.tex
@@ -17,7 +17,7 @@
 \pdflayout=(0l)
 
 % Nothing else needs to be changed below this line.
-% Copyright (C) 1987, 1993, 1996-1997, 2001-2018 Free Software
+% Copyright (C) 1987, 1993, 1996-1997, 2001-2019 Free Software
 % Foundation, Inc.
 
 % This document is free software: you can redistribute it and/or modify
diff --git a/etc/refcards/pdflayout.sty b/etc/refcards/pdflayout.sty
index e2fd4e0..b2ca739 100644
--- a/etc/refcards/pdflayout.sty
+++ b/etc/refcards/pdflayout.sty
@@ -1,4 +1,4 @@
-% Copyright (C) 2007-2018 Free Software Foundation, Inc.
+% Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 % This file is part of GNU Emacs.
 
diff --git a/etc/refcards/pl-refcard.tex b/etc/refcards/pl-refcard.tex
index ce5f603..578a8f6 100644
--- a/etc/refcards/pl-refcard.tex
+++ b/etc/refcards/pl-refcard.tex
@@ -1,7 +1,7 @@
 %&mex
 % Reference Card for GNU Emacs
 
-% Copyright (C) 1999, 2001-2018 Free Software Foundation, Inc.
+% Copyright (C) 1999, 2001-2019 Free Software Foundation, Inc.
 
 % Author: Stephen Gildea <address@hidden>
 % Polish translation: W{\l}odek Bzyl <address@hidden>
diff --git a/etc/refcards/pt-br-refcard.tex b/etc/refcards/pt-br-refcard.tex
index 50cf511..04ce77d 100644
--- a/etc/refcards/pt-br-refcard.tex
+++ b/etc/refcards/pt-br-refcard.tex
@@ -1,6 +1,6 @@
 % Reference Card for GNU Emacs
 
-% Copyright (C) 1987, 1993, 1996-1997, 2002-2004, 2006-2018 Free
+% Copyright (C) 1987, 1993, 1996-1997, 2002-2004, 2006-2019 Free
 % Software Foundation, Inc.
 
 % Author: Stephen Gildea <address@hidden>
diff --git a/etc/refcards/refcard.tex b/etc/refcards/refcard.tex
index 74db197..5089133 100644
--- a/etc/refcards/refcard.tex
+++ b/etc/refcards/refcard.tex
@@ -1,6 +1,6 @@
 % Reference Card for GNU Emacs
 
-% Copyright (C) 1987, 1993, 1996-1997, 2001-2018 Free Software
+% Copyright (C) 1987, 1993, 1996-1997, 2001-2019 Free Software
 % Foundation, Inc.
 
 % Author: Stephen Gildea <address@hidden>
diff --git a/etc/refcards/ru-refcard.tex b/etc/refcards/ru-refcard.tex
index 0c4cfbe..43c18d5 100644
--- a/etc/refcards/ru-refcard.tex
+++ b/etc/refcards/ru-refcard.tex
@@ -1,4 +1,4 @@
-% Copyright (C) 1997, 2002-2018 Free Software Foundation, Inc.
+% Copyright (C) 1997, 2002-2019 Free Software Foundation, Inc.
 
 % Author: Stephen Gildea <address@hidden>
 % Russian translation: Alex Ott <address@hidden>
@@ -41,7 +41,7 @@
 \setlength{\ColThreeWidth}{25mm}
 
 \newcommand{\versionemacs}[0]{27} % version of Emacs this is for
-\newcommand{\cyear}[0]{2018}       % copyright year
+\newcommand{\cyear}[0]{2019}       % copyright year
 
 \newcommand\shortcopyrightnotice[0]{\vskip 1ex plus 2 fill
   \centerline{\footnotesize \copyright\ \cyear\ Free Software Foundation, Inc.
diff --git a/etc/refcards/sk-dired-ref.tex b/etc/refcards/sk-dired-ref.tex
index 334a51c..7b550d2 100644
--- a/etc/refcards/sk-dired-ref.tex
+++ b/etc/refcards/sk-dired-ref.tex
@@ -1,6 +1,6 @@
 % Reference Card for Dired -*- coding: utf-8 -*-
 
-% Copyright (C) 2000-2018 Free Software Foundation, Inc.
+% Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 % Author: Evgeny Roubinchtein <address@hidden>
 % Czech translation: Pavel Janík <address@hidden>, March 2001
diff --git a/etc/refcards/sk-refcard.tex b/etc/refcards/sk-refcard.tex
index 7f83332..823913a 100644
--- a/etc/refcards/sk-refcard.tex
+++ b/etc/refcards/sk-refcard.tex
@@ -1,6 +1,6 @@
 % Reference Card for GNU Emacs -*- coding: utf-8 -*-
 
-% Copyright (C) 1987, 1993, 1996-1997, 2001-2018 Free Software
+% Copyright (C) 1987, 1993, 1996-1997, 2001-2019 Free Software
 % Foundation, Inc.
 
 % Author: Stephen Gildea <address@hidden>
diff --git a/etc/refcards/sk-survival.tex b/etc/refcards/sk-survival.tex
index b063708..b63a618 100644
--- a/etc/refcards/sk-survival.tex
+++ b/etc/refcards/sk-survival.tex
@@ -1,6 +1,6 @@
 % Title:  GNU Emacs Survival Card -*- coding: utf-8 -*-
 
-% Copyright (C) 2000-2018 Free Software Foundation, Inc.
+% Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 % Author: Wlodek Bzyl <address@hidden>
 % Czech translation: Pavel Janík <address@hidden>, March 2001
diff --git a/etc/refcards/survival.tex b/etc/refcards/survival.tex
index 63fdde1..5dbe788 100644
--- a/etc/refcards/survival.tex
+++ b/etc/refcards/survival.tex
@@ -1,7 +1,7 @@
 %&tex
 % Title:  GNU Emacs Survival Card
 
-% Copyright (C) 2000-2018 Free Software Foundation, Inc.
+% Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 % Author: Wlodek Bzyl <address@hidden>
 
diff --git a/etc/refcards/vipcard.tex b/etc/refcards/vipcard.tex
index a5e47d0..87cf4ad 100644
--- a/etc/refcards/vipcard.tex
+++ b/etc/refcards/vipcard.tex
@@ -1,6 +1,6 @@
 % Quick Reference Card for VIP
 
-% Copyright (C) 1987, 2001-2018 Free Software Foundation, Inc.
+% Copyright (C) 1987, 2001-2019 Free Software Foundation, Inc.
 
 % Author: Masahiko Sato <address@hidden>, <address@hidden>
 
diff --git a/etc/refcards/viperCard.tex b/etc/refcards/viperCard.tex
index 7cf6533..fb116d4 100644
--- a/etc/refcards/viperCard.tex
+++ b/etc/refcards/viperCard.tex
@@ -1,6 +1,6 @@
 % ViperCard -- The Reference Card for Viper under GNU Emacs and XEmacs
 
-% Copyright (C) 1995-1997, 2001-2018 Free Software Foundation, Inc.
+% Copyright (C) 1995-1997, 2001-2019 Free Software Foundation, Inc.
 
 % Author: Michael Kifer <address@hidden> (Viper)
 %      Aamod Sane <address@hidden> (VIP 4.3)
diff --git a/etc/schema/locate.rnc b/etc/schema/locate.rnc
index 0aec85c..e31eb1f 100644
--- a/etc/schema/locate.rnc
+++ b/etc/schema/locate.rnc
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2004, 2007-2018 Free Software Foundation, Inc.
+# Copyright (C) 2003-2004, 2007-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
diff --git a/etc/schema/relaxng.rnc b/etc/schema/relaxng.rnc
index ff030c9..125d2e2 100644
--- a/etc/schema/relaxng.rnc
+++ b/etc/schema/relaxng.rnc
@@ -1,6 +1,6 @@
 # RELAX NG XML syntax expressed in RELAX NG Compact syntax.
 
-# Copyright (C) 2003-2004, 2007-2018 Free Software Foundation, Inc.
+# Copyright (C) 2003-2004, 2007-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
diff --git a/etc/schema/schemas.xml b/etc/schema/schemas.xml
index 6121b7d..a9c14dd 100644
--- a/etc/schema/schemas.xml
+++ b/etc/schema/schemas.xml
@@ -1,4 +1,4 @@
-<!-- Copyright (C) 2003-2004, 2007-2018 Free Software Foundation, Inc.
+<!-- Copyright (C) 2003-2004, 2007-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/etc/ses-example.ses b/etc/ses-example.ses
index fb06e62..665ec48 100644
--- a/etc/ses-example.ses
+++ b/etc/ses-example.ses
@@ -205,7 +205,7 @@ Sales summary - Acme fundraising
 ;;; ses--symbolic-formulas: (("Eastern area") ("West-district") 
("North&South") ("Other"))
 ;;; End:
 
-;;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;;; COPYING PERMISSIONS:
 ;;; 
diff --git a/etc/srecode/c.srt b/etc/srecode/c.srt
index 7d05ade..d1710c9 100644
--- a/etc/srecode/c.srt
+++ b/etc/srecode/c.srt
@@ -1,6 +1,6 @@
 ;;; c.srt --- SRecode templates for c-mode
 
-;; Copyright (C) 2007-2010, 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2010, 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/etc/srecode/cpp.srt b/etc/srecode/cpp.srt
index b5acac1..79b62b3 100644
--- a/etc/srecode/cpp.srt
+++ b/etc/srecode/cpp.srt
@@ -1,6 +1,6 @@
 ;;; cpp.srt --- SRecode templates for c++-mode
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/etc/srecode/default.srt b/etc/srecode/default.srt
index 1fc37c2..693cc95 100644
--- a/etc/srecode/default.srt
+++ b/etc/srecode/default.srt
@@ -1,6 +1,6 @@
 ;;; default.srt --- SRecode templates for srecode-template-mode
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/etc/srecode/doc-cpp.srt b/etc/srecode/doc-cpp.srt
index a696711..f7a0af6 100644
--- a/etc/srecode/doc-cpp.srt
+++ b/etc/srecode/doc-cpp.srt
@@ -1,6 +1,6 @@
 ;; doc-c.srt --- SRecode templates for "document" applications
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/etc/srecode/doc-default.srt b/etc/srecode/doc-default.srt
index 019191a..1f1cb4e 100644
--- a/etc/srecode/doc-default.srt
+++ b/etc/srecode/doc-default.srt
@@ -1,6 +1,6 @@
 ;; doc-default.srt --- SRecode templates for "document" applications
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/etc/srecode/doc-java.srt b/etc/srecode/doc-java.srt
index b4a76d1..659a8e9 100644
--- a/etc/srecode/doc-java.srt
+++ b/etc/srecode/doc-java.srt
@@ -1,6 +1,6 @@
 ;; doc-java.srt --- SRecode templates for "document" applications
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/etc/srecode/ede-autoconf.srt b/etc/srecode/ede-autoconf.srt
index 17e9a0e..1f5a271 100644
--- a/etc/srecode/ede-autoconf.srt
+++ b/etc/srecode/ede-autoconf.srt
@@ -1,6 +1,6 @@
 ;;; ede/templates/autoconf.srt --- Templates for autoconf used by EDE
 
-;; Copyright (C) 2010, 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010, 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/etc/srecode/ede-make.srt b/etc/srecode/ede-make.srt
index da0f02d..edf34a0 100644
--- a/etc/srecode/ede-make.srt
+++ b/etc/srecode/ede-make.srt
@@ -1,6 +1,6 @@
 ;; ede-make.srt --- SRecode templates for Makefiles used by EDE.
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/etc/srecode/el.srt b/etc/srecode/el.srt
index e0a54a7..5d5a2ec 100644
--- a/etc/srecode/el.srt
+++ b/etc/srecode/el.srt
@@ -1,6 +1,6 @@
 ;;; el.srt --- SRecode templates for Emacs Lisp mode
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Ludlam <address@hidden>
 
diff --git a/etc/srecode/getset-cpp.srt b/etc/srecode/getset-cpp.srt
index c7032cf..cdb06dc 100644
--- a/etc/srecode/getset-cpp.srt
+++ b/etc/srecode/getset-cpp.srt
@@ -1,6 +1,6 @@
 ;;; getset-cpp.srt --- SRecode templates for C++ class getter/setters.
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/etc/srecode/java.srt b/etc/srecode/java.srt
index df19192..f9e67b7 100644
--- a/etc/srecode/java.srt
+++ b/etc/srecode/java.srt
@@ -1,6 +1,6 @@
 ;; java.srt
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/etc/srecode/make.srt b/etc/srecode/make.srt
index 509ec0d..1288acb 100644
--- a/etc/srecode/make.srt
+++ b/etc/srecode/make.srt
@@ -1,6 +1,6 @@
 ;; make.srt
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/etc/srecode/template.srt b/etc/srecode/template.srt
index 464b11f..a651e32 100644
--- a/etc/srecode/template.srt
+++ b/etc/srecode/template.srt
@@ -1,6 +1,6 @@
 ;;; template.srt --- Templates for Semantic Recoders
 
-;; Copyright (C) 2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Ludlam <address@hidden>
 
diff --git a/etc/srecode/test.srt b/etc/srecode/test.srt
index b09f2f1..79f9dd0 100644
--- a/etc/srecode/test.srt
+++ b/etc/srecode/test.srt
@@ -1,6 +1,6 @@
 ;; test.srt --- SRecode templates for testing
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/etc/srecode/texi.srt b/etc/srecode/texi.srt
index d214567..d696cc0 100644
--- a/etc/srecode/texi.srt
+++ b/etc/srecode/texi.srt
@@ -1,6 +1,6 @@
 ;; texi.srt --- SRecode templates for Texinfo
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/etc/srecode/wisent.srt b/etc/srecode/wisent.srt
index 0c92d73..40fe942 100644
--- a/etc/srecode/wisent.srt
+++ b/etc/srecode/wisent.srt
@@ -1,6 +1,6 @@
 ;; wisent.srt --- SRecode templates for Emacs/WISENT grammar files.
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/etc/themes/adwaita-theme.el b/etc/themes/adwaita-theme.el
index 415db8a..73ef7b6 100644
--- a/etc/themes/adwaita-theme.el
+++ b/etc/themes/adwaita-theme.el
@@ -1,6 +1,6 @@
 ;;; adwaita-theme.el --- Tango-based custom theme for faces
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: William Stevenson <address@hidden>
 
diff --git a/etc/themes/deeper-blue-theme.el b/etc/themes/deeper-blue-theme.el
index 0700f4f..d04a270 100644
--- a/etc/themes/deeper-blue-theme.el
+++ b/etc/themes/deeper-blue-theme.el
@@ -1,6 +1,6 @@
 ;;; deeper-blue-theme.el --- Custom theme for faces
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Scott Frazer <address@hidden>
 
diff --git a/etc/themes/dichromacy-theme.el b/etc/themes/dichromacy-theme.el
index bfced43..b361fe5 100644
--- a/etc/themes/dichromacy-theme.el
+++ b/etc/themes/dichromacy-theme.el
@@ -1,6 +1,6 @@
 ;;; dichromacy-theme.el --- color theme suitable for color-blind users
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Chong Yidong <address@hidden>
 
diff --git a/etc/themes/leuven-theme.el b/etc/themes/leuven-theme.el
index c3c6665..d544f28 100644
--- a/etc/themes/leuven-theme.el
+++ b/etc/themes/leuven-theme.el
@@ -1,6 +1,6 @@
 ;;; leuven-theme.el --- Awesome Emacs color theme on white background
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author: Fabrice Niessen <(concat "fniessen" at-sign "pirilampo.org")>
 ;; URL: https://github.com/fniessen/emacs-leuven-theme
diff --git a/etc/themes/light-blue-theme.el b/etc/themes/light-blue-theme.el
index ba00db6..3060dcf 100644
--- a/etc/themes/light-blue-theme.el
+++ b/etc/themes/light-blue-theme.el
@@ -1,6 +1,6 @@
 ;;; light-blue-theme.el --- Custom theme for faces
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Drew Adams <address@hidden>
 
diff --git a/etc/themes/manoj-dark-theme.el b/etc/themes/manoj-dark-theme.el
index ddcaa0b..b6bf9bf 100644
--- a/etc/themes/manoj-dark-theme.el
+++ b/etc/themes/manoj-dark-theme.el
@@ -1,6 +1,6 @@
 ;;; manoj-dark.el --- A dark theme from Manoj
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Manoj Srivastava <address@hidden>
 ;; Keywords: lisp, faces
diff --git a/etc/themes/misterioso-theme.el b/etc/themes/misterioso-theme.el
index 6c1eec0..cac76d6 100644
--- a/etc/themes/misterioso-theme.el
+++ b/etc/themes/misterioso-theme.el
@@ -1,6 +1,6 @@
 ;;; misterioso-theme.el --- Custom face theme for Emacs
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Sebastian Hermida
 
diff --git a/etc/themes/tango-dark-theme.el b/etc/themes/tango-dark-theme.el
index dae77a5..bd99790 100644
--- a/etc/themes/tango-dark-theme.el
+++ b/etc/themes/tango-dark-theme.el
@@ -1,6 +1,6 @@
 ;;; tango-dark-theme.el --- Tango-based custom theme for faces
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Authors: Chong Yidong <address@hidden>
 ;;          Jan Moringen <address@hidden>
diff --git a/etc/themes/tango-theme.el b/etc/themes/tango-theme.el
index 4fe2480..12d4db3f 100644
--- a/etc/themes/tango-theme.el
+++ b/etc/themes/tango-theme.el
@@ -1,6 +1,6 @@
 ;;; tango-theme.el --- Tango-based custom theme for faces
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Authors: Chong Yidong <address@hidden>
 ;;          Jan Moringen <address@hidden>
diff --git a/etc/themes/tsdh-dark-theme.el b/etc/themes/tsdh-dark-theme.el
index c216750..5482ced 100644
--- a/etc/themes/tsdh-dark-theme.el
+++ b/etc/themes/tsdh-dark-theme.el
@@ -1,6 +1,6 @@
 ;;; tsdh-dark-theme.el --- Tassilo's dark custom theme
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/etc/themes/tsdh-light-theme.el b/etc/themes/tsdh-light-theme.el
index ce9d1a2..8e6a79f 100644
--- a/etc/themes/tsdh-light-theme.el
+++ b/etc/themes/tsdh-light-theme.el
@@ -1,6 +1,6 @@
 ;;; tsdh-light-theme.el --- Tassilo's light custom theme
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/etc/themes/wheatgrass-theme.el b/etc/themes/wheatgrass-theme.el
index 8d34c28..2e18eb9 100644
--- a/etc/themes/wheatgrass-theme.el
+++ b/etc/themes/wheatgrass-theme.el
@@ -1,6 +1,6 @@
 ;;; wheatgrass-theme.el --- custom theme for faces
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/etc/themes/whiteboard-theme.el b/etc/themes/whiteboard-theme.el
index fe46cb0..75c6c1c 100644
--- a/etc/themes/whiteboard-theme.el
+++ b/etc/themes/whiteboard-theme.el
@@ -1,6 +1,6 @@
 ;;; whiteboard-theme.el --- Custom theme for faces
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Scott Frazer <address@hidden>
 
diff --git a/etc/themes/wombat-theme.el b/etc/themes/wombat-theme.el
index 00f29bb..c56700f 100644
--- a/etc/themes/wombat-theme.el
+++ b/etc/themes/wombat-theme.el
@@ -1,6 +1,6 @@
 ;;; wombat-theme.el --- Custom face theme for Emacs
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Kristoffer Grönlund <address@hidden>
 
diff --git a/etc/tutorials/TUTORIAL b/etc/tutorials/TUTORIAL
index ac3ab76..3f5f116 100644
--- a/etc/tutorials/TUTORIAL
+++ b/etc/tutorials/TUTORIAL
@@ -704,7 +704,7 @@ Emacs deletes its auto save file.
 If the computer crashes, you can recover your auto-saved editing by
 finding the file normally (the file you were editing, not the auto
 save file) and then typing M-x recover-this-file <Return>.  When it
-asks fo confirmation, type yes<Return> to go ahead and recover the
+asks for confirmation, type yes<Return> to go ahead and recover the
 auto-save data.
 
 
@@ -1116,7 +1116,7 @@ starting with the one written by Stuart Cracraft for the 
original Emacs.
 This version of the tutorial is a part of GNU Emacs.  It is copyrighted
 and comes with permission to distribute copies on certain conditions:
 
-  Copyright (C) 1985, 1996, 1998, 2001-2018 Free Software Foundation,
+  Copyright (C) 1985, 1996, 1998, 2001-2019 Free Software Foundation,
   Inc.
 
   This file is part of GNU Emacs.
diff --git a/etc/tutorials/TUTORIAL.bg b/etc/tutorials/TUTORIAL.bg
index f31ce57..fa7f743 100644
--- a/etc/tutorials/TUTORIAL.bg
+++ b/etc/tutorials/TUTORIAL.bg
@@ -1162,7 +1162,7 @@ Dired ви позволява да гледате списъка от файло
 This version of the tutorial, like GNU Emacs, is copyrighted, and
 comes with permission to distribute copies on certain conditions:
 
-  Copyright (C) 1985, 1996, 1998, 2001-2018 Free Software Foundation,
+  Copyright (C) 1985, 1996, 1998, 2001-2019 Free Software Foundation,
   Inc.
 
   This file is part of GNU Emacs.
diff --git a/etc/tutorials/TUTORIAL.cn b/etc/tutorials/TUTORIAL.cn
index b2efa6e..e927ac2 100644
--- a/etc/tutorials/TUTORIAL.cn
+++ b/etc/tutorials/TUTORIAL.cn
@@ -997,7 +997,7 @@ starting with the one written by Stuart Cracraft for the 
original Emacs.
 This version of the tutorial is a part of GNU Emacs.  It is copyrighted
 and comes with permission to distribute copies on certain conditions:
 
-  Copyright (C) 1985, 1996, 1998, 2001-2018 Free Software Foundation,
+  Copyright (C) 1985, 1996, 1998, 2001-2019 Free Software Foundation,
   Inc.
 
   This file is part of GNU Emacs.
@@ -1026,7 +1026,7 @@ using, writing, and sharing free software!
 
 本篇指南是 GNU Emacs 的一部分,并允许在下列条件的约束下发行其拷贝:
 
-   Copyright (C) 1985, 1996, 1998, 2001-2018 Free Software Foundation,
+   Copyright (C) 1985, 1996, 1998, 2001-2019 Free Software Foundation,
    Inc.
 
    本文件为 GNU Emacs 的一部分。
diff --git a/etc/tutorials/TUTORIAL.cs b/etc/tutorials/TUTORIAL.cs
index 7dc0d31..ac0faba 100644
--- a/etc/tutorials/TUTORIAL.cs
+++ b/etc/tutorials/TUTORIAL.cs
@@ -1015,7 +1015,7 @@ tutoriálem napsaným Stuartem Cracraftem pro původní Emacs.
 Tato verze tutoriálu je, podobně jako GNU Emacs, chráněna copyrightem a
 je šířena se svolením distribuovat kopie za jistých podmínek:
 
-Copyright (C) 1985, 1996, 1998, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1985, 1996, 1998, 2001-2019 Free Software Foundation, Inc.
 
    Každému je zaručeno právo vytvářet a distribuovat přesné kopie tohoto
    dokumentu tak, jak jej obdržel, na jakémkoliv médiu, s tím, že bude
diff --git a/etc/tutorials/TUTORIAL.de b/etc/tutorials/TUTORIAL.de
index 94d13bd..d1b5a48 100644
--- a/etc/tutorials/TUTORIAL.de
+++ b/etc/tutorials/TUTORIAL.de
@@ -1458,7 +1458,7 @@ Beachten Sie bitte, dass im Zweifelsfalle das englische 
Original
 dieser Urheberrechtsnotiz gültig ist (zu finden in der Datei
 TUTORIAL).
 
-   Copyright (C) 1985, 1996-1997, 2001-2018 Free Software Foundation,
+   Copyright (C) 1985, 1996-1997, 2001-2019 Free Software Foundation,
    Inc.
 
    Diese Datei ist ein Bestandteil von GNU Emacs.
diff --git a/etc/tutorials/TUTORIAL.eo b/etc/tutorials/TUTORIAL.eo
index 37a79f0..1854020 100644
--- a/etc/tutorials/TUTORIAL.eo
+++ b/etc/tutorials/TUTORIAL.eo
@@ -1081,7 +1081,7 @@ la dosiero verkita de Stuart Cracraft por la originala 
Emakso.
 kopirajton, kaj venas kun permeso por disdoni kopiojn se certaj
 kondiĉoj estas observataj:
 
-   Copyright (C) 1985, 1999, 2001-2002, 2005, 2007-2018 Free Software
+   Copyright (C) 1985, 1999, 2001-2002, 2005, 2007-2019 Free Software
    Foundation, Inc.
 
    Ĉi tiu dosiero estas parto de "GNU Emacs".
diff --git a/etc/tutorials/TUTORIAL.es b/etc/tutorials/TUTORIAL.es
index 50b99c4..fba873a 100644
--- a/etc/tutorials/TUTORIAL.es
+++ b/etc/tutorials/TUTORIAL.es
@@ -1204,7 +1204,7 @@ Por favor, en caso de duda, solo es válido el original en 
inglés de la
 siguiente nota de derechos de reproducción (que puede encontrar en el
 archivo TUTORIAL).
 
-Copyright (C) 1985, 1996, 1998, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1985, 1996, 1998, 2001-2019 Free Software Foundation, Inc.
 
    Se permite a cualquiera hacer o distribuir copias literales de este
    documento como se recibe, en cualquier medio, siempre que la nota
diff --git a/etc/tutorials/TUTORIAL.fr b/etc/tutorials/TUTORIAL.fr
index 07a2802..732ca22 100644
--- a/etc/tutorials/TUTORIAL.fr
+++ b/etc/tutorials/TUTORIAL.fr
@@ -1202,7 +1202,7 @@ Cette version du didacticiel, comme GNU Emacs, est placée 
sous
 droit d'auteur, et vous pouvez en distribuer des copies sous certaines
 conditions :
 
-Copyright (C) 1985, 1996, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1985, 1996, 2001-2019 Free Software Foundation, Inc.
 
    Chacun peut créer ou distribuer des copies de ce document tel qu'il
    l'a reçu, sur n'importe quel support, pourvu que la note de
diff --git a/etc/tutorials/TUTORIAL.he b/etc/tutorials/TUTORIAL.he
index 652bc0d..5422ca1 100644
--- a/etc/tutorials/TUTORIAL.he
+++ b/etc/tutorials/TUTORIAL.he
@@ -1004,7 +1004,7 @@ find-file.
 גירסה זו של השיעור הינה חלק מחבילת GNU Emacs. היא מוגנת בזכויות יוצרים
 וניתנת להעתקה והפצת עותקים בתנאים מסויימים כדלקמן:
 
-                       Copyright (C) 2010-2018 Free Software Foundation, Inc.
+                       Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ‏GNU Emacs הינו תכנה חפשית; זכותכם להפיצו ו\או לשנותו בכפוף לתנאי
 הרשיון GNU General Public License, כפי שהוא יוצא לאור ע״י Free
diff --git a/etc/tutorials/TUTORIAL.it b/etc/tutorials/TUTORIAL.it
index cea1dcb..84f0ca5 100644
--- a/etc/tutorials/TUTORIAL.it
+++ b/etc/tutorials/TUTORIAL.it
@@ -1203,7 +1203,7 @@ distribuito con il permesso di farne copie a determinate 
condizioni:
    indicativo, restando comunque inteso il fatto che è quella
    originale a fare fede.
 
-Copyright (C) 2003-2018 Free Software Foundation, Inc.
+Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
    È permesso a chiunque copiare e distribuire attraverso ogni mezzo
    copie fedeli di questo documento così come viene ricevuto, a
diff --git a/etc/tutorials/TUTORIAL.ja b/etc/tutorials/TUTORIAL.ja
index f0b0e08..401d9c2 100644
--- a/etc/tutorials/TUTORIAL.ja
+++ b/etc/tutorials/TUTORIAL.ja
@@ -1062,7 +1062,7 @@ starting with the one written by Stuart Cracraft for the 
original Emacs.
 This version of the tutorial, like GNU Emacs, is copyrighted, and
 comes with permission to distribute copies on certain conditions:
 
-Copyright (C) 1985, 1996, 1998, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1985, 1996, 1998, 2001-2019 Free Software Foundation, Inc.
 
    Permission is granted to anyone to make or distribute verbatim copies
    of this document as received, in any medium, provided that the
diff --git a/etc/tutorials/TUTORIAL.ko b/etc/tutorials/TUTORIAL.ko
index 480a8ac..c95d944 100644
--- a/etc/tutorials/TUTORIAL.ko
+++ b/etc/tutorials/TUTORIAL.ko
@@ -981,7 +981,7 @@ C-x C-s와 (META쇠나 EDIT쇠 혹은 교체쇠가 있으면) <ESC>v와 같은 
 GNU 이맥스와 같이 이 지침서 판은 저작권이 있으며 특정한 조건을 만족할
 때에 복사본을 배포할 수 있는 허가를 갖고 나온 것이다:
 
-Copyright (C) 1985, 1996, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1985, 1996, 2001-2019 Free Software Foundation, Inc.
 
    이 문서는 이 저작권 공고와 허용 공고가 그대로 유지되고, 배포자가
    수취자에게 이 공고에 따라 허용되는 것처럼 또 재분배하는 것을
diff --git a/etc/tutorials/TUTORIAL.nl b/etc/tutorials/TUTORIAL.nl
index 9e3d0e6..4a525cc 100644
--- a/etc/tutorials/TUTORIAL.nl
+++ b/etc/tutorials/TUTORIAL.nl
@@ -1209,7 +1209,7 @@ Deze versie van de inleiding is onderdeel van GNU Emacs.  
Het valt
 onder copyright.  Je mag deze inleiding verspreiden onder bepaalde
 voorwaarden:
 
-  Copyright (C) 1985, 1996, 1998, 2001-2018 Free Software Foundation,
+  Copyright (C) 1985, 1996, 1998, 2001-2019 Free Software Foundation,
   Inc.
 
   Dit bestand is onderdeel van GNU Emacs.
@@ -1239,7 +1239,7 @@ Engels origineel van de copyrightmelding en condities:
 This version of the tutorial is a part of GNU Emacs.  It is copyrighted
 and comes with permission to distribute copies on certain conditions:
 
-  Copyright (C) 1985, 1996, 1998, 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 1985, 1996, 1998, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/etc/tutorials/TUTORIAL.pl b/etc/tutorials/TUTORIAL.pl
index 6a476ff..5d9fb2a 100644
--- a/etc/tutorials/TUTORIAL.pl
+++ b/etc/tutorials/TUTORIAL.pl
@@ -1209,7 +1209,7 @@ z pomocą Ryszarda Kubiaka i Janusza S. Bienia 
<address@hidden>.
 Ta wersja samouczka, podobnie jak GNU Emacs, jest chroniona prawem
 autorskim, ale wolno ją kopiować pod następującymi warunkami:
 
-Copyright (C) 1985, 1994, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1985, 1994, 2001-2019 Free Software Foundation, Inc.
 
 Zezwala się na wykonywanie lub rozpowszechnianie
 wiernych kopii tego dokumentu w otrzymanej formie, na dowolnym
diff --git a/etc/tutorials/TUTORIAL.pt_BR b/etc/tutorials/TUTORIAL.pt_BR
index 461fe12..f8db6b0 100644
--- a/etc/tutorials/TUTORIAL.pt_BR
+++ b/etc/tutorials/TUTORIAL.pt_BR
@@ -1056,7 +1056,7 @@ Essa versão do tutorial foi originalmente traduzida por 
Marcelo Toledo
 <address@hidden> e como o GNU Emacs, tem um copyright, e vem
 com uma permissão de distribuição de cópias nas seguintes condições:
 
-Copyright (C) 2004-2018 Free Software Foundation, Inc.
+Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
    Permissão é garantida a qualquer um para fazer ou distribuir cópias
    integrais deste documento como recebido, em qualquer meio, deixando
diff --git a/etc/tutorials/TUTORIAL.ro b/etc/tutorials/TUTORIAL.ro
index f744c27..0e7981f 100644
--- a/etc/tutorials/TUTORIAL.ro
+++ b/etc/tutorials/TUTORIAL.ro
@@ -4,7 +4,7 @@ Mulţumiri Aidei Hulubei <address@hidden> pentru corecturi şi 
sugestii.
 
 Această versiune a fost produsă plecând de la versiunea în limba
 engleză, care este
-Copyright (c) 1985, 2013-2018 Free Software Foundation, Inc.
+Copyright (c) 1985, 2013-2019 Free Software Foundation, Inc.
 
 Citiţi acum versiunea românească a tutorialului de Emacs.
 
@@ -1082,7 +1082,7 @@ continuare noţita de copyright originală în limba engleză.
 This version of the tutorial, like GNU Emacs, is copyrighted, and
 comes with permission to distribute copies on certain conditions:
 
-Copyright (C) 1998, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1998, 2001-2019 Free Software Foundation, Inc.
 
    Permission is granted to anyone to make or distribute verbatim copies
    of this document as received, in any medium, provided that the
diff --git a/etc/tutorials/TUTORIAL.ru b/etc/tutorials/TUTORIAL.ru
index 73c6dd9..ba3a5c2 100644
--- a/etc/tutorials/TUTORIAL.ru
+++ b/etc/tutorials/TUTORIAL.ru
@@ -1105,7 +1105,7 @@ Dired позволяет вам отображать список файлов 
 (copyrighted) и приходит с ограничениями распространения копий со
 следующими соглашениями:
 
-Copyright (C) 1985, 1996, 1998, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1985, 1996, 1998, 2001-2019 Free Software Foundation, Inc.
 
    Permission is granted to anyone to make or distribute verbatim copies
    of this document as received, in any medium, provided that the
diff --git a/etc/tutorials/TUTORIAL.sk b/etc/tutorials/TUTORIAL.sk
index daa4e93..8121814 100644
--- a/etc/tutorials/TUTORIAL.sk
+++ b/etc/tutorials/TUTORIAL.sk
@@ -1074,7 +1074,7 @@ tútorialom napísaným Stuartom Cracraftom pre pôvodný 
Emacs.
 Táto verzia tútorialu je, podobne ako GNU Emacs, chránená copyrightom
 a je šírená s povolením distribuovať kópie za istých podmienok:
 
-Copyright (C) 1985, 1996, 1998, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1985, 1996, 1998, 2001-2019 Free Software Foundation, Inc.
 
    Každému je zaručené právo vytvárať a distribuovať presné kópie tohto
    dokumentu tak, ako ho dostal, na akomkoľvek médiu, s tým, že bude
diff --git a/etc/tutorials/TUTORIAL.sl b/etc/tutorials/TUTORIAL.sl
index 0f0dd12..7e189b6 100644
--- a/etc/tutorials/TUTORIAL.sl
+++ b/etc/tutorials/TUTORIAL.sl
@@ -1119,7 +1119,7 @@ Emacs. V slovenščino ga je prevedel Primož Peterlin.
 To besedilo, kot sam GNU Emacs, je avtorsko delo, in njegovo
 razmnoževanje in razširjanje je dovoljeno pod naslednjimi pogoji:
 
-Copyright © 1985, 1996, 1998, 2001-2018 Free Software Foundation, Inc.
+Copyright © 1985, 1996, 1998, 2001-2019 Free Software Foundation, Inc.
 
   Ta datoteka je del paketa GNU Emacs.
 
diff --git a/etc/tutorials/TUTORIAL.sv b/etc/tutorials/TUTORIAL.sv
index 74ecf45..10a1877 100644
--- a/etc/tutorials/TUTORIAL.sv
+++ b/etc/tutorials/TUTORIAL.sv
@@ -1140,7 +1140,7 @@ Lidell översatte den till Svenska.
 This version of the tutorial, like GNU Emacs, is copyrighted, and
 comes with permission to distribute copies on certain conditions:
 
-Copyright (C) 1985, 1996, 1998, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1985, 1996, 1998, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/etc/tutorials/TUTORIAL.th b/etc/tutorials/TUTORIAL.th
index 1f24467..1fc8a4a 100644
--- a/etc/tutorials/TUTORIAL.th
+++ b/etc/tutorials/TUTORIAL.th
@@ -964,7 +964,7 @@ starting with the one written by Stuart Cracraft for the 
original Emacs.
 This version of the tutorial, like GNU Emacs, is copyrighted, and
 comes with permission to distribute copies on certain conditions:
 
-Copyright (C) 1985, 1996, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1985, 1996, 2001-2019 Free Software Foundation, Inc.
 
    Permission is granted to anyone to make or distribute verbatim copies
    of this document as received, in any medium, provided that the
diff --git a/etc/tutorials/TUTORIAL.zh b/etc/tutorials/TUTORIAL.zh
index 4bbdc60..778338e 100644
--- a/etc/tutorials/TUTORIAL.zh
+++ b/etc/tutorials/TUTORIAL.zh
@@ -1049,7 +1049,7 @@ issue here>」。
 這個版本的快速指南和 GNU Emacs 一樣都是版權化的,並且允許在某些條件下
 散佈其拷貝:
 
-Copyright (C) 1985, 1996, 1998, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1985, 1996, 1998, 2001-2019 Free Software Foundation, Inc.
 
    Permission is granted to anyone to make or distribute verbatim copies
    of this document as received, in any medium, provided that the
diff --git a/leim/ChangeLog.1 b/leim/ChangeLog.1
index c3904db..c11ba30 100644
--- a/leim/ChangeLog.1
+++ b/leim/ChangeLog.1
@@ -2578,7 +2578,7 @@
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 1997-1999, 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 1997-1999, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/leim/Makefile.in b/leim/Makefile.in
index 1657ccf..4307d50 100644
--- a/leim/Makefile.in
+++ b/leim/Makefile.in
@@ -1,6 +1,6 @@
 ### @configure_input@
 
-# Copyright (C) 1997-2018 Free Software Foundation, Inc.
+# Copyright (C) 1997-2019 Free Software Foundation, Inc.
 # Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 #   2006, 2007, 2008, 2009, 2010, 2011
 #   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -84,7 +84,8 @@ MISC= \
        ${leimdir}/quail/PY.el          \
        ${leimdir}/quail/ZIRANMA.el     \
        ${leimdir}/quail/CTLau.el       \
-       ${leimdir}/quail/CTLau-b5.el
+       ${leimdir}/quail/CTLau-b5.el    \
+       ${srcdir}/../lisp/language/pinyin.el
 
 ## All the generated .el files.
 TIT_MISC = ${TIT_GB} ${TIT_BIG5} ${MISC}
@@ -142,6 +143,9 @@ ${leimdir}/ja-dic/ja-dic.el: $(srcdir)/SKK-DIC/SKK-JISYO.L
        $(AM_V_GEN)$(RUN_EMACS) -batch -l ja-dic-cnv \
          -f batch-skkdic-convert -dir "$(leimdir)/ja-dic" "$<"
 
+${srcdir}/../lisp/language/pinyin.el: ${srcdir}/MISC-DIC/pinyin.map
+       $(AM_V_GEN)${RUN_EMACS} -l titdic-cnv -f pinyin-convert $< $@
+
 
 .PHONY: bootstrap-clean distclean maintainer-clean extraclean
 
diff --git a/leim/README b/leim/README
index da1f6a5..7bf3041 100644
--- a/leim/README
+++ b/leim/README
@@ -1,4 +1,4 @@
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 
diff --git a/leim/leim-ext.el b/leim/leim-ext.el
index 495d971..de30a70 100644
--- a/leim/leim-ext.el
+++ b/leim/leim-ext.el
@@ -1,6 +1,6 @@
 ;; leim-ext.el -- extra leim configuration     -*- coding:utf-8; -*-
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
 ;;   Registration Number H13PRO009
diff --git a/lib-src/ChangeLog.1 b/lib-src/ChangeLog.1
index b002f28..d5a7d46 100644
--- a/lib-src/ChangeLog.1
+++ b/lib-src/ChangeLog.1
@@ -8609,7 +8609,7 @@
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 1988-1999, 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 1988-1999, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in
index 0015193..4022217 100644
--- a/lib-src/Makefile.in
+++ b/lib-src/Makefile.in
@@ -1,6 +1,6 @@
 ### @configure_input@
 
-# Copyright (C) 1985, 1987-1988, 1993-1994, 2001-2018 Free Software
+# Copyright (C) 1985, 1987-1988, 1993-1994, 2001-2019 Free Software
 # Foundation, Inc.
 
 # This file is part of GNU Emacs.
@@ -163,11 +163,11 @@ INSTALLABLES = etags${EXEEXT} ctags${EXEEXT} 
emacsclient${EXEEXT} $(CLIENTW) \
 
 # Things that Emacs runs internally, or during the build process,
 #  which should not be installed in bindir.
-UTILITIES = profile${EXEEXT} hexl${EXEEXT} \
+UTILITIES = hexl${EXEEXT}                               \
            $(if $(with_mailutils), , movemail${EXEEXT}) \
             $(and $(use_gamedir), update-game-score${EXEEXT})
 
-DONT_INSTALL= make-docfile${EXEEXT}
+DONT_INSTALL= make-docfile${EXEEXT} make-fingerprint${EXEEXT}
 
 # Like UTILITIES, but they're not system-dependent, and should not be
 #  deleted by the distclean target.
@@ -204,6 +204,8 @@ address@hidden@
 address@hidden@
 ## empty or -lrt or -lposix4 if HAVE_CLOCK_GETTIME
 LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@
+## Whatever libraries are needed for euidaccess
address@hidden@
 ## empty or -lwsock2 for MinGW
 address@hidden@
 
@@ -378,13 +380,12 @@ ebrowse${EXEEXT}: ${srcdir}/ebrowse.c 
${srcdir}/../lib/min-max.h $(NTLIB) \
        $(AM_V_CCLD)$(CC) ${ALL_CFLAGS} -DVERSION="\"${version}\"" \
          $< $(NTLIB) $(LOADLIBES) -o $@
 
-profile${EXEEXT}: ${srcdir}/profile.c $(NTLIB) $(config_h)
-       $(AM_V_CCLD)$(CC) ${ALL_CFLAGS} $< \
-         $(NTLIB) $(LOADLIBES) $(LIB_CLOCK_GETTIME) -o $@
-
 make-docfile${EXEEXT}: ${srcdir}/make-docfile.c $(NTLIB) $(config_h)
        $(AM_V_CCLD)$(CC) ${ALL_CFLAGS} $< $(NTLIB) $(LOADLIBES) -o $@
 
+make-fingerprint${EXEEXT}: ${srcdir}/make-fingerprint.c $(NTLIB) $(config_h)
+       $(AM_V_CCLD)$(CC) ${ALL_CFLAGS} $< $(NTLIB) $(LOADLIBES) -o $@
+
 movemail${EXEEXT}: ${srcdir}/movemail.c pop.o $(NTLIB) $(config_h)
        $(AM_V_CCLD)$(CC) ${ALL_CFLAGS} ${MOVE_FLAGS} $< pop.o \
          $(NTLIB) $(LOADLIBES) $(LIBS_MOVE) -o $@
@@ -395,12 +396,12 @@ pop.o: ${srcdir}/pop.c ${srcdir}/pop.h 
${srcdir}/../lib/min-max.h $(config_h)
 emacsclient${EXEEXT}: ${srcdir}/emacsclient.c $(NTLIB) $(config_h)
        $(AM_V_CCLD)$(CC) ${ALL_CFLAGS} $< \
           -DVERSION="\"${version}\"" $(NTLIB) $(LOADLIBES) \
-          $(LIB_WSOCK32) $(LIBS_ECLIENT) -o $@
+          $(LIB_WSOCK32) $(LIB_EACCESS) $(LIBS_ECLIENT) -o $@
 
 emacsclientw${EXEEXT}: ${srcdir}/emacsclient.c $(NTLIB) $(CLIENTRES) 
$(config_h)
        $(AM_V_CCLD)$(CC) ${ALL_CFLAGS} $(CLIENTRES) -mwindows $< \
           -DVERSION="\"${version}\"" $(LOADLIBES) \
-          $(LIB_WSOCK32) $(LIBS_ECLIENT) -o $@
+          $(LIB_WSOCK32) $(LIB_EACCESS) $(LIBS_ECLIENT) -o $@
 
 NTINC = ${srcdir}/../nt/inc
 NTDEPS = $(NTINC)/ms-w32.h $(NTINC)/sys/stat.h $(NTINC)/inttypes.h \
diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c
index 33af4f0..938b405 100644
--- a/lib-src/ebrowse.c
+++ b/lib-src/ebrowse.c
@@ -1,6 +1,6 @@
 /* ebrowse.c --- parsing files for the ebrowse C++ browser
 
-Copyright (C) 1992-2018 Free Software Foundation, Inc.
+Copyright (C) 1992-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -187,7 +187,8 @@ enum token
   STATIC_CAST,                 /* static_cast */
   TYPEID,                      /* typeid */
   USING,                       /* using */
-  WCHAR                                /* wchar_t */
+  WCHAR,                       /* wchar_t */
+  FINAL                         /* final */
 };
 
 /* Storage classes, in a wider sense.  */
@@ -471,7 +472,7 @@ static struct sym *add_sym (const char *, struct sym *);
 static void add_global_defn (char *, char *, int, unsigned, int, int, int);
 static void add_global_decl (char *, char *, int, unsigned, int, int, int);
 static struct member *add_member (struct sym *, char *, int, int, unsigned);
-static void class_definition (struct sym *, int, int, int);
+static void class_definition (struct sym *, const char *, int, int, int);
 static char *operator_name (int *);
 static void parse_qualified_param_ident_or_type (char **);
 
@@ -2035,6 +2036,7 @@ token_string (int t)
     case USING:                        return "using";
     case WCHAR:                        return "wchar_t";
     case YYEOF:                 return "EOF";
+    case FINAL:                 return "final";
 
     default:
       if (t < 255)
@@ -2140,6 +2142,7 @@ init_scanner (void)
   insert_keyword ("explicit", EXPLICIT);
   insert_keyword ("extern", EXTERN);
   insert_keyword ("false", FALSE);
+  insert_keyword ("final", FINAL);
   insert_keyword ("float", FLOAT);
   insert_keyword ("for", FOR);
   insert_keyword ("friend", FRIEND);
@@ -2501,9 +2504,9 @@ member (struct sym *cls, int vis)
   char *regexp = NULL;
   int pos;
   int is_constructor;
-  int anonymous = 0;
   int flags = 0;
   int class_tag;
+  char *class_name;
   int type_seen = 0;
   int paren_seen = 0;
   unsigned hash = 0;
@@ -2626,7 +2629,7 @@ member (struct sym *cls, int vis)
           class_tag = LA1;
           type_seen = 1;
           MATCH ();
-          anonymous = 1;
+          class_name = NULL;
 
           /* More than one ident here to allow for MS-DOS specialties
              like `_export class' etc.  The last IDENT seen counts
@@ -2634,14 +2637,33 @@ member (struct sym *cls, int vis)
          while (!LOOKING_AT4 (YYEOF, ';', ':', '{'))
            {
              if (LOOKING_AT (IDENT))
-               anonymous = 0;
-             MATCH ();
+                {
+                  if (class_name)
+                    {
+                      int size = strlen (yytext);
+
+                      if(strlen (class_name) < size)
+                        {
+                          class_name = (char *) xrealloc(class_name, size + 1);
+                        }
+
+                      memcpy(class_name, yytext, size + 1);
+                    }
+                  else
+                    {
+                      class_name = xstrdup(yytext);
+                    }
+                }
+
+              MATCH ();
            }
 
           if (LOOKING_AT2 (':', '{'))
-           class_definition (anonymous ? NULL : cls, class_tag, flags, 1);
+           class_definition (class_name ? cls : NULL, class_name ? class_name 
: yytext, class_tag, flags, 1);
           else
             skip_to (';');
+
+          free(class_name);
           break;
 
         case INT:       case CHAR:      case LONG:      case UNSIGNED:
@@ -2997,7 +3019,7 @@ parse_qualified_param_ident_or_type (char **last_id)
    Current lookahead is the class name.  */
 
 static void
-class_definition (struct sym *containing, int tag, int flags, int nested)
+class_definition (struct sym *containing, const char *class_name, int tag, int 
flags, int nested)
 {
   struct sym *current;
   struct sym *base_class;
@@ -3009,7 +3031,7 @@ class_definition (struct sym *containing, int tag, int 
flags, int nested)
     current = NULL;
   else
     {
-      current = add_sym (yytext, containing);
+      current = add_sym (class_name, containing);
       current->pos = BUFFER_POS ();
       current->regexp = matching_regexp ();
       current->filename = filename;
@@ -3292,8 +3314,8 @@ declaration (int flags)
 static int
 globals (int start_flags)
 {
-  int anonymous;
   int class_tk;
+  char *class_name;
   int flags = start_flags;
 
   for (;;)
@@ -3362,7 +3384,7 @@ globals (int start_flags)
         case CLASS: case STRUCT: case UNION:
           class_tk = LA1;
           MATCH ();
-          anonymous = 1;
+          class_name = NULL;
 
           /* More than one ident here to allow for MS-DOS and OS/2
              specialties like `far', `_Export' etc.  Some C++ libs
@@ -3371,19 +3393,37 @@ globals (int start_flags)
          while (!LOOKING_AT4 (YYEOF, ';', ':', '{'))
            {
              if (LOOKING_AT (IDENT))
-               anonymous = 0;
+                {
+                  if (class_name)
+                    {
+                      int size = strlen (yytext);
+
+                      if(strlen (class_name) < size)
+                        {
+                          class_name = (char *) xrealloc(class_name, size + 1);
+                        }
+
+                      memcpy(class_name, yytext, size + 1);
+                    }
+                  else
+                    {
+                      class_name = xstrdup(yytext);
+                    }
+                }
+
              MATCH ();
            }
 
           /* Don't add anonymous unions.  */
-          if (LOOKING_AT2 (':', '{') && !anonymous)
-              class_definition (NULL, class_tk, flags, 0);
+          if (LOOKING_AT2 (':', '{') && class_name)
+            class_definition (NULL, class_name, class_tk, flags, 0);
           else
             {
               if (skip_to (';') == ';')
                 MATCH ();
             }
 
+          free(class_name);
           flags = start_flags;
           break;
 
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index c596fb2..fd56007 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -1,6 +1,6 @@
 /* Client process that communicates with GNU Emacs acting as server.
 
-Copyright (C) 1986-1987, 1994, 1999-2018 Free Software Foundation, Inc.
+Copyright (C) 1986-1987, 1994, 1999-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -1357,6 +1357,7 @@ set_local_socket (char const *server_name)
   int tmpdirlen = -1;
   int socknamelen = -1;
   uid_t uid = geteuid ();
+  bool tmpdir_used = false;
 
   if (strchr (server_name, '/')
       || (ISSLASH ('\\') && strchr (server_name, '\\')))
@@ -1389,6 +1390,7 @@ set_local_socket (char const *server_name)
            }
          socknamelen = local_sockname (sockname, socknamesize, tmpdirlen,
                                        uid, server_name);
+         tmpdir_used = true;
        }
     }
 
@@ -1462,11 +1464,27 @@ set_local_socket (char const *server_name)
   if (sock_status < 0)
     message (true, "%s: Invalid socket owner\n", progname);
   else if (sock_status == ENOENT)
-    message (true,
-            ("%s: can't find socket; have you started the server?\n"
-             "%s: To start the server in Emacs,"
-             " type \"M-x server-start\".\n"),
-            progname, progname);
+    {
+      if (tmpdir_used)
+       {
+         uintmax_t id = uid;
+         char sockdirname[socknamesize];
+         int sockdirnamelen = snprintf (sockdirname, sizeof sockdirname,
+                                        "/run/user/%"PRIuMAX, id);
+         if (0 <= sockdirnamelen && sockdirnamelen < sizeof sockdirname
+             && faccessat (AT_FDCWD, sockdirname, X_OK, AT_EACCESS) == 0)
+           message
+             (true,
+              ("%s: Should XDG_RUNTIME_DIR='%s' be in the environment?\n"
+               "%s: (Be careful: XDG_RUNTIME_DIR is security-related.)\n"),
+              progname, sockdirname, progname);
+       }
+      message (true,
+              ("%s: can't find socket; have you started the server?\n"
+               "%s: To start the server in Emacs,"
+               " type \"M-x server-start\".\n"),
+              progname, progname);
+    }
   else
     message (true, "%s: can't stat %s: %s\n",
             progname, sockname, strerror (sock_status));
diff --git a/lib-src/etags.c b/lib-src/etags.c
index 102d867..362897f 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -28,7 +28,7 @@ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
SOFTWARE, EVEN
 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
-Copyright (C) 1984, 1987-1989, 1993-1995, 1998-2018 Free Software
+Copyright (C) 1984, 1987-1989, 1993-1995, 1998-2019 Free Software
 Foundation, Inc.
 
 This file is not considered part of GNU Emacs.
diff --git a/lib-src/hexl.c b/lib-src/hexl.c
index d67dd4c..99a1132 100644
--- a/lib-src/hexl.c
+++ b/lib-src/hexl.c
@@ -1,5 +1,5 @@
 /* Convert files for Emacs Hexl mode.
-   Copyright (C) 1989, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1989, 2001-2019 Free Software Foundation, Inc.
 
 Author: Keith Gabryelski (according to authors.el)
 
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c
index 23728e7..4d25b0a 100644
--- a/lib-src/make-docfile.c
+++ b/lib-src/make-docfile.c
@@ -1,6 +1,6 @@
 /* Generate doc-string file for GNU Emacs from source files.
 
-Copyright (C) 1985-1986, 1992-1994, 1997, 1999-2018 Free Software
+Copyright (C) 1985-1986, 1992-1994, 1997, 1999-2019 Free Software
 Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -700,7 +700,7 @@ write_globals (void)
       switch (globals[i].type)
        {
        case EMACS_INTEGER:
-         type = "EMACS_INT";
+         type = "intmax_t";
          break;
        case BOOLEAN:
          type = "bool";
@@ -747,6 +747,8 @@ write_globals (void)
            printf ("%d", globals[i].v.value);
          putchar (')');
 
+         if (globals[i].flags & DEFUN_noreturn)
+           fputs (" ATTRIBUTE_COLD", stdout);
          if (globals[i].flags & DEFUN_const)
            fputs (" ATTRIBUTE_CONST", stdout);
 
@@ -1107,6 +1109,9 @@ scan_c_stream (FILE *infile)
                g->flags |= DEFUN_noreturn;
              if (strstr (input_buffer, "const"))
                g->flags |= DEFUN_const;
+
+             /* Although the noinline attribute is no longer used,
+                leave its support in, in case it's needed later.  */
              if (strstr (input_buffer, "noinline"))
                g->flags |= DEFUN_noinline;
            }
diff --git a/lib-src/make-fingerprint.c b/lib-src/make-fingerprint.c
new file mode 100644
index 0000000..79bd007
--- /dev/null
+++ b/lib-src/make-fingerprint.c
@@ -0,0 +1,179 @@
+/* Hash inputs and generate C file with the digest.
+
+Copyright (C) 1985-1986, 1992-1994, 1997, 1999-2016, 2018-2019
+Free Software Foundation, Inc.
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
+
+
+/* The arguments given to this program are all the object files that
+ go into building GNU Emacs.  There is no special search logic to find
+ the files.  */
+
+#include <config.h>
+
+#include <limits.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+
+#include <sysstdio.h>
+
+#include <fingerprint.h>
+#include <getopt.h>
+#include <intprops.h>
+#include <min-max.h>
+#include <sha256.h>
+
+#ifndef SSIZE_MAX
+# define SSIZE_MAX TYPE_MAXIMUM (ssize_t)
+#endif
+
+#ifdef WINDOWSNT
+/* Defined to be sys_fopen in ms-w32.h, but only #ifdef emacs, so this
+   is really just insurance.  */
+#undef fopen
+#include <direct.h>
+
+#ifndef MINGW_W64
+# undef fseeko
+# define fseeko fseeko64
+#endif
+#endif /* WINDOWSNT */
+
+/* Static (instead of being local to 'main') to pacify LeakSanitizer.  */
+static char *buf;
+
+int
+main (int argc, char **argv)
+{
+  int c;
+  bool raw = false;
+  while (0 <= (c = getopt (argc, argv, "rh")))
+    {
+      switch (c)
+        {
+        case 'r':
+          raw = true;
+          break;
+        case 'h':
+          printf ("make-fingerprint [-r] FILE: replace or compute a hash\n");
+          return EXIT_SUCCESS;
+        default:
+          return EXIT_FAILURE;
+        }
+    }
+
+  struct sha256_ctx ctx;
+  sha256_init_ctx (&ctx);
+
+  char *prog = argv[0];
+  char *file = argv[optind];
+  if (argc - optind != 1)
+    {
+      fprintf (stderr, "%s: missing or extra file operand\n", prog);
+      return EXIT_FAILURE;
+    }
+
+  FILE *f = fopen (file, raw ? "r" FOPEN_BINARY : "r+" FOPEN_BINARY);
+  struct stat st;
+  if (!f || fstat (fileno (f), &st) != 0)
+    {
+      perror (file);
+      return EXIT_FAILURE;
+    }
+
+  if (!S_ISREG (st.st_mode))
+    {
+      fprintf (stderr, "%s: Error: %s is not a regular file\n",
+              prog, file);
+      return EXIT_FAILURE;
+    }
+
+  ptrdiff_t maxlen = min (min (TYPE_MAXIMUM (off_t), PTRDIFF_MAX),
+                         min (SIZE_MAX, SSIZE_MAX));
+  if (maxlen <= st.st_size)
+    {
+      fprintf (stderr, "%s: %s: file too big\n", prog, file);
+      return EXIT_FAILURE;
+    }
+
+  buf = malloc (st.st_size + 1);
+  if (!buf)
+    {
+      perror ("malloc");
+      return EXIT_FAILURE;
+    }
+
+  size_t chunksz = fread (buf, 1, st.st_size + 1, f);
+  if (ferror (f) || chunksz != st.st_size)
+    {
+      fprintf (stderr, "%s: Error: could not read %s\n", prog, file);
+      return EXIT_FAILURE;
+    }
+
+  sha256_process_bytes (buf, chunksz, &ctx);
+
+  unsigned char digest[32];
+  sha256_finish_ctx (&ctx, digest);
+
+  if (raw)
+    {
+      for (int i = 0; i < 32; ++i)
+        printf ("%02X", digest[i]);
+    }
+  else
+    {
+      char *finger = memmem (buf, chunksz, fingerprint, sizeof fingerprint);
+      if (!finger)
+       {
+         fprintf (stderr, "%s: %s: missing fingerprint\n", prog, file);
+         return EXIT_FAILURE;
+       }
+      else if (memmem (finger + 1, buf + chunksz - (finger + 1),
+                      fingerprint, sizeof fingerprint))
+       {
+         fprintf (stderr, "%s: %s: two occurrences of fingerprint\n",
+                  prog, file);
+         return EXIT_FAILURE;
+       }
+
+      if (fseeko (f, finger - buf, SEEK_SET) != 0)
+       {
+         perror (file);
+         return EXIT_FAILURE;
+       }
+
+      if (fwrite (digest, 1, sizeof digest, f) != sizeof digest)
+       {
+         perror (file);
+         return EXIT_FAILURE;
+       }
+    }
+
+  if (fclose (f) != 0)
+    {
+      perror (file);
+      return EXIT_FAILURE;
+    }
+
+  return EXIT_SUCCESS;
+}
+
+/* make-fingerprint.c ends here */
diff --git a/lib-src/movemail.c b/lib-src/movemail.c
index 7a37e16..109e998 100644
--- a/lib-src/movemail.c
+++ b/lib-src/movemail.c
@@ -1,7 +1,7 @@
 /* movemail foo bar -- move file foo to file bar,
    locking file foo the way /bin/mail respects.
 
-Copyright (C) 1986, 1992-1994, 1996, 1999, 2001-2018 Free Software
+Copyright (C) 1986, 1992-1994, 1996, 1999, 2001-2019 Free Software
 Foundation, Inc.
 
 This file is part of GNU Emacs.
diff --git a/lib-src/ntlib.c b/lib-src/ntlib.c
index 4ca521d..d992f54 100644
--- a/lib-src/ntlib.c
+++ b/lib-src/ntlib.c
@@ -1,6 +1,6 @@
 /* Utility and Unix shadow routines for GNU Emacs support programs on NT.
 
-Copyright (C) 1994, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1994, 2001-2019 Free Software Foundation, Inc.
 
 Author: Geoff Voelker (address@hidden)
 Created: 10-8-94
@@ -290,8 +290,8 @@ is_exec (const char * name)
 /* FIXME?  This is in configure.ac now - is this still needed?  */
 #define IS_DIRECTORY_SEP(x) ((x) == '/' || (x) == '\\')
 
-/* We need this because nt/inc/sys/stat.h defines struct stat that is
-   incompatible with the MS run-time libraries.  */
+/* We need stat/fsfat below because nt/inc/sys/stat.h defines struct
+   stat that is incompatible with the MS run-time libraries.  */
 int
 stat (const char * path, struct stat * buf)
 {
@@ -377,7 +377,9 @@ stat (const char * path, struct stat * buf)
     buf->st_dev = _getdrive ();
   buf->st_rdev = buf->st_dev;
 
-  buf->st_size = wfd.nFileSizeLow;
+  buf->st_size = wfd.nFileSizeHigh;
+  buf->st_size <<= 32;
+  buf->st_size += wfd.nFileSizeLow;
 
   /* Convert timestamps to Unix format. */
   buf->st_mtime = convert_time (wfd.ftLastWriteTime);
@@ -408,6 +410,98 @@ lstat (const char * path, struct stat * buf)
   return stat (path, buf);
 }
 
+int
+fstat (int desc, struct stat * buf)
+{
+  HANDLE fh = (HANDLE) _get_osfhandle (desc);
+  BY_HANDLE_FILE_INFORMATION info;
+  unsigned __int64 fake_inode;
+  int permission;
+
+  if (!init)
+    {
+      /* Determine the delta between 1-Jan-1601 and 1-Jan-1970. */
+      SYSTEMTIME st;
+
+      st.wYear = 1970;
+      st.wMonth = 1;
+      st.wDay = 1;
+      st.wHour = 0;
+      st.wMinute = 0;
+      st.wSecond = 0;
+      st.wMilliseconds = 0;
+
+      SystemTimeToFileTime (&st, &utc_base_ft);
+      utc_base = (long double) utc_base_ft.dwHighDateTime
+       * 4096.0L * 1024.0L * 1024.0L + utc_base_ft.dwLowDateTime;
+      init = 1;
+    }
+
+  switch (GetFileType (fh) & ~FILE_TYPE_REMOTE)
+    {
+    case FILE_TYPE_DISK:
+      buf->st_mode = S_IFREG;
+      if (!GetFileInformationByHandle (fh, &info))
+       {
+         errno = EACCES;
+         return -1;
+       }
+      break;
+    case FILE_TYPE_PIPE:
+      buf->st_mode = S_IFIFO;
+      goto non_disk;
+    case FILE_TYPE_CHAR:
+    case FILE_TYPE_UNKNOWN:
+    default:
+      buf->st_mode = S_IFCHR;
+    non_disk:
+      memset (&info, 0, sizeof (info));
+      info.dwFileAttributes = 0;
+      info.ftCreationTime = utc_base_ft;
+      info.ftLastAccessTime = utc_base_ft;
+      info.ftLastWriteTime = utc_base_ft;
+    }
+
+  if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+      buf->st_mode = S_IFDIR;
+
+  buf->st_nlink = info.nNumberOfLinks;
+  /* Might as well use file index to fake inode values, but this
+     is not guaranteed to be unique unless we keep a handle open
+     all the time. */
+  fake_inode = info.nFileIndexHigh;
+  fake_inode <<= 32;
+  fake_inode += info.nFileIndexLow;
+  buf->st_ino = fake_inode;
+
+  buf->st_dev = info.dwVolumeSerialNumber;
+  buf->st_rdev = info.dwVolumeSerialNumber;
+
+  buf->st_size = info.nFileSizeHigh;
+  buf->st_size <<= 32;
+  buf->st_size += info.nFileSizeLow;
+
+  /* Convert timestamps to Unix format. */
+  buf->st_mtime = convert_time (info.ftLastWriteTime);
+  buf->st_atime = convert_time (info.ftLastAccessTime);
+  if (buf->st_atime == 0) buf->st_atime = buf->st_mtime;
+  buf->st_ctime = convert_time (info.ftCreationTime);
+  if (buf->st_ctime == 0) buf->st_ctime = buf->st_mtime;
+
+  /* determine rwx permissions */
+  if (info.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
+    permission = S_IREAD;
+  else
+    permission = S_IREAD | S_IWRITE;
+
+  if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+    permission |= S_IEXEC;
+
+  buf->st_mode |= permission | (permission >> 3) | (permission >> 6);
+
+  return 0;
+}
+
 /* On Windows, you cannot rename into an existing file.  */
 int
 sys_rename (const char *from, const char *to)
diff --git a/lib-src/ntlib.h b/lib-src/ntlib.h
index e6df31d..fd5a0d2 100644
--- a/lib-src/ntlib.h
+++ b/lib-src/ntlib.h
@@ -1,5 +1,5 @@
 /* Utility and Unix shadow routines for GNU Emacs support programs on NT.
-   Copyright (C) 1994, 2002-2018 Free Software Foundation, Inc.
+   Copyright (C) 1994, 2002-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/lib-src/pop.c b/lib-src/pop.c
index 731f951..c14808d 100644
--- a/lib-src/pop.c
+++ b/lib-src/pop.c
@@ -1,6 +1,6 @@
 /* pop.c: client routines for talking to a POP3-protocol post-office server
 
-Copyright (C) 1991, 1993, 1996-1997, 1999, 2001-2018 Free Software
+Copyright (C) 1991, 1993, 1996-1997, 1999, 2001-2019 Free Software
 Foundation, Inc.
 
 Author: Jonathan Kamens <address@hidden>
diff --git a/lib-src/pop.h b/lib-src/pop.h
index dca85b8..81fa459 100644
--- a/lib-src/pop.h
+++ b/lib-src/pop.h
@@ -1,5 +1,5 @@
 /* pop.h: Header file for the "pop.c" client POP3 protocol.
-   Copyright (C) 1991, 1993, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1991, 1993, 2001-2019 Free Software Foundation, Inc.
 
 Author:  Jonathan Kamens <address@hidden>
 
diff --git a/lib-src/profile.c b/lib-src/profile.c
deleted file mode 100644
index 649eb04..0000000
--- a/lib-src/profile.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* profile.c --- generate periodic events for profiling of Emacs Lisp code.
-   Copyright (C) 1992, 1994, 1999, 2001-2018 Free Software Foundation,
-   Inc.
-
-Author: Boaz Ben-Zvi <address@hidden>
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or (at
-your option) any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
-
-
-/**
- **  To be run as an emacs subprocess.  Input string that starts with:
- **    'z' -- resets the watch (to zero).
- **    'p' -- return time (on stdout) as string with format <sec>.<micro-sec>
- **    'q' -- exit.
- **
- **  abstraction : a stopwatch
- **  operations: reset_watch, get_time
- */
-
-#include <config.h>
-
-#include <inttypes.h>
-#include <stdlib.h>
-
-#include <intprops.h>
-#include <timespec.h>
-#include <unlocked-io.h>
-
-static struct timespec TV1;
-static int watch_not_started = 1; /* flag */
-static char time_string[INT_STRLEN_BOUND (uintmax_t) + sizeof "."
-                       + LOG10_TIMESPEC_HZ];
-
-/* Reset the stopwatch to zero.  */
-
-static void
-reset_watch (void)
-{
-  TV1 = current_timespec ();
-  watch_not_started = 0;
-}
-
-/* This call returns the time since the last reset_watch call.  The time
-   is returned as a string with the format  <seconds>.<nanoseconds>
-   If reset_watch was not called yet, exit.  */
-
-static char *
-get_time (void)
-{
-  struct timespec TV2 = timespec_sub (current_timespec (), TV1);
-  uintmax_t s = TV2.tv_sec;
-  int ns = TV2.tv_nsec;
-  if (watch_not_started)
-    exit (EXIT_FAILURE);  /* call reset_watch first ! */
-  sprintf (time_string, "%"PRIuMAX".%0*d", s, LOG10_TIMESPEC_HZ, ns);
-  return time_string;
-}
-
-int
-main (void)
-{
-  int c;
-  while ((c = getchar ()) != EOF)
-    {
-      switch (c)
-       {
-       case 'z':
-         reset_watch ();
-         break;
-       case 'p':
-         puts (get_time ());
-         break;
-       case 'q':
-         return EXIT_SUCCESS;
-       }
-      /* Anything remaining on the line is ignored.  */
-      while (c != '\n' && c != EOF)
-       c = getchar ();
-    }
-  return EXIT_FAILURE;
-}
-
-
-/* profile.c ends here */
diff --git a/lib-src/rcs2log b/lib-src/rcs2log
index e459d35..2368780 100755
--- a/lib-src/rcs2log
+++ b/lib-src/rcs2log
@@ -2,7 +2,7 @@
 
 # RCS to ChangeLog generator
 
-# Copyright (C) 1992-1998, 2001-2018 Free Software Foundation, Inc.
+# Copyright (C) 1992-1998, 2001-2019 Free Software Foundation, Inc.
 
 # Author: Paul Eggert <address@hidden>
 
@@ -20,7 +20,7 @@
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 
-Copyright='Copyright (C) 2018 Free Software Foundation, Inc.
+Copyright='Copyright (C) 2019 Free Software Foundation, Inc.
 This program comes with NO WARRANTY, to the extent permitted by law.
 You may redistribute copies of this program
 under the terms of the GNU General Public License.
diff --git a/lib-src/update-game-score.c b/lib-src/update-game-score.c
index 050a4da..8a6f46b 100644
--- a/lib-src/update-game-score.c
+++ b/lib-src/update-game-score.c
@@ -1,6 +1,6 @@
 /* update-game-score.c --- Update a score file
 
-Copyright (C) 2002-2018 Free Software Foundation, Inc.
+Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 Author: Colin Walters <address@hidden>
 
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 7dba31b..ac32c70 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -1,6 +1,6 @@
 ### @configure_input@
 
-# Copyright 2017-2018 Free Software Foundation, Inc.
+# Copyright 2017-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
@@ -84,7 +84,7 @@ Makefile: ../config.status $(srcdir)/Makefile.in
 # and building it would just waste time.
 not_emacs_OBJECTS = regex.o
 
-libgnu_a_OBJECTS = $(gl_LIBOBJS) \
+libgnu_a_OBJECTS = fingerprint.o $(gl_LIBOBJS) \
   $(patsubst %.c,%.o,$(filter %.c,$(libgnu_a_SOURCES)))
 for_emacs_OBJECTS = $(filter-out $(not_emacs_OBJECTS),$(libgnu_a_OBJECTS))
 libegnu_a_OBJECTS = $(patsubst %.o,e-%.o,$(for_emacs_OBJECTS))
diff --git a/lib/_Noreturn.h b/lib/_Noreturn.h
index 94fdfaf..db9b455 100644
--- a/lib/_Noreturn.h
+++ b/lib/_Noreturn.h
@@ -1,8 +1,27 @@
+/* A C macro for declaring that a function does not return.
+   Copyright (C) 2011-2019 Free Software Foundation, Inc.
+
+   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/>.  */
+
 #ifndef _Noreturn
-# if 201103 <= (defined __cplusplus ? __cplusplus : 0)
+# if (defined __cplusplus \
+      && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
+          || (defined _MSC_VER && 1900 <= _MSC_VER)))
 #  define _Noreturn [[noreturn]]
-# elif (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
-        || 4 < __GNUC__ + (7 <= __GNUC_MINOR__))
+# elif ((!defined __cplusplus || defined __clang__)                     \
+        && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0)  \
+            || 4 < __GNUC__ + (7 <= __GNUC_MINOR__)))
    /* _Noreturn works as-is.  */
 # elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
 #  define _Noreturn __attribute__ ((__noreturn__))
diff --git a/lib/acl-errno-valid.c b/lib/acl-errno-valid.c
index 96577eb..99ddf3b 100644
--- a/lib/acl-errno-valid.c
+++ b/lib/acl-errno-valid.c
@@ -1,6 +1,6 @@
 /* Test whether ACLs are well supported on this system.
 
-   Copyright 2013-2018 Free Software Foundation, Inc.
+   Copyright 2013-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/acl-internal.c b/lib/acl-internal.c
index 92e7b9b..cc42183 100644
--- a/lib/acl-internal.c
+++ b/lib/acl-internal.c
@@ -1,6 +1,6 @@
 /* Test whether a file has a nontrivial ACL.  -*- coding: utf-8 -*-
 
-   Copyright (C) 2002-2003, 2005-2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2005-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/acl-internal.h b/lib/acl-internal.h
index 2da7c5a..05833ef 100644
--- a/lib/acl-internal.h
+++ b/lib/acl-internal.h
@@ -1,6 +1,6 @@
 /* Internal implementation of access control lists.  -*- coding: utf-8 -*-
 
-   Copyright (C) 2002-2003, 2005-2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2005-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/acl.h b/lib/acl.h
index d0c122c..904606d 100644
--- a/lib/acl.h
+++ b/lib/acl.h
@@ -1,6 +1,6 @@
 /* acl.c - access control lists
 
-   Copyright (C) 2002, 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2008-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/acl_entries.c b/lib/acl_entries.c
index ce730d4..19ac3c3 100644
--- a/lib/acl_entries.c
+++ b/lib/acl_entries.c
@@ -1,6 +1,6 @@
 /* Return the number of entries in an ACL.
 
-   Copyright (C) 2002-2003, 2005-2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2005-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/alloca.in.h b/lib/alloca.in.h
index 5ad8af8..a581d58 100644
--- a/lib/alloca.in.h
+++ b/lib/alloca.in.h
@@ -1,6 +1,6 @@
 /* Memory allocation on the stack.
 
-   Copyright (C) 1995, 1999, 2001-2004, 2006-2018 Free Software Foundation,
+   Copyright (C) 1995, 1999, 2001-2004, 2006-2019 Free Software Foundation,
    Inc.
 
    This program is free software; you can redistribute it and/or modify it
@@ -36,6 +36,12 @@
 
 #ifndef alloca
 # ifdef __GNUC__
+   /* Some version of mingw have an <alloca.h> that causes trouble when
+      included after 'alloca' gets defined as a macro.  As a workaround, 
include
+      this <alloca.h> first and define 'alloca' as a macro afterwards.  */
+#  if (defined _WIN32 && ! defined __CYGWIN__) && @HAVE_ALLOCA_H@
+#   include_next <alloca.h>
+#  endif
 #  define alloca __builtin_alloca
 # elif defined _AIX
 #  define alloca __alloca
diff --git a/lib/allocator.h b/lib/allocator.h
index ab312f5..5a632ba 100644
--- a/lib/allocator.h
+++ b/lib/allocator.h
@@ -1,6 +1,6 @@
 /* Memory allocators such as malloc+free.
 
-   Copyright (C) 2011-2018 Free Software Foundation, Inc.
+   Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/arg-nonnull.h b/lib/arg-nonnull.h
index 5f03408..ad8c26c 100644
--- a/lib/arg-nonnull.h
+++ b/lib/arg-nonnull.h
@@ -1,5 +1,5 @@
 /* A C macro for declaring that specific arguments must not be NULL.
-   Copyright (C) 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published
diff --git a/lib/at-func.c b/lib/at-func.c
index 55e4b8c..d2e6319 100644
--- a/lib/at-func.c
+++ b/lib/at-func.c
@@ -1,5 +1,5 @@
 /* Define at-style functions like fstatat, unlinkat, fchownat, etc.
-   Copyright (C) 2006, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/binary-io.c b/lib/binary-io.c
index f9cc4dd..01e0bf6 100644
--- a/lib/binary-io.c
+++ b/lib/binary-io.c
@@ -1,5 +1,5 @@
 /* Binary mode I/O.
-   Copyright 2017-2018 Free Software Foundation, Inc.
+   Copyright 2017-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/binary-io.h b/lib/binary-io.h
index 1f21fc0..720b08c 100644
--- a/lib/binary-io.h
+++ b/lib/binary-io.h
@@ -1,5 +1,5 @@
 /* Binary mode I/O.
-   Copyright (C) 2001, 2003, 2005, 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2003, 2005, 2008-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/byteswap.in.h b/lib/byteswap.in.h
index 547e384..273855d 100644
--- a/lib/byteswap.in.h
+++ b/lib/byteswap.in.h
@@ -1,5 +1,5 @@
 /* byteswap.h - Byte swapping
-   Copyright (C) 2005, 2007, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2007, 2009-2019 Free Software Foundation, Inc.
    Written by Oskar Liljeblad <address@hidden>, 2005.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/c++defs.h b/lib/c++defs.h
index 72ff1ff..87d0716 100644
--- a/lib/c++defs.h
+++ b/lib/c++defs.h
@@ -1,5 +1,5 @@
 /* C++ compatible function declaration macros.
-   Copyright (C) 2010-2018 Free Software Foundation, Inc.
+   Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published
diff --git a/lib/c-ctype.h b/lib/c-ctype.h
index d55d4f6..4d52176 100644
--- a/lib/c-ctype.h
+++ b/lib/c-ctype.h
@@ -5,7 +5,7 @@
    <ctype.h> functions' behaviour depends on the current locale set via
    setlocale.
 
-   Copyright (C) 2000-2003, 2006, 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2000-2003, 2006, 2008-2019 Free Software Foundation, Inc.
 
 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
diff --git a/lib/c-strcase.h b/lib/c-strcase.h
index 41f439e..b67c9b5 100644
--- a/lib/c-strcase.h
+++ b/lib/c-strcase.h
@@ -1,5 +1,5 @@
 /* Case-insensitive string comparison functions in C locale.
-   Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2018 Free Software
+   Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2019 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/lib/c-strcasecmp.c b/lib/c-strcasecmp.c
index 2b1ac99..ec50f1a 100644
--- a/lib/c-strcasecmp.c
+++ b/lib/c-strcasecmp.c
@@ -1,5 +1,5 @@
 /* c-strcasecmp.c -- case insensitive string comparator in C locale
-   Copyright (C) 1998-1999, 2005-2006, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 1998-1999, 2005-2006, 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/c-strncasecmp.c b/lib/c-strncasecmp.c
index 8151c1a..513c353 100644
--- a/lib/c-strncasecmp.c
+++ b/lib/c-strncasecmp.c
@@ -1,5 +1,5 @@
 /* c-strncasecmp.c -- case insensitive string comparator in C locale
-   Copyright (C) 1998-1999, 2005-2006, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 1998-1999, 2005-2006, 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/careadlinkat.c b/lib/careadlinkat.c
index b5ae905..e56d503 100644
--- a/lib/careadlinkat.c
+++ b/lib/careadlinkat.c
@@ -1,6 +1,6 @@
 /* Read symbolic links into a buffer without size limitation, relative to fd.
 
-   Copyright (C) 2001, 2003-2004, 2007, 2009-2018 Free Software Foundation,
+   Copyright (C) 2001, 2003-2004, 2007, 2009-2019 Free Software Foundation,
    Inc.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/careadlinkat.h b/lib/careadlinkat.h
index 051d3ed..68b69aa 100644
--- a/lib/careadlinkat.h
+++ b/lib/careadlinkat.h
@@ -1,6 +1,6 @@
 /* Read symbolic links into a buffer without size limitation, relative to fd.
 
-   Copyright (C) 2011-2018 Free Software Foundation, Inc.
+   Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/cdefs.h b/lib/cdefs.h
index 2d620cc..96d2616 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-2018 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -139,7 +139,7 @@
    Headers that should use flexible arrays only if they're "real"
    (e.g. only if they won't affect sizeof()) should test
    #if __glibc_c99_flexarr_available.  */
-#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L && !defined __HP_cc
 # define __flexarr     []
 # define __glibc_c99_flexarr_available 1
 #elif __GNUC_PREREQ (2,97)
@@ -340,7 +340,7 @@
    semantics.
 
    clang++ identifies itself as gcc-4.2, but has support for GNU inlining
-   semantics, that can be checked fot by using the __GNUC_STDC_INLINE_ and
+   semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and
    __GNUC_GNU_INLINE__ macro definitions.  */
 #if (!defined __cplusplus || __GNUC_PREREQ (4,3) \
      || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \
diff --git a/lib/cloexec.c b/lib/cloexec.c
index 238ab18..db42576 100644
--- a/lib/cloexec.c
+++ b/lib/cloexec.c
@@ -1,6 +1,6 @@
 /* cloexec.c - set or clear the close-on-exec descriptor flag
 
-   Copyright (C) 1991, 2004-2006, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 1991, 2004-2006, 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/cloexec.h b/lib/cloexec.h
index 5902805..06ad945 100644
--- a/lib/cloexec.h
+++ b/lib/cloexec.h
@@ -1,6 +1,6 @@
 /* cloexec.c - set or clear the close-on-exec descriptor flag
 
-   Copyright (C) 2004, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/close-stream.c b/lib/close-stream.c
index 3d5a52e..5458c4f 100644
--- a/lib/close-stream.c
+++ b/lib/close-stream.c
@@ -1,6 +1,6 @@
 /* Close a stream, with nicer error checking than fclose's.
 
-   Copyright (C) 1998-2002, 2004, 2006-2018 Free Software Foundation, Inc.
+   Copyright (C) 1998-2002, 2004, 2006-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/count-leading-zeros.h b/lib/count-leading-zeros.h
index efb0851..e5ac2e1 100644
--- a/lib/count-leading-zeros.h
+++ b/lib/count-leading-zeros.h
@@ -1,5 +1,5 @@
 /* count-leading-zeros.h -- counts the number of leading 0 bits in a word.
-   Copyright (C) 2012-2018 Free Software Foundation, Inc.
+   Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/count-one-bits.h b/lib/count-one-bits.h
index ae1872b..0056994 100644
--- a/lib/count-one-bits.h
+++ b/lib/count-one-bits.h
@@ -1,5 +1,5 @@
 /* count-one-bits.h -- counts the number of 1-bits in a word.
-   Copyright (C) 2007-2018 Free Software Foundation, Inc.
+   Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/count-trailing-zeros.h b/lib/count-trailing-zeros.h
index a4c7848..3f78696 100644
--- a/lib/count-trailing-zeros.h
+++ b/lib/count-trailing-zeros.h
@@ -1,5 +1,5 @@
 /* count-trailing-zeros.h -- counts the number of trailing 0 bits in a word.
-   Copyright 2013-2018 Free Software Foundation, Inc.
+   Copyright 2013-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/diffseq.h b/lib/diffseq.h
index 9244729..c6aac3d 100644
--- a/lib/diffseq.h
+++ b/lib/diffseq.h
@@ -1,6 +1,6 @@
 /* Analyze differences between two vectors.
 
-   Copyright (C) 1988-1989, 1992-1995, 2001-2004, 2006-2018 Free Software
+   Copyright (C) 1988-1989, 1992-1995, 2001-2004, 2006-2019 Free Software
    Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/dirent.in.h b/lib/dirent.in.h
index 2ab25af..a3c8eb3 100644
--- a/lib/dirent.in.h
+++ b/lib/dirent.in.h
@@ -1,5 +1,5 @@
 /* A GNU-like <dirent.h>.
-   Copyright (C) 2006-2018 Free Software Foundation, Inc.
+   Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/dirfd.c b/lib/dirfd.c
index 19c8046..bc858fd 100644
--- a/lib/dirfd.c
+++ b/lib/dirfd.c
@@ -1,6 +1,6 @@
 /* dirfd.c -- return the file descriptor associated with an open DIR*
 
-   Copyright (C) 2001, 2006, 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2006, 2008-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/dosname.h b/lib/dosname.h
index fef3b6d..c0ab684 100644
--- a/lib/dosname.h
+++ b/lib/dosname.h
@@ -1,6 +1,6 @@
 /* File names on MS-DOS/Windows systems.
 
-   Copyright (C) 2000-2001, 2004-2006, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2000-2001, 2004-2006, 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/dtotimespec.c b/lib/dtotimespec.c
index dcbd280..a8ff04a 100644
--- a/lib/dtotimespec.c
+++ b/lib/dtotimespec.c
@@ -1,6 +1,6 @@
 /* Convert double to timespec.
 
-   Copyright (C) 2011-2018 Free Software Foundation, Inc.
+   Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/dup2.c b/lib/dup2.c
index c7d1767..d3aafa4 100644
--- a/lib/dup2.c
+++ b/lib/dup2.c
@@ -1,6 +1,6 @@
 /* Duplicate an open file descriptor to a specified file descriptor.
 
-   Copyright (C) 1999, 2004-2007, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2004-2007, 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/errno.in.h b/lib/errno.in.h
index b95c4e9..3bd27f1 100644
--- a/lib/errno.in.h
+++ b/lib/errno.in.h
@@ -1,6 +1,6 @@
 /* A POSIX-like <errno.h>.
 
-   Copyright (C) 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/euidaccess.c b/lib/euidaccess.c
index de5d82b..fece4cf 100644
--- a/lib/euidaccess.c
+++ b/lib/euidaccess.c
@@ -1,6 +1,6 @@
 /* euidaccess -- check if effective user id can access file
 
-   Copyright (C) 1990-1991, 1995, 1998, 2000, 2003-2006, 2008-2018 Free
+   Copyright (C) 1990-1991, 1995, 1998, 2000, 2003-2006, 2008-2019 Free
    Software Foundation, Inc.
 
    This file is part of the GNU C Library.
diff --git a/lib/execinfo.in.h b/lib/execinfo.in.h
index 83e1b28..def124e 100644
--- a/lib/execinfo.in.h
+++ b/lib/execinfo.in.h
@@ -1,6 +1,6 @@
 /* Information about executables.
 
-   Copyright (C) 2012-2018 Free Software Foundation, Inc.
+   Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/explicit_bzero.c b/lib/explicit_bzero.c
index 79b7fd6..79ef186 100644
--- a/lib/explicit_bzero.c
+++ b/lib/explicit_bzero.c
@@ -1,5 +1,5 @@
 /* Erasure of sensitive data, generic implementation.
-   Copyright (C) 2016-2018 Free Software Foundation, Inc.
+   Copyright (C) 2016-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
diff --git a/lib/faccessat.c b/lib/faccessat.c
index 8aab786..6c63e61 100644
--- a/lib/faccessat.c
+++ b/lib/faccessat.c
@@ -1,5 +1,5 @@
 /* Check the access rights of a file relative to an open directory.
-   Copyright (C) 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/fcntl.c b/lib/fcntl.c
index 74e0f5d..51f62ef 100644
--- a/lib/fcntl.c
+++ b/lib/fcntl.c
@@ -1,6 +1,6 @@
 /* Provide file descriptor control.
 
-   Copyright (C) 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
    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
@@ -545,7 +545,7 @@ rpl_fcntl_DUPFD_CLOEXEC (int fd, int target)
 #ifdef __KLIBC__
 
 static int
-klibc_fcntl (int fd, int action, /* arg */...);
+klibc_fcntl (int fd, int action, /* arg */...)
 {
   va_list arg_ptr;
   int arg;
diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h
index a1e7d35..eb70dc6 100644
--- a/lib/fcntl.in.h
+++ b/lib/fcntl.in.h
@@ -1,6 +1,6 @@
 /* Like <fcntl.h>, but with non-working flags defined to 0.
 
-   Copyright (C) 2006-2018 Free Software Foundation, Inc.
+   Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/fdopendir.c b/lib/fdopendir.c
index 9adefd2..b65588a 100644
--- a/lib/fdopendir.c
+++ b/lib/fdopendir.c
@@ -1,5 +1,5 @@
 /* provide a replacement fdopendir function
-   Copyright (C) 2004-2018 Free Software Foundation, Inc.
+   Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/filemode.c b/lib/filemode.c
index 574e994..71f2b82 100644
--- a/lib/filemode.c
+++ b/lib/filemode.c
@@ -1,6 +1,6 @@
 /* filemode.c -- make a string describing file modes
 
-   Copyright (C) 1985, 1990, 1993, 1998-2000, 2004, 2006, 2009-2018 Free
+   Copyright (C) 1985, 1990, 1993, 1998-2000, 2004, 2006, 2009-2019 Free
    Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/filemode.h b/lib/filemode.h
index f9d1d21..5ae9da0 100644
--- a/lib/filemode.h
+++ b/lib/filemode.h
@@ -1,6 +1,6 @@
 /* Make a string describing file modes.
 
-   Copyright (C) 1998-1999, 2003, 2006, 2009-2018 Free Software Foundation,
+   Copyright (C) 1998-1999, 2003, 2006, 2009-2019 Free Software Foundation,
    Inc.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/filevercmp.c b/lib/filevercmp.c
index 9e9b440..aebe088 100644
--- a/lib/filevercmp.c
+++ b/lib/filevercmp.c
@@ -1,7 +1,7 @@
 /*
    Copyright (C) 1995 Ian Jackson <address@hidden>
    Copyright (C) 2001 Anthony Towns <address@hidden>
-   Copyright (C) 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/filevercmp.h b/lib/filevercmp.h
index 5e59456..23766f0 100644
--- a/lib/filevercmp.h
+++ b/lib/filevercmp.h
@@ -1,7 +1,7 @@
 /*
    Copyright (C) 1995 Ian Jackson <address@hidden>
    Copyright (C) 2001 Anthony Towns <address@hidden>
-   Copyright (C) 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/fingerprint.c b/lib/fingerprint.c
new file mode 100644
index 0000000..e55de9c
--- /dev/null
+++ b/lib/fingerprint.c
@@ -0,0 +1,66 @@
+/* Placeholder fingerprint for Emacs
+
+Copyright 2019 Free Software Foundation, Inc.
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include "fingerprint.h"
+
+/* This random fingerprint was generated by the shell command:
+
+   shuf -i 0-255 -n 32 -r | awk '{printf "   0x%.02X,\n", $0}'
+
+   In the final Emacs executable, this random fingerprint is replaced
+   by a fingerprint of the temporary Emacs executable that was built
+   along the way.  */
+
+unsigned char const fingerprint[] =
+  {
+   0xDE,
+   0x86,
+   0xBB,
+   0x99,
+   0xFF,
+   0xF5,
+   0x46,
+   0x9A,
+   0x9E,
+   0x3F,
+   0x9F,
+   0x5D,
+   0x9A,
+   0xDF,
+   0xF0,
+   0x91,
+   0xBD,
+   0xCD,
+   0xC1,
+   0xE8,
+   0x0C,
+   0x16,
+   0x1E,
+   0xAF,
+   0xB8,
+   0x6C,
+   0xE2,
+   0x2B,
+   0xB1,
+   0x24,
+   0xCE,
+   0xB0,
+  };
diff --git a/src/mini-gmp-emacs.c b/lib/fingerprint.h
similarity index 53%
copy from src/mini-gmp-emacs.c
copy to lib/fingerprint.h
index 7a1b7ab..0b195fd 100644
--- a/src/mini-gmp-emacs.c
+++ b/lib/fingerprint.h
@@ -1,6 +1,6 @@
-/* Tailor mini-gmp.c for GNU Emacs
+/* Header file for the Emacs build fingerprint.
 
-Copyright 2018 Free Software Foundation, Inc.
+Copyright (C) 2016, 2018-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -15,18 +15,15 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See 
the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#include <config.h>
+#ifndef EMACS_FINGERPRINT_H
+#define EMACS_FINGERPRINT_H
 
-#include <stddef.h>
+/* We generate fingerprint.c and fingerprint.o from all the sources in
+   Emacs.  This way, we have a unique value that we can use to pair
+   data files (like a portable dump image) with a specific build of
+   Emacs.  */
+extern unsigned char const fingerprint[32];
 
-/* Pacify GCC -Wsuggest-attribute=malloc.  */
-static void *gmp_default_alloc (size_t) ATTRIBUTE_MALLOC;
-
-/* Pacify GCC -Wunused-variable for variables used only in 'assert' calls.  */
-#if defined NDEBUG && GNUC_PREREQ (4, 6, 0)
-# pragma GCC diagnostic ignored "-Wunused-variable"
 #endif
-
-#include "mini-gmp.c"
diff --git a/lib/flexmember.h b/lib/flexmember.h
index 7e3f598..0d65f6d 100644
--- a/lib/flexmember.h
+++ b/lib/flexmember.h
@@ -1,6 +1,6 @@
 /* Sizes of structs with flexible array members.
 
-   Copyright 2016-2018 Free Software Foundation, Inc.
+   Copyright 2016-2019 Free Software Foundation, Inc.
 
    This file is part of the GNU C Library.
 
diff --git a/lib/fpending.c b/lib/fpending.c
index de370d4..3c01285 100644
--- a/lib/fpending.c
+++ b/lib/fpending.c
@@ -1,5 +1,5 @@
 /* fpending.c -- return the number of pending output bytes on a stream
-   Copyright (C) 2000, 2004, 2006-2007, 2009-2018 Free Software Foundation,
+   Copyright (C) 2000, 2004, 2006-2007, 2009-2019 Free Software Foundation,
    Inc.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/fpending.h b/lib/fpending.h
index 2ff26bc..097a3ef 100644
--- a/lib/fpending.h
+++ b/lib/fpending.h
@@ -1,6 +1,6 @@
 /* Declare __fpending.
 
-   Copyright (C) 2000, 2003, 2005-2006, 2009-2018 Free Software Foundation,
+   Copyright (C) 2000, 2003, 2005-2006, 2009-2019 Free Software Foundation,
    Inc.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/fstatat.c b/lib/fstatat.c
index 63ceceb..019d3c6 100644
--- a/lib/fstatat.c
+++ b/lib/fstatat.c
@@ -1,6 +1,6 @@
 /* Work around an fstatat bug on Solaris 9.
 
-   Copyright (C) 2006, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2009-2019 Free Software Foundation, Inc.
 
    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
@@ -36,10 +36,14 @@ orig_fstatat (int fd, char const *filename, struct stat 
*buf, int flags)
 }
 #endif
 
+#ifdef __osf__
 /* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
    eliminates this include because of the preliminary #include <sys/stat.h>
    above.  */
-#include "sys/stat.h"
+# include "sys/stat.h"
+#else
+# include <sys/stat.h>
+#endif
 
 #include "stat-time.h"
 
diff --git a/lib/fsusage.c b/lib/fsusage.c
index 17daf91..7ddeb52 100644
--- a/lib/fsusage.c
+++ b/lib/fsusage.c
@@ -1,6 +1,6 @@
 /* fsusage.c -- return space usage of mounted file systems
 
-   Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2018 Free Software
+   Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2019 Free Software
    Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/fsusage.h b/lib/fsusage.h
index 65daa73..1d550bc 100644
--- a/lib/fsusage.h
+++ b/lib/fsusage.h
@@ -1,6 +1,6 @@
 /* fsusage.h -- declarations for file system space usage info
 
-   Copyright (C) 1991-1992, 1997, 2003-2006, 2009-2018 Free Software
+   Copyright (C) 1991-1992, 1997, 2003-2006, 2009-2019 Free Software
    Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/fsync.c b/lib/fsync.c
index ecacb0b..bfb6d28 100644
--- a/lib/fsync.c
+++ b/lib/fsync.c
@@ -7,7 +7,7 @@
 
    Written by Richard W.M. Jones <rjones.at.redhat.com>
 
-   Copyright (C) 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public
diff --git a/lib/ftoastr.c b/lib/ftoastr.c
index a6899b2..55f1e02 100644
--- a/lib/ftoastr.c
+++ b/lib/ftoastr.c
@@ -1,6 +1,6 @@
 /* floating point to accurate string
 
-   Copyright (C) 2010-2018 Free Software Foundation, Inc.
+   Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
    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
@@ -40,9 +40,7 @@
 # define FLOAT_PREC_BOUND _GL_LDBL_PREC_BOUND
 # define FTOASTR ldtoastr
 # define PROMOTED_FLOAT long double
-# if HAVE_C99_STRTOLD
-#  define STRTOF strtold
-# endif
+# define STRTOF strtold
 #elif LENGTH == 2
 # define FLOAT double
 # define FLOAT_DIG DBL_DIG
@@ -63,7 +61,7 @@
 # endif
 #endif
 
-/* On pre-C99 hosts, approximate strtof and strtold with strtod.  This
+/* On pre-C99 hosts, approximate strtof with strtod.  This
    may generate one or two extra digits, but that's better than not
    working at all.  */
 #ifndef STRTOF
diff --git a/lib/ftoastr.h b/lib/ftoastr.h
index 2d78358..752e3c4 100644
--- a/lib/ftoastr.h
+++ b/lib/ftoastr.h
@@ -1,6 +1,6 @@
 /* floating point to accurate string
 
-   Copyright (C) 2010-2018 Free Software Foundation, Inc.
+   Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/get-permissions.c b/lib/get-permissions.c
index 3b98451..99b4664 100644
--- a/lib/get-permissions.c
+++ b/lib/get-permissions.c
@@ -1,6 +1,6 @@
 /* Get permissions of a file.  -*- coding: utf-8 -*-
 
-   Copyright (C) 2002-2003, 2005-2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2005-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/getdtablesize.c b/lib/getdtablesize.c
index ac05bc4..03a9243 100644
--- a/lib/getdtablesize.c
+++ b/lib/getdtablesize.c
@@ -1,5 +1,5 @@
 /* getdtablesize() function: Return maximum possible file descriptor value + 1.
-   Copyright (C) 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2008-2019 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2008.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/getgroups.c b/lib/getgroups.c
index cd6f4d7..d8c77e9 100644
--- a/lib/getgroups.c
+++ b/lib/getgroups.c
@@ -1,6 +1,6 @@
 /* provide consistent interface to getgroups for systems that don't allow N==0
 
-   Copyright (C) 1996, 1999, 2003, 2006-2018 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1999, 2003, 2006-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/getloadavg.c b/lib/getloadavg.c
index 4e7eb0d..08c14ef 100644
--- a/lib/getloadavg.c
+++ b/lib/getloadavg.c
@@ -1,6 +1,6 @@
 /* Get the system load averages.
 
-   Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2018 Free Software
+   Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2019 Free Software
    Foundation, Inc.
 
    NOTE: The canonical source of this file is maintained with gnulib.
@@ -47,8 +47,8 @@
    N_NAME_POINTER               The nlist n_name element is a pointer,
                                 not an array.
    HAVE_STRUCT_NLIST_N_UN_N_NAME 'n_un.n_name' is member of 'struct nlist'.
-   LINUX_LDAV_FILE              [__linux__, __CYGWIN__]: File containing
-                                load averages.
+   LINUX_LDAV_FILE              [__linux__, __ANDROID__, __CYGWIN__]: File
+                                containing load averages.
 
    Specific system predefines this file uses, aside from setting
    default values if not emacs:
@@ -65,7 +65,7 @@
    UMAX4_3
    VMS
    _WIN32                       Native Windows (possibly also defined on 
Cygwin)
-   __linux__                    Linux: assumes /proc file system mounted.
+   __linux__, __ANDROID__       Linux: assumes /proc file system mounted.
                                 Support from Michael K. Johnson.
    __CYGWIN__                   Cygwin emulates linux /proc/loadavg.
    __NetBSD__                   NetBSD: assumes /kern file system mounted.
@@ -263,7 +263,7 @@
 # ifdef LOAD_AVE_TYPE
 
 #  ifndef __VMS
-#   ifndef __linux__
+#   if !(defined __linux__ || defined __ANDROID__)
 #    ifndef NLIST_STRUCT
 #     include <a.out.h>
 #    else /* NLIST_STRUCT */
@@ -286,7 +286,7 @@
 #    ifndef LDAV_SYMBOL
 #     define LDAV_SYMBOL "_avenrun"
 #    endif /* LDAV_SYMBOL */
-#   endif /* __linux__ */
+#   endif /* __linux__ || __ANDROID__ */
 
 #  else /* __VMS */
 
@@ -359,7 +359,8 @@
 #  include <sys/dg_sys_info.h>
 # endif
 
-# if (defined __linux__ || defined __CYGWIN__ || defined SUNOS_5        \
+# if (defined __linux__ || defined __ANDROID__ \
+      || defined __CYGWIN__ || defined SUNOS_5 \
       || (defined LOAD_AVE_TYPE && ! defined __VMS))
 #  include <fcntl.h>
 # endif
@@ -388,7 +389,7 @@ static bool getloadavg_initialized;
 /* Offset in kmem to seek to read load average, or 0 means invalid.  */
 static long offset;
 
-#  if ! defined __VMS && ! defined sgi && ! defined __linux__
+#  if ! defined __VMS && ! defined sgi && ! (defined __linux__ || defined 
__ANDROID__)
 static struct nlist name_list[2];
 #  endif
 
@@ -423,17 +424,17 @@ getloadavg (double loadavg[], int nelem)
   int saved_errno;
 
   kc = kstat_open ();
-  if (kc == 0)
+  if (kc == NULL)
     return -1;
   ksp = kstat_lookup (kc, "unix", 0, "system_misc");
-  if (ksp == 0)
+  if (ksp == NULL)
     return -1;
   if (kstat_read (kc, ksp, 0) == -1)
     return -1;
 
 
   kn = kstat_data_lookup (ksp, "avenrun_1min");
-  if (kn == 0)
+  if (kn == NULL)
     {
       /* Return -1 if no load average information is available.  */
       nelem = 0;
@@ -446,14 +447,14 @@ getloadavg (double loadavg[], int nelem)
   if (nelem >= 2)
     {
       kn = kstat_data_lookup (ksp, "avenrun_5min");
-      if (kn != 0)
+      if (kn != NULL)
         {
           loadavg[elem++] = (double) kn->value.ul / FSCALE;
 
           if (nelem >= 3)
             {
               kn = kstat_data_lookup (ksp, "avenrun_15min");
-              if (kn != 0)
+              if (kn != NULL)
                 loadavg[elem++] = (double) kn->value.ul / FSCALE;
             }
         }
@@ -498,8 +499,8 @@ getloadavg (double loadavg[], int nelem)
   }
 # endif
 
-# if !defined (LDAV_DONE) && (defined (__linux__) || defined (__CYGWIN__))
-                                              /* Linux without glibc, Cygwin */
+# if !defined (LDAV_DONE) && (defined __linux__ || defined __ANDROID__ || 
defined __CYGWIN__)
+                                      /* Linux without glibc, Android, Cygwin 
*/
 #  define LDAV_DONE
 #  undef LOAD_AVE_TYPE
 
@@ -554,7 +555,7 @@ getloadavg (double loadavg[], int nelem)
 
   return elem;
 
-# endif /* __linux__ || __CYGWIN__ */
+# endif /* __linux__ || __ANDROID__ || __CYGWIN__ */
 
 # if !defined (LDAV_DONE) && defined (__NetBSD__)          /* NetBSD < 0.9 */
 #  define LDAV_DONE
@@ -894,7 +895,7 @@ getloadavg (double loadavg[], int nelem)
       /* We pass 0 for the kernel, corefile, and swapfile names
          to use the currently running kernel.  */
       kd = kvm_open (0, 0, 0, O_RDONLY, 0);
-      if (kd != 0)
+      if (kd != NULL)
         {
           /* nlist the currently running kernel.  */
           kvm_nlist (kd, name_list);
diff --git a/lib/getopt-cdefs.in.h b/lib/getopt-cdefs.in.h
index 12b5a87..049145b 100644
--- a/lib/getopt-cdefs.in.h
+++ b/lib/getopt-cdefs.in.h
@@ -1,5 +1,5 @@
 /* getopt-on-non-glibc compatibility macros.
-   Copyright (C) 1989-2018 Free Software Foundation, Inc.
+   Copyright (C) 1989-2019 Free Software Foundation, Inc.
    This file is part of gnulib.
    Unlike most of the getopt implementation, it is NOT shared
    with the GNU C Library.
diff --git a/lib/getopt-core.h b/lib/getopt-core.h
index e51b6c7..6360ad6 100644
--- a/lib/getopt-core.h
+++ b/lib/getopt-core.h
@@ -1,5 +1,5 @@
 /* Declarations for getopt (basic, portable features only).
-   Copyright (C) 1989-2018 Free Software Foundation, Inc.
+   Copyright (C) 1989-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library and is also part of gnulib.
    Patches to this file should be submitted to both projects.
 
diff --git a/lib/getopt-ext.h b/lib/getopt-ext.h
index cb41206..13cb007 100644
--- a/lib/getopt-ext.h
+++ b/lib/getopt-ext.h
@@ -1,5 +1,5 @@
 /* Declarations for getopt (GNU extensions).
-   Copyright (C) 1989-2018 Free Software Foundation, Inc.
+   Copyright (C) 1989-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library and is also part of gnulib.
    Patches to this file should be submitted to both projects.
 
diff --git a/lib/getopt-pfx-core.h b/lib/getopt-pfx-core.h
index c62f9e2..8fac269 100644
--- a/lib/getopt-pfx-core.h
+++ b/lib/getopt-pfx-core.h
@@ -1,5 +1,5 @@
 /* getopt (basic, portable features) gnulib wrapper header.
-   Copyright (C) 1989-2018 Free Software Foundation, Inc.
+   Copyright (C) 1989-2019 Free Software Foundation, Inc.
    This file is part of gnulib.
    Unlike most of the getopt implementation, it is NOT shared
    with the GNU C Library.
diff --git a/lib/getopt-pfx-ext.h b/lib/getopt-pfx-ext.h
index 753f129..0e21aef 100644
--- a/lib/getopt-pfx-ext.h
+++ b/lib/getopt-pfx-ext.h
@@ -1,5 +1,5 @@
 /* getopt (GNU extensions) gnulib wrapper header.
-   Copyright (C) 1989-2018 Free Software Foundation, Inc.
+   Copyright (C) 1989-2019 Free Software Foundation, Inc.
    This file is part of gnulib.
    Unlike most of the getopt implementation, it is NOT shared
    with the GNU C Library.
diff --git a/lib/getopt.c b/lib/getopt.c
index 11e36ee..8ee075a 100644
--- a/lib/getopt.c
+++ b/lib/getopt.c
@@ -1,5 +1,5 @@
 /* Getopt for GNU.
-   Copyright (C) 1987-2018 Free Software Foundation, Inc.
+   Copyright (C) 1987-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library and is also part of gnulib.
    Patches to this file should be submitted to both projects.
 
diff --git a/lib/getopt.in.h b/lib/getopt.in.h
index 5fb58dd..c77f34c 100644
--- a/lib/getopt.in.h
+++ b/lib/getopt.in.h
@@ -1,5 +1,5 @@
 /* Declarations for getopt.
-   Copyright (C) 1989-2018 Free Software Foundation, Inc.
+   Copyright (C) 1989-2019 Free Software Foundation, Inc.
    This file is part of gnulib.
    Unlike most of the getopt implementation, it is NOT shared
    with the GNU C Library, which supplies a different version of
diff --git a/lib/getopt1.c b/lib/getopt1.c
index 9c7fff4..883aa6b 100644
--- a/lib/getopt1.c
+++ b/lib/getopt1.c
@@ -1,5 +1,5 @@
 /* getopt_long and getopt_long_only entry points for GNU getopt.
-   Copyright (C) 1987-2018 Free Software Foundation, Inc.
+   Copyright (C) 1987-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library and is also part of gnulib.
    Patches to this file should be submitted to both projects.
 
diff --git a/lib/getopt_int.h b/lib/getopt_int.h
index b0e9a6d..e63706f 100644
--- a/lib/getopt_int.h
+++ b/lib/getopt_int.h
@@ -1,5 +1,5 @@
 /* Internal declarations for getopt.
-   Copyright (C) 1989-2018 Free Software Foundation, Inc.
+   Copyright (C) 1989-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library and is also part of gnulib.
    Patches to this file should be submitted to both projects.
 
diff --git a/lib/gettext.h b/lib/gettext.h
index f2d7458..c7c0fdb 100644
--- a/lib/gettext.h
+++ b/lib/gettext.h
@@ -1,5 +1,5 @@
 /* Convenience header for conditional use of GNU <libintl.h>.
-   Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2018 Free Software
+   Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2019 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -184,9 +184,16 @@ npgettext_aux (const char *domain,
 
 #include <string.h>
 
-#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
-     /* || __STDC_VERSION__ == 199901L
-        || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ )
+/* GNULIB_NO_VLA can be defined to disable use of VLAs even if supported.
+   This relates to the -Wvla and -Wvla-larger-than warnings, enabled in
+   the default GCC many warnings set.  This allows programs to disable use
+   of VLAs, which may be unintended, or may be awkward to support portably,
+   or may have security implications due to non-deterministic stack usage.  */
+
+#if (!defined GNULIB_NO_VLA \
+     && (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
+     /*  || (__STDC_VERSION__ == 199901L && !defined __HP_cc)
+         || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ ))
 # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
 #else
 # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
diff --git a/lib/gettime.c b/lib/gettime.c
index bb59c44..1fd153f 100644
--- a/lib/gettime.c
+++ b/lib/gettime.c
@@ -1,6 +1,6 @@
 /* gettime -- get the system clock
 
-   Copyright (C) 2002, 2004-2007, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004-2007, 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c
index 1bd50fa..e728bf4 100644
--- a/lib/gettimeofday.c
+++ b/lib/gettimeofday.c
@@ -1,6 +1,6 @@
 /* Provide gettimeofday for systems that don't have it or for which it's 
broken.
 
-   Copyright (C) 2001-2003, 2005-2007, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003, 2005-2007, 2009-2019 Free Software Foundation, Inc.
 
    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
@@ -72,10 +72,10 @@ gettimeofday (struct timeval *restrict tv, void *restrict 
tz)
 
   /* On native Windows, there are two ways to get the current time:
      GetSystemTimeAsFileTime
-     <https://msdn.microsoft.com/en-us/library/ms724397.aspx>
+     
<https://docs.microsoft.com/en-us/windows/desktop/api/sysinfoapi/nf-sysinfoapi-getsystemtimeasfiletime>
      or
      GetSystemTimePreciseAsFileTime
-     <https://msdn.microsoft.com/en-us/library/hh706895.aspx>.
+     
<https://docs.microsoft.com/en-us/windows/desktop/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime>.
      GetSystemTimeAsFileTime produces values that jump by increments of
      15.627 milliseconds (!) on average.
      Whereas GetSystemTimePreciseAsFileTime values usually jump by 1 or 2
@@ -92,7 +92,7 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz)
     GetSystemTimeAsFileTime (&current_time);
 
   /* Convert from FILETIME to 'struct timeval'.  */
-  /* FILETIME: <https://msdn.microsoft.com/en-us/library/ms724284.aspx> */
+  /* FILETIME: 
<https://docs.microsoft.com/en-us/windows/desktop/api/minwinbase/ns-minwinbase-filetime>
 */
   ULONGLONG since_1601 =
     ((ULONGLONG) current_time.dwHighDateTime << 32)
     | (ULONGLONG) current_time.dwLowDateTime;
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index aa32dcc..ade4ff8 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -1,5 +1,5 @@
 ## DO NOT EDIT! GENERATED AUTOMATICALLY!
-# Copyright (C) 2002-2018 Free Software Foundation, Inc.
+# Copyright (C) 2002-2019 Free Software Foundation, Inc.
 #
 # 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
@@ -44,6 +44,7 @@
 #  --avoid=malloc-posix \
 #  --avoid=mbrtowc \
 #  --avoid=mbsinit \
+#  --avoid=memchr \
 #  --avoid=mkdir \
 #  --avoid=msvc-inval \
 #  --avoid=msvc-nothrow \
@@ -111,6 +112,7 @@
 #  largefile \
 #  lstat \
 #  manywarnings \
+#  memmem-simple \
 #  memrchr \
 #  minmax \
 #  mkostemp \
@@ -176,10 +178,10 @@ BUILD_DETAILS = @BUILD_DETAILS@
 BYTESWAP_H = @BYTESWAP_H@
 CAIRO_CFLAGS = @CAIRO_CFLAGS@
 CAIRO_LIBS = @CAIRO_LIBS@
-CANNOT_DUMP = @CANNOT_DUMP@
 CC = @CC@
 CFLAGS = @CFLAGS@
 CFLAGS_SOUND = @CFLAGS_SOUND@
+CHECK_STRUCTS = @CHECK_STRUCTS@
 CLIENTRES = @CLIENTRES@
 CLIENTW = @CLIENTW@
 CM_OBJ = @CM_OBJ@
@@ -197,6 +199,7 @@ DBUS_OBJ = @DBUS_OBJ@
 DEFS = @DEFS@
 DESLIB = @DESLIB@
 DOCMISC_W32 = @DOCMISC_W32@
+DUMPING = @DUMPING@
 ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
@@ -431,6 +434,7 @@ GNULIB_STRSTR = @GNULIB_STRSTR@
 GNULIB_STRTOD = @GNULIB_STRTOD@
 GNULIB_STRTOIMAX = @GNULIB_STRTOIMAX@
 GNULIB_STRTOK_R = @GNULIB_STRTOK_R@
+GNULIB_STRTOLD = @GNULIB_STRTOLD@
 GNULIB_STRTOLL = @GNULIB_STRTOLL@
 GNULIB_STRTOULL = @GNULIB_STRTOULL@
 GNULIB_STRTOUMAX = @GNULIB_STRTOUMAX@
@@ -478,6 +482,7 @@ GTK_CFLAGS = @GTK_CFLAGS@
 GTK_LIBS = @GTK_LIBS@
 GTK_OBJ = @GTK_OBJ@
 GZIP_PROG = @GZIP_PROG@
+HAVE_ALLOCA_H = @HAVE_ALLOCA_H@
 HAVE_ALPHASORT = @HAVE_ALPHASORT@
 HAVE_ATOLL = @HAVE_ATOLL@
 HAVE_C99_STDINT_H = @HAVE_C99_STDINT_H@
@@ -556,6 +561,7 @@ HAVE_GETTIMEOFDAY = @HAVE_GETTIMEOFDAY@
 HAVE_GRANTPT = @HAVE_GRANTPT@
 HAVE_GROUP_MEMBER = @HAVE_GROUP_MEMBER@
 HAVE_IMAXDIV_T = @HAVE_IMAXDIV_T@
+HAVE_INITSTATE = @HAVE_INITSTATE@
 HAVE_INTTYPES_H = @HAVE_INTTYPES_H@
 HAVE_LCHMOD = @HAVE_LCHMOD@
 HAVE_LCHOWN = @HAVE_LCHOWN@
@@ -566,6 +572,7 @@ HAVE_LSTAT = @HAVE_LSTAT@
 HAVE_MAKEINFO = @HAVE_MAKEINFO@
 HAVE_MAX_ALIGN_T = @HAVE_MAX_ALIGN_T@
 HAVE_MBSLEN = @HAVE_MBSLEN@
+HAVE_MBTOWC = @HAVE_MBTOWC@
 HAVE_MEMCHR = @HAVE_MEMCHR@
 HAVE_MEMPCPY = @HAVE_MEMPCPY@
 HAVE_MKDIRAT = @HAVE_MKDIRAT@
@@ -584,6 +591,7 @@ HAVE_OPENAT = @HAVE_OPENAT@
 HAVE_OPENDIR = @HAVE_OPENDIR@
 HAVE_OS_H = @HAVE_OS_H@
 HAVE_PCLOSE = @HAVE_PCLOSE@
+HAVE_PDUMPER = @HAVE_PDUMPER@
 HAVE_PIPE = @HAVE_PIPE@
 HAVE_PIPE2 = @HAVE_PIPE2@
 HAVE_POPEN = @HAVE_POPEN@
@@ -613,6 +621,7 @@ HAVE_SCANDIR = @HAVE_SCANDIR@
 HAVE_SECURE_GETENV = @HAVE_SECURE_GETENV@
 HAVE_SETENV = @HAVE_SETENV@
 HAVE_SETHOSTNAME = @HAVE_SETHOSTNAME@
+HAVE_SETSTATE = @HAVE_SETSTATE@
 HAVE_SIGACTION = @HAVE_SIGACTION@
 HAVE_SIGHANDLER_T = @HAVE_SIGHANDLER_T@
 HAVE_SIGINFO_T = @HAVE_SIGINFO_T@
@@ -630,6 +639,7 @@ HAVE_STRPBRK = @HAVE_STRPBRK@
 HAVE_STRPTIME = @HAVE_STRPTIME@
 HAVE_STRSEP = @HAVE_STRSEP@
 HAVE_STRTOD = @HAVE_STRTOD@
+HAVE_STRTOLD = @HAVE_STRTOLD@
 HAVE_STRTOLL = @HAVE_STRTOLL@
 HAVE_STRTOULL = @HAVE_STRTOULL@
 HAVE_STRUCT_RANDOM_DATA = @HAVE_STRUCT_RANDOM_DATA@
@@ -859,6 +869,7 @@ REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
 REPLACE_GETPASS = @REPLACE_GETPASS@
 REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@
 REPLACE_GMTIME = @REPLACE_GMTIME@
+REPLACE_INITSTATE = @REPLACE_INITSTATE@
 REPLACE_ISATTY = @REPLACE_ISATTY@
 REPLACE_LCHOWN = @REPLACE_LCHOWN@
 REPLACE_LINK = @REPLACE_LINK@
@@ -894,6 +905,7 @@ REPLACE_PUTENV = @REPLACE_PUTENV@
 REPLACE_PWRITE = @REPLACE_PWRITE@
 REPLACE_QSORT_R = @REPLACE_QSORT_R@
 REPLACE_RAISE = @REPLACE_RAISE@
+REPLACE_RANDOM = @REPLACE_RANDOM@
 REPLACE_RANDOM_R = @REPLACE_RANDOM_R@
 REPLACE_READ = @REPLACE_READ@
 REPLACE_READLINK = @REPLACE_READLINK@
@@ -906,6 +918,7 @@ REPLACE_RENAMEAT = @REPLACE_RENAMEAT@
 REPLACE_RMDIR = @REPLACE_RMDIR@
 REPLACE_SELECT = @REPLACE_SELECT@
 REPLACE_SETENV = @REPLACE_SETENV@
+REPLACE_SETSTATE = @REPLACE_SETSTATE@
 REPLACE_SLEEP = @REPLACE_SLEEP@
 REPLACE_SNPRINTF = @REPLACE_SNPRINTF@
 REPLACE_SPRINTF = @REPLACE_SPRINTF@
@@ -927,6 +940,7 @@ REPLACE_STRSTR = @REPLACE_STRSTR@
 REPLACE_STRTOD = @REPLACE_STRTOD@
 REPLACE_STRTOIMAX = @REPLACE_STRTOIMAX@
 REPLACE_STRTOK_R = @REPLACE_STRTOK_R@
+REPLACE_STRTOLD = @REPLACE_STRTOLD@
 REPLACE_STRTOUMAX = @REPLACE_STRTOUMAX@
 REPLACE_STRUCT_TIMEVAL = @REPLACE_STRUCT_TIMEVAL@
 REPLACE_SYMLINK = @REPLACE_SYMLINK@
@@ -1009,6 +1023,7 @@ XMKMF = @XMKMF@
 XOBJ = @XOBJ@
 XRANDR_CFLAGS = @XRANDR_CFLAGS@
 XRANDR_LIBS = @XRANDR_LIBS@
+XRENDER_LIBS = @XRENDER_LIBS@
 XWIDGETS_OBJ = @XWIDGETS_OBJ@
 X_TOOLKIT_TYPE = @X_TOOLKIT_TYPE@
 ac_ct_CC = @ac_ct_CC@
@@ -1041,7 +1056,6 @@ gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7 = 
@gl_GNULIB_ENABLED_03e0aaad
 gl_GNULIB_ENABLED_2049e887c7e5308faad27b3f894bb8c9 = 
@gl_GNULIB_ENABLED_2049e887c7e5308faad27b3f894bb8c9@
 gl_GNULIB_ENABLED_21ee726a3540c09237a8e70c0baf7467 = 
@gl_GNULIB_ENABLED_21ee726a3540c09237a8e70c0baf7467@
 gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b = 
@gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b@
-gl_GNULIB_ENABLED_37f71b604aa9c54446783d80f42fe547 = 
@gl_GNULIB_ENABLED_37f71b604aa9c54446783d80f42fe547@
 gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31 = 
@gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31@
 gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c = 
@gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c@
 gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec = 
@gl_GNULIB_ENABLED_682e609604ccaac6be382e4ee3a4eaec@
@@ -1139,7 +1153,7 @@ ifneq (,$(GL_GENERATE_ALLOCA_H))
 alloca.h: alloca.in.h $(top_builddir)/config.status
        $(AM_V_GEN)rm -f address@hidden $@ && \
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-         cat $(srcdir)/alloca.in.h; \
+         sed -e 's|@''HAVE_ALLOCA_H''@|$(HAVE_ALLOCA_H)|g' < 
$(srcdir)/alloca.in.h; \
        } > address@hidden && \
        mv -f address@hidden $@
 else
@@ -1951,6 +1965,17 @@ EXTRA_libgnu_a_SOURCES += lstat.c
 endif
 ## end   gnulib module lstat
 
+## begin gnulib module memmem-simple
+ifeq (,$(OMIT_GNULIB_MODULE_memmem-simple))
+
+
+EXTRA_DIST += memmem.c str-two-way.h
+
+EXTRA_libgnu_a_SOURCES += memmem.c
+
+endif
+## end   gnulib module memmem-simple
+
 ## begin gnulib module memrchr
 ifeq (,$(OMIT_GNULIB_MODULE_memrchr))
 
@@ -2539,6 +2564,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) \
              -e 's/@''GNULIB_SECURE_GETENV''@/$(GNULIB_SECURE_GETENV)/g' \
              -e 's/@''GNULIB_SETENV''@/$(GNULIB_SETENV)/g' \
              -e 's/@''GNULIB_STRTOD''@/$(GNULIB_STRTOD)/g' \
+             -e 's/@''GNULIB_STRTOLD''@/$(GNULIB_STRTOLD)/g' \
              -e 's/@''GNULIB_STRTOLL''@/$(GNULIB_STRTOLL)/g' \
              -e 's/@''GNULIB_STRTOULL''@/$(GNULIB_STRTOULL)/g' \
              -e 's/@''GNULIB_SYSTEM_POSIX''@/$(GNULIB_SYSTEM_POSIX)/g' \
@@ -2552,7 +2578,9 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) \
              -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
              -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
              -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \
+             -e 's|@''HAVE_INITSTATE''@|$(HAVE_INITSTATE)|g' \
              -e 's|@''HAVE_DECL_INITSTATE''@|$(HAVE_DECL_INITSTATE)|g' \
+             -e 's|@''HAVE_MBTOWC''@|$(HAVE_MBTOWC)|g' \
              -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
              -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \
              -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
@@ -2570,8 +2598,10 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) \
              -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
              -e 's|@''HAVE_SECURE_GETENV''@|$(HAVE_SECURE_GETENV)|g' \
              -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \
+             -e 's|@''HAVE_SETSTATE''@|$(HAVE_SETSTATE)|g' \
              -e 's|@''HAVE_DECL_SETSTATE''@|$(HAVE_DECL_SETSTATE)|g' \
              -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
+             -e 's|@''HAVE_STRTOLD''@|$(HAVE_STRTOLD)|g' \
              -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
              -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \
              -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' 
\
@@ -2580,6 +2610,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) \
              -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \
              -e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \
              -e 
's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
+             -e 's|@''REPLACE_INITSTATE''@|$(REPLACE_INITSTATE)|g' \
              -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \
              -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \
              -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
@@ -2587,11 +2618,14 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) \
              -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \
              -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
              -e 's|@''REPLACE_QSORT_R''@|$(REPLACE_QSORT_R)|g' \
+             -e 's|@''REPLACE_RANDOM''@|$(REPLACE_RANDOM)|g' \
              -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \
              -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \
              -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
              -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \
+             -e 's|@''REPLACE_SETSTATE''@|$(REPLACE_SETSTATE)|g' \
              -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
+             -e 's|@''REPLACE_STRTOLD''@|$(REPLACE_STRTOLD)|g' \
              -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
              -e 's|@''REPLACE_WCTOMB''@|$(REPLACE_WCTOMB)|g' \
              -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
diff --git a/lib/group-member.c b/lib/group-member.c
index 3747dfe..ad61cf0 100644
--- a/lib/group-member.c
+++ b/lib/group-member.c
@@ -1,6 +1,6 @@
 /* group-member.c -- determine whether group id is in calling user's group list
 
-   Copyright (C) 1994, 1997-1998, 2003, 2005-2006, 2009-2018 Free Software
+   Copyright (C) 1994, 1997-1998, 2003, 2005-2006, 2009-2019 Free Software
    Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/ieee754.in.h b/lib/ieee754.in.h
index 316ac03..a079e59 100644
--- a/lib/ieee754.in.h
+++ b/lib/ieee754.in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-2018 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
diff --git a/lib/ignore-value.h b/lib/ignore-value.h
index 95eac1c..7e3b4c1 100644
--- a/lib/ignore-value.h
+++ b/lib/ignore-value.h
@@ -1,6 +1,6 @@
 /* ignore a function return without a compiler warning.  -*- coding: utf-8 -*-
 
-   Copyright (C) 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/intprops.h b/lib/intprops.h
index cdaf658..1a44ae5 100644
--- a/lib/intprops.h
+++ b/lib/intprops.h
@@ -1,6 +1,6 @@
 /* intprops.h -- properties of integer types
 
-   Copyright (C) 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published
diff --git a/lib/inttypes.in.h b/lib/inttypes.in.h
index c7d7968..d3c735c 100644
--- a/lib/inttypes.in.h
+++ b/lib/inttypes.in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2006-2018 Free Software Foundation, Inc.
+/* Copyright (C) 2006-2019 Free Software Foundation, Inc.
    Written by Paul Eggert, Bruno Haible, Derek Price.
    This file is part of gnulib.
 
diff --git a/lib/libc-config.h b/lib/libc-config.h
index d7b4093..57c6966 100644
--- a/lib/libc-config.h
+++ b/lib/libc-config.h
@@ -1,6 +1,6 @@
 /* System definitions for code taken from the GNU C Library
 
-   Copyright 2017-2018 Free Software Foundation, Inc.
+   Copyright 2017-2019 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public
diff --git a/lib/limits.in.h b/lib/limits.in.h
index 89d7195..39750b3 100644
--- a/lib/limits.in.h
+++ b/lib/limits.in.h
@@ -1,6 +1,6 @@
 /* A GNU-like <limits.h>.
 
-   Copyright 2016-2018 Free Software Foundation, Inc.
+   Copyright 2016-2019 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
diff --git a/lib/localtime-buffer.c b/lib/localtime-buffer.c
index df11f43..b65ea45 100644
--- a/lib/localtime-buffer.c
+++ b/lib/localtime-buffer.c
@@ -1,6 +1,6 @@
 /* Provide access to the last buffer returned by localtime() or gmtime().
 
-   Copyright (C) 2001-2003, 2005-2007, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003, 2005-2007, 2009-2019 Free Software Foundation, Inc.
 
    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
@@ -34,6 +34,7 @@ struct tm *localtime_buffer_addr = &tm_zero_buffer;
 
 struct tm *
 rpl_localtime (time_t const *timep)
+#undef localtime
 {
   struct tm *tm = localtime (timep);
 
@@ -46,6 +47,7 @@ rpl_localtime (time_t const *timep)
 /* Same as above, since gmtime and localtime use the same buffer.  */
 struct tm *
 rpl_gmtime (time_t const *timep)
+#undef gmtime
 {
   struct tm *tm = gmtime (timep);
 
diff --git a/lib/localtime-buffer.h b/lib/localtime-buffer.h
index f381ff0..031111a 100644
--- a/lib/localtime-buffer.h
+++ b/lib/localtime-buffer.h
@@ -1,6 +1,6 @@
 /* Provide access to the last buffer returned by localtime() or gmtime().
 
-   Copyright (C) 2001-2003, 2005-2007, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003, 2005-2007, 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/lstat.c b/lib/lstat.c
index 5873bbd..a3e40d8 100644
--- a/lib/lstat.c
+++ b/lib/lstat.c
@@ -1,6 +1,6 @@
 /* Work around a bug of lstat on some systems
 
-   Copyright (C) 1997-2006, 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 1997-2006, 2008-2019 Free Software Foundation, Inc.
 
    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
@@ -42,10 +42,14 @@ orig_lstat (const char *filename, struct stat *buf)
 }
 
 /* Specification.  */
+# ifdef __osf__
 /* Write "sys/stat.h" here, not <sys/stat.h>, otherwise OSF/1 5.1 DTK cc
    eliminates this include because of the preliminary #include <sys/stat.h>
    above.  */
-# include "sys/stat.h"
+#  include "sys/stat.h"
+# else
+#  include <sys/stat.h>
+# endif
 
 # include "stat-time.h"
 
diff --git a/lib/md5.c b/lib/md5.c
index 554d421..5c8bcf9 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -1,6 +1,6 @@
 /* Functions to compute MD5 message digest of files or memory blocks.
    according to the definition of MD5 in RFC 1321 from April 1992.
-   Copyright (C) 1995-1997, 1999-2001, 2005-2006, 2008-2018 Free Software
+   Copyright (C) 1995-1997, 1999-2001, 2005-2006, 2008-2019 Free Software
    Foundation, Inc.
    This file is part of the GNU C Library.
 
diff --git a/lib/md5.h b/lib/md5.h
index db031aa..478a27b 100644
--- a/lib/md5.h
+++ b/lib/md5.h
@@ -1,6 +1,6 @@
 /* Declaration of functions and data types used for MD5 sum computing
    library functions.
-   Copyright (C) 1995-1997, 1999-2001, 2004-2006, 2008-2018 Free Software
+   Copyright (C) 1995-1997, 1999-2001, 2004-2006, 2008-2019 Free Software
    Foundation, Inc.
    This file is part of the GNU C Library.
 
diff --git a/lib/memmem.c b/lib/memmem.c
new file mode 100644
index 0000000..12ae24f
--- /dev/null
+++ b/lib/memmem.c
@@ -0,0 +1,71 @@
+/* Copyright (C) 1991-1994, 1996-1998, 2000, 2004, 2007-2019 Free Software
+   Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   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, 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/>.  */
+
+/* This particular implementation was written by Eric Blake, 2008.  */
+
+#ifndef _LIBC
+# include <config.h>
+#endif
+
+/* Specification of memmem.  */
+#include <string.h>
+
+#define RETURN_TYPE void *
+#define AVAILABLE(h, h_l, j, n_l) ((j) <= (h_l) - (n_l))
+#include "str-two-way.h"
+
+/* Return the first occurrence of NEEDLE in HAYSTACK.  Return HAYSTACK
+   if NEEDLE_LEN is 0, otherwise NULL if NEEDLE is not found in
+   HAYSTACK.  */
+void *
+memmem (const void *haystack_start, size_t haystack_len,
+        const void *needle_start, size_t needle_len)
+{
+  /* Abstract memory is considered to be an array of 'unsigned char' values,
+     not an array of 'char' values.  See ISO C 99 section 6.2.6.1.  */
+  const unsigned char *haystack = (const unsigned char *) haystack_start;
+  const unsigned char *needle = (const unsigned char *) needle_start;
+
+  if (needle_len == 0)
+    /* The first occurrence of the empty string is deemed to occur at
+       the beginning of the string.  */
+    return (void *) haystack;
+
+  /* Sanity check, otherwise the loop might search through the whole
+     memory.  */
+  if (__builtin_expect (haystack_len < needle_len, 0))
+    return NULL;
+
+  /* Use optimizations in memchr when possible, to reduce the search
+     size of haystack using a linear algorithm with a smaller
+     coefficient.  However, avoid memchr for long needles, since we
+     can often achieve sublinear performance.  */
+  if (needle_len < LONG_NEEDLE_THRESHOLD)
+    {
+      haystack = memchr (haystack, *needle, haystack_len);
+      if (!haystack || __builtin_expect (needle_len == 1, 0))
+        return (void *) haystack;
+      haystack_len -= haystack - (const unsigned char *) haystack_start;
+      if (haystack_len < needle_len)
+        return NULL;
+      return two_way_short_needle (haystack, haystack_len, needle, needle_len);
+    }
+  else
+    return two_way_long_needle (haystack, haystack_len, needle, needle_len);
+}
+
+#undef LONG_NEEDLE_THRESHOLD
diff --git a/lib/memrchr.c b/lib/memrchr.c
index 2efc7cb..9602283 100644
--- a/lib/memrchr.c
+++ b/lib/memrchr.c
@@ -1,6 +1,6 @@
 /* memrchr -- find the last occurrence of a byte in a memory block
 
-   Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2018 Free Software
+   Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2019 Free Software
    Foundation, Inc.
 
    Based on strlen implementation by Torbjorn Granlund (address@hidden),
diff --git a/lib/minmax.h b/lib/minmax.h
index 33a5305..d7f6bea 100644
--- a/lib/minmax.h
+++ b/lib/minmax.h
@@ -1,5 +1,5 @@
 /* MIN, MAX macros.
-   Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2018 Free Software
+   Copyright (C) 1995, 1998, 2001, 2003, 2005, 2009-2019 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/lib/mkostemp.c b/lib/mkostemp.c
index df9ecf8..bbfe9db 100644
--- a/lib/mkostemp.c
+++ b/lib/mkostemp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2018 Free Software
+/* Copyright (C) 1998-1999, 2001, 2005-2007, 2009-2019 Free Software
    Foundation, Inc.
    This file is derived from the one in the GNU C Library.
 
diff --git a/lib/mktime-internal.h b/lib/mktime-internal.h
index 31cf3a4..d13d89c 100644
--- a/lib/mktime-internal.h
+++ b/lib/mktime-internal.h
@@ -1,6 +1,6 @@
 /* mktime variant that also uses an offset guess
 
-   Copyright 2016-2018 Free Software Foundation, Inc.
+   Copyright 2016-2019 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public
diff --git a/lib/mktime.c b/lib/mktime.c
index 9c3fb20..e3783d7 100644
--- a/lib/mktime.c
+++ b/lib/mktime.c
@@ -1,5 +1,5 @@
 /* Convert a 'struct tm' to a time_t value.
-   Copyright (C) 1993-2018 Free Software Foundation, Inc.
+   Copyright (C) 1993-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Paul Eggert <address@hidden>.
 
@@ -72,7 +72,7 @@ my_tzset (void)
   /* Rectify the value of the environment variable TZ.
      There are four possible kinds of such values:
        - Traditional US time zone names, e.g. "PST8PDT".  Syntax: see
-         <https://msdn.microsoft.com/en-us/library/90s5c885.aspx>
+         
<https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/tzset>
        - Time zone names based on geography, that contain one or more
          slashes, e.g. "Europe/Moscow".
        - Time zone names based on geography, without slashes, e.g.
diff --git a/lib/nstrftime.c b/lib/nstrftime.c
index 1dd49c0..bc84da5 100644
--- a/lib/nstrftime.c
+++ b/lib/nstrftime.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -180,7 +180,7 @@ extern char *tzname[];
           if (digits == 0 && _n < _w)                                         \
             {                                                                 \
               size_t _delta = width - _n;                                     \
-              if (pad == L_('0'))                                             \
+              if (pad == L_('0') || pad == L_('+'))                           \
                 memset_zero (p, _delta);                                      \
               else                                                            \
                 memset_space (p, _delta);                                     \
@@ -418,7 +418,7 @@ iso_week_days (int yday, int wday)
 
 static size_t __strftime_internal (STREAM_OR_CHAR_T *, STRFTIME_ARG (size_t)
                                    const CHAR_T *, const struct tm *,
-                                   bool, bool *
+                                   bool, int, int, bool *
                                    extra_args_spec LOCALE_PARAM);
 
 /* Write information from TP into S according to the format
@@ -433,8 +433,8 @@ my_strftime (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t 
maxsize)
              const struct tm *tp extra_args_spec LOCALE_PARAM)
 {
   bool tzset_called = false;
-  return __strftime_internal (s, STRFTIME_ARG (maxsize) format, tp,
-                              false, &tzset_called extra_args LOCALE_ARG);
+  return __strftime_internal (s, STRFTIME_ARG (maxsize) format, tp, false,
+                              0, -1, &tzset_called extra_args LOCALE_ARG);
 }
 #if defined _LIBC && ! FPRINTFTIME
 libc_hidden_def (my_strftime)
@@ -446,7 +446,8 @@ libc_hidden_def (my_strftime)
 static size_t
 __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize)
                      const CHAR_T *format,
-                     const struct tm *tp, bool upcase, bool *tzset_called
+                     const struct tm *tp, bool upcase,
+                     int yr_spec, int width, bool *tzset_called
                      extra_args_spec LOCALE_PARAM)
 {
 #if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL
@@ -558,7 +559,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG 
(size_t maxsize)
     if (hour12 == 0)
       hour12 = 12;
 
-  for (f = format; *f != '\0'; ++f)
+  for (f = format; *f != '\0'; width = -1, f++)
     {
       int pad = 0;              /* Padding for number ('-', '_', or 0).  */
       int modifier;             /* Field modifier ('E', 'O', or 0).  */
@@ -576,12 +577,12 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG 
(size_t maxsize)
                  + (sizeof (int) < sizeof (time_t)
                     ? INT_STRLEN_BOUND (time_t)
                     : INT_STRLEN_BOUND (int))];
-      int width = -1;
       bool to_lowcase = false;
       bool to_uppcase = upcase;
       size_t colons;
       bool change_case = false;
       int format_char;
+      int subwidth;
 
 #if DO_MULTIBYTE && !defined COMPILE_WIDE
       switch (*f)
@@ -679,6 +680,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG 
(size_t maxsize)
               /* This influences the number formats.  */
             case L_('_'):
             case L_('-'):
+            case L_('+'):
             case L_('0'):
               pad = *f;
               continue;
@@ -697,7 +699,6 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG 
(size_t maxsize)
           break;
         }
 
-      /* As a GNU extension we allow the field width to be specified.  */
       if (ISDIGIT (*f))
         {
           width = 0;
@@ -743,12 +744,16 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG 
(size_t maxsize)
             }                                                                 \
           while (0)
 #define DO_SIGNED_NUMBER(d, negative, v) \
+          DO_MAYBE_SIGNED_NUMBER (d, negative, v, do_signed_number)
+#define DO_YEARISH(d, negative, v) \
+          DO_MAYBE_SIGNED_NUMBER (d, negative, v, do_yearish)
+#define DO_MAYBE_SIGNED_NUMBER(d, negative, v, label) \
           do                                                                  \
             {                                                                 \
               digits = d;                                                     \
               negative_number = negative;                                     \
               u_number_value = v;                                             \
-              goto do_signed_number;                                          \
+              goto label;                                                     \
             }                                                                 \
           while (0)
 
@@ -850,7 +855,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG 
(size_t maxsize)
           if (modifier == L_('O'))
             goto bad_format;
 #ifdef _NL_CURRENT
-          if (! (modifier == 'E'
+          if (! (modifier == L_('E')
                  && (*(subfmt =
                        (const CHAR_T *) _NL_CURRENT (LC_TIME,
                                                      NLW(ERA_D_T_FMT)))
@@ -861,15 +866,17 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG 
(size_t maxsize)
 #endif
 
         subformat:
+          subwidth = -1;
+        subformat_width:
           {
             size_t len = __strftime_internal (NULL, STRFTIME_ARG ((size_t) -1)
-                                              subfmt,
-                                              tp, to_uppcase, tzset_called
+                                              subfmt, tp, to_uppcase,
+                                              pad, subwidth, tzset_called
                                               extra_args LOCALE_ARG);
             add (len, __strftime_internal (p,
                                            STRFTIME_ARG (maxsize - i)
-                                           subfmt,
-                                           tp, to_uppcase, tzset_called
+                                           subfmt, tp, to_uppcase,
+                                           pad, subwidth, tzset_called
                                            extra_args LOCALE_ARG));
           }
           break;
@@ -930,7 +937,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG 
(size_t maxsize)
           {
             int century = tp->tm_year / 100 + TM_YEAR_BASE / 100;
             century -= tp->tm_year % 100 < 0 && 0 < century;
-            DO_SIGNED_NUMBER (2, tp->tm_year < - TM_YEAR_BASE, century);
+            DO_YEARISH (2, tp->tm_year < - TM_YEAR_BASE, century);
           }
 
         case L_('x'):
@@ -939,7 +946,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG 
(size_t maxsize)
 #ifdef _NL_CURRENT
           if (! (modifier == L_('E')
                  && (*(subfmt =
-                       (const CHAR_T *)_NL_CURRENT (LC_TIME, NLW(ERA_D_FMT)))
+                       (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ERA_D_FMT)))
                      != L_('\0'))))
             subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_FMT));
           goto subformat;
@@ -971,9 +978,17 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG 
(size_t maxsize)
           always_output_a_sign = true;
           goto do_number_body;
 
+        do_yearish:
+          if (pad == 0)
+            pad = yr_spec;
+          always_output_a_sign
+            = (pad == L_('+')
+               && ((digits == 2 ? 99 : 9999) < u_number_value
+                   || digits < width));
+          goto do_maybe_signed_number;
+
         do_number_spacepad:
-          /* Force '_' flag unless overridden by '0' or '-' flag.  */
-          if (pad != L_('0') && pad != L_('-'))
+          if (pad == 0)
             pad = L_('_');
 
         do_number:
@@ -983,6 +998,8 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG 
(size_t maxsize)
 
         do_signed_number:
           always_output_a_sign = false;
+
+        do_maybe_signed_number:
           tz_colon_mask = 0;
 
         do_number_body:
@@ -1087,8 +1104,19 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG 
(size_t maxsize)
         case L_('F'):
           if (modifier != 0)
             goto bad_format;
+          if (pad == 0 && width < 0)
+            {
+              pad = L_('+');
+              subwidth = 4;
+            }
+          else
+            {
+              subwidth = width - 6;
+              if (subwidth < 0)
+                subwidth = 0;
+            }
           subfmt = L_("%Y-%m-%d");
-          goto subformat;
+          goto subformat_width;
 
         case L_('H'):
           if (modifier == L_('E'))
@@ -1297,17 +1325,18 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG 
(size_t maxsize)
               case L_('g'):
                 {
                   int yy = (tp->tm_year % 100 + year_adjust) % 100;
-                  DO_NUMBER (2, (0 <= yy
-                                 ? yy
-                                 : tp->tm_year < -TM_YEAR_BASE - year_adjust
-                                 ? -yy
-                                 : yy + 100));
+                  DO_YEARISH (2, false,
+                              (0 <= yy
+                               ? yy
+                               : tp->tm_year < -TM_YEAR_BASE - year_adjust
+                               ? -yy
+                               : yy + 100));
                 }
 
               case L_('G'):
-                DO_SIGNED_NUMBER (4, tp->tm_year < -TM_YEAR_BASE - year_adjust,
-                                  (tp->tm_year + (unsigned int) TM_YEAR_BASE
-                                   + year_adjust));
+                DO_YEARISH (4, tp->tm_year < -TM_YEAR_BASE - year_adjust,
+                            (tp->tm_year + (unsigned int) TM_YEAR_BASE
+                             + year_adjust));
 
               default:
                 DO_NUMBER (2, days / 7 + 1);
@@ -1327,7 +1356,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG 
(size_t maxsize)
           DO_NUMBER (1, tp->tm_wday);
 
         case L_('Y'):
-          if (modifier == 'E')
+          if (modifier == L_('E'))
             {
 #if HAVE_STRUCT_ERA_ENTRY
               struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG);
@@ -1338,6 +1367,8 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG 
(size_t maxsize)
 # else
                   subfmt = era->era_format;
 # endif
+                  if (pad == 0)
+                    pad = yr_spec;
                   goto subformat;
                 }
 #else
@@ -1347,8 +1378,8 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG 
(size_t maxsize)
           if (modifier == L_('O'))
             goto bad_format;
 
-          DO_SIGNED_NUMBER (4, tp->tm_year < -TM_YEAR_BASE,
-                            tp->tm_year + (unsigned int) TM_YEAR_BASE);
+          DO_YEARISH (4, tp->tm_year < -TM_YEAR_BASE,
+                      tp->tm_year + (unsigned int) TM_YEAR_BASE);
 
         case L_('y'):
           if (modifier == L_('E'))
@@ -1358,7 +1389,9 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG 
(size_t maxsize)
               if (era)
                 {
                   int delta = tp->tm_year - era->start_date[0];
-                  DO_NUMBER (1, (era->offset
+                  if (pad == 0)
+                    pad = yr_spec;
+                  DO_NUMBER (2, (era->offset
                                  + delta * era->absolute_direction));
                 }
 #else
@@ -1370,7 +1403,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG 
(size_t maxsize)
             int yy = tp->tm_year % 100;
             if (yy < 0)
               yy = tp->tm_year < - TM_YEAR_BASE ? -yy : yy + 100;
-            DO_NUMBER (2, yy);
+            DO_YEARISH (2, false, yy);
           }
 
         case L_('Z'):
diff --git a/lib/open.c b/lib/open.c
index 792e258..6552605 100644
--- a/lib/open.c
+++ b/lib/open.c
@@ -1,5 +1,5 @@
 /* Open a descriptor to a file.
-   Copyright (C) 2007-2018 Free Software Foundation, Inc.
+   Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/openat-priv.h b/lib/openat-priv.h
index 5d53df1..7b90eef 100644
--- a/lib/openat-priv.h
+++ b/lib/openat-priv.h
@@ -1,6 +1,6 @@
 /* Internals for openat-like functions.
 
-   Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2005-2006, 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/openat-proc.c b/lib/openat-proc.c
index 87137ee..da76e2b 100644
--- a/lib/openat-proc.c
+++ b/lib/openat-proc.c
@@ -1,6 +1,6 @@
 /* Create /proc/self/fd-related names for subfiles of open directories.
 
-   Copyright (C) 2006, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/openat.h b/lib/openat.h
index 945e032..f23b371 100644
--- a/lib/openat.h
+++ b/lib/openat.h
@@ -1,5 +1,5 @@
 /* provide a replacement openat function
-   Copyright (C) 2004-2006, 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2004-2006, 2008-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/pipe2.c b/lib/pipe2.c
index c16d935..15a5dec 100644
--- a/lib/pipe2.c
+++ b/lib/pipe2.c
@@ -1,5 +1,5 @@
 /* Create a pipe, with specific opening flags.
-   Copyright (C) 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/pselect.c b/lib/pselect.c
index 33b2719..ae010aa 100644
--- a/lib/pselect.c
+++ b/lib/pselect.c
@@ -1,6 +1,6 @@
 /* pselect - synchronous I/O multiplexing
 
-   Copyright 2011-2018 Free Software Foundation, Inc.
+   Copyright 2011-2019 Free Software Foundation, Inc.
 
    This file is part of gnulib.
 
diff --git a/lib/pthread_sigmask.c b/lib/pthread_sigmask.c
index 3bb92ca..3e40cfc 100644
--- a/lib/pthread_sigmask.c
+++ b/lib/pthread_sigmask.c
@@ -1,5 +1,5 @@
 /* POSIX compatible signal blocking for threads.
-   Copyright (C) 2011-2018 Free Software Foundation, Inc.
+   Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/putenv.c b/lib/putenv.c
index 801e372..81085e9 100644
--- a/lib/putenv.c
+++ b/lib/putenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2018 Free Software
+/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2019 Free Software
    Foundation, Inc.
 
    NOTE: The canonical source of this file is maintained with the GNU C
diff --git a/lib/qcopy-acl.c b/lib/qcopy-acl.c
index ee482ef..cf75080 100644
--- a/lib/qcopy-acl.c
+++ b/lib/qcopy-acl.c
@@ -1,6 +1,6 @@
 /* Copy access control list from one file to another.  -*- coding: utf-8 -*-
 
-   Copyright (C) 2002-2003, 2005-2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2005-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/readlink.c b/lib/readlink.c
index 924e00d..bf71109 100644
--- a/lib/readlink.c
+++ b/lib/readlink.c
@@ -1,5 +1,5 @@
 /* Stub for readlink().
-   Copyright (C) 2003-2007, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2003-2007, 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/readlinkat.c b/lib/readlinkat.c
index 35179e2..c0f3e59 100644
--- a/lib/readlinkat.c
+++ b/lib/readlinkat.c
@@ -1,5 +1,5 @@
 /* Read a symlink relative to an open directory.
-   Copyright (C) 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/regcomp.c b/lib/regcomp.c
index 0b05a63..892139a 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -1,5 +1,5 @@
 /* Extended regular expression matching and search library.
-   Copyright (C) 2002-2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Isamu Hasegawa <address@hidden>.
 
@@ -233,9 +233,7 @@ re_compile_pattern (const char *pattern, size_t length,
     return NULL;
   return gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);
 }
-#ifdef _LIBC
 weak_alias (__re_compile_pattern, re_compile_pattern)
-#endif
 
 /* Set by 're_set_syntax' to the current regexp syntax to recognize.  Can
    also be assigned to arbitrarily: each pattern buffer stores its own
@@ -260,9 +258,7 @@ re_set_syntax (reg_syntax_t syntax)
   re_syntax_options = syntax;
   return ret;
 }
-#ifdef _LIBC
 weak_alias (__re_set_syntax, re_set_syntax)
-#endif
 
 int
 re_compile_fastmap (struct re_pattern_buffer *bufp)
@@ -281,9 +277,7 @@ re_compile_fastmap (struct re_pattern_buffer *bufp)
   bufp->fastmap_accurate = 1;
   return 0;
 }
-#ifdef _LIBC
 weak_alias (__re_compile_fastmap, re_compile_fastmap)
-#endif
 
 static inline void
 __attribute__ ((always_inline))
@@ -464,7 +458,7 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t 
*init_state,
    the return codes and their meanings.)  */
 
 int
-regcomp (regex_t *_Restrict_ preg, const char *_Restrict_ pattern, int cflags)
+regcomp (regex_t *__restrict preg, const char *__restrict pattern, int cflags)
 {
   reg_errcode_t ret;
   reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED
@@ -515,16 +509,14 @@ regcomp (regex_t *_Restrict_ preg, const char *_Restrict_ 
pattern, int cflags)
 
   return (int) ret;
 }
-#ifdef _LIBC
 libc_hidden_def (__regcomp)
 weak_alias (__regcomp, regcomp)
-#endif
 
 /* Returns a message corresponding to an error code, ERRCODE, returned
    from either regcomp or regexec.   We don't use PREG here.  */
 
 size_t
-regerror (int errcode, const regex_t *_Restrict_ preg, char *_Restrict_ errbuf,
+regerror (int errcode, const regex_t *__restrict preg, char *__restrict errbuf,
          size_t errbuf_size)
 {
   const char *msg;
@@ -555,9 +547,7 @@ regerror (int errcode, const regex_t *_Restrict_ preg, char 
*_Restrict_ errbuf,
 
   return msg_size;
 }
-#ifdef _LIBC
 weak_alias (__regerror, regerror)
-#endif
 
 
 #ifdef RE_ENABLE_I18N
@@ -657,10 +647,8 @@ regfree (regex_t *preg)
   re_free (preg->translate);
   preg->translate = NULL;
 }
-#ifdef _LIBC
 libc_hidden_def (__regfree)
 weak_alias (__regfree, regfree)
-#endif
 
 /* Entry points compatible with 4.2 BSD regex library.  We don't define
    them unless specifically requested.  */
@@ -1812,8 +1800,8 @@ peek_token (re_token_t *token, re_string_t *input, 
reg_syntax_t syntax)
   token->word_char = 0;
 #ifdef RE_ENABLE_I18N
   token->mb_partial = 0;
-  if (input->mb_cur_max > 1 &&
-      !re_string_first_byte (input, re_string_cur_idx (input)))
+  if (input->mb_cur_max > 1
+      && !re_string_first_byte (input, re_string_cur_idx (input)))
     {
       token->type = CHARACTER;
       token->mb_partial = 1;
@@ -2000,8 +1988,8 @@ peek_token (re_token_t *token, re_string_t *input, 
reg_syntax_t syntax)
       token->type = OP_PERIOD;
       break;
     case '^':
-      if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE)) &&
-         re_string_cur_idx (input) != 0)
+      if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE))
+         && re_string_cur_idx (input) != 0)
        {
          char prev = re_string_peek_byte (input, -1);
          if (!(syntax & RE_NEWLINE_ALT) || prev != '\n')
@@ -2011,8 +1999,8 @@ peek_token (re_token_t *token, re_string_t *input, 
reg_syntax_t syntax)
       token->opr.ctx_type = LINE_FIRST;
       break;
     case '$':
-      if (!(syntax & RE_CONTEXT_INDEP_ANCHORS) &&
-         re_string_cur_idx (input) + 1 != re_string_length (input))
+      if (!(syntax & RE_CONTEXT_INDEP_ANCHORS)
+         && re_string_cur_idx (input) + 1 != re_string_length (input))
        {
          re_token_t next;
          re_string_skip_bytes (input, 1);
@@ -2046,8 +2034,8 @@ peek_token_bracket (re_token_t *token, re_string_t 
*input, reg_syntax_t syntax)
   token->opr.c = c;
 
 #ifdef RE_ENABLE_I18N
-  if (input->mb_cur_max > 1 &&
-      !re_string_first_byte (input, re_string_cur_idx (input)))
+  if (input->mb_cur_max > 1
+      && !re_string_first_byte (input, re_string_cur_idx (input)))
     {
       token->type = CHARACTER;
       return 1;
@@ -2345,8 +2333,8 @@ parse_expression (re_string_t *regexp, regex_t *preg, 
re_token_t *token,
        }
       FALLTHROUGH;
     case OP_CLOSE_SUBEXP:
-      if ((token->type == OP_CLOSE_SUBEXP) &&
-         !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD))
+      if ((token->type == OP_CLOSE_SUBEXP)
+         && !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD))
        {
          *err = REG_ERPAREN;
          return NULL;
diff --git a/lib/regex.c b/lib/regex.c
index 2a86e10..eab7a48 100644
--- a/lib/regex.c
+++ b/lib/regex.c
@@ -1,5 +1,5 @@
 /* Extended regular expression matching and search library.
-   Copyright (C) 2002-2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Isamu Hasegawa <address@hidden>.
 
@@ -20,10 +20,10 @@
 #ifndef _LIBC
 # include <libc-config.h>
 
-# if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
+# if __GNUC_PREREQ (4, 6)
 #  pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
 # endif
-# if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
+# if __GNUC_PREREQ (4, 3)
 #  pragma GCC diagnostic ignored "-Wold-style-definition"
 #  pragma GCC diagnostic ignored "-Wtype-limits"
 # endif
diff --git a/lib/regex.h b/lib/regex.h
index f2ac950..77ac1a5 100644
--- a/lib/regex.h
+++ b/lib/regex.h
@@ -1,6 +1,6 @@
 /* Definitions for data structures and routines for the regular
    expression library.
-   Copyright (C) 1985, 1989-2018 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1989-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
diff --git a/lib/regex_internal.c b/lib/regex_internal.c
index f13def3..b592f06 100644
--- a/lib/regex_internal.c
+++ b/lib/regex_internal.c
@@ -1,5 +1,5 @@
 /* Extended regular expression matching and search library.
-   Copyright (C) 2002-2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Isamu Hasegawa <address@hidden>.
 
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index b0e49cd..a3aedda 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -1,5 +1,5 @@
 /* Extended regular expression matching and search library.
-   Copyright (C) 2002-2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Isamu Hasegawa <address@hidden>.
 
@@ -144,13 +144,8 @@
 # define __mbrtowc mbrtowc
 # define __wcrtomb wcrtomb
 # define __regfree regfree
-# define attribute_hidden
 #endif /* not _LIBC */
 
-#if __GNUC__ < 3 + (__GNUC_MINOR__ < 1)
-# define __attribute__(arg)
-#endif
-
 #ifndef SSIZE_MAX
 # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
 #endif
@@ -868,23 +863,6 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx)
 }
 #endif /* RE_ENABLE_I18N */
 
-#ifndef __GNUC_PREREQ
-# if defined __GNUC__ && defined __GNUC_MINOR__
-#  define __GNUC_PREREQ(maj, min) \
-         ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
-# else
-#  define __GNUC_PREREQ(maj, min) 0
-# endif
-#endif
-
-#if __GNUC_PREREQ (3,4)
-# undef __attribute_warn_unused_result__
-# define __attribute_warn_unused_result__ \
-   __attribute__ ((__warn_unused_result__))
-#else
-# define __attribute_warn_unused_result__ /* empty */
-#endif
-
 #ifndef FALLTHROUGH
 # if __GNUC__ < 7
 #  define FALLTHROUGH ((void) 0)
diff --git a/lib/regexec.c b/lib/regexec.c
index 8b82ea5..f464869 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -1,5 +1,5 @@
 /* Extended regular expression matching and search library.
-   Copyright (C) 2002-2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Isamu Hasegawa <address@hidden>.
 
@@ -189,7 +189,7 @@ static reg_errcode_t extend_buffers (re_match_context_t 
*mctx, int min_len);
    We return 0 if we find a match and REG_NOMATCH if not.  */
 
 int
-regexec (const regex_t *_Restrict_ preg, const char *_Restrict_ string,
+regexec (const regex_t *__restrict preg, const char *__restrict string,
         size_t nmatch, regmatch_t pmatch[], int eflags)
 {
   reg_errcode_t err;
@@ -232,8 +232,8 @@ __typeof__ (__regexec) __compat_regexec;
 
 int
 attribute_compat_text_section
-__compat_regexec (const regex_t *_Restrict_ preg,
-                 const char *_Restrict_ string, size_t nmatch,
+__compat_regexec (const regex_t *__restrict preg,
+                 const char *__restrict string, size_t nmatch,
                  regmatch_t pmatch[], int eflags)
 {
   return regexec (preg, string, nmatch, pmatch,
@@ -1293,8 +1293,10 @@ proceed_next_node (const re_match_context_t *mctx, Idx 
nregs, regmatch_t *regs,
              else if (naccepted)
                {
                  char *buf = (char *) re_string_get_buffer (&mctx->input);
-                 if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
-                             naccepted) != 0)
+                 if (mctx->input.valid_len - *pidx < naccepted
+                     || (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
+                                 naccepted)
+                         != 0))
                    return -1;
                }
            }
@@ -2202,12 +2204,12 @@ sift_states_iter_mb (const re_match_context_t *mctx, 
re_sift_context_t *sctx,
   int naccepted;
   /* Check the node can accept "multi byte".  */
   naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx);
-  if (naccepted > 0 && str_idx + naccepted <= max_str_idx &&
-      !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted],
-                           dfa->nexts[node_idx]))
+  if (naccepted > 0 && str_idx + naccepted <= max_str_idx
+      && !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted],
+                              dfa->nexts[node_idx]))
     /* The node can't accept the "multi byte", or the
        destination was already thrown away, then the node
-       could't accept the current input "multi byte".   */
+       couldn't accept the current input "multi byte".   */
     naccepted = 0;
   /* Otherwise, it is sure that the node could accept
      'naccepted' bytes input.  */
@@ -2783,8 +2785,11 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, 
Idx bkref_str_idx)
            return REG_ESPACE;
          err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node,
                                bkref_str_idx);
+         buf = (const char *) re_string_get_buffer (&mctx->input);
          if (err == REG_NOMATCH)
            continue;
+         if (__glibc_unlikely (err != REG_NOERROR))
+           return err;
        }
     }
   return REG_NOERROR;
@@ -3777,10 +3782,10 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx 
node_idx,
       /* FIXME: I don't think this if is needed, as both '\n'
         and '\0' are char_len == 1.  */
       /* '.' accepts any one character except the following two cases.  */
-      if ((!(dfa->syntax & RE_DOT_NEWLINE) &&
-          re_string_byte_at (input, str_idx) == '\n') ||
-         ((dfa->syntax & RE_DOT_NOT_NULL) &&
-          re_string_byte_at (input, str_idx) == '\0'))
+      if ((!(dfa->syntax & RE_DOT_NEWLINE)
+          && re_string_byte_at (input, str_idx) == '\n')
+         || ((dfa->syntax & RE_DOT_NOT_NULL)
+             && re_string_byte_at (input, str_idx) == '\0'))
        return 0;
       return char_len;
     }
diff --git a/lib/root-uid.h b/lib/root-uid.h
index 4af7d95..eebfa94 100644
--- a/lib/root-uid.h
+++ b/lib/root-uid.h
@@ -1,6 +1,6 @@
 /* The user ID that always has appropriate privileges in the POSIX sense.
 
-   Copyright 2012-2018 Free Software Foundation, Inc.
+   Copyright 2012-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/save-cwd.c b/lib/save-cwd.c
index 5020fac..a7c4745 100644
--- a/lib/save-cwd.c
+++ b/lib/save-cwd.c
@@ -1,6 +1,6 @@
 /* save-cwd.c -- Save and restore current working directory.
 
-   Copyright (C) 1995, 1997-1998, 2003-2006, 2009-2018 Free Software
+   Copyright (C) 1995, 1997-1998, 2003-2006, 2009-2019 Free Software
    Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/save-cwd.h b/lib/save-cwd.h
index 88c8505..2fa6e75 100644
--- a/lib/save-cwd.h
+++ b/lib/save-cwd.h
@@ -1,6 +1,6 @@
 /* Save and restore current working directory.
 
-   Copyright (C) 1995, 1997-1998, 2003, 2009-2018 Free Software
+   Copyright (C) 1995, 1997-1998, 2003, 2009-2019 Free Software
    Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/set-permissions.c b/lib/set-permissions.c
index a415e13..38cd30a 100644
--- a/lib/set-permissions.c
+++ b/lib/set-permissions.c
@@ -1,6 +1,6 @@
 /* Set permissions of a file.  -*- coding: utf-8 -*-
 
-   Copyright (C) 2002-2003, 2005-2018 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2005-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/sha1.c b/lib/sha1.c
index cd79dfa..d94c437 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -1,7 +1,7 @@
 /* sha1.c - Functions to compute SHA1 message digest of files or
    memory blocks according to the NIST specification FIPS-180-1.
 
-   Copyright (C) 2000-2001, 2003-2006, 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2000-2001, 2003-2006, 2008-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/sha1.h b/lib/sha1.h
index 9419750..617f7b0 100644
--- a/lib/sha1.h
+++ b/lib/sha1.h
@@ -1,6 +1,6 @@
 /* Declarations of functions and data types used for SHA1 sum
    library functions.
-   Copyright (C) 2000-2001, 2003, 2005-2006, 2008-2018 Free Software
+   Copyright (C) 2000-2001, 2003, 2005-2006, 2008-2019 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify it
diff --git a/lib/sha256.c b/lib/sha256.c
index c518517..721e944 100644
--- a/lib/sha256.c
+++ b/lib/sha256.c
@@ -1,7 +1,7 @@
 /* sha256.c - Functions to compute SHA256 and SHA224 message digest of files or
    memory blocks according to the NIST specification FIPS-180-2.
 
-   Copyright (C) 2005-2006, 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2005-2006, 2008-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/sha256.h b/lib/sha256.h
index 19ed3cc..b1ccb2a 100644
--- a/lib/sha256.h
+++ b/lib/sha256.h
@@ -1,6 +1,6 @@
 /* Declarations of functions and data types used for SHA256 and SHA224 sum
    library functions.
-   Copyright (C) 2005-2006, 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2005-2006, 2008-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/sha512.c b/lib/sha512.c
index e854951..e7f5bd5 100644
--- a/lib/sha512.c
+++ b/lib/sha512.c
@@ -1,7 +1,7 @@
 /* sha512.c - Functions to compute SHA512 and SHA384 message digest of files or
    memory blocks according to the NIST specification FIPS-180-2.
 
-   Copyright (C) 2005-2006, 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2005-2006, 2008-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/sha512.h b/lib/sha512.h
index 2c39ab1..7e8cc28 100644
--- a/lib/sha512.h
+++ b/lib/sha512.h
@@ -1,6 +1,6 @@
 /* Declarations of functions and data types used for SHA512 and SHA384 sum
    library functions.
-   Copyright (C) 2005-2006, 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2005-2006, 2008-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/sig2str.c b/lib/sig2str.c
index 72b075e..cd5bd4d 100644
--- a/lib/sig2str.c
+++ b/lib/sig2str.c
@@ -1,6 +1,6 @@
 /* sig2str.c -- convert between signal names and numbers
 
-   Copyright (C) 2002, 2004, 2006, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2006, 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/sig2str.h b/lib/sig2str.h
index 69887d4..32e0d26 100644
--- a/lib/sig2str.h
+++ b/lib/sig2str.h
@@ -1,6 +1,6 @@
 /* sig2str.h -- convert between signal names and numbers
 
-   Copyright (C) 2002, 2005, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2005, 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/signal.in.h b/lib/signal.in.h
index 7d4927b..a6960a2 100644
--- a/lib/signal.in.h
+++ b/lib/signal.in.h
@@ -1,6 +1,6 @@
 /* A GNU-like <signal.h>.
 
-   Copyright (C) 2006-2018 Free Software Foundation, Inc.
+   Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/stat-time.h b/lib/stat-time.h
index 69ebe85..38a1f55 100644
--- a/lib/stat-time.h
+++ b/lib/stat-time.h
@@ -1,6 +1,6 @@
 /* stat-related time functions.
 
-   Copyright (C) 2005, 2007, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2007, 2009-2019 Free Software Foundation, Inc.
 
    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
@@ -171,7 +171,7 @@ get_stat_birthtime (struct stat const *st _GL_UNUSED)
 #elif defined _WIN32 && ! defined __CYGWIN__
   /* Native Windows platforms (but not Cygwin) put the "file creation
      time" in st_ctime (!).  See
-     <https://msdn.microsoft.com/en-us/library/14h5k7ff(VS.80).aspx>.  */
+     
<https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/stat-functions>.
  */
 # if _GL_WINDOWS_STAT_TIMESPEC
   t = st->st_ctim;
 # else
diff --git a/lib/stdalign.in.h b/lib/stdalign.in.h
index bbfa9ac..d988d7c 100644
--- a/lib/stdalign.in.h
+++ b/lib/stdalign.in.h
@@ -1,6 +1,6 @@
 /* A substitute for ISO C11 <stdalign.h>.
 
-   Copyright 2011-2018 Free Software Foundation, Inc.
+   Copyright 2011-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/stddef.in.h b/lib/stddef.in.h
index 8329a9b..5aad121 100644
--- a/lib/stddef.in.h
+++ b/lib/stddef.in.h
@@ -1,6 +1,6 @@
 /* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
 
-   Copyright (C) 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/stdint.in.h b/lib/stdint.in.h
index 94e7c81..21dd8d2 100644
--- a/lib/stdint.in.h
+++ b/lib/stdint.in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2002, 2004-2018 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2002, 2004-2019 Free Software Foundation, Inc.
    Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
    This file is part of gnulib.
 
diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h
index 393ef0c..4260468 100644
--- a/lib/stdio-impl.h
+++ b/lib/stdio-impl.h
@@ -1,5 +1,5 @@
 /* Implementation details of FILE streams.
-   Copyright (C) 2007-2008, 2010-2018 Free Software Foundation, Inc.
+   Copyright (C) 2007-2008, 2010-2019 Free Software Foundation, Inc.
 
    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
@@ -61,6 +61,11 @@
 #  define _r pub._r
 #  define _w pub._w
 # elif defined __ANDROID__ /* Android */
+#  ifdef __LP64__
+#   define _gl_flags_file_t int
+#  else
+#   define _gl_flags_file_t short
+#  endif
   /* Up to this commit from 2015-10-12
      
<https://android.googlesource.com/platform/bionic.git/+/f0141dfab10a4b332769d52fa76631a64741297a>
      the innards of FILE were public, and fp_ub could be defined like for 
OpenBSD,
@@ -70,8 +75,8 @@
 #  define fp_ ((struct { unsigned char *_p; \
                          int _r; \
                          int _w; \
-                         int _flags; \
-                         int _file; \
+                         _gl_flags_file_t _flags; \
+                         _gl_flags_file_t _file; \
                          struct { unsigned char *_base; size_t _size; } _bf; \
                          int _lbfsize; \
                          void *_cookie; \
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index ff7c9c8..4a8aa55 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -1,6 +1,6 @@
 /* A GNU-like <stdio.h>.
 
-   Copyright (C) 2004, 2007-2018 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2007-2019 Free Software Foundation, Inc.
 
    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
@@ -118,6 +118,13 @@
 # include <unistd.h>
 #endif
 
+/* Android 4.3 declares renameat in <sys/stat.h>, not in <stdio.h>.  */
+/* But in any case avoid namespace pollution on glibc systems.  */
+#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
+    && ! defined __GLIBC__
+# include <sys/stat.h>
+#endif
+
 /* MSVC declares 'perror' in <stdlib.h>, not in <stdio.h>.  We must include
    it before we  #define perror rpl_perror.  */
 /* But in any case avoid namespace pollution on glibc systems.  */
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index 441c018..f829525 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -1,6 +1,6 @@
 /* A GNU-like <stdlib.h>.
 
-   Copyright (C) 1995, 2001-2004, 2006-2018 Free Software Foundation, Inc.
+   Copyright (C) 1995, 2001-2004, 2006-2019 Free Software Foundation, Inc.
 
    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
@@ -306,9 +306,18 @@ _GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant 
everywhere - "
 _GL_FUNCDECL_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
 _GL_CXXALIAS_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
 # else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
+#  endif
 _GL_CXXALIAS_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
 # endif
 _GL_CXXALIASWARN (mbtowc);
+#elif defined GNULIB_POSIXCHECK
+# undef mbtowc
+# if HAVE_RAW_DECL_MBTOWC
+_GL_WARN_ON_USE (mbtowc, "mbtowc is not portable - "
+                 "use gnulib module mbtowc for portability");
+# endif
 #endif
 
 #if @GNULIB_MKDTEMP@
@@ -573,10 +582,19 @@ _GL_WARN_ON_USE (qsort_r, "qsort_r is not portable - "
 
 
 #if @GNULIB_RANDOM@
-# if address@hidden@
+# if @REPLACE_RANDOM@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef random
+#   define random rpl_random
+#  endif
+_GL_FUNCDECL_RPL (random, long, (void));
+_GL_CXXALIAS_RPL (random, long, (void));
+# else
+#  if address@hidden@
 _GL_FUNCDECL_SYS (random, long, (void));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (random, long, (void));
+# endif
 _GL_CXXALIASWARN (random);
 #elif defined GNULIB_POSIXCHECK
 # undef random
@@ -587,10 +605,19 @@ _GL_WARN_ON_USE (random, "random is unportable - "
 #endif
 
 #if @GNULIB_RANDOM@
-# if address@hidden@
+# if @REPLACE_RANDOM@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef srandom
+#   define srandom rpl_srandom
+#  endif
+_GL_FUNCDECL_RPL (srandom, void, (unsigned int seed));
+_GL_CXXALIAS_RPL (srandom, void, (unsigned int seed));
+# else
+#  if address@hidden@
 _GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (srandom, void, (unsigned int seed));
+# endif
 _GL_CXXALIASWARN (srandom);
 #elif defined GNULIB_POSIXCHECK
 # undef srandom
@@ -601,31 +628,52 @@ _GL_WARN_ON_USE (srandom, "srandom is unportable - "
 #endif
 
 #if @GNULIB_RANDOM@
-# if address@hidden@ || address@hidden@
+# if @REPLACE_INITSTATE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef initstate
+#   define initstate rpl_initstate
+#  endif
+_GL_FUNCDECL_RPL (initstate, char *,
+                  (unsigned int seed, char *buf, size_t buf_size)
+                  _GL_ARG_NONNULL ((2)));
+_GL_CXXALIAS_RPL (initstate, char *,
+                  (unsigned int seed, char *buf, size_t buf_size));
+# else
+#  if address@hidden@ || address@hidden@
 _GL_FUNCDECL_SYS (initstate, char *,
                   (unsigned int seed, char *buf, size_t buf_size)
                   _GL_ARG_NONNULL ((2)));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (initstate, char *,
                   (unsigned int seed, char *buf, size_t buf_size));
+# endif
 _GL_CXXALIASWARN (initstate);
 #elif defined GNULIB_POSIXCHECK
 # undef initstate
-# if HAVE_RAW_DECL_INITSTATE_R
+# if HAVE_RAW_DECL_INITSTATE
 _GL_WARN_ON_USE (initstate, "initstate is unportable - "
                  "use gnulib module random for portability");
 # endif
 #endif
 
 #if @GNULIB_RANDOM@
-# if address@hidden@ || address@hidden@
+# if @REPLACE_SETSTATE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef setstate
+#   define setstate rpl_setstate
+#  endif
+_GL_FUNCDECL_RPL (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (setstate, char *, (char *arg_state));
+# else
+#  if address@hidden@ || address@hidden@
 _GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (setstate, char *, (char *arg_state));
+# endif
 _GL_CXXALIASWARN (setstate);
 #elif defined GNULIB_POSIXCHECK
 # undef setstate
-# if HAVE_RAW_DECL_SETSTATE_R
+# if HAVE_RAW_DECL_SETSTATE
 _GL_WARN_ON_USE (setstate, "setstate is unportable - "
                  "use gnulib module random for portability");
 # endif
@@ -881,6 +929,7 @@ _GL_WARN_ON_USE (setenv, "setenv is unportable - "
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   define strtod rpl_strtod
 #  endif
+#  define GNULIB_defined_strtod_function 1
 _GL_FUNCDECL_RPL (strtod, double, (const char *str, char **endp)
                                   _GL_ARG_NONNULL ((1)));
 _GL_CXXALIAS_RPL (strtod, double, (const char *str, char **endp));
@@ -900,6 +949,32 @@ _GL_WARN_ON_USE (strtod, "strtod is unportable - "
 # endif
 #endif
 
+#if @GNULIB_STRTOLD@
+ /* Parse a 'long double' from STRING, updating ENDP if appropriate.  */
+# if @REPLACE_STRTOLD@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define strtold rpl_strtold
+#  endif
+#  define GNULIB_defined_strtold_function 1
+_GL_FUNCDECL_RPL (strtold, long double, (const char *str, char **endp)
+                                        _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (strtold, long double, (const char *str, char **endp));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (strtold, long double, (const char *str, char **endp)
+                                        _GL_ARG_NONNULL ((1)));
+#  endif
+_GL_CXXALIAS_SYS (strtold, long double, (const char *str, char **endp));
+# endif
+_GL_CXXALIASWARN (strtold);
+#elif defined GNULIB_POSIXCHECK
+# undef strtold
+# if HAVE_RAW_DECL_STRTOLD
+_GL_WARN_ON_USE (strtold, "strtold is unportable - "
+                 "use gnulib module strtold for portability");
+# endif
+#endif
+
 #if @GNULIB_STRTOLL@
 /* Parse a signed integer whose textual representation starts at STRING.
    The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
diff --git a/lib/stpcpy.c b/lib/stpcpy.c
index 61239e9..a1d32fd 100644
--- a/lib/stpcpy.c
+++ b/lib/stpcpy.c
@@ -1,5 +1,5 @@
 /* stpcpy.c -- copy a string and return pointer to end of new string
-   Copyright (C) 1992, 1995, 1997-1998, 2006, 2009-2018 Free Software
+   Copyright (C) 1992, 1995, 1997-1998, 2006, 2009-2019 Free Software
    Foundation, Inc.
 
    NOTE: The canonical source of this file is maintained with the GNU C 
Library.
diff --git a/lib/str-two-way.h b/lib/str-two-way.h
new file mode 100644
index 0000000..7078c34
--- /dev/null
+++ b/lib/str-two-way.h
@@ -0,0 +1,452 @@
+/* Byte-wise substring search, using the Two-Way algorithm.
+   Copyright (C) 2008-2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Written by Eric Blake <address@hidden>, 2008.
+
+   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, 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/>.  */
+
+/* Before including this file, you need to include <config.h> and
+   <string.h>, and define:
+     RETURN_TYPE             A macro that expands to the return type.
+     AVAILABLE(h, h_l, j, n_l)
+                             A macro that returns nonzero if there are
+                             at least N_L bytes left starting at H[J].
+                             H is 'unsigned char *', H_L, J, and N_L
+                             are 'size_t'; H_L is an lvalue.  For
+                             NUL-terminated searches, H_L can be
+                             modified each iteration to avoid having
+                             to compute the end of H up front.
+
+  For case-insensitivity, you may optionally define:
+     CMP_FUNC(p1, p2, l)     A macro that returns 0 iff the first L
+                             characters of P1 and P2 are equal.
+     CANON_ELEMENT(c)        A macro that canonicalizes an element right after
+                             it has been fetched from one of the two strings.
+                             The argument is an 'unsigned char'; the result
+                             must be an 'unsigned char' as well.
+
+  This file undefines the macros documented above, and defines
+  LONG_NEEDLE_THRESHOLD.
+*/
+
+#include <limits.h>
+#include <stdint.h>
+
+/* We use the Two-Way string matching algorithm (also known as
+   Chrochemore-Perrin), which guarantees linear complexity with
+   constant space.  Additionally, for long needles, we also use a bad
+   character shift table similar to the Boyer-Moore algorithm to
+   achieve improved (potentially sub-linear) performance.
+
+   See http://www-igm.univ-mlv.fr/~lecroq/string/node26.html#SECTION00260,
+   https://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm,
+   
https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.34.6641&rep=rep1&type=pdf
+*/
+
+/* Point at which computing a bad-byte shift table is likely to be
+   worthwhile.  Small needles should not compute a table, since it
+   adds (1 << CHAR_BIT) + NEEDLE_LEN computations of preparation for a
+   speedup no greater than a factor of NEEDLE_LEN.  The larger the
+   needle, the better the potential performance gain.  On the other
+   hand, on non-POSIX systems with CHAR_BIT larger than eight, the
+   memory required for the table is prohibitive.  */
+#if CHAR_BIT < 10
+# define LONG_NEEDLE_THRESHOLD 32U
+#else
+# define LONG_NEEDLE_THRESHOLD SIZE_MAX
+#endif
+
+#ifndef MAX
+# define MAX(a, b) ((a < b) ? (b) : (a))
+#endif
+
+#ifndef CANON_ELEMENT
+# define CANON_ELEMENT(c) c
+#endif
+#ifndef CMP_FUNC
+# define CMP_FUNC memcmp
+#endif
+
+/* Perform a critical factorization of NEEDLE, of length NEEDLE_LEN.
+   Return the index of the first byte in the right half, and set
+   *PERIOD to the global period of the right half.
+
+   The global period of a string is the smallest index (possibly its
+   length) at which all remaining bytes in the string are repetitions
+   of the prefix (the last repetition may be a subset of the prefix).
+
+   When NEEDLE is factored into two halves, a local period is the
+   length of the smallest word that shares a suffix with the left half
+   and shares a prefix with the right half.  All factorizations of a
+   non-empty NEEDLE have a local period of at least 1 and no greater
+   than NEEDLE_LEN.
+
+   A critical factorization has the property that the local period
+   equals the global period.  All strings have at least one critical
+   factorization with the left half smaller than the global period.
+   And while some strings have more than one critical factorization,
+   it is provable that with an ordered alphabet, at least one of the
+   critical factorizations corresponds to a maximal suffix.
+
+   Given an ordered alphabet, a critical factorization can be computed
+   in linear time, with 2 * NEEDLE_LEN comparisons, by computing the
+   shorter of two ordered maximal suffixes.  The ordered maximal
+   suffixes are determined by lexicographic comparison while tracking
+   periodicity.  */
+static size_t
+critical_factorization (const unsigned char *needle, size_t needle_len,
+                        size_t *period)
+{
+  /* Index of last byte of left half, or SIZE_MAX.  */
+  size_t max_suffix, max_suffix_rev;
+  size_t j; /* Index into NEEDLE for current candidate suffix.  */
+  size_t k; /* Offset into current period.  */
+  size_t p; /* Intermediate period.  */
+  unsigned char a, b; /* Current comparison bytes.  */
+
+  /* Special case NEEDLE_LEN of 1 or 2 (all callers already filtered
+     out 0-length needles.  */
+  if (needle_len < 3)
+    {
+      *period = 1;
+      return needle_len - 1;
+    }
+
+  /* Invariants:
+     0 <= j < NEEDLE_LEN - 1
+     -1 <= max_suffix{,_rev} < j (treating SIZE_MAX as if it were signed)
+     min(max_suffix, max_suffix_rev) < global period of NEEDLE
+     1 <= p <= global period of NEEDLE
+     p == global period of the substring NEEDLE[max_suffix{,_rev}+1...j]
+     1 <= k <= p
+  */
+
+  /* Perform lexicographic search.  */
+  max_suffix = SIZE_MAX;
+  j = 0;
+  k = p = 1;
+  while (j + k < needle_len)
+    {
+      a = CANON_ELEMENT (needle[j + k]);
+      b = CANON_ELEMENT (needle[max_suffix + k]);
+      if (a < b)
+        {
+          /* Suffix is smaller, period is entire prefix so far.  */
+          j += k;
+          k = 1;
+          p = j - max_suffix;
+        }
+      else if (a == b)
+        {
+          /* Advance through repetition of the current period.  */
+          if (k != p)
+            ++k;
+          else
+            {
+              j += p;
+              k = 1;
+            }
+        }
+      else /* b < a */
+        {
+          /* Suffix is larger, start over from current location.  */
+          max_suffix = j++;
+          k = p = 1;
+        }
+    }
+  *period = p;
+
+  /* Perform reverse lexicographic search.  */
+  max_suffix_rev = SIZE_MAX;
+  j = 0;
+  k = p = 1;
+  while (j + k < needle_len)
+    {
+      a = CANON_ELEMENT (needle[j + k]);
+      b = CANON_ELEMENT (needle[max_suffix_rev + k]);
+      if (b < a)
+        {
+          /* Suffix is smaller, period is entire prefix so far.  */
+          j += k;
+          k = 1;
+          p = j - max_suffix_rev;
+        }
+      else if (a == b)
+        {
+          /* Advance through repetition of the current period.  */
+          if (k != p)
+            ++k;
+          else
+            {
+              j += p;
+              k = 1;
+            }
+        }
+      else /* a < b */
+        {
+          /* Suffix is larger, start over from current location.  */
+          max_suffix_rev = j++;
+          k = p = 1;
+        }
+    }
+
+  /* Choose the shorter suffix.  Return the index of the first byte of
+     the right half, rather than the last byte of the left half.
+
+     For some examples, 'banana' has two critical factorizations, both
+     exposed by the two lexicographic extreme suffixes of 'anana' and
+     'nana', where both suffixes have a period of 2.  On the other
+     hand, with 'aab' and 'bba', both strings have a single critical
+     factorization of the last byte, with the suffix having a period
+     of 1.  While the maximal lexicographic suffix of 'aab' is 'b',
+     the maximal lexicographic suffix of 'bba' is 'ba', which is not a
+     critical factorization.  Conversely, the maximal reverse
+     lexicographic suffix of 'a' works for 'bba', but not 'ab' for
+     'aab'.  The shorter suffix of the two will always be a critical
+     factorization.  */
+  if (max_suffix_rev + 1 < max_suffix + 1)
+    return max_suffix + 1;
+  *period = p;
+  return max_suffix_rev + 1;
+}
+
+/* Return the first location of non-empty NEEDLE within HAYSTACK, or
+   NULL.  HAYSTACK_LEN is the minimum known length of HAYSTACK.  This
+   method is optimized for NEEDLE_LEN < LONG_NEEDLE_THRESHOLD.
+   Performance is guaranteed to be linear, with an initialization cost
+   of 2 * NEEDLE_LEN comparisons.
+
+   If AVAILABLE does not modify HAYSTACK_LEN (as in memmem), then at
+   most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching.
+   If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 *
+   HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching.  */
+static RETURN_TYPE
+two_way_short_needle (const unsigned char *haystack, size_t haystack_len,
+                      const unsigned char *needle, size_t needle_len)
+{
+  size_t i; /* Index into current byte of NEEDLE.  */
+  size_t j; /* Index into current window of HAYSTACK.  */
+  size_t period; /* The period of the right half of needle.  */
+  size_t suffix; /* The index of the right half of needle.  */
+
+  /* Factor the needle into two halves, such that the left half is
+     smaller than the global period, and the right half is
+     periodic (with a period as large as NEEDLE_LEN - suffix).  */
+  suffix = critical_factorization (needle, needle_len, &period);
+
+  /* Perform the search.  Each iteration compares the right half
+     first.  */
+  if (CMP_FUNC (needle, needle + period, suffix) == 0)
+    {
+      /* Entire needle is periodic; a mismatch in the left half can
+         only advance by the period, so use memory to avoid rescanning
+         known occurrences of the period in the right half.  */
+      size_t memory = 0;
+      j = 0;
+      while (AVAILABLE (haystack, haystack_len, j, needle_len))
+        {
+          /* Scan for matches in right half.  */
+          i = MAX (suffix, memory);
+          while (i < needle_len && (CANON_ELEMENT (needle[i])
+                                    == CANON_ELEMENT (haystack[i + j])))
+            ++i;
+          if (needle_len <= i)
+            {
+              /* Scan for matches in left half.  */
+              i = suffix - 1;
+              while (memory < i + 1 && (CANON_ELEMENT (needle[i])
+                                        == CANON_ELEMENT (haystack[i + j])))
+                --i;
+              if (i + 1 < memory + 1)
+                return (RETURN_TYPE) (haystack + j);
+              /* No match, so remember how many repetitions of period
+                 on the right half were scanned.  */
+              j += period;
+              memory = needle_len - period;
+            }
+          else
+            {
+              j += i - suffix + 1;
+              memory = 0;
+            }
+        }
+    }
+  else
+    {
+      /* The two halves of needle are distinct; no extra memory is
+         required, and any mismatch results in a maximal shift.  */
+      period = MAX (suffix, needle_len - suffix) + 1;
+      j = 0;
+      while (AVAILABLE (haystack, haystack_len, j, needle_len))
+        {
+          /* Scan for matches in right half.  */
+          i = suffix;
+          while (i < needle_len && (CANON_ELEMENT (needle[i])
+                                    == CANON_ELEMENT (haystack[i + j])))
+            ++i;
+          if (needle_len <= i)
+            {
+              /* Scan for matches in left half.  */
+              i = suffix - 1;
+              while (i != SIZE_MAX && (CANON_ELEMENT (needle[i])
+                                       == CANON_ELEMENT (haystack[i + j])))
+                --i;
+              if (i == SIZE_MAX)
+                return (RETURN_TYPE) (haystack + j);
+              j += period;
+            }
+          else
+            j += i - suffix + 1;
+        }
+    }
+  return NULL;
+}
+
+/* Return the first location of non-empty NEEDLE within HAYSTACK, or
+   NULL.  HAYSTACK_LEN is the minimum known length of HAYSTACK.  This
+   method is optimized for LONG_NEEDLE_THRESHOLD <= NEEDLE_LEN.
+   Performance is guaranteed to be linear, with an initialization cost
+   of 3 * NEEDLE_LEN + (1 << CHAR_BIT) operations.
+
+   If AVAILABLE does not modify HAYSTACK_LEN (as in memmem), then at
+   most 2 * HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching,
+   and sublinear performance O(HAYSTACK_LEN / NEEDLE_LEN) is possible.
+   If AVAILABLE modifies HAYSTACK_LEN (as in strstr), then at most 3 *
+   HAYSTACK_LEN - NEEDLE_LEN comparisons occur in searching, and
+   sublinear performance is not possible.  */
+static RETURN_TYPE
+two_way_long_needle (const unsigned char *haystack, size_t haystack_len,
+                     const unsigned char *needle, size_t needle_len)
+{
+  size_t i; /* Index into current byte of NEEDLE.  */
+  size_t j; /* Index into current window of HAYSTACK.  */
+  size_t period; /* The period of the right half of needle.  */
+  size_t suffix; /* The index of the right half of needle.  */
+  size_t shift_table[1U << CHAR_BIT]; /* See below.  */
+
+  /* Factor the needle into two halves, such that the left half is
+     smaller than the global period, and the right half is
+     periodic (with a period as large as NEEDLE_LEN - suffix).  */
+  suffix = critical_factorization (needle, needle_len, &period);
+
+  /* Populate shift_table.  For each possible byte value c,
+     shift_table[c] is the distance from the last occurrence of c to
+     the end of NEEDLE, or NEEDLE_LEN if c is absent from the NEEDLE.
+     shift_table[NEEDLE[NEEDLE_LEN - 1]] contains the only 0.  */
+  for (i = 0; i < 1U << CHAR_BIT; i++)
+    shift_table[i] = needle_len;
+  for (i = 0; i < needle_len; i++)
+    shift_table[CANON_ELEMENT (needle[i])] = needle_len - i - 1;
+
+  /* Perform the search.  Each iteration compares the right half
+     first.  */
+  if (CMP_FUNC (needle, needle + period, suffix) == 0)
+    {
+      /* Entire needle is periodic; a mismatch in the left half can
+         only advance by the period, so use memory to avoid rescanning
+         known occurrences of the period in the right half.  */
+      size_t memory = 0;
+      size_t shift;
+      j = 0;
+      while (AVAILABLE (haystack, haystack_len, j, needle_len))
+        {
+          /* Check the last byte first; if it does not match, then
+             shift to the next possible match location.  */
+          shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])];
+          if (0 < shift)
+            {
+              if (memory && shift < period)
+                {
+                  /* Since needle is periodic, but the last period has
+                     a byte out of place, there can be no match until
+                     after the mismatch.  */
+                  shift = needle_len - period;
+                }
+              memory = 0;
+              j += shift;
+              continue;
+            }
+          /* Scan for matches in right half.  The last byte has
+             already been matched, by virtue of the shift table.  */
+          i = MAX (suffix, memory);
+          while (i < needle_len - 1 && (CANON_ELEMENT (needle[i])
+                                        == CANON_ELEMENT (haystack[i + j])))
+            ++i;
+          if (needle_len - 1 <= i)
+            {
+              /* Scan for matches in left half.  */
+              i = suffix - 1;
+              while (memory < i + 1 && (CANON_ELEMENT (needle[i])
+                                        == CANON_ELEMENT (haystack[i + j])))
+                --i;
+              if (i + 1 < memory + 1)
+                return (RETURN_TYPE) (haystack + j);
+              /* No match, so remember how many repetitions of period
+                 on the right half were scanned.  */
+              j += period;
+              memory = needle_len - period;
+            }
+          else
+            {
+              j += i - suffix + 1;
+              memory = 0;
+            }
+        }
+    }
+  else
+    {
+      /* The two halves of needle are distinct; no extra memory is
+         required, and any mismatch results in a maximal shift.  */
+      size_t shift;
+      period = MAX (suffix, needle_len - suffix) + 1;
+      j = 0;
+      while (AVAILABLE (haystack, haystack_len, j, needle_len))
+        {
+          /* Check the last byte first; if it does not match, then
+             shift to the next possible match location.  */
+          shift = shift_table[CANON_ELEMENT (haystack[j + needle_len - 1])];
+          if (0 < shift)
+            {
+              j += shift;
+              continue;
+            }
+          /* Scan for matches in right half.  The last byte has
+             already been matched, by virtue of the shift table.  */
+          i = suffix;
+          while (i < needle_len - 1 && (CANON_ELEMENT (needle[i])
+                                        == CANON_ELEMENT (haystack[i + j])))
+            ++i;
+          if (needle_len - 1 <= i)
+            {
+              /* Scan for matches in left half.  */
+              i = suffix - 1;
+              while (i != SIZE_MAX && (CANON_ELEMENT (needle[i])
+                                       == CANON_ELEMENT (haystack[i + j])))
+                --i;
+              if (i == SIZE_MAX)
+                return (RETURN_TYPE) (haystack + j);
+              j += period;
+            }
+          else
+            j += i - suffix + 1;
+        }
+    }
+  return NULL;
+}
+
+#undef AVAILABLE
+#undef CANON_ELEMENT
+#undef CMP_FUNC
+#undef MAX
+#undef RETURN_TYPE
diff --git a/lib/strftime.h b/lib/strftime.h
index af73767..e4a720b 100644
--- a/lib/strftime.h
+++ b/lib/strftime.h
@@ -1,6 +1,6 @@
 /* declarations for strftime.c
 
-   Copyright (C) 2002, 2004, 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2008-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/string.in.h b/lib/string.in.h
index 29f4ba6..4a9292f 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -1,6 +1,6 @@
 /* A GNU-like <string.h>.
 
-   Copyright (C) 1995-1996, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1995-1996, 2001-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/strtoimax.c b/lib/strtoimax.c
index 69e3a99..87b080c 100644
--- a/lib/strtoimax.c
+++ b/lib/strtoimax.c
@@ -1,6 +1,6 @@
 /* Convert string representation of a number into an intmax_t value.
 
-   Copyright (C) 1999, 2001-2004, 2006, 2009-2018 Free Software Foundation,
+   Copyright (C) 1999, 2001-2004, 2006, 2009-2019 Free Software Foundation,
    Inc.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/strtol.c b/lib/strtol.c
index f6f5c32..1d920af 100644
--- a/lib/strtol.c
+++ b/lib/strtol.c
@@ -1,6 +1,6 @@
 /* Convert string representation of a number into an integer value.
 
-   Copyright (C) 1991-1992, 1994-1999, 2003, 2005-2007, 2009-2018 Free Software
+   Copyright (C) 1991-1992, 1994-1999, 2003, 2005-2007, 2009-2019 Free Software
    Foundation, Inc.
 
    NOTE: The canonical source of this file is maintained with the GNU C
diff --git a/lib/strtoll.c b/lib/strtoll.c
index 8aa10f4..038362a 100644
--- a/lib/strtoll.c
+++ b/lib/strtoll.c
@@ -1,5 +1,5 @@
 /* Function to parse a 'long long int' from text.
-   Copyright (C) 1995-1997, 1999, 2001, 2009-2018 Free Software Foundation,
+   Copyright (C) 1995-1997, 1999, 2001, 2009-2019 Free Software Foundation,
    Inc.
    This file is part of the GNU C Library.
 
diff --git a/lib/symlink.c b/lib/symlink.c
index c1c4b40..16432ee 100644
--- a/lib/symlink.c
+++ b/lib/symlink.c
@@ -1,5 +1,5 @@
 /* Stub for symlink().
-   Copyright (C) 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/sys_select.in.h b/lib/sys_select.in.h
index 154e570..4cf7cfc 100644
--- a/lib/sys_select.in.h
+++ b/lib/sys_select.in.h
@@ -1,5 +1,5 @@
 /* Substitute for <sys/select.h>.
-   Copyright (C) 2007-2018 Free Software Foundation, Inc.
+   Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index 6ae6ac5..9ddd1a8 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -1,5 +1,5 @@
 /* Provide a more complete sys/stat.h header file.
-   Copyright (C) 2005-2018 Free Software Foundation, Inc.
+   Copyright (C) 2005-2019 Free Software Foundation, Inc.
 
    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
@@ -54,9 +54,16 @@
 
 /* The definition of _GL_WARN_ON_USE is copied here.  */
 
+/* Before doing "#define mknod rpl_mknod" below, we need to include all
+   headers that may declare mknod().  OS/2 kLIBC declares mknod() in
+   <unistd.h>, not in <sys/stat.h>.  */
+#ifdef __KLIBC__
+# include <unistd.h>
+#endif
+
 /* Before doing "#define mkdir rpl_mkdir" below, we need to include all
    headers that may declare mkdir().  Native Windows platforms declare mkdir
-   in <io.h> and/or <direct.h>, not in <unistd.h>.  */
+   in <io.h> and/or <direct.h>, not in <sys/stat.h>.  */
 #if defined _WIN32 && ! defined __CYGWIN__
 # include <io.h>     /* mingw32, mingw64 */
 # include <direct.h> /* mingw64, MSVC 9 */
diff --git a/lib/sys_time.in.h b/lib/sys_time.in.h
index b4a0e49..5397688 100644
--- a/lib/sys_time.in.h
+++ b/lib/sys_time.in.h
@@ -1,6 +1,6 @@
 /* Provide a more complete sys/time.h.
 
-   Copyright (C) 2007-2018 Free Software Foundation, Inc.
+   Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/sys_types.in.h b/lib/sys_types.in.h
index 7f8c1c4..237e206 100644
--- a/lib/sys_types.in.h
+++ b/lib/sys_types.in.h
@@ -1,6 +1,6 @@
 /* Provide a more complete sys/types.h.
 
-   Copyright (C) 2011-2018 Free Software Foundation, Inc.
+   Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/tempname.c b/lib/tempname.c
index da81263..be62ed9 100644
--- a/lib/tempname.c
+++ b/lib/tempname.c
@@ -1,6 +1,6 @@
 /* tempname.c - generate the name of a temporary file.
 
-   Copyright (C) 1991-2003, 2005-2007, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 1991-2003, 2005-2007, 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/tempname.h b/lib/tempname.h
index 4020c73..fb203d3 100644
--- a/lib/tempname.h
+++ b/lib/tempname.h
@@ -1,6 +1,6 @@
 /* Create a temporary file or directory.
 
-   Copyright (C) 2006, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/time-internal.h b/lib/time-internal.h
index 3a83623..57f2e78 100644
--- a/lib/time-internal.h
+++ b/lib/time-internal.h
@@ -1,6 +1,6 @@
 /* Time internal interface
 
-   Copyright 2015-2018 Free Software Foundation, Inc.
+   Copyright 2015-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/time.in.h b/lib/time.in.h
index 3128f44..dd3b212 100644
--- a/lib/time.in.h
+++ b/lib/time.in.h
@@ -1,6 +1,6 @@
 /* A more-standard <time.h>.
 
-   Copyright (C) 2007-2018 Free Software Foundation, Inc.
+   Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/time_r.c b/lib/time_r.c
index 3029780..a701ccc 100644
--- a/lib/time_r.c
+++ b/lib/time_r.c
@@ -1,6 +1,6 @@
 /* Reentrant time functions like localtime_r.
 
-   Copyright (C) 2003, 2006-2007, 2010-2018 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2006-2007, 2010-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/time_rz.c b/lib/time_rz.c
index 5293c7c..42ae3d3 100644
--- a/lib/time_rz.c
+++ b/lib/time_rz.c
@@ -1,6 +1,6 @@
 /* Time zone functions such as tzalloc and localtime_rz
 
-   Copyright 2015-2018 Free Software Foundation, Inc.
+   Copyright 2015-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/timegm.c b/lib/timegm.c
index 9d9ab11..2ca5744 100644
--- a/lib/timegm.c
+++ b/lib/timegm.c
@@ -1,6 +1,6 @@
 /* Convert UTC calendar time to simple time.  Like mktime but assumes UTC.
 
-   Copyright (C) 1994-2018 Free Software Foundation, Inc.
+   Copyright (C) 1994-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
diff --git a/lib/timespec-add.c b/lib/timespec-add.c
index 1913b97..e0a9f12 100644
--- a/lib/timespec-add.c
+++ b/lib/timespec-add.c
@@ -1,6 +1,6 @@
 /* Add two struct timespec values.
 
-   Copyright (C) 2011-2018 Free Software Foundation, Inc.
+   Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/timespec-sub.c b/lib/timespec-sub.c
index 9eac36e..48434e8 100644
--- a/lib/timespec-sub.c
+++ b/lib/timespec-sub.c
@@ -1,6 +1,6 @@
 /* Subtract two struct timespec values.
 
-   Copyright (C) 2011-2018 Free Software Foundation, Inc.
+   Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/timespec.h b/lib/timespec.h
index cc49668..26f1bc1 100644
--- a/lib/timespec.h
+++ b/lib/timespec.h
@@ -1,6 +1,6 @@
 /* timespec -- System time interface
 
-   Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2018 Free Software
+   Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2019 Free Software
    Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/u64.h b/lib/u64.h
index 498b7f9..bb2f6ed 100644
--- a/lib/u64.h
+++ b/lib/u64.h
@@ -1,6 +1,6 @@
 /* uint64_t-like operations that work even on hosts lacking uint64_t
 
-   Copyright (C) 2006, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 66f254d..7778d25 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -1,5 +1,5 @@
 /* Substitute for and wrapper around <unistd.h>.
-   Copyright (C) 2003-2018 Free Software Foundation, Inc.
+   Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
    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
@@ -68,9 +68,11 @@
 # include <stdio.h>
 #endif
 
-/* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>.  */
+/* Cygwin 1.7.1 and Android 4.3 declare unlinkat in <fcntl.h>, not in
+   <unistd.h>.  */
 /* But avoid namespace pollution on glibc systems.  */
-#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
+#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) \
+    && (defined __CYGWIN__ || defined __ANDROID__) \
     && ! defined __GLIBC__
 # include <fcntl.h>
 #endif
@@ -113,6 +115,13 @@
 # include <netdb.h>
 #endif
 
+/* Android 4.3 declares fchownat in <sys/stat.h>, not in <unistd.h>.  */
+/* But avoid namespace pollution on glibc systems.  */
+#if (@GNULIB_FCHOWNAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
+    && !defined __GLIBC__
+# include <sys/stat.h>
+#endif
+
 /* MSVC defines off_t in <sys/types.h>.
    May also define off_t to a 64-bit type on native Windows.  */
 #if address@hidden@ || @WINDOWS_64_BIT_OFF_T@
diff --git a/lib/unlocked-io.h b/lib/unlocked-io.h
index e3f0fcf..ee1c062 100644
--- a/lib/unlocked-io.h
+++ b/lib/unlocked-io.h
@@ -1,6 +1,6 @@
 /* Prefer faster, non-thread-safe stdio functions if available.
 
-   Copyright (C) 2001-2004, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2001-2004, 2009-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/utimens.c b/lib/utimens.c
index f6c4fe3..c9b65ef 100644
--- a/lib/utimens.c
+++ b/lib/utimens.c
@@ -1,6 +1,6 @@
 /* Set file access and modification times.
 
-   Copyright (C) 2003-2018 Free Software Foundation, Inc.
+   Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
    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
@@ -288,8 +288,8 @@ fdutimens (int fd, char const *file, struct timespec const 
timespec[2])
 
 #ifdef USE_SETFILETIME
   /* On native Windows, use SetFileTime(). See
-     <https://msdn.microsoft.com/en-us/library/ms724933.aspx>
-     <https://msdn.microsoft.com/en-us/library/ms724284.aspx>  */
+     
<https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-setfiletime>
+     
<https://docs.microsoft.com/en-us/windows/desktop/api/minwinbase/ns-minwinbase-filetime>
  */
   if (0 <= fd)
     {
       HANDLE handle;
@@ -307,10 +307,10 @@ fdutimens (int fd, char const *file, struct timespec 
const timespec[2])
       if (ts == NULL || ts[0].tv_nsec == UTIME_NOW || ts[1].tv_nsec == 
UTIME_NOW)
         {
           /* GetSystemTimeAsFileTime
-             <https://msdn.microsoft.com/en-us/library/ms724397.aspx>.
+             
<https://docs.microsoft.com/en-us/windows/desktop/api/sysinfoapi/nf-sysinfoapi-getsystemtimeasfiletime>.
              It would be overkill to use
              GetSystemTimePreciseAsFileTime
-             <https://msdn.microsoft.com/en-us/library/hh706895.aspx>.  */
+             
<https://docs.microsoft.com/en-us/windows/desktop/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime>.
  */
           GetSystemTimeAsFileTime (&current_time);
         }
 
diff --git a/lib/utimens.h b/lib/utimens.h
index a24e62c..b174096 100644
--- a/lib/utimens.h
+++ b/lib/utimens.h
@@ -1,6 +1,6 @@
 /* Set file access and modification times.
 
-   Copyright 2012-2018 Free Software Foundation, Inc.
+   Copyright 2012-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lib/verify.h b/lib/verify.h
index 3b57dde..6930645 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -1,6 +1,6 @@
 /* Compile-time assert-like macros.
 
-   Copyright (C) 2005-2006, 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2005-2006, 2009-2019 Free Software Foundation, Inc.
 
    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
@@ -26,7 +26,7 @@
    here generates easier-to-read diagnostics when verify (R) fails.
 
    Define _GL_HAVE_STATIC_ASSERT to 1 if static_assert works as per C++11.
-   This will likely be supported by future GCC versions, in C++ mode.
+   This is supported by GCC 6.1.0 and later, in C++ mode.
 
    Use this only with GCC.  If we were willing to slow 'configure'
    down we could also use it with other compilers, but since this
@@ -36,9 +36,7 @@
      && !defined __cplusplus)
 # define _GL_HAVE__STATIC_ASSERT 1
 #endif
-/* The condition (99 < __GNUC__) is temporary, until we know about the
-   first G++ release that supports static_assert.  */
-#if (99 < __GNUC__) && defined __cplusplus
+#if (6 <= __GNUC__) && defined __cplusplus
 # define _GL_HAVE_STATIC_ASSERT 1
 #endif
 
diff --git a/lib/vla.h b/lib/vla.h
index 5c9735f..8f5dea7 100644
--- a/lib/vla.h
+++ b/lib/vla.h
@@ -1,6 +1,6 @@
 /* vla.h - variable length arrays
 
-   Copyright 2014-2018 Free Software Foundation, Inc.
+   Copyright 2014-2019 Free Software Foundation, Inc.
 
    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
@@ -17,6 +17,20 @@
 
    Written by Paul Eggert.  */
 
+/* The VLA_ELEMS macro does not allocate variable-length arrays (VLAs),
+   so it does not have the security or performance issues commonly
+   associated with VLAs.  VLA_ELEMS is for exploiting a C11 feature
+   where a function can start like this:
+
+     double scan_array (int n, double v[static n])
+
+   to require a caller to pass a vector V with at least N elements;
+   this allows better static checking and performance in some cases.
+   In C11 this feature means that V is a VLA, so the feature is
+   supported only if __STDC_NO_VLA__ is defined, and for compatibility
+   to platforms that do not support VLAs, VLA_ELEMS (n) expands to
+   nothing when __STDC_NO_VLA__ is not defined.  */
+
 /* A function's argument must point to an array with at least N elements.
    Example: 'int main (int argc, char *argv[VLA_ELEMS (argc)]);'.  */
 
@@ -25,3 +39,15 @@
 #else
 # define VLA_ELEMS(n) static n
 #endif
+
+/* Although C99 requires support for variable-length arrays (VLAs),
+   some C compilers never supported VLAs and VLAs are optional in C11.
+   VLAs are controversial because their allocation may be unintended
+   or awkward to support, and large VLAs might cause security or
+   performance problems.  GCC can diagnose the use of VLAs via the
+   -Wvla and -Wvla-larger-than warnings options, and defining the
+   macro GNULIB_NO_VLA disables the allocation of VLAs in Gnulib code.
+
+   The VLA_ELEMS macro is unaffected by GNULIB_NO_VLA, since it does
+   not allocate VLAs.  Programs that use VLA_ELEMS should be compiled
+   with 'gcc -Wvla-larger-than' instead of with 'gcc -Wvla'.  */
diff --git a/lib/warn-on-use.h b/lib/warn-on-use.h
index 72d67cc..7d11a15 100644
--- a/lib/warn-on-use.h
+++ b/lib/warn-on-use.h
@@ -1,5 +1,5 @@
 /* A C macro for emitting warnings if a function is used.
-   Copyright (C) 2010-2018 Free Software Foundation, Inc.
+   Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published
diff --git a/lib/xalloc-oversized.h b/lib/xalloc-oversized.h
index 3426e10..e3068c8 100644
--- a/lib/xalloc-oversized.h
+++ b/lib/xalloc-oversized.h
@@ -1,6 +1,6 @@
 /* xalloc-oversized.h -- memory allocation size checking
 
-   Copyright (C) 1990-2000, 2003-2004, 2006-2018 Free Software Foundation, Inc.
+   Copyright (C) 1990-2000, 2003-2004, 2006-2019 Free Software Foundation, Inc.
 
    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
diff --git a/lisp/ChangeLog.1 b/lisp/ChangeLog.1
index 060d018..ac4c49b 100644
--- a/lisp/ChangeLog.1
+++ b/lisp/ChangeLog.1
@@ -3244,7 +3244,7 @@
                Set current buffer variables from defaults
                in case user's init file has changed them.
 
-  Copyright (C) 1985-1986, 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 1985-1986, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/ChangeLog.10 b/lisp/ChangeLog.10
index 7ea47f9..8aa56b1 100644
--- a/lisp/ChangeLog.10
+++ b/lisp/ChangeLog.10
@@ -23541,7 +23541,7 @@ See ChangeLog.9 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-    Copyright (C) 2001-2018 Free Software Foundation, Inc.
+    Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/ChangeLog.11 b/lisp/ChangeLog.11
index 2eb2286..2884381 100644
--- a/lisp/ChangeLog.11
+++ b/lisp/ChangeLog.11
@@ -14321,7 +14321,7 @@ See ChangeLog.10 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 2003-2011, 2013-2018 Free Software Foundation, Inc.
+  Copyright (C) 2003-2011, 2013-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/ChangeLog.12 b/lisp/ChangeLog.12
index 3c12d5b..0c0349c 100644
--- a/lisp/ChangeLog.12
+++ b/lisp/ChangeLog.12
@@ -8873,7 +8873,7 @@
 2006-06-06  Nick Roberts  <address@hidden>
 
        * progmodes/gud.el (gud-running): Fix doc string.
-       (gud-menu-map): Use :visible instead fo :enable for debugger test.
+       (gud-menu-map): Use :visible instead of :enable for debugger test.
        (gud-tooltip-modes): Add python-mode.
        (gud-tooltip-print-command): Add pdb.  Remove perldb.
 
@@ -33334,7 +33334,7 @@ See ChangeLog.11 for earlier changes.
 ;; add-log-time-zone-rule: t
 ;; End:
 
-    Copyright (C) 2005-2018 Free Software Foundation, Inc.
+    Copyright (C) 2005-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/ChangeLog.13 b/lisp/ChangeLog.13
index f088edc..9f81264 100644
--- a/lisp/ChangeLog.13
+++ b/lisp/ChangeLog.13
@@ -16697,7 +16697,7 @@ See ChangeLog.12 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 2007-2018 Free Software Foundation, Inc.
+  Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/ChangeLog.14 b/lisp/ChangeLog.14
index 84a2a25..370ed58 100644
--- a/lisp/ChangeLog.14
+++ b/lisp/ChangeLog.14
@@ -20547,7 +20547,7 @@ See ChangeLog.13 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-    Copyright (C) 2008-2018 Free Software Foundation, Inc.
+    Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/ChangeLog.15 b/lisp/ChangeLog.15
index c4d7be5..b22661f 100644
--- a/lisp/ChangeLog.15
+++ b/lisp/ChangeLog.15
@@ -22802,7 +22802,7 @@ See ChangeLog.14 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 2009-2018 Free Software Foundation, Inc.
+  Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/ChangeLog.16 b/lisp/ChangeLog.16
index 279ee3e..3e2ddd9 100644
--- a/lisp/ChangeLog.16
+++ b/lisp/ChangeLog.16
@@ -25223,7 +25223,7 @@ See ChangeLog.15 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 2011-2018 Free Software Foundation, Inc.
+  Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/ChangeLog.17 b/lisp/ChangeLog.17
index 64b9a14..ed3b4a9 100644
--- a/lisp/ChangeLog.17
+++ b/lisp/ChangeLog.17
@@ -26294,7 +26294,7 @@ See ChangeLog.16 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 2011-2018 Free Software Foundation, Inc.
+  Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/ChangeLog.2 b/lisp/ChangeLog.2
index a5a654a..e8675b9 100644
--- a/lisp/ChangeLog.2
+++ b/lisp/ChangeLog.2
@@ -3992,7 +3992,7 @@
 
 See ChangeLog.1 for earlier changes.
 
-    Copyright (C) 1986-1988, 2001-2018 Free Software Foundation, Inc.
+    Copyright (C) 1986-1988, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/ChangeLog.3 b/lisp/ChangeLog.3
index ae91947..38e6844 100644
--- a/lisp/ChangeLog.3
+++ b/lisp/ChangeLog.3
@@ -12433,7 +12433,7 @@ See ChangeLog.2 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-    Copyright (C) 1989, 1993, 2001-2018 Free Software Foundation, Inc.
+    Copyright (C) 1989, 1993, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/ChangeLog.4 b/lisp/ChangeLog.4
index 0374e1b..74f09e5 100644
--- a/lisp/ChangeLog.4
+++ b/lisp/ChangeLog.4
@@ -8934,7 +8934,7 @@ See ChangeLog.3 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-    Copyright (C) 1993-1994, 2001-2018 Free Software Foundation, Inc.
+    Copyright (C) 1993-1994, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/ChangeLog.5 b/lisp/ChangeLog.5
index 3a68421..0976a15 100644
--- a/lisp/ChangeLog.5
+++ b/lisp/ChangeLog.5
@@ -9268,7 +9268,7 @@ See ChangeLog.4 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-    Copyright (C) 1994-1995, 2001-2018 Free Software Foundation, Inc.
+    Copyright (C) 1994-1995, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/ChangeLog.6 b/lisp/ChangeLog.6
index 0d0df58..d68e6fc 100644
--- a/lisp/ChangeLog.6
+++ b/lisp/ChangeLog.6
@@ -8021,7 +8021,7 @@ See ChangeLog.5 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-    Copyright (C) 1995-1996, 2001-2018 Free Software Foundation, Inc.
+    Copyright (C) 1995-1996, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/ChangeLog.7 b/lisp/ChangeLog.7
index 27cbe10..b8e0f10 100644
--- a/lisp/ChangeLog.7
+++ b/lisp/ChangeLog.7
@@ -12376,7 +12376,7 @@
        when turning on Encoded-kbd mode, and recover it when turning off
        Encoded-kbd mode.  Set encoded-kbd-iso2022-designations correctly.
        (encoded-kbd-self-insert-iso2022-7bit): Call charset-dimension
-       instead fo charset-bytes.
+       instead of charset-bytes.
        (encoded-kbd-self-insert-iso2022-8bit): Likewise.
 
        * language/china-util.el (setup-chinese-gb-environment): Do not
@@ -23110,7 +23110,7 @@ See ChangeLog.6 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-       Copyright (C) 1997-1998, 2001-2018 Free Software Foundation,
+       Copyright (C) 1997-1998, 2001-2019 Free Software Foundation,
        Inc.
 
   This file is part of GNU Emacs.
diff --git a/lisp/ChangeLog.8 b/lisp/ChangeLog.8
index 13c7f65..cd09053 100644
--- a/lisp/ChangeLog.8
+++ b/lisp/ChangeLog.8
@@ -9992,7 +9992,7 @@ See ChangeLog.7 for earlier changes.
 ;; add-log-time-zone-rule: t
 ;; End:
 
-    Copyright (C) 1999, 2001-2018 Free Software Foundation, Inc.
+    Copyright (C) 1999, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/ChangeLog.9 b/lisp/ChangeLog.9
index 87d3818..ebf9509 100644
--- a/lisp/ChangeLog.9
+++ b/lisp/ChangeLog.9
@@ -20685,7 +20685,7 @@ See ChangeLog.8 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-    Copyright (C) 2000-2011, 2013-2018 Free Software Foundation, Inc.
+    Copyright (C) 2000-2011, 2013-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/Makefile.in b/lisp/Makefile.in
index c447598..9bcd5a8 100644
--- a/lisp/Makefile.in
+++ b/lisp/Makefile.in
@@ -1,6 +1,6 @@
 ### @configure_input@
 
-# Copyright (C) 2000-2018 Free Software Foundation, Inc.
+# Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
@@ -220,7 +220,7 @@ update-subdirs:
           $(srcdir)/../build-aux/update-subdirs $$file; \
        done;
 
-.PHONY: updates repo-update update-authors update-gnus-news
+.PHONY: updates repo-update update-authors
 
 # Some modes of make-dist use this.
 updates: update-subdirs autoloads finder-data custom-deps
@@ -233,17 +233,12 @@ updates: update-subdirs autoloads finder-data custom-deps
 # this directory's autoloads rule.
 repo-update: compile finder-data custom-deps
 
-# Update etc/AUTHORS and etc/GNUS-NEWS.
+# Update etc/AUTHORS
 
 update-authors:
        $(emacs) -L "$(top_srcdir)/admin" -l authors \
          -f batch-update-authors "$(top_srcdir)/etc/AUTHORS" "$(top_srcdir)"
 
-update-gnus-news:
-       $(emacs) -L "$(top_srcdir)/doc/misc" -l gnus-news -f batch-gnus-news \
-         "$(top_srcdir)/doc/misc/gnus-news.texi" \
-         "$(top_srcdir)/etc/GNUS-NEWS"
-
 FORCE:
 .PHONY: FORCE
 
@@ -321,14 +316,16 @@ compile-targets: $(TARGETS)
 # Compile all the Elisp files that need it.  Beware: it approximates
 # 'no-byte-compile', so watch out for false-positives!
 compile-main: gen-lisp compile-clean
-       @(cd $(lisp) && \
+       @(cd $(lisp) &&                              \
        els=`echo "${SUBDIRS_REL} " | sed -e 's|/\./|/|g' -e 's|/\. | |g' -e 
's| |/*.el |g'`; \
-       for el in ${MAIN_FIRST} $$els; do \
-         test -f $$el || continue; \
-         test ! -f $${el}c && GREP_OPTIONS= grep '^;.*no-byte-compile: t' $$el 
> /dev/null && continue; \
-         echo "$${el}c"; \
-       done | xargs $(XARGS_LIMIT) echo) | \
-       while read chunk; do \
+       for el in ${MAIN_FIRST} $$els; do            \
+         test -f $$el || continue;                  \
+         test ! -f $${el}c &&                       \
+             GREP_OPTIONS= grep '^;.*[^a-zA-Z]no-byte-compile: *t' $$el > 
/dev/null && \
+             continue;                              \
+         echo "$${el}c";                            \
+       done | xargs $(XARGS_LIMIT) echo) |          \
+       while read chunk; do                         \
          $(MAKE) compile-targets TARGETS="$$chunk"; \
        done
 
@@ -350,7 +347,9 @@ compile-clean:
 ## with ../src.  See comments above for loaddefs.
 gen-lisp: leim semantic
 
-leim:
+# (re)compile titdic-cnv before recursing into `leim` since its used to
+# generate some of the Quail source files from tables.
+leim: $(lisp)/international/titdic-cnv.elc
        $(MAKE) -C ../leim all EMACS="$(EMACS)"
 
 semantic:
diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index 70123b6..3c88ec6 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -1,6 +1,6 @@
 ;;; abbrev.el --- abbrev mode commands for Emacs -*- lexical-binding: t -*-
 
-;; Copyright (C) 1985-1987, 1992, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1985-1987, 1992, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Maintainer: address@hidden
@@ -940,8 +940,7 @@ If READABLE is nil, an expression is inserted.  The 
expression is
 a call to `define-abbrev-table' that when evaluated will define
 the abbrev table NAME exactly as it is currently defined.
 Abbrevs marked as \"system abbrevs\" are ignored."
-  (let ((table (symbol-value name))
-        (symbols (abbrev--table-symbols name readable)))
+  (let ((symbols (abbrev--table-symbols name readable)))
     (setq symbols (sort symbols 'string-lessp))
     (let ((standard-output (current-buffer)))
       (if readable
diff --git a/lisp/align.el b/lisp/align.el
index 941fa3a..443237b 100644
--- a/lisp/align.el
+++ b/lisp/align.el
@@ -1,6 +1,6 @@
 ;;; align.el --- align text to a specific column, by regexp -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 ;; Maintainer: address@hidden
@@ -399,7 +399,7 @@ The possible settings for `align-region-separate' are:
                   (lambda (end reverse)
                     (funcall (if reverse 're-search-backward
                                're-search-forward)
-                             (concat "[^ \t\n\\\\]"
+                             (concat "[^ \t\n\\]"
                                      (regexp-quote comment-start)
                                      "\\(.+\\)$") end t))))
      (modes    . align-open-comment-modes))
@@ -411,7 +411,7 @@ The possible settings for `align-region-separate' are:
     (c-variable-declaration
      (regexp   . ,(concat "[*&0-9A-Za-z_]>?[&*]*\\(\\s-+[*&]*\\)"
                          "[A-Za-z_][0-9A-Za-z:_]*\\s-*\\(\\()\\|"
-                         "=[^=\n].*\\|(.*)\\|\\(\\[.*\\]\\)*\\)?"
+                         "=[^=\n].*\\|(.*)\\|\\(\\[.*\\]\\)*\\)"
                          "\\s-*[;,]\\|)\\s-*$\\)"))
      (group    . 1)
      (modes    . align-c++-modes)
@@ -438,7 +438,7 @@ The possible settings for `align-region-separate' are:
      (tab-stop . nil))
 
     (perl-assignment
-     (regexp   . ,(concat "[^=!^&*-+<>/| \t\n]\\(\\s-*\\)=[~>]?"
+     (regexp   . ,(concat "[^=!^&*+<>/| \t\n-]\\(\\s-*\\)=[~>]?"
                          "\\(\\s-*\\)\\([^>= \t\n]\\|$\\)"))
      (group    . (1 2))
      (modes    . align-perl-modes)
@@ -452,7 +452,7 @@ The possible settings for `align-region-separate' are:
      (tab-stop . nil))
 
     (make-assignment
-     (regexp   . "^\\s-*\\w+\\(\\s-*\\):?=\\(\\s-*\\)\\([^\t\n \\\\]\\|$\\)")
+     (regexp   . "^\\s-*\\w+\\(\\s-*\\):?=\\(\\s-*\\)\\([^\t\n \\]\\|$\\)")
      (group    . (1 2))
      (modes    . '(makefile-mode))
      (tab-stop . nil))
@@ -759,7 +759,7 @@ The following attributes are meaningful:
          (lambda (end reverse)
            (funcall (if reverse 're-search-backward
                       're-search-forward)
-                    (concat "[^ \t\n\\\\]"
+                    (concat "[^ \t\n\\]"
                             (regexp-quote comment-start)
                             "\\(.+\\)$") end t))))
      (modes  . align-open-comment-modes))
diff --git a/lisp/allout-widgets.el b/lisp/allout-widgets.el
index 5abd978..67fce32 100644
--- a/lisp/allout-widgets.el
+++ b/lisp/allout-widgets.el
@@ -1,6 +1,6 @@
 ;; allout-widgets.el --- Visually highlight allout outline structure.
 
-;; Copyright (C) 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005-2019 Free Software Foundation, Inc.
 
 ;; Author: Ken Manheimer <ken dot manheimer at gmail...>
 ;; Maintainer: Ken Manheimer <ken dot manheimer at gmail...>
diff --git a/lisp/allout.el b/lisp/allout.el
index a123ece..b3b87e5 100644
--- a/lisp/allout.el
+++ b/lisp/allout.el
@@ -1,6 +1,6 @@
 ;;; allout.el --- extensive outline mode for use alone and with other modes
 
-;; Copyright (C) 1992-1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992-1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Ken Manheimer <ken dot manheimer at gmail...>
 ;; Maintainer: Ken Manheimer <ken dot manheimer at gmail...>
@@ -4351,7 +4351,7 @@ subtopics into siblings of the item."
             (let ((children-chart (allout-chart-subtree 1)))
               (if (listp (car children-chart))
                   ;; whoops:
-                  (setq children-chart (allout-flatten children-chart)))
+                  (setq children-chart (flatten-tree children-chart)))
               (save-excursion
                 (dolist (child-point children-chart)
                   (goto-char child-point)
@@ -5788,7 +5788,7 @@ BULLET string, and a list of TEXT strings for the body."
                                        ; "\end{verbatim}" in text,
                                        ; it's special:
        (if (and body-content
-                (setq bop (string-match "\\end{verbatim}" curr-line)))
+                (setq bop (string-match "\\\\end{verbatim}" curr-line)))
            (setq curr-line (concat (substring curr-line 0 bop)
                                    ">"
                                    (substring curr-line bop))))
@@ -6547,14 +6547,7 @@ If BEG is bigger than END we return 0."
   (apply 'concat
          (mapcar (lambda (char) (if (= char ?%) "%%" (char-to-string char)))
                  string)))
-;;;_  : lists
-;;;_   > allout-flatten (list)
-(defun allout-flatten (list)
-  "Return a list of all atoms in list."
-  ;; classic.
-  (cond ((null list) nil)
-        ((atom (car list)) (cons (car list) (allout-flatten (cdr list))))
-        (t (append (allout-flatten (car list)) (allout-flatten (cdr list))))))
+(define-obsolete-function-alias 'allout-flatten #'flatten-tree "27.1")
 ;;;_  : Compatibility:
 ;;;_   : xemacs undo-in-progress provision:
 (unless (boundp 'undo-in-progress)
diff --git a/lisp/ansi-color.el b/lisp/ansi-color.el
index 6fb7acf..d3b8d06 100644
--- a/lisp/ansi-color.el
+++ b/lisp/ansi-color.el
@@ -1,6 +1,6 @@
 ;;; ansi-color.el --- translate ANSI escape sequences into faces -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Alex Schroeder <address@hidden>
 ;; Maintainer: Alex Schroeder <address@hidden>
diff --git a/lisp/apropos.el b/lisp/apropos.el
index a13a0c2..1b86f5b 100644
--- a/lisp/apropos.el
+++ b/lisp/apropos.el
@@ -1,6 +1,6 @@
 ;;; apropos.el --- apropos commands for users and programmers
 
-;; Copyright (C) 1989, 1994-1995, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1989, 1994-1995, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Joe Wells <address@hidden>
@@ -681,7 +681,7 @@ the output includes key-bindings of commands."
             (re (concat "\\(?:\\`\\|[\\/]\\)" (regexp-quote file)
                         "\\(\\.\\|\\'\\)")))
         (while (and lh (null lh-entry))
-          (if (and (caar lh) (string-match re (caar lh)))
+          (if (and (stringp (caar lh)) (string-match re (caar lh)))
               (setq lh-entry (car lh))
             (setq lh (cdr lh)))))
       (unless lh-entry (error "Unknown library `%s'" file)))
diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index 068702b..1c88f9a 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -1,6 +1,6 @@
 ;;; arc-mode.el --- simple editing of archives
 
-;; Copyright (C) 1995, 1997-1998, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1995, 1997-1998, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Morten Welinder <address@hidden>
@@ -637,7 +637,7 @@ the mode is invalid.  If ERROR is nil then nil will be 
returned."
 
 (defun archive-unixdate (low high)
   "Stringify Unix (LOW HIGH) date."
-  (let* ((time (cons high low))
+  (let* ((time (list high low))
         (str (current-time-string time)))
     (format "%s-%s-%s"
            (substring str 8 10)
@@ -646,8 +646,7 @@ the mode is invalid.  If ERROR is nil then nil will be 
returned."
 
 (defun archive-unixtime (low high)
   "Stringify Unix (LOW HIGH) time."
-  (let ((str (current-time-string (cons high low))))
-    (substring str 11 19)))
+  (format-time-string "%H:%M:%S" (list high low)))
 
 (defun archive-get-lineno ()
   (if (>= (point) archive-file-list-start)
@@ -969,8 +968,8 @@ using `make-temp-file', and the generated name is returned."
                   (jka-compr-inhibit t))
               (write-region (point-min) (point-max) tmpfile nil 'quiet))
             (erase-buffer)
-            (let ((coding-system-for-read 'no-conversion))
-              (insert-file-contents tmpfile)))
+            (set-buffer-multibyte t)
+            (insert-file-contents tmpfile))
         (delete-file tmpfile)))))
 
 (defun archive-file-name-handler (op &rest args)
@@ -1535,7 +1534,7 @@ This doesn't recover lost files, it just undoes changes 
in the buffer itself."
     (apply #'vector (nreverse files))))
 
 (defun archive-arc-rename-entry (newname descr)
-  (if (string-match "[:\\\\/]" newname)
+  (if (string-match "[:\\/]" newname)
       (error "File names in arc files must not contain a directory component"))
   (if (> (length newname) 12)
       (error "File names in arc files are limited to 12 characters"))
@@ -2017,10 +2016,10 @@ This doesn't recover lost files, it just undoes changes 
in the buffer itself."
       (call-process "lsar" nil t nil "-l" (or file copy))
       (if copy (delete-file copy))
       (goto-char (point-min))
-      (re-search-forward "^\\(\s+=+\s?+\\)+\n")
+      (re-search-forward "^\\(\s+=+\s*\\)+\n")
       (while (looking-at (concat "^\s+[0-9.]+\s+D?-+\s+"   ; Flags
                                  "\\([0-9-]+\\)\s+"        ; Size
-                                 "\\([-0-9.%]+\\|-+\\)\s+" ; Ratio
+                                 "\\([-0-9.%]+\\)\s+"      ; Ratio
                                  "\\([0-9a-zA-Z]+\\)\s+"   ; Mode
                                  "\\([0-9-]+\\)\s+"        ; Date
                                  "\\([0-9:]+\\)\s+"        ; Time
diff --git a/lisp/array.el b/lisp/array.el
index 242511b..2fffe01 100644
--- a/lisp/array.el
+++ b/lisp/array.el
@@ -1,6 +1,6 @@
 ;;; array.el --- array editing commands for GNU Emacs
 
-;; Copyright (C) 1987, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1987, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: David M. Brown
 ;; Maintainer: address@hidden
diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el
index cebe8c2..4283ed0 100644
--- a/lisp/auth-source-pass.el
+++ b/lisp/auth-source-pass.el
@@ -1,6 +1,6 @@
 ;;; auth-source-pass.el --- Integrate auth-source with password-store -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2015, 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015, 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Damien Cassou <address@hidden>,
 ;;         Nicolas Petton <address@hidden>
@@ -134,12 +134,12 @@ ENTRY is the name of a password-store entry."
 (defun auth-source-pass--parse-secret (contents)
   "Parse the password-store data in the string CONTENTS and return its secret.
 The secret is the first line of CONTENTS."
-  (car (split-string contents "\\\n" t)))
+  (car (split-string contents "\n" t)))
 
 (defun auth-source-pass--parse-data (contents)
   "Parse the password-store data in the string CONTENTS and return an alist.
 CONTENTS is the contents of a password-store formatted file."
-  (let ((lines (split-string contents "\\\n" t "\\\s")))
+  (let ((lines (split-string contents "\n" t "[ \t]+")))
     (seq-remove #'null
                 (mapcar (lambda (line)
                           (let ((pair (mapcar (lambda (s) (string-trim s))
@@ -189,7 +189,7 @@ often."
   (let ((store-dir (expand-file-name "~/.password-store/")))
     (mapcar
      (lambda (file) (file-name-sans-extension (file-relative-name file 
store-dir)))
-     (directory-files-recursively store-dir "\.gpg$"))))
+     (directory-files-recursively store-dir "\\.gpg$"))))
 
 (defun auth-source-pass--find-all-by-entry-name (entryname user)
   "Search the store for all entries either matching ENTRYNAME/USER or 
ENTRYNAME.
diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index fda6cfc..74c4491 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -1,6 +1,6 @@
 ;;; auth-source.el --- authentication sources for Gnus and Emacs -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Ted Zlatanov <address@hidden>
 ;; Keywords: news
diff --git a/lisp/autoarg.el b/lisp/autoarg.el
index 4bf5785..97e9d6b 100644
--- a/lisp/autoarg.el
+++ b/lisp/autoarg.el
@@ -1,6 +1,6 @@
 ;;; autoarg.el --- make digit keys supply prefix args
 
-;; Copyright (C) 1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author:  Dave Love <address@hidden>
 ;; Created: 1998-09-04
diff --git a/lisp/autoinsert.el b/lisp/autoinsert.el
index cb0d151..f7ecfe2 100644
--- a/lisp/autoinsert.el
+++ b/lisp/autoinsert.el
@@ -1,6 +1,6 @@
 ;;; autoinsert.el --- automatic mode-dependent insertion of text into new files
 
-;; Copyright (C) 1985-1987, 1994-1995, 1998, 2000-2018 Free Software
+;; Copyright (C) 1985-1987, 1994-1995, 1998, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Charlie Martin <address@hidden>
diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index d4cb823..1d20896 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -1,6 +1,6 @@
 ;;; autorevert.el --- revert buffers when files on disk change  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1997-1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1999, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Anders Lindgren
 ;; Keywords: convenience
@@ -326,12 +326,12 @@ the list of old buffers.")
 (add-hook 'find-file-hook
          #'auto-revert-find-file-function)
 
-(defvar auto-revert-notify-watch-descriptor-hash-list
+(defvar auto-revert--buffers-by-watch-descriptor
   (make-hash-table :test 'equal)
-  "A hash table collecting all file watch descriptors.
-Hash key is a watch descriptor, hash value is a list of buffers
-which are related to files being watched and carrying the same
-default directory.")
+  "A hash table mapping notification descriptors to lists of buffers.
+The buffers use that descriptor for auto-revert notifications.
+The key is equal to `auto-revert-notify-watch-descriptor' in each
+buffer.")
 
 (defvar-local auto-revert-notify-watch-descriptor nil
   "The file watch descriptor active for the current buffer.")
@@ -343,10 +343,11 @@ This has been reported by a file notification event.")
 
 ;; Functions:
 
-(defun auto-revert-remove-current-buffer ()
-  "Remove dead buffer from `auto-revert-buffer-list'."
+(defun auto-revert-remove-current-buffer (&optional buffer)
+  "Remove BUFFER from `auto-revert-buffer-list'.
+BUFFER defaults to `current-buffer'."
   (setq auto-revert-buffer-list
-        (delq (current-buffer) auto-revert-buffer-list)))
+        (delq (or buffer (current-buffer)) auto-revert-buffer-list)))
 
 ;;;###autoload
 (define-minor-mode auto-revert-mode
@@ -464,7 +465,7 @@ If `global-auto-revert-non-file-buffers' is non-nil, this 
mode
 may also revert some non-file buffers, as described in the
 documentation of that variable.  It ignores buffers with modes
 matching `global-auto-revert-ignore-modes', and buffers with a
-non-nil vale of `global-auto-revert-ignore-buffer'.
+non-nil value of `global-auto-revert-ignore-buffer'.
 
 When a buffer is reverted, a message is generated.  This can be
 suppressed by setting `auto-revert-verbose' to nil.
@@ -498,18 +499,16 @@ will use an up-to-date value of `auto-revert-interval'"
 
 (defun auto-revert-notify-rm-watch ()
   "Disable file notification for current buffer's associated file."
-  (when auto-revert-notify-watch-descriptor
-    (maphash
-     (lambda (key value)
-       (when (equal key auto-revert-notify-watch-descriptor)
-        (setq value (delete (current-buffer) value))
-        (if value
-            (puthash key value auto-revert-notify-watch-descriptor-hash-list)
-          (remhash key auto-revert-notify-watch-descriptor-hash-list)
-          (ignore-errors
-            (file-notify-rm-watch auto-revert-notify-watch-descriptor)))))
-     auto-revert-notify-watch-descriptor-hash-list)
-    (remove-hook 'kill-buffer-hook #'auto-revert-notify-rm-watch))
+  (let ((desc auto-revert-notify-watch-descriptor)
+        (table auto-revert--buffers-by-watch-descriptor))
+    (when desc
+      (let ((buffers (delq (current-buffer) (gethash desc table))))
+        (if buffers
+            (puthash desc buffers table)
+          (remhash desc table)))
+      (ignore-errors
+       (file-notify-rm-watch desc))
+      (remove-hook 'kill-buffer-hook #'auto-revert-notify-rm-watch t)))
   (setq auto-revert-notify-watch-descriptor nil
        auto-revert-notify-modified-p nil))
 
@@ -535,7 +534,7 @@ will use an up-to-date value of `auto-revert-interval'"
                         (gethash key file-notify-descriptors))
                        'auto-revert-notify-handler))
          (setq auto-revert-notify-watch-descriptor key)))
-       auto-revert-notify-watch-descriptor-hash-list)
+       auto-revert--buffers-by-watch-descriptor)
       ;; Create a new watch if needed.
       (unless auto-revert-notify-watch-descriptor
         (setq auto-revert-notify-watch-descriptor
@@ -550,8 +549,8 @@ will use an up-to-date value of `auto-revert-interval'"
          auto-revert-notify-watch-descriptor
          (cons (current-buffer)
               (gethash auto-revert-notify-watch-descriptor
-                       auto-revert-notify-watch-descriptor-hash-list))
-         auto-revert-notify-watch-descriptor-hash-list)
+                       auto-revert--buffers-by-watch-descriptor))
+         auto-revert--buffers-by-watch-descriptor)
         (add-hook 'kill-buffer-hook #'auto-revert-notify-rm-watch nil t)))))
 
 ;; If we have file notifications, we want to update the auto-revert buffers
@@ -586,7 +585,7 @@ no more reverts are possible until the next call of
           (file (nth 2 event))
           (file1 (nth 3 event)) ;; Target of `renamed'.
           (buffers (gethash descriptor
-                            auto-revert-notify-watch-descriptor-hash-list)))
+                            auto-revert--buffers-by-watch-descriptor)))
       ;; Check, that event is meant for us.
       (cl-assert descriptor)
       ;; Since we watch a directory, a file name must be returned.
@@ -595,19 +594,16 @@ no more reverts are possible until the next call of
 
       (if (eq action 'stopped)
           ;; File notification has stopped.  Continue with polling.
-          (cl-dolist (buffer
-                      (if global-auto-revert-mode
-                          (buffer-list) auto-revert-buffer-list))
+          (cl-dolist (buffer buffers)
             (with-current-buffer buffer
-              (when (and (equal descriptor auto-revert-notify-watch-descriptor)
-                         (or
-                          ;; A buffer associated with a file.
-                          (and (stringp buffer-file-name)
-                               (string-equal
-                                (file-name-nondirectory file)
-                                (file-name-nondirectory buffer-file-name)))
-                          ;; A buffer w/o a file, like dired.
-                          (null buffer-file-name)))
+              (when (or
+                     ;; A buffer associated with a file.
+                     (and (stringp buffer-file-name)
+                          (string-equal
+                           (file-name-nondirectory file)
+                           (file-name-nondirectory buffer-file-name)))
+                     ;; A buffer w/o a file, like dired.
+                     (null buffer-file-name))
                 (auto-revert-notify-rm-watch))))
 
         ;; Loop over all buffers, in order to find the intended one.
@@ -767,6 +763,18 @@ the timer when no buffers need to be checked."
                    (buffer-list)
                  auto-revert-buffer-list))
          remaining new)
+      ;; Buffers with remote contents shall be reverted only if the
+      ;; connection is established already.
+      (setq bufs (delq nil
+                       (mapcar
+                        (lambda (buf)
+                          (and (buffer-live-p buf)
+                               (with-current-buffer buf
+                                 (and
+                                  (or (not (file-remote-p default-directory))
+                                      (file-remote-p default-directory nil t))
+                                      buf))))
+                        bufs)))
       ;; Partition `bufs' into two halves depending on whether or not
       ;; the buffers are in `auto-revert-remaining-buffers'.  The two
       ;; halves are then re-joined with the "remaining" buffers at the
@@ -782,31 +790,30 @@ the timer when no buffers need to be checked."
                  (not (and auto-revert-stop-on-user-input
                            (input-pending-p))))
        (let ((buf (car bufs)))
-          (with-current-buffer buf
-            (if (buffer-live-p buf)
-                (progn
-                  ;; Test if someone has turned off Auto-Revert Mode
-                  ;; in a non-standard way, for example by changing
-                  ;; major mode.
-                  (if (and (not auto-revert-mode)
-                           (not auto-revert-tail-mode)
-                           (memq buf auto-revert-buffer-list))
-                      (auto-revert-remove-current-buffer))
-                  (when (auto-revert-active-p)
-                    ;; Enable file notification.
-                    (when (and auto-revert-use-notify
-                               (not auto-revert-notify-watch-descriptor))
-                      (auto-revert-notify-add-watch))
-                    (auto-revert-handler)))
+          (if (not (buffer-live-p buf))
               ;; Remove dead buffer from `auto-revert-buffer-list'.
-              (auto-revert-remove-current-buffer))))
+              (auto-revert-remove-current-buffer buf)
+            (with-current-buffer buf
+              ;; Test if someone has turned off Auto-Revert Mode
+              ;; in a non-standard way, for example by changing
+              ;; major mode.
+              (if (and (not auto-revert-mode)
+                       (not auto-revert-tail-mode)
+                       (memq buf auto-revert-buffer-list))
+                  (auto-revert-remove-current-buffer))
+              (when (auto-revert-active-p)
+                ;; Enable file notification.
+                (when (and auto-revert-use-notify
+                           (not auto-revert-notify-watch-descriptor))
+                  (auto-revert-notify-add-watch))
+                (auto-revert-handler)))))
        (setq bufs (cdr bufs)))
       (setq auto-revert-remaining-buffers bufs)
       ;; Check if we should cancel the timer.
       (when (and (not global-auto-revert-mode)
                 (null auto-revert-buffer-list))
         (if (timerp auto-revert-timer)
-           (cancel-timer auto-revert-timer))
+            (cancel-timer auto-revert-timer))
        (setq auto-revert-timer nil)))))
 
 
diff --git a/lisp/avoid.el b/lisp/avoid.el
index f5519e9..7d69fa2 100644
--- a/lisp/avoid.el
+++ b/lisp/avoid.el
@@ -1,6 +1,6 @@
 ;;; avoid.el --- make mouse pointer stay out of the way of editing
 
-;; Copyright (C) 1993-1994, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1994, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Boris Goldowsky <address@hidden>
 ;; Keywords: mouse
diff --git a/lisp/battery.el b/lisp/battery.el
index 192a6ae..49b01d5 100644
--- a/lisp/battery.el
+++ b/lisp/battery.el
@@ -1,6 +1,6 @@
 ;;; battery.el --- display battery status information
 
-;; Copyright (C) 1997-1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Ralph Schleicher <address@hidden>
 ;; Keywords: hardware
@@ -375,12 +375,12 @@ The following %-sequences are provided:
                            last-full-capacity design-capacity))
     (and capacity rate
         (setq minutes (if (zerop rate) 0
-                        (floor (* (/ (float (if (string= charging-state
-                                                         "charging")
-                                                (- full-capacity capacity)
-                                              capacity))
-                                     rate)
-                                  60)))
+                        (floor (* (if (string= charging-state
+                                               "charging")
+                                      (- full-capacity capacity)
+                                    capacity)
+                                  60)
+                               rate))
               hours (/ minutes 60)))
     (list (cons ?c (or (and capacity (number-to-string capacity)) "N/A"))
          (cons ?L (or (battery-search-for-one-match-in-files
@@ -414,8 +414,7 @@ The following %-sequences are provided:
          (cons ?p (or (and full-capacity capacity
                            (> full-capacity 0)
                            (number-to-string
-                            (floor (/ capacity
-                                      (/ (float full-capacity) 100)))))
+                            (floor (* 100 capacity) full-capacity)))
                       "N/A")))))
 
 
@@ -471,9 +470,9 @@ The following %-sequences are provided:
                  "POWER_SUPPLY_\\(CURRENT\\|POWER\\)_NOW=\\([0-9]*\\)$"
                  nil t)
            (cl-incf power-now
-                    (* (float (string-to-number (match-string 2)))
+                    (* (string-to-number (match-string 2))
                        (if (eq (char-after (match-beginning 1)) ?C)
-                           voltage-now 1.0))))
+                           voltage-now 1))))
          (goto-char (point-min))
          (when (re-search-forward "POWER_SUPPLY_TEMP=\\([0-9]*\\)$" nil t)
            (setq temperature (match-string 1)))
@@ -585,9 +584,7 @@ The following %-sequences are provided:
     (when seconds
       (setq minutes (/ seconds 60)
             hours (/ minutes 60)
-            remaining-time
-            (format "%d:%02d" (truncate hours)
-                    (- (truncate minutes) (* 60 (truncate hours))))))
+           remaining-time (format "%d:%02d" hours (mod minutes 60))))
     (list (cons ?c (or (and energy
                             (number-to-string (round (* 1000 energy))))
                        "N/A"))
@@ -620,46 +617,71 @@ The following %-sequences are provided:
 %h Remaining battery charge time in hours
 %t Remaining battery charge time in the form `h:min'"
   (let* ((os-name (car (split-string
-                       (shell-command-to-string "/usr/bin/uname"))))
-        (apm-flag (if (equal os-name "OpenBSD") "P" "s"))
-        (apm-cmd (concat "/usr/sbin/apm -ablm" apm-flag))
-        (apm-output (split-string (shell-command-to-string apm-cmd)))
-        ;; Battery status
-        (battery-status
-         (let ((stat (string-to-number (nth 0 apm-output))))
-           (cond ((eq stat 0) '("high" . ""))
-                 ((eq stat 1) '("low" . "-"))
-                 ((eq stat 2) '("critical" . "!"))
-                 ((eq stat 3) '("charging" . "+"))
-                 ((eq stat 4) '("absent" . nil)))))
-        ;; Battery percentage
-        (battery-percentage (nth 1 apm-output))
-        ;; Battery life
-        (battery-life (nth 2 apm-output))
-        ;; AC status
-        (line-status
-         (let ((ac (string-to-number (nth 3 apm-output))))
-           (cond ((eq ac 0) "disconnected")
-                 ((eq ac 1) "connected")
-                 ((eq ac 2) "backup power"))))
-        ;; Advanced power savings mode
-        (apm-mode
-         (let ((apm (string-to-number (nth 4 apm-output))))
-           (if (string= os-name "OpenBSD")
-               (cond ((eq apm 0) "manual")
-                     ((eq apm 1) "automatic")
-                     ((eq apm 2) "cool running"))
-             (if (eq apm 1) "on" "off"))))
+                        ;; FIXME: Can't we use something like `system-type'?
+                        (shell-command-to-string "/usr/bin/uname"))))
+         (apm-flag (pcase os-name
+                     ("OpenBSD" "mP")
+                     ("FreeBSD" "st")
+                     (_         "ms")))
+         (apm-cmd (concat "/usr/sbin/apm -abl" apm-flag))
+         (apm-output (split-string (shell-command-to-string apm-cmd)))
+         (indices (pcase os-name
+                    ;; FreeBSD's manpage documents that multiple
+                    ;; outputs are ordered by "the order in which
+                    ;; they're listed in the manpage", which is alphabetical
+                    ;; and is also the order in which we pass them.
+                    ("FreeBSD" '((ac . 0)
+                                 (battery-status . 1)
+                                 (battery-percent . 2)
+                                 (apm-mode . 3)
+                                 (battery-life . 4)))
+                    ;; For NetBSD and OpenBSD, the manpage doesn't document
+                    ;; the order.  The previous code used this order, so let's
+                    ;; assume it's right.
+                    (_         '((ac . 3)
+                                 (battery-status . 0)
+                                 (battery-percent . 1)
+                                 (apm-mode . 4)
+                                 (battery-life . 2)))))
+         ;; Battery status
+         (battery-status
+          (pcase (string-to-number
+                  (nth (alist-get 'battery-status indices) apm-output))
+            (0 '("high" . ""))
+            (1 '("low" . "-"))
+            (2 '("critical" . "!"))
+            (3 '("charging" . "+"))
+            (4 '("absent" . nil))))
+         ;; Battery percentage
+         (battery-percentage
+          (nth (alist-get 'battery-percent indices) apm-output))
+         ;; Battery life
+         (battery-life (nth (alist-get 'battery-life indices) apm-output))
+         ;; AC status
+         (line-status
+          (pcase (string-to-number (nth (alist-get 'ac indices) apm-output))
+            (0 "disconnected")
+            (1 "connected")
+            (2 "backup power")))
+         ;; Advanced power savings mode
+         (apm-mode
+          (let ((apm (string-to-number
+                      (nth (alist-get 'apm-mode indices) apm-output))))
+            (if (string= os-name "OpenBSD")
+                (pcase apm
+                  (0 "manual")
+                  (1 "automatic")
+                 (2 "cool running"))
+             (if (eql apm 1) "on" "off"))))
         seconds minutes hours remaining-time)
     (unless (member battery-life '("unknown" "-1"))
       (if (member os-name '("OpenBSD" "NetBSD"))
          (setq minutes (string-to-number battery-life)
                seconds (* 60 minutes))
        (setq seconds (string-to-number battery-life)
-             minutes (truncate (/ seconds 60))))
-      (setq hours (truncate (/ minutes 60))
-           remaining-time (format "%d:%02d" hours
-                                  (- minutes (* 60 hours)))))
+             minutes (truncate seconds 60)))
+      (setq hours (truncate minutes 60)
+           remaining-time (format "%d:%02d" hours (mod minutes 60))))
     (list (cons ?L (or line-status "N/A"))
          (cons ?B (or (car battery-status) "N/A"))
          (cons ?b (or (cdr battery-status) "N/A"))
diff --git a/lisp/bindings.el b/lisp/bindings.el
index 10c4ae50..744bcc3 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -1,6 +1,6 @@
 ;;; bindings.el --- define standard key bindings and some variables
 
-;; Copyright (C) 1985-1987, 1992-1996, 1999-2018 Free Software
+;; Copyright (C) 1985-1987, 1992-1996, 1999-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/bookmark.el b/lisp/bookmark.el
index 1f06d67..3041401 100644
--- a/lisp/bookmark.el
+++ b/lisp/bookmark.el
@@ -1,6 +1,6 @@
 ;;; bookmark.el --- set bookmarks, maybe annotate them, jump to them later
 
-;; Copyright (C) 1993-1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Karl Fogel <address@hidden>
 ;; Maintainer: Karl Fogel <address@hidden>
diff --git a/lisp/bs.el b/lisp/bs.el
index 1021e82..86a19fd 100644
--- a/lisp/bs.el
+++ b/lisp/bs.el
@@ -1,6 +1,6 @@
 ;;; bs.el --- menu for selecting and displaying buffers -*- lexical-binding: t 
-*-
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 ;; Author: Olaf Sylvester <address@hidden>
 ;; Maintainer: address@hidden
 ;; Keywords: convenience
diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el
index bc1288a..5f88986 100644
--- a/lisp/buff-menu.el
+++ b/lisp/buff-menu.el
@@ -1,6 +1,6 @@
 ;;; buff-menu.el --- Interface for viewing and manipulating buffers -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1985-1987, 1993-1995, 2000-2018 Free Software
+;; Copyright (C) 1985-1987, 1993-1995, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
@@ -475,10 +475,10 @@ Buffers marked with 
\\<Buffer-menu-mode-map>`\\[Buffer-menu-delete]' are deleted
                           (save-buffer))
                         (tabulated-list-set-col 2 " " t))
                     (error (warn "Error saving %s" buffer))))
-                (if delete
-                    (unless (eq buffer (current-buffer))
-                      (kill-buffer buffer)
-                      (tabulated-list-delete-entry))
+                (if (and delete
+                         (not (eq buffer (current-buffer)))
+                          (kill-buffer buffer))
+                     (tabulated-list-delete-entry)
                   (forward-line 1)))))))))
 
 (defun Buffer-menu-select ()
diff --git a/lisp/button.el b/lisp/button.el
index 0edd215..921e84d 100644
--- a/lisp/button.el
+++ b/lisp/button.el
@@ -1,6 +1,6 @@
 ;;; button.el --- clickable buttons
 ;;
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Miles Bader <address@hidden>
 ;; Keywords: extensions
@@ -382,10 +382,12 @@ Also see `make-text-button'."
 If the button at POS is a text property button, the return value
 is a marker pointing to POS."
   (let ((button (get-char-property pos 'button)))
-    (if (or (overlayp button) (null button))
-       button
-      ;; Must be a text-property button; return a marker pointing to it.
-      (copy-marker pos t))))
+    (and button (get-char-property pos 'category)
+         (if (overlayp button)
+             button
+           ;; Must be a text-property button;
+           ;; return a marker pointing to it.
+           (copy-marker pos t)))))
 
 (defun next-button (pos &optional count-current)
   "Return the next button after position POS in the current buffer.
diff --git a/lisp/calc/calc-aent.el b/lisp/calc/calc-aent.el
index 93aacac..f16e665 100644
--- a/lisp/calc/calc-aent.el
+++ b/lisp/calc/calc-aent.el
@@ -1,6 +1,6 @@
 ;;; calc-aent.el --- algebraic entry functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-alg.el b/lisp/calc/calc-alg.el
index 2f23399..41ffc83 100644
--- a/lisp/calc/calc-alg.el
+++ b/lisp/calc/calc-alg.el
@@ -1,6 +1,6 @@
 ;;; calc-alg.el --- algebraic functions for Calc  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-arith.el b/lisp/calc/calc-arith.el
index 345d0cd..284dfa8 100644
--- a/lisp/calc/calc-arith.el
+++ b/lisp/calc/calc-arith.el
@@ -1,6 +1,6 @@
 ;;; calc-arith.el --- arithmetic functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-bin.el b/lisp/calc/calc-bin.el
index a61cecf..d979edb 100644
--- a/lisp/calc/calc-bin.el
+++ b/lisp/calc/calc-bin.el
@@ -1,6 +1,6 @@
 ;;; calc-bin.el --- binary functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-comb.el b/lisp/calc/calc-comb.el
index f1d3dae..0277903 100644
--- a/lisp/calc/calc-comb.el
+++ b/lisp/calc/calc-comb.el
@@ -1,6 +1,6 @@
 ;;; calc-comb.el --- combinatoric functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-cplx.el b/lisp/calc/calc-cplx.el
index 35cd31d..79893c6 100644
--- a/lisp/calc/calc-cplx.el
+++ b/lisp/calc/calc-cplx.el
@@ -1,6 +1,6 @@
 ;;; calc-cplx.el --- Complex number functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-embed.el b/lisp/calc/calc-embed.el
index 6573c07..c41b232 100644
--- a/lisp/calc/calc-embed.el
+++ b/lisp/calc/calc-embed.el
@@ -1,6 +1,6 @@
 ;;; calc-embed.el --- embed Calc in a buffer
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-ext.el b/lisp/calc/calc-ext.el
index 761eb97..1456fb2 100644
--- a/lisp/calc/calc-ext.el
+++ b/lisp/calc/calc-ext.el
@@ -1,6 +1,6 @@
 ;;; calc-ext.el --- various extension functions for Calc  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-fin.el b/lisp/calc/calc-fin.el
index 0bdf3f0..813da28 100644
--- a/lisp/calc/calc-fin.el
+++ b/lisp/calc/calc-fin.el
@@ -1,6 +1,6 @@
 ;;; calc-fin.el --- financial functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-forms.el b/lisp/calc/calc-forms.el
index f758628..fce82d2 100644
--- a/lisp/calc/calc-forms.el
+++ b/lisp/calc/calc-forms.el
@@ -1,6 +1,6 @@
 ;;; calc-forms.el --- data format conversion functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
@@ -37,13 +37,11 @@
 (defun calc-time ()
   (interactive)
   (calc-wrapper
-   (let ((time (current-time-string)))
+   (let ((time (decode-time)))
      (calc-enter-result 0 "time"
                        (list 'mod
                              (list 'hms
-                                   (string-to-number (substring time 11 13))
-                                   (string-to-number (substring time 14 16))
-                                   (string-to-number (substring time 17 19)))
+                                   (nth 2 time) (nth 1 time) (nth 0 time))
                              (list 'hms 24 0 0))))))
 
 (defun calc-to-hms (arg)
@@ -62,7 +60,7 @@
 
 
 (defun calc-hms-notation (fmt)
-  (interactive "sHours-minutes-seconds format (hms, @ \\=' \", etc.): ")
+  (interactive "sHours-minutes-seconds format (hms, @ ' \", etc.): ")
   (calc-wrapper
    (if (string-match "\\`\\([^,; ]+\\)\\([,; ]*\\)\\([^,; ]\\)\\([,; 
]*\\)\\([^,; ]\\)\\'" fmt)
        (progn
@@ -1341,16 +1339,15 @@ as measured in the integer number of days before 
December 31, 1 BC (Gregorian)."
           (math-parse-iso-date-validate isoyear isoweek isoweekday hour minute 
second)))))
 
 (defun calcFunc-now (&optional zone)
-  (let ((date (let ((calc-date-format nil))
-               (math-parse-date (current-time-string)))))
-    (if (consp date)
-       (if zone
-           (math-add date (math-div (math-sub (calcFunc-tzone nil date)
-                                              (calcFunc-tzone zone date))
-                                    '(float 864 2)))
-         date)
-      (calc-record-why "*Unable to interpret current date from system")
-      (append (list 'calcFunc-now) (and zone (list zone))))))
+  (let ((date (let ((now (decode-time)))
+               (list 'date (math-dt-to-date
+                            (list (nth 5 now) (nth 4 now) (nth 3 now)
+                                  (nth 2 now) (nth 1 now) (nth 0 now)))))))
+    (if zone
+       (math-add date (math-div (math-sub (calcFunc-tzone nil date)
+                                          (calcFunc-tzone zone date))
+                                '(float 864 2)))
+      date)))
 
 (defun calcFunc-year (date)
   (car (math-date-to-dt date)))
diff --git a/lisp/calc/calc-frac.el b/lisp/calc/calc-frac.el
index 240d423..b420581 100644
--- a/lisp/calc/calc-frac.el
+++ b/lisp/calc/calc-frac.el
@@ -1,6 +1,6 @@
 ;;; calc-frac.el --- fraction functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-funcs.el b/lisp/calc/calc-funcs.el
index 8d110b6..a9d1539 100644
--- a/lisp/calc/calc-funcs.el
+++ b/lisp/calc/calc-funcs.el
@@ -1,6 +1,6 @@
 ;;; calc-funcs.el --- well-known functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-graph.el b/lisp/calc/calc-graph.el
index 7d1fc4b..56f11c6 100644
--- a/lisp/calc/calc-graph.el
+++ b/lisp/calc/calc-graph.el
@@ -1,6 +1,6 @@
 ;;; calc-graph.el --- graph output functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
@@ -65,6 +65,9 @@
 (defvar calc-graph-no-wait nil)
 (defvar calc-gnuplot-trail-mark)
 
+(defsubst calc-graph-w32-p ()
+  (eq system-type 'windows-nt))
+
 (defun calc-graph-fast (many)
   (interactive "P")
   (let ((calc-graph-no-auto-view t))
@@ -376,8 +379,13 @@
                    ;; Check MS-Windows before X, in case they have
                    ;; $DISPLAY set for some reason (e.g., Cygwin or
                    ;; whatever)
-                   ((string= calc-gnuplot-name "pgnuplot")
-                    "windows")
+                    ((string= calc-gnuplot-name "pgnuplot")
+                     "windows")
+                    ;; Versions of gnuplot that come without pgnuplot
+                    ;; only work on MS-Windows with "qt" as the
+                    ;; terminal, for some reason.
+                   ((calc-graph-w32-p)
+                    "qt")
                    ((or (eq window-system 'x) (getenv "DISPLAY"))
                     "x11")
                    ((>= calc-gnuplot-version 3)
@@ -1113,7 +1121,7 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
                  (eval (intern
                         (concat "var-"
                                 (save-excursion
-                                  (re-search-backward ":\\(.*\\)\\}")
+                                 (re-search-backward ":\\(.*\\)}")
                                   (match-string 1))))))
               (error nil)))
       (if yerr
@@ -1178,7 +1186,7 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
         (or (looking-at "{")
             (error "Can't hide this curve (wrong format)"))
         (forward-char 1)
-        (if (looking-at "*")
+        (if (looking-at "\\*")
             (if (or (null flag) (<= (prefix-numeric-value flag) 0))
                 (delete-char 1))
           (if (or (null flag) (> (prefix-numeric-value flag) 0))
@@ -1321,14 +1329,13 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
    (calc-graph-init)
    (calc-graph-view-trail)
    (calc-gnuplot-command cmd)
-   (or (string= calc-gnuplot-name "pgnuplot")
+   (or (calc-graph-w32-p)
        (progn
         (accept-process-output)
         (calc-graph-view-trail)))))
 
 (defun calc-graph-kill (&optional no-view)
   (interactive)
-  (calc-graph-delete-temps)
   (if (calc-gnuplot-alive)
       (calc-wrapper
        (or no-view (calc-graph-view-trail))
@@ -1337,7 +1344,8 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
        (sit-for 1)
        (if (process-status calc-gnuplot-process)
           (delete-process calc-gnuplot-process))
-       (setq calc-gnuplot-process nil))))
+       (setq calc-gnuplot-process nil)))
+  (calc-graph-delete-temps))
 
 (defun calc-graph-quit ()
   (interactive)
@@ -1404,7 +1412,7 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
 (defun calc-gnuplot-command (&rest args)
   (calc-graph-init)
   (let ((cmd (concat (mapconcat 'identity args " ") "\n")))
-    (or (string= calc-gnuplot-name "pgnuplot")
+    (or (calc-graph-w32-p)
        (accept-process-output))
     (with-current-buffer calc-gnuplot-buffer
       (calc-gnuplot-check-for-errors)
@@ -1416,7 +1424,7 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
       (process-send-string calc-gnuplot-process cmd)
       (if (get-buffer-window calc-gnuplot-buffer)
          (calc-graph-view-trail))
-      (or (string= calc-gnuplot-name "pgnuplot")
+      (or (calc-graph-w32-p)
          (accept-process-output (and (not calc-graph-no-wait)
                                      calc-gnuplot-process)))
       (calc-gnuplot-check-for-errors)
@@ -1445,8 +1453,9 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
          (setq origin (point)))
        (setq calc-graph-last-device nil)
        (setq calc-graph-last-output nil)
-       (if (string= calc-gnuplot-name "pgnuplot")
-           (let ((version-str (shell-command-to-string "pgnuplot -V")))
+       (if (calc-graph-w32-p)
+           (let ((version-str
+                   (shell-command-to-string (concat calc-gnuplot-name " -V"))))
              (if (string-match "gnuplot \\([0-9]+\\)\\." version-str)
                  (setq calc-gnuplot-version (string-to-number
                                              (substring version-str
@@ -1457,11 +1466,11 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
            (let ((args (append (and calc-gnuplot-display
                                     (not (equal calc-gnuplot-display
                                                 (getenv "DISPLAY")))
-                                    (not (string= calc-gnuplot-name 
"pgnuplot"))
+                                     (not (calc-graph-w32-p))
                                     (list "-display"
                                           calc-gnuplot-display))
                                (and calc-gnuplot-geometry
-                                    (not (string= calc-gnuplot-name 
"pgnuplot"))
+                                    (not (calc-graph-w32-p))
                                     (list "-geometry"
                                           calc-gnuplot-geometry)))))
              (setq calc-gnuplot-process
@@ -1475,7 +1484,7 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
           (error "Sorry, can't find \"%s\" on your system"
                  calc-gnuplot-name)))
        (with-current-buffer calc-gnuplot-buffer
-         (while (and (not (string= calc-gnuplot-name "pgnuplot"))
+         (while (and (not (calc-graph-w32-p))
                      (not (save-excursion
                             (goto-char origin)
                             (search-forward "gnuplot> " nil t)))
@@ -1483,7 +1492,7 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
            (accept-process-output calc-gnuplot-process))
          (or (memq (process-status calc-gnuplot-process) '(run stop))
              (error "Unable to start GNUPLOT process"))
-         (if (not (string= calc-gnuplot-name "pgnuplot"))
+         (if (not (calc-graph-w32-p))
              (if (save-excursion
                    (goto-char origin)
                    (re-search-forward
diff --git a/lisp/calc/calc-help.el b/lisp/calc/calc-help.el
index de00ff6..d9e8fe7 100644
--- a/lisp/calc/calc-help.el
+++ b/lisp/calc/calc-help.el
@@ -1,6 +1,6 @@
 ;;; calc-help.el --- help display functions for Calc,
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
@@ -172,7 +172,7 @@ C-w  Describe how there is no warranty for Calc."
          (setq desc (concat "M-" (substring desc 4))))
       (while (string-match "^M-# \\(ESC \\|C-\\)" desc)
        (setq desc (concat "M-# " (substring desc (match-end 0)))))
-      (if (string-match "\\(DEL\\|\\LFD\\|RET\\|SPC\\|TAB\\)" desc)
+      (if (string-match "\\(DEL\\|LFD\\|RET\\|SPC\\|TAB\\)" desc)
           (setq desc (replace-match "<\\&>" nil nil desc)))
       (if briefly
          (let ((msg (with-current-buffer (get-buffer-create "*Calc Summary*")
diff --git a/lisp/calc/calc-incom.el b/lisp/calc/calc-incom.el
index 50a6793..4bf922b 100644
--- a/lisp/calc/calc-incom.el
+++ b/lisp/calc/calc-incom.el
@@ -1,6 +1,6 @@
 ;;; calc-incom.el --- complex data type input functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-keypd.el b/lisp/calc/calc-keypd.el
index 2b22421..15bdc5b 100644
--- a/lisp/calc/calc-keypd.el
+++ b/lisp/calc/calc-keypd.el
@@ -1,6 +1,6 @@
 ;;; calc-keypd.el --- mouse-capable keypad input for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-lang.el b/lisp/calc/calc-lang.el
index b6ff705..ee107df 100644
--- a/lisp/calc/calc-lang.el
+++ b/lisp/calc/calc-lang.el
@@ -1,6 +1,6 @@
 ;;; calc-lang.el --- calc language functions
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
@@ -753,8 +753,8 @@
                  right " \\right)"))
           ((and (eq (aref func 0) ?\\)
                 (not (or
-                      (string-match "\\hbox{" func)
-                      (string-match "\\text{" func)))
+                      (string-match "\\\\hbox{" func)
+                      (string-match "\\\\text{" func)))
                 (= (length a) 2)
                 (or (Math-realp (nth 1 a))
                     (memq (car (nth 1 a)) '(var *))))
@@ -1127,7 +1127,7 @@
                  (math-read-token)))))))
 
 (put 'eqn 'math-lang-read
-     '((eq (string-match "->\\|<-\\|+-\\|\\\\dots\\|~\\|\\^"
+     '((eq (string-match "->\\|<-\\|\\+-\\|\\\\dots\\|~\\|\\^"
                          math-exp-str math-exp-pos)
            math-exp-pos)
        (progn
diff --git a/lisp/calc/calc-macs.el b/lisp/calc/calc-macs.el
index 0a1f552..033f6e9 100644
--- a/lisp/calc/calc-macs.el
+++ b/lisp/calc/calc-macs.el
@@ -1,6 +1,6 @@
 ;;; calc-macs.el --- important macros for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-map.el b/lisp/calc/calc-map.el
index 67a4dc3..0ba5ec7 100644
--- a/lisp/calc/calc-map.el
+++ b/lisp/calc/calc-map.el
@@ -1,6 +1,6 @@
 ;;; calc-map.el --- higher-order functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-math.el b/lisp/calc/calc-math.el
index 483907a..62fe3d4 100644
--- a/lisp/calc/calc-math.el
+++ b/lisp/calc/calc-math.el
@@ -1,6 +1,6 @@
 ;;; calc-math.el --- mathematical functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-menu.el b/lisp/calc/calc-menu.el
index 245a5f90..23a27e9 100644
--- a/lisp/calc/calc-menu.el
+++ b/lisp/calc/calc-menu.el
@@ -1,6 +1,6 @@
 ;;; calc-menu.el --- a menu for Calc
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/lisp/calc/calc-misc.el b/lisp/calc/calc-misc.el
index 6543920..aedb687 100644
--- a/lisp/calc/calc-misc.el
+++ b/lisp/calc/calc-misc.el
@@ -1,6 +1,6 @@
 ;;; calc-misc.el --- miscellaneous functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-mode.el b/lisp/calc/calc-mode.el
index 8070907..22a4b87 100644
--- a/lisp/calc/calc-mode.el
+++ b/lisp/calc/calc-mode.el
@@ -1,6 +1,6 @@
 ;;; calc-mode.el --- calculator modes for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-mtx.el b/lisp/calc/calc-mtx.el
index a314985..325e075 100644
--- a/lisp/calc/calc-mtx.el
+++ b/lisp/calc/calc-mtx.el
@@ -1,6 +1,6 @@
 ;;; calc-mtx.el --- matrix functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-nlfit.el b/lisp/calc/calc-nlfit.el
index b63d404..0349dc2 100644
--- a/lisp/calc/calc-nlfit.el
+++ b/lisp/calc/calc-nlfit.el
@@ -1,6 +1,6 @@
 ;;; calc-nlfit.el --- nonlinear curve fitting for Calc
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/lisp/calc/calc-poly.el b/lisp/calc/calc-poly.el
index 41083b7..5fba85e 100644
--- a/lisp/calc/calc-poly.el
+++ b/lisp/calc/calc-poly.el
@@ -1,6 +1,6 @@
 ;;; calc-poly.el --- polynomial functions for Calc  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-prog.el b/lisp/calc/calc-prog.el
index fc73143..ba8efd4 100644
--- a/lisp/calc/calc-prog.el
+++ b/lisp/calc/calc-prog.el
@@ -1,6 +1,6 @@
 ;;; calc-prog.el --- user programmability functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-rewr.el b/lisp/calc/calc-rewr.el
index cc68272..e990071 100644
--- a/lisp/calc/calc-rewr.el
+++ b/lisp/calc/calc-rewr.el
@@ -1,6 +1,6 @@
 ;;; calc-rewr.el --- rewriting functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-rules.el b/lisp/calc/calc-rules.el
index 61396a1..4f53d89 100644
--- a/lisp/calc/calc-rules.el
+++ b/lisp/calc/calc-rules.el
@@ -1,6 +1,6 @@
 ;;; calc-rules.el --- rules for simplifying algebraic expressions in Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-sel.el b/lisp/calc/calc-sel.el
index 3c36bb3..5616bd0 100644
--- a/lisp/calc/calc-sel.el
+++ b/lisp/calc/calc-sel.el
@@ -1,6 +1,6 @@
 ;;; calc-sel.el --- data selection functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-stat.el b/lisp/calc/calc-stat.el
index af4a6bb..54ecc1b 100644
--- a/lisp/calc/calc-stat.el
+++ b/lisp/calc/calc-stat.el
@@ -1,6 +1,6 @@
 ;;; calc-stat.el --- statistical functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-store.el b/lisp/calc/calc-store.el
index 864b162..3987c12 100644
--- a/lisp/calc/calc-store.el
+++ b/lisp/calc/calc-store.el
@@ -1,6 +1,6 @@
 ;;; calc-store.el --- value storage functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
@@ -405,8 +405,8 @@
                                     sconst))))
        (if var
            (let ((msg (calc-store-value var value "")))
-             (message (concat "Special constant \"%s\" copied to \"%s\"" msg)
-                      sconst (calc-var-name var)))))))))
+            (message "Special constant \"%s\" copied to \"%s\"%s"
+                     sconst (calc-var-name var) msg))))))))
 
 (defun calc-copy-variable (&optional var1 var2)
   (interactive)
diff --git a/lisp/calc/calc-stuff.el b/lisp/calc/calc-stuff.el
index 4db3443..173ecda 100644
--- a/lisp/calc/calc-stuff.el
+++ b/lisp/calc/calc-stuff.el
@@ -1,6 +1,6 @@
 ;;; calc-stuff.el --- miscellaneous functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-trail.el b/lisp/calc/calc-trail.el
index 74864ed..0eb03f4 100644
--- a/lisp/calc/calc-trail.el
+++ b/lisp/calc/calc-trail.el
@@ -1,6 +1,6 @@
 ;;; calc-trail.el --- functions for manipulating the Calc "trail"
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-undo.el b/lisp/calc/calc-undo.el
index 9101190..795a8bc 100644
--- a/lisp/calc/calc-undo.el
+++ b/lisp/calc/calc-undo.el
@@ -1,6 +1,6 @@
 ;;; calc-undo.el --- undo functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-units.el b/lisp/calc/calc-units.el
index 6e58eaf..86bebe6 100644
--- a/lisp/calc/calc-units.el
+++ b/lisp/calc/calc-units.el
@@ -1,6 +1,6 @@
 ;;; calc-units.el --- unit conversion functions for Calc  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-vec.el b/lisp/calc/calc-vec.el
index 2c9dc06..a3e98c0 100644
--- a/lisp/calc/calc-vec.el
+++ b/lisp/calc/calc-vec.el
@@ -1,6 +1,6 @@
 ;;; calc-vec.el --- vector functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc-yank.el b/lisp/calc/calc-yank.el
index 425e4b4..0d45c12 100644
--- a/lisp/calc/calc-yank.el
+++ b/lisp/calc/calc-yank.el
@@ -1,6 +1,6 @@
 ;;; calc-yank.el --- kill-ring functionality for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el
index f155b82..35f13f9 100644
--- a/lisp/calc/calc.el
+++ b/lisp/calc/calc.el
@@ -1,6 +1,6 @@
 ;;; calc.el --- the GNU Emacs calculator  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 ;; Keywords: convenience, extensions
@@ -395,10 +395,17 @@ This is not required to be present for user-written mode 
annotations."
                                   (string :tag "Closing annotation 
delimiter"))))
 
 (defcustom calc-gnuplot-name
-  (if (eq system-type 'windows-nt) "pgnuplot" "gnuplot")
+  (if (and (eq system-type 'windows-nt)
+           ;; Gnuplot v4.x on MS-Windows came with a special
+           ;; pipe-enabled gnuplot executable for batch-mode
+           ;; execution; newer versions allow using gnuplot.exe.
+           (executable-find "pgnuplot"))
+      "pgnuplot"
+    "gnuplot")
   "Name of GNUPLOT program, for calc-graph features."
   :group 'calc
-  :type '(string))
+  :type '(string)
+  :version "26.2")
 
 (defcustom calc-gnuplot-plot-command
   nil
@@ -2423,7 +2430,7 @@ the United States."
          (beep)
        (and (not (calc-minibuffer-contains 
"[-+]?\\(1[5-9]\\|[2-9][0-9]\\)#.*"))
             (search-forward "e" nil t))
-       (if (looking-at "+")
+       (if (looking-at "\\+")
            (delete-char 1))
        (if (looking-at "-")
            (delete-char 1)
diff --git a/lisp/calc/calcalg2.el b/lisp/calc/calcalg2.el
index 29288b6..18243bf 100644
--- a/lisp/calc/calcalg2.el
+++ b/lisp/calc/calcalg2.el
@@ -1,6 +1,6 @@
 ;;; calcalg2.el --- more algebraic functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calcalg3.el b/lisp/calc/calcalg3.el
index 9da08b6..8015b8e 100644
--- a/lisp/calc/calcalg3.el
+++ b/lisp/calc/calcalg3.el
@@ -1,6 +1,6 @@
 ;;; calcalg3.el --- more algebraic functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calccomp.el b/lisp/calc/calccomp.el
index 75c7adc..91eadfb 100644
--- a/lisp/calc/calccomp.el
+++ b/lisp/calc/calccomp.el
@@ -1,6 +1,6 @@
 ;;; calccomp.el --- composition functions for Calc  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calc/calcsel2.el b/lisp/calc/calcsel2.el
index 1ed4faa..c49f9a0 100644
--- a/lisp/calc/calcsel2.el
+++ b/lisp/calc/calcsel2.el
@@ -1,6 +1,6 @@
 ;;; calcsel2.el --- selection functions for Calc
 
-;; Copyright (C) 1990-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Gillespie <address@hidden>
 
diff --git a/lisp/calculator.el b/lisp/calculator.el
index c3fb689..eec7aff 100644
--- a/lisp/calculator.el
+++ b/lisp/calculator.el
@@ -1,6 +1,6 @@
 ;;; calculator.el --- a calculator for Emacs  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Eli Barzilay <address@hidden>
 ;; Keywords: tools, convenience
diff --git a/lisp/calendar/appt.el b/lisp/calendar/appt.el
index 0259dd1..40cb9f7 100644
--- a/lisp/calendar/appt.el
+++ b/lisp/calendar/appt.el
@@ -1,6 +1,6 @@
 ;;; appt.el --- appointment notification functions  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1989-1990, 1994, 1998, 2001-2018 Free Software
+;; Copyright (C) 1989-1990, 1994, 1998, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Neil Mager <address@hidden>
diff --git a/lisp/calendar/cal-bahai.el b/lisp/calendar/cal-bahai.el
index 41b0902..ec491ec 100644
--- a/lisp/calendar/cal-bahai.el
+++ b/lisp/calendar/cal-bahai.el
@@ -1,6 +1,6 @@
 ;;; cal-bahai.el --- calendar functions for the Bahá’í calendar.
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 ;; Keywords: calendar
diff --git a/lisp/calendar/cal-china.el b/lisp/calendar/cal-china.el
index 7746e80..f92947e 100644
--- a/lisp/calendar/cal-china.el
+++ b/lisp/calendar/cal-china.el
@@ -1,6 +1,6 @@
 ;;; cal-china.el --- calendar functions for the Chinese calendar
 
-;; Copyright (C) 1995, 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Edward M. Reingold <address@hidden>
 ;; Maintainer: Glenn Morris <address@hidden>
diff --git a/lisp/calendar/cal-coptic.el b/lisp/calendar/cal-coptic.el
index 9079d4a..6fa4606 100644
--- a/lisp/calendar/cal-coptic.el
+++ b/lisp/calendar/cal-coptic.el
@@ -1,6 +1,6 @@
 ;;; cal-coptic.el --- calendar functions for the Coptic/Ethiopic calendars
 
-;; Copyright (C) 1995, 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Edward M. Reingold <address@hidden>
 ;; Maintainer: Glenn Morris <address@hidden>
diff --git a/lisp/calendar/cal-dst.el b/lisp/calendar/cal-dst.el
index 8392e81..2126cfd 100644
--- a/lisp/calendar/cal-dst.el
+++ b/lisp/calendar/cal-dst.el
@@ -1,6 +1,6 @@
 ;;; cal-dst.el --- calendar functions for daylight saving rules  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1993-1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1996, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Paul Eggert <address@hidden>
 ;;         Edward M. Reingold <address@hidden>
@@ -231,7 +231,7 @@ The result has the proper form for 
`calendar-daylight-savings-starts'."
 ;; https://lists.gnu.org/r/emacs-pretest-bug/2006-11/msg00060.html
 (defun calendar-dst-find-data (&optional time)
   "Find data on the first daylight saving time transitions after TIME.
-TIME defaults to `current-time'.  Return value is as described
+TIME defaults to the current time.  Return value is as described
 for `calendar-current-time-zone'."
   (let* ((t0 (or time (current-time)))
          (t0-zone (current-time-zone t0))
@@ -279,8 +279,8 @@ expressions that when evaluated return the start and end 
dates,
 respectively. This function first attempts to use pre-calculated
 data from `calendar-dst-transition-cache', otherwise it calls
 `calendar-dst-find-data' (and adds the results to the cache).
-If dates in YEAR cannot be handled by `encode-time' (e.g. if they
-are too large to be represented as a lisp integer), then rather
+If dates in YEAR cannot be handled by `encode-time' (e.g.,
+if they are out of range for POSIX time_t), then rather
 than an error this function returns the result appropriate for
 the current year."
   (let ((e (assoc year calendar-dst-transition-cache))
diff --git a/lisp/calendar/cal-french.el b/lisp/calendar/cal-french.el
index 75a4914..b9abab5 100644
--- a/lisp/calendar/cal-french.el
+++ b/lisp/calendar/cal-french.el
@@ -1,6 +1,6 @@
 ;;; cal-french.el --- calendar functions for the French Revolutionary calendar
 
-;; Copyright (C) 1988-1989, 1992, 1994-1995, 1997, 2001-2018 Free
+;; Copyright (C) 1988-1989, 1992, 1994-1995, 1997, 2001-2019 Free
 ;; Software Foundation, Inc.
 
 ;; Author: Edward M. Reingold <address@hidden>
diff --git a/lisp/calendar/cal-hebrew.el b/lisp/calendar/cal-hebrew.el
index f34c69f..b26dbbe 100644
--- a/lisp/calendar/cal-hebrew.el
+++ b/lisp/calendar/cal-hebrew.el
@@ -1,6 +1,6 @@
 ;;; cal-hebrew.el --- calendar functions for the Hebrew calendar
 
-;; Copyright (C) 1995, 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Nachum Dershowitz <address@hidden>
 ;;         Edward M. Reingold <address@hidden>
diff --git a/lisp/calendar/cal-html.el b/lisp/calendar/cal-html.el
index f6ecc9e..a77330a 100644
--- a/lisp/calendar/cal-html.el
+++ b/lisp/calendar/cal-html.el
@@ -1,6 +1,6 @@
 ;;; cal-html.el --- functions for printing HTML calendars
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Anna M. Bigatti <address@hidden>
 ;; Keywords: calendar
diff --git a/lisp/calendar/cal-islam.el b/lisp/calendar/cal-islam.el
index ac62791..32e15f5 100644
--- a/lisp/calendar/cal-islam.el
+++ b/lisp/calendar/cal-islam.el
@@ -1,6 +1,6 @@
 ;;; cal-islam.el --- calendar functions for the Islamic calendar
 
-;; Copyright (C) 1995, 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Edward M. Reingold <address@hidden>
 ;; Maintainer: Glenn Morris <address@hidden>
diff --git a/lisp/calendar/cal-iso.el b/lisp/calendar/cal-iso.el
index 5366fef..8568afe 100644
--- a/lisp/calendar/cal-iso.el
+++ b/lisp/calendar/cal-iso.el
@@ -1,6 +1,6 @@
 ;;; cal-iso.el --- calendar functions for the ISO calendar
 
-;; Copyright (C) 1995, 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Edward M. Reingold <address@hidden>
 ;; Maintainer: Glenn Morris <address@hidden>
diff --git a/lisp/calendar/cal-julian.el b/lisp/calendar/cal-julian.el
index fecf4d5..1297a96 100644
--- a/lisp/calendar/cal-julian.el
+++ b/lisp/calendar/cal-julian.el
@@ -1,6 +1,6 @@
 ;;; cal-julian.el --- calendar functions for the Julian calendar
 
-;; Copyright (C) 1995, 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Edward M. Reingold <address@hidden>
 ;; Maintainer: Glenn Morris <address@hidden>
diff --git a/lisp/calendar/cal-mayan.el b/lisp/calendar/cal-mayan.el
index ecc5419..37fe4b9 100644
--- a/lisp/calendar/cal-mayan.el
+++ b/lisp/calendar/cal-mayan.el
@@ -1,6 +1,6 @@
 ;;; cal-mayan.el --- calendar functions for the Mayan calendars
 
-;; Copyright (C) 1992-1993, 1995, 1997, 2001-2018 Free Software
+;; Copyright (C) 1992-1993, 1995, 1997, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Stewart M. Clamen <address@hidden>
diff --git a/lisp/calendar/cal-menu.el b/lisp/calendar/cal-menu.el
index be3c7a2..cf7d04f 100644
--- a/lisp/calendar/cal-menu.el
+++ b/lisp/calendar/cal-menu.el
@@ -1,6 +1,6 @@
 ;;; cal-menu.el --- calendar functions for menu bar and popup menu support
 
-;; Copyright (C) 1994-1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Edward M. Reingold <address@hidden>
 ;;         Lara Rios <address@hidden>
diff --git a/lisp/calendar/cal-move.el b/lisp/calendar/cal-move.el
index 7a32eb6..ecd05e7 100644
--- a/lisp/calendar/cal-move.el
+++ b/lisp/calendar/cal-move.el
@@ -1,6 +1,6 @@
 ;;; cal-move.el --- calendar functions for movement in the calendar
 
-;; Copyright (C) 1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Edward M. Reingold <address@hidden>
 ;; Maintainer: Glenn Morris <address@hidden>
diff --git a/lisp/calendar/cal-persia.el b/lisp/calendar/cal-persia.el
index dad9c09..c0b6cb2 100644
--- a/lisp/calendar/cal-persia.el
+++ b/lisp/calendar/cal-persia.el
@@ -1,6 +1,6 @@
 ;;; cal-persia.el --- calendar functions for the Persian calendar
 
-;; Copyright (C) 1996-1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Edward M. Reingold <address@hidden>
 ;; Maintainer: Glenn Morris <address@hidden>
diff --git a/lisp/calendar/cal-tex.el b/lisp/calendar/cal-tex.el
index 7ae0ecb..78ab076 100644
--- a/lisp/calendar/cal-tex.el
+++ b/lisp/calendar/cal-tex.el
@@ -1,6 +1,6 @@
 ;;; cal-tex.el --- calendar functions for printing calendars with LaTeX
 
-;; Copyright (C) 1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Steve Fisk <address@hidden>
 ;;         Edward M. Reingold <address@hidden>
@@ -925,7 +925,7 @@ argument EVENT specifies a different buffer position."
         (cal-tex-large-bf (cal-tex-LaTeXify-string (calendar-day-name date)))
         (insert ", ")
         (cal-tex-large-bf (cal-tex-month-name month))
-        (insert " ")
+        (insert "\\ ")
         (cal-tex-large-bf (number-to-string day))
         (unless (string-equal "" (setq s (cal-tex-latexify-list
                                           holidays date "; ")))
@@ -976,7 +976,7 @@ shown are hard-coded to 8-12, 13-17."
   (cal-tex-large-bf (cal-tex-LaTeXify-string (calendar-day-name date)))
   (insert ", ")
   (cal-tex-large-bf (cal-tex-month-name month))
-  (insert " ")
+  (insert "\\ ")
   (cal-tex-large-bf (number-to-string day))
   (unless (string-equal "" (setq s (cal-tex-latexify-list
                                     holidays date "; ")))
diff --git a/lisp/calendar/cal-x.el b/lisp/calendar/cal-x.el
index f605d0c..58d1eeb 100644
--- a/lisp/calendar/cal-x.el
+++ b/lisp/calendar/cal-x.el
@@ -1,6 +1,6 @@
 ;;; cal-x.el --- calendar windows in dedicated frames
 
-;; Copyright (C) 1994-1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <address@hidden>
 ;;         Edward M. Reingold <address@hidden>
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index 71fb76c..de8f758 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -1,6 +1,6 @@
 ;;; calendar.el --- calendar functions  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1988-1995, 1997, 2000-2018 Free Software Foundation,
+;; Copyright (C) 1988-1995, 1997, 2000-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Edward M. Reingold <address@hidden>
diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el
index 1cc5978..1be2a05 100644
--- a/lisp/calendar/diary-lib.el
+++ b/lisp/calendar/diary-lib.el
@@ -1,6 +1,6 @@
 ;;; diary-lib.el --- diary functions  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1989-1990, 1992-1995, 2001-2018 Free Software
+;; Copyright (C) 1989-1990, 1992-1995, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Edward M. Reingold <address@hidden>
diff --git a/lisp/calendar/holidays.el b/lisp/calendar/holidays.el
index 62b9d77..2b080c3 100644
--- a/lisp/calendar/holidays.el
+++ b/lisp/calendar/holidays.el
@@ -1,6 +1,6 @@
 ;;; holidays.el --- holiday functions for the calendar package  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1989-1990, 1992-1994, 1997, 2001-2018 Free Software
+;; Copyright (C) 1989-1990, 1992-1994, 1997, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Edward M. Reingold <address@hidden>
diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el
index e3e458a..a8fd765 100644
--- a/lisp/calendar/icalendar.el
+++ b/lisp/calendar/icalendar.el
@@ -1,6 +1,6 @@
 ;;; icalendar.el --- iCalendar implementation -*- lexical-binding: t -*-
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author:         Ulf Jasper <address@hidden>
 ;; Created:        August 2002
@@ -643,12 +643,14 @@ FIXME: multiple comma-separated values should be allowed!"
               (setq year  (nth 2 mdy))))
         ;; create the decoded date-time
         ;; FIXME!?!
-        (condition-case nil
-            (decode-time (encode-time second minute hour day month year zone))
-          (error
-           (message "Cannot decode \"%s\"" isodatetimestring)
-           ;; hope for the best...
-           (list second minute hour day month year 0 nil 0))))
+       (let ((decoded-time (list second minute hour day month year
+                                 nil -1 zone)))
+         (condition-case nil
+             (decode-time (encode-time decoded-time 'integer))
+           (error
+            (message "Cannot decode \"%s\"" isodatetimestring)
+            ;; Hope for the best....
+            decoded-time))))
     ;; isodatetimestring == nil
     nil))
 
@@ -1596,8 +1598,7 @@ regular expression matching the start of non-marking 
entries.
 ENTRY-MAIN is the first line of the diary entry.
 
 Optional argument START determines the first day of the
-enumeration, given as a time value, in same format as returned by
-`current-time' -- used for test purposes."
+enumeration, given as a Lisp time value -- used for test purposes."
   (cond ((string-match (concat nonmarker
                                "%%(and \\(([^)]+)\\))\\(\\s-*.*?\\) ?$")
                        entry-main)
@@ -1621,8 +1622,7 @@ enumeration, given as a time value, in same format as 
returned by
                    (mapcar
                     (lambda (offset)
                       (let* ((day (decode-time (time-add now
-                                                         (seconds-to-time
-                                                          (* offset 60 60 
24)))))
+                                                        (* 60 60 24 offset))))
                              (d (nth 3 day))
                              (m (nth 4 day))
                              (y (nth 5 day))
diff --git a/lisp/calendar/lunar.el b/lisp/calendar/lunar.el
index b9d79e4..5424551 100644
--- a/lisp/calendar/lunar.el
+++ b/lisp/calendar/lunar.el
@@ -1,6 +1,6 @@
 ;;; lunar.el --- calendar functions for phases of the moon
 
-;; Copyright (C) 1992-1993, 1995, 1997, 2001-2018 Free Software
+;; Copyright (C) 1992-1993, 1995, 1997, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Edward M. Reingold <address@hidden>
diff --git a/lisp/calendar/parse-time.el b/lisp/calendar/parse-time.el
index 9443fde..68d6ce0 100644
--- a/lisp/calendar/parse-time.el
+++ b/lisp/calendar/parse-time.el
@@ -1,6 +1,6 @@
 ;;; parse-time.el --- parsing time strings -*- lexical-binding: t -*-
 
-;; Copyright (C) 1996, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Erik Naggum <address@hidden>
 ;; Keywords: util
@@ -147,7 +147,7 @@ letters, digits, plus or minus signs or colons."
 ;;;###autoload
 (defun parse-time-string (string)
   "Parse the time-string STRING into (SEC MIN HOUR DAY MON YEAR DOW DST TZ).
-STRING should be on something resembling an RFC2822 string, a la
+STRING should be something resembling an RFC 822 (or later) date-time, e.g.,
 \"Fri, 25 Mar 2016 16:24:56 +0100\", but this function is
 somewhat liberal in what format it accepts, and will attempt to
 return a \"likely\" value even for somewhat malformed strings.
@@ -168,8 +168,7 @@ unknown DST value is returned as -1."
            (when (and (not (nth (car slots) time)) ;not already set
                       (setq parse-time-val
                             (cond ((and (consp predicate)
-                                        (not (eq (car predicate)
-                                                 'lambda)))
+                                        (not (functionp predicate)))
                                    (and (numberp parse-time-elt)
                                         (<= (car predicate) parse-time-elt)
                                         (or (not (cdr predicate))
@@ -191,7 +190,7 @@ unknown DST value is returned as -1."
                                          :end (aref this 1))
                                       (funcall this)))
                                 parse-time-val)))
-                 (rplaca (nthcdr (pop slots) time) new-val))))))))
+                 (setf (nth (pop slots) time) new-val))))))))
     time))
 
 (defconst parse-time-iso8601-regexp
@@ -244,16 +243,17 @@ If DATE-STRING cannot be parsed, it falls back to
              re-start (match-end 0))
        (when (string-match tz-re date-string re-start)
           (setq dst nil)
-          (if (string= "Z" (match-string 1 date-string))
-              (setq tz 0)  ;; UTC timezone indicated by Z
-            (setq tz (+
-                      (* 3600
-                         (string-to-number (match-string 3 date-string)))
-                      (* 60
-                         (string-to-number
-                          (or (match-string 4 date-string) "0")))))
-            (when (string= "-" (match-string 2 date-string))
-              (setq tz (- tz)))))
+          (setq tz (if (string= "Z" (match-string 1 date-string))
+                       0  ;; UTC timezone indicated by Z
+                     (let ((tz (+
+                                (* 3600
+                                   (string-to-number
+                                    (match-string 3 date-string)))
+                                (* 60
+                                   (string-to-number
+                                    (or (match-string 4 date-string) "0"))))))
+                       (if (string= "-" (match-string 2 date-string))
+                            (- tz) tz)))))
        (setq time (list seconds minute hour day month year day-of-week dst 
tz))))
 
     ;; Fall back to having `parse-time-string' do fancy things for us.
diff --git a/lisp/calendar/solar.el b/lisp/calendar/solar.el
index ddaf745..23bc761 100644
--- a/lisp/calendar/solar.el
+++ b/lisp/calendar/solar.el
@@ -1,6 +1,6 @@
 ;;; solar.el --- calendar functions for solar events  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1992-1993, 1995, 1997, 2001-2018 Free Software
+;; Copyright (C) 1992-1993, 1995, 1997, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Edward M. Reingold <address@hidden>
diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el
index c3898e0..decb21e 100644
--- a/lisp/calendar/time-date.el
+++ b/lisp/calendar/time-date.el
@@ -1,6 +1,6 @@
 ;;; time-date.el --- Date and time handling functions
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;;     Masanobu Umeda <address@hidden>
@@ -148,20 +148,20 @@ it is assumed that PICO was omitted and should be treated 
as zero."
 ;; values.  timezone-make-date-arpa-standard should help.
 (defun date-to-time (date)
   "Parse a string DATE that represents a date-time and return a time value.
+DATE should be in one of the forms recognized by `parse-time-string'.
 If DATE lacks timezone information, GMT is assumed."
   (condition-case err
-      (apply 'encode-time (parse-time-string date))
+      (encode-time (parse-time-string date))
     (error
      (let ((overflow-error '(error "Specified time is not representable")))
        (if (equal err overflow-error)
-          (apply 'signal err)
-        (condition-case err
-            (apply 'encode-time
-                   (parse-time-string
-                    (timezone-make-date-arpa-standard date)))
+          (signal (car err) (cdr err))
+        (condition-case-unless-debug err
+            (encode-time (parse-time-string
+                          (timezone-make-date-arpa-standard date)))
           (error
            (if (equal err overflow-error)
-               (apply 'signal err)
+               (signal (car err) (cdr err))
              (error "Invalid date: %s" date)))))))))
 
 ;;;###autoload
diff --git a/lisp/calendar/timeclock.el b/lisp/calendar/timeclock.el
index 646f529..a896df5 100644
--- a/lisp/calendar/timeclock.el
+++ b/lisp/calendar/timeclock.el
@@ -1,6 +1,6 @@
 ;;; timeclock.el --- mode for keeping track of how much you work  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 ;; Created: 25 Mar 1999
@@ -467,16 +467,10 @@ include the second count.  If REVERSE-LEADER is non-nil, 
it means to
 output a \"+\" if the time value is negative, rather than a \"-\".
 This is used when negative time values have an inverted meaning (such
 as with time remaining, where negative time really means overtime)."
-  (if show-seconds
-      (format "%s%d:%02d:%02d"
-             (if (< seconds 0) (if reverse-leader "+" "-") "")
-             (truncate (/ (abs seconds) 60 60))
-             (% (truncate (/ (abs seconds) 60)) 60)
-             (% (truncate (abs seconds)) 60))
-    (format "%s%d:%02d"
+  (let ((s (abs (truncate seconds))))
+    (format (if show-seconds "%s%d:%02d:%02d" "%s%d:%02d")
            (if (< seconds 0) (if reverse-leader "+" "-") "")
-           (truncate (/ (abs seconds) 60 60))
-           (% (truncate (/ (abs seconds) 60)) 60))))
+           (/ s 3600) (% (/ s 60) 60) (% s 60))))
 
 (defsubst timeclock-currently-in-p ()
   "Return non-nil if the user is currently clocked in."
@@ -528,14 +522,12 @@ non-nil, the amount returned will be relative to past 
time worked."
   "Return a time value representing the end of today's workday.
 If TODAY-ONLY is non-nil, the value returned will be relative only to
 the time worked today, and not to past time."
-  (seconds-to-time
-   (- (float-time)
-      (let ((discrep (timeclock-find-discrep)))
-       (if discrep
-           (if today-only
-               (cadr discrep)
-             (car discrep))
-         0.0)))))
+  (time-since (let ((discrep (timeclock-find-discrep)))
+               (if discrep
+                   (if today-only
+                       (cadr discrep)
+                     (car discrep))
+                 0))))
 
 ;;;###autoload
 (defun timeclock-when-to-leave-string (&optional show-seconds
@@ -672,8 +664,8 @@ being logged for.  Normally only \"in\" events specify a 
project."
                    "\n")
            (if (equal (downcase code) "o")
                (setq timeclock-last-period
-                     (- (float-time now)
-                        (float-time (cadr timeclock-last-event)))
+                     (float-time
+                      (time-subtract now (cadr timeclock-last-event)))
                      timeclock-discrepancy
                      (+ timeclock-discrepancy
                         timeclock-last-period)))
@@ -708,8 +700,7 @@ recorded to disk.  If MOMENT is non-nil, use that as the 
current time.
 This is only provided for coherency when used by
 `timeclock-discrepancy'."
   (if (equal (car timeclock-last-event) "i")
-      (- (float-time moment)
-        (float-time (cadr timeclock-last-event)))
+      (float-time (time-subtract moment (cadr timeclock-last-event)))
     timeclock-last-period))
 
 (cl-defstruct (timeclock-entry
@@ -722,8 +713,7 @@ This is only provided for coherency when used by
 
 (defsubst timeclock-entry-length (entry)
   "Return the length of ENTRY in seconds."
-  (- (float-time (cadr entry))
-     (float-time (car entry))))
+  (float-time (time-subtract (cadr entry) (car entry))))
 
 (defsubst timeclock-entry-list-length (entry-list)
   "Return the total length of ENTRY-LIST in seconds."
@@ -742,8 +732,8 @@ This is only provided for coherency when used by
 
 (defsubst timeclock-entry-list-span (entry-list)
   "Return the total time in seconds spanned by ENTRY-LIST."
-  (- (float-time (timeclock-entry-list-end entry-list))
-     (float-time (timeclock-entry-list-begin entry-list))))
+  (float-time (time-subtract (timeclock-entry-list-end entry-list)
+                            (timeclock-entry-list-begin entry-list))))
 
 (defsubst timeclock-entry-list-break (entry-list)
   "Return the total break time (span - length) in ENTRY-LIST."
@@ -1110,7 +1100,7 @@ discrepancy, today's discrepancy, and the time worked 
today."
                           last-date-limited nil)
                     (if beg
                         (error "Error in format of timelog file!")
-                      (setq beg (float-time (cadr event))))))
+                      (setq beg (cadr event)))))
                  ((equal (downcase (car event)) "o")
                   (if (and (nth 2 event)
                            (> (length (nth 2 event)) 0))
@@ -1118,7 +1108,7 @@ discrepancy, today's discrepancy, and the time worked 
today."
                   (if (not beg)
                       (error "Error in format of timelog file!")
                     (setq timeclock-last-period
-                          (- (float-time (cadr event)) beg)
+                          (float-time (time-subtract (cadr event) beg))
                           accum (+ timeclock-last-period accum)
                           beg nil))
                   (if (equal last-date todays-date)
@@ -1156,7 +1146,7 @@ If optional argument TIME is non-nil, use that instead of 
the current time."
     (setcar (nthcdr 0 decoded) 0)
     (setcar (nthcdr 1 decoded) 0)
     (setcar (nthcdr 2 decoded) 0)
-    (apply 'encode-time decoded)))
+    (encode-time decoded)))
 
 (defun timeclock-mean (l)
   "Compute the arithmetic mean of the values in the list L."
@@ -1196,9 +1186,7 @@ HTML-P is non-nil, HTML markup is added."
            (insert project "</b><br>\n")
          (insert project "*\n"))
        (let ((proj-data (cdr (assoc project (timeclock-project-alist log))))
-             (two-weeks-ago (seconds-to-time
-                             (- (float-time today)
-                                (* 2 7 24 60 60))))
+             (two-weeks-ago (time-subtract today (* 2 7 24 60 60)))
              two-week-len today-len)
          (while proj-data
            (if (not (time-less-p
@@ -1249,18 +1237,10 @@ HTML-P is non-nil, HTML markup is added."
     <th>-1 year</th>
 </tr>")
        (let* ((day-list (timeclock-day-list))
-              (thirty-days-ago (seconds-to-time
-                                (- (float-time today)
-                                   (* 30 24 60 60))))
-              (three-months-ago (seconds-to-time
-                                 (- (float-time today)
-                                    (* 90 24 60 60))))
-              (six-months-ago (seconds-to-time
-                               (- (float-time today)
-                                  (* 180 24 60 60))))
-              (one-year-ago (seconds-to-time
-                             (- (float-time today)
-                                (* 365 24 60 60))))
+              (thirty-days-ago (time-subtract today (* 30 24 60 60)))
+              (three-months-ago (time-subtract today (* 90 24 60 60)))
+              (six-months-ago (time-subtract today (* 180 24 60 60)))
+              (one-year-ago (time-subtract today (* 365 24 60 60)))
               (time-in  (vector (list t) (list t) (list t) (list t) (list t)))
               (time-out (vector (list t) (list t) (list t) (list t) (list t)))
               (breaks   (vector (list t) (list t) (list t) (list t) (list t)))
@@ -1273,12 +1253,11 @@ HTML-P is non-nil, HTML markup is added."
              (unless (time-less-p
                       (timeclock-day-begin day)
                       (aref lengths i))
-               (let ((base (float-time
-                            (timeclock-day-base
-                             (timeclock-day-begin day)))))
+               (let ((base (timeclock-day-base (timeclock-day-begin day))))
                  (nconc (aref time-in i)
-                        (list (- (float-time (timeclock-day-begin day))
-                                 base)))
+                        (list (float-time (time-subtract
+                                           (timeclock-day-begin day)
+                                           base))))
                  (let ((span (timeclock-day-span day))
                        (len (timeclock-day-length day))
                        (req (timeclock-day-required day)))
@@ -1289,8 +1268,9 @@ HTML-P is non-nil, HTML markup is added."
                    (when (and (> span 0)
                               (> (/ (float len) (float span)) 0.70))
                      (nconc (aref time-out i)
-                            (list (- (float-time (timeclock-day-end day))
-                                     base)))
+                            (list (float-time (time-subtract
+                                               (timeclock-day-end day)
+                                               base))))
                      (nconc (aref breaks i) (list (- span len))))
                    (if req
                        (setq len (+ len (- timeclock-workday req))))
diff --git a/lisp/calendar/todo-mode.el b/lisp/calendar/todo-mode.el
index 41fe57e..7169ef4 100644
--- a/lisp/calendar/todo-mode.el
+++ b/lisp/calendar/todo-mode.el
@@ -1,6 +1,6 @@
 ;;; todo-mode.el --- facilities for making and maintaining todo lists  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1997, 1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1999, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Oliver Seidel <address@hidden>
 ;;     Stephen Berman <address@hidden>
@@ -1931,7 +1931,7 @@ their associated keys and their effects."
                             (calendar-current-date) t t))))
             (time-string (or (and time (todo-read-time))
                              (and todo-always-add-time-string
-                                  (substring (current-time-string) 11 16)))))
+                                  (format-time-string "%H:%M")))))
        (setq todo-date-from-calendar nil)
        (find-file-noselect file 'nowarn)
        (set-window-buffer (selected-window)
@@ -2881,8 +2881,7 @@ visible."
              (not marked))
       (let* ((date-string (calendar-date-string (calendar-current-date) t t))
             (time-string (if todo-always-add-time-string
-                             (concat " " (substring (current-time-string)
-                                                    11 16))
+                             (format-time-string " %H:%M")
                            ""))
             (done-prefix (concat "[" todo-done-string date-string time-string
                                  "] "))
@@ -6091,7 +6090,7 @@ the empty string (i.e., no time string)."
     (while (not valid)
       (setq answer (read-string "Enter a clock time: " nil nil
                                (when todo-always-add-time-string
-                                 (substring (current-time-string) 11 16))))
+                                 (format-time-string "%H:%M"))))
       (when (or (string= "" answer)
                (string-match diary-time-regexp answer))
        (setq valid t)))
diff --git a/lisp/case-table.el b/lisp/case-table.el
index 8ff931d..c27e772 100644
--- a/lisp/case-table.el
+++ b/lisp/case-table.el
@@ -1,6 +1,6 @@
 ;;; case-table.el --- code to extend the character set and support case tables 
 -*- lexical-binding: t -*-
 
-;; Copyright (C) 1988, 1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Howard Gayle
 ;; Maintainer: address@hidden
diff --git a/lisp/cdl.el b/lisp/cdl.el
index 487ec90..752e59b 100644
--- a/lisp/cdl.el
+++ b/lisp/cdl.el
@@ -1,6 +1,6 @@
 ;;; cdl.el --- Common Data Language (CDL) utility functions for GNU Emacs
 
-;; Copyright (C) 1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Ata Etemadi <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/cedet/ChangeLog.1 b/lisp/cedet/ChangeLog.1
index 58ce7f7..8333dd3 100644
--- a/lisp/cedet/ChangeLog.1
+++ b/lisp/cedet/ChangeLog.1
@@ -3460,7 +3460,7 @@
 ;; coding: utf-8
 ;; End:
 
-       Copyright (C) 2009-2018 Free Software Foundation, Inc.
+       Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/cedet/cedet-cscope.el b/lisp/cedet/cedet-cscope.el
index ef958fa..19a4ef9 100644
--- a/lisp/cedet/cedet-cscope.el
+++ b/lisp/cedet/cedet-cscope.el
@@ -1,6 +1,6 @@
 ;;; cedet-cscope.el --- CScope support for CEDET
 
-;;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Package: cedet
diff --git a/lisp/cedet/cedet-files.el b/lisp/cedet/cedet-files.el
index 4865b98..b378bcf 100644
--- a/lisp/cedet/cedet-files.el
+++ b/lisp/cedet/cedet-files.el
@@ -1,6 +1,6 @@
 ;;; cedet-files.el --- Common routines dealing with file names.
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Package: cedet
diff --git a/lisp/cedet/cedet-global.el b/lisp/cedet/cedet-global.el
index a0e8813..0a6604b 100644
--- a/lisp/cedet/cedet-global.el
+++ b/lisp/cedet/cedet-global.el
@@ -1,6 +1,6 @@
 ;;; cedet-global.el --- GNU Global support for CEDET.
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Package: cedet
diff --git a/lisp/cedet/cedet-idutils.el b/lisp/cedet/cedet-idutils.el
index 393d64d..7b8be07 100644
--- a/lisp/cedet/cedet-idutils.el
+++ b/lisp/cedet/cedet-idutils.el
@@ -1,6 +1,6 @@
 ;;; cedet-idutils.el --- ID Utils support for CEDET.
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Old-Version: 0.2
diff --git a/lisp/cedet/cedet.el b/lisp/cedet/cedet.el
index 34a4d99..b3d4a5d 100644
--- a/lisp/cedet/cedet.el
+++ b/lisp/cedet/cedet.el
@@ -1,6 +1,6 @@
 ;;; cedet.el --- Setup CEDET environment
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: David Ponce <address@hidden>
 ;; Maintainer: Eric M. Ludlam  <address@hidden>
diff --git a/lisp/cedet/data-debug.el b/lisp/cedet/data-debug.el
index 0a907c9..eeec6b5 100644
--- a/lisp/cedet/data-debug.el
+++ b/lisp/cedet/data-debug.el
@@ -1,6 +1,6 @@
 ;;; data-debug.el --- Data structure debugger
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam  <address@hidden>
 ;; Old-Version: 0.2
@@ -920,14 +920,14 @@ If PARENT is non-nil, it is somehow related as a parent 
to thing."
   (interactive)
   (forward-line 1)
   (beginning-of-line)
-  (skip-chars-forward " *-><[]" (point-at-eol)))
+  (skip-chars-forward "- *><[]" (point-at-eol)))
 
 (defun data-debug-prev ()
   "Go to the previous line in the Ddebug buffer."
   (interactive)
   (forward-line -1)
   (beginning-of-line)
-  (skip-chars-forward " *-><[]" (point-at-eol)))
+  (skip-chars-forward "- *><[]" (point-at-eol)))
 
 (defun data-debug-next-expando ()
   "Go to the next line in the Ddebug buffer.
@@ -1014,7 +1014,7 @@ Do nothing if already contracted."
           (data-debug-current-line-expanded-p))
       (data-debug-contract-current-line)
     (data-debug-expand-current-line))
-  (skip-chars-forward " *-><[]" (point-at-eol)))
+  (skip-chars-forward "- *><[]" (point-at-eol)))
 
 (defun data-debug-expand-or-contract-mouse (event)
   "Expand or contract anything at event EVENT."
diff --git a/lisp/cedet/ede.el b/lisp/cedet/ede.el
index 1168f26..22374dd 100644
--- a/lisp/cedet/ede.el
+++ b/lisp/cedet/ede.el
@@ -1,6 +1,6 @@
 ;;; ede.el --- Emacs Development Environment gloss
 
-;; Copyright (C) 1998-2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: project, make
diff --git a/lisp/cedet/ede/auto.el b/lisp/cedet/ede/auto.el
index b360694..4871d51 100644
--- a/lisp/cedet/ede/auto.el
+++ b/lisp/cedet/ede/auto.el
@@ -1,6 +1,6 @@
 ;;; ede/auto.el --- Autoload features for EDE
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/ede/autoconf-edit.el b/lisp/cedet/ede/autoconf-edit.el
index 2c5ca56..c243e9b 100644
--- a/lisp/cedet/ede/autoconf-edit.el
+++ b/lisp/cedet/ede/autoconf-edit.el
@@ -1,6 +1,6 @@
 ;;; ede/autoconf-edit.el --- Keymap for autoconf
 
-;; Copyright (C) 1998-2000, 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2000, 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: project
diff --git a/lisp/cedet/ede/base.el b/lisp/cedet/ede/base.el
index 8e2ee16..41ab17f 100644
--- a/lisp/cedet/ede/base.el
+++ b/lisp/cedet/ede/base.el
@@ -1,6 +1,6 @@
 ;;; ede/base.el --- Baseclasses for EDE.
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/ede/config.el b/lisp/cedet/ede/config.el
index 2cb2271..285951c 100644
--- a/lisp/cedet/ede/config.el
+++ b/lisp/cedet/ede/config.el
@@ -1,6 +1,6 @@
 ;;; ede/config.el --- Configuration Handler baseclass
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Ludlam <address@hidden>
 
diff --git a/lisp/cedet/ede/cpp-root.el b/lisp/cedet/ede/cpp-root.el
index bcefb4e..f715187 100644
--- a/lisp/cedet/ede/cpp-root.el
+++ b/lisp/cedet/ede/cpp-root.el
@@ -1,6 +1,6 @@
 ;;; ede/cpp-root.el --- A simple way to wrap a C++ project with a single root
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/ede/custom.el b/lisp/cedet/ede/custom.el
index aea4fd7..f4c34aa 100644
--- a/lisp/cedet/ede/custom.el
+++ b/lisp/cedet/ede/custom.el
@@ -1,6 +1,6 @@
 ;;; ede/custom.el --- customization of EDE projects.
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/ede/detect.el b/lisp/cedet/ede/detect.el
index 2b5086a..e33f7a9 100644
--- a/lisp/cedet/ede/detect.el
+++ b/lisp/cedet/ede/detect.el
@@ -1,6 +1,6 @@
 ;;; ede/detect.el --- EDE project detection and file associations
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
@@ -198,7 +198,7 @@ Return a cons cell:
        (ans (ede-detect-directory-for-project default-directory)))
     (if ans
        (message "Project found in %d sec @ %s of type %s"
-                (float-time (time-subtract nil start))
+                (encode-time (time-since start) 'integer)
                 (car ans)
                 (eieio-object-name-string (cdr ans)))
       (message "No Project found.") )))
diff --git a/lisp/cedet/ede/dired.el b/lisp/cedet/ede/dired.el
index 9600d3d..7fe8809 100644
--- a/lisp/cedet/ede/dired.el
+++ b/lisp/cedet/ede/dired.el
@@ -1,6 +1,6 @@
 ;;; ede/dired.el --- EDE extensions to dired.
 
-;; Copyright (C) 1998-2000, 2003, 2009-2018 Free Software Foundation,
+;; Copyright (C) 1998-2000, 2003, 2009-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
diff --git a/lisp/cedet/ede/emacs.el b/lisp/cedet/ede/emacs.el
index f756932..19400c7 100644
--- a/lisp/cedet/ede/emacs.el
+++ b/lisp/cedet/ede/emacs.el
@@ -1,6 +1,6 @@
 ;;; ede/emacs.el --- Special project for Emacs
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/ede/files.el b/lisp/cedet/ede/files.el
index 2c47481..dbe07fb 100644
--- a/lisp/cedet/ede/files.el
+++ b/lisp/cedet/ede/files.el
@@ -1,6 +1,6 @@
 ;;; ede/files.el --- Associate projects with files and directories.
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/ede/generic.el b/lisp/cedet/ede/generic.el
index 915891e..075c4ce 100644
--- a/lisp/cedet/ede/generic.el
+++ b/lisp/cedet/ede/generic.el
@@ -1,6 +1,6 @@
 ;;; ede/generic.el --- Base Support for generic build systems
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/ede/linux.el b/lisp/cedet/ede/linux.el
index cb5e739..8ec6d8b 100644
--- a/lisp/cedet/ede/linux.el
+++ b/lisp/cedet/ede/linux.el
@@ -1,6 +1,6 @@
 ;;; ede/linux.el --- Special project for Linux
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/ede/locate.el b/lisp/cedet/ede/locate.el
index c1c4851..866dce6 100644
--- a/lisp/cedet/ede/locate.el
+++ b/lisp/cedet/ede/locate.el
@@ -1,6 +1,6 @@
 ;;; ede/locate.el --- Locate support
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/ede/make.el b/lisp/cedet/ede/make.el
index 8b9a38b..3eb11d5 100644
--- a/lisp/cedet/ede/make.el
+++ b/lisp/cedet/ede/make.el
@@ -1,6 +1,6 @@
 ;;; ede/make.el --- General information about "make"
 
-;;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/ede/makefile-edit.el b/lisp/cedet/ede/makefile-edit.el
index d05fb86..1472108 100644
--- a/lisp/cedet/ede/makefile-edit.el
+++ b/lisp/cedet/ede/makefile-edit.el
@@ -1,6 +1,6 @@
 ;;; makefile-edit.el --- Makefile editing/scanning commands.
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
@@ -105,7 +105,7 @@ STOP-BEFORE is a regular expression matching a file name."
        (let ((e (save-excursion
                   (makefile-end-of-command)
                   (point))))
-         (while (re-search-forward 
"\\s-**\\([-a-zA-Z0-9./address@hidden(){}]+\\)\\s-*" e t)
+         (while (re-search-forward 
"\\s-*\\([-a-zA-Z0-9./address@hidden(){}]+\\)\\s-*" e t)
            (let ((var nil)(varexp nil)
                  (match (buffer-substring-no-properties
                          (match-beginning 1)
diff --git a/lisp/cedet/ede/pconf.el b/lisp/cedet/ede/pconf.el
index cba7aaa..4b6da44 100644
--- a/lisp/cedet/ede/pconf.el
+++ b/lisp/cedet/ede/pconf.el
@@ -1,6 +1,6 @@
 ;;; ede/pconf.el --- configure.ac maintenance for EDE
 
-;;; Copyright (C) 1998-2000, 2005, 2008-2018 Free Software Foundation,
+;;; Copyright (C) 1998-2000, 2005, 2008-2019 Free Software Foundation,
 ;;; Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
diff --git a/lisp/cedet/ede/pmake.el b/lisp/cedet/ede/pmake.el
index f0f07e9..db5a33e 100644
--- a/lisp/cedet/ede/pmake.el
+++ b/lisp/cedet/ede/pmake.el
@@ -1,6 +1,6 @@
 ;;; ede-pmake.el --- EDE Generic Project Makefile code generator.
 
-;; Copyright (C) 1998-2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: project, make
diff --git a/lisp/cedet/ede/proj-archive.el b/lisp/cedet/ede/proj-archive.el
index 553f918..d071e42 100644
--- a/lisp/cedet/ede/proj-archive.el
+++ b/lisp/cedet/ede/proj-archive.el
@@ -1,6 +1,6 @@
 ;;; ede/proj-archive.el --- EDE Generic Project archive support
 
-;;  Copyright (C) 1998-2001, 2009-2018 Free Software Foundation, Inc.
+;;  Copyright (C) 1998-2001, 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: project, make
diff --git a/lisp/cedet/ede/proj-aux.el b/lisp/cedet/ede/proj-aux.el
index f75006d..1b03722 100644
--- a/lisp/cedet/ede/proj-aux.el
+++ b/lisp/cedet/ede/proj-aux.el
@@ -1,6 +1,6 @@
 ;;; ede/proj-aux.el --- EDE Generic Project auxiliary file support
 
-;; Copyright (C) 1998-2000, 2007, 2009-2018 Free Software Foundation,
+;; Copyright (C) 1998-2000, 2007, 2009-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
diff --git a/lisp/cedet/ede/proj-comp.el b/lisp/cedet/ede/proj-comp.el
index fc7205f..aa6baf3 100644
--- a/lisp/cedet/ede/proj-comp.el
+++ b/lisp/cedet/ede/proj-comp.el
@@ -1,6 +1,6 @@
 ;;; ede/proj-comp.el --- EDE Generic Project compiler/rule driver
 
-;; Copyright (C) 1999-2001, 2004-2005, 2007, 2009-2018 Free Software
+;; Copyright (C) 1999-2001, 2004-2005, 2007, 2009-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
diff --git a/lisp/cedet/ede/proj-elisp.el b/lisp/cedet/ede/proj-elisp.el
index d9b8989..c8e920a 100644
--- a/lisp/cedet/ede/proj-elisp.el
+++ b/lisp/cedet/ede/proj-elisp.el
@@ -1,6 +1,6 @@
 ;;; ede-proj-elisp.el --- EDE Generic Project Emacs Lisp support
 
-;; Copyright (C) 1998-2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: project, make
diff --git a/lisp/cedet/ede/proj-info.el b/lisp/cedet/ede/proj-info.el
index 992996a..1a2f107 100644
--- a/lisp/cedet/ede/proj-info.el
+++ b/lisp/cedet/ede/proj-info.el
@@ -1,6 +1,6 @@
 ;;; ede-proj-info.el --- EDE Generic Project texinfo support
 
-;;; Copyright (C) 1998-2001, 2004, 2007-2018 Free Software Foundation,
+;;; Copyright (C) 1998-2001, 2004, 2007-2019 Free Software Foundation,
 ;;; Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
diff --git a/lisp/cedet/ede/proj-misc.el b/lisp/cedet/ede/proj-misc.el
index d1a8fce..c9be119 100644
--- a/lisp/cedet/ede/proj-misc.el
+++ b/lisp/cedet/ede/proj-misc.el
@@ -1,6 +1,6 @@
 ;;; ede-proj-misc.el --- EDE Generic Project Emacs Lisp support
 
-;; Copyright (C) 1998-2001, 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2001, 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: project, make
diff --git a/lisp/cedet/ede/proj-obj.el b/lisp/cedet/ede/proj-obj.el
index c6c52ed..45e8740 100644
--- a/lisp/cedet/ede/proj-obj.el
+++ b/lisp/cedet/ede/proj-obj.el
@@ -1,6 +1,6 @@
 ;;; ede/proj-obj.el --- EDE Generic Project Object code generation support
 
-;;; Copyright (C) 1998-2000, 2005, 2008-2018 Free Software Foundation,
+;;; Copyright (C) 1998-2000, 2005, 2008-2019 Free Software Foundation,
 ;;; Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
diff --git a/lisp/cedet/ede/proj-prog.el b/lisp/cedet/ede/proj-prog.el
index 215b791..8299b72 100644
--- a/lisp/cedet/ede/proj-prog.el
+++ b/lisp/cedet/ede/proj-prog.el
@@ -1,6 +1,6 @@
 ;;; ede-proj-prog.el --- EDE Generic Project program support
 
-;; Copyright (C) 1998-2001, 2005, 2008-2018 Free Software Foundation,
+;; Copyright (C) 1998-2001, 2005, 2008-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
diff --git a/lisp/cedet/ede/proj-scheme.el b/lisp/cedet/ede/proj-scheme.el
index fa9395d..8f28d62 100644
--- a/lisp/cedet/ede/proj-scheme.el
+++ b/lisp/cedet/ede/proj-scheme.el
@@ -1,6 +1,6 @@
 ;;; ede/proj-scheme.el --- EDE Generic Project scheme (guile) support
 
-;; Copyright (C) 1998-2000, 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2000, 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: project, make, scheme
diff --git a/lisp/cedet/ede/proj-shared.el b/lisp/cedet/ede/proj-shared.el
index 75d02ec..47fb453 100644
--- a/lisp/cedet/ede/proj-shared.el
+++ b/lisp/cedet/ede/proj-shared.el
@@ -1,6 +1,6 @@
 ;;; ede-proj-shared.el --- EDE Generic Project shared library support
 
-;;; Copyright (C) 1998-2000, 2009-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 1998-2000, 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: project, make
diff --git a/lisp/cedet/ede/proj.el b/lisp/cedet/ede/proj.el
index 77ecc2a..0774a46 100644
--- a/lisp/cedet/ede/proj.el
+++ b/lisp/cedet/ede/proj.el
@@ -1,6 +1,6 @@
 ;;; ede/proj.el --- EDE Generic Project file driver
 
-;; Copyright (C) 1998-2003, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2003, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: project, make
diff --git a/lisp/cedet/ede/project-am.el b/lisp/cedet/ede/project-am.el
index e0fb111..12db0a4 100644
--- a/lisp/cedet/ede/project-am.el
+++ b/lisp/cedet/ede/project-am.el
@@ -1,6 +1,6 @@
 ;;; project-am.el --- A project management scheme based on automake files.
 
-;; Copyright (C) 1998-2000, 2003, 2005, 2007-2018 Free Software
+;; Copyright (C) 1998-2000, 2003, 2005, 2007-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
diff --git a/lisp/cedet/ede/shell.el b/lisp/cedet/ede/shell.el
index 7ba338d..a20046c 100644
--- a/lisp/cedet/ede/shell.el
+++ b/lisp/cedet/ede/shell.el
@@ -1,6 +1,6 @@
 ;;; ede/shell.el --- A shell controlled by EDE.
 ;;
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/ede/simple.el b/lisp/cedet/ede/simple.el
index 3931cf6..fb4df48 100644
--- a/lisp/cedet/ede/simple.el
+++ b/lisp/cedet/ede/simple.el
@@ -1,6 +1,6 @@
 ;;; ede/simple.el --- Overlay an EDE structure on an existing project
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/ede/source.el b/lisp/cedet/ede/source.el
index 71a1c38..8105af0 100644
--- a/lisp/cedet/ede/source.el
+++ b/lisp/cedet/ede/source.el
@@ -1,6 +1,6 @@
 ;; ede/source.el --- EDE source code object
 
-;; Copyright (C) 2000, 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: project, make
diff --git a/lisp/cedet/ede/speedbar.el b/lisp/cedet/ede/speedbar.el
index 353bec2..a5ccb66 100644
--- a/lisp/cedet/ede/speedbar.el
+++ b/lisp/cedet/ede/speedbar.el
@@ -1,6 +1,6 @@
 ;;; ede/speedbar.el --- Speedbar viewing of EDE projects
 
-;; Copyright (C) 1998-2001, 2003, 2005, 2007-2018 Free Software
+;; Copyright (C) 1998-2001, 2003, 2005, 2007-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
@@ -276,7 +276,7 @@ INDENT is the current indentation level."
 Etags does not support this feature.  TEXT will be the button
 string.  TOKEN will be the list, and INDENT is the current indentation
 level."
-  (cond ((string-match "+" text)       ;we have to expand this file
+  (cond ((string-match "\\+" text)     ;we have to expand this file
         (speedbar-change-expand-button-char ?-)
         (speedbar-with-writable
           (save-excursion
diff --git a/lisp/cedet/ede/srecode.el b/lisp/cedet/ede/srecode.el
index 0e8e829..5217e2d 100644
--- a/lisp/cedet/ede/srecode.el
+++ b/lisp/cedet/ede/srecode.el
@@ -1,6 +1,6 @@
 ;;; ede/srecode.el --- EDE utilities on top of SRecoder
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/ede/system.el b/lisp/cedet/ede/system.el
index 734450e..9999923 100644
--- a/lisp/cedet/ede/system.el
+++ b/lisp/cedet/ede/system.el
@@ -1,6 +1,6 @@
 ;;; ede-system.el --- EDE working with the system (VC, FTP, ETC)
 
-;; Copyright (C) 2001-2003, 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2003, 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: project, make, vc
diff --git a/lisp/cedet/ede/util.el b/lisp/cedet/ede/util.el
index 7bd0bfe..29b8fbf 100644
--- a/lisp/cedet/ede/util.el
+++ b/lisp/cedet/ede/util.el
@@ -1,6 +1,6 @@
 ;;; ede/util.el --- EDE utilities
 
-;; Copyright (C) 2000, 2005, 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2005, 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: project, make
diff --git a/lisp/cedet/inversion.el b/lisp/cedet/inversion.el
index 48010f7..c62a57e 100644
--- a/lisp/cedet/inversion.el
+++ b/lisp/cedet/inversion.el
@@ -1,6 +1,6 @@
 ;;; inversion.el --- When you need something in version XX.XX
 
-;;; Copyright (C) 2002-2003, 2005-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2002-2003, 2005-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Version: 1.3
diff --git a/lisp/cedet/mode-local.el b/lisp/cedet/mode-local.el
index 1cd306b..f83decb 100644
--- a/lisp/cedet/mode-local.el
+++ b/lisp/cedet/mode-local.el
@@ -1,6 +1,6 @@
 ;;; mode-local.el --- Support for mode local facilities
 ;;
-;; Copyright (C) 2004-2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2005, 2007-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: David Ponce <address@hidden>
 ;; Maintainer: David Ponce <address@hidden>
diff --git a/lisp/cedet/pulse.el b/lisp/cedet/pulse.el
index e34b51f..fd658fa 100644
--- a/lisp/cedet/pulse.el
+++ b/lisp/cedet/pulse.el
@@ -1,6 +1,6 @@
 ;;; pulse.el --- Pulsing Overlays
 
-;;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Version: 1.0
diff --git a/lisp/cedet/semantic.el b/lisp/cedet/semantic.el
index 08a827f..3c84461 100644
--- a/lisp/cedet/semantic.el
+++ b/lisp/cedet/semantic.el
@@ -1,6 +1,6 @@
 ;;; semantic.el --- Semantic buffer evaluator.
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: syntax tools
diff --git a/lisp/cedet/semantic/analyze.el b/lisp/cedet/semantic/analyze.el
index 2c50722..9ea7ebf 100644
--- a/lisp/cedet/semantic/analyze.el
+++ b/lisp/cedet/semantic/analyze.el
@@ -1,6 +1,6 @@
 ;;; semantic/analyze.el --- Analyze semantic tags against local context
 
-;; Copyright (C) 2000-2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/analyze/complete.el 
b/lisp/cedet/semantic/analyze/complete.el
index 68dffc1..7d31ec7 100644
--- a/lisp/cedet/semantic/analyze/complete.el
+++ b/lisp/cedet/semantic/analyze/complete.el
@@ -1,6 +1,6 @@
 ;;; semantic/analyze/complete.el --- Smart Completions
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/analyze/debug.el 
b/lisp/cedet/semantic/analyze/debug.el
index cff20a5..d78d850 100644
--- a/lisp/cedet/semantic/analyze/debug.el
+++ b/lisp/cedet/semantic/analyze/debug.el
@@ -1,6 +1,6 @@
 ;;; semantic/analyze/debug.el --- Debug the analyzer
 
-;;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/analyze/fcn.el 
b/lisp/cedet/semantic/analyze/fcn.el
index 5120694..5e46624 100644
--- a/lisp/cedet/semantic/analyze/fcn.el
+++ b/lisp/cedet/semantic/analyze/fcn.el
@@ -1,6 +1,6 @@
 ;;; semantic/analyze/fcn.el --- Analyzer support functions.
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/analyze/refs.el 
b/lisp/cedet/semantic/analyze/refs.el
index 6268da8..7732106 100644
--- a/lisp/cedet/semantic/analyze/refs.el
+++ b/lisp/cedet/semantic/analyze/refs.el
@@ -1,6 +1,6 @@
 ;;; semantic/analyze/refs.el --- Analysis of the references between tags.
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/bovine.el b/lisp/cedet/semantic/bovine.el
index dbd7c3e..5d174c8 100644
--- a/lisp/cedet/semantic/bovine.el
+++ b/lisp/cedet/semantic/bovine.el
@@ -1,6 +1,6 @@
 ;;; semantic/bovine.el --- LL Parser/Analyzer core.
 
-;; Copyright (C) 1999-2004, 2006-2007, 2009-2018 Free Software
+;; Copyright (C) 1999-2004, 2006-2007, 2009-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
diff --git a/lisp/cedet/semantic/bovine/c.el b/lisp/cedet/semantic/bovine/c.el
index cb27582..5f0ea16 100644
--- a/lisp/cedet/semantic/bovine/c.el
+++ b/lisp/cedet/semantic/bovine/c.el
@@ -1,6 +1,6 @@
 ;;; semantic/bovine/c.el --- Semantic details for C
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/bovine/debug.el 
b/lisp/cedet/semantic/bovine/debug.el
index e511b3d..3464e25 100644
--- a/lisp/cedet/semantic/bovine/debug.el
+++ b/lisp/cedet/semantic/bovine/debug.el
@@ -1,6 +1,6 @@
 ;;; semantic/bovine/debug.el --- Debugger support for bovinator
 
-;; Copyright (C) 2003, 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/bovine/el.el b/lisp/cedet/semantic/bovine/el.el
index 7400a4c..d46b73f 100644
--- a/lisp/cedet/semantic/bovine/el.el
+++ b/lisp/cedet/semantic/bovine/el.el
@@ -1,6 +1,6 @@
 ;;; semantic/bovine/el.el --- Semantic details for Emacs Lisp
 
-;; Copyright (C) 1999-2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/bovine/gcc.el 
b/lisp/cedet/semantic/bovine/gcc.el
index 29ec41e..e04efb3 100644
--- a/lisp/cedet/semantic/bovine/gcc.el
+++ b/lisp/cedet/semantic/bovine/gcc.el
@@ -1,6 +1,6 @@
 ;;; semantic/bovine/gcc.el --- gcc querying special code for the C parser
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/bovine/grammar.el 
b/lisp/cedet/semantic/bovine/grammar.el
index 1746f3e..f77bc9d 100644
--- a/lisp/cedet/semantic/bovine/grammar.el
+++ b/lisp/cedet/semantic/bovine/grammar.el
@@ -1,6 +1,6 @@
 ;;; semantic/bovine/grammar.el --- Bovine's input grammar mode
 ;;
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: David Ponce <address@hidden>
 ;; Maintainer: David Ponce <address@hidden>
diff --git a/lisp/cedet/semantic/bovine/make.el 
b/lisp/cedet/semantic/bovine/make.el
index 23e3860..4fe3334 100644
--- a/lisp/cedet/semantic/bovine/make.el
+++ b/lisp/cedet/semantic/bovine/make.el
@@ -1,6 +1,6 @@
 ;;; semantic/bovine/make.el --- Makefile parsing rules.
 
-;; Copyright (C) 2000-2004, 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2004, 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/bovine/scm.el 
b/lisp/cedet/semantic/bovine/scm.el
index 44b5ff0..3dc2437 100644
--- a/lisp/cedet/semantic/bovine/scm.el
+++ b/lisp/cedet/semantic/bovine/scm.el
@@ -1,6 +1,6 @@
 ;;; semantic/bovine/scm.el --- Semantic details for Scheme (guile)
 
-;;; Copyright (C) 2001-2004, 2008-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2001-2004, 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/chart.el b/lisp/cedet/semantic/chart.el
index b1fe7f3..02da145 100644
--- a/lisp/cedet/semantic/chart.el
+++ b/lisp/cedet/semantic/chart.el
@@ -1,6 +1,6 @@
 ;;; semantic/chart.el --- Utilities for use with semantic tag tables
 
-;; Copyright (C) 1999-2001, 2003, 2005, 2008-2018 Free Software
+;; Copyright (C) 1999-2001, 2003, 2005, 2008-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
diff --git a/lisp/cedet/semantic/complete.el b/lisp/cedet/semantic/complete.el
index eb25f11..88ddd58 100644
--- a/lisp/cedet/semantic/complete.el
+++ b/lisp/cedet/semantic/complete.el
@@ -1,6 +1,6 @@
 ;;; semantic/complete.el --- Routines for performing tag completion
 
-;; Copyright (C) 2003-2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: syntax
diff --git a/lisp/cedet/semantic/ctxt.el b/lisp/cedet/semantic/ctxt.el
index 8edccfc..54ef2ee 100644
--- a/lisp/cedet/semantic/ctxt.el
+++ b/lisp/cedet/semantic/ctxt.el
@@ -1,6 +1,6 @@
 ;;; semantic/ctxt.el --- Context calculations for Semantic tools.
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: syntax
diff --git a/lisp/cedet/semantic/db-debug.el b/lisp/cedet/semantic/db-debug.el
index 3021666..bfc2c98 100644
--- a/lisp/cedet/semantic/db-debug.el
+++ b/lisp/cedet/semantic/db-debug.el
@@ -1,6 +1,6 @@
 ;;; semantic/db-debug.el --- Extra level debugging routines for Semantic
 
-;;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/db-ebrowse.el 
b/lisp/cedet/semantic/db-ebrowse.el
index 1856531..14ada88 100644
--- a/lisp/cedet/semantic/db-ebrowse.el
+++ b/lisp/cedet/semantic/db-ebrowse.el
@@ -1,6 +1,6 @@
 ;;; semantic/db-ebrowse.el --- Semanticdb backend using ebrowse.
 
-;; Copyright (C) 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005-2019 Free Software Foundation, Inc.
 
 ;; Authors: Eric M. Ludlam <address@hidden>
 ;;     Joakim Verona
diff --git a/lisp/cedet/semantic/db-el.el b/lisp/cedet/semantic/db-el.el
index 6752397..5375623 100644
--- a/lisp/cedet/semantic/db-el.el
+++ b/lisp/cedet/semantic/db-el.el
@@ -1,6 +1,6 @@
 ;;; semantic/db-el.el --- Semantic database extensions for Emacs Lisp
 
-;;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: tags
diff --git a/lisp/cedet/semantic/db-file.el b/lisp/cedet/semantic/db-file.el
index 2d55c27..8dbb337 100644
--- a/lisp/cedet/semantic/db-file.el
+++ b/lisp/cedet/semantic/db-file.el
@@ -1,6 +1,6 @@
 ;;; semantic/db-file.el --- Save a semanticdb to a cache file.
 
-;;; Copyright (C) 2000-2005, 2007-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2000-2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: tags
diff --git a/lisp/cedet/semantic/db-find.el b/lisp/cedet/semantic/db-find.el
index 7cb2ac1..c89ae13 100644
--- a/lisp/cedet/semantic/db-find.el
+++ b/lisp/cedet/semantic/db-find.el
@@ -1,6 +1,6 @@
 ;;; semantic/db-find.el --- Searching through semantic databases.
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: tags
diff --git a/lisp/cedet/semantic/db-global.el b/lisp/cedet/semantic/db-global.el
index cc58d2c..7592b00 100644
--- a/lisp/cedet/semantic/db-global.el
+++ b/lisp/cedet/semantic/db-global.el
@@ -1,6 +1,6 @@
 ;;; semantic/db-global.el --- Semantic database extensions for GLOBAL
 
-;; Copyright (C) 2002-2006, 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2006, 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: tags
diff --git a/lisp/cedet/semantic/db-javascript.el 
b/lisp/cedet/semantic/db-javascript.el
index 789614d..5622594 100644
--- a/lisp/cedet/semantic/db-javascript.el
+++ b/lisp/cedet/semantic/db-javascript.el
@@ -1,6 +1,6 @@
 ;;; semantic/db-javascript.el --- Semantic database extensions for javascript
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Joakim Verona
 
diff --git a/lisp/cedet/semantic/db-mode.el b/lisp/cedet/semantic/db-mode.el
index e61eb71..e1d8f63 100644
--- a/lisp/cedet/semantic/db-mode.el
+++ b/lisp/cedet/semantic/db-mode.el
@@ -1,6 +1,6 @@
 ;;; semantic/db-mode.el --- Semanticdb Minor Mode
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/db-ref.el b/lisp/cedet/semantic/db-ref.el
index c689e31..ddac96c 100644
--- a/lisp/cedet/semantic/db-ref.el
+++ b/lisp/cedet/semantic/db-ref.el
@@ -1,6 +1,6 @@
 ;;; semantic/db-ref.el --- Handle cross-db file references
 
-;;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/db-typecache.el 
b/lisp/cedet/semantic/db-typecache.el
index ade0dda..8de3cc4 100644
--- a/lisp/cedet/semantic/db-typecache.el
+++ b/lisp/cedet/semantic/db-typecache.el
@@ -1,6 +1,6 @@
 ;;; semantic/db-typecache.el --- Manage Datatypes
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/db.el b/lisp/cedet/semantic/db.el
index 05484fc..1987bc0 100644
--- a/lisp/cedet/semantic/db.el
+++ b/lisp/cedet/semantic/db.el
@@ -1,6 +1,6 @@
 ;;; semantic/db.el --- Semantic tag database manager
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: tags
diff --git a/lisp/cedet/semantic/debug.el b/lisp/cedet/semantic/debug.el
index 3c71c20..e5c04d1 100644
--- a/lisp/cedet/semantic/debug.el
+++ b/lisp/cedet/semantic/debug.el
@@ -1,6 +1,6 @@
 ;;; semantic/debug.el --- Language Debugger framework
 
-;; Copyright (C) 2003-2005, 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2005, 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/decorate.el b/lisp/cedet/semantic/decorate.el
index c33d15c..07e393f 100644
--- a/lisp/cedet/semantic/decorate.el
+++ b/lisp/cedet/semantic/decorate.el
@@ -1,6 +1,6 @@
 ;;; semantic/decorate.el --- Utilities for decorating/highlighting tokens.
 
-;;; Copyright (C) 1999-2003, 2005-2007, 2009-2018 Free Software
+;;; Copyright (C) 1999-2003, 2005-2007, 2009-2019 Free Software
 ;;; Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
diff --git a/lisp/cedet/semantic/decorate/include.el 
b/lisp/cedet/semantic/decorate/include.el
index 98fcc88..4412a4c 100644
--- a/lisp/cedet/semantic/decorate/include.el
+++ b/lisp/cedet/semantic/decorate/include.el
@@ -1,6 +1,6 @@
 ;;; semantic/decorate/include.el --- Decoration modes for include statements
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/decorate/mode.el 
b/lisp/cedet/semantic/decorate/mode.el
index 77a8471..be1d5db 100644
--- a/lisp/cedet/semantic/decorate/mode.el
+++ b/lisp/cedet/semantic/decorate/mode.el
@@ -1,6 +1,6 @@
 ;;; semantic/decorate/mode.el --- Minor mode for decorating tags
 
-;; Copyright (C) 2000-2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: syntax
diff --git a/lisp/cedet/semantic/dep.el b/lisp/cedet/semantic/dep.el
index 3f19f51..84bb228 100644
--- a/lisp/cedet/semantic/dep.el
+++ b/lisp/cedet/semantic/dep.el
@@ -1,6 +1,6 @@
 ;;; semantic/dep.el --- Methods for tracking dependencies (include files)
 
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: syntax
diff --git a/lisp/cedet/semantic/doc.el b/lisp/cedet/semantic/doc.el
index a175355..4f98cf4 100644
--- a/lisp/cedet/semantic/doc.el
+++ b/lisp/cedet/semantic/doc.el
@@ -1,6 +1,6 @@
 ;;; semantic/doc.el --- Routines for documentation strings
 
-;; Copyright (C) 1999-2003, 2005, 2008-2018 Free Software Foundation,
+;; Copyright (C) 1999-2003, 2005, 2008-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
@@ -103,7 +103,8 @@ If NOSNARF is `lex', then return the lex token."
            nil
          ;; ok, try to clean the text up.
          ;; Comment start thingy
-         (while (string-match (concat "^\\s-*" comment-start-skip) ct)
+         (while (string-match (concat "^\\s-*\\(?:" comment-start-skip "\\)")
+                               ct)
            (setq ct (concat (substring ct 0 (match-beginning 0))
                             (substring ct (match-end 0)))))
          ;; Arbitrary punctuation at the beginning of each line.
diff --git a/lisp/cedet/semantic/ede-grammar.el 
b/lisp/cedet/semantic/ede-grammar.el
index 8c36623..4ced6fa 100644
--- a/lisp/cedet/semantic/ede-grammar.el
+++ b/lisp/cedet/semantic/ede-grammar.el
@@ -1,6 +1,6 @@
 ;;; semantic/ede-grammar.el --- EDE support for Semantic Grammar Files
 
-;; Copyright (C) 2003-2004, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2004, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: project, make
diff --git a/lisp/cedet/semantic/edit.el b/lisp/cedet/semantic/edit.el
index 2a31588..1225492 100644
--- a/lisp/cedet/semantic/edit.el
+++ b/lisp/cedet/semantic/edit.el
@@ -1,6 +1,6 @@
 ;;; semantic/edit.el --- Edit Management for Semantic
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/find.el b/lisp/cedet/semantic/find.el
index 7cb8ebf..57a296d 100644
--- a/lisp/cedet/semantic/find.el
+++ b/lisp/cedet/semantic/find.el
@@ -1,6 +1,6 @@
 ;;; semantic/find.el --- Search routines for Semantic
 
-;; Copyright (C) 1999-2005, 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2005, 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: syntax
diff --git a/lisp/cedet/semantic/format.el b/lisp/cedet/semantic/format.el
index 6f4e8c6..7d040fd 100644
--- a/lisp/cedet/semantic/format.el
+++ b/lisp/cedet/semantic/format.el
@@ -1,6 +1,6 @@
 ;;; semantic/format.el --- Routines for formatting tags
 
-;; Copyright (C) 1999-2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: syntax
diff --git a/lisp/cedet/semantic/fw.el b/lisp/cedet/semantic/fw.el
index 6e7a26e..6719e62 100644
--- a/lisp/cedet/semantic/fw.el
+++ b/lisp/cedet/semantic/fw.el
@@ -1,6 +1,6 @@
 ;;; semantic/fw.el --- Framework for Semantic
 
-;;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/grammar-wy.el 
b/lisp/cedet/semantic/grammar-wy.el
index 49f3264..cc5942f 100644
--- a/lisp/cedet/semantic/grammar-wy.el
+++ b/lisp/cedet/semantic/grammar-wy.el
@@ -1,6 +1,6 @@
 ;;; semantic/grammar-wy.el --- Generated parser support file
 
-;; Copyright (C) 2002-2004, 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2004, 2009-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/lisp/cedet/semantic/grammar.el b/lisp/cedet/semantic/grammar.el
index e4dfd5c..f6d67cf 100644
--- a/lisp/cedet/semantic/grammar.el
+++ b/lisp/cedet/semantic/grammar.el
@@ -1,6 +1,6 @@
 ;;; semantic/grammar.el --- Major mode framework for Semantic grammars
 
-;; Copyright (C) 2002-2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: David Ponce <address@hidden>
 ;; Maintainer: David Ponce <address@hidden>
diff --git a/lisp/cedet/semantic/html.el b/lisp/cedet/semantic/html.el
index 6ddb645..3a8165c 100644
--- a/lisp/cedet/semantic/html.el
+++ b/lisp/cedet/semantic/html.el
@@ -1,6 +1,6 @@
 ;;; semantic/html.el --- Semantic details for html files
 
-;; Copyright (C) 2004-2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/ia-sb.el b/lisp/cedet/semantic/ia-sb.el
index c0b22b5..9f2cb7d 100644
--- a/lisp/cedet/semantic/ia-sb.el
+++ b/lisp/cedet/semantic/ia-sb.el
@@ -1,6 +1,6 @@
 ;;; semantic/ia-sb.el --- Speedbar analysis display interactor
 
-;;; Copyright (C) 2002-2004, 2006, 2008-2018 Free Software Foundation,
+;;; Copyright (C) 2002-2004, 2006, 2008-2019 Free Software Foundation,
 ;;; Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
diff --git a/lisp/cedet/semantic/ia.el b/lisp/cedet/semantic/ia.el
index 74f9afe..1549f52 100644
--- a/lisp/cedet/semantic/ia.el
+++ b/lisp/cedet/semantic/ia.el
@@ -1,6 +1,6 @@
 ;;; semantic/ia.el --- Interactive Analysis functions
 
-;;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: syntax
diff --git a/lisp/cedet/semantic/idle.el b/lisp/cedet/semantic/idle.el
index 07b7af8..a894630 100644
--- a/lisp/cedet/semantic/idle.el
+++ b/lisp/cedet/semantic/idle.el
@@ -1,6 +1,6 @@
 ;;; idle.el --- Schedule parsing tasks in idle time
 
-;; Copyright (C) 2003-2006, 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2006, 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: syntax
diff --git a/lisp/cedet/semantic/imenu.el b/lisp/cedet/semantic/imenu.el
index 62bcfac..0fb9eca 100644
--- a/lisp/cedet/semantic/imenu.el
+++ b/lisp/cedet/semantic/imenu.el
@@ -1,6 +1,6 @@
 ;;; semantic/imenu.el --- Use Semantic as an imenu tag generator
 
-;; Copyright (C) 2000-2005, 2007-2008, 2010-2018 Free Software
+;; Copyright (C) 2000-2005, 2007-2008, 2010-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
diff --git a/lisp/cedet/semantic/java.el b/lisp/cedet/semantic/java.el
index ae43953..54cce96 100644
--- a/lisp/cedet/semantic/java.el
+++ b/lisp/cedet/semantic/java.el
@@ -1,6 +1,6 @@
 ;;; semantic/java.el --- Semantic functions for Java
 
-;;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: David Ponce <address@hidden>
 
diff --git a/lisp/cedet/semantic/lex-spp.el b/lisp/cedet/semantic/lex-spp.el
index b7cacbc..d491e33 100644
--- a/lisp/cedet/semantic/lex-spp.el
+++ b/lisp/cedet/semantic/lex-spp.el
@@ -1,6 +1,6 @@
 ;;; semantic/lex-spp.el --- Semantic Lexical Pre-processor
 
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/lex.el b/lisp/cedet/semantic/lex.el
index 0cc296f..2690122 100644
--- a/lisp/cedet/semantic/lex.el
+++ b/lisp/cedet/semantic/lex.el
@@ -1,6 +1,6 @@
 ;;; semantic/lex.el --- Lexical Analyzer builder  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/mru-bookmark.el 
b/lisp/cedet/semantic/mru-bookmark.el
index 5789881..2f38d35 100644
--- a/lisp/cedet/semantic/mru-bookmark.el
+++ b/lisp/cedet/semantic/mru-bookmark.el
@@ -1,6 +1,6 @@
 ;;; semantic/mru-bookmark.el --- Automatic bookmark tracking
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/sb.el b/lisp/cedet/semantic/sb.el
index 443c383..83d11e1 100644
--- a/lisp/cedet/semantic/sb.el
+++ b/lisp/cedet/semantic/sb.el
@@ -1,6 +1,6 @@
 ;;; semantic/sb.el --- Semantic tag display for speedbar
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: syntax
@@ -279,7 +279,7 @@ Optional MODIFIERS is additional text needed for variables."
 (defun semantic-sb-show-extra (text token indent)
   "Display additional information about the token as an expansion.
 TEXT TOKEN and INDENT are the details."
-  (cond ((string-match "+" text)       ;we have to expand this file
+  (cond ((string-match "\\+" text)     ;we have to expand this file
         (speedbar-change-expand-button-char ?-)
         (speedbar-with-writable
           (save-excursion
@@ -325,7 +325,7 @@ TEXT TOKEN and INDENT are the details."
 (defun semantic-sb-expand-group (text token indent)
   "Expand a group which has semantic tokens.
 TEXT TOKEN and INDENT are the details."
-  (cond ((string-match "+" text)       ;we have to expand this file
+  (cond ((string-match "\\+" text)     ;we have to expand this file
         (speedbar-change-expand-button-char ?-)
         (speedbar-with-writable
           (save-excursion
diff --git a/lisp/cedet/semantic/scope.el b/lisp/cedet/semantic/scope.el
index 0f171e2..e0851d3 100644
--- a/lisp/cedet/semantic/scope.el
+++ b/lisp/cedet/semantic/scope.el
@@ -1,6 +1,6 @@
 ;;; semantic/scope.el --- Analyzer Scope Calculations
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/senator.el b/lisp/cedet/semantic/senator.el
index c217b00..2462662 100644
--- a/lisp/cedet/semantic/senator.el
+++ b/lisp/cedet/semantic/senator.el
@@ -1,6 +1,6 @@
 ;;; semantic/senator.el --- SEmantic NAvigaTOR
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: David Ponce <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/cedet/semantic/sort.el b/lisp/cedet/semantic/sort.el
index 5d6a938..02a4e58 100644
--- a/lisp/cedet/semantic/sort.el
+++ b/lisp/cedet/semantic/sort.el
@@ -1,6 +1,6 @@
 ;;; semantic/sort.el --- Utilities for sorting and re-arranging tag tables.
 
-;;; Copyright (C) 1999-2005, 2007-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 1999-2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: syntax
diff --git a/lisp/cedet/semantic/symref.el b/lisp/cedet/semantic/symref.el
index c697e54..b005199 100644
--- a/lisp/cedet/semantic/symref.el
+++ b/lisp/cedet/semantic/symref.el
@@ -1,6 +1,6 @@
 ;;; semantic/symref.el --- Symbol Reference API
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/symref/cscope.el 
b/lisp/cedet/semantic/symref/cscope.el
index d02ca53..53e62a4 100644
--- a/lisp/cedet/semantic/symref/cscope.el
+++ b/lisp/cedet/semantic/symref/cscope.el
@@ -1,6 +1,6 @@
 ;;; semantic/symref/cscope.el --- Semantic-symref support via cscope.
 
-;;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/symref/filter.el 
b/lisp/cedet/semantic/symref/filter.el
index 726ef59..5d16669 100644
--- a/lisp/cedet/semantic/symref/filter.el
+++ b/lisp/cedet/semantic/symref/filter.el
@@ -1,6 +1,6 @@
 ;;; semantic/symref/filter.el --- Filter symbol reference hits for accuracy.
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/symref/global.el 
b/lisp/cedet/semantic/symref/global.el
index b749150..9bc24fb 100644
--- a/lisp/cedet/semantic/symref/global.el
+++ b/lisp/cedet/semantic/symref/global.el
@@ -1,6 +1,6 @@
 ;;; semantic/symref/global.el --- Use GNU Global for symbol references
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/symref/grep.el 
b/lisp/cedet/semantic/symref/grep.el
index 661e101..caac757 100644
--- a/lisp/cedet/semantic/symref/grep.el
+++ b/lisp/cedet/semantic/symref/grep.el
@@ -1,6 +1,6 @@
 ;;; semantic/symref/grep.el --- Symref implementation using find/grep
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/symref/idutils.el 
b/lisp/cedet/semantic/symref/idutils.el
index 3ffab31..58cf12a 100644
--- a/lisp/cedet/semantic/symref/idutils.el
+++ b/lisp/cedet/semantic/symref/idutils.el
@@ -1,6 +1,6 @@
 ;;; semantic/symref/idutils.el --- Symref implementation for idutils
 
-;;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/symref/list.el 
b/lisp/cedet/semantic/symref/list.el
index ab22d0d..50aa5c5 100644
--- a/lisp/cedet/semantic/symref/list.el
+++ b/lisp/cedet/semantic/symref/list.el
@@ -1,6 +1,6 @@
 ;;; semantic/symref/list.el --- Symref Output List UI.
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/tag-file.el b/lisp/cedet/semantic/tag-file.el
index ca67efd..21bc8c8 100644
--- a/lisp/cedet/semantic/tag-file.el
+++ b/lisp/cedet/semantic/tag-file.el
@@ -1,6 +1,6 @@
 ;;; semantic/tag-file.el --- Routines that find files based on tags.
 
-;; Copyright (C) 1999-2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: syntax
diff --git a/lisp/cedet/semantic/tag-ls.el b/lisp/cedet/semantic/tag-ls.el
index 39a4d95..e4627d6 100644
--- a/lisp/cedet/semantic/tag-ls.el
+++ b/lisp/cedet/semantic/tag-ls.el
@@ -1,6 +1,6 @@
 ;;; semantic/tag-ls.el --- Language Specific override functions for tags
 
-;; Copyright (C) 1999-2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/tag-write.el b/lisp/cedet/semantic/tag-write.el
index 2127be8..bb79775 100644
--- a/lisp/cedet/semantic/tag-write.el
+++ b/lisp/cedet/semantic/tag-write.el
@@ -1,6 +1,6 @@
 ;;; semantic/tag-write.el --- Write tags to a text stream
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/tag.el b/lisp/cedet/semantic/tag.el
index 0e27546..1011d1c 100644
--- a/lisp/cedet/semantic/tag.el
+++ b/lisp/cedet/semantic/tag.el
@@ -1,6 +1,6 @@
 ;;; semantic/tag.el --- tag creation and access
 
-;; Copyright (C) 1999-2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/texi.el b/lisp/cedet/semantic/texi.el
index 1fdfd10..f079bf2 100644
--- a/lisp/cedet/semantic/texi.el
+++ b/lisp/cedet/semantic/texi.el
@@ -1,6 +1,6 @@
 ;;; semantic/texi.el --- Semantic details for Texinfo files
 
-;; Copyright (C) 2001-2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/semantic/util-modes.el 
b/lisp/cedet/semantic/util-modes.el
index 180aca5..69df671 100644
--- a/lisp/cedet/semantic/util-modes.el
+++ b/lisp/cedet/semantic/util-modes.el
@@ -1,6 +1,6 @@
 ;;; semantic/util-modes.el --- Semantic minor modes
 
-;; Copyright (C) 2000-2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Authors: Eric M. Ludlam <address@hidden>
 ;;          David Ponce <address@hidden>
diff --git a/lisp/cedet/semantic/util.el b/lisp/cedet/semantic/util.el
index 0a02b89..943f9c7 100644
--- a/lisp/cedet/semantic/util.el
+++ b/lisp/cedet/semantic/util.el
@@ -1,6 +1,6 @@
 ;;; semantic/util.el --- Utilities for use with semantic tag tables
 
-;;; Copyright (C) 1999-2005, 2007-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 1999-2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: syntax
diff --git a/lisp/cedet/semantic/wisent.el b/lisp/cedet/semantic/wisent.el
index bfbcb6a..6bb7710 100644
--- a/lisp/cedet/semantic/wisent.el
+++ b/lisp/cedet/semantic/wisent.el
@@ -1,6 +1,6 @@
 ;;; semantic/wisent.el --- Wisent - Semantic gateway
 
-;; Copyright (C) 2001-2007, 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2007, 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: David Ponce <address@hidden>
 ;; Maintainer: David Ponce <address@hidden>
diff --git a/lisp/cedet/semantic/wisent/comp.el 
b/lisp/cedet/semantic/wisent/comp.el
index 479b07c..db910b1 100644
--- a/lisp/cedet/semantic/wisent/comp.el
+++ b/lisp/cedet/semantic/wisent/comp.el
@@ -1,6 +1,6 @@
 ;;; semantic/wisent/comp.el --- GNU Bison for Emacs - Grammar compiler
 
-;; Copyright (C) 1984, 1986, 1989, 1992, 1995, 2000-2007, 2009-2018 Free
+;; Copyright (C) 1984, 1986, 1989, 1992, 1995, 2000-2007, 2009-2019 Free
 ;; Software Foundation, Inc.
 
 ;; Author: David Ponce <address@hidden>
diff --git a/lisp/cedet/semantic/wisent/grammar.el 
b/lisp/cedet/semantic/wisent/grammar.el
index 4b5cc0b..7d77671 100644
--- a/lisp/cedet/semantic/wisent/grammar.el
+++ b/lisp/cedet/semantic/wisent/grammar.el
@@ -1,6 +1,6 @@
 ;;; semantic/wisent/grammar.el --- Wisent's input grammar mode
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: David Ponce <address@hidden>
 ;; Maintainer: David Ponce <address@hidden>
diff --git a/lisp/cedet/semantic/wisent/java-tags.el 
b/lisp/cedet/semantic/wisent/java-tags.el
index 7cd739a..4bf7a8e 100644
--- a/lisp/cedet/semantic/wisent/java-tags.el
+++ b/lisp/cedet/semantic/wisent/java-tags.el
@@ -1,6 +1,6 @@
 ;;; semantic/wisent/java-tags.el --- Java LALR parser for Emacs
 
-;; Copyright (C) 2001-2006, 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2006, 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: David Ponce <address@hidden>
 ;; Maintainer: David Ponce <address@hidden>
diff --git a/lisp/cedet/semantic/wisent/javascript.el 
b/lisp/cedet/semantic/wisent/javascript.el
index 518689a..05040b3 100644
--- a/lisp/cedet/semantic/wisent/javascript.el
+++ b/lisp/cedet/semantic/wisent/javascript.el
@@ -1,6 +1,6 @@
 ;;; semantic/wisent/javascript.el --- javascript parser support
 
-;; Copyright (C) 2005, 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Ludlam <address@hidden>
 ;; Keywords: syntax
diff --git a/lisp/cedet/semantic/wisent/python.el 
b/lisp/cedet/semantic/wisent/python.el
index f7944fe..c530329 100644
--- a/lisp/cedet/semantic/wisent/python.el
+++ b/lisp/cedet/semantic/wisent/python.el
@@ -1,6 +1,6 @@
 ;;; wisent-python.el --- Semantic support for Python
 
-;; Copyright (C) 2002, 2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Richard Kim  <address@hidden>
 ;; Maintainer: Richard Kim  <address@hidden>
diff --git a/lisp/cedet/semantic/wisent/wisent.el 
b/lisp/cedet/semantic/wisent/wisent.el
index 310799d..2108242 100644
--- a/lisp/cedet/semantic/wisent/wisent.el
+++ b/lisp/cedet/semantic/wisent/wisent.el
@@ -1,6 +1,6 @@
 ;;; semantic/wisent/wisent.el --- GNU Bison for Emacs - Runtime
 
-;;; Copyright (C) 2002-2007, 2009-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2002-2007, 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: David Ponce <address@hidden>
 ;; Maintainer: David Ponce <address@hidden>
diff --git a/lisp/cedet/srecode.el b/lisp/cedet/srecode.el
index e27fa1d..ce263fc 100644
--- a/lisp/cedet/srecode.el
+++ b/lisp/cedet/srecode.el
@@ -1,6 +1,6 @@
 ;;; srecode.el --- Semantic buffer evaluator.
 
-;;; Copyright (C) 2005, 2007-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: codegeneration
diff --git a/lisp/cedet/srecode/args.el b/lisp/cedet/srecode/args.el
index 7195b78..e8a1a2c 100644
--- a/lisp/cedet/srecode/args.el
+++ b/lisp/cedet/srecode/args.el
@@ -1,6 +1,6 @@
 ;;; srecode/args.el --- Provide some simple template arguments
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/srecode/compile.el b/lisp/cedet/srecode/compile.el
index a0a53a6..204211b 100644
--- a/lisp/cedet/srecode/compile.el
+++ b/lisp/cedet/srecode/compile.el
@@ -1,6 +1,6 @@
 ;;; srecode/compile --- Compilation of srecode template files.
 
-;; Copyright (C) 2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: codegeneration
diff --git a/lisp/cedet/srecode/cpp.el b/lisp/cedet/srecode/cpp.el
index 1413914..e6a5599 100644
--- a/lisp/cedet/srecode/cpp.el
+++ b/lisp/cedet/srecode/cpp.el
@@ -1,6 +1,6 @@
 ;;; srecode/cpp.el --- C++ specific handlers for Semantic Recoder
 
-;; Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;;         Jan Moringen <address@hidden>
diff --git a/lisp/cedet/srecode/ctxt.el b/lisp/cedet/srecode/ctxt.el
index 9afbac9..66f6779 100644
--- a/lisp/cedet/srecode/ctxt.el
+++ b/lisp/cedet/srecode/ctxt.el
@@ -1,6 +1,6 @@
 ;;; srecode/ctxt.el --- Derive a context from the source buffer.
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/srecode/dictionary.el b/lisp/cedet/srecode/dictionary.el
index a2410be..a13c42d 100644
--- a/lisp/cedet/srecode/dictionary.el
+++ b/lisp/cedet/srecode/dictionary.el
@@ -1,6 +1,6 @@
 ;;; srecode/dictionary.el --- Dictionary code for the semantic recoder.
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/srecode/document.el b/lisp/cedet/srecode/document.el
index cf43337..06fc262 100644
--- a/lisp/cedet/srecode/document.el
+++ b/lisp/cedet/srecode/document.el
@@ -1,6 +1,6 @@
 ;;; srecode/document.el --- Documentation (comment) generation
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/srecode/el.el b/lisp/cedet/srecode/el.el
index ff9e1d5..348c812 100644
--- a/lisp/cedet/srecode/el.el
+++ b/lisp/cedet/srecode/el.el
@@ -1,6 +1,6 @@
 ;;; srecode/el.el --- Emacs Lisp specific arguments
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/srecode/expandproto.el 
b/lisp/cedet/srecode/expandproto.el
index ae63aff..7b5de0d 100644
--- a/lisp/cedet/srecode/expandproto.el
+++ b/lisp/cedet/srecode/expandproto.el
@@ -1,6 +1,6 @@
 ;;; srecode/expandproto.el --- Expanding prototypes.
 
-;; Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/srecode/extract.el b/lisp/cedet/srecode/extract.el
index 276f2ac..f493251 100644
--- a/lisp/cedet/srecode/extract.el
+++ b/lisp/cedet/srecode/extract.el
@@ -1,6 +1,6 @@
 ;;; srecode/extract.el --- Extract content from previously inserted macro.
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/srecode/fields.el b/lisp/cedet/srecode/fields.el
index d184469..95caeb3 100644
--- a/lisp/cedet/srecode/fields.el
+++ b/lisp/cedet/srecode/fields.el
@@ -1,6 +1,6 @@
 ;;; srecode/fields.el --- Handling type-in fields in a buffer.
 ;;
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/srecode/filters.el b/lisp/cedet/srecode/filters.el
index 2138212..b9b037f 100644
--- a/lisp/cedet/srecode/filters.el
+++ b/lisp/cedet/srecode/filters.el
@@ -1,6 +1,6 @@
 ;;; srecode/filters.el --- Filters for use in template variables.
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/srecode/find.el b/lisp/cedet/srecode/find.el
index 1929ef3..6859226 100644
--- a/lisp/cedet/srecode/find.el
+++ b/lisp/cedet/srecode/find.el
@@ -1,6 +1,6 @@
 ;;;; srecode/find.el --- Tools for finding templates in the database.
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/srecode/getset.el b/lisp/cedet/srecode/getset.el
index 870acd6..cef4b94 100644
--- a/lisp/cedet/srecode/getset.el
+++ b/lisp/cedet/srecode/getset.el
@@ -1,6 +1,6 @@
 ;;; srecode/getset.el --- Package for inserting new get/set methods.
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/srecode/insert.el b/lisp/cedet/srecode/insert.el
index 13dc8ee..26af2ff 100644
--- a/lisp/cedet/srecode/insert.el
+++ b/lisp/cedet/srecode/insert.el
@@ -1,6 +1,6 @@
 ;;; srecode/insert.el --- Insert srecode templates to an output stream.
 
-;; Copyright (C) 2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/srecode/java.el b/lisp/cedet/srecode/java.el
index 7021267..85df930 100644
--- a/lisp/cedet/srecode/java.el
+++ b/lisp/cedet/srecode/java.el
@@ -1,6 +1,6 @@
 ;;; srecode/java.el --- Srecode Java support
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/srecode/map.el b/lisp/cedet/srecode/map.el
index 1d419c9..fa5d27b 100644
--- a/lisp/cedet/srecode/map.el
+++ b/lisp/cedet/srecode/map.el
@@ -1,6 +1,6 @@
 ;;; srecode/map.el --- Manage a template file map
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/srecode/mode.el b/lisp/cedet/srecode/mode.el
index 2bdc58a..bf1f64e 100644
--- a/lisp/cedet/srecode/mode.el
+++ b/lisp/cedet/srecode/mode.el
@@ -1,6 +1,6 @@
 ;;; srecode/mode.el --- Minor mode for managing and using SRecode templates
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/srecode/semantic.el b/lisp/cedet/srecode/semantic.el
index 122fd88..93dcaff 100644
--- a/lisp/cedet/srecode/semantic.el
+++ b/lisp/cedet/srecode/semantic.el
@@ -1,6 +1,6 @@
 ;;; srecode/semantic.el --- Semantic specific extensions to SRecode.
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/srecode/srt-mode.el b/lisp/cedet/srecode/srt-mode.el
index 6c269e0..6bf2d51 100644
--- a/lisp/cedet/srecode/srt-mode.el
+++ b/lisp/cedet/srecode/srt-mode.el
@@ -1,6 +1,6 @@
 ;;; srecode/srt-mode.el --- Major mode for writing screcode macros
 
-;; Copyright (C) 2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -64,7 +64,7 @@
 (defvar srecode-font-lock-keywords
   '(
     ;; Template
-    ("^\\(template\\)\\s-+\\(\\w*\\)\\(\\( \\(:\\w+\\)\\|\\)+\\)$"
+    ("^\\(template\\)\\s-+\\(\\w*\\)\\(\\( \\(:\\w+\\)\\)*\\)$"
      (1 font-lock-keyword-face)
      (2 font-lock-function-name-face)
      (3 font-lock-builtin-face ))
diff --git a/lisp/cedet/srecode/srt.el b/lisp/cedet/srecode/srt.el
index fdabdc4..e6d2bb7 100644
--- a/lisp/cedet/srecode/srt.el
+++ b/lisp/cedet/srecode/srt.el
@@ -1,6 +1,6 @@
 ;;; srecode/srt.el --- argument handlers for SRT files
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/srecode/table.el b/lisp/cedet/srecode/table.el
index af2e8b1..3b271f0 100644
--- a/lisp/cedet/srecode/table.el
+++ b/lisp/cedet/srecode/table.el
@@ -1,6 +1,6 @@
 ;;; srecode/table.el --- Tables of Semantic Recoders
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/cedet/srecode/template.el b/lisp/cedet/srecode/template.el
index add2f09..8528a37 100644
--- a/lisp/cedet/srecode/template.el
+++ b/lisp/cedet/srecode/template.el
@@ -1,6 +1,6 @@
 ;;; srecode/template.el --- SRecoder template language parser support.
 
-;; Copyright (C) 2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/lisp/cedet/srecode/texi.el b/lisp/cedet/srecode/texi.el
index ec73b7b..223cf28 100644
--- a/lisp/cedet/srecode/texi.el
+++ b/lisp/cedet/srecode/texi.el
@@ -1,6 +1,6 @@
 ;;; srecode/texi.el --- Srecode texinfo support.
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/lisp/char-fold.el b/lisp/char-fold.el
index 907d49e..e61bc3e 100644
--- a/lisp/char-fold.el
+++ b/lisp/char-fold.el
@@ -1,6 +1,6 @@
 ;;; char-fold.el --- match unicode to similar ASCII -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: matching
diff --git a/lisp/chistory.el b/lisp/chistory.el
index b4a8b6e..59bdc00 100644
--- a/lisp/chistory.el
+++ b/lisp/chistory.el
@@ -1,6 +1,6 @@
 ;;; chistory.el --- list command history
 
-;; Copyright (C) 1985, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: K. Shane Hartman
 ;; Maintainer: address@hidden
diff --git a/lisp/cmuscheme.el b/lisp/cmuscheme.el
index 93856aa..ed6f1bf 100644
--- a/lisp/cmuscheme.el
+++ b/lisp/cmuscheme.el
@@ -1,6 +1,6 @@
 ;;; cmuscheme.el --- Scheme process in a buffer. Adapted from tea.el
 
-;; Copyright (C) 1988, 1994, 1997, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1988, 1994, 1997, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Olin Shivers <address@hidden>
diff --git a/lisp/color.el b/lisp/color.el
index 9981354..e401456 100644
--- a/lisp/color.el
+++ b/lisp/color.el
@@ -1,6 +1,6 @@
 ;;; color.el --- Color manipulation library -*- lexical-binding:t -*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Authors: Julien Danjou <address@hidden>
 ;;          Drew Adams <address@hidden>
diff --git a/lisp/comint.el b/lisp/comint.el
index 5928804..d21cc13 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -1,6 +1,6 @@
 ;;; comint.el --- general command interpreter in a window stuff -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1988, 1990, 1992-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 1990, 1992-2019 Free Software Foundation, Inc.
 
 ;; Author: Olin Shivers <address@hidden>
 ;;     Simon Marshall <address@hidden>
@@ -1618,8 +1618,8 @@ Go to the history element by the absolute history 
position HIST-POS."
 (defun comint-within-quotes (beg end)
   "Return t if the number of quotes between BEG and END is odd.
 Quotes are single and double."
-  (let ((countsq (comint-how-many-region "\\(^\\|[^\\\\]\\)'" beg end))
-       (countdq (comint-how-many-region "\\(^\\|[^\\\\]\\)\"" beg end)))
+  (let ((countsq (comint-how-many-region "\\(^\\|[^\\]\\)'" beg end))
+       (countdq (comint-how-many-region "\\(^\\|[^\\]\\)\"" beg end)))
     (or (= (mod countsq 2) 1) (= (mod countdq 2) 1))))
 
 (defun comint-how-many-region (regexp beg end)
@@ -2072,20 +2072,6 @@ Make backspaces delete the previous character."
            (goto-char (process-mark process))
            (set-marker comint-last-output-start (point))
 
-            ;; Try to skip repeated prompts, which can occur as a result of
-            ;; commands sent without inserting them in the buffer.
-            (let ((bol (save-excursion (forward-line 0) (point)))) ;No fields.
-              (when (and (not (bolp))
-                         (looking-back comint-prompt-regexp bol))
-                (let* ((prompt (buffer-substring bol (point)))
-                       (prompt-re (concat "\\`" (regexp-quote prompt))))
-                  (while (string-match prompt-re string)
-                    (setq string (substring string (match-end 0)))))))
-            (while (string-match (concat "\\(^" comint-prompt-regexp
-                                         "\\)\\1+")
-                                 string)
-              (setq string (replace-match "\\1" nil nil string)))
-
            ;; insert-before-markers is a bad thing. XXX
            ;; Luckily we don't have to use it any more, we use
            ;; window-point-insertion-type instead.
@@ -2536,13 +2522,16 @@ Useful if you accidentally suspend the top-level 
process."
 
 (defun comint-skip-input ()
   "Skip all pending input, from last stuff output by interpreter to point.
-This means mark it as if it had been sent as input, without sending it."
+This means mark it as if it had been sent as input, without
+sending it.  The command keys used to trigger the command that
+called this function are inserted into the buffer."
   (let ((comint-input-sender 'ignore)
        (comint-input-filter-functions nil))
     (comint-send-input t t))
   (end-of-line)
   (let ((pos (point))
-       (marker (process-mark (get-buffer-process (current-buffer)))))
+       (marker (process-mark (get-buffer-process (current-buffer))))
+        (inhibit-read-only t))
     (insert "  " (key-description (this-command-keys)))
     (if (= marker pos)
        (set-marker marker (point)))))
@@ -3089,7 +3078,7 @@ interpreter (e.g., the percent notation of cmd.exe on 
Windows)."
        (let (env-var-name
              env-var-val)
          (save-match-data
-           (while (string-match "%\\([^\\\\/]*\\)%" name)
+           (while (string-match "%\\([^\\/]*\\)%" name)
              (setq env-var-name (match-string 1 name))
              (setq env-var-val (or (getenv env-var-name) ""))
              (setq name (replace-match env-var-val t t name))))))
diff --git a/lisp/completion.el b/lisp/completion.el
index 66b413f..89285c7 100644
--- a/lisp/completion.el
+++ b/lisp/completion.el
@@ -1,6 +1,6 @@
 ;;; completion.el --- dynamic word-completion code
 
-;; Copyright (C) 1990, 1993, 1995, 1997, 2001-2018 Free Software
+;; Copyright (C) 1990, 1993, 1995, 1997, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
@@ -409,10 +409,7 @@ Used to decide whether to save completions.")
 (defun cmpl-coerce-string-case (string case-type)
   (cond ((eq case-type :down) (downcase string))
        ((eq case-type :up) (upcase string))
-       ((eq case-type :capitalized)
-        (setq string (downcase string))
-        (aset string 0 (logand ?\337 (aref string 0)))
-        string)
+       ((eq case-type :capitalized) (capitalize string))
        (t string)))
 
 (defun cmpl-merge-string-cases (string-to-coerce given-string)
@@ -435,7 +432,7 @@ Used to decide whether to save completions.")
 
 
 (defun cmpl-hours-since-origin ()
-  (floor (float-time) 3600))
+  (floor (encode-time nil 'integer) 3600))
 
 ;;---------------------------------------------------------------------------
 ;; "Symbol" parsing functions
diff --git a/lisp/composite.el b/lisp/composite.el
index 6d280c8..6333481 100644
--- a/lisp/composite.el
+++ b/lisp/composite.el
@@ -1,6 +1,6 @@
 ;;; composite.el --- support character composition
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
 ;;   2008, 2009, 2010, 2011
diff --git a/lisp/cus-dep.el b/lisp/cus-dep.el
index 258b62e..e26837b 100644
--- a/lisp/cus-dep.el
+++ b/lisp/cus-dep.el
@@ -1,6 +1,6 @@
 ;;; cus-dep.el --- find customization dependencies
 ;;
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Per Abrahamsen <address@hidden>
 ;; Keywords: internal
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el
index 9aac0fb..f87b6b6 100644
--- a/lisp/cus-edit.el
+++ b/lisp/cus-edit.el
@@ -1,6 +1,6 @@
 ;;; cus-edit.el --- tools for customizing Emacs and Lisp packages -*- 
lexical-binding:t -*-
 ;;
-;; Copyright (C) 1996-1997, 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1997, 1999-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Per Abrahamsen <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/cus-face.el b/lisp/cus-face.el
index 54f5d51..0ee6a8d 100644
--- a/lisp/cus-face.el
+++ b/lisp/cus-face.el
@@ -1,6 +1,6 @@
 ;;; cus-face.el --- customization support for faces
 ;;
-;; Copyright (C) 1996-1997, 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1997, 1999-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Per Abrahamsen <address@hidden>
 ;; Keywords: help, faces
diff --git a/lisp/cus-start.el b/lisp/cus-start.el
index 133e94f..baa05d0 100644
--- a/lisp/cus-start.el
+++ b/lisp/cus-start.el
@@ -1,6 +1,6 @@
 ;;; cus-start.el --- define customization properties of builtins  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1997, 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Per Abrahamsen <address@hidden>
 ;; Keywords: internal
@@ -314,7 +314,13 @@ Leaving \"Default\" unchecked is equivalent with 
specifying a default of
                                            (other :tag "hidden by keypress" 1))
                              "22.1")
             (make-pointer-invisible mouse boolean "23.2")
-            (menu-bar-mode frames boolean nil
+             (resize-mini-frames
+              frames (choice
+                      (const :tag "Never" nil)
+                      (const :tag "Fit frame to buffer" t)
+                      (function :tag "User-defined function"))
+               "27.1")
+             (menu-bar-mode frames boolean nil
                            ;; FIXME?
                             ;; :initialize custom-initialize-default
                            :set custom-set-minor-mode)
@@ -730,7 +736,7 @@ since it could result in memory overflow and make Emacs 
crash."
       ;; If this is NOT while dumping Emacs, set up the rest of the
       ;; customization info.  This is the stuff that is not needed
       ;; until someone does M-x customize etc.
-      (unless purify-flag
+      (unless dump-mode
        ;; Add it to the right group(s).
        (if (listp group)
            (dolist (g group)
@@ -752,7 +758,7 @@ since it could result in memory overflow and make Emacs 
crash."
 ;; Record cus-start as loaded if we have set up all the info that we can.
 ;; Don't record it as loaded if we have only set up the standard values
 ;; and safe/risky properties.
-(unless purify-flag
+(unless dump-mode
   (provide 'cus-start))
 
 ;;; cus-start.el ends here
diff --git a/lisp/cus-theme.el b/lisp/cus-theme.el
index 995c55b..bc9d1d4 100644
--- a/lisp/cus-theme.el
+++ b/lisp/cus-theme.el
@@ -1,6 +1,6 @@
 ;;; cus-theme.el -- custom theme creation user interface  -*- lexical-binding: 
t -*-
 ;;
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Alex Schroeder <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/custom.el b/lisp/custom.el
index a08f7fd..53b8045 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -1,6 +1,6 @@
 ;;; custom.el --- tools for declaring and initializing options  -*- 
lexical-binding: t -*-
 ;;
-;; Copyright (C) 1996-1997, 1999, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1996-1997, 1999, 2001-2019 Free Software Foundation,
 ;; Inc.
 ;;
 ;; Author: Per Abrahamsen <address@hidden>
diff --git a/lisp/dabbrev.el b/lisp/dabbrev.el
index 913b23d..2159f96 100644
--- a/lisp/dabbrev.el
+++ b/lisp/dabbrev.el
@@ -1,6 +1,6 @@
 ;;; dabbrev.el --- dynamic abbreviation package  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1985-1986, 1992, 1994, 1996-1997, 2000-2018 Free
+;; Copyright (C) 1985-1986, 1992, 1994, 1996-1997, 2000-2019 Free
 ;; Software Foundation, Inc.
 
 ;; Author: Don Morrison
diff --git a/lisp/delim-col.el b/lisp/delim-col.el
index 076d4dc..a968b32 100644
--- a/lisp/delim-col.el
+++ b/lisp/delim-col.el
@@ -1,6 +1,6 @@
 ;;; delim-col.el --- prettify all columns in a region or rectangle
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Vinicius Jose Latorre <address@hidden>
 ;; Maintainer: Vinicius Jose Latorre <address@hidden>
diff --git a/lisp/delsel.el b/lisp/delsel.el
index 9582272..8f71bc6 100644
--- a/lisp/delsel.el
+++ b/lisp/delsel.el
@@ -1,6 +1,6 @@
 ;;; delsel.el --- delete selection if you insert  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1992, 1997-1998, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1992, 1997-1998, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Matthieu Devin <address@hidden>
diff --git a/lisp/descr-text.el b/lisp/descr-text.el
index 4a6db28..8be2b94 100644
--- a/lisp/descr-text.el
+++ b/lisp/descr-text.el
@@ -1,6 +1,6 @@
 ;;; descr-text.el --- describe text mode  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1994-1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1996, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Boris Goldowsky <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/desktop.el b/lisp/desktop.el
index 1346fa3..97c057e 100644
--- a/lisp/desktop.el
+++ b/lisp/desktop.el
@@ -1,6 +1,6 @@
 ;;; desktop.el --- save partial status of Emacs when killed -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1993-1995, 1997, 2000-2018 Free Software Foundation,
+;; Copyright (C) 1993-1995, 1997, 2000-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Morten Welinder <address@hidden>
@@ -856,6 +856,19 @@ QUOTE may be `may' (value may be quoted),
                                        `',(cdr el) (cdr el)))
                                  pass1)))
         (cons 'may `[,@(mapcar #'cdr pass1)]))))
+    ((and (recordp value) (symbolp (aref value 0)))
+     (let* ((pass1 (let ((res ()))
+                     (dotimes (i (length value))
+                       (push (desktop--v2s (aref value i)) res))
+                     (nreverse res)))
+           (special (assq nil pass1)))
+       (if special
+          (cons nil `(record
+                       ,@(mapcar (lambda (el)
+                                   (if (eq (car el) 'must)
+                                       `',(cdr el) (cdr el)))
+                                 pass1)))
+        (cons 'may (apply #'record (mapcar #'cdr pass1))))))
     ((consp value)
      (let ((p value)
           newlist
@@ -1544,10 +1557,10 @@ and try to load that."
           ;; for the sake of `clean-buffer-list': preserving the invariant
           ;; "how much time the user spent in Emacs without looking at this 
buffer".
           (setq buffer-display-time
-                (if buffer-display-time
-                    (time-add buffer-display-time
-                              (time-subtract nil desktop-file-modtime))
-                  (current-time)))
+               (time-since (if buffer-display-time
+                               (time-subtract desktop-file-modtime
+                                              buffer-display-time)
+                             0)))
          (unless (< desktop-file-version 208) ; Don't misinterpret any old 
custom args
            (dolist (record compacted-vars)
              (let*
diff --git a/lisp/dframe.el b/lisp/dframe.el
index 12cedaf..eebc0bf 100644
--- a/lisp/dframe.el
+++ b/lisp/dframe.el
@@ -1,6 +1,6 @@
 ;;; dframe --- dedicate frame support modes  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: file, tags, tools
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index 9cd7998..b81c0d1 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -1,6 +1,6 @@
 ;;; dired-aux.el --- less commonly used parts of dired -*- lexical-binding: t 
-*-
 
-;; Copyright (C) 1985-1986, 1992, 1994, 1998, 2000-2018 Free Software
+;; Copyright (C) 1985-1986, 1992, 1994, 1998, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Sebastian Kremer <address@hidden>.
@@ -148,7 +148,7 @@ the string of command switches used as the third argument 
of `diff'."
          (read-string "Options for diff: "
                       (if (stringp diff-switches)
                           diff-switches
-                        (mapconcat 'identity diff-switches " ")))))))
+                        (mapconcat #'identity diff-switches " ")))))))
   (let ((current (dired-get-filename t)))
     (when (or (equal (expand-file-name file)
                     (expand-file-name current))
@@ -173,7 +173,7 @@ With prefix arg, prompt for argument SWITCHES which is 
options for `diff'."
        (list (read-string "Options for diff: "
                           (if (stringp diff-switches)
                               diff-switches
-                            (mapconcat 'identity diff-switches " "))))
+                            (mapconcat #'identity diff-switches " "))))
       nil))
   (diff-backup (dired-get-filename) switches))
 
@@ -227,12 +227,12 @@ Examples of PREDICATE:
     (setq file-alist2 (delq (assoc "." file-alist2) file-alist2))
     (setq file-alist2 (delq (assoc ".." file-alist2) file-alist2))
     (setq file-list1 (mapcar
-                     'cadr
+                     #'cadr
                       (dired-file-set-difference
                        file-alist1 file-alist2
                       predicate))
          file-list2 (mapcar
-                     'cadr
+                     #'cadr
                       (dired-file-set-difference
                        file-alist2 file-alist1
                       predicate)))
@@ -491,7 +491,7 @@ Uses the shell command coming from variables `lpr-command' 
and
            lpr-switches))
         (command (dired-mark-read-string
                   "Print %s with: "
-                  (mapconcat 'identity
+                   (mapconcat #'identity
                              (cons lpr-command
                                    (if (stringp lpr-switches)
                                        (list lpr-switches)
@@ -597,7 +597,7 @@ with a prefix argument."
             (possibilities (file-name-all-completions
                             base-versions
                             (file-name-directory fn)))
-            (versions (mapcar 'backup-extract-version possibilities)))
+            (versions (mapcar #'backup-extract-version possibilities)))
        (if versions
            (setq dired-file-version-alist
                  (cons (cons fn versions)
@@ -822,27 +822,28 @@ can be produced by `dired-get-marked-files', for example."
                  retval))
            (lambda (x) (concat cmd-prefix command dired-mark-separator x)))))
     (concat
-     (cond (on-each
-            (format "%s%s"
-                    (mapconcat stuff-it (mapcar 'shell-quote-argument 
file-list)
-                               cmd-sep)
-                    ;; POSIX shells running a list of commands in the 
background
-                    ;; (LIST = cmd_1 & [cmd_2 & ... cmd_i & ... cmd_N &])
-                    ;; return once cmd_N ends, i.e., the shell does not
-                    ;; wait for cmd_i to finish before executing cmd_i+1.
-                    ;; That means, running (shell-command LIST) may not show
-                    ;; the output of all the commands (Bug#23206).
-                    ;; Add 'wait' to force those POSIX shells to wait until
-                    ;; all commands finish.
-                    (or (and parallel-in-background (not w32-shell)
-                             "&wait")
-                        "")))
-           (t
-            (let ((files (mapconcat 'shell-quote-argument
-                                    file-list dired-mark-separator)))
-              (when (cdr file-list)
-                (setq files (concat dired-mark-prefix files 
dired-mark-postfix)))
-              (funcall stuff-it files))))
+     (cond
+      (on-each
+       (format "%s%s"
+               (mapconcat stuff-it (mapcar #'shell-quote-argument file-list)
+                          cmd-sep)
+               ;; POSIX shells running a list of commands in the background
+               ;; (LIST = cmd_1 & [cmd_2 & ... cmd_i & ... cmd_N &])
+               ;; return once cmd_N ends, i.e., the shell does not
+               ;; wait for cmd_i to finish before executing cmd_i+1.
+               ;; That means, running (shell-command LIST) may not show
+               ;; the output of all the commands (Bug#23206).
+               ;; Add 'wait' to force those POSIX shells to wait until
+               ;; all commands finish.
+               (or (and parallel-in-background (not w32-shell)
+                        "&wait")
+                   "")))
+      (t
+       (let ((files (mapconcat #'shell-quote-argument
+                               file-list dired-mark-separator)))
+         (when (cdr file-list)
+           (setq files (concat dired-mark-prefix files dired-mark-postfix)))
+         (funcall stuff-it files))))
      (or (and in-background "&") ""))))
 
 ;; This is an extra function so that it can be redefined by ange-ftp.
@@ -872,7 +873,7 @@ Else returns nil for success."
       (set-buffer err-buffer)
       (erase-buffer)
       (setq default-directory dir      ; caller's default-directory
-           err (not (eq 0 (apply 'process-file program nil t nil arguments))))
+           err (not (eq 0 (apply #'process-file program nil t nil arguments))))
       (if err
          (progn
            (dired-log (concat program " " (prin1-to-string arguments) "\n"))
@@ -1349,7 +1350,7 @@ See Info node `(emacs)Subdir switches' for more details."
           ;; Replace space by old marker without moving point.
           ;; Faster than goto+insdel inside a save-excursion?
           (when char
-            (subst-char-in-region opoint (1+ opoint) ?\040 char)))))
+            (subst-char-in-region opoint (1+ opoint) ?\s char)))))
   (dired-move-to-filename))
 
 ;;;###autoload
@@ -1403,8 +1404,8 @@ files matching `dired-omit-regexp'."
                (catch 'not-found
                  (if (string= directory cur-dir)
                      (progn
-                       (skip-chars-forward "^\r\n")
-                       (if (eq (following-char) ?\r)
+                       (end-of-line)
+                       (if (dired--hidden-p)
                            (dired-unhide-subdir))
                        ;; We are already where we should be, except when
                        ;; point is before the subdir line or its total line.
@@ -1414,7 +1415,7 @@ files matching `dired-omit-regexp'."
                    ;; else try to find correct place to insert
                    (if (dired-goto-subdir directory)
                        (progn ;; unhide if necessary
-                         (if (= (following-char) ?\r)
+                         (if (dired--hidden-p)
                              ;; Point is at end of subdir line.
                              (dired-unhide-subdir))
                          ;; found - skip subdir and `total' line
@@ -1523,7 +1524,7 @@ files matching `dired-omit-regexp'."
                                 (point))
                          (line-beginning-position 2)))
       (setq file (directory-file-name file))
-      (dired-add-entry file (if (eq ?\040 marker) nil marker)))))
+      (dired-add-entry file (if (eq ?\s marker) nil marker)))))
 
 ;;; Copy, move/rename, making hard and symbolic links
 
@@ -2562,7 +2563,7 @@ Optional third arg LIMIT (>= 1) is a limit to the length 
of the
 resulting list.
 Thus, if SEP is a regexp that only matches itself,
 
-   (mapconcat 'identity (dired-split SEP STRING) SEP)
+   (mapconcat #'identity (dired-split SEP STRING) SEP)
 
 is always equal to STRING."
   (let* ((start (string-match pat str))
@@ -2610,7 +2611,7 @@ When called interactively and not on a subdir line, go to 
this subdir's line."
 (defun dired-goto-subdir (dir)
   "Go to end of header line of DIR in this dired buffer.
 Return value of point on success, otherwise return nil.
-The next char is either \\n, or \\r if DIR is hidden."
+The next char is \\n."
   (interactive
    (prog1                              ; let push-mark display its message
        (list (expand-file-name
@@ -2625,8 +2626,8 @@ The next char is either \\n, or \\r if DIR is hidden."
     (and elt
         (goto-char (dired-get-subdir-min elt))
         ;; dired-subdir-hidden-p and dired-add-entry depend on point being
-        ;; at either \r or \n after this function succeeds.
-        (progn (skip-chars-forward "^\r\n")
+        ;; at \n after this function succeeds.
+        (progn (end-of-line)
                (point)))))
 
 ;;;###autoload
@@ -2699,18 +2700,13 @@ Lower levels are unaffected."
 ;;; hiding
 
 (defun dired-unhide-subdir ()
-  (let (buffer-read-only)
-    (subst-char-in-region (dired-subdir-min) (dired-subdir-max) ?\r ?\n)))
-
-(defun dired-hide-check ()
-  (or selective-display
-      (error "selective-display must be t for subdir hiding to work!")))
+  (with-silent-modifications
+    (dired--unhide (dired-subdir-min) (dired-subdir-max))))
 
 (defun dired-subdir-hidden-p (dir)
-  (and selective-display
-       (save-excursion
-        (dired-goto-subdir dir)
-        (= (following-char) ?\r))))
+  (save-excursion
+    (dired-goto-subdir dir)
+    (dired--hidden-p)))
 
 ;;;###autoload
 (defun dired-hide-subdir (arg)
@@ -2718,8 +2714,7 @@ Lower levels are unaffected."
 Optional prefix arg is a repeat factor.
 Use \\[dired-hide-all] to (un)hide all directories."
   (interactive "p")
-  (dired-hide-check)
-  (let ((modflag (buffer-modified-p)))
+  (with-silent-modifications
     (while (>=  (setq arg (1- arg)) 0)
       (let* ((cur-dir (dired-current-directory))
             (hidden-p (dired-subdir-hidden-p cur-dir))
@@ -2728,12 +2723,11 @@ Use \\[dired-hide-all] to (un)hide all directories."
             buffer-read-only)
        ;; keep header line visible, hide rest
        (goto-char (dired-get-subdir-min elt))
-       (skip-chars-forward "^\n\r")
+       (end-of-line)
        (if hidden-p
-           (subst-char-in-region (point) end-pos ?\r ?\n)
-         (subst-char-in-region (point) end-pos ?\n ?\r)))
-      (dired-next-subdir 1 t))
-    (restore-buffer-modified-p modflag)))
+           (dired--unhide (point) end-pos)
+         (dired--hide (point) end-pos)))
+      (dired-next-subdir 1 t))))
 
 ;;;###autoload
 (defun dired-hide-all (&optional ignored)
@@ -2741,28 +2735,20 @@ Use \\[dired-hide-all] to (un)hide all directories."
 If there is already something hidden, make everything visible again.
 Use \\[dired-hide-subdir] to (un)hide a particular subdirectory."
   (interactive "P")
-  (dired-hide-check)
-  (let ((modflag (buffer-modified-p))
-       buffer-read-only)
-    (if (save-excursion
-         (goto-char (point-min))
-         (search-forward "\r" nil t))
-       ;; unhide - bombs on \r in filenames
-       (subst-char-in-region (point-min) (point-max) ?\r ?\n)
+  (with-silent-modifications
+    (if (text-property-any (point-min) (point-max) 'invisible 'dired)
+       (dired--unhide (point-min) (point-max))
       ;; hide
-      (let ((pos (point-max))          ; pos of end of last directory
-           (alist dired-subdir-alist))
-       (while alist                    ; while there are dirs before pos
-         (subst-char-in-region (dired-get-subdir-min (car alist)) ; pos of 
prev dir
-                               (save-excursion
-                                 (goto-char pos) ; current dir
-                                 ;; we're somewhere on current dir's line
-                                 (forward-line -1)
-                                 (point))
-                               ?\n ?\r)
-         (setq pos (dired-get-subdir-min (car alist))) ; prev dir gets current 
dir
-         (setq alist (cdr alist)))))
-    (restore-buffer-modified-p modflag)))
+      (let ((pos (point-max)))         ; pos of end of last directory
+        (dolist (subdir dired-subdir-alist)
+         (let ((start (dired-get-subdir-min subdir)) ; pos of prev dir
+               (end (save-excursion
+                      (goto-char pos) ; current dir
+                      ;; we're somewhere on current dir's line
+                      (forward-line -1)
+                      (point))))
+            (dired--hide start end))
+         (setq pos (dired-get-subdir-min subdir))))))) ; prev dir gets current 
dir
 
 ;;;###end dired-ins.el
 
@@ -2788,8 +2774,8 @@ When off, it uses the original predicate."
   nil nil nil
   (if dired-isearch-filenames-mode
       (add-function :before-while (local 'isearch-filter-predicate)
-                  #'dired-isearch-filter-filenames
-                  '((isearch-message-prefix . "filename ")))
+                    #'dired-isearch-filter-filenames
+                    '((isearch-message-prefix . "filename ")))
     (remove-function (local 'isearch-filter-predicate)
                      #'dired-isearch-filter-filenames))
   (when isearch-mode
@@ -2805,13 +2791,13 @@ Intended to be added to `isearch-mode-hook'."
                 (get-text-property (point) 'dired-filename)))
     (define-key isearch-mode-map "\M-sff" 'dired-isearch-filenames-mode)
     (dired-isearch-filenames-mode 1)
-    (add-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end nil t)))
+    (add-hook 'isearch-mode-end-hook #'dired-isearch-filenames-end nil t)))
 
 (defun dired-isearch-filenames-end ()
   "Clean up the Dired file name search after terminating isearch."
   (define-key isearch-mode-map "\M-sff" nil)
   (dired-isearch-filenames-mode -1)
-  (remove-hook 'isearch-mode-end-hook 'dired-isearch-filenames-end t)
+  (remove-hook 'isearch-mode-end-hook #'dired-isearch-filenames-end t)
   (unless isearch-suspended
     (custom-reevaluate-setting 'dired-isearch-filenames)))
 
@@ -2859,11 +2845,11 @@ is part of a file name (i.e., has the text property 
`dired-filename')."
 Stops when a match is found.
 To continue searching for next match, use command \\[tags-loop-continue]."
   (interactive "sSearch marked files (regexp): ")
-  (multifile-initialize-search
+  (fileloop-initialize-search
    regexp
    (dired-get-marked-files nil nil #'dired-nondirectory-p)
    'default)
-  (multifile-continue))
+  (fileloop-continue))
 
 ;;;###autoload
 (defun dired-do-query-replace-regexp (from to &optional delimited)
@@ -2881,11 +2867,11 @@ with the command \\[tags-loop-continue]."
       (if (and buffer (with-current-buffer buffer
                        buffer-read-only))
          (error "File `%s' is visited read-only" file))))
-  (multifile-initialize-replace
+  (fileloop-initialize-replace
    from to (dired-get-marked-files nil nil #'dired-nondirectory-p)
    (if (equal from (downcase from)) nil 'default)
    delimited)
-  (multifile-continue))
+  (fileloop-continue))
 
 (declare-function xref--show-xrefs "xref")
 (declare-function xref-query-replace-in-results "xref")
@@ -2905,7 +2891,7 @@ REGEXP should use constructs supported by your local 
`grep' command."
   (declare-function rgrep-find-ignored-directories "grep" (dir))
   (let* ((files (dired-get-marked-files nil nil nil nil t))
          (ignores (nconc (mapcar
-                          (lambda (s) (concat s "/"))
+                          #'file-name-as-directory
                           (rgrep-find-ignored-directories default-directory))
                          grep-find-ignored-files))
          (xrefs (mapcan
diff --git a/lisp/dired-x.el b/lisp/dired-x.el
index 6c19863..defc541 100644
--- a/lisp/dired-x.el
+++ b/lisp/dired-x.el
@@ -1,6 +1,6 @@
 ;;; dired-x.el --- extra Dired functionality  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1993-1994, 1997, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1993-1994, 1997, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Sebastian Kremer <address@hidden>
@@ -463,9 +463,11 @@ Interactively with prefix argument, read FILE-NAME."
    (list nil (and current-prefix-arg
                   (read-file-name "Jump to Dired file: "))))
   (cond
-   ((bound-and-true-p archive-subfile-mode)
+   ((and (bound-and-true-p archive-subfile-mode)
+         (buffer-live-p archive-superior-buffer))
     (switch-to-buffer archive-superior-buffer))
-   ((bound-and-true-p tar-subfile-mode)
+   ((and (bound-and-true-p tar-subfile-mode)
+         (buffer-live-p tar-superior-buffer))
     (switch-to-buffer tar-superior-buffer))
    (t
     ;; Expand file-name before `dired-goto-file' call:
diff --git a/lisp/dired.el b/lisp/dired.el
index e5dc862..63082fe 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -1,6 +1,6 @@
 ;;; dired.el --- directory-browsing commands -*- lexical-binding: t -*-
 
-;; Copyright (C) 1985-1986, 1992-1997, 2000-2018 Free Software
+;; Copyright (C) 1985-1986, 1992-1997, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Sebastian Kremer <address@hidden>
@@ -325,7 +325,7 @@ The directory name must be absolute, but need not be fully 
expanded.")
 
 (put 'dired-actual-switches 'safe-local-variable 'dired-safe-switches-p)
 
-(defvar dired-re-inode-size "[0-9  \t]*[.,0-9]*[BkKMGTPEZY]?[ \t]*"
+(defvar dired-re-inode-size "[0-9 \t]*[.,0-9]*[BkKMGTPEZY]?[ \t]*"
   "Regexp for optional initial inode and file size as made by `ls -i -s'.")
 
 ;; These regexps must be tested at beginning-of-line, but are also
@@ -364,12 +364,12 @@ This is an alist of the form (SUBDIR . SWITCHES).")
 (defvaralias 'dired-move-to-filename-regexp
   'directory-listing-before-filename-regexp)
 
-(defvar dired-subdir-regexp "^. \\([^\n\r]+\\)\\(:\\)[\n\r]"
+(defvar dired-subdir-regexp "^. \\(.+\\)\\(:\\)\n"
   "Regexp matching a maybe hidden subdirectory line in `ls -lR' output.
 Subexpression 1 is the subdirectory proper, no trailing colon.
 The match starts at the beginning of the line and ends after the end
-of the line (\\n or \\r).
-Subexpression 2 must end right before the \\n or \\r.")
+of the line.
+Subexpression 2 must end right before the \\n.")
 
 (defgroup dired-faces nil
   "Faces used by Dired."
@@ -548,7 +548,7 @@ Return value is the number of files marked, or nil if none 
were marked."
       (setq count 0)
       (when ,msg
        (message "%s %ss%s..."
-                (cond ((eq dired-marker-char ?\040) "Unmarking")
+                (cond ((eq dired-marker-char ?\s) "Unmarking")
                       ((eq dired-del-marker dired-marker-char)
                        "Flagging")
                       (t "Marking"))
@@ -568,7 +568,7 @@ Return value is the number of files marked, or nil if none 
were marked."
                         count
                         ,msg
                         (dired-plural-s count)
-                        (if (eq dired-marker-char ?\040) "un" "")
+                        (if (eq dired-marker-char ?\s) "un" "")
                         (if (eq dired-marker-char dired-del-marker)
                             "flagged" "marked"))))
     (and (> count 0) count)))
@@ -774,6 +774,15 @@ as an argument to `dired-goto-file'."
          (file-name-as-directory (abbreviate-file-name filename))
        (abbreviate-file-name filename)))))
 
+(defun dired-grep-read-files ()
+  "Use file at point as the file for grep's default file-name pattern 
suggestion.
+If a directory or nothing is found at point, return nil."
+  (let ((file-name (dired-file-name-at-point)))
+    (if (and file-name
+            (not (file-directory-p file-name)))
+       file-name)))
+(put 'dired-mode 'grep-read-files 'dired-grep-read-files)
+
 ;;;###autoload (define-key ctl-x-map "d" 'dired)
 ;;;###autoload
 (defun dired (dirname &optional switches)
@@ -1269,8 +1278,8 @@ If HDR is non-nil, insert a header line with the 
directory name."
         ;; as indicated by `ls-lisp-use-insert-directory-program'.
         (not (and (featurep 'ls-lisp)
                   (null ls-lisp-use-insert-directory-program)))
-         (not (and (featurep 'eshell)
-                   (bound-and-true-p eshell-ls-use-in-dired)))
+         ;; FIXME: Big ugly hack for Eshell's eshell-ls-use-in-dired.
+         (not (bound-and-true-p eshell-ls-use-in-dired))
         (or (file-remote-p dir)
              (if (eq dired-use-ls-dired 'unspecified)
                 ;; Check whether "ls --dired" gives exit code 0, and
@@ -1530,7 +1539,7 @@ change; the point does."
               ;; Sanity check of the point marker.
               (when (and (markerp point)
                          (eq (marker-buffer point) buffer))
-                (unless (and (nth 0 prev)
+                (unless (and (nth 1 prev)
                              (dired-goto-file (nth 1 prev)))
                   (goto-char (point-min))
                  (forward-line (1- (nth 2 prev))))
@@ -1539,9 +1548,8 @@ change; the point does."
 
 (defun dired-remember-marks (beg end)
   "Return alist of files and their marks, from BEG to END."
-  (if selective-display                        ; must unhide to make this work.
-      (let ((inhibit-read-only t))
-       (subst-char-in-region beg end ?\r ?\n)))
+  (if (dired--find-hidden-pos (point-min) (point-max))
+      (dired--unhide (point-min) (point-max))) ;Must unhide to make this work.
   (let (fil chr alist)
     (save-excursion
       (goto-char beg)
@@ -1568,15 +1576,12 @@ Each element of ALIST looks like (FILE . MARKERCHAR)."
 
 (defun dired-remember-hidden ()
   "Return a list of names of subdirs currently hidden."
-  (let ((l dired-subdir-alist) dir pos result)
-    (while l
-      (setq dir (car (car l))
-           pos (cdr (car l))
-           l (cdr l))
+  (let (result)
+    (pcase-dolist (`(,dir . ,pos) dired-subdir-alist)
       (goto-char pos)
-      (skip-chars-forward "^\r\n")
-      (if (eq (following-char) ?\r)
-         (setq result (cons dir result))))
+      (end-of-line)
+      (if (dired--hidden-p)
+         (push dir result)))
     result))
 
 (defun dired-insert-old-subdirs (old-subdir-alist)
@@ -1747,7 +1752,7 @@ Do so according to the former subdir alist 
OLD-SUBDIR-ALIST."
 
     ;; Make menu bar items.
 
-    ;; No need to fo this, now that top-level items are fewer.
+    ;; No need to do this, now that top-level items are fewer.
     ;;;;
     ;; Get rid of the Edit menu bar item to save space.
     ;(define-key map [menu-bar edit] 'undefined)
@@ -2135,9 +2140,9 @@ Keybindings:
        mode-name "Dired"
        ;; case-fold-search nil
        buffer-read-only t
-       selective-display t             ; for subdirectory hiding
        mode-line-buffer-identification
        (propertized-buffer-identification "%17b"))
+  (add-to-invisibility-spec '(dired . t))
   ;; Ignore dired-hide-details-* value of invisible text property by default.
   (when (eq buffer-invisibility-spec t)
     (setq buffer-invisibility-spec (list t)))
@@ -2160,8 +2165,8 @@ Keybindings:
   (when (featurep 'dnd)
     (setq-local dnd-protocol-alist
                 (append dired-dnd-protocol-alist dnd-protocol-alist)))
-  (add-hook 'file-name-at-point-functions 'dired-file-name-at-point nil t)
-  (add-hook 'isearch-mode-hook 'dired-isearch-filenames-setup nil t)
+  (add-hook 'file-name-at-point-functions #'dired-file-name-at-point nil t)
+  (add-hook 'isearch-mode-hook #'dired-isearch-filenames-setup nil t)
   (run-mode-hooks 'dired-mode-hook))
 
 ;; Idiosyncratic dired commands that don't deal with marks.
@@ -2266,7 +2271,8 @@ directory in another window."
        (error "File no longer exists; type `g' to update Dired buffer")))))
 
 ;; Force C-m keybinding rather than `f' or `e' in the mode doc:
-(define-obsolete-function-alias 'dired-advertised-find-file 'dired-find-file 
"23.2")
+(define-obsolete-function-alias 'dired-advertised-find-file
+  #'dired-find-file "23.2")
 (defun dired-find-file ()
   "In Dired, visit the file or directory named on this line."
   (interactive)
@@ -2514,6 +2520,34 @@ See options: `dired-hide-details-hide-symlink-targets' 
and
             'remove-from-invisibility-spec)
           'dired-hide-details-link))
 
+;;; Functions to hide/unhide text
+
+(defun dired--find-hidden-pos (start end)
+  (text-property-any start end 'invisible 'dired))
+
+(defun dired--hidden-p (&optional pos)
+  (eq (get-char-property (or pos (point)) 'invisible) 'dired))
+
+(defun dired--hide (start end)
+  ;; The old code used selective-display which only works at
+  ;; a line-granularity, so it used start and end positions that where
+  ;; approximate ("anywhere on the line is fine").
+  (save-excursion
+    (put-text-property (progn (goto-char start) (line-end-position))
+                       (progn (goto-char end) (line-end-position))
+                       'invisible 'dired)))
+
+(defun dired--unhide (start end)
+  ;; The old code used selective-display which only works at
+  ;; a line-granularity, so it used start and end positions that where
+  ;; approximate ("anywhere on the line is fine").
+  ;; FIXME: This also removes other invisible properties!
+  (save-excursion
+    (remove-text-properties
+     (progn (goto-char start) (line-end-position))
+     (progn (goto-char end) (line-end-position))
+     '(invisible))))
+
 ;;; Functions for finding the file name in a dired buffer line.
 
 (defvar dired-permission-flags-regexp
@@ -2553,12 +2587,11 @@ Return the position of the beginning of the filename, 
or nil if none found."
   ;; This is the UNIX version.
   (if (get-text-property (point) 'dired-filename)
       (goto-char (next-single-property-change (point) 'dired-filename))
-    (let (opoint file-type executable symlink hidden used-F eol)
-      (setq used-F (dired-check-switches dired-actual-switches "F" "classify")
-           opoint (point)
-           eol (line-end-position)
-           hidden (and selective-display
-                       (save-excursion (search-forward "\r" eol t))))
+    (let ((opoint (point))
+          (used-F (dired-check-switches dired-actual-switches "F" "classify"))
+          (eol (line-end-position))
+          (hidden (dired--hidden-p))
+          file-type executable symlink)
       (if hidden
          nil
        (save-excursion ;; Find out what kind of file this is:
@@ -2795,7 +2828,7 @@ You can then feed the file name(s) to other commands with 
\\[yank]."
     (if pos
        (progn
          (goto-char pos)
-         (or no-skip (skip-chars-forward "^\n\r"))
+         (or no-skip (end-of-line))
          (point))
       (if no-error-if-not-found
          nil                           ; return nil if not found
@@ -3187,17 +3220,17 @@ non-empty directories is allowed."
   (dired-move-to-filename))
 
 (defun dired-fun-in-all-buffers (directory file fun &rest args)
-  ;; In all buffers dired'ing DIRECTORY, run FUN with ARGS.
-  ;; If the buffer has a wildcard pattern, check that it matches FILE.
-  ;; (FILE does not include a directory component.)
-  ;; FILE may be nil, in which case ignore it.
-  ;; Return list of buffers where FUN succeeded (i.e., returned non-nil).
+  "In all buffers dired'ing DIRECTORY, run FUN with ARGS.
+If the buffer has a wildcard pattern, check that it matches FILE.
+(FILE does not include a directory component.)
+FILE may be nil, in which case ignore it.
+Return list of buffers where FUN succeeded (i.e., returned non-nil)."
   (let (success-list)
-    (dolist (buf (dired-buffers-for-dir (expand-file-name directory)
-                                       file))
+    (dolist (buf (dired-buffers-for-dir (expand-file-name directory) file))
       (with-current-buffer buf
        (if (apply fun args)
-           (setq success-list (cons (buffer-name buf) success-list)))))
+           (push buf success-list))))
+    ;; FIXME: AFAICT, this return value is not used by any of the callers!
     success-list))
 
 ;; Delete the entry for FILE from
@@ -3430,7 +3463,7 @@ no ARGth marked file is found before this line."
     (and (dired-goto-file file)
         (progn
           (beginning-of-line)
-          (if (not (equal ?\040 (following-char)))
+          (if (not (equal ?\s (following-char)))
               (following-char))))))
 
 (defun dired-mark-files-in-region (start end)
@@ -3488,7 +3521,7 @@ If looking at a subdir, unmark all its files except `.' 
and `..'.
 If the region is active in Transient Mark mode, unmark all files
 in the active region."
   (interactive (list current-prefix-arg t))
-  (let ((dired-marker-char ?\040))
+  (let ((dired-marker-char ?\s))
     (dired-mark arg interactive)))
 
 (defun dired-flag-file-deletion (arg &optional interactive)
@@ -3527,11 +3560,11 @@ As always, hidden subdirs are not affected."
             ;; use subst instead of insdel because it does not move
             ;; the gap and thus should be faster and because
             ;; other characters are left alone automatically
-            (apply 'subst-char-in-region
+            (apply #'subst-char-in-region
                    (point) (1+ (point))
-                   (if (eq ?\040 (following-char)) ; SPC
-                       (list ?\040 dired-marker-char)
-                     (list dired-marker-char ?\040))))
+                   (if (eq ?\s (following-char))
+                       (list ?\s dired-marker-char)
+                     (list dired-marker-char ?\s))))
         (forward-line 1)))))
 
 ;;; Commands to mark or flag files based on their characteristics or names.
@@ -3562,7 +3595,7 @@ object files--just `.o' will mark more than you might 
think."
                                                      (dired-get-filename nil 
t) t))
                                                    "\\'"))))
                       'dired-regexp-history)
-        (if current-prefix-arg ?\040)))
+        (if current-prefix-arg ?\s)))
   (let ((dired-marker-char (or marker-char dired-marker-char)))
     (dired-mark-if
      (and (not (looking-at-p dired-re-dot))
@@ -3585,7 +3618,7 @@ since it was last visited."
    (list (read-regexp (concat (if current-prefix-arg "Unmark" "Mark")
                               " files containing (regexp): ")
                       nil 'dired-regexp-history)
-        (if current-prefix-arg ?\040)))
+        (if current-prefix-arg ?\s)))
   (let ((dired-marker-char (or marker-char dired-marker-char)))
     (dired-mark-if
      (and (not (looking-at-p dired-re-dot))
@@ -3622,14 +3655,14 @@ The match is against the non-directory part of the 
filename.  Use `^'
   "Mark all symbolic links.
 With prefix argument, unmark or unflag all those files."
   (interactive "P")
-  (let ((dired-marker-char (if unflag-p ?\040 dired-marker-char)))
+  (let ((dired-marker-char (if unflag-p ?\s dired-marker-char)))
     (dired-mark-if (looking-at-p dired-re-sym) "symbolic link")))
 
 (defun dired-mark-directories (unflag-p)
   "Mark all directory file lines except `.' and `..'.
 With prefix argument, unmark or unflag all those files."
   (interactive "P")
-  (let ((dired-marker-char (if unflag-p ?\040 dired-marker-char)))
+  (let ((dired-marker-char (if unflag-p ?\s dired-marker-char)))
     (dired-mark-if (and (looking-at-p dired-re-dir)
                        (not (looking-at-p dired-re-dot)))
                   "directory file")))
@@ -3638,7 +3671,7 @@ With prefix argument, unmark or unflag all those files."
   "Mark all executable files.
 With prefix argument, unmark or unflag all those files."
   (interactive "P")
-  (let ((dired-marker-char (if unflag-p ?\040 dired-marker-char)))
+  (let ((dired-marker-char (if unflag-p ?\s dired-marker-char)))
     (dired-mark-if (looking-at-p dired-re-exe) "executable file")))
 
 ;; dired-x.el has a dired-mark-sexp interactive command: mark
@@ -3648,7 +3681,7 @@ With prefix argument, unmark or unflag all those files."
   "Flag for deletion files whose names suggest they are auto save files.
 A prefix argument says to unmark or unflag those files instead."
   (interactive "P")
-  (let ((dired-marker-char (if unflag-p ?\040 dired-del-marker)))
+  (let ((dired-marker-char (if unflag-p ?\s dired-del-marker)))
     (dired-mark-if
      ;; It is less than general to check for # here,
      ;; but it's the only way this runs fast enough.
@@ -3887,7 +3920,7 @@ The idea is to set this buffer-locally in special Dired 
buffers.")
     (force-mode-line-update)))
 
 (define-obsolete-function-alias 'dired-sort-set-modeline
-  'dired-sort-set-mode-line "24.3")
+  #'dired-sort-set-mode-line "24.3")
 
 (defun dired-sort-toggle-or-edit (&optional arg)
   "Toggle sorting by date, and refresh the Dired buffer.
@@ -4129,7 +4162,7 @@ Ask means pop up a menu for the user to select one of 
copy, move or link."
           (dired dired-dir)
           ;; The following elements of `misc-data' are the keys
           ;; from `dired-subdir-alist'.
-          (mapc 'dired-maybe-insert-subdir (cdr misc-data))
+          (mapc #'dired-maybe-insert-subdir (cdr misc-data))
           (current-buffer))
       (message "Desktop: Directory %s no longer exists." dir)
       (when desktop-missing-file-warning (sit-for 1))
diff --git a/lisp/dirtrack.el b/lisp/dirtrack.el
index 862268d..0925a4d 100644
--- a/lisp/dirtrack.el
+++ b/lisp/dirtrack.el
@@ -1,6 +1,6 @@
 ;;; dirtrack.el --- Directory Tracking by watching the prompt
 
-;; Copyright (C) 1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Peter Breton <address@hidden>
 ;; Created: Sun Nov 17 1996
diff --git a/lisp/disp-table.el b/lisp/disp-table.el
index 95224f2..4a59750 100644
--- a/lisp/disp-table.el
+++ b/lisp/disp-table.el
@@ -1,6 +1,6 @@
 ;;; disp-table.el --- functions for dealing with char tables
 
-;; Copyright (C) 1987, 1994-1995, 1999, 2001-2018 Free Software
+;; Copyright (C) 1987, 1994-1995, 1999, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Erik Naggum <address@hidden>
@@ -175,8 +175,8 @@ in the default way after this call."
 (defun standard-display-g1 (c sc)
   "Display character C as character SC in the g1 character set.
 This function assumes that your terminal uses the SO/SI characters;
-it is meaningless for an X frame."
-  (if (memq window-system '(x w32 ns))
+it is meaningless for a graphical frame."
+  (if (display-graphic-p)
       (error "Cannot use string glyphs in a windowing system"))
   (or standard-display-table
       (setq standard-display-table (make-display-table)))
@@ -186,9 +186,9 @@ it is meaningless for an X frame."
 ;;;###autoload
 (defun standard-display-graphic (c gc)
   "Display character C as character GC in graphics character set.
-This function assumes VT100-compatible escapes; it is meaningless for an
-X frame."
-  (if (memq window-system '(x w32 ns))
+This function assumes VT100-compatible escapes; it is meaningless
+for a graphical frame."
+  (if (display-graphic-p)
       (error "Cannot use string glyphs in a windowing system"))
   (or standard-display-table
       (setq standard-display-table (make-display-table)))
@@ -276,7 +276,7 @@ in `.emacs'."
       (progn
        (standard-display-default
         (unibyte-char-to-multibyte 160) (unibyte-char-to-multibyte 255))
-       (unless (or (memq window-system '(x w32 ns)))
+       (unless (display-graphic-p)
          (and (terminal-coding-system)
               (set-terminal-coding-system nil))))
 
@@ -289,7 +289,7 @@ in `.emacs'."
     ;; unless some other has been specified.
     (if (equal current-language-environment "English")
        (set-language-environment "latin-1"))
-    (unless (or noninteractive (memq window-system '(x w32 ns)))
+    (unless (or noninteractive (display-graphic-p))
       ;; Send those codes literally to a character-based terminal.
       ;; If we are using single-byte characters,
       ;; it doesn't matter which coding system we use.
diff --git a/lisp/display-line-numbers.el b/lisp/display-line-numbers.el
index 3569b84..d38f2e6 100644
--- a/lisp/display-line-numbers.el
+++ b/lisp/display-line-numbers.el
@@ -1,6 +1,6 @@
 ;;; display-line-numbers.el --- interface for display-line-numbers -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: convenience
diff --git a/lisp/dnd.el b/lisp/dnd.el
index 0c94c8b..459a723 100644
--- a/lisp/dnd.el
+++ b/lisp/dnd.el
@@ -1,6 +1,6 @@
 ;;; dnd.el --- drag and drop support
 
-;; Copyright (C) 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005-2019 Free Software Foundation, Inc.
 
 ;; Author: Jan Djärv <address@hidden>
 ;; Maintainer: address@hidden
@@ -130,6 +130,7 @@ Return nil if URI is not a local file."
                         (match-string 0 sysname)
                       sysname))))
       (when (and hostname
+                 (not (eq system-type 'windows-nt))
                 (or (string-equal "localhost" hostname)
                     (string-equal (downcase sysname) hostname)
                     (string-equal sysname-no-dot hostname)))
diff --git a/lisp/doc-view.el b/lisp/doc-view.el
index 48d0c08..a706907 100644
--- a/lisp/doc-view.el
+++ b/lisp/doc-view.el
@@ -1,6 +1,6 @@
 ;;; doc-view.el --- View PDF/PostScript/DVI files in Emacs -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Tassilo Horn <address@hidden>
 ;; Maintainer: Tassilo Horn <address@hidden>
@@ -155,12 +155,13 @@
 
 (defcustom doc-view-ghostscript-program "gs"
   "Program to convert PS and PDF files to PNG."
-  :type 'file
-  :group 'doc-view)
+  :type 'file)
 
 (defcustom doc-view-pdfdraw-program
   (cond
    ((executable-find "pdfdraw") "pdfdraw")
+   ((executable-find "mudraw") "mudraw")
+   ((executable-find "mutool") "mutool")
    (t "mudraw"))
   "Name of MuPDF's program to convert PDF files to PNG."
   :type 'file
@@ -182,17 +183,20 @@
 (defcustom doc-view-ghostscript-options
   '("-dSAFER" ;; Avoid security problems when rendering files from untrusted
     ;; sources.
-    "-dNOPAUSE" "-sDEVICE=png16m" "-dTextAlphaBits=4"
+    "-dNOPAUSE" "-dTextAlphaBits=4"
     "-dBATCH" "-dGraphicsAlphaBits=4" "-dQUIET")
   "A list of options to give to ghostscript."
-  :type '(repeat string)
-  :group 'doc-view)
+  :type '(repeat string))
+
+(defcustom doc-view-ghostscript-device "png16m"
+  "Output device to give to ghostscript."
+  :type 'string
+  :version "27.1")
 
 (defcustom doc-view-resolution 100
   "Dots per inch resolution used to render the documents.
 Higher values result in larger images."
-  :type 'number
-  :group 'doc-view)
+  :type 'number)
 
 (defcustom doc-view-scale-internally t
   "Whether we should try to rescale images ourselves.
@@ -207,8 +211,7 @@ scaling."
 Has only an effect if `doc-view-scale-internally' is non-nil and support for
 scaling is compiled into emacs."
   :version "24.1"
-  :type 'number
-  :group 'doc-view)
+  :type 'number)
 
 (defcustom doc-view-dvipdfm-program "dvipdfm"
   "Program to convert DVI files to PDF.
@@ -218,8 +221,7 @@ converted to PNG.
 
 If this and `doc-view-dvipdf-program' are set,
 `doc-view-dvipdf-program' will be preferred."
-  :type 'file
-  :group 'doc-view)
+  :type 'file)
 
 (defcustom doc-view-dvipdf-program "dvipdf"
   "Program to convert DVI files to PDF.
@@ -229,8 +231,7 @@ converted to PNG.
 
 If this and `doc-view-dvipdfm-program' are set,
 `doc-view-dvipdf-program' will be preferred."
-  :type 'file
-  :group 'doc-view)
+  :type 'file)
 
 (define-obsolete-variable-alias 'doc-view-unoconv-program
                                 'doc-view-odf->pdf-converter-program
@@ -245,8 +246,7 @@ If this and `doc-view-dvipdfm-program' are set,
 
 Needed for viewing OpenOffice.org (and MS Office) files."
   :version "24.4"
-  :type 'file
-  :group 'doc-view)
+  :type 'file)
 
 (defcustom doc-view-odf->pdf-converter-function
   (cond
@@ -267,22 +267,19 @@ Needed for viewing OpenOffice.org (and MS Office) files."
   "Program to convert PS files to PDF.
 
 PS files will be converted to PDF before searching is possible."
-  :type 'file
-  :group 'doc-view)
+  :type 'file)
 
 (defcustom doc-view-pdftotext-program "pdftotext"
   "Program to convert PDF files to plain text.
 
 Needed for searching."
-  :type 'file
-  :group 'doc-view)
+  :type 'file)
 
 (defcustom doc-view-cache-directory
   (expand-file-name (format "docview%d" (user-uid))
                    temporary-file-directory)
   "The base directory, where the PNG images will be saved."
-  :type 'directory
-  :group 'doc-view)
+  :type 'directory)
 
 (defvar doc-view-conversion-buffer " *doc-view conversion output*"
   "The buffer where messages from the converter programs go to.")
@@ -293,8 +290,7 @@ After such a refresh newly converted pages will be 
available for
 viewing.  If set to nil there won't be any refreshes and the
 pages won't be displayed before conversion of the whole document
 has finished."
-  :type 'integer
-  :group 'doc-view)
+  :type 'integer)
 
 (defcustom doc-view-continuous nil
   "In Continuous mode reaching the page edge advances to next/previous page.
@@ -302,7 +298,6 @@ When non-nil, scrolling a line upward at the bottom edge of 
the page
 moves to the next page, and scrolling a line downward at the top edge
 of the page moves to the previous page."
   :type 'boolean
-  :group 'doc-view
   :version "23.2")
 
 ;;;; Internal Variables
@@ -412,6 +407,7 @@ Typically \"page-%s.png\".")
     (define-key map "W"               'doc-view-fit-width-to-window)
     (define-key map "H"               'doc-view-fit-height-to-window)
     (define-key map "P"               'doc-view-fit-page-to-window)
+    (define-key map "F"               'doc-view-fit-window-to-page) ;F = frame
     ;; Killing the buffer (and the process)
     (define-key map (kbd "K")         'doc-view-kill-proc)
     ;; Slicing the image
@@ -429,22 +425,20 @@ Typically \"page-%s.png\".")
     (define-key map (kbd "C-c C-c")   'doc-view-toggle-display)
     ;; Open a new buffer with doc's text contents
     (define-key map (kbd "C-c C-t")   'doc-view-open-text)
-    ;; Reconvert the current document.  Don't just use revert-buffer
-    ;; because that resets the scale factor, the page number, ...
-    (define-key map (kbd "g")         'doc-view-revert-buffer)
-    (define-key map (kbd "r")         'doc-view-revert-buffer)
+    (define-key map (kbd "r")         'revert-buffer)
     map)
   "Keymap used by `doc-view-mode' when displaying a doc as a set of images.")
 
-(defun doc-view-revert-buffer (&optional ignore-auto noconfirm)
-  "Like `revert-buffer', but preserves the buffer's current modes."
-  (interactive (list (not current-prefix-arg)))
+(define-obsolete-function-alias 'doc-view-revert-buffer #'revert-buffer "27.1")
+(defvar revert-buffer-preserve-modes)
+(defun doc-view--revert-buffer (orig-fun &rest args)
+  "Preserve the buffer's current mode and check PDF sanity."
   (if (< undo-outer-limit (* 2 (buffer-size)))
       ;; It's normal for this operation to result in a very large undo entry.
       (setq-local undo-outer-limit (* 2 (buffer-size))))
   (cl-labels ((revert ()
-                      (let (revert-buffer-function)
-                        (revert-buffer ignore-auto noconfirm 
'preserve-modes))))
+                      (let ((revert-buffer-preserve-modes t))
+                        (apply orig-fun args))))
     (if (and (eq 'pdf doc-view-doc-type)
              (executable-find "pdfinfo"))
         ;; We don't want to revert if the PDF file is corrupted which
@@ -492,6 +486,8 @@ Typically \"page-%s.png\".")
 
 ;;;; Navigation Commands
 
+;; FIXME: The doc-view-current-* definitions below are macros because they
+;; map to accessors which we want to use via `setf' as well!
 (defmacro doc-view-current-page (&optional win)
   `(image-mode-window-get 'page ,win))
 (defmacro doc-view-current-info () '(image-mode-window-get 'info))
@@ -683,7 +679,7 @@ at the top edge of the page moves to the previous page."
        (file-error
        (error
         (format "Unable to use temporary directory %s: %s"
-                dir (mapconcat 'identity (cdr error) " "))))))))
+                dir (mapconcat #'identity (cdr error) " "))))))))
 
 (defun doc-view--current-cache-dir ()
   "Return the directory where the png files of the current doc should be saved.
@@ -872,6 +868,38 @@ min {(window-width / image-width), (window-height / 
image-height)} times."
         (setf (doc-view-current-slice) new-slice)
         (doc-view-goto-page (doc-view-current-page))))))
 
+(defun doc-view-fit-window-to-page ()
+  "Resize selected window so it just fits the current page.
+Resize the containing frame if needed."
+  (interactive)
+  (let* ((slice (doc-view-current-slice))
+         (img-width  (if slice (nth 2 slice)
+                       (car (image-display-size
+                             (image-get-display-property) t))))
+         (img-height (if slice (nth 3 slice)
+                       (cdr (image-display-size
+                             (image-get-display-property) t))))
+         (win-width  (- (nth 2 (window-inside-pixel-edges))
+                        (nth 0 (window-inside-pixel-edges))))
+         (win-height (- (nth 3 (window-inside-pixel-edges))
+                        (nth 1 (window-inside-pixel-edges))))
+         (width-diff  (- img-width  win-width))
+         (height-diff (- img-height win-height))
+         (new-frame-params
+          (append
+           (if (= (window-width) (frame-width))
+               `((width  . (text-pixels
+                            . ,(+ (frame-text-width) width-diff))))
+             (enlarge-window (/ width-diff (frame-char-width)) 'horiz)
+             nil)
+           (if (= (window-height) (frame-height))
+               `((height  . (text-pixels
+                             . ,(+ (frame-text-height) height-diff))))
+             (enlarge-window (/ height-diff (frame-char-height)) nil)
+             nil))))
+    (when new-frame-params
+      (modify-frame-parameters (selected-frame) new-frame-params))))
+
 (defun doc-view-reconvert-doc ()
   "Reconvert the current document.
 Should be invoked when the cached images aren't up-to-date."
@@ -906,7 +934,7 @@ Should be invoked when the cached images aren't up-to-date."
   (let* ((default-directory (or (unhandled-file-name-directory
                                  default-directory)
                              (expand-file-name "~/")))
-         (proc (apply 'start-process name doc-view-conversion-buffer
+         (proc (apply #'start-process name doc-view-conversion-buffer
                       program args)))
     (push proc doc-view--current-converter-processes)
     (setq mode-line-process (list (format ":%s" proc)))
@@ -927,16 +955,31 @@ Should be invoked when the cached images aren't 
up-to-date."
                            (list "-o" pdf dvi)
                            callback)))
 
+(defun doc-view-pdf-password-protected-ghostscript-p (pdf)
+  "Return non-nil if a PDF file is password-protected.
+The test is performed using `doc-view-ghostscript-program'."
+  (with-temp-buffer
+    (apply #'call-process doc-view-ghostscript-program nil (current-buffer)
+           nil `(,@doc-view-ghostscript-options
+                 "-sNODISPLAY"
+                 ,pdf))
+    (goto-char (point-min))
+    (search-forward "This file requires a password for access." nil t)))
+
 (defun doc-view-pdf->png-converter-ghostscript (pdf png page callback)
-  (doc-view-start-process
-   "pdf/ps->png" doc-view-ghostscript-program
-   `(,@doc-view-ghostscript-options
-     ,(format "-r%d" (round doc-view-resolution))
-     ,@(if page `(,(format "-dFirstPage=%d" page)))
-     ,@(if page `(,(format "-dLastPage=%d" page)))
-     ,(concat "-sOutputFile=" png)
-     ,pdf)
-   callback))
+  (let ((pdf-passwd (if (doc-view-pdf-password-protected-ghostscript-p pdf)
+                        (read-passwd "Enter password for PDF file: "))))
+    (doc-view-start-process
+     "pdf/ps->png" doc-view-ghostscript-program
+     `(,@doc-view-ghostscript-options
+       ,(concat "-sDEVICE=" doc-view-ghostscript-device)
+       ,(format "-r%d" (round doc-view-resolution))
+       ,@(if page `(,(format "-dFirstPage=%d" page)))
+       ,@(if page `(,(format "-dLastPage=%d" page)))
+       ,@(if pdf-passwd `(,(format "-sPDFPassword=%s" pdf-passwd)))
+       ,(concat "-sOutputFile=" png)
+       ,pdf)
+     callback)))
 
 (defalias 'doc-view-ps->png-converter-ghostscript
   'doc-view-pdf->png-converter-ghostscript)
@@ -957,14 +1000,36 @@ If PAGE is nil, convert the whole document."
      ,tiff)
    callback))
 
+(defun doc-view-pdfdraw-program-subcommand ()
+  "Return the mutool subcommand replacing mudraw.
+Recent MuPDF distributions replaced 'mudraw' with 'mutool draw'."
+  (when (string-match "mutool[^/\\]*$" doc-view-pdfdraw-program)
+    '("draw")))
+
+(defun doc-view-pdf-password-protected-pdfdraw-p (pdf)
+  "Return non-nil if a PDF file is password-protected.
+The test is performed using `doc-view-pdfdraw-program'."
+  (with-temp-buffer
+    (apply #'call-process doc-view-pdfdraw-program nil (current-buffer) nil
+           `(,@(doc-view-pdfdraw-program-subcommand)
+             ,(concat "-o" null-device)
+             ;; In case PDF isn't password-protected, "draw" only one page.
+             ,pdf "1"))
+    (goto-char (point-min))
+    (search-forward "error: cannot authenticate password" nil t)))
+
 (defun doc-view-pdf->png-converter-mupdf (pdf png page callback)
-  (doc-view-start-process
-   "pdf->png" doc-view-pdfdraw-program
-   `(,(concat "-o" png)
-     ,(format "-r%d" (round doc-view-resolution))
-     ,pdf
-     ,@(if page `(,(format "%d" page))))
-   callback))
+  (let ((pdf-passwd (if (doc-view-pdf-password-protected-pdfdraw-p pdf)
+                        (read-passwd "Enter password for PDF file: "))))
+    (doc-view-start-process
+     "pdf->png" doc-view-pdfdraw-program
+     `(,@(doc-view-pdfdraw-program-subcommand)
+       ,(concat "-o" png)
+       ,(format "-r%d" (round doc-view-resolution))
+       ,@(if pdf-passwd `("-p" ,pdf-passwd))
+       ,pdf
+       ,@(if page `(,(format "%d" page))))
+     callback)))
 
 (defun doc-view-odf->pdf-converter-unoconv (odf callback)
   "Convert ODF to PDF asynchronously and call CALLBACK when finished.
@@ -1217,7 +1282,8 @@ dragging it to its bottom-right corner.  See also
     (save-match-data
       (when (string-match (concat "%%BoundingBox: "
                                  "\\([[:digit:]]+\\) \\([[:digit:]]+\\) "
-                                 "\\([[:digit:]]+\\) \\([[:digit:]]+\\)") o)
+                                 "\\([[:digit:]]+\\) \\([[:digit:]]+\\)")
+                          o)
        (mapcar #'string-to-number
                (list (match-string 1 o)
                      (match-string 2 o)
@@ -1301,10 +1367,10 @@ ARGS is a list of image descriptors."
       (let* ((image (if (and file (file-readable-p file))
                        (if (not (and doc-view-scale-internally
                                      (fboundp 'imagemagick-types)))
-                           (apply 'create-image file doc-view--image-type nil 
args)
+                           (apply #'create-image file doc-view--image-type nil 
args)
                          (unless (member :width args)
                            (setq args `(,@args :width ,doc-view-image-width)))
-                         (apply 'create-image file 'imagemagick nil args))))
+                         (apply #'create-image file 'imagemagick nil args))))
             (slice (doc-view-current-slice))
             (img-width (and image (car (image-size image))))
             (displayed-img-width (if (and image slice)
@@ -1410,6 +1476,14 @@ For now these keys are useful:
   (interactive)
   (tooltip-show (doc-view-current-info)))
 
+;; We define an own major mode for DocView's text display so that we
+;; can easily distinguish when we want to toggle back because
+;; text-mode is a likely candidate for a default major-mode
+;; (bug#34451).
+(define-derived-mode doc-view--text-view-mode text-mode "DV/Text"
+  "View mode used in DocView's text buffers."
+  (view-mode))
+
 (defun doc-view-open-text ()
   "Display the current doc's contents as text."
   (interactive)
@@ -1421,15 +1495,22 @@ For now these keys are useful:
                (buffer-undo-list t)
                (dv-bfn doc-view--buffer-file-name))
            (erase-buffer)
+            ;; FIXME: Replacing the buffer's PDF content with its txt rendering
+            ;; is pretty risky.  We should probably use *another*
+            ;; buffer instead, so there's much less risk of
+            ;; overwriting the PDF file with some text rendering.
            (set-buffer-multibyte t)
            (insert-file-contents txt)
-           (text-mode)
+           (doc-view--text-view-mode)
            (setq-local doc-view--buffer-file-name dv-bfn)
            (set-buffer-modified-p nil)
            (doc-view-minor-mode)
            (add-hook 'write-file-functions
                      (lambda ()
-                       (when (eq major-mode 'text-mode)
+                        ;; FIXME: If the user changes major mode and then
+                        ;; saves the buffer, the PDF file will be clobbered
+                        ;; with its txt rendering!
+                       (when (eq major-mode 'doc-view--text-view-mode)
                          (error "Cannot save text contents of document %s"
                                 buffer-file-name)))
                      nil t))
@@ -1453,7 +1534,7 @@ For now these keys are useful:
     ;; normal mode.
     (doc-view-fallback-mode)
     (doc-view-minor-mode 1))
-   ((eq major-mode 'text-mode)
+   ((eq major-mode 'doc-view--text-view-mode)
     (let ((buffer-undo-list t))
       ;; We're currently viewing the document's text contents, so switch
       ;; back to .
@@ -1725,7 +1806,7 @@ If BACKWARD is non-nil, jump to the previous match."
       ;; window-parameters in the window-state(s) and then restoring this
       ;; window-state should call us back (to interpret/use those parameters).
       (doc-view-goto-page page)
-      (when slice (apply 'doc-view-set-slice slice))
+      (when slice (apply #'doc-view-set-slice slice))
       (current-buffer))))
 
 (add-to-list 'desktop-buffer-mode-handlers
@@ -1789,22 +1870,22 @@ toggle between displaying the document or editing it as 
text.
     (when (not (string= doc-view--buffer-file-name buffer-file-name))
       (write-region nil nil doc-view--buffer-file-name))
 
-    (setq-local revert-buffer-function #'doc-view-revert-buffer)
+    (add-function :around (local 'revert-buffer-function) 
#'doc-view--revert-buffer)
 
     (add-hook 'change-major-mode-hook
              (lambda ()
                (doc-view-kill-proc)
                (remove-overlays (point-min) (point-max) 'doc-view t))
              nil t)
-    (add-hook 'clone-indirect-buffer-hook 'doc-view-clone-buffer-hook nil t)
-    (add-hook 'kill-buffer-hook 'doc-view-kill-proc nil t)
-    (setq-local desktop-save-buffer 'doc-view-desktop-save-buffer)
+    (add-hook 'clone-indirect-buffer-hook #'doc-view-clone-buffer-hook nil t)
+    (add-hook 'kill-buffer-hook #'doc-view-kill-proc nil t)
+    (setq-local desktop-save-buffer #'doc-view-desktop-save-buffer)
 
     (remove-overlays (point-min) (point-max) 'doc-view t) ;Just in case.
     ;; Keep track of display info ([vh]scroll, page number, overlay,
     ;; ...)  for each window in which this document is shown.
     (add-hook 'image-mode-new-window-functions
-             'doc-view-new-window-function nil t)
+             #'doc-view-new-window-function nil t)
     (image-mode-setup-winprops)
 
     (setq-local mode-line-position
@@ -1820,7 +1901,7 @@ toggle between displaying the document or editing it as 
text.
                     #'doc-view-scroll-down-or-previous-page))
     (setq-local cursor-type nil)
     (use-local-map doc-view-mode-map)
-    (add-hook 'after-revert-hook 'doc-view-reconvert-doc nil t)
+    (add-hook 'after-revert-hook #'doc-view-reconvert-doc nil t)
     (setq-local bookmark-make-record-function
                 #'doc-view-bookmark-make-record)
     (setq mode-name "DocView"
@@ -1862,8 +1943,7 @@ to the next best mode."
   "Toggle displaying buffer via Doc View (Doc View minor mode).
 
 See the command `doc-view-mode' for more information on this mode."
-  nil " DocView" doc-view-minor-mode-map
-  :group 'doc-view
+  :lighter " DocView"
   (when doc-view-minor-mode
     (add-hook 'change-major-mode-hook (lambda () (doc-view-minor-mode -1)) nil 
t)
     (message
@@ -1881,6 +1961,84 @@ See the command `doc-view-mode' for more information on 
this mode."
   (interactive)
   (dired doc-view-cache-directory))
 
+;;;; Presentation mode
+
+(defvar doc-view-presentation-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "\e" 'doc-view-presentation-exit)
+    (define-key map "q" 'doc-view-presentation-exit)
+    ;; (define-key map "C" 'doc-view-convert-all-pages)
+    map))
+
+(defvar-local doc-view-presentation--src-data nil)
+
+(defun doc-view-presentation-exit ()
+  "Leave Doc-View's presentation mode."
+  (interactive)
+  (doc-view-presentation-mode -1))
+
+(define-minor-mode doc-view-presentation-mode
+  "Minor mode used while in presentation mode."
+  :init-value nil :keymap doc-view-presentation-mode-map
+  (if doc-view-presentation-mode
+      (progn
+        (set (make-local-variable 'mode-line-format) nil)
+        (doc-view-fit-page-to-window)
+        ;; (doc-view-convert-all-pages)
+        )
+    (kill-local-variable 'mode-line-format)
+    (let ((pn (doc-view-current-page))
+          (win (selected-window)))
+      (doc-view-presentation--propagate-pn doc-view-presentation--src-data pn)
+      (setq doc-view-presentation--src-data nil)
+      (with-selected-window win
+        (if (and (one-window-p) (window-dedicated-p))
+            (delete-frame))))))
+
+(defun doc-view-presentation--propagate-pn (src-data pn)
+  (when src-data
+    (let ((win (car src-data)))
+      (when (and (window-live-p win)
+                 (eq (current-buffer) (window-buffer win)))
+        (select-window win))
+      (when (eq (doc-view-current-page) (cdr src-data))
+        (doc-view-goto-page pn)))))
+
+(defun doc-view-presentation ()
+  "Put Doc-View in presentation mode."
+  (interactive)
+  (let* ((src-data (cons (selected-window) (doc-view-current-page)))
+         (mal (display-monitor-attributes-list))
+         (monitor-top 0)
+         (monitor-left 0)
+         (monitor-height (display-pixel-height))
+         (monitor-width (display-pixel-width)))
+    (dolist (attrs mal)
+      (when (memq (selected-frame) (alist-get 'frames attrs))
+        (let ((geom (alist-get 'geometry attrs)))
+          (when geom
+            (setq monitor-top (nth 0 geom))
+            (setq monitor-left (nth 1 geom))
+            (setq monitor-width (nth 2 geom))
+            (setq monitor-height (nth 3 geom))))))
+    (let ((frame (make-frame
+                  `((minibuffer . nil)
+                    (fullscreen . fullboth)
+                    (height . ,(ceiling monitor-height (frame-char-height)))
+                    ;; Don't use `ceiling' here since doc-view will center the
+                    ;; image instead.
+                    (width . ,(ceiling monitor-width (frame-char-width)))
+                    (name . "Doc-View-Presentation")
+                    (top . ,monitor-top) (left . ,monitor-left) (user-position 
. t)
+                    (vertical-scroll-bars . nil)
+                    (left-fringe . 0) (right-fringe . 0)
+                    (menu-bar-lines . 0)
+                    (tool-bar-lines . 0)))))
+      (select-window (frame-root-window frame))
+      (setq doc-view-presentation--src-data src-data)
+      (set-window-dedicated-p (selected-window) t)
+      (doc-view-presentation-mode 1))))
+
 
 ;;;; Bookmark integration
 
diff --git a/lisp/dom.el b/lisp/dom.el
index 6045a68..e4da63d 100644
--- a/lisp/dom.el
+++ b/lisp/dom.el
@@ -1,6 +1,6 @@
 ;;; dom.el --- XML/HTML (etc.) DOM manipulation and searching functions -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: xml, html
diff --git a/lisp/dos-fns.el b/lisp/dos-fns.el
index aeb8da4..c575dd4 100644
--- a/lisp/dos-fns.el
+++ b/lisp/dos-fns.el
@@ -1,6 +1,6 @@
 ;;; dos-fns.el --- MS-Dos specific functions
 
-;; Copyright (C) 1991, 1993, 1995-1996, 2001-2018 Free Software
+;; Copyright (C) 1991, 1993, 1995-1996, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/dos-vars.el b/lisp/dos-vars.el
index d4fe760..53de20b 100644
--- a/lisp/dos-vars.el
+++ b/lisp/dos-vars.el
@@ -1,6 +1,6 @@
 ;;; dos-vars.el --- MS-Dos specific user options
 
-;; Copyright (C) 1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: internal
diff --git a/lisp/dos-w32.el b/lisp/dos-w32.el
index c19aa44..0c04b8f 100644
--- a/lisp/dos-w32.el
+++ b/lisp/dos-w32.el
@@ -1,6 +1,6 @@
 ;; dos-w32.el --- Functions shared among MS-DOS and W32 (NT/95) platforms
 
-;; Copyright (C) 1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: Geoff Voelker <address@hidden>
 ;; Keywords: internal
diff --git a/lisp/double.el b/lisp/double.el
index b21fe5b..a5e7dcd 100644
--- a/lisp/double.el
+++ b/lisp/double.el
@@ -1,6 +1,6 @@
 ;;; double.el --- support for keyboard remapping with double clicking
 
-;; Copyright (C) 1994, 1997-1998, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1994, 1997-1998, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Per Abrahamsen <address@hidden>
diff --git a/lisp/dynamic-setting.el b/lisp/dynamic-setting.el
index f5fbe15..cf1a8d3 100644
--- a/lisp/dynamic-setting.el
+++ b/lisp/dynamic-setting.el
@@ -1,6 +1,6 @@
 ;;; dynamic-setting.el --- Support dynamic changes
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Jan Djärv <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/ebuff-menu.el b/lisp/ebuff-menu.el
index 198320c..6543e5f 100644
--- a/lisp/ebuff-menu.el
+++ b/lisp/ebuff-menu.el
@@ -1,6 +1,6 @@
 ;;; ebuff-menu.el --- electric-buffer-list mode
 
-;; Copyright (C) 1985-1986, 1994, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1985-1986, 1994, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Richard Mlynarik <address@hidden>
diff --git a/lisp/echistory.el b/lisp/echistory.el
index fb00027..e932daf 100644
--- a/lisp/echistory.el
+++ b/lisp/echistory.el
@@ -1,6 +1,6 @@
 ;;; echistory.el --- Electric Command History Mode
 
-;; Copyright (C) 1985, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: K. Shane Hartman
 ;; Maintainer: address@hidden
diff --git a/lisp/ecomplete.el b/lisp/ecomplete.el
index 3bfab47..d9f34ef 100644
--- a/lisp/ecomplete.el
+++ b/lisp/ecomplete.el
@@ -1,6 +1,6 @@
 ;;; ecomplete.el --- electric completion of addresses and the like  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: mail
@@ -96,7 +96,7 @@ string that was matched."
 (defun ecomplete-add-item (type key text)
   "Add item TEXT of TYPE to the database, using KEY as the identifier."
   (let ((elems (assq type ecomplete-database))
-       (now (string-to-number (format-time-string "%s")))
+       (now (encode-time nil 'integer))
        entry)
     (unless elems
       (push (setq elems (list type)) ecomplete-database))
@@ -210,7 +210,7 @@ matches."
 (defun ecomplete-decay-1 (elem)
   ;; We subtract 5% from the item for each week it hasn't been used.
   (/ (car elem)
-     (expt 1.05 (/ (- (float-time) (cadr elem))
+     (expt 1.05 (/ (float-time (time-since (cadr elem)))
                    (* 7 24 60 60)))))
 
 ;; `ecomplete-get-matches' uses substring matching, so also use the `substring'
diff --git a/lisp/edmacro.el b/lisp/edmacro.el
index c3d9bc5..b480b23 100644
--- a/lisp/edmacro.el
+++ b/lisp/edmacro.el
@@ -1,6 +1,6 @@
 ;;; edmacro.el --- keyboard macro editor
 
-;; Copyright (C) 1993-1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Gillespie <address@hidden>
 ;; Maintainer: Dave Gillespie <address@hidden>
@@ -623,12 +623,16 @@ This function assumes that the events can be stored in a 
string."
                 (push (vector 'menu-bar (car ev)) result))
                ;; It would be nice to do pop-up menus, too, but not enough
                ;; info is recorded in macros to make this possible.
-               (noerror
-                ;; Just ignore mouse events.
+               ((or (mouse-event-p ev) (mouse-movement-p ev)
+                    (memq (event-basic-type ev)
+                          (list mouse-wheel-down-event mouse-wheel-up-event
+                                mouse-wheel-right-event
+                                mouse-wheel-left-event)))
                 nil)
+               (noerror nil)
                (t
-                (error "Macros with mouse clicks are not %s"
-                       "supported by this command"))))
+                (error "`edmacro-fix-menu-commands': Unsupported event: %S"
+                       ev))))
        ;; Reverse them again and make them back into a vector.
        (vconcat (nreverse result)))
     macro))
diff --git a/lisp/ehelp.el b/lisp/ehelp.el
index d43efd4..2a24c98 100644
--- a/lisp/ehelp.el
+++ b/lisp/ehelp.el
@@ -1,6 +1,6 @@
 ;;; ehelp.el --- bindings for electric-help mode -*- lexical-binding: t -*-
 
-;; Copyright (C) 1986, 1995, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1986, 1995, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Richard Mlynarik
 ;; (according to ack.texi and authors.el)
diff --git a/lisp/elec-pair.el b/lisp/elec-pair.el
index 64ed0f6..3be09d8 100644
--- a/lisp/elec-pair.el
+++ b/lisp/elec-pair.el
@@ -1,6 +1,6 @@
 ;;; elec-pair.el --- Automatic parenthesis pairing  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: João Távora <address@hidden>
 
@@ -227,7 +227,14 @@ inside a comment or string."
 (defun electric-pair--insert (char)
   (let ((last-command-event char)
        (blink-matching-paren nil)
-       (electric-pair-mode nil))
+       (electric-pair-mode nil)
+        ;; When adding the "closer" delimiter, a job his function is
+        ;; frequently used for, we don't want to munch any extra
+        ;; newlines above us.  That would be the default behaviour of
+        ;; `electric-layout-mode', which potentially kicked in before
+        ;; us to add these newlines, and is probably about to kick in
+        ;; again after we add the closer.
+        (electric-layout-allow-duplicate-newlines t))
     (self-insert-command 1)))
 
 (cl-defmacro electric-pair--with-uncached-syntax ((table &optional start) 
&rest body)
@@ -405,6 +412,15 @@ strings."
   (let ((ppss (electric-pair--syntax-ppss (point) '(comment))))
     (memq (nth 3 ppss) (list t char))))
 
+(defmacro electric-pair--save-literal-point-excursion (&rest body)
+  ;; FIXME: need this instead of `save-excursion' when functions in
+  ;; BODY, such as `electric-pair-inhibit-if-helps-balance' and
+  ;; `electric-pair-skip-if-helps-balance' modify and restore the
+  ;; buffer in a way that modifies the marker used by save-excursion.
+  (let ((point (make-symbol "point")))
+    `(let ((,point (point)))
+       (unwind-protect (progn ,@body) (goto-char ,point)))))
+
 (defun electric-pair-inhibit-if-helps-balance (char)
   "Return non-nil if auto-pairing of CHAR would hurt parentheses' balance.
 
@@ -413,24 +429,28 @@ some list calculations, finally restoring the situation 
as if nothing
 happened."
   (pcase (electric-pair-syntax-info char)
     (`(,syntax ,pair ,_ ,s-or-c)
-     (unwind-protect
-         (progn
-           (delete-char -1)
-           (cond ((eq ?\( syntax)
-                  (let* ((pair-data
-                          (electric-pair--balance-info 1 s-or-c))
-                         (outermost (cdr pair-data)))
-                    (cond ((car outermost)
-                           nil)
-                          (t
-                           (eq (cdr outermost) pair)))))
-                 ((eq syntax ?\")
-                  (electric-pair--unbalanced-strings-p char))))
-       (insert-char char)))))
+     (catch 'done
+       ;; FIXME: modify+undo is *very* tricky business.  We used to
+       ;; use `delete-char' followed by `insert', but this changed the
+       ;; position some markers.  The real fix would be to compute the
+       ;; result without having to modify the buffer at all.
+       (atomic-change-group
+         (delete-char -1)
+         (throw
+          'done
+          (cond ((eq ?\( syntax)
+                 (let* ((pair-data
+                         (electric-pair--balance-info 1 s-or-c))
+                        (outermost (cdr pair-data)))
+                   (cond ((car outermost)
+                          nil)
+                         (t
+                          (eq (cdr outermost) pair)))))
+                ((eq syntax ?\")
+                 (electric-pair--unbalanced-strings-p char)))))))))
 
 (defun electric-pair-skip-if-helps-balance (char)
   "Return non-nil if skipping CHAR would benefit parentheses' balance.
-
 Works by first removing the character from the buffer, then doing
 some list calculations, finally restoring the situation as if nothing
 happened."
@@ -452,7 +472,7 @@ happened."
                             (not (eq (cdr outermost) pair)))))))
                  ((eq syntax ?\")
                   (electric-pair--inside-string-p char))))
-       (insert-char char)))))
+       (insert char)))))
 
 (defun electric-pair-default-skip-self (char)
   (if electric-pair-preserve-balance
@@ -498,7 +518,9 @@ happened."
         ((and (memq syntax '(?\) ?\" ?\$))
               (and (or unconditional
                        (if (functionp electric-pair-skip-self)
-                           (funcall electric-pair-skip-self last-command-event)
+                           (electric-pair--save-literal-point-excursion
+                             (goto-char pos)
+                             (funcall electric-pair-skip-self 
last-command-event))
                          electric-pair-skip-self))
                    (save-excursion
                      (when (and (not (and unconditional
@@ -525,8 +547,10 @@ happened."
         ((and (memq syntax '(?\( ?\" ?\$))
               (not overwrite-mode)
               (or unconditional
-                  (not (funcall electric-pair-inhibit-predicate
-                                last-command-event))))
+                  (not (electric-pair--save-literal-point-excursion
+                         (goto-char pos)
+                         (funcall electric-pair-inhibit-predicate
+                                  last-command-event)))))
          (save-excursion (electric-pair--insert pair)))))
       (_
        (when (and (if (functionp electric-pair-open-newline-between-pairs)
@@ -540,7 +564,12 @@ happened."
                       (matching-paren (char-after))))
          (save-excursion (newline 1 t)))))))
 
-(put 'electric-pair-post-self-insert-function   'priority  20)
+;; Prioritize this to kick in after
+;; `electric-layout-post-self-insert-function': that considerably
+;; simplifies interoperation when `electric-pair-mode',
+;; `electric-layout-mode' and `electric-indent-mode' are used
+;; together.  Use `vc-region-history' on these lines for more info.
+(put 'electric-pair-post-self-insert-function   'priority  50)
 
 (defun electric-pair-will-use-region ()
   (and (use-region-p)
diff --git a/lisp/electric.el b/lisp/electric.el
index 6dbf46b8..07da2f1 100644
--- a/lisp/electric.el
+++ b/lisp/electric.el
@@ -1,6 +1,6 @@
 ;;; electric.el --- window maker and Command loop for `electric' modes
 
-;; Copyright (C) 1985-1986, 1995, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1985-1986, 1995, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: K. Shane Hartman
@@ -198,8 +198,8 @@ relative order must be maintained within it."
   (setq-default post-self-insert-hook
                 (sort (default-value 'post-self-insert-hook)
                       #'(lambda (fn1 fn2)
-                          (< (or (get fn1 'priority) 0)
-                             (or (get fn2 'priority) 0))))))
+                          (< (or (if (symbolp fn1) (get fn1 'priority)) 0)
+                             (or (if (symbolp fn2) (get fn2 'priority)) 0))))))
 
 ;;; Electric indentation.
 
@@ -223,9 +223,9 @@ Python does not lend itself to fully automatic 
indentation.")
 
 (defvar electric-indent-functions-without-reindent
   '(indent-relative indent-to-left-margin indent-relative-maybe
-    py-indent-line coffee-indent-line org-indent-line yaml-indent-line
-    haskell-indentation-indent-line haskell-indent-cycle haskell-simple-indent
-    yaml-indent-line)
+    indent-relative-first-indent-point py-indent-line coffee-indent-line
+    org-indent-line yaml-indent-line haskell-indentation-indent-line
+    haskell-indent-cycle haskell-simple-indent yaml-indent-line)
   "List of indent functions that can't reindent.
 If `indent-line-function' is one of those, then `electric-indent-mode' will
 not try to reindent lines.  It is normally better to make the major
@@ -272,26 +272,25 @@ or comment."
           (when at-newline
             (let ((before (copy-marker (1- pos) t)))
               (save-excursion
-                (unless (or (memq indent-line-function
-                                  electric-indent-functions-without-reindent)
-                            electric-indent-inhibit)
+                (unless
+                    (or (memq indent-line-function
+                              electric-indent-functions-without-reindent)
+                        electric-indent-inhibit)
                   ;; Don't reindent the previous line if the
                   ;; indentation function is not a real one.
                   (goto-char before)
                   (condition-case-unless-debug ()
                       (indent-according-to-mode)
-                    (error (throw 'indent-error nil))))
-                ;; We are at EOL before the call to
-                ;; `indent-according-to-mode', and after it we usually
-                ;; are as well, but not always.  We tried to address
-                ;; it with `save-excursion' but that uses a normal
-                ;; marker whereas we need `move after insertion', so
-                ;; we do the save/restore by hand.
-                (goto-char before)
-                (when (eolp)
-                  ;; Remove the trailing whitespace after indentation because
-                  ;; indentation may (re)introduce the whitespace.
-                  (delete-horizontal-space t)))))
+                    (error (throw 'indent-error nil)))
+                  ;; The goal here will be to remove the trailing
+                  ;; whitespace after reindentation of the previous line
+                  ;; because that may have (re)introduced it.
+                  (goto-char before)
+                  ;; We were at EOL in marker `before' before the call
+                  ;; to `indent-according-to-mode' but after we may
+                  ;; not be (Bug#15767).
+                  (when (and (eolp))
+                    (delete-horizontal-space t))))))
           (unless (and electric-indent-inhibit
                        (not at-newline))
             (condition-case-unless-debug ()
@@ -363,45 +362,115 @@ use `electric-indent-local-mode'."
 (defvar electric-layout-rules nil
   "List of rules saying where to automatically insert newlines.
 
-Each rule has the form (CHAR . WHERE) where CHAR is the char that
-was just inserted and WHERE specifies where to insert newlines
-and can be: nil, `before', `after', `around', `after-stay', or a
-function of no arguments that returns one of those symbols.
+Each rule has the form (CHAR . WHERE), the rule matching if the
+character just inserted was CHAR.  WHERE specifies where to
+insert newlines, and can be:
+
+* one of the symbols `before', `after', `around', `after-stay',
+  or nil.
+
+* a list of the preceding symbols, processed in order of
+  appearance to insert multiple newlines;
+
+* a function of no arguments that returns one of the previous
+  values.
+
+Each symbol specifies where, in relation to the position POS of
+the character inserted, the newline character(s) should be
+inserted.  `after-stay' means insert a newline after POS but stay
+in the same place.
+
+Instead of the (CHAR . WHERE) form, a rule can also be just a
+function of a single argument, the character just inserted.  It
+is called at that position, and should return a value compatible with
+WHERE if the rule matches, or nil if it doesn't match.
 
-The symbols specify where in relation to CHAR the newline
-character(s) should be inserted. `after-stay' means insert a
-newline after CHAR but stay in the same place.")
+If multiple rules match, only first one is executed.")
+
+;; TODO: Make this a defcustom?
+(defvar electric-layout-allow-duplicate-newlines nil
+  "If non-nil, allow duplication of `before' newlines.")
 
 (defun electric-layout-post-self-insert-function ()
-  (let* ((rule (cdr (assq last-command-event electric-layout-rules)))
-         pos)
+  (when electric-layout-mode
+    (electric-layout-post-self-insert-function-1)))
+
+;; for edebug's sake, a separate function
+(defun electric-layout-post-self-insert-function-1 ()
+  (let* ((pos (electric--after-char-pos))
+         probe
+         (rules electric-layout-rules)
+         (rule
+          (catch 'done
+            (when pos
+              (while (setq probe (pop rules))
+                (cond ((and (consp probe)
+                            (eq (car probe) last-command-event))
+                       (throw 'done (cdr probe)))
+                      ((functionp probe)
+                       (let ((res
+                              (save-excursion
+                                (goto-char pos)
+                                (funcall probe last-command-event))))
+                         (when res (throw 'done res))))))))))
     (when (and rule
-               (setq pos (electric--after-char-pos))
                ;; Not in a string or comment.
                (not (nth 8 (save-excursion (syntax-ppss pos)))))
-      (let ((end (point-marker))
-            (sym (if (functionp rule) (funcall rule) rule)))
-        (set-marker-insertion-type end (not (eq sym 'after-stay)))
-        (goto-char pos)
-        (pcase sym
-          ;; FIXME: we used `newline' down here which called
-          ;; self-insert-command and ran post-self-insert-hook recursively.
-          ;; It happened to make electric-indent-mode work automatically with
-          ;; electric-layout-mode (at the cost of re-indenting lines
-          ;; multiple times), but I'm not sure it's what we want.
-          ;;
-          ;; FIXME: check eolp before inserting \n?
-          ('before (goto-char (1- pos)) (skip-chars-backward " \t")
-                   (unless (bolp) (insert "\n")))
-          ('after  (insert "\n"))
-          ('after-stay (save-excursion
-                         (let ((electric-layout-rules nil))
-                           (newline 1 t))))
-          ('around (save-excursion
-                     (goto-char (1- pos)) (skip-chars-backward " \t")
-                     (unless (bolp) (insert "\n")))
-                   (insert "\n")))      ; FIXME: check eolp before inserting 
\n?
-        (goto-char end)))))
+      (goto-char pos)
+      (when (functionp rule) (setq rule (funcall rule)))
+      (dolist (sym (if (symbolp rule) (list rule) rule))
+        (let* ((nl-after
+                (lambda ()
+                  ;; FIXME: we use `newline', which calls
+                  ;; `self-insert-command' and ran
+                  ;; `post-self-insert-hook' recursively.  It happened
+                  ;; to make `electric-indent-mode' work automatically
+                  ;; with `electric-layout-mode' (at the cost of
+                  ;; re-indenting lines multiple times), but I'm not
+                  ;; sure it's what we want.
+                  ;;
+                  ;; address@hidden/02/22: Indeed in the case of `before'
+                  ;; newlines, re-indentation is prevented.
+                  ;;
+                  ;; FIXME: when `newline'ing, we exceptionally
+                  ;; prevent a specific behaviour of
+                  ;; `eletric-pair-mode', that of opening an extra
+                  ;; newline between newly inserted matching paris.
+                  ;; In theory that behaviour should be provided by
+                  ;; `electric-layout-mode' instead, which should be
+                  ;; possible given the current API.
+                  ;;
+                  ;; FIXME: check eolp before inserting \n?
+                  (let ((electric-layout-mode nil)
+                        (electric-pair-open-newline-between-pairs nil))
+                    (newline 1 t))))
+               (nl-before
+                (lambda ()
+                  (save-excursion
+                    (goto-char (1- pos))
+                    ;; Normally, we don't duplicate newlines, but when
+                    ;; we're being called for i.e. a closer brace for
+                    ;; `electric-pair-mode' generally make sense.  So
+                    ;; consult `electric-layout-allow-duplicate-newlines'
+                    (unless (and (not electric-layout-allow-duplicate-newlines)
+                                 (progn (skip-chars-backward " \t")
+                                        (bolp)))
+                      ;; FIXME: address@hidden/03/22: Make sure the `before'
+                      ;; newline being inserted here does not trigger
+                      ;; reindentation.  It doesn't seem to be our job
+                      ;; to do so and it break with `cc-mode's
+                      ;; indentation function.  Later on we can add a
+                      ;; before-and-maybe-indent, or if the user
+                      ;; really wants to reindent, then
+                      ;; `last-command-event' should be in
+                      ;; `electric-indent-chars'.
+                      (let ((electric-indent-inhibit t))
+                        (funcall nl-after)))))))
+            (pcase sym
+              ('before (funcall nl-before))
+              ('after  (funcall nl-after))
+              ('after-stay (save-excursion (funcall nl-after)))
+              ('around (funcall nl-before) (funcall nl-after))))))))
 
 (put 'electric-layout-post-self-insert-function 'priority  40)
 
@@ -419,6 +488,19 @@ The variable `electric-layout-rules' says when and how to 
insert newlines."
          (remove-hook 'post-self-insert-hook
                       #'electric-layout-post-self-insert-function))))
 
+;;;###autoload
+(define-minor-mode electric-layout-local-mode
+  "Toggle `electric-layout-mode' only in this buffer."
+  :variable (buffer-local-value 'electric-layout-mode (current-buffer))
+  (cond
+   ((eq electric-layout-mode (default-value 'electric-layout-mode))
+    (kill-local-variable 'electric-layout-mode))
+   ((not (default-value 'electric-layout-mode))
+    ;; Locally enabled, but globally disabled.
+    (electric-layout-mode 1)             ; Setup the hooks.
+    (setq-default electric-layout-mode nil) ; But keep it globally disabled.
+    )))
+
 ;;; Electric quoting.
 
 (defcustom electric-quote-comment t
diff --git a/lisp/elide-head.el b/lisp/elide-head.el
index d43a40d..c1678c0 100644
--- a/lisp/elide-head.el
+++ b/lisp/elide-head.el
@@ -1,6 +1,6 @@
 ;;; elide-head.el --- hide headers in files
 
-;; Copyright (C) 1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Love <address@hidden>
 ;; Keywords: outlines tools
@@ -52,7 +52,7 @@
 (defcustom elide-head-headers-to-hide
   '(("is free software[:;] you can redistribute it" . ; GNU boilerplate
      "\\(Boston, MA 0211\\(1-1307\\|0-1301\\), USA\\|\
-If not, see <http://www\\.gnu\\.org/licenses/>\\)\\.")
+If not, see <https?://www\\.gnu\\.org/licenses/>\\)\\.")
     ("The Regents of the University of California\\.  All rights reserved\\." .
      "SUCH DAMAGE\\.")                               ; BSD
     ("Permission is hereby granted, free of charge" . ; X11
diff --git a/lisp/emacs-lisp/advice.el b/lisp/emacs-lisp/advice.el
index 04d2fbf..2034f33 100644
--- a/lisp/emacs-lisp/advice.el
+++ b/lisp/emacs-lisp/advice.el
@@ -1,6 +1,6 @@
 ;;; advice.el --- An overloading mechanism for Emacs Lisp functions  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1993-1994, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1994, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Hans Chalupsky <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/emacs-lisp/autoload.el b/lisp/emacs-lisp/autoload.el
index e4290ba..19e1e93 100644
--- a/lisp/emacs-lisp/autoload.el
+++ b/lisp/emacs-lisp/autoload.el
@@ -1,6 +1,6 @@
 ;; autoload.el --- maintain autoloads in loaddefs.el  -*- lexical-binding: t 
-*-
 
-;; Copyright (C) 1991-1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1991-1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Roland McGrath <address@hidden>
 ;; Keywords: maint
@@ -146,7 +146,7 @@ expression, in which case we want to handle forms 
differently."
                            t))))
         ;; Add the usage form at the end where describe-function-1
         ;; can recover it.
-        (when (listp args) (setq doc (help-add-fundoc-usage doc args)))
+        (when (consp args) (setq doc (help-add-fundoc-usage doc args)))
         ;; (message "autoload of %S" (nth 1 form))
         `(autoload ,(nth 1 form) ,file ,doc ,interactive ,type)))
 
diff --git a/lisp/emacs-lisp/avl-tree.el b/lisp/emacs-lisp/avl-tree.el
index 5031238..d2a3a13 100644
--- a/lisp/emacs-lisp/avl-tree.el
+++ b/lisp/emacs-lisp/avl-tree.el
@@ -1,6 +1,6 @@
 ;;; avl-tree.el --- balanced binary trees, AVL-trees  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1995, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Per Cederqvist <address@hidden>
 ;;         Inge Wallin <address@hidden>
diff --git a/lisp/emacs-lisp/backquote.el b/lisp/emacs-lisp/backquote.el
index c306b1c..5e72dc3 100644
--- a/lisp/emacs-lisp/backquote.el
+++ b/lisp/emacs-lisp/backquote.el
@@ -1,6 +1,6 @@
 ;;; backquote.el --- implement the ` Lisp construct
 
-;; Copyright (C) 1990, 1992, 1994, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1990, 1992, 1994, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Rick Sladkey <address@hidden>
diff --git a/lisp/emacs-lisp/backtrace.el b/lisp/emacs-lisp/backtrace.el
index e82d4f5..60d146e 100644
--- a/lisp/emacs-lisp/backtrace.el
+++ b/lisp/emacs-lisp/backtrace.el
@@ -1,6 +1,6 @@
 ;;; backtrace.el --- generic major mode for Elisp backtraces -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; Author: Gemini Lasswell
 ;; Keywords: lisp, tools, maint
diff --git a/lisp/emacs-lisp/benchmark.el b/lisp/emacs-lisp/benchmark.el
index a9fa7c4..5b5cda3 100644
--- a/lisp/emacs-lisp/benchmark.el
+++ b/lisp/emacs-lisp/benchmark.el
@@ -1,6 +1,6 @@
 ;;; benchmark.el --- support for benchmarking code  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Love  <address@hidden>
 ;; Keywords: lisp, extensions
@@ -38,7 +38,7 @@
     `(let (,t1)
        (setq ,t1 (current-time))
        ,@forms
-       (float-time (time-subtract nil ,t1)))))
+       (float-time (time-since ,t1)))))
 
 ;;;###autoload
 (defmacro benchmark-run (&optional repetitions &rest forms)
diff --git a/lisp/emacs-lisp/bindat.el b/lisp/emacs-lisp/bindat.el
index 3124217..33ab2f5 100644
--- a/lisp/emacs-lisp/bindat.el
+++ b/lisp/emacs-lisp/bindat.el
@@ -1,6 +1,6 @@
 ;;; bindat.el --- binary data structure packing and unpacking.
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Kim F. Storm <address@hidden>
 ;; Assignment name: struct.el
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 8d9779e..44cca61 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -1,6 +1,6 @@
 ;;; byte-opt.el --- the optimization passes of the emacs-lisp byte compiler 
-*- lexical-binding: t -*-
 
-;; Copyright (C) 1991, 1994, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1991, 1994, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Jamie Zawinski <address@hidden>
 ;;     Hallvard Furuseth <address@hidden>
@@ -436,11 +436,6 @@
                     (cons (byte-optimize-form (nth 1 form) for-effect)
                           (byte-optimize-body (cdr (cdr form)) t)))
             (byte-optimize-form (nth 1 form) for-effect)))
-         ((eq fn 'prog2)
-          (cons 'prog2
-            (cons (byte-optimize-form (nth 1 form) t)
-              (cons (byte-optimize-form (nth 2 form) for-effect)
-                    (byte-optimize-body (cdr (cdr (cdr form))) t)))))
 
          ((memq fn '(save-excursion save-restriction save-current-buffer))
           ;; those subrs which have an implicit progn; it's not quite good
@@ -884,7 +879,8 @@
 (put 'symbolp 'byte-optimizer 'byte-optimize-predicate)
 (put 'stringp 'byte-optimizer 'byte-optimize-predicate)
 (put 'string< 'byte-optimizer 'byte-optimize-predicate)
-(put 'string-lessp 'byte-optimizer 'byte-optimize-predicate)
+(put 'string-lessp  'byte-optimizer 'byte-optimize-predicate)
+(put 'proper-list-p 'byte-optimizer 'byte-optimize-predicate)
 
 (put 'logand 'byte-optimizer 'byte-optimize-predicate)
 (put 'logior 'byte-optimizer 'byte-optimize-predicate)
diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el
index 5edf5a2..842d1d4 100644
--- a/lisp/emacs-lisp/byte-run.el
+++ b/lisp/emacs-lisp/byte-run.el
@@ -1,6 +1,6 @@
 ;;; byte-run.el --- byte-compiler support for inlining  -*- lexical-binding: t 
-*-
 
-;; Copyright (C) 1992, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Jamie Zawinski <address@hidden>
 ;;     Hallvard Furuseth <address@hidden>
@@ -423,7 +423,7 @@ variable (this is due to the way `defvaralias' works).
 If provided, WHEN should be a string indicating when the variable
 was first made obsolete, for example a date or a release number.
 
-For the benefit of `custom-set-variables', if OBSOLETE-NAME has
+For the benefit of Customize, if OBSOLETE-NAME has
 any of the following properties, they are copied to
 CURRENT-NAME, if it does not already have them:
 `saved-value', `saved-variable-comment'."
@@ -495,6 +495,21 @@ is enabled."
   (car (last body)))
 
 
+(defun byte-run--unescaped-character-literals-warning ()
+  "Return a warning about unescaped character literals.
+If there were any unescaped character literals in the last form
+read, return an appropriate warning message as a string.
+Otherwise, return nil.  For internal use only."
+  ;; This is called from lread.c and therefore needs to be preloaded.
+  (if lread--unescaped-character-literals
+      (let ((sorted (sort lread--unescaped-character-literals #'<)))
+        (format-message "unescaped character literals %s detected, %s 
expected!"
+                        (mapconcat (lambda (char) (format "`?%c'" char))
+                                   sorted ", ")
+                        (mapconcat (lambda (char) (format "`?\\%c'" char))
+                                   sorted ", ")))))
+
+
 ;; I nuked this because it's not a good idea for users to think of using it.
 ;; These options are a matter of installation preference, and have nothing to
 ;; with particular source files; it's a mistake to suggest to users
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index c0a764b..e76baf5 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1,6 +1,6 @@
 ;;; bytecomp.el --- compilation of Lisp code into byte code -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1985-1987, 1992, 1994, 1998, 2000-2018 Free Software
+;; Copyright (C) 1985-1987, 1992, 1994, 1998, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Jamie Zawinski <address@hidden>
@@ -1022,6 +1022,15 @@ If STR is something like \"Buffer foo.el\", return 
#<buffer foo.el>
   "The value for `compilation-parse-errors-filename-function' for when
 we go into emacs-lisp-compilation-mode.")
 
+(defcustom emacs-lisp-compilation-search-path '(nil)
+  "Search path for byte-compile error messages.
+Elements should be directory names, not file names of directories.
+The value nil as an element means to try the default directory."
+  :group 'bytecomp
+  :version "27.1"
+  :type '(repeat (choice (const :tag "Default" nil)
+                        (string :tag "Directory"))))
+
 (define-compilation-mode emacs-lisp-compilation-mode "elisp-compile"
   "The variant of `compilation-mode' used for emacs-lisp error buffers")
 
@@ -2082,14 +2091,9 @@ With argument ARG, insert value in current buffer after 
the form."
                 (not (eobp)))
          (setq byte-compile-read-position (point)
                byte-compile-last-position byte-compile-read-position)
-         (let* ((lread--unescaped-character-literals nil)
-                 (form (read inbuffer)))
-            (when lread--unescaped-character-literals
-              (byte-compile-warn
-               "unescaped character literals %s detected!"
-               (mapconcat (lambda (char) (format "`?%c'" char))
-                          (sort lread--unescaped-character-literals #'<)
-                          ", ")))
+         (let ((form (read inbuffer))
+                (warning (byte-run--unescaped-character-literals-warning)))
+            (when warning (byte-compile-warn "%s" warning))
            (byte-compile-toplevel-file-form form)))
        ;; Compile pending forms at end of file.
        (byte-compile-flush-pending)
@@ -2501,9 +2505,8 @@ list that represents a doc string reference.
 
 (put 'progn 'byte-hunk-handler 'byte-compile-file-form-progn)
 (put 'prog1 'byte-hunk-handler 'byte-compile-file-form-progn)
-(put 'prog2 'byte-hunk-handler 'byte-compile-file-form-progn)
 (defun byte-compile-file-form-progn (form)
-  (mapc 'byte-compile-file-form (cdr form))
+  (mapc #'byte-compile-file-form (cdr form))
   ;; Return nil so the forms are not output twice.
   nil)
 
@@ -3534,7 +3537,7 @@ If it is nil, then the handler is 
\"byte-compile-SYMBOL.\""
 (byte-defop-compiler (>= byte-geq)     2-and)
 (byte-defop-compiler get               2)
 (byte-defop-compiler nth               2)
-(byte-defop-compiler substring         2-3)
+(byte-defop-compiler substring         1-3)
 (byte-defop-compiler (move-marker byte-set-marker) 2-3)
 (byte-defop-compiler set-marker        2-3)
 (byte-defop-compiler match-beginning   1)
@@ -3910,7 +3913,6 @@ discarding."
 
 
 (byte-defop-compiler-1 setq)
-(byte-defop-compiler-1 setq-default)
 (byte-defop-compiler-1 quote)
 
 (defun byte-compile-setq (form)
@@ -3935,34 +3937,20 @@ discarding."
         (byte-compile-form nil byte-compile--for-effect)))
     (setq byte-compile--for-effect nil)))
 
-(defun byte-compile-setq-default (form)
-  (setq form (cdr form))
-  (if (null form)                      ; (setq-default), with no arguments
-      (byte-compile-form nil byte-compile--for-effect)
-    (if (> (length form) 2)
-       (let ((setters ()))
-         (while (consp form)
-           (push `(setq-default ,(pop form) ,(pop form)) setters))
-         (byte-compile-form (cons 'progn (nreverse setters))))
-      (let ((var (car form)))
-       (and (or (not (symbolp var))
-                (macroexp--const-symbol-p var t))
-            (byte-compile-warning-enabled-p 'constants)
-            (byte-compile-warn
-             "variable assignment to %s `%s'"
-             (if (symbolp var) "constant" "nonvariable")
-             (prin1-to-string var)))
-       (byte-compile-normal-call `(set-default ',var ,@(cdr form)))))))
-
 (byte-defop-compiler-1 set-default)
 (defun byte-compile-set-default (form)
   (let ((varexp (car-safe (cdr-safe form))))
     (if (eq (car-safe varexp) 'quote)
-        ;; If the varexp is constant, compile it as a setq-default
-        ;; so we get more warnings.
-        (byte-compile-setq-default `(setq-default ,(car-safe (cdr varexp))
-                                                  ,@(cddr form)))
-      (byte-compile-normal-call form))))
+        ;; If the varexp is constant, check the var's name.
+        (let ((var (car-safe (cdr varexp))))
+          (and (or (not (symbolp var))
+                  (macroexp--const-symbol-p var t))
+               (byte-compile-warning-enabled-p 'constants)
+               (byte-compile-warn
+               "variable assignment to %s `%s'"
+               (if (symbolp var) "constant" "nonvariable")
+               (prin1-to-string var)))))
+    (byte-compile-normal-call form)))
 
 (defun byte-compile-quote (form)
   (byte-compile-constant (car (cdr form))))
@@ -3986,7 +3974,6 @@ discarding."
 (byte-defop-compiler-1 inline byte-compile-progn)
 (byte-defop-compiler-1 progn)
 (byte-defop-compiler-1 prog1)
-(byte-defop-compiler-1 prog2)
 (byte-defop-compiler-1 if)
 (byte-defop-compiler-1 cond)
 (byte-defop-compiler-1 and)
@@ -4003,11 +3990,6 @@ discarding."
   (byte-compile-form-do-effect (car (cdr form)))
   (byte-compile-body (cdr (cdr form)) t))
 
-(defun byte-compile-prog2 (form)
-  (byte-compile-form (nth 1 form) t)
-  (byte-compile-form-do-effect (nth 2 form))
-  (byte-compile-body (cdr (cdr (cdr form))) t))
-
 (defmacro byte-compile-goto-if (cond discard tag)
   `(byte-compile-goto
     (if ,cond
diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el
index d776297..58ca9d5 100644
--- a/lisp/emacs-lisp/cconv.el
+++ b/lisp/emacs-lisp/cconv.el
@@ -1,6 +1,6 @@
 ;;; cconv.el --- Closure conversion for statically scoped Emacs lisp. -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Igor Kuzmin <address@hidden>
 ;; Maintainer: address@hidden
@@ -556,7 +556,7 @@ places where they originally did not directly appear."
 
     (`(,func . ,forms)
      ;; First element is function or whatever function-like forms are: or, and,
-     ;; if, catch, progn, prog1, prog2, while, until
+     ;; if, catch, progn, prog1, while, until
      `(,func . ,(mapcar (lambda (form)
                           (cconv-convert form env extend))
                         forms)))
diff --git a/lisp/emacs-lisp/chart.el b/lisp/emacs-lisp/chart.el
index cf1d4ce..9c29297 100644
--- a/lisp/emacs-lisp/chart.el
+++ b/lisp/emacs-lisp/chart.el
@@ -1,6 +1,6 @@
 ;;; chart.el --- Draw charts (bar charts, etc)  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1996, 1998-1999, 2001, 2004-2005, 2007-2018 Free
+;; Copyright (C) 1996, 1998-1999, 2001, 2004-2005, 2007-2019 Free
 ;; Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam  <address@hidden>
@@ -704,7 +704,7 @@ SORT-PRED if desired."
        (cntlst nil))
     (save-excursion
       (goto-char (point-min))
-      (while (re-search-forward "\\-[A-Z][a-z][a-z] +\\(\\w+\\)@\\w+" nil t)
+      (while (re-search-forward "-[A-Z][a-z][a-z] +\\(\\w+\\)@\\w+" nil t)
        (let* ((nam (buffer-substring (match-beginning 1) (match-end 1)))
               (m (member nam nmlst)))
          (message "Scanned username %s" nam)
diff --git a/lisp/emacs-lisp/check-declare.el b/lisp/emacs-lisp/check-declare.el
index 769da3a..8445950 100644
--- a/lisp/emacs-lisp/check-declare.el
+++ b/lisp/emacs-lisp/check-declare.el
@@ -1,6 +1,6 @@
 ;;; check-declare.el --- Check declare-function statements
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Glenn Morris <address@hidden>
 ;; Keywords: lisp, tools, maint
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index 86d211c..fa6f85c 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -1,6 +1,6 @@
 ;;; checkdoc.el --- check documentation strings for style requirements  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1997-1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Version: 0.6.2
@@ -174,6 +174,7 @@
 (require 'cl-lib)
 (require 'help-mode) ;; for help-xref-info-regexp
 (require 'thingatpt) ;; for handy thing-at-point-looking-at
+(require 'lisp-mnt)
 
 (defvar compilation-error-regexp-alist)
 (defvar compilation-mode-font-lock-keywords)
@@ -1510,7 +1511,7 @@ may require more formatting")
                                              (line-end-position))))))))
      ;; Continuation of above.  Make sure our sentence is capitalized.
      (save-excursion
-       (skip-chars-forward "\"\\*")
+       (skip-chars-forward "\"*")
        (if (looking-at "[a-z]")
           (if (checkdoc-autofix-ask-replace
                (match-beginning 0) (match-end 0)
@@ -2205,21 +2206,10 @@ News agents may remove it"
 ;;
 (defvar generate-autoload-cookie)
 
-(eval-when-compile (require 'lisp-mnt))        ; expand silly defsubsts
-(declare-function lm-summary "lisp-mnt" (&optional file))
-(declare-function lm-section-start "lisp-mnt" (header &optional after))
-(declare-function lm-section-end "lisp-mnt" (header))
-
 (defun checkdoc-file-comments-engine ()
   "Return a message list if this file does not match the Emacs standard.
 This checks for style only, such as the first line, Commentary:,
 Code:, and others referenced in the style guide."
-  (if (featurep 'lisp-mnt)
-      nil
-    (require 'lisp-mnt)
-    ;; Old XEmacs don't have `lm-commentary-mark'
-    (if (and (not (fboundp 'lm-commentary-mark)) (fboundp 'lm-commentary))
-       (defalias 'lm-commentary-mark #'lm-commentary)))
   (save-excursion
     (let* ((f1 (file-name-nondirectory (buffer-file-name)))
           (fn (file-name-sans-extension f1))
@@ -2280,7 +2270,7 @@ Code:, and others referenced in the style guide."
        (if (or (not checkdoc-force-history-flag)
                (file-exists-p "ChangeLog")
                (file-exists-p "../ChangeLog")
-                (and (fboundp 'lm-history-mark) (funcall #'lm-history-mark)))
+                (lm-history-mark))
            nil
          (progn
            (goto-char (or (lm-commentary-mark) (point-min)))
diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el
index 13988db..a2400a0 100644
--- a/lisp/emacs-lisp/cl-extra.el
+++ b/lisp/emacs-lisp/cl-extra.el
@@ -1,6 +1,6 @@
 ;;; cl-extra.el --- Common Lisp features, part 2  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1993, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Gillespie <address@hidden>
 ;; Keywords: extensions
@@ -438,9 +438,7 @@ as an integer unless JUNK-ALLOWED is non-nil."
 ;; Random numbers.
 
 (defun cl--random-time ()
-  (let* ((time (copy-sequence (current-time-string))) (i (length time)) (v 0))
-    (while (>= (cl-decf i) 0) (setq v (+ (* v 3) (aref time i))))
-    v))
+  (car (encode-time nil t)))
 
 ;;;###autoload (autoload 'cl-random-state-p "cl-extra")
 (cl-defstruct (cl--random-state
@@ -484,7 +482,7 @@ Optional second arg STATE is a random-state object."
 If STATE is t, return a new state object seeded from the time of day."
   (unless state (setq state cl--random-state))
   (if (cl-random-state-p state)
-      (copy-tree state t)
+      (copy-sequence state)
     (cl--make-random-state (if (integerp state) state (cl--random-time)))))
 
 ;; Implementation limits.
@@ -596,10 +594,10 @@ too large if positive or too small if negative)."
 ;;;###autoload
 (defun cl-list-length (x)
   "Return the length of list X.  Return nil if list is circular."
-  (let ((n 0) (fast x) (slow x))
-    (while (and (cdr fast) (not (and (eq fast slow) (> n 0))))
-      (setq n (+ n 2) fast (cdr (cdr fast)) slow (cdr slow)))
-    (if fast (if (cdr fast) nil (1+ n)) n)))
+  (cl-check-type x list)
+  (condition-case nil
+      (length x)
+    (circular-list)))
 
 ;;;###autoload
 (defun cl-tailp (sublist list)
diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el
index cad629d..f104d80 100644
--- a/lisp/emacs-lisp/cl-generic.el
+++ b/lisp/emacs-lisp/cl-generic.el
@@ -1,6 +1,6 @@
 ;;; cl-generic.el --- CLOS-style generic functions for Elisp  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Version: 1.0
diff --git a/lisp/emacs-lisp/cl-indent.el b/lisp/emacs-lisp/cl-indent.el
index 73b9172..10af440 100644
--- a/lisp/emacs-lisp/cl-indent.el
+++ b/lisp/emacs-lisp/cl-indent.el
@@ -1,6 +1,6 @@
 ;;; cl-indent.el --- Enhanced lisp-indent mode  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1987, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1987, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Richard Mlynarik <address@hidden>
 ;; Created: July 1987
diff --git a/lisp/emacs-lisp/cl-lib.el b/lisp/emacs-lisp/cl-lib.el
index 592235d..3a9280f 100644
--- a/lisp/emacs-lisp/cl-lib.el
+++ b/lisp/emacs-lisp/cl-lib.el
@@ -1,6 +1,6 @@
 ;;; cl-lib.el --- Common Lisp extensions for Emacs  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Gillespie <address@hidden>
 ;; Version: 1.0
@@ -365,13 +365,6 @@ SEQ, this is like `mapcar'.  With several, it is like the 
Common Lisp
 (cl--defalias 'cl-second 'cadr)
 (cl--defalias 'cl-rest 'cdr)
 
-(defun cl-endp (x)
-  "Return true if X is the empty list; false if it is a cons.
-Signal an error if X is not a list."
-  (if (listp x)
-      (null x)
-    (signal 'wrong-type-argument (list 'listp x 'x))))
-
 (cl--defalias 'cl-third 'cl-caddr "Return the third element of the list X.")
 (cl--defalias 'cl-fourth 'cl-cadddr "Return the fourth element of the list X.")
 
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index bc78d80..16e9bd6 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -1,6 +1,6 @@
 ;;; cl-macs.el --- Common Lisp macros  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Gillespie <address@hidden>
 ;; Old-Version: 2.02
@@ -2687,6 +2687,9 @@ The function's arguments should be treated as immutable.
 ;; for bootstrapping reasons.
 (defvar cl--struct-default-parent nil)
 
+(defvar cl--struct-inline t
+  "If non-nil, `cl-defstruct' will define inlinable functions.")
+
 ;;;###autoload
 (defmacro cl-defstruct (struct &rest descs)
   "Define a struct type.
@@ -2698,7 +2701,7 @@ You can use the accessors to set the corresponding slots, 
via `setf'.
 NAME may instead take the form (NAME OPTIONS...), where each
 OPTION is either a single keyword or (KEYWORD VALUE) where
 KEYWORD can be one of :conc-name, :constructor, :copier, :predicate,
-:type, :named, :initial-offset, :print-function, or :include.
+:type, :named, :initial-offset, :print-function, :noinline, or :include.
 
 Each SLOT may instead take the form (SNAME SDEFAULT SOPTIONS...), where
 SDEFAULT is the default value of that slot and SOPTIONS are keyword-value
@@ -2757,6 +2760,8 @@ non-nil value, that slot cannot be set via `setf'.
         (include-name nil)
         (type nil)         ;nil here means not specified explicitly.
         (named nil)
+         (cldefsym (if cl--struct-inline 'cl-defsubst 'cl-defun))
+         (defsym (if cl--struct-inline 'cl-defsubst 'defun))
         (forms nil)
          (docstring (if (stringp (car descs)) (pop descs)))
         pred-form pred-check)
@@ -2803,6 +2808,8 @@ non-nil value, that slot cannot be set via `setf'.
                  (error "Invalid :type specifier: %s" type)))
              ((eq opt :named)
               (setq named t))
+             ((eq opt :noinline)
+              (setq defsym 'defun) (setq cldefsym 'cl-defun))
              ((eq opt :initial-offset)
               (setq descs (nconc (make-list (car args) '(cl-skip-slot))
                                  descs)))
@@ -2861,7 +2868,7 @@ non-nil value, that slot cannot be set via `setf'.
                              (cons 'and (cl-cdddr pred-form))
                             `(,predicate cl-x))))
     (when pred-form
-      (push `(cl-defsubst ,predicate (cl-x)
+      (push `(,defsym ,predicate (cl-x)
                (declare (side-effect-free error-free))
                ,(if (eq (car pred-form) 'and)
                     (append pred-form '(t))
@@ -2884,7 +2891,7 @@ non-nil value, that slot cannot be set via `setf'.
              (push (pop desc) defaults)
              ;; The arg "cl-x" is referenced by name in eg pred-form
              ;; and pred-check, so changing it is not straightforward.
-             (push `(cl-defsubst ,accessor (cl-x)
+             (push `(,defsym ,accessor (cl-x)
                        ,(format "Access slot \"%s\" of `%s' struct CL-X."
                                 slot struct)
                        (declare (side-effect-free t))
@@ -2955,7 +2962,7 @@ non-nil value, that slot cannot be set via `setf'.
       (let* ((anames (cl--arglist-args args))
             (make (cl-mapcar (function (lambda (s d) (if (memq s anames) s d)))
                            slots defaults)))
-       (push `(cl-defsubst ,cname
+       (push `(,cldefsym ,cname
                    (&cl-defs (nil ,@descs) ,@args)
                  ,(if (stringp doc) doc
                     (format "Constructor for objects of type `%s'." name))
diff --git a/lisp/emacs-lisp/cl-preloaded.el b/lisp/emacs-lisp/cl-preloaded.el
index 2a70f9b..4bd22fa 100644
--- a/lisp/emacs-lisp/cl-preloaded.el
+++ b/lisp/emacs-lisp/cl-preloaded.el
@@ -1,6 +1,6 @@
 ;;; cl-preloaded.el --- Preloaded part of the CL library  -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Package: emacs
diff --git a/lisp/emacs-lisp/cl-print.el b/lisp/emacs-lisp/cl-print.el
index c63f5ac..5fe3dd1 100644
--- a/lisp/emacs-lisp/cl-print.el
+++ b/lisp/emacs-lisp/cl-print.el
@@ -1,6 +1,6 @@
 ;;; cl-print.el --- CL-style generic printing  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords:
diff --git a/lisp/emacs-lisp/cl-seq.el b/lisp/emacs-lisp/cl-seq.el
index 60cccd0..3eb6ea1 100644
--- a/lisp/emacs-lisp/cl-seq.el
+++ b/lisp/emacs-lisp/cl-seq.el
@@ -1,6 +1,6 @@
 ;;; cl-seq.el --- Common Lisp features, part 3  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Gillespie <address@hidden>
 ;; Old-Version: 2.02
@@ -113,6 +113,13 @@
 (defvar cl-key)
 
 ;;;###autoload
+(defun cl-endp (x)
+  "Return true if X is the empty list; false if it is a cons.
+Signal an error if X is not a list."
+  (cl-check-type x list)
+  (null x))
+
+;;;###autoload
 (defun cl-reduce (cl-func cl-seq &rest cl-keys)
   "Reduce two-argument FUNCTION across SEQ.
 \nKeywords supported:  :start :end :from-end :initial-value :key
diff --git a/lisp/emacs-lisp/cl.el b/lisp/emacs-lisp/cl.el
index f664315..71be1d1 100644
--- a/lisp/emacs-lisp/cl.el
+++ b/lisp/emacs-lisp/cl.el
@@ -1,6 +1,6 @@
 ;;; cl.el --- Compatibility aliases for the old CL library.  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords: extensions
diff --git a/lisp/emacs-lisp/copyright.el b/lisp/emacs-lisp/copyright.el
index 2f29c19..be33583 100644
--- a/lisp/emacs-lisp/copyright.el
+++ b/lisp/emacs-lisp/copyright.el
@@ -1,6 +1,6 @@
 ;;; copyright.el --- update the copyright notice in current buffer
 
-;; Copyright (C) 1991-1995, 1998, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1991-1995, 1998, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Daniel Pfeiffer <address@hidden>
@@ -52,7 +52,7 @@ This is useful for ChangeLogs."
 (defcustom copyright-regexp
  "\\(©\\|@copyright{}\\|[Cc]opyright\\s *:?\\s *\\(?:(C)\\)?\
 \\|[Cc]opyright\\s *:?\\s *©\\)\
-\\s *\\(?:[^0-9\n]*\\s *\\)?\
+\\s *[^0-9\n]*\\s *\
 \\([1-9]\\([-0-9, ';/*%#\n\t]\\|\\s<\\|\\s>\\)*[0-9]+\\)"
   "What your copyright notice looks like.
 The second \\( \\) construct must match the years."
diff --git a/lisp/emacs-lisp/crm.el b/lisp/emacs-lisp/crm.el
index 3ec0bd8..40567e1 100644
--- a/lisp/emacs-lisp/crm.el
+++ b/lisp/emacs-lisp/crm.el
@@ -1,6 +1,6 @@
 ;;; crm.el --- read multiple strings with completion
 
-;; Copyright (C) 1985-1986, 1993-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1986, 1993-2019 Free Software Foundation, Inc.
 
 ;; Author: Sen Nagata <address@hidden>
 ;; Keywords: completion, minibuffer, multiple elements
diff --git a/lisp/emacs-lisp/cursor-sensor.el b/lisp/emacs-lisp/cursor-sensor.el
index 7e3088d..66b940f 100644
--- a/lisp/emacs-lisp/cursor-sensor.el
+++ b/lisp/emacs-lisp/cursor-sensor.el
@@ -1,6 +1,6 @@
 ;;; cursor-sensor.el --- React to cursor movement  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords:
@@ -22,17 +22,50 @@
 
 ;;; Commentary:
 
-;; This package implements the `cursor-intangible' property, which is
-;; meant to replace the old `intangible' property.  To use it, just enable the
-;; `cursor-intangible-mode', after which this package will move point away from
-;; any position that has a non-nil `cursor-intangible' property.  This is only
-;; done just before redisplay happens, contrary to the old `intangible'
-;; property which was done at a much lower level.
+;; This package implements the `cursor-intangible' and
+;; `cursor-sensor-functions' properties, which are meant to replace
+;; the old `intangible', `point-entered', and `point-left' properties.
+
+;; To use `cursor-intangible', just enable the
+;; `cursor-intangible-mode' minor mode, after which this package will
+;; move point away from any position that has a non-nil
+;; `cursor-intangible' property.  This is only done just before
+;; redisplay happens, contrary to the old `intangible' property which
+;; was done at a much lower level.
+
+;; To use `cursor-sensor-functions', enable the `cursor-sensor-mode'
+;; minor mode, after which the `cursor-sensor-functions' will be
+;; called just before redisplay happens, according to the movement of
+;; the cursor since the last redisplay.
+
+;;;; Motivation
+
+;; The old properties were very problematic in practice because they
+;; operate at a much lower level and hence affect all motion
+;; *functions* like goto-char, forward-char, ... hence breaking
+;; invariants like:
+;;
+;;    (forward-char N) == (progn (forward-char N1) (forward-char (- N N1)))
+;;    (point) == (progn (forward-char N) (forward-char -N) (point))
+;;    (+ N (point)) == (progn (forward-char N) (point))
+;;
+;; The problems would usually show up due to interaction between
+;; unrelated code working in the same buffer, where one code used those
+;; properties and the other (unknowingly) assumed those aren't used.
+;; In practice a *lot* of code assumes there's no such funny business.
+;;
+;; Worse: all(?) packages using those properties don't actually want those
+;; properties to affect motion at such a low-level, they only want to
+;; affect the overall effect of commands, but not the effect of every
+;; single point-motion that a given command happened to use internally.
 
 ;;; Code:
 
 ;;;###autoload
-(defvar cursor-sensor-inhibit nil)
+(defvar cursor-sensor-inhibit nil
+  "When non-nil, suspend `cursor-sensor-mode' and `cursor-intangible-mode'.
+By convention, this is a list of symbols where each symbol stands for the
+\"cause\" of the suspension.")
 
 (defun cursor-sensor--intangible-p (pos)
   (let ((p (get-pos-property pos 'cursor-intangible)))
@@ -127,7 +160,7 @@
         (setcdr old nil))
       (if (or (and (null new) (null (cdr old)))
               (and (eq new (cdr old))
-                   (eq (next-single-property-change
+                   (eq (next-single-char-property-change
                         start 'cursor-sensor-functions nil end)
                        end)))
           ;; Clearly nothing to do.
@@ -139,7 +172,7 @@
                   (let ((pos start)
                         (missing nil))
                     (while (< pos end)
-                      (setq pos (next-single-property-change
+                      (setq pos (next-single-char-property-change
                                  pos 'cursor-sensor-functions
                                  nil end))
                       (unless (memq f (get-char-property
diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el
index 34a2a13..8989aa0 100644
--- a/lisp/emacs-lisp/debug.el
+++ b/lisp/emacs-lisp/debug.el
@@ -1,6 +1,6 @@
 ;;; debug.el --- debuggers and related commands for Emacs  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1985-1986, 1994, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1985-1986, 1994, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Maintainer: address@hidden
@@ -236,14 +236,37 @@ first will be printed into the backtrace buffer."
                ;; Place an extra debug-on-exit for macro's.
                (when (eq 'lambda (car-safe (cadr (backtrace-frame 4))))
                  (backtrace-debug 5 t)))
+              (with-current-buffer debugger-buffer
+                (unless (derived-mode-p 'debugger-mode)
+                 (debugger-mode))
+               (debugger-setup-buffer debugger-args)
+               (when noninteractive
+                 ;; If the backtrace is long, save the beginning
+                 ;; and the end, but discard the middle.
+                 (when (> (count-lines (point-min) (point-max))
+                          debugger-batch-max-lines)
+                   (goto-char (point-min))
+                   (forward-line (/ 2 debugger-batch-max-lines))
+                   (let ((middlestart (point)))
+                     (goto-char (point-max))
+                     (forward-line (- (/ 2 debugger-batch-max-lines)
+                                      debugger-batch-max-lines))
+                     (delete-region middlestart (point)))
+                   (insert "...\n"))
+                 (goto-char (point-min))
+                 (message "%s" (buffer-string))
+                 (kill-emacs -1)))
              (pop-to-buffer
               debugger-buffer
               `((display-buffer-reuse-window
-                 display-buffer-in-previous-window)
-                . (,(when (and (window-live-p debugger-previous-window)
-                               (frame-visible-p
-                                (window-frame debugger-previous-window)))
-                      `(previous-window . ,debugger-previous-window)))))
+                 display-buffer-in-previous-window
+                 display-buffer-below-selected)
+                . ((window-min-height . 10)
+                    (window-height . fit-window-to-buffer)
+                   ,@(when (and (window-live-p debugger-previous-window)
+                                (frame-visible-p
+                                 (window-frame debugger-previous-window)))
+                       `((previous-window . ,debugger-previous-window))))))
              (setq debugger-window (selected-window))
              (if (eq debugger-previous-window debugger-window)
                  (when debugger-jumping-flag
@@ -256,25 +279,6 @@ first will be printed into the backtrace buffer."
                            (window-total-height debugger-window)))
                      (error nil)))
                (setq debugger-previous-window debugger-window))
-              (unless (derived-mode-p 'debugger-mode)
-               (debugger-mode))
-             (debugger-setup-buffer debugger-args)
-             (when noninteractive
-               ;; If the backtrace is long, save the beginning
-               ;; and the end, but discard the middle.
-               (when (> (count-lines (point-min) (point-max))
-                        debugger-batch-max-lines)
-                 (goto-char (point-min))
-                 (forward-line (/ 2 debugger-batch-max-lines))
-                 (let ((middlestart (point)))
-                   (goto-char (point-max))
-                   (forward-line (- (/ 2 debugger-batch-max-lines)
-                                    debugger-batch-max-lines))
-                   (delete-region middlestart (point)))
-                 (insert "...\n"))
-               (goto-char (point-min))
-               (message "%s" (buffer-string))
-               (kill-emacs -1))
              (message "")
              (let ((standard-output nil)
                    (buffer-read-only t))
@@ -740,7 +744,7 @@ This function is called when SYMBOL's value is modified."
 
 When called interactively, prompt for VARIABLE in the minibuffer.
 
-This works by calling `add-variable-watch' on VARIABLE.  If you
+This works by calling `add-variable-watcher' on VARIABLE.  If you
 quit from the debugger, this will abort the change (unless the
 change is caused by the termination of a let-binding).
 
diff --git a/lisp/emacs-lisp/derived.el b/lisp/emacs-lisp/derived.el
index 483d6fb..6db0584 100644
--- a/lisp/emacs-lisp/derived.el
+++ b/lisp/emacs-lisp/derived.el
@@ -1,7 +1,7 @@
 ;;; derived.el --- allow inheritance of major modes
 ;; (formerly mode-clone.el)
 
-;; Copyright (C) 1993-1994, 1999, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1993-1994, 1999, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: David Megginson (address@hidden)
diff --git a/lisp/emacs-lisp/disass.el b/lisp/emacs-lisp/disass.el
index 53f9b66..3fc2224 100644
--- a/lisp/emacs-lisp/disass.el
+++ b/lisp/emacs-lisp/disass.el
@@ -1,6 +1,6 @@
 ;;; disass.el --- disassembler for compiled Emacs Lisp code  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1986, 1991, 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1986, 1991, 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Doug Cutting <address@hidden>
 ;;     Jamie Zawinski <address@hidden>
diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index 035c65b..be531aa 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -1,6 +1,6 @@
 ;;; easy-mmode.el --- easy definition for major and minor modes
 
-;; Copyright (C) 1997, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Georges Brun-Cottan <address@hidden>
 ;; Maintainer: Stefan Monnier <address@hidden>
@@ -411,12 +411,6 @@ on if the hook has explicitly disabled it."
        (:global (setq keys (cdr keys)))
        (_ (push keyw extra-keywords) (push (pop keys) extra-keywords))))
 
-    (unless group
-      ;; We might as well provide a best-guess default group.
-      (setq group
-           `(:group ',(intern (replace-regexp-in-string
-                               "-mode\\'" "" (symbol-name mode))))))
-
     `(progn
        (progn
          :autoload-end
@@ -624,12 +618,11 @@ BODY is executed after moving to the destination 
location."
          (when-narrowed
           (lambda (body)
             (if (null narrowfun) body
-              `(let ((was-narrowed
-                      (prog1 (or (< (- (point-max) (point-min)) (buffer-size)))
-                        (widen))))
+              `(let ((was-narrowed (prog1 (buffer-narrowed-p) (widen))))
                  ,body
                  (when was-narrowed (funcall #',narrowfun)))))))
     (unless name (setq name base-name))
+    ;; FIXME: Move most of those functions's bodies to helper functions!
     `(progn
        (defun ,next-sym (&optional count)
         ,(format "Go to the next COUNT'th %s.
@@ -651,7 +644,11 @@ Interactively, COUNT is the prefix numeric argument, and 
defaults to 1." name)
                                         `(re-search-forward ,re nil t 2)))
                                    (point-max))))
                     (unless (pos-visible-in-window-p endpt nil t)
-                      (recenter '(0)))))))
+                      (let ((ws (window-start)))
+                        (recenter '(0))
+                        (if (< (window-start) ws)
+                            ;; recenter scrolled in the wrong direction!
+                            (set-window-start nil ws))))))))
            ,@body))
        (put ',next-sym 'definition-name ',base)
        (defun ,prev-sym (&optional count)
diff --git a/lisp/emacs-lisp/easymenu.el b/lisp/emacs-lisp/easymenu.el
index 403829a..5bf046d 100644
--- a/lisp/emacs-lisp/easymenu.el
+++ b/lisp/emacs-lisp/easymenu.el
@@ -1,6 +1,6 @@
 ;;; easymenu.el --- support the easymenu interface for defining a menu  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1994, 1996, 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1996, 1998-2019 Free Software Foundation, Inc.
 
 ;; Keywords: emulations
 ;; Author: Richard Stallman <address@hidden>
diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el
index b50b038..6dfcc24 100644
--- a/lisp/emacs-lisp/edebug.el
+++ b/lisp/emacs-lisp/edebug.el
@@ -1,6 +1,6 @@
 ;;; edebug.el --- a source-level debugger for Emacs Lisp  -*- lexical-binding: 
t -*-
 
-;; Copyright (C) 1988-1995, 1997, 1999-2018 Free Software Foundation,
+;; Copyright (C) 1988-1995, 1997, 1999-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Daniel LaLiberte <address@hidden>
@@ -2165,7 +2165,6 @@ into `edebug--cl-macrolet-defs' which is checked in 
`edebug-list-form-args'."
 (def-edebug-spec let* let)
 
 (def-edebug-spec setq (&rest symbolp form))
-(def-edebug-spec setq-default setq)
 
 (def-edebug-spec cond (&rest (&rest form)))
 
@@ -3602,9 +3601,7 @@ Return the result of the last expression."
   "Evaluate an expression in the outside environment.
 If interactive, prompt for the expression.
 Print result in minibuffer."
-  (interactive (list (read-from-minibuffer
-                     "Eval: " nil read-expression-map t
-                     'read-expression-history)))
+  (interactive (list (read--expression "Eval: ")))
   (princ
    (edebug-outside-excursion
     (setq values (cons (edebug-eval expr) values))
diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el
index 75709dd..3a01098 100644
--- a/lisp/emacs-lisp/eieio-base.el
+++ b/lisp/emacs-lisp/eieio-base.el
@@ -1,6 +1,6 @@
 ;;; eieio-base.el --- Base classes for EIEIO.  -*- lexical-binding:t -*-
 
-;;; Copyright (C) 2000-2002, 2004-2005, 2007-2018 Free Software
+;;; Copyright (C) 2000-2002, 2004-2005, 2007-2019 Free Software
 ;;; Foundation, Inc.
 
 ;; Author: Eric M. Ludlam  <address@hidden>
diff --git a/lisp/emacs-lisp/eieio-compat.el b/lisp/emacs-lisp/eieio-compat.el
index e343dcf..ea5a283 100644
--- a/lisp/emacs-lisp/eieio-compat.el
+++ b/lisp/emacs-lisp/eieio-compat.el
@@ -1,6 +1,6 @@
 ;;; eieio-compat.el --- Compatibility with Older EIEIO versions  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1995-1996, 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-1996, 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: OO, lisp
diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el
index e5c4f19..31ee6c5 100644
--- a/lisp/emacs-lisp/eieio-core.el
+++ b/lisp/emacs-lisp/eieio-core.el
@@ -1,6 +1,6 @@
 ;;; eieio-core.el --- Core implementation for eieio  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1995-1996, 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-1996, 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Version: 1.4
diff --git a/lisp/emacs-lisp/eieio-custom.el b/lisp/emacs-lisp/eieio-custom.el
index 3ee5a29..e018883 100644
--- a/lisp/emacs-lisp/eieio-custom.el
+++ b/lisp/emacs-lisp/eieio-custom.el
@@ -1,6 +1,6 @@
 ;;; eieio-custom.el -- eieio object customization  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2001, 2005, 2007-2018 Free Software Foundation,
+;; Copyright (C) 1999-2001, 2005, 2007-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
diff --git a/lisp/emacs-lisp/eieio-datadebug.el 
b/lisp/emacs-lisp/eieio-datadebug.el
index f309117..df17e81 100644
--- a/lisp/emacs-lisp/eieio-datadebug.el
+++ b/lisp/emacs-lisp/eieio-datadebug.el
@@ -1,6 +1,6 @@
 ;;; eieio-datadebug.el --- EIEIO extensions to the data debugger.  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: OO, lisp
diff --git a/lisp/emacs-lisp/eieio-opt.el b/lisp/emacs-lisp/eieio-opt.el
index eeb0bc9..193f92b 100644
--- a/lisp/emacs-lisp/eieio-opt.el
+++ b/lisp/emacs-lisp/eieio-opt.el
@@ -1,6 +1,6 @@
 ;;; eieio-opt.el -- eieio optional functions (debug, printing, speedbar)
 
-;; Copyright (C) 1996, 1998-2003, 2005, 2008-2018 Free Software
+;; Copyright (C) 1996, 1998-2003, 2005, 2008-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
@@ -327,7 +327,7 @@ current expansion depth."
 (defun eieio-sb-expand (text class indent)
   "For button TEXT, expand CLASS at the current location.
 Argument INDENT is the depth of indentation."
-  (cond ((string-match "+" text)       ;we have to expand this file
+  (cond ((string-match "\\+" text)     ;we have to expand this file
         (speedbar-change-expand-button-char ?-)
         (speedbar-with-writable
           (save-excursion
diff --git a/lisp/emacs-lisp/eieio-speedbar.el 
b/lisp/emacs-lisp/eieio-speedbar.el
index 3553e47..2dd9a5e 100644
--- a/lisp/emacs-lisp/eieio-speedbar.el
+++ b/lisp/emacs-lisp/eieio-speedbar.el
@@ -1,6 +1,6 @@
 ;;; eieio-speedbar.el -- Classes for managing speedbar displays.  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1999-2002, 2005, 2007-2018 Free Software Foundation,
+;; Copyright (C) 1999-2002, 2005, 2007-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
@@ -348,7 +348,7 @@ The object is at indentation level INDENT."
 (defun eieio-speedbar-object-expand (text token indent)
   "Expand object represented by TEXT.
 TOKEN is the object.  INDENT is the current indentation level."
-  (cond ((string-match "+" text)       ;we have to expand this file
+  (cond ((string-match "\\+" text)     ;we have to expand this file
         (speedbar-change-expand-button-char ?-)
         (oset token expanded t)
         (speedbar-with-writable
diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el
index 98cdd4f..b6ec191 100644
--- a/lisp/emacs-lisp/eieio.el
+++ b/lisp/emacs-lisp/eieio.el
@@ -1,7 +1,7 @@
 ;;; eieio.el --- Enhanced Implementation of Emacs Interpreted Objects  -*- 
lexical-binding:t -*-
 ;;;              or maybe Eric's Implementation of Emacs Interpreted Objects
 
-;; Copyright (C) 1995-1996, 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-1996, 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Version: 1.4
diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el
index 21be4f3..188d99e 100644
--- a/lisp/emacs-lisp/eldoc.el
+++ b/lisp/emacs-lisp/eldoc.el
@@ -1,6 +1,6 @@
 ;;; eldoc.el --- Show function arglist or variable docstring in echo area  -*- 
lexical-binding:t; -*-
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Noah Friedman <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/emacs-lisp/elint.el b/lisp/emacs-lisp/elint.el
index 391d3fd..3f49b51 100644
--- a/lisp/emacs-lisp/elint.el
+++ b/lisp/emacs-lisp/elint.el
@@ -1,6 +1,6 @@
 ;;; elint.el --- Lint Emacs Lisp -*- lexical-binding: t -*-
 
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Peter Liljenberg <address@hidden>
 ;; Created: May 1997
diff --git a/lisp/emacs-lisp/elp.el b/lisp/emacs-lisp/elp.el
index 012e7cf..f0dcb51 100644
--- a/lisp/emacs-lisp/elp.el
+++ b/lisp/emacs-lisp/elp.el
@@ -1,6 +1,6 @@
 ;;; elp.el --- Emacs Lisp Profiler  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1994-1995, 1997-1998, 2001-2018 Free Software
+;; Copyright (C) 1994-1995, 1997-1998, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Barry A. Warsaw
diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el
index a883feb..ee561d5 100644
--- a/lisp/emacs-lisp/ert-x.el
+++ b/lisp/emacs-lisp/ert-x.el
@@ -1,6 +1,6 @@
 ;;; ert-x.el --- Staging area for experimental extensions to ERT  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2008, 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008, 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Lennart Borgman (lennart O borgman A gmail O com)
 ;;         Christian Ohler <address@hidden>
diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index 9702a11..20d013b 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -1,6 +1,6 @@
 ;;; ert.el --- Emacs Lisp Regression Testing  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2007-2008, 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2008, 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Christian Ohler <address@hidden>
 ;; Keywords: lisp, tools
@@ -1563,7 +1563,8 @@ Ran \\([0-9]+\\) tests, \\([0-9]+\\) results as expected\
       (message "-------")
       (with-temp-buffer
         (dolist (x (list (list skipped "skipped" "SKIPPED")
-                         (list unexpected "unexpected" "FAILED")))
+                         (list unexpected "unexpected"
+                               "\\(?:FAILED\\|PASSED\\)")))
           (mapc (lambda (l)
                   (erase-buffer)
                   (insert-file-contents l)
@@ -1821,13 +1822,13 @@ determines how frequently the progress display is 
updated.")
   (force-mode-line-update)
   (redisplay t)
   (setf (ert--stats-next-redisplay stats)
-        (+ (float-time) ert-test-run-redisplay-interval-secs)))
+       (float-time (time-add nil ert-test-run-redisplay-interval-secs))))
 
 (defun ert--results-update-stats-display-maybe (ewoc stats)
   "Call `ert--results-update-stats-display' if not called recently.
 
 EWOC and STATS are arguments for `ert--results-update-stats-display'."
-  (when (>= (float-time) (ert--stats-next-redisplay stats))
+  (unless (time-less-p nil (ert--stats-next-redisplay stats))
     (ert--results-update-stats-display ewoc stats)))
 
 (defun ert--tests-running-mode-line-indicator ()
diff --git a/lisp/emacs-lisp/ewoc.el b/lisp/emacs-lisp/ewoc.el
index 52d8451..c33b465 100644
--- a/lisp/emacs-lisp/ewoc.el
+++ b/lisp/emacs-lisp/ewoc.el
@@ -1,6 +1,6 @@
 ;;; ewoc.el --- utility to maintain a view of a list of objects in a buffer  
-*- lexical-binding: t -*-
 
-;; Copyright (C) 1991-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1991-2019 Free Software Foundation, Inc.
 
 ;; Author: Per Cederqvist <address@hidden>
 ;;     Inge Wallin <address@hidden>
diff --git a/lisp/emacs-lisp/faceup.el b/lisp/emacs-lisp/faceup.el
index bbf4c5d..7527f53 100644
--- a/lisp/emacs-lisp/faceup.el
+++ b/lisp/emacs-lisp/faceup.el
@@ -1,6 +1,6 @@
 ;;; faceup.el --- Markup language for faces and font-lock regression testing  
-*- lexical-binding: t -*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Anders Lindgren
 ;; Version: 0.0.6
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index c542469..b63d4d4 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -1,6 +1,6 @@
 ;;; find-func.el --- find the definition of the Emacs Lisp function near point 
 -*- lexical-binding:t -*-
 
-;; Copyright (C) 1997, 1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1999, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Jens Petersen <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/emacs-lisp/float-sup.el b/lisp/emacs-lisp/float-sup.el
index 45933bb..54c8afe 100644
--- a/lisp/emacs-lisp/float-sup.el
+++ b/lisp/emacs-lisp/float-sup.el
@@ -1,6 +1,6 @@
 ;;; float-sup.el --- define some constants useful for floating point numbers.
 
-;; Copyright (C) 1985-1987, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1987, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: internal
diff --git a/lisp/emacs-lisp/generator.el b/lisp/emacs-lisp/generator.el
index 6378321..caf5fed 100644
--- a/lisp/emacs-lisp/generator.el
+++ b/lisp/emacs-lisp/generator.el
@@ -1,6 +1,6 @@
 ;;; generator.el --- generators  -*- lexical-binding: t -*-
 
-;;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Daniel Colascione <address@hidden>
 ;; Keywords: extensions, elisp
@@ -374,13 +374,6 @@ don't yield.")
                       `(setf ,cps--value-symbol ,temp-var-symbol
                              ,cps--state-symbol ,next-state))))))))
 
-    ;; Process `prog2'.
-
-    (`(prog2 ,form1 ,form2 . ,body)
-      (cps--transform-1
-       `(progn ,form1 (prog1 ,form2 ,@body))
-       next-state))
-
     ;; Process `unwind-protect': If we're inside an unwind-protect, we
     ;; have a block of code UNWINDFORMS which we would like to run
     ;; whenever control flows away from the main piece of code,
diff --git a/lisp/emacs-lisp/generic.el b/lisp/emacs-lisp/generic.el
index 194fa1e..678d384 100644
--- a/lisp/emacs-lisp/generic.el
+++ b/lisp/emacs-lisp/generic.el
@@ -1,6 +1,6 @@
 ;;; generic.el --- defining simple major modes with comment and font-lock
 ;;
-;; Copyright (C) 1997, 1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1999, 2001-2019 Free Software Foundation, Inc.
 ;;
 ;; Author:  Peter Breton <address@hidden>
 ;; Created: Fri Sep 27 1996
diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el
index 6bfc32c..4ea3ce8 100644
--- a/lisp/emacs-lisp/gv.el
+++ b/lisp/emacs-lisp/gv.el
@@ -1,6 +1,6 @@
 ;;; gv.el --- generalized variables  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords: extensions
diff --git a/lisp/emacs-lisp/helper.el b/lisp/emacs-lisp/helper.el
index 58fd17d..d1bd46f 100644
--- a/lisp/emacs-lisp/helper.el
+++ b/lisp/emacs-lisp/helper.el
@@ -1,6 +1,6 @@
 ;;; helper.el --- utility help package supporting help in electric modes
 
-;; Copyright (C) 1985, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: K. Shane Hartman
 ;; Maintainer: address@hidden
diff --git a/lisp/emacs-lisp/inline.el b/lisp/emacs-lisp/inline.el
index b6afcc0..70dbff2 100644
--- a/lisp/emacs-lisp/inline.el
+++ b/lisp/emacs-lisp/inline.el
@@ -1,6 +1,6 @@
 ;;; inline.el --- Define functions by their inliner  -*- lexical-binding:t; -*-
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 
diff --git a/lisp/emacs-lisp/let-alist.el b/lisp/emacs-lisp/let-alist.el
index 17732bc..dc54342 100644
--- a/lisp/emacs-lisp/let-alist.el
+++ b/lisp/emacs-lisp/let-alist.el
@@ -1,6 +1,6 @@
 ;;; let-alist.el --- Easily let-bind values of an assoc-list by their names 
-*- lexical-binding: t; -*-
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Artur Malabarba <address@hidden>
 ;; Package-Requires: ((emacs "24.1"))
diff --git a/lisp/emacs-lisp/lisp-mnt.el b/lisp/emacs-lisp/lisp-mnt.el
index 5c623a3..91c7615 100644
--- a/lisp/emacs-lisp/lisp-mnt.el
+++ b/lisp/emacs-lisp/lisp-mnt.el
@@ -1,6 +1,6 @@
 ;;; lisp-mnt.el --- utility functions for Emacs Lisp maintainers  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1992, 1994, 1997, 2000-2018 Free Software Foundation,
+;; Copyright (C) 1992, 1994, 1997, 2000-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Eric S. Raymond <address@hidden>
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 4619919..4c7a8be 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -1,6 +1,6 @@
 ;;; lisp-mode.el --- Lisp mode, and its idiosyncratic commands  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1985-1986, 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1986, 1999-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: lisp, languages
@@ -1183,7 +1183,6 @@ Lisp function does not specify a special indentation."
 (put 'autoload 'lisp-indent-function 'defun) ;Elisp
 (put 'progn 'lisp-indent-function 0)
 (put 'prog1 'lisp-indent-function 1)
-(put 'prog2 'lisp-indent-function 2)
 (put 'save-excursion 'lisp-indent-function 0)      ;Elisp
 (put 'save-restriction 'lisp-indent-function 0)    ;Elisp
 (put 'save-current-buffer 'lisp-indent-function 0) ;Elisp
diff --git a/lisp/emacs-lisp/lisp.el b/lisp/emacs-lisp/lisp.el
index 3fda1dd..d10d5f0 100644
--- a/lisp/emacs-lisp/lisp.el
+++ b/lisp/emacs-lisp/lisp.el
@@ -1,6 +1,6 @@
 ;;; lisp.el --- Lisp editing commands for Emacs  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1985-1986, 1994, 2000-2018 Free Software Foundation,
+;; Copyright (C) 1985-1986, 1994, 2000-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el
index 2418264..9af7532 100644
--- a/lisp/emacs-lisp/macroexp.el
+++ b/lisp/emacs-lisp/macroexp.el
@@ -1,6 +1,6 @@
 ;;; macroexp.el --- Additional macro-expansion support -*- lexical-binding: t 
-*-
 ;;
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Miles Bader <address@hidden>
 ;; Keywords: lisp, compiler, macros
@@ -94,7 +94,7 @@ each clause."
       clause)))
 
 (defun macroexp--compiler-macro (handler form)
-  (condition-case err
+  (condition-case-unless-debug err
       (apply handler form (cdr form))
     (error
      (message "Compiler-macro error for %S: %S" (car form) err)
diff --git a/lisp/emacs-lisp/map-ynp.el b/lisp/emacs-lisp/map-ynp.el
index 27e8ea6..a688330 100644
--- a/lisp/emacs-lisp/map-ynp.el
+++ b/lisp/emacs-lisp/map-ynp.el
@@ -1,6 +1,6 @@
 ;;; map-ynp.el --- general-purpose boolean question-asker  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1991-1995, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1991-1995, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Roland McGrath <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/emacs-lisp/map.el b/lisp/emacs-lisp/map.el
index 987521d..54e802e 100644
--- a/lisp/emacs-lisp/map.el
+++ b/lisp/emacs-lisp/map.el
@@ -1,10 +1,11 @@
 ;;; map.el --- Map manipulation functions  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Nicolas Petton <address@hidden>
 ;; Keywords: convenience, map, hash-table, alist, array
-;; Version: 1.2
+;; Version: 2.0
+;; Package-Requires: ((emacs "25"))
 ;; Package: map
 
 ;; Maintainer: address@hidden
@@ -92,17 +93,21 @@ Returns the result of evaluating the form associated with 
MAP-VAR's type."
     `(cond ((listp ,map-var) ,(plist-get args :list))
            ((hash-table-p ,map-var) ,(plist-get args :hash-table))
            ((arrayp ,map-var) ,(plist-get args :array))
-           (t (error "Unsupported map: %s" ,map-var)))))
+           (t (error "Unsupported map type `%S': %S"
+                     (type-of ,map-var) ,map-var)))))
 
-(defun map-elt (map key &optional default testfn)
+(define-error 'map-not-inplace "Cannot modify map in-place")
+
+(defsubst map--plist-p (list)
+  (and (consp list) (not (listp (car list)))))
+
+(cl-defgeneric map-elt (map key &optional default testfn)
   "Lookup KEY in MAP and return its associated value.
 If KEY is not found, return DEFAULT which defaults to nil.
 
-If MAP is a list, `eql' is used to lookup KEY.  Optional argument
-TESTFN, if non-nil, means use its function definition instead of
-`eql'.
+TESTFN is deprecated.  Its default depends on the MAP argument.
 
-MAP can be a list, hash-table or array."
+In the base definition, MAP can be an alist, hash-table, or array."
   (declare
    (gv-expander
     (lambda (do)
@@ -110,17 +115,23 @@ MAP can be a list, hash-table or array."
         (macroexp-let2* nil
             ;; Eval them once and for all in the right order.
             ((key key) (default default) (testfn testfn))
-          `(if (listp ,mgetter)
-               ;; Special case the alist case, since it can't be handled by the
-               ;; map--put function.
-               ,(gv-get `(alist-get ,key (gv-synthetic-place
-                                          ,mgetter ,msetter)
-                                    ,default nil ,testfn)
-                        do)
-             ,(funcall do `(map-elt ,mgetter ,key ,default)
-                       (lambda (v) `(map--put ,mgetter ,key ,v)))))))))
+          (funcall do `(map-elt ,mgetter ,key ,default)
+                   (lambda (v)
+                     `(condition-case nil
+                          ;; Silence warnings about the hidden 4th arg.
+                          (with-no-warnings (map-put! ,mgetter ,key ,v 
,testfn))
+                        (map-not-inplace
+                         ,(funcall msetter
+                                   `(map-insert ,mgetter ,key ,v))))))))))
+   ;; `testfn' is deprecated.
+   (advertised-calling-convention (map key &optional default) "27.1"))
   (map--dispatch map
-    :list (alist-get key map default nil testfn)
+    :list (if (map--plist-p map)
+              (let ((res (plist-get map key)))
+                (if (and default (null res) (not (plist-member map key)))
+                    default
+                  res))
+            (alist-get key map default nil testfn))
     :hash-table (gethash key map default)
     :array (if (and (>= key 0) (< key (seq-length map)))
                (seq-elt map key)
@@ -133,16 +144,34 @@ with VALUE.
 When MAP is a list, test equality with TESTFN if non-nil, otherwise use `eql'.
 
 MAP can be a list, hash-table or array."
+  (declare (obsolete "use map-put! or (setf (map-elt ...) ...) instead" 
"27.1"))
   `(setf (map-elt ,map ,key nil ,testfn) ,value))
 
-(defun map-delete (map key)
-  "Delete KEY from MAP and return MAP.
-No error is signaled if KEY is not a key of MAP.  If MAP is an
-array, store nil at the index KEY.
-
-MAP can be a list, hash-table or array."
+(defun map--plist-delete (map key)
+  (let ((tail map) last)
+    (while (consp tail)
+      (cond
+       ((not (equal key (car tail)))
+        (setq last tail)
+        (setq tail (cddr last)))
+       (last
+        (setq tail (cddr tail))
+        (setf (cddr last) tail))
+       (t
+        (cl-assert (eq tail map))
+        (setq map (cddr map))
+        (setq tail map))))
+    map))
+
+(cl-defgeneric map-delete (map key)
+  "Delete KEY in-place from MAP and return MAP.
+No error is signaled if KEY is not a key of MAP.
+If MAP is an array, store nil at the index KEY."
   (map--dispatch map
-    :list (setf (alist-get key map nil t) nil)
+    ;; FIXME: Signal map-not-inplace i.s.o returning a different list?
+    :list (if (map--plist-p map)
+              (setq map (map--plist-delete map key))
+            (setf (alist-get key map nil t) nil))
     :hash-table (remhash key map)
     :array (and (>= key 0)
                 (<= key (seq-length map))
@@ -160,120 +189,133 @@ Map can be a nested map composed of alists, hash-tables 
and arrays."
                   map)
       default))
 
-(defun map-keys (map)
+(cl-defgeneric map-keys (map)
   "Return the list of keys in MAP.
-
-MAP can be a list, hash-table or array."
+The default implementation delegates to `map-apply'."
   (map-apply (lambda (key _) key) map))
 
-(defun map-values (map)
+(cl-defgeneric map-values (map)
   "Return the list of values in MAP.
-
-MAP can be a list, hash-table or array."
+The default implementation delegates to `map-apply'."
   (map-apply (lambda (_ value) value) map))
 
-(defun map-pairs (map)
+(cl-defgeneric map-pairs (map)
   "Return the elements of MAP as key/value association lists.
-
-MAP can be a list, hash-table or array."
+The default implementation delegates to `map-apply'."
   (map-apply #'cons map))
 
-(defun map-length (map)
-  "Return the length of MAP.
-
-MAP can be a list, hash-table or array."
-  (length (map-keys map)))
-
-(defun map-copy (map)
-  "Return a copy of MAP.
-
-MAP can be a list, hash-table or array."
+(cl-defgeneric map-length (map)
+  ;; FIXME: Should we rename this to `map-size'?
+  "Return the number of elements in the map.
+The default implementation counts `map-keys'."
+  (cond
+   ((hash-table-p map) (hash-table-count map))
+   ((listp map)
+    ;; FIXME: What about repeated/shadowed keys?
+    (if (map--plist-p map) (/ (length map) 2) (length map)))
+   ((arrayp map) (length map))
+   (t (length (map-keys map)))))
+
+(cl-defgeneric map-copy (map)
+  "Return a copy of MAP."
+  ;; FIXME: Clarify how deep is the copy!
   (map--dispatch map
-    :list (seq-copy map)
+    :list (seq-copy map)           ;FIXME: Probably not deep enough for alists!
     :hash-table (copy-hash-table map)
     :array (seq-copy map)))
 
-(defun map-apply (function map)
+(cl-defgeneric map-apply (function map)
   "Apply FUNCTION to each element of MAP and return the result as a list.
 FUNCTION is called with two arguments, the key and the value.
+The default implementation delegates to `map-do'."
+  (let ((res '()))
+    (map-do (lambda (k v) (push (funcall function k v) res)) map)
+    (nreverse res)))
 
-MAP can be a list, hash-table or array."
-  (funcall (map--dispatch map
-             :list #'map--apply-alist
-             :hash-table #'map--apply-hash-table
-             :array #'map--apply-array)
-           function
-           map))
-
-(defun map-do (function map)
+(cl-defgeneric map-do (function map)
   "Apply FUNCTION to each element of MAP and return nil.
-FUNCTION is called with two arguments, the key and the value."
-  (funcall (map--dispatch map
-             :list #'map--do-alist
-             :hash-table #'maphash
-             :array #'map--do-array)
-           function
-           map))
-
-(defun map-keys-apply (function map)
-  "Return the result of applying FUNCTION to each key of MAP.
+FUNCTION is called with two arguments, the key and the value.")
 
-MAP can be a list, hash-table or array."
+;; FIXME: I wish there was a way to avoid this η-redex!
+(cl-defmethod map-do (function (map hash-table)) (maphash function map))
+
+(cl-defgeneric map-keys-apply (function map)
+  "Return the result of applying FUNCTION to each key of MAP.
+The default implementation delegates to `map-apply'."
   (map-apply (lambda (key _)
                (funcall function key))
              map))
 
-(defun map-values-apply (function map)
+(cl-defgeneric map-values-apply (function map)
   "Return the result of applying FUNCTION to each value of MAP.
-
-MAP can be a list, hash-table or array."
+The default implementation delegates to `map-apply'."
   (map-apply (lambda (_ val)
                (funcall function val))
              map))
 
-(defun map-filter (pred map)
+(cl-defgeneric map-filter (pred map)
   "Return an alist of key/val pairs for which (PRED key val) is non-nil in MAP.
-
-MAP can be a list, hash-table or array."
+The default implementation delegates to `map-apply'."
   (delq nil (map-apply (lambda (key val)
                          (if (funcall pred key val)
                              (cons key val)
                            nil))
                        map)))
 
-(defun map-remove (pred map)
+(cl-defgeneric map-remove (pred map)
   "Return an alist of the key/val pairs for which (PRED key val) is nil in MAP.
-
-MAP can be a list, hash-table or array."
+The default implementation delegates to `map-filter'."
   (map-filter (lambda (key val) (not (funcall pred key val)))
               map))
 
-(defun mapp (map)
-  "Return non-nil if MAP is a map (list, hash-table or array)."
+(cl-defgeneric mapp (map)
+  "Return non-nil if MAP is a map (alist, hash-table, array, ...)."
   (or (listp map)
       (hash-table-p map)
       (arrayp map)))
 
-(defun map-empty-p (map)
+(cl-defgeneric map-empty-p (map)
   "Return non-nil if MAP is empty.
+The default implementation delegates to `map-length'."
+  (zerop (map-length map)))
+
+(cl-defmethod map-empty-p ((map list))
+  (null map))
+
+(cl-defgeneric map-contains-key (map key &optional testfn)
+  ;; FIXME: The test function to use generally depends on the map object,
+  ;; so specifying `testfn' here is problematic: e.g. for hash-tables
+  ;; we shouldn't use `gethash' unless `testfn' is the same as the map's own
+  ;; test function!
+  "Return non-nil If and only if MAP contains KEY.
+TESTFN is deprecated.  Its default depends on MAP.
+The default implementation delegates to `map-do'."
+  (unless testfn (setq testfn #'equal))
+  (catch 'map--catch
+    (map-do (lambda (k _v)
+              (if (funcall testfn key k) (throw 'map--catch t)))
+            map)
+    nil))
 
-MAP can be a list, hash-table or array."
-  (map--dispatch map
-    :list (null map)
-    :array (seq-empty-p map)
-    :hash-table (zerop (hash-table-count map))))
-
-(defun map-contains-key (map key &optional testfn)
-  "If MAP contain KEY return KEY, nil otherwise.
-Equality is defined by TESTFN if non-nil or by `equal' if nil.
-
-MAP can be a list, hash-table or array."
-  (seq-contains (map-keys map) key testfn))
-
-(defun map-some (pred map)
-  "Return a non-nil if (PRED key val) is non-nil for any key/value pair in MAP.
-
-MAP can be a list, hash-table or array."
+(cl-defmethod map-contains-key ((map list) key &optional testfn)
+  (let ((v '(nil)))
+    (not (eq v (alist-get key map v nil (or testfn #'equal))))))
+
+(cl-defmethod map-contains-key ((map array) key &optional _testfn)
+  (and (integerp key)
+       (>= key 0)
+       (< key (length map))))
+
+(cl-defmethod map-contains-key ((map hash-table) key &optional _testfn)
+  (let ((v '(nil)))
+    (not (eq v (gethash key map v)))))
+
+(cl-defgeneric map-some (pred map)
+  "Return the first non-nil (PRED key val) in MAP.
+The default implementation delegates to `map-apply'."
+  ;; FIXME: Not sure if there's much benefit to defining it as defgeneric,
+  ;; since as defined, I can't think of a map-type where we could provide an
+  ;; algorithmically more efficient algorithm than the default.
   (catch 'map--break
     (map-apply (lambda (key value)
                  (let ((result (funcall pred key value)))
@@ -282,10 +324,12 @@ MAP can be a list, hash-table or array."
                map)
     nil))
 
-(defun map-every-p (pred map)
+(cl-defgeneric map-every-p (pred map)
   "Return non-nil if (PRED key val) is non-nil for all elements of the map MAP.
-
-MAP can be a list, hash-table or array."
+The default implementation delegates to `map-apply'."
+  ;; FIXME: Not sure if there's much benefit to defining it as defgeneric,
+  ;; since as defined, I can't think of a map-type where we could provide an
+  ;; algorithmically more efficient algorithm than the default.
   (catch 'map--break
     (map-apply (lambda (key value)
               (or (funcall pred key value)
@@ -294,9 +338,7 @@ MAP can be a list, hash-table or array."
     t))
 
 (defun map-merge (type &rest maps)
-  "Merge into a map of type TYPE all the key/value pairs in MAPS.
-
-MAP can be a list, hash-table or array."
+  "Merge into a map of type TYPE all the key/value pairs in MAPS."
   (let ((result (map-into (pop maps) type)))
     (while maps
       ;; FIXME: When `type' is `list', we get an O(N^2) behavior.
@@ -310,7 +352,7 @@ MAP can be a list, hash-table or array."
 
 (defun map-merge-with (type function &rest maps)
   "Merge into a map of type TYPE all the key/value pairs in MAPS.
-When two maps contain the same key, call FUNCTION on the two
+When two maps contain the same key (`eql'), call FUNCTION on the two
 values and use the value returned by it.
 MAP can be a list, hash-table or array."
   (let ((result (map-into (pop maps) type))
@@ -318,49 +360,80 @@ MAP can be a list, hash-table or array."
     (while maps
       (map-apply (lambda (key value)
                    (cl-callf (lambda (old)
-                               (if (eq old not-found)
+                               (if (eql old not-found)
                                    value
                                  (funcall function old value)))
                        (map-elt result key not-found)))
                  (pop maps)))
     result))
 
-(defun map-into (map type)
-  "Convert the map MAP into a map of type TYPE.
-
-TYPE can be one of the following symbols: list or hash-table.
-MAP can be a list, hash-table or array."
-  (pcase type
-    ('list (map-pairs map))
-    ('hash-table (map--into-hash-table map))
-    (_ (error "Not a map type name: %S" type))))
-
-(defun map--put (map key v)
+(cl-defgeneric map-into (map type)
+  "Convert the map MAP into a map of type TYPE.")
+;; FIXME: I wish there was a way to avoid this η-redex!
+(cl-defmethod map-into (map (_type (eql list))) (map-pairs map))
+(cl-defmethod map-into (map (_type (eql alist))) (map-pairs map))
+(cl-defmethod map-into (map (_type (eql plist)))
+  (let ((plist '()))
+    (map-do (lambda (k v) (setq plist `(,k ,v ,@plist))) map)
+    plist))
+
+(cl-defgeneric map-put! (map key value &optional testfn)
+  "Associate KEY with VALUE in MAP.
+If KEY is already present in MAP, replace the associated value
+with VALUE.
+This operates by modifying MAP in place.
+If it cannot do that, it signals the `map-not-inplace' error.
+If you want to insert an element without modifying MAP, use `map-insert'."
+  ;; `testfn' only exists for backward compatibility with `map-put'!
+  (declare (advertised-calling-convention (map key value) "27.1"))
   (map--dispatch map
-    :list (let ((p (assoc key map)))
-            (if p (setcdr p v)
-              (error "No place to change the mapping for %S" key)))
-    :hash-table (puthash key v map)
-    :array (aset map key v)))
-
-(defun map--apply-alist (function map)
-  "Private function used to apply FUNCTION over MAP, MAP being an alist."
-  (seq-map (lambda (pair)
-             (funcall function
-                      (car pair)
-                      (cdr pair)))
-           map))
-
-(defun map--apply-hash-table (function map)
-  "Private function used to apply FUNCTION over MAP, MAP being a hash-table."
+    :list
+    (if (map--plist-p map)
+        (plist-put map key value)
+      (let ((oldmap map))
+        (setf (alist-get key map key nil (or testfn #'equal)) value)
+        (unless (eq oldmap map)
+          (signal 'map-not-inplace (list oldmap)))))
+    :hash-table (puthash key value map)
+    ;; FIXME: If `key' is too large, should we signal `map-not-inplace'
+    ;; and let `map-insert' grow the array?
+    :array (aset map key value)))
+
+(define-error 'map-inplace "Can only modify map in place")
+
+(cl-defgeneric map-insert (map key value)
+  "Return a new map like MAP except that it associates KEY with VALUE.
+This does not modify MAP.
+If you want to insert an element in place, use `map-put!'."
+  (if (listp map)
+      (if (map--plist-p map)
+          `(,key ,value ,@map)
+        (cons (cons key value) map))
+    ;; FIXME: Should we signal an error or use copy+put! ?
+    (signal 'map-inplace (list map))))
+
+;; There shouldn't be old source code referring to `map--put', yet we do
+;; need to keep it for backward compatibility with .elc files where the
+;; expansion of `setf' may call this function.
+(define-obsolete-function-alias 'map--put #'map-put! "27.1")
+
+(cl-defmethod map-apply (function (map list))
+  (if (map--plist-p map)
+      (cl-call-next-method)
+    (seq-map (lambda (pair)
+               (funcall function
+                        (car pair)
+                        (cdr pair)))
+             map)))
+
+(cl-defmethod map-apply (function (map hash-table))
   (let (result)
     (maphash (lambda (key value)
                (push (funcall function key value) result))
              map)
     (nreverse result)))
 
-(defun map--apply-array (function map)
-  "Private function used to apply FUNCTION over MAP, MAP being an array."
+(cl-defmethod map-apply (function (map array))
   (let ((index 0))
     (seq-map (lambda (elt)
                (prog1
@@ -368,22 +441,27 @@ MAP can be a list, hash-table or array."
                  (setq index (1+ index))))
              map)))
 
-(defun map--do-alist (function alist)
+(cl-defmethod map-do (function (map list))
   "Private function used to iterate over ALIST using FUNCTION."
-  (seq-do (lambda (pair)
-            (funcall function
-                     (car pair)
-                     (cdr pair)))
-          alist))
-
-(defun map--do-array (function array)
+  (if (map--plist-p map)
+      (while map
+        (funcall function (pop map) (pop map)))
+    (seq-do (lambda (pair)
+              (funcall function
+                       (car pair)
+                       (cdr pair)))
+            map)))
+
+(cl-defmethod map-do (function (array array))
   "Private function used to iterate over ARRAY using FUNCTION."
   (seq-do-indexed (lambda (elt index)
                      (funcall function index elt))
                    array))
 
-(defun map--into-hash-table (map)
+(cl-defmethod map-into (map (_type (eql hash-table)))
   "Convert MAP into a hash-table."
+  ;; FIXME: Just knowing we want a hash-table is insufficient, since that
+  ;; doesn't tell us the test function to use with it!
   (let ((ht (make-hash-table :size (map-length map)
                              :test 'equal)))
     (map-apply (lambda (key value)
diff --git a/lisp/emacs-lisp/nadvice.el b/lisp/emacs-lisp/nadvice.el
index 76a9095..2278e38 100644
--- a/lisp/emacs-lisp/nadvice.el
+++ b/lisp/emacs-lisp/nadvice.el
@@ -1,6 +1,6 @@
 ;;; nadvice.el --- Light-weight advice primitives for Elisp functions  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords: extensions, lisp, tools
@@ -36,6 +36,11 @@
 
 ;;; Code:
 
+;; The autoloads.el mechanism which adds package--builtin-versions
+;; maintenance to loaddefs.el doesn't work for preloaded packages (such
+;; as this one), so we have to do it by hand!
+(push (purecopy '(nadvice 1 0)) package--builtin-versions)
+
 ;;;; Lightweight advice/hook
 (defvar advice--where-alist
   '((:around "\300\301\302\003#\207" 5)
@@ -241,6 +246,8 @@ different, but `function-equal' will hopefully ignore those 
differences.")
   (if (local-variable-p var) (symbol-value var)
     (setq advice--buffer-local-function-sample
           ;; This function acts like the t special value in buffer-local hooks.
+          ;; FIXME: Provide an `advice-bottom' function that's like
+          ;; `advice-cd*r' but also follows through this proxy.
           (lambda (&rest args) (apply (default-value var) args)))))
 
 (eval-and-compile
diff --git a/lisp/emacs-lisp/package-x.el b/lisp/emacs-lisp/package-x.el
index d3120ac..1486aeb 100644
--- a/lisp/emacs-lisp/package-x.el
+++ b/lisp/emacs-lisp/package-x.el
@@ -1,6 +1,6 @@
 ;;; package-x.el --- Package extras
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Tom Tromey <address@hidden>
 ;; Created: 10 Mar 2007
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index dcede1a..61cf690 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1,6 +1,6 @@
 ;;; package.el --- Simple package system for Emacs  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Tom Tromey <address@hidden>
 ;;         Daniel Hackney <address@hidden>
@@ -487,7 +487,7 @@ This is, approximately, the inverse of `version-to-list'.
                 str-list))))
       (if (equal "." (car str-list))
           (pop str-list))
-      (apply 'concat (nreverse str-list)))))
+      (apply #'concat (nreverse str-list)))))
 
 (defun package-desc-full-name (pkg-desc)
   (format "%s-%s"
@@ -609,6 +609,12 @@ updates `package-alist'."
             (when (file-directory-p pkg-dir)
               (package-load-descriptor pkg-dir))))))))
 
+(defun package--alist ()
+  "Return `package-alist', after computing it if needed."
+  (or package-alist
+      (progn (package-load-all-descriptors)
+             package-alist)))
+
 (defun define-package (_name-string _version-string
                                     &optional _docstring _requirements
                                     &rest _extra-properties)
@@ -750,7 +756,8 @@ DIR, sorted by most recently loaded last."
   (let* ((history (delq nil
                         (mapcar (lambda (x)
                                   (let ((f (car x)))
-                                    (and f (file-name-sans-extension f))))
+                                    (and (stringp f)
+                                         (file-name-sans-extension f))))
                                 load-history)))
          (dir (file-truename dir))
          ;; List all files that have already been loaded.
@@ -837,7 +844,7 @@ untar into a directory named DIR; otherwise, signal an 
error."
   (tar-untar-buffer))
 
 (defun package--alist-to-plist-args (alist)
-  (mapcar 'macroexp-quote
+  (mapcar #'macroexp-quote
           (apply #'nconc
                  (mapcar (lambda (pair) (list (car pair) (cdr pair))) alist))))
 (defun package-unpack (pkg-desc)
@@ -898,7 +905,9 @@ untar into a directory named DIR; otherwise, signal an 
error."
           (print-length nil))
       (write-region
        (concat
-        ";;; -*- no-byte-compile: t -*-\n"
+        ";;; Generated package description from "
+        (replace-regexp-in-string "-pkg\\.el\\'" ".el" pkg-file)
+        "  -*- no-byte-compile: t -*-\n"
         (prin1-to-string
          (nconc
           (list 'define-package
@@ -1001,6 +1010,7 @@ is wrapped around any parts requiring it."
 
 (declare-function lm-header "lisp-mnt" (header))
 (declare-function lm-homepage "lisp-mnt" (&optional file))
+(declare-function lm-keywords-list "lisp-mnt" (&optional file))
 (declare-function lm-maintainer "lisp-mnt" (&optional file))
 (declare-function lm-authors "lisp-mnt" (&optional file))
 
@@ -1031,6 +1041,7 @@ boundaries."
            (pkg-version
             (or (package-strip-rcs-id (lm-header "package-version"))
                 (package-strip-rcs-id (lm-header "version"))))
+           (keywords (lm-keywords-list))
            (homepage (lm-homepage)))
       (unless pkg-version
         (error
@@ -1042,6 +1053,7 @@ boundaries."
             (package-read-from-string requires-str)))
        :kind 'single
        :url homepage
+       :keywords keywords
        :maintainer (lm-maintainer)
        :authors (lm-authors)))))
 
@@ -1491,10 +1503,8 @@ The variable `package-load-list' controls which packages 
to load."
       ;; 2 (this assumes we were careful to save this file so it doesn't need
       ;; any decoding).
       (let ((load-source-file-function nil))
-        (load package-quickstart-file))
-    (unless package--initialized
-      (package-initialize t))
-    (dolist (elt package-alist)
+        (load package-quickstart-file nil 'nomessage))
+    (dolist (elt (package--alist))
       (condition-case err
           (package-activate (car elt))
         ;; Don't let failure of activation of a package arbitrarily stop
@@ -1563,14 +1573,16 @@ similar to an entry in `package-alist'.  Save the 
cached copy to
                 (member name package-unsigned-archives))
             ;; If we don't care about the signature, save the file and
             ;; we're done.
-            (progn (write-region content nil local-file nil 'silent)
+            (progn (let ((coding-system-for-write 'utf-8))
+                     (write-region content nil local-file nil 'silent))
                    (package--update-downloads-in-progress archive))
           ;; If we care, check it (perhaps async) and *then* write the file.
           (package--check-signature
            location file content async
            ;; This function will be called after signature checking.
            (lambda (&optional good-sigs)
-             (write-region content nil local-file nil 'silent)
+             (let ((coding-system-for-write 'utf-8))
+               (write-region content nil local-file nil 'silent))
              ;; Write out good signatures into archive-contents.signed file.
              (when good-sigs
                (write-region (mapconcat #'epg-signature-to-string good-sigs 
"\n")
@@ -1903,10 +1915,9 @@ If PACKAGE is a `package-desc' object, MIN-VERSION is 
ignored."
     ;; We used the quickstart: make it possible to use package-installed-p
     ;; even before package is fully initialized.
     (memq package package-activated-list))
-   ((not package--initialized) (error "package.el is not yet initialized!"))
    (t
     (or
-     (let ((pkg-descs (cdr (assq package package-alist))))
+     (let ((pkg-descs (cdr (assq package (package--alist)))))
        (and pkg-descs
             (version-list-<= min-version
                              (package-desc-version (car pkg-descs)))))
@@ -2079,16 +2090,12 @@ If NOSAVE is non-nil, the package is not removed from
 `package-selected-packages'."
   (interactive
    (progn
-     ;; Initialize the package system to get the list of package
-     ;; symbols for completion.
-     (unless package--initialized
-       (package-initialize t))
      (let* ((package-table
              (mapcar
               (lambda (p) (cons (package-desc-full-name p) p))
               (delq nil
                     (mapcar (lambda (p) (unless (package-built-in-p p) p))
-                            (apply #'append (mapcar #'cdr package-alist))))))
+                            (apply #'append (mapcar #'cdr 
(package--alist)))))))
             (package-name (completing-read "Delete package: "
                                            (mapcar #'car package-table)
                                            nil t)))
@@ -2123,6 +2130,9 @@ If NOSAVE is non-nil, the package is not removed from
            (add-hook 'post-command-hook #'package-menu--post-refresh)
            (delete-directory dir t)
            ;; Remove NAME-VERSION.signed and NAME-readme.txt files.
+           ;;
+           ;; NAME-readme.txt files are no longer created, but they
+           ;; may be left around from an earlier install.
            (dolist (suffix '(".signed" "readme.txt"))
              (let* ((version (package-version-join (package-desc-version 
pkg-desc)))
                     (file (concat (if (string= suffix ".signed")
@@ -2193,12 +2203,12 @@ will be deleted."
      ;; Load the package list if necessary (but don't activate them).
      (unless package--initialized
        (package-initialize t))
-     (let ((packages (append (mapcar 'car package-alist)
-                             (mapcar 'car package-archive-contents)
-                             (mapcar 'car package--builtins))))
+     (let ((packages (append (mapcar #'car package-alist)
+                             (mapcar #'car package-archive-contents)
+                             (mapcar #'car package--builtins))))
        (unless (memq guess packages)
          (setq guess nil))
-       (setq packages (mapcar 'symbol-name packages))
+       (setq packages (mapcar #'symbol-name packages))
        (let ((val
               (completing-read (if guess
                                    (format "Describe package (default %s): "
@@ -2233,6 +2243,45 @@ Otherwise no newline is inserted."
 
 (declare-function lm-commentary "lisp-mnt" (&optional file))
 
+(defun package--get-description (desc)
+  "Return a string containing the long description of the package DESC.
+The description is read from the installed package files."
+  ;; Installed packages have nil for kind, so we look for README
+  ;; first, then fall back to the Commentary header.
+
+  ;; We don’t include README.md here, because that is often the home
+  ;; page on a site like github, and not suitable as the package long
+  ;; description.
+  (let ((files '("README-elpa" "README-elpa.md" "README" "README.rst" 
"README.org"))
+        file
+        (srcdir (package-desc-dir desc))
+        result)
+    (while (and files
+                (not result))
+      (setq file (pop files))
+      (when (file-readable-p (expand-file-name file srcdir))
+        ;; Found a README.
+        (with-temp-buffer
+          (insert-file-contents (expand-file-name file srcdir))
+          (setq result (buffer-string)))))
+
+    (or
+     result
+
+     ;; Look for Commentary header.
+     (let ((mainsrcfile (expand-file-name (format "%s.el" (package-desc-name 
desc))
+                                          srcdir)))
+       (when (file-readable-p mainsrcfile)
+         (with-temp-buffer
+           (insert (or (lm-commentary mainsrcfile) ""))
+           (goto-char (point-min))
+           (when (re-search-forward "^;;; Commentary:\n" nil t)
+             (replace-match ""))
+           (while (re-search-forward "^\\(;+ ?\\)" nil t)
+             (replace-match ""))
+           (buffer-string))))
+     )))
+
 (defun describe-package-1 (pkg)
   (require 'lisp-mnt)
   (let* ((desc (or
@@ -2406,7 +2455,8 @@ Otherwise no newline is inserted."
     (insert "\n")
 
     (if built-in
-        ;; For built-in packages, insert the commentary.
+        ;; For built-in packages, get the description from the
+        ;; Commentary header.
         (let ((fn (locate-file (format "%s.el" name) load-path
                                load-file-rep-suffixes))
               (opoint (point)))
@@ -2417,27 +2467,26 @@ Otherwise no newline is inserted."
               (replace-match ""))
             (while (re-search-forward "^\\(;+ ?\\)" nil t)
               (replace-match ""))))
-      (let* ((basename (format "%s-readme.txt" name))
-             (readme (expand-file-name basename package-user-dir))
-             readme-string)
-        ;; For elpa packages, try downloading the commentary.  If that
-        ;; fails, try an existing readme file in `package-user-dir'.
-        (cond ((and (package-desc-archive desc)
-                    (package--with-response-buffer (package-archive-base desc)
-                      :file basename :noerror t
-                      (save-excursion
-                        (goto-char (point-max))
-                        (unless (bolp)
-                          (insert ?\n)))
-                      (write-region nil nil
-                                    (expand-file-name readme package-user-dir)
-                                    nil 'silent)
-                      (setq readme-string (buffer-string))
-                      t))
-               (insert readme-string))
-              ((file-readable-p readme)
-               (insert-file-contents readme)
-               (goto-char (point-max))))))))
+
+      (if (package-installed-p desc)
+          ;; For installed packages, get the description from the installed 
files.
+          (insert (package--get-description desc))
+
+        ;; For non-built-in, non-installed packages, get description from the 
archive.
+        (let* ((basename (format "%s-readme.txt" name))
+               readme-string)
+
+          (package--with-response-buffer (package-archive-base desc)
+            :file basename :noerror t
+            (save-excursion
+              (goto-char (point-max))
+              (unless (bolp)
+                (insert ?\n)))
+            (setq readme-string (buffer-string))
+            t)
+          (insert (or readme-string
+                      "This package does not provide a description.")))
+        ))))
 
 (defun package-install-button-action (button)
   (let ((pkg-desc (button-get button 'package-desc)))
@@ -2466,7 +2515,7 @@ Otherwise no newline is inserted."
                                 :background "light grey"
                                 :foreground "black")
                        'link)))
-    (apply 'insert-text-button button-text 'face button-face 'follow-link t
+    (apply #'insert-text-button button-text 'face button-face 'follow-link t
            props)))
 
 
@@ -2547,7 +2596,7 @@ Letters do not insert themselves; instead, they are 
commands.
           ("Description" 0 nil)])
   (setq tabulated-list-padding 2)
   (setq tabulated-list-sort-key (cons "Status" nil))
-  (add-hook 'tabulated-list-revert-hook 'package-menu--refresh nil t)
+  (add-hook 'tabulated-list-revert-hook #'package-menu--refresh nil t)
   (tabulated-list-init-header))
 
 (defmacro package--push (pkg-desc status listname)
@@ -2818,7 +2867,7 @@ shown."
   (package-menu--refresh packages keywords)
   (setf (car (aref tabulated-list-format 0))
         (if keywords
-            (let ((filters (mapconcat 'identity keywords ",")))
+            (let ((filters (mapconcat #'identity keywords ",")))
               (concat "Package[" filters "]"))
           "Package"))
   (if keywords
@@ -3392,6 +3441,9 @@ short description."
   ;; Generate the Package Menu.
   (let ((buf (get-buffer-create "*Packages*")))
     (with-current-buffer buf
+      ;; Since some packages have their descriptions include non-ASCII
+      ;; characters...
+      (setq buffer-file-coding-system 'utf-8)
       (package-menu-mode)
 
       ;; Fetch the remote list of packages.
diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el
index a2143bf..a644453 100644
--- a/lisp/emacs-lisp/pcase.el
+++ b/lisp/emacs-lisp/pcase.el
@@ -1,6 +1,6 @@
 ;;; pcase.el --- ML-style pattern-matching macro for Elisp -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords:
@@ -63,6 +63,7 @@
 ;; FIXME: Now that macroexpansion is also performed when loading an interpreted
 ;; file, this is not a real problem any more.
 (defconst pcase--memoize (make-hash-table :weakness 'key :test 'eq))
+;; (defconst pcase--memoize (make-hash-table :test 'eq))
 ;; (defconst pcase--memoize-1 (make-hash-table :test 'eq))
 ;; (defconst pcase--memoize-2 (make-hash-table :weakness 'key :test 'equal))
 
@@ -175,7 +176,9 @@ Emacs Lisp manual for more information and examples."
 
 ;; FIXME: Obviously, this will collide with nadvice's use of
 ;; function-documentation if we happen to advise `pcase'.
+;;;###autoload
 (put 'pcase 'function-documentation '(pcase--make-docstring))
+;;;###autoload
 (defun pcase--make-docstring ()
   (let* ((main (documentation (symbol-function 'pcase) 'raw))
          (ud (help-split-fundoc main 'pcase)))
@@ -782,7 +785,7 @@ Otherwise, it defers to REST which is a list of branches of 
the form
    ((eq 'or (caar matches))
     (let* ((alts (cdar matches))
            (var (if (eq (caar alts) 'match) (cadr (car alts))))
-           (simples '()) (others '()) (memq-ok t))
+           (simples '()) (others '()) (memql-ok t))
       (when var
         (dolist (alt alts)
           (if (and (eq (car alt) 'match) (eq var (cadr alt))
@@ -790,16 +793,16 @@ Otherwise, it defers to REST which is a list of branches 
of the form
                      (eq (car-safe upat) 'quote)))
               (let ((val (cadr (cddr alt))))
                 (unless (or (integerp val) (symbolp val))
-                  (setq memq-ok nil))
+                  (setq memql-ok nil))
                 (push (cadr (cddr alt)) simples))
             (push alt others))))
       (cond
        ((null alts) (error "Please avoid it") (pcase--u rest))
-       ;; Yes, we can use `memq' (or `member')!
+       ;; Yes, we can use `memql' (or `member')!
        ((> (length simples) 1)
         (pcase--u1 (cons `(match ,var
                                  . (pred (pcase--flip
-                                          ,(if memq-ok #'memq #'member)
+                                          ,(if memql-ok #'memql #'member)
                                           ',simples)))
                          (cdr matches))
                    code vars
diff --git a/lisp/emacs-lisp/pp.el b/lisp/emacs-lisp/pp.el
index 1698d44..de4cbfc 100644
--- a/lisp/emacs-lisp/pp.el
+++ b/lisp/emacs-lisp/pp.el
@@ -1,6 +1,6 @@
 ;;; pp.el --- pretty printer for Emacs Lisp  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1989, 1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1989, 1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Randal Schwartz <address@hidden>
 ;; Keywords: lisp
diff --git a/lisp/emacs-lisp/radix-tree.el b/lisp/emacs-lisp/radix-tree.el
index f4184e8..dd65e1a 100644
--- a/lisp/emacs-lisp/radix-tree.el
+++ b/lisp/emacs-lisp/radix-tree.el
@@ -1,6 +1,6 @@
 ;;; radix-tree.el --- A simple library of radix trees  -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords:
@@ -196,8 +196,8 @@ If not found, return nil."
 
 (eval-and-compile
   (pcase-defmacro radix-tree-leaf (vpat)
-    "Build a `pcase' pattern that matches radix-tree leaf EXPVAL.
-VPAT is a `pcase' pattern to extract the value."
+    "Pattern which matches a radix-tree leaf.
+The pattern VPAT is matched against the leaf's carried value."
     ;; FIXME: We'd like to use a negative pattern (not consp), but pcase
     ;; doesn't support it.  Using `atom' works but generates sub-optimal code.
     `(or `(t . ,,vpat) (and (pred atom) ,vpat))))
diff --git a/lisp/emacs-lisp/re-builder.el b/lisp/emacs-lisp/re-builder.el
index 358bb19..f5b1dd8 100644
--- a/lisp/emacs-lisp/re-builder.el
+++ b/lisp/emacs-lisp/re-builder.el
@@ -1,6 +1,6 @@
 ;;; re-builder.el --- building Regexps with visual feedback -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Detlev Zundel <address@hidden>
 ;; Keywords: matching, lisp, tools
diff --git a/lisp/emacs-lisp/regexp-opt.el b/lisp/emacs-lisp/regexp-opt.el
index 8de4959..d883752 100644
--- a/lisp/emacs-lisp/regexp-opt.el
+++ b/lisp/emacs-lisp/regexp-opt.el
@@ -1,6 +1,6 @@
 ;;; regexp-opt.el --- generate efficient regexps to match strings -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1994-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Marshall <address@hidden>
 ;; Maintainer: address@hidden
@@ -84,11 +84,14 @@
 ;;; Code:
 
 ;;;###autoload
-(defun regexp-opt (strings &optional paren)
+(defun regexp-opt (strings &optional paren keep-order)
   "Return a regexp to match a string in the list STRINGS.
-Each string should be unique in STRINGS and should not contain
-any regexps, quoted or not.  Optional PAREN specifies how the
-returned regexp is surrounded by grouping constructs.
+Each member of STRINGS is treated as a fixed string, not as a regexp.
+Optional PAREN specifies how the returned regexp is surrounded by
+grouping constructs.
+
+If STRINGS is the empty list, the return value is a regexp that
+never matches anything.
 
 The optional argument PAREN can be any of the following:
 
@@ -111,8 +114,14 @@ nil
     necessary to ensure that a postfix operator appended to it will
     apply to the whole expression.
 
-The resulting regexp is equivalent to but usually more efficient
-than that of a simplified version:
+The optional argument KEEP-ORDER, if nil or omitted, allows the
+returned regexp to match the strings in any order.  If non-nil,
+the match is guaranteed to be performed in the order given, as if
+the strings were made into a regexp by joining them with the
+`\\|' operator.
+
+Up to reordering, the resulting regexp is equivalent to but
+usually more efficient than that of a simplified version:
 
  (defun simplified-regexp-opt (strings &optional paren)
    (let ((parens
@@ -121,9 +130,9 @@ than that of a simplified version:
                 ((eq paren \\='symbols) \\='(\"\\\\_<\\\\(\" . 
\"\\\\)\\\\_>\"))
                 ((null paren)          \\='(\"\\\\(?:\" . \"\\\\)\"))
                 (t                       \\='(\"\\\\(\" . \"\\\\)\")))))
-     (concat (car paren)
+     (concat (car parens)
              (mapconcat \\='regexp-quote strings \"\\\\|\")
-             (cdr paren))))"
+             (cdr parens))))"
   (save-match-data
     ;; Recurse on the sorted list.
     (let* ((max-lisp-eval-depth 10000)
@@ -133,7 +142,19 @@ than that of a simplified version:
           (open (cond ((stringp paren) paren) (paren "\\(")))
           (sorted-strings (delete-dups
                            (sort (copy-sequence strings) 'string-lessp)))
-          (re (regexp-opt-group sorted-strings (or open t) (not open))))
+          (re
+            (cond
+             ;; No strings: return a\` which cannot match anything.
+             ((null strings)
+              (concat (or open "\\(?:") "a\\`\\)"))
+             ;; If we cannot reorder, give up all attempts at
+             ;; optimisation.  There is room for improvement (Bug#34641).
+             ((and keep-order (regexp-opt--contains-prefix sorted-strings))
+              (concat (or open "\\(?:")
+                      (mapconcat #'regexp-quote strings "\\|")
+                      "\\)"))
+             (t
+              (regexp-opt-group sorted-strings (or open t) (not open))))))
       (cond ((eq paren 'words)
             (concat "\\<" re "\\>"))
            ((eq paren 'symbols)
@@ -313,6 +334,22 @@ CHARS should be a list of characters."
           (concat "[" dash caret "]"))
       (concat "[" bracket charset caret dash "]"))))
 
+
+(defun regexp-opt--contains-prefix (strings)
+  "Whether STRINGS contains a proper prefix of one of its other elements.
+STRINGS must be a list of sorted strings without duplicates."
+  (let ((s strings))
+    ;; In a lexicographically sorted list, a string always immediately
+    ;; succeeds one of its prefixes.
+    (while (and (cdr s)
+                (not (string-equal
+                      (car s)
+                      (substring (cadr s) 0 (min (length (car s))
+                                                 (length (cadr s)))))))
+      (setq s (cdr s)))
+    (cdr s)))
+
+
 (provide 'regexp-opt)
 
 ;;; regexp-opt.el ends here
diff --git a/lisp/emacs-lisp/regi.el b/lisp/emacs-lisp/regi.el
index 9a1ba76..f8268ed 100644
--- a/lisp/emacs-lisp/regi.el
+++ b/lisp/emacs-lisp/regi.el
@@ -1,6 +1,6 @@
 ;;; regi.el --- REGular expression Interpreting engine
 
-;; Copyright (C) 1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: 1993 Barry A. Warsaw, Century Computing, Inc. <address@hidden>
 ;; Maintainer:    address@hidden
diff --git a/lisp/emacs-lisp/ring.el b/lisp/emacs-lisp/ring.el
index 1b36811..c7d0268 100644
--- a/lisp/emacs-lisp/ring.el
+++ b/lisp/emacs-lisp/ring.el
@@ -1,6 +1,6 @@
 ;;; ring.el --- handle rings of items   -*- lexical-binding: t; -*-
 
-;; Copyright (C) 1992, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: extensions
diff --git a/lisp/emacs-lisp/rmc.el b/lisp/emacs-lisp/rmc.el
index 3197478..6d1adae 100644
--- a/lisp/emacs-lisp/rmc.el
+++ b/lisp/emacs-lisp/rmc.el
@@ -1,6 +1,6 @@
 ;;; rmc.el --- read from a multiple choice question -*- lexical-binding: t -*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 
diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el
index 1230df4..fdd2431 100644
--- a/lisp/emacs-lisp/rx.el
+++ b/lisp/emacs-lisp/rx.el
@@ -1,6 +1,6 @@
-;;; rx.el --- sexp notation for regular expressions
+;;; rx.el --- sexp notation for regular expressions  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Gerd Moellmann <address@hidden>
 ;; Maintainer: address@hidden
@@ -246,7 +246,9 @@ regular expressions.")
 
 
 (defconst rx-categories
-  '((consonant                 . ?0)
+  '((space-for-indent           . ?\s)
+    (base                       . ?.)
+    (consonant                 . ?0)
     (base-vowel                        . ?1)
     (upper-diacritical-mark    . ?2)
     (lower-diacritical-mark    . ?3)
@@ -265,7 +267,9 @@ regular expressions.")
     (japanese-hiragana-two-byte . ?H)
     (indian-two-byte           . ?I)
     (japanese-katakana-two-byte . ?K)
+    (strong-left-to-right       . ?L)
     (korean-hangul-two-byte    . ?N)
+    (strong-right-to-left       . ?R)
     (cyrillic-two-byte         . ?Y)
     (combining-diacritic       . ?^)
     (ascii                     . ?a)
@@ -389,7 +393,7 @@ FORM is of the form `(and FORM1 ...)'."
   (rx-group-if
    (if (memq nil (mapcar 'stringp (cdr form)))
        (mapconcat (lambda (x) (rx-form x '|)) (cdr form) "\\|")
-     (regexp-opt (cdr form)))
+     (regexp-opt (cdr form) nil t))
    (and (memq rx-parent '(: * t)) rx-parent)))
 
 
@@ -425,6 +429,13 @@ Only both edges of each range is checked."
     ;; set L list of all ranges
     (mapc (lambda (e) (cond ((stringp e) (push e str))
                            ((numberp e) (push (cons e e) l))
+                            ;; Ranges between ASCII and raw bytes are split,
+                            ;; to prevent accidental inclusion of Unicode
+                            ;; characters later on.
+                            ((and (<= (car e) #x7f)
+                                  (>= (cdr e) #x3fff80))
+                             (push (cons (car e) #x7f) l)
+                             (push (cons #x3fff80 (cdr e)) l))
                            (t (push e l))))
          args)
     ;; condense overlapped ranges in L
@@ -449,28 +460,38 @@ Only both edges of each range is checked."
 
 
 (defun rx-check-any-string (str)
-  "Check string argument STR for Rx `any'."
-  (let ((i 0)
-       c1 c2 l)
-    (if (= 0 (length str))
-       (error "String arg for Rx `any' must not be empty"))
-    (while (string-match ".-." str i)
-      ;; string before range: convert it to characters
-      (if (< i (match-beginning 0))
-         (setq l (nconc
-                  l
-                  (append (substring str i (match-beginning 0)) nil))))
-      ;; range
-      (setq i (match-end 0)
-           c1 (aref str (match-beginning 0))
-           c2 (aref str (1- i)))
-      (cond
-       ((< c1 c2) (setq l (nconc l (list (cons c1 c2)))))
-       ((= c1 c2) (setq l (nconc l (list c1))))))
-    ;; rest?
-    (if (< i (length str))
-       (setq l (nconc l (append (substring str i) nil))))
-    l))
+  "Turn the `any' argument string STR into a list of characters.
+The original order is not preserved.  Ranges, \"A-Z\", become pairs, (?A . 
?Z)."
+  (let ((decode-char
+         ;; Make sure raw bytes are decoded as such, to avoid confusion with
+         ;; U+0080..U+00FF.
+         (if (multibyte-string-p str)
+             #'identity
+           (lambda (c) (if (<= #x80 c #xff)
+                           (+ c #x3fff00)
+                         c))))
+        (len (length str))
+        (i 0)
+        (ret nil))
+    (if (= 0 len)
+        (error "String arg for Rx `any' must not be empty"))
+    (while (< i len)
+      (cond ((and (< i (- len 2))
+                  (= (aref str (+ i 1)) ?-))
+             ;; Range.
+             (let ((start (funcall decode-char (aref str i)))
+                   (end   (funcall decode-char (aref str (+ i 2)))))
+               (cond ((< start end) (push (cons start end) ret))
+                     ((= start end) (push start ret))
+                     (t
+                      (error "Rx character range `%c-%c' is reversed"
+                             start end)))
+               (setq i (+ i 3))))
+            (t
+             ;; Single character.
+             (push (funcall decode-char (aref str i)) ret)
+             (setq i (+ i 1)))))
+    ret))
 
 
 (defun rx-check-any (arg)
@@ -485,7 +506,10 @@ Only both edges of each range is checked."
               (null (string-match "\\`\\[\\[:[-a-z]+:\\]\\]\\'" translation)))
           (error "Invalid char class `%s' in Rx `any'" arg))
        (list (substring translation 1 -1)))) ; strip outer brackets
-    ((and (integerp (car-safe arg)) (integerp (cdr-safe arg)))
+    ((and (characterp (car-safe arg)) (characterp (cdr-safe arg)))
+     (unless (<= (car arg) (cdr arg))
+       (error "Rx character range `%c-%c' is reversed"
+              (car arg) (cdr arg)))
      (list arg))
     ((stringp arg) (rx-check-any-string arg))
     ((error
@@ -591,7 +615,7 @@ ARG is optional."
   (rx-check form)
   (let ((result (rx-form (cadr form) '!))
        case-fold-search)
-    (cond ((string-match "\\`\\[^" result)
+    (cond ((string-match "\\`\\[\\^" result)
           (cond
            ((equal result "[^]") "[^^]")
            ((and (= (length result) 4) (null (eq rx-parent '!)))
@@ -726,8 +750,8 @@ If OP is anything else, produce a greedy regexp if 
`rx-greedy-flag'
 is non-nil."
   (rx-check form)
   (setq form (rx-trans-forms form))
-  (let ((suffix (cond ((memq (car form) '(* + ?\s)) "")
-                     ((memq (car form) '(*? +? ??)) "?")
+  (let ((suffix (cond ((memq (car form) '(* + \? ?\s)) "")
+                     ((memq (car form) '(*? +? \?? ??)) "?")
                      (rx-greedy-flag "")
                      (t "?")))
        (op (cond ((memq (car form) '(* *? 0+ zero-or-more)) "*")
@@ -769,7 +793,7 @@ of all atomic regexps."
      ((= l 3) (string-match "\\`\\(?:\\\\[cCsS_]\\|\\[[^^]\\]\\)" r))
      ((null lax)
       (cond
-       ((string-match "\\`\\[^?\]?\\(?:\\[:[a-z]+:]\\|[^]]\\)*\\]\\'" r))
+       ((string-match "\\`\\[\\^?]?\\(?:\\[:[a-z]+:]\\|[^]]\\)*]\\'" r))
        ((string-match "\\`\\\\(\\(?:[^\\]\\|\\\\[^)]\\)*\\\\)\\'" r)))))))
 
 
@@ -830,33 +854,34 @@ If FORM is `(minimal-match FORM1)', non-greedy versions 
of `*',
   (rx-group-if (cadr form) rx-parent))
 
 
-(defun rx-form (form &optional rx-parent)
+(defun rx-form (form &optional parent)
   "Parse and produce code for regular expression FORM.
 FORM is a regular expression in sexp form.
-RX-PARENT shows which type of expression calls and controls putting of
+PARENT shows which type of expression calls and controls putting of
 shy groups around the result and some more in other functions."
-  (cond
-   ((stringp form)
-    (rx-group-if (regexp-quote form)
-                 (if (and (eq rx-parent '*) (< 1 (length form)))
-                     rx-parent)))
-   ((integerp form)
-    (regexp-quote (char-to-string form)))
-   ((symbolp form)
-    (let ((info (rx-info form nil)))
-      (cond ((stringp info)
-             info)
-            ((null info)
-             (error "Unknown rx form `%s'" form))
-            (t
-             (funcall (nth 0 info) form)))))
-   ((consp form)
-    (let ((info (rx-info (car form) 'head)))
-      (unless (consp info)
-        (error "Unknown rx form `%s'" (car form)))
-      (funcall (nth 0 info) form)))
-   (t
-    (error "rx syntax error at `%s'" form))))
+  (let ((rx-parent parent))
+    (cond
+     ((stringp form)
+      (rx-group-if (regexp-quote form)
+                   (if (and (eq parent '*) (< 1 (length form)))
+                       parent)))
+     ((integerp form)
+      (regexp-quote (char-to-string form)))
+     ((symbolp form)
+      (let ((info (rx-info form nil)))
+        (cond ((stringp info)
+               info)
+              ((null info)
+               (error "Unknown rx form `%s'" form))
+              (t
+               (funcall (nth 0 info) form)))))
+     ((consp form)
+      (let ((info (rx-info (car form) 'head)))
+        (unless (consp info)
+          (error "Unknown rx form `%s'" (car form)))
+        (funcall (nth 0 info) form)))
+     (t
+      (error "rx syntax error at `%s'" form)))))
 
 
 ;;;###autoload
@@ -897,6 +922,7 @@ CHAR
      matches any character in SET ....  SET may be a character or string.
      Ranges of characters can be specified as `A-Z' in strings.
      Ranges may also be specified as conses like `(?A . ?Z)'.
+     Reversed ranges like `Z-A' and `(?Z . ?A)' are not permitted.
 
      SET may also be the name of a character class: `digit',
      `control', `hex-digit', `blank', `graph', `print', `alnum',
@@ -957,7 +983,7 @@ CHAR
      matches 0 through 9.
 
 `control', `cntrl'
-     matches ASCII control characters.
+     matches any character whose code is in the range 0-31.
 
 `hex-digit', `hex', `xdigit'
      matches 0 through 9, a through f and A through F.
@@ -1044,7 +1070,9 @@ CHAR
      matches a character with category CATEGORY.  CATEGORY must be
      either a character to use for C, or one of the following symbols.
 
-     `consonant'                       (\\c0 in string notation)
+     `space-for-indent'                 (\\c\\s in string notation)
+     `base'                             (\\c.)
+     `consonant'                       (\\c0)
      `base-vowel'                      (\\c1)
      `upper-diacritical-mark'          (\\c2)
      `lower-diacritical-mark'          (\\c3)
@@ -1062,7 +1090,9 @@ CHAR
      `japanese-hiragana-two-byte'      (\\cH)
      `indian-two-byte'                 (\\cI)
      `japanese-katakana-two-byte'      (\\cK)
+     `strong-left-to-right'             (\\cL)
      `korean-hangul-two-byte'          (\\cN)
+     `strong-right-to-left'             (\\cR)
      `cyrillic-two-byte'               (\\cY)
      `combining-diacritic'             (\\c^)
      `ascii'                           (\\ca)
diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el
index b40c424..3413cd1 100644
--- a/lisp/emacs-lisp/seq.el
+++ b/lisp/emacs-lisp/seq.el
@@ -1,10 +1,10 @@
 ;;; seq.el --- Sequence manipulation functions  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Nicolas Petton <address@hidden>
 ;; Keywords: sequences
-;; Version: 2.20
+;; Version: 2.21
 ;; Package: seq
 
 ;; Maintainer: address@hidden
@@ -110,6 +110,14 @@ name to be bound to the rest of SEQUENCE."
   "Return the number of elements of SEQUENCE."
   (length sequence))
 
+(defun seq-first (sequence)
+  "Return the first element of SEQUENCE."
+  (seq-elt sequence 0))
+
+(defun seq-rest (sequence)
+  "Return a sequence of the elements of SEQUENCE except the first one."
+  (seq-drop sequence 1))
+
 (cl-defgeneric seq-do (function sequence)
   "Apply FUNCTION to each element of SEQUENCE, presumably for side effects.
 Return SEQUENCE."
@@ -348,6 +356,7 @@ found or not."
     count))
 
 (cl-defgeneric seq-contains (sequence elt &optional testfn)
+  (declare (obsolete seq-contains-p "27.1"))
   "Return the first element in SEQUENCE that is equal to ELT.
 Equality is defined by TESTFN if non-nil or by `equal' if nil."
   (seq-some (lambda (e)
@@ -355,11 +364,20 @@ Equality is defined by TESTFN if non-nil or by `equal' if 
nil."
                 e))
             sequence))
 
+(cl-defgeneric seq-contains-p (sequence elt &optional testfn)
+  "Return non-nil if SEQUENCE contains an element equal to ELT.
+Equality is defined by TESTFN if non-nil or by `equal' if nil."
+    (catch 'seq--break
+      (seq-doseq (e sequence)
+        (when (funcall (or testfn #'equal) e elt)
+          (throw 'seq--break t)))
+      nil))
+
 (cl-defgeneric seq-set-equal-p (sequence1 sequence2 &optional testfn)
   "Return non-nil if SEQUENCE1 and SEQUENCE2 contain the same elements, 
regardless of order.
 Equality is defined by TESTFN if non-nil or by `equal' if nil."
-  (and (seq-every-p (lambda (item1) (seq-contains sequence2 item1 testfn)) 
sequence1)
-       (seq-every-p (lambda (item2) (seq-contains sequence1 item2 testfn)) 
sequence2)))
+  (and (seq-every-p (lambda (item1) (seq-contains-p sequence2 item1 testfn)) 
sequence1)
+       (seq-every-p (lambda (item2) (seq-contains-p sequence1 item2 testfn)) 
sequence2)))
 
 (cl-defgeneric seq-position (sequence elt &optional testfn)
   "Return the index of the first element in SEQUENCE that is equal to ELT.
@@ -377,7 +395,7 @@ Equality is defined by TESTFN if non-nil or by `equal' if 
nil."
 TESTFN is used to compare elements, or `equal' if TESTFN is nil."
   (let ((result '()))
     (seq-doseq (elt sequence)
-      (unless (seq-contains result elt testfn)
+      (unless (seq-contains-p result elt testfn)
         (setq result (cons elt result))))
     (nreverse result)))
 
@@ -402,7 +420,7 @@ negative integer or 0, nil is returned."
   "Return a list of the elements that appear in both SEQUENCE1 and SEQUENCE2.
 Equality is defined by TESTFN if non-nil or by `equal' if nil."
   (seq-reduce (lambda (acc elt)
-                (if (seq-contains sequence2 elt testfn)
+                (if (seq-contains-p sequence2 elt testfn)
                     (cons elt acc)
                   acc))
               (seq-reverse sequence1)
@@ -412,9 +430,9 @@ Equality is defined by TESTFN if non-nil or by `equal' if 
nil."
   "Return a list of the elements that appear in SEQUENCE1 but not in SEQUENCE2.
 Equality is defined by TESTFN if non-nil or by `equal' if nil."
   (seq-reduce (lambda (acc elt)
-                (if (not (seq-contains sequence2 elt testfn))
-                    (cons elt acc)
-                  acc))
+                (if (seq-contains-p sequence2 elt testfn)
+                    acc
+                  (cons elt acc)))
               (seq-reverse sequence1)
               '()))
 
diff --git a/lisp/emacs-lisp/shadow.el b/lisp/emacs-lisp/shadow.el
index 260ac36..85adbe3 100644
--- a/lisp/emacs-lisp/shadow.el
+++ b/lisp/emacs-lisp/shadow.el
@@ -1,6 +1,6 @@
 ;;; shadow.el --- locate Emacs Lisp file shadowings
 
-;; Copyright (C) 1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Terry Jones <address@hidden>
 ;; Keywords: lisp
diff --git a/lisp/emacs-lisp/smie.el b/lisp/emacs-lisp/smie.el
index be40319..f2163b2 100644
--- a/lisp/emacs-lisp/smie.el
+++ b/lisp/emacs-lisp/smie.el
@@ -1,6 +1,6 @@
 ;;; smie.el --- Simple Minded Indentation Engine -*- lexical-binding: t -*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords: languages, lisp, internal, parsing, indentation
@@ -1446,9 +1446,9 @@ in order to figure out the indentation of some other 
(further down) point."
   (and (smie-indent--bolp)
        (save-excursion
          (comment-normalize-vars)
-         (re-search-forward (concat comment-start-skip
+         (re-search-forward (concat "\\(?:" comment-start-skip "\\)"
                                     "fixindent"
-                                    comment-end-skip)
+                                    "\\(?:" comment-end-skip "\\)")
                             ;; 1+ to account for the \n comment termination.
                             (1+ (line-end-position)) t))
        (current-column)))
@@ -1648,11 +1648,33 @@ should not be computed on the basis of the following 
token."
          (let ((ppss (syntax-ppss)))
            (save-excursion
              (forward-line -1)
-             (if (<= (point) (nth 8 ppss))
-                 (progn (goto-char (1+ (nth 8 ppss))) (current-column))
-               (skip-chars-forward " \t")
-               (if (looking-at (regexp-quote continue))
-                   (current-column))))))))
+             (let ((start (nth 8 ppss)))
+               (if (<= (point) start)
+                   (progn
+                     (goto-char start)
+                     (if (not (and comment-start-skip
+                                   (looking-at comment-start-skip)))
+                         (forward-char 1)
+                       (goto-char (match-end 0))
+                       (skip-chars-backward " \t")
+                       ;; Try to align the first char of the comment-continue
+                       ;; with the second char of the comment-start or the
+                       ;; first char if the comment-start is made of
+                       ;; a single char.  E.g.
+                       ;;
+                       ;;     /* foo
+                       ;;      * bar */
+                       ;;
+                       ;; but
+                       ;;
+                       ;;     { foo
+                       ;;     | bar }
+                       (goto-char (if (eq (point) (1+ start))
+                                      start (1+ start))))
+                     (current-column))
+                 (skip-chars-forward " \t")
+                 (if (looking-at (regexp-quote continue))
+                     (current-column)))))))))
 
 (defun smie-indent-comment-close ()
   (and (boundp 'comment-end-skip)
diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el
index 3d59af2..b9ffe6a 100644
--- a/lisp/emacs-lisp/subr-x.el
+++ b/lisp/emacs-lisp/subr-x.el
@@ -1,6 +1,6 @@
 ;;; subr-x.el --- extra Lisp functions  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: convenience
@@ -250,6 +250,35 @@ TRIM-LEFT and TRIM-RIGHT default to \"[ \\t\\n\\r]+\"."
       (substring string 0 (- (length string) (length suffix)))
     string))
 
+(defun replace-region-contents (beg end replace-fn
+                                    &optional max-secs max-costs)
+  "Replace the region between BEG and END using REPLACE-FN.
+REPLACE-FN runs on the current buffer narrowed to the region.  It
+should return either a string or a buffer replacing the region.
+
+The replacement is performed using `replace-buffer-contents'
+which also describes the MAX-SECS and MAX-COSTS arguments and the
+return value.
+
+Note: If the replacement is a string, it'll be placed in a
+temporary buffer so that `replace-buffer-contents' can operate on
+it.  Therefore, if you already have the replacement in a buffer,
+it makes no sense to convert it to a string using
+`buffer-substring' or similar."
+  (save-excursion
+    (save-restriction
+      (narrow-to-region beg end)
+      (goto-char (point-min))
+      (let ((repl (funcall replace-fn)))
+       (if (bufferp repl)
+           (replace-buffer-contents repl max-secs max-costs)
+         (let ((source-buffer (current-buffer)))
+           (with-temp-buffer
+             (insert repl)
+             (let ((tmp-buffer (current-buffer)))
+               (set-buffer source-buffer)
+               (replace-buffer-contents tmp-buffer max-secs max-costs)))))))))
+
 (provide 'subr-x)
 
 ;;; subr-x.el ends here
diff --git a/lisp/emacs-lisp/syntax.el b/lisp/emacs-lisp/syntax.el
index a4b7015..d09d6c1 100644
--- a/lisp/emacs-lisp/syntax.el
+++ b/lisp/emacs-lisp/syntax.el
@@ -1,6 +1,6 @@
 ;;; syntax.el --- helper functions to find syntactic context  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: internal
@@ -434,14 +434,20 @@ These are valid when the buffer has no restriction.")
        (setcdr cell cache)))
     ))
 
+;;; FIXME: Explain this variable.  Currently only its last (5th) slot is used.
+;;; Perhaps the other slots should be removed?
 (defvar syntax-ppss-stats
-  [(0 . 0.0) (0 . 0.0) (0 . 0.0) (0 . 0.0) (0 . 0.0) (1 . 2500.0)])
+  [(0 . 0) (0 . 0) (0 . 0) (0 . 0) (0 . 0) (2 . 2500)])
 (defun syntax-ppss-stats ()
   (mapcar (lambda (x)
            (condition-case nil
-               (cons (car x) (truncate (/ (cdr x) (car x))))
+               (cons (car x) (/ (cdr x) (car x)))
              (error nil)))
          syntax-ppss-stats))
+(defun syntax-ppss--update-stats (i old new)
+  (let ((pair (aref syntax-ppss-stats i)))
+    (cl-incf (car pair))
+    (cl-incf (cdr pair) (- new old))))
 
 (defvar-local syntax-ppss-table nil
   "Syntax-table to use during `syntax-ppss', if any.")
@@ -486,11 +492,10 @@ running the hook."
        (if (and old-pos (< (- pos old-pos)
                            ;; The time to use syntax-begin-function and
                            ;; find PPSS is assumed to be about 2 * distance.
-                           (* 2 (/ (cdr (aref syntax-ppss-stats 5))
-                                   (1+ (car (aref syntax-ppss-stats 5)))))))
+                           (let ((pair (aref syntax-ppss-stats 5)))
+                             (/ (* 2 (cdr pair)) (car pair)))))
            (progn
-             (cl-incf (car (aref syntax-ppss-stats 0)))
-             (cl-incf (cdr (aref syntax-ppss-stats 0)) (- pos old-pos))
+             (syntax-ppss--update-stats 0 old-pos pos)
              (parse-partial-sexp old-pos pos nil nil old-ppss))
 
          (cond
@@ -506,8 +511,7 @@ running the hook."
                 (setq pt-min (or (syntax-ppss-toplevel-pos old-ppss)
                                  (nth 2 old-ppss)))
                 (<= pt-min pos) (< (- pos pt-min) syntax-ppss-max-span))
-           (cl-incf (car (aref syntax-ppss-stats 1)))
-           (cl-incf (cdr (aref syntax-ppss-stats 1)) (- pos pt-min))
+           (syntax-ppss--update-stats 1 pt-min pos)
            (setq ppss (parse-partial-sexp pt-min pos)))
           ;; The OLD-* data can't be used.  Consult the cache.
           (t
@@ -529,14 +533,18 @@ running the hook."
 
              ;; Setup the before-change function if necessary.
              (unless (or ppss-cache ppss-last)
+                ;; We should be either the very last function on
+                ;; before-change-functions or the very first on
+                ;; after-change-functions.
+                ;; Note: combine-change-calls-1 needs to be kept in sync
+                ;; with this!
                (add-hook 'before-change-functions
                          'syntax-ppss-flush-cache t t))
 
              ;; Use the best of OLD-POS and CACHE.
              (if (or (not old-pos) (< old-pos pt-min))
                  (setq pt-best pt-min ppss-best ppss)
-               (cl-incf (car (aref syntax-ppss-stats 4)))
-               (cl-incf (cdr (aref syntax-ppss-stats 4)) (- pos old-pos))
+               (syntax-ppss--update-stats 4 old-pos pos)
                (setq pt-best old-pos ppss-best old-ppss))
 
              ;; Use the `syntax-begin-function' if available.
@@ -556,21 +564,18 @@ running the hook."
                         (not (memq (get-text-property (point) 'face)
                                    '(font-lock-string-face font-lock-doc-face
                                      font-lock-comment-face))))
-               (cl-incf (car (aref syntax-ppss-stats 5)))
-               (cl-incf (cdr (aref syntax-ppss-stats 5)) (- pos (point)))
+               (syntax-ppss--update-stats 5 (point) pos)
                (setq pt-best (point) ppss-best nil))
 
              (cond
               ;; Quick case when we found a nearby pos.
               ((< (- pos pt-best) syntax-ppss-max-span)
-               (cl-incf (car (aref syntax-ppss-stats 2)))
-               (cl-incf (cdr (aref syntax-ppss-stats 2)) (- pos pt-best))
+               (syntax-ppss--update-stats 2 pt-best pos)
                (setq ppss (parse-partial-sexp pt-best pos nil nil ppss-best)))
               ;; Slow case: compute the state from some known position and
               ;; populate the cache so we won't need to do it again soon.
               (t
-               (cl-incf (car (aref syntax-ppss-stats 3)))
-               (cl-incf (cdr (aref syntax-ppss-stats 3)) (- pos pt-min))
+               (syntax-ppss--update-stats 3 pt-min pos)
 
                ;; If `pt-min' is too far, add a few intermediate entries.
                (while (> (- pos pt-min) (* 2 syntax-ppss-max-span))
diff --git a/lisp/emacs-lisp/tabulated-list.el 
b/lisp/emacs-lisp/tabulated-list.el
index 58619ec..b23ce21 100644
--- a/lisp/emacs-lisp/tabulated-list.el
+++ b/lisp/emacs-lisp/tabulated-list.el
@@ -1,6 +1,6 @@
 ;;; tabulated-list.el --- generic major mode for tabulated lists -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Chong Yidong <address@hidden>
 ;; Keywords: extensions, lisp
@@ -36,6 +36,43 @@
 
 ;;; Code:
 
+(defgroup tabulated-list nil
+  "Tabulated-list customization group."
+  :group 'convenience
+  :group 'display)
+
+(defcustom tabulated-list-gui-sort-indicator-asc ?▼
+  "Indicator for columns sorted in ascending order, for GUI frames.
+See `tabulated-list-tty-sort-indicator-asc' for the indicator used on
+text-mode frames."
+  :group 'tabulated-list
+  :type 'character
+  :version "27.1")
+
+(defcustom tabulated-list-gui-sort-indicator-desc ?▲
+  "Indicator for columns sorted in descending order, for GUI frames.
+See `tabulated-list-tty-sort-indicator-desc' for the indicator used on
+text-mode frames."
+  :group 'tabulated-list
+  :type 'character
+  :version "27.1")
+
+(defcustom tabulated-list-tty-sort-indicator-asc ?v
+  "Indicator for columns sorted in ascending order, for text-mode frames.
+See `tabulated-list-gui-sort-indicator-asc' for the indicator used on GUI
+frames."
+  :group 'tabulated-list
+  :type 'character
+  :version "27.1")
+
+(defcustom tabulated-list-tty-sort-indicator-desc ?^
+  "Indicator for columns sorted in ascending order, for text-mode frames.
+See `tabulated-list-gui-sort-indicator-asc' for the indicator used on GUI
+frames."
+  :group 'tabulated-list
+  :type 'character
+  :version "27.1")
+
 ;; The reason `tabulated-list-format' and other variables are
 ;; permanent-local is to make it convenient to switch to a different
 ;; major mode, switch back, and have the original Tabulated List data
@@ -151,8 +188,10 @@ If ADVANCE is non-nil, move forward by one line 
afterwards."
       (forward-line)))
 
 (defvar tabulated-list-mode-map
-  (let ((map (copy-keymap special-mode-map)))
-    (set-keymap-parent map button-buffer-map)
+  (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map (make-composed-keymap
+                            button-buffer-map
+                            special-mode-map))
     (define-key map "n" 'next-line)
     (define-key map "p" 'previous-line)
     (define-key map "S" 'tabulated-list-sort)
@@ -172,14 +211,20 @@ If ADVANCE is non-nil, move forward by one line 
afterwards."
     map)
   "Local keymap for `tabulated-list-mode' sort buttons.")
 
-(defvar tabulated-list-glyphless-char-display
+(defun tabulated-list-make-glyphless-char-display-table ()
+  "Make the `glyphless-char-display' table used for text-mode frames.
+This table is used for displaying the sorting indicators, see
+variables `tabulated-list-tty-sort-indicator-asc' and
+`tabulated-list-tty-sort-indicator-desc' for more information."
   (let ((table (make-char-table 'glyphless-char-display nil)))
     (set-char-table-parent table glyphless-char-display)
-    ;; Some text terminals can't display the Unicode arrows; be safe.
-    (aset table 9650 (cons nil "^"))
-    (aset table 9660 (cons nil "v"))
-    table)
-  "The `glyphless-char-display' table in Tabulated List buffers.")
+    (aset table
+          tabulated-list-gui-sort-indicator-desc
+          (cons nil (char-to-string tabulated-list-tty-sort-indicator-desc)))
+    (aset table
+          tabulated-list-gui-sort-indicator-asc
+          (cons nil (char-to-string tabulated-list-tty-sort-indicator-asc)))
+    table))
 
 (defvar tabulated-list--header-string nil
   "Holds the header if `tabulated-list-use-header-line' is nil.
@@ -229,8 +274,11 @@ Populated by `tabulated-list-init-header'.")
                  (concat label
                          (cond
                           ((> (+ 2 (length label)) width) "")
-                          ((cdr tabulated-list-sort-key) " ▲")
-                          (t " ▼")))
+                          ((cdr tabulated-list-sort-key)
+                            (format " %c"
+                                    tabulated-list-gui-sort-indicator-desc))
+                          (t (format " %c"
+                                      tabulated-list-gui-sort-indicator-asc))))
                  'face 'bold
                  'tabulated-list-column-name label
                  button-props))
@@ -653,7 +701,8 @@ as the ewoc pretty-printer."
   (setq-local truncate-lines t)
   (setq-local buffer-undo-list t)
   (setq-local revert-buffer-function #'tabulated-list-revert)
-  (setq-local glyphless-char-display tabulated-list-glyphless-char-display)
+  (setq-local glyphless-char-display
+              (tabulated-list-make-glyphless-char-display-table))
   ;; Avoid messing up the entries' display just because the first
   ;; column of the first entry happens to begin with a R2L letter.
   (setq bidi-paragraph-direction 'left-to-right)
diff --git a/lisp/emacs-lisp/tcover-ses.el b/lisp/emacs-lisp/tcover-ses.el
index 21bc2ce..29b4818 100644
--- a/lisp/emacs-lisp/tcover-ses.el
+++ b/lisp/emacs-lisp/tcover-ses.el
@@ -1,6 +1,6 @@
 ;;;; testcover-ses.el -- Example use of `testcover' to test "SES"
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Jonathan Yavner <address@hidden>
 ;; Maintainer: Jonathan Yavner <address@hidden>
diff --git a/lisp/emacs-lisp/tcover-unsafep.el 
b/lisp/emacs-lisp/tcover-unsafep.el
index ecfb3bb..571f53c 100644
--- a/lisp/emacs-lisp/tcover-unsafep.el
+++ b/lisp/emacs-lisp/tcover-unsafep.el
@@ -1,6 +1,6 @@
 ;;;; testcover-unsafep.el -- Use testcover to test unsafep's code coverage
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Jonathan Yavner <address@hidden>
 ;; Maintainer: Jonathan Yavner <address@hidden>
diff --git a/lisp/emacs-lisp/testcover.el b/lisp/emacs-lisp/testcover.el
index d48c79c..1ea1285 100644
--- a/lisp/emacs-lisp/testcover.el
+++ b/lisp/emacs-lisp/testcover.el
@@ -1,6 +1,6 @@
 ;;;; testcover.el -- Visual code-coverage tool  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Jonathan Yavner <address@hidden>
 ;; Maintainer: Jonathan Yavner <address@hidden>
diff --git a/lisp/emacs-lisp/text-property-search.el 
b/lisp/emacs-lisp/text-property-search.el
index b464402..41ca070 100644
--- a/lisp/emacs-lisp/text-property-search.el
+++ b/lisp/emacs-lisp/text-property-search.el
@@ -1,6 +1,6 @@
 ;;; text-property-search.el --- search for text properties  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: convenience
diff --git a/lisp/emacs-lisp/thunk.el b/lisp/emacs-lisp/thunk.el
index 823d496..e1370c4 100644
--- a/lisp/emacs-lisp/thunk.el
+++ b/lisp/emacs-lisp/thunk.el
@@ -1,6 +1,6 @@
 ;;; thunk.el --- Lazy form evaluation  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Nicolas Petton <address@hidden>
 ;; Keywords: sequences
diff --git a/lisp/emacs-lisp/timer-list.el b/lisp/emacs-lisp/timer-list.el
index f0fd4f4..55aa56b 100644
--- a/lisp/emacs-lisp/timer-list.el
+++ b/lisp/emacs-lisp/timer-list.el
@@ -1,6 +1,6 @@
-;;; timer-list.el --- list active timers in a buffer
+;;; timer-list.el --- list active timers in a buffer  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Package: emacs
@@ -24,6 +24,9 @@
 
 ;;; Code:
 
+(defvar cl-print-compiled)
+(defvar cl-print-compiled-button)
+
 ;;;###autoload
 (defun list-timers (&optional _ignore-auto _nonconfirm)
   "List all timers in a buffer."
@@ -37,16 +40,14 @@
                       ;; Idle.
                       (if (aref timer 7) "*" " ")
                       ;; Next time.
-                      (let ((time (float-time (list (aref timer 1)
-                                                    (aref timer 2)
-                                                    (aref timer 3)))))
+                     (let ((time (list (aref timer 1)
+                                       (aref timer 2)
+                                       (aref timer 3))))
                         (format "%.2f"
-                                (if (aref timer 7)
-                                    time
-                                  (- (float-time (list (aref timer 1)
-                                                       (aref timer 2)
-                                                       (aref timer 3)))
-                                     (float-time)))))
+                               (float-time
+                                (if (aref timer 7)
+                                    time
+                                  (time-subtract time nil)))))
                       ;; Repeat.
                       (let ((repeat (aref timer 4)))
                         (cond
@@ -87,8 +88,9 @@
   (setq-local revert-buffer-function #'list-timers)
   (setq buffer-read-only t)
   (setq header-line-format
-        (format "%4s %10s %8s %s"
-                "Idle" "Next" "Repeat" "Function")))
+        (concat (propertize " " 'display '(space :align-to 0))
+                (format "%4s %10s %8s %s"
+                "Idle" "Next" "Repeat" "Function"))))
 
 (defun timer-list-cancel ()
   "Cancel the timer on the line under point."
diff --git a/lisp/emacs-lisp/timer.el b/lisp/emacs-lisp/timer.el
index 56323c8..22ccc35 100644
--- a/lisp/emacs-lisp/timer.el
+++ b/lisp/emacs-lisp/timer.el
@@ -1,6 +1,6 @@
 ;;; timer.el --- run a function with args at some time in future -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Package: emacs
@@ -74,7 +74,7 @@
 
 (defun timer-set-time (timer time &optional delta)
   "Set the trigger time of TIMER to TIME.
-TIME must be in the internal format returned by, e.g., `current-time'.
+TIME must be a Lisp time value.
 If optional third argument DELTA is a positive number, make the timer
 fire repeatedly that many seconds apart."
   (setf (timer--time timer) time)
@@ -88,7 +88,7 @@ SECS may be an integer, floating point number, or the internal
 time format returned by, e.g., `current-idle-time'.
 If optional third argument REPEAT is non-nil, make the timer
 fire each time Emacs is idle for that many seconds."
-  (setf (timer--time timer) (if (consp secs) secs (seconds-to-time secs)))
+  (setf (timer--time timer) secs)
   (setf (timer--repeat-delay timer) repeat)
   timer)
 
@@ -249,8 +249,8 @@ how many will really happen."
 (defun timer-until (timer time)
   "Calculate number of seconds from when TIMER will run, until TIME.
 TIMER is a timer, and stands for the time when its next repeat is scheduled.
-TIME is a time-list."
-  (- (float-time time) (float-time (timer--time timer))))
+TIME is a Lisp time value."
+  (float-time (time-subtract time (timer--time timer))))
 
 (defun timer-event-handler (timer)
   "Call the handler for the timer TIMER.
@@ -281,7 +281,7 @@ This function is called, by name, directly by the C code."
               ;; perhaps because Emacs was suspended for a long time,
               ;; limit how many times things get repeated.
               (if (and (numberp timer-max-repeats)
-                       (< 0 (timer-until timer nil)))
+                      (time-less-p (timer--time timer) nil))
                   (let ((repeats (/ (timer-until timer nil)
                                     (timer--repeat-delay timer))))
                     (if (> repeats timer-max-repeats)
diff --git a/lisp/emacs-lisp/tq.el b/lisp/emacs-lisp/tq.el
index f23c387..4249305 100644
--- a/lisp/emacs-lisp/tq.el
+++ b/lisp/emacs-lisp/tq.el
@@ -1,6 +1,6 @@
 ;;; tq.el --- utility to maintain a transaction queue  -*- lexical-binding:t 
-*-
 
-;; Copyright (C) 1985-1987, 1992, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1985-1987, 1992, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Scott Draves <address@hidden>
diff --git a/lisp/emacs-lisp/trace.el b/lisp/emacs-lisp/trace.el
index b92395b..2f271c1 100644
--- a/lisp/emacs-lisp/trace.el
+++ b/lisp/emacs-lisp/trace.el
@@ -1,6 +1,6 @@
 ;;; trace.el --- tracing facility for Emacs Lisp functions  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1993, 1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1998, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Hans Chalupsky <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/emacs-lisp/unsafep.el b/lisp/emacs-lisp/unsafep.el
index 03f22eb..1a2f1f3 100644
--- a/lisp/emacs-lisp/unsafep.el
+++ b/lisp/emacs-lisp/unsafep.el
@@ -1,6 +1,6 @@
 ;;;; unsafep.el -- Determine whether a Lisp form is safe to evaluate
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Jonathan Yavner <address@hidden>
 ;; Maintainer: Jonathan Yavner <address@hidden>
@@ -92,11 +92,6 @@
 in the parse.")
 (put 'unsafep-vars 'risky-local-variable t)
 
-;;Side-effect-free functions from subr.el
-(dolist (x '(assoc-default butlast last match-string
-            match-string-no-properties member-ignore-case remove remq))
-  (put x 'side-effect-free t))
-
 ;;Other safe functions
 (dolist (x '(;;Special forms
             and catch if or prog1 prog2 progn while unwind-protect
diff --git a/lisp/emacs-lisp/warnings.el b/lisp/emacs-lisp/warnings.el
index c4d97ce..13ca605 100644
--- a/lisp/emacs-lisp/warnings.el
+++ b/lisp/emacs-lisp/warnings.el
@@ -1,6 +1,6 @@
 ;;; warnings.el --- log and display warnings
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: internal
diff --git a/lisp/emacs-lock.el b/lisp/emacs-lock.el
index 1ff69cc..0cded29 100644
--- a/lisp/emacs-lock.el
+++ b/lisp/emacs-lock.el
@@ -1,6 +1,6 @@
 ;;; emacs-lock.el --- protect buffers against killing or exiting -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Juanma Barranquero <address@hidden>
 ;; Inspired by emacs-lock.el by Tom Wurgler <address@hidden>
diff --git a/lisp/emulation/cua-base.el b/lisp/emulation/cua-base.el
index f9a3fb0..46258cb 100644
--- a/lisp/emulation/cua-base.el
+++ b/lisp/emulation/cua-base.el
@@ -1,6 +1,6 @@
 ;;; cua-base.el --- emulate CUA key bindings
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
 ;; Author: Kim F. Storm <address@hidden>
 ;; Keywords: keyboard emulations convenience cua
@@ -427,7 +427,7 @@ and after the region marked by the rectangle to search."
 
 (defcustom cua-rectangle-modifier-key 'meta
   "Modifier key used for rectangle commands bindings.
-On non-window systems, always use the meta modifier.
+On non-window systems, use `cua-rectangle-terminal-modifier-key'.
 Must be set prior to enabling CUA."
   :type '(choice (const :tag "Meta key" meta)
                 (const :tag "Alt key" alt)
@@ -435,6 +435,16 @@ Must be set prior to enabling CUA."
                 (const :tag "Super key" super))
   :group 'cua)
 
+(defcustom cua-rectangle-terminal-modifier-key 'meta
+  "Modifier key used for rectangle commands bindings in terminals.
+Must be set prior to enabling CUA."
+  :type '(choice (const :tag "Meta key" meta)
+                (const :tag "Alt key" alt)
+                (const :tag "Hyper key" hyper)
+                (const :tag "Super key" super))
+  :group 'cua
+  :version "27.1")
+
 (defcustom cua-enable-rectangle-auto-help t
   "If non-nil, automatically show help for region, rectangle and global mark."
   :type 'boolean
@@ -592,6 +602,7 @@ a cons (TYPE . COLOR), then both properties are affected."
 
 (autoload 'cua-set-rectangle-mark "cua-rect"
   "Start rectangle at mouse click position." t nil)
+(autoload 'cua-toggle-rectangle-mark "cua-rect" nil t)
 
 ;; Stub definitions until it is loaded
 (defvar cua--rectangle)
@@ -710,7 +721,8 @@ a cons (TYPE . COLOR), then both properties are affected."
     ;; C-x binding after the first C-x C-x was rewritten to just C-x).
     (prefix-command-preserve-state)
     ;; Push the key back on the event queue
-    (setq unread-command-events (cons key unread-command-events))))
+    (setq unread-command-events (cons (cons 'no-record key)
+                                      unread-command-events))))
 
 (defun cua--prefix-override-handler ()
   "Start timer waiting for prefix key to be followed by another key.
@@ -1236,10 +1248,9 @@ If ARG is the atom `-', scroll upward by nearly full 
screen."
 (defun cua--init-keymaps ()
   ;; Cache actual rectangle modifier key.
   (setq cua--rectangle-modifier-key
-       (if (and cua-rectangle-modifier-key
-                (memq window-system '(x)))
-           cua-rectangle-modifier-key
-         'meta))
+       (if (eq (framep (selected-frame)) t)
+           cua-rectangle-terminal-modifier-key
+         cua-rectangle-modifier-key))
   ;; C-return always toggles rectangle mark
   (define-key cua-global-keymap cua-rectangle-mark-key 'cua-set-rectangle-mark)
   (unless (eq cua--rectangle-modifier-key 'meta)
diff --git a/lisp/emulation/cua-gmrk.el b/lisp/emulation/cua-gmrk.el
index 7f817da..16eff9d 100644
--- a/lisp/emulation/cua-gmrk.el
+++ b/lisp/emulation/cua-gmrk.el
@@ -1,6 +1,6 @@
 ;;; cua-gmrk.el --- CUA unified global mark support
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
 ;; Author: Kim F. Storm <address@hidden>
 ;; Keywords: keyboard emulations convenience cua mark
diff --git a/lisp/emulation/cua-rect.el b/lisp/emulation/cua-rect.el
index 296aba1..706634a 100644
--- a/lisp/emulation/cua-rect.el
+++ b/lisp/emulation/cua-rect.el
@@ -1,6 +1,6 @@
 ;;; cua-rect.el --- CUA unified rectangle support
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
 ;; Author: Kim F. Storm <address@hidden>
 ;; Keywords: keyboard emulations convenience CUA
diff --git a/lisp/emulation/edt-lk201.el b/lisp/emulation/edt-lk201.el
index 6073501..797de50 100644
--- a/lisp/emulation/edt-lk201.el
+++ b/lisp/emulation/edt-lk201.el
@@ -1,6 +1,6 @@
 ;;; edt-lk201.el --- enhanced EDT keypad mode emulation for LK-201 keyboards
 
-;; Copyright (C) 1986, 1992-1993, 1995, 2001-2018 Free Software
+;; Copyright (C) 1986, 1992-1993, 1995, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Kevin Gallagher <address@hidden>
diff --git a/lisp/emulation/edt-mapper.el b/lisp/emulation/edt-mapper.el
index 87becd5..b8e28f5 100644
--- a/lisp/emulation/edt-mapper.el
+++ b/lisp/emulation/edt-mapper.el
@@ -1,6 +1,6 @@
 ;;; edt-mapper.el --- create an EDT LK-201 map file for X-Windows Emacs
 
-;; Copyright (C) 1994-1995, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1995, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Kevin Gallagher <address@hidden>
 ;; Maintainer: Kevin Gallagher <address@hidden>
diff --git a/lisp/emulation/edt-pc.el b/lisp/emulation/edt-pc.el
index 2ee7e34..3fe33ca 100644
--- a/lisp/emulation/edt-pc.el
+++ b/lisp/emulation/edt-pc.el
@@ -1,6 +1,6 @@
 ;;; edt-pc.el --- enhanced EDT keypad mode emulation for PC 101 keyboards
 
-;; Copyright (C) 1986, 1994-1995, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1986, 1994-1995, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Kevin Gallagher <address@hidden>
diff --git a/lisp/emulation/edt-vt100.el b/lisp/emulation/edt-vt100.el
index f85f08e..f3d2518 100644
--- a/lisp/emulation/edt-vt100.el
+++ b/lisp/emulation/edt-vt100.el
@@ -1,6 +1,6 @@
 ;;; edt-vt100.el --- enhanced EDT keypad mode emulation for VT series terminals
 
-;; Copyright (C) 1986, 1992-1993, 1995, 2002-2018 Free Software
+;; Copyright (C) 1986, 1992-1993, 1995, 2002-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Kevin Gallagher <address@hidden>
diff --git a/lisp/emulation/edt.el b/lisp/emulation/edt.el
index 179791b..d1fe0b8 100644
--- a/lisp/emulation/edt.el
+++ b/lisp/emulation/edt.el
@@ -1,6 +1,6 @@
 ;;; edt.el --- enhanced EDT keypad mode emulation for GNU Emacs
 
-;; Copyright (C) 1986, 1992-1995, 2000-2018 Free Software Foundation,
+;; Copyright (C) 1986, 1992-1995, 2000-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Kevin Gallagher <address@hidden>
diff --git a/lisp/emulation/keypad.el b/lisp/emulation/keypad.el
index 841cf3c..543a1c9 100644
--- a/lisp/emulation/keypad.el
+++ b/lisp/emulation/keypad.el
@@ -1,6 +1,6 @@
 ;;; keypad.el --- simplified keypad bindings
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Kim F. Storm <address@hidden>
 ;; Keywords: keyboard convenience
diff --git a/lisp/emulation/viper-cmd.el b/lisp/emulation/viper-cmd.el
index 3b617a4..f52ce72 100644
--- a/lisp/emulation/viper-cmd.el
+++ b/lisp/emulation/viper-cmd.el
@@ -1,6 +1,6 @@
 ;;; viper-cmd.el --- Vi command support for Viper  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <address@hidden>
 ;; Package: viper
@@ -1124,7 +1124,7 @@ as a Meta key and any number of multiple escapes are 
allowed."
          ;; it is an error.
          (progn
            ;; new com is (CHAR . OLDCOM)
-           (if (viper-memq-char char '(?# ?\")) (error "Viper bell"))
+           (if (viper-memq-char char '(?# ?\")) (user-error viper-ViperBell))
            (setq com (cons char com))
            (setq cont nil))
        ;; If com is nil we set com as char, and read more.  Again, if char is
@@ -1143,7 +1143,7 @@ as a Meta key and any number of multiple escapes are 
allowed."
               (let ((reg (read-char)))
                 (if (viper-valid-register reg)
                     (setq viper-use-register reg)
-                  (error "Viper bell"))
+                  (user-error viper-ViperBell))
                 (setq char (read-char))))
              (t
               (setq com char)
@@ -1165,7 +1165,7 @@ as a Meta key and any number of multiple escapes are 
allowed."
              (viper-regsuffix-command-p char)
              (viper= char ?!) ; bang command
              (viper= char ?g) ; the gg command (like G0)
-             (error "Viper bell"))
+             (user-error viper-ViperBell))
          (setq cmd-to-exec-at-end
                (viper-exec-form-in-vi
                 `(key-binding (char-to-string ,char)))))
@@ -1199,7 +1199,7 @@ as a Meta key and any number of multiple escapes are 
allowed."
         ((equal com '(?= . ?=)) (viper-line (cons value ?=)))
         ;; gg  acts as G0
         ((equal (car com) ?g)   (viper-goto-line 0))
-        (t (error "Viper bell")))))
+        (t (user-error viper-ViperBell)))))
 
     (if cmd-to-exec-at-end
        (progn
@@ -2609,9 +2609,9 @@ On reaching end of line, stop and signal error."
          ;; the forward motion before the 'viper-execute-com', but, of
          ;; course, 'dl' doesn't work on an empty line, so we have to
          ;; catch that condition before 'viper-execute-com'
-         (if (and (eolp) (bolp)) (error "Viper bell") (forward-char val))
+         (if (and (eolp) (bolp)) (user-error viper-ViperBell) (forward-char 
val))
          (if com (viper-execute-com 'viper-forward-char val com))
-         (if (eolp) (progn (backward-char 1) (error "Viper bell"))))
+         (if (eolp) (progn (backward-char 1) (user-error viper-ViperBell))))
       (forward-char val)
       (if com (viper-execute-com 'viper-forward-char val com)))))
 
@@ -2626,7 +2626,7 @@ On reaching beginning of line, stop and signal error."
     (if com (viper-move-marker-locally 'viper-com-point (point)))
     (if viper-ex-style-motion
        (progn
-         (if (bolp) (error "Viper bell") (backward-char val))
+         (if (bolp) (user-error viper-ViperBell) (backward-char val))
          (if com (viper-execute-com 'viper-backward-char val com)))
       (backward-char val)
       (if com (viper-execute-com 'viper-backward-char val com)))))
@@ -2953,7 +2953,7 @@ On reaching beginning of line, stop and signal error."
     (if com (viper-execute-com 'viper-goto-col val com))
     (save-excursion
       (end-of-line)
-      (if (> val (current-column)) (error "Viper bell")))
+      (if (> val (current-column)) (user-error viper-ViperBell)))
     ))
 
 
@@ -3084,7 +3084,7 @@ If point is on a widget or a button, simulate clicking on 
that widget/button."
 ;; If FORWARD then search is forward, otherwise backward.  OFFSET is used to
 ;; adjust point after search.
 (defun viper-find-char (arg char forward offset)
-  (or (char-or-string-p char) (error "Viper bell"))
+  (or (char-or-string-p char) (user-error viper-ViperBell))
   (let ((arg (if forward arg (- arg)))
        (cmd (if (eq viper-intermediate-command 'viper-repeat)
                 (nth 5 viper-d-com)
@@ -3424,7 +3424,7 @@ controlled by the sign of prefix numeric value."
             (if com (viper-move-marker-locally 'viper-com-point (point)))
             (backward-sexp 1)
             (if com (viper-execute-com 'viper-paren-match nil com)))
-           (t (error "Viper bell"))))))
+           (t (user-error viper-ViperBell))))))
 
 (defun viper-toggle-parse-sexp-ignore-comments ()
   (interactive)
@@ -4001,7 +4001,7 @@ Null string will repeat previous search."
            (let ((reg viper-use-register))
              (setq viper-use-register nil)
              (error viper-EmptyRegister reg))
-         (error "Viper bell")))
+         (user-error viper-ViperBell)))
     (setq viper-use-register nil)
     (if (viper-end-with-a-newline-p text)
        (progn
@@ -4051,7 +4051,7 @@ Null string will repeat previous search."
            (let ((reg viper-use-register))
              (setq viper-use-register nil)
              (error viper-EmptyRegister reg))
-         (error "Viper bell")))
+         (user-error viper-ViperBell)))
     (setq viper-use-register nil)
     (if (viper-end-with-a-newline-p text) (beginning-of-line))
     (viper-set-destructive-command
@@ -4096,7 +4096,7 @@ Null string will repeat previous search."
             (> val (viper-chars-in-region (point) (viper-line-pos 'end))))
        (setq val (viper-chars-in-region (point) (viper-line-pos 'end))))
     (if (and viper-ex-style-motion (eolp))
-       (if (bolp) (error "Viper bell") (setq val 0))) ; not bol---simply back 
1 ch
+       (if (bolp) (user-error viper-ViperBell) (setq val 0))) ; not 
bol---simply back 1 ch
     (save-excursion
       (viper-forward-char-carefully val)
       (setq end-del-pos (point)))
@@ -4366,7 +4366,7 @@ and regexp replace."
          ((viper= char ?,) (viper-cycle-through-mark-ring))
          ((viper= char ?^) (push-mark viper-saved-mark t t))
          ((viper= char ?D) (mark-defun))
-         (t (error "Viper bell"))
+         (t (user-error viper-ViperBell))
          )))
 
 ;; Algorithm: If first invocation of this command save mark on ring, goto
@@ -4465,7 +4465,7 @@ One can use \\=`\\=` and \\='\\=' to temporarily jump 1 
step back."
                 (switch-to-buffer buff)
                 (goto-char viper-com-point)
                 (viper-change-state-to-vi)
-                (error "Viper bell")))))
+                (user-error viper-ViperBell)))))
        ((and (not skip-white) (viper= char ?`))
         (if com (viper-move-marker-locally 'viper-com-point (point)))
         (if (and (viper-same-line (point) viper-last-jump)
diff --git a/lisp/emulation/viper-ex.el b/lisp/emulation/viper-ex.el
index d95a828..45b91cd 100644
--- a/lisp/emulation/viper-ex.el
+++ b/lisp/emulation/viper-ex.el
@@ -1,6 +1,6 @@
 ;;; viper-ex.el --- functions implementing the Ex commands for Viper
 
-;; Copyright (C) 1994-1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1998, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <address@hidden>
 ;; Package: viper
@@ -427,18 +427,18 @@ reversed."
             (forward-char 1)
             (setq ex-token-type 'whole))
            ((= char ?+)
-            (cond ((or (looking-at "+[-+]") (looking-at "+[\n|]"))
+            (cond ((looking-at "\\+[-+\n|]")
                    (forward-char 1)
                    (insert "1")
                    (backward-char 1)
                  (setq ex-token-type 'plus))
-                  ((looking-at "+[0-9]")
+                  ((looking-at "\\+[0-9]")
                    (forward-char 1)
                    (setq ex-token-type 'plus))
                   (t
                    (error viper-BadAddress))))
            ((= char ?-)
-            (cond ((or (looking-at "-[-+]") (looking-at "-[\n|]"))
+            (cond ((looking-at "-[-+\n|]")
                    (forward-char 1)
                    (insert "1")
                    (backward-char 1)
@@ -455,7 +455,7 @@ reversed."
               (while (and (not (eolp)) cont)
                 ;;(re-search-forward "[^/]*/")
                 (re-search-forward "[^/]*\\(/\\|\n\\)")
-                (if (not (looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\/"
+                (if (not (looking-back "[^\\]\\(\\\\\\\\\\)*\\\\/"
                                         (line-beginning-position 0)))
                     (setq cont nil))))
             (backward-char 1)
@@ -469,7 +469,7 @@ reversed."
               (while (and (not (eolp)) cont)
                 ;;(re-search-forward "[^\\?]*\\?")
                 (re-search-forward "[^\\?]*\\(\\?\\|\n\\)")
-                (if (not (looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\\\?"
+                (if (not (looking-back "[^\\]\\(\\\\\\\\\\)*\\\\\\?"
                                         (line-beginning-position 0)))
                     (setq cont nil))
                 (backward-char 1)
@@ -565,7 +565,7 @@ reversed."
   (let (save-pos dist compl-list string-to-complete completion-result)
 
     (save-excursion
-      (setq dist (skip-chars-backward "[a-zA-Z!=>&~]")
+      (setq dist (skip-chars-backward "a-zA-Z!=>&~")
            save-pos (point)))
 
     (if (or (= dist 0)
@@ -744,7 +744,7 @@ reversed."
             (error
              "Global regexp must be inside matching non-alphanumeric chars"))
            ((= c ??) (error "`?' is not an allowed pattern delimiter here")))
-      (if (looking-at "[^\\\\\n]")
+      (if (looking-at "[^\\\n]")
          (progn
            (forward-char 1)
            (set-mark (point))
@@ -757,7 +757,7 @@ reversed."
                        (error "Missing closing delimiter for global regexp")
                      (goto-char (point-max))))
                (if (not (looking-back
-                         (format "[^\\\\]\\(\\\\\\\\\\)*\\\\%c" c)
+                         (format "[^\\]\\(\\\\\\\\\\)*\\\\%c" c)
                           (line-beginning-position 0)))
                    (setq cont nil)
                  ;; we are at an escaped delimiter: unescape it and continue
@@ -1240,7 +1240,7 @@ reversed."
                (read-string "[Hit return to confirm] ")
              (quit
               (save-excursion (kill-buffer " *delete text*"))
-              (error "Viper bell")))
+              (user-error viper-ViperBell)))
            (save-excursion (kill-buffer " *delete text*")))
        (if ex-buffer
            (cond ((viper-valid-register ex-buffer '(Letter))
@@ -1686,7 +1686,7 @@ reversed."
     (message ":set  <Variable> [= <Value>]")
     (or batch (sit-for 2))
 
-    (while (string-match "^[ \\t\\n]*$"
+    (while (string-match "^[ \t\n]*$"
                         (setq str
                               (completing-read ":set " ex-variable-alist)))
       (message ":set <Variable> [= <Value>]")
diff --git a/lisp/emulation/viper-init.el b/lisp/emulation/viper-init.el
index 7db9a34..5a80804 100644
--- a/lisp/emulation/viper-init.el
+++ b/lisp/emulation/viper-init.el
@@ -1,6 +1,6 @@
 ;;; viper-init.el --- some common definitions for Viper
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <address@hidden>
 ;; Package: viper
@@ -268,6 +268,7 @@ that deletes a file.")
 (defconst viper-BadAddress "Ill-formed address"   "")
 (defconst viper-FirstAddrExceedsSecond "First address exceeds second"   "")
 (defconst viper-NoFileSpecified "No file specified"   "")
+(defconst viper-ViperBell "Viper bell"   "")
 
 ;; Is t until viper-mode executes for the very first time.
 ;; Prevents recursive descend into startup messages.
diff --git a/lisp/emulation/viper-keym.el b/lisp/emulation/viper-keym.el
index cc0b7eb..8bb75d6 100644
--- a/lisp/emulation/viper-keym.el
+++ b/lisp/emulation/viper-keym.el
@@ -1,6 +1,6 @@
 ;;; viper-keym.el --- Viper keymaps  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1994-1997, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1997, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <address@hidden>
 ;; Package: viper
diff --git a/lisp/emulation/viper-macs.el b/lisp/emulation/viper-macs.el
index cfb46cc..37ab81d 100644
--- a/lisp/emulation/viper-macs.el
+++ b/lisp/emulation/viper-macs.el
@@ -1,6 +1,6 @@
 ;;; viper-macs.el --- functions implementing keyboard macros for Viper  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1994-1997, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1997, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <address@hidden>
 ;; Package: viper
diff --git a/lisp/emulation/viper-mous.el b/lisp/emulation/viper-mous.el
index 639596c..e49fc87 100644
--- a/lisp/emulation/viper-mous.el
+++ b/lisp/emulation/viper-mous.el
@@ -1,6 +1,6 @@
 ;;; viper-mous.el --- mouse support for Viper
 
-;; Copyright (C) 1994-1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <address@hidden>
 ;; Package: viper
diff --git a/lisp/emulation/viper-util.el b/lisp/emulation/viper-util.el
index aa45655..a7e7af3 100644
--- a/lisp/emulation/viper-util.el
+++ b/lisp/emulation/viper-util.el
@@ -1,6 +1,6 @@
 ;;; viper-util.el --- Utilities used by viper.el  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1994-1997, 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1997, 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <address@hidden>
 ;; Package: viper
diff --git a/lisp/emulation/viper.el b/lisp/emulation/viper.el
index 8dd150b..d6912ee 100644
--- a/lisp/emulation/viper.el
+++ b/lisp/emulation/viper.el
@@ -3,7 +3,7 @@
 ;;              and a venomous VI PERil.
 ;;              Viper Is also a Package for Emacs Rebels.
 
-;; Copyright (C) 1994-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <address@hidden>
 ;; Keywords: emulations
diff --git a/lisp/env.el b/lisp/env.el
index 7007ba3..5a4130e 100644
--- a/lisp/env.el
+++ b/lisp/env.el
@@ -1,6 +1,6 @@
 ;;; env.el --- functions to manipulate environment variables  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1991, 1994, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1991, 1994, 2000-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: processes, unix
diff --git a/lisp/epa-dired.el b/lisp/epa-dired.el
index 31f398f..3a3a143 100644
--- a/lisp/epa-dired.el
+++ b/lisp/epa-dired.el
@@ -1,5 +1,5 @@
 ;;; epa-dired.el --- the EasyPG Assistant, dired extension -*- 
lexical-binding: t -*-
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <address@hidden>
 ;; Keywords: PGP, GnuPG
diff --git a/lisp/epa-file.el b/lisp/epa-file.el
index 866a4ae..35cd1ec 100644
--- a/lisp/epa-file.el
+++ b/lisp/epa-file.el
@@ -1,5 +1,5 @@
 ;;; epa-file.el --- the EasyPG Assistant, transparent file encryption -*- 
lexical-binding: t -*-
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <address@hidden>
 ;; Keywords: PGP, GnuPG
diff --git a/lisp/epa-hook.el b/lisp/epa-hook.el
index 19f131c..cb9d997 100644
--- a/lisp/epa-hook.el
+++ b/lisp/epa-hook.el
@@ -1,5 +1,5 @@
 ;;; epa-hook.el --- preloaded code to enable epa-file.el -*- lexical-binding: 
t -*-
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <address@hidden>
 ;; Keywords: PGP, GnuPG
diff --git a/lisp/epa-mail.el b/lisp/epa-mail.el
index 0085937..1bb8d9b 100644
--- a/lisp/epa-mail.el
+++ b/lisp/epa-mail.el
@@ -1,5 +1,5 @@
 ;;; epa-mail.el --- the EasyPG Assistant, minor-mode for mail composer -*- 
lexical-binding: t -*-
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <address@hidden>
 ;; Keywords: PGP, GnuPG, mail, message
@@ -150,7 +150,7 @@ If no one is selected, default secret key is used.  "
                   (mapcar
                    (lambda (recipient)
                      (let ((tem (assoc recipient epa-mail-aliases)))
-                       (if tem (cdr tem)
+                       (if tem (copy-sequence (cdr tem))
                          (list recipient))))
                    real-recipients)))
       )))
diff --git a/lisp/epa.el b/lisp/epa.el
index 9f09128..c8abff4 100644
--- a/lisp/epa.el
+++ b/lisp/epa.el
@@ -1,6 +1,6 @@
 ;;; epa.el --- the EasyPG Assistant -*- lexical-binding: t -*-
 
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <address@hidden>
 ;; Keywords: PGP, GnuPG
diff --git a/lisp/epg-config.el b/lisp/epg-config.el
index fb866df..4502f90 100644
--- a/lisp/epg-config.el
+++ b/lisp/epg-config.el
@@ -1,6 +1,6 @@
 ;;; epg-config.el --- configuration of the EasyPG Library
 
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <address@hidden>
 ;; Keywords: PGP, GnuPG
diff --git a/lisp/epg.el b/lisp/epg.el
index c8f24eb..e06cc06 100644
--- a/lisp/epg.el
+++ b/lisp/epg.el
@@ -1,5 +1,5 @@
 ;;; epg.el --- the EasyPG Library -*- lexical-binding: t -*-
-;; Copyright (C) 1999-2000, 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2000, 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <address@hidden>
 ;; Keywords: PGP, GnuPG
@@ -1144,7 +1144,7 @@ callback data (if any)."
 
 (defun epg--status-SIG_CREATED (context string)
   (if (string-match "\\`\\([DCS]\\) \\([0-9]+\\) \\([0-9]+\\) \
-\\([0-9A-Fa-F][0-9A-Fa-F]\\) \\(.*\\) " string)
+\\([0-9A-Fa-f][0-9A-Fa-f]\\) \\(.*\\) " string)
       (epg-context-set-result-for
        context 'sign
        (cons (epg-make-new-signature
diff --git a/lisp/erc/ChangeLog.1 b/lisp/erc/ChangeLog.1
index 7e12f63..97b5d3f 100644
--- a/lisp/erc/ChangeLog.1
+++ b/lisp/erc/ChangeLog.1
@@ -11443,7 +11443,7 @@
        * erc.el: * Added command-names to completion (erc-command-table)
        * New variable erc-auto-query. When set, every arriving message to you
        will open a query buffer for that sender if not already open.
-       * Compatibility function fo non-existing line-beginning|end-position 
functions in XEmacs.
+       * Compatibility function for non-existing line-beginning|end-position 
functions in XEmacs.
 
 2001-10-03  Mario Lang  <address@hidden>
 
@@ -11702,7 +11702,7 @@
 
        * erc-speak.el, erc.el: New file.
 
-  Copyright (C) 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/erc/ChangeLog.2 b/lisp/erc/ChangeLog.2
index 5fc4135..e8b1046 100644
--- a/lisp/erc/ChangeLog.2
+++ b/lisp/erc/ChangeLog.2
@@ -757,7 +757,7 @@
 
 See ChangeLog.1 for earlier changes.
 
-  Copyright (C) 2009-2018 Free Software Foundation, Inc.
+  Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/erc/erc-autoaway.el b/lisp/erc/erc-autoaway.el
index 80cb6ab..9e224e0 100644
--- a/lisp/erc/erc-autoaway.el
+++ b/lisp/erc/erc-autoaway.el
@@ -1,6 +1,6 @@
 ;;; erc-autoaway.el --- Provides autoaway for ERC
 
-;; Copyright (C) 2002-2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Jorgen Schaefer <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 814ecfa..210830a 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -1,6 +1,6 @@
 ;;; erc-backend.el --- Backend network communication for ERC  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Filename: erc-backend.el
 ;; Author: Lawrence Mitchell <address@hidden>
@@ -844,10 +844,9 @@ Additionally, detect whether the IRC process has hung."
              erc-server-last-received-time))
       (with-current-buffer buf
         (if (and erc-server-send-ping-timeout
-                 (>
-                  (erc-time-diff (erc-current-time)
-                                 erc-server-last-received-time)
-                  erc-server-send-ping-timeout))
+                 (time-less-p
+                  erc-server-send-ping-timeout
+                  (time-since erc-server-last-received-time)))
             (progn
               ;; if the process is hung, kill it
               (setq erc-server-timed-out t)
@@ -865,16 +864,15 @@ Additionally, detect whether the IRC process has hung."
 See `erc-server-flood-margin' for an explanation of the flood
 protection algorithm."
   (with-current-buffer buffer
-    (let ((now (erc-current-time)))
+    (let ((now (current-time)))
       (when erc-server-flood-timer
         (erc-cancel-timer erc-server-flood-timer)
         (setq erc-server-flood-timer nil))
-      (when (< erc-server-flood-last-message
-               now)
-        (setq erc-server-flood-last-message now))
+      (when (time-less-p erc-server-flood-last-message now)
+        (setq erc-server-flood-last-message (erc-emacs-time-to-erc-time now)))
       (while (and erc-server-flood-queue
-                  (< erc-server-flood-last-message
-                     (+ now erc-server-flood-margin)))
+                  (time-less-p erc-server-flood-last-message
+                               (time-add now erc-server-flood-margin)))
         (let ((msg (caar erc-server-flood-queue))
               (encoding (cdar erc-server-flood-queue)))
           (setq erc-server-flood-queue (cdr erc-server-flood-queue)
@@ -1070,8 +1068,8 @@ Hands off to helper functions via `erc-call-hooks'."
               erc-server-prevent-duplicates)
       (let ((m (erc-response.unparsed parsed-response)))
         ;; duplicate suppression
-        (if (< (or (gethash m erc-server-duplicates) 0)
-               (- (erc-current-time) erc-server-duplicate-timeout))
+        (if (time-less-p (or (gethash m erc-server-duplicates) 0)
+                         (time-since erc-server-duplicate-timeout))
             (erc-call-hooks process parsed-response))
         (puthash m (erc-current-time) erc-server-duplicates))
     ;; Hand off to the relevant handler.
@@ -1287,7 +1285,7 @@ add things to `%s' instead."
     (pcase-let ((`(,nick ,login ,host)
                  (erc-parse-user (erc-response.sender parsed))))
       ;; strip the stupid combined JOIN facility (IRC 2.9)
-      (if (string-match "^\\(.*\\)?\^g.*$" chnl)
+      (if (string-match "^\\(.*\\)\^g.*$" chnl)
           (setq chnl (match-string 1 chnl)))
       (save-excursion
         (let* ((str (cond
@@ -1447,7 +1445,7 @@ add things to `%s' instead."
   "Handle pong messages." nil
   (let ((time (string-to-number (erc-response.contents parsed))))
     (when (> time 0)
-      (setq erc-server-lag (erc-time-diff time (erc-current-time)))
+      (setq erc-server-lag (erc-time-diff time nil))
       (when erc-verbose-server-ping
         (erc-display-message
          parsed 'notice proc 'PONG
@@ -1730,7 +1728,7 @@ See `erc-display-server-message'." nil
                (cdr (erc-response.command-args parsed))))
     (setq time (when on-since
                  (format-time-string erc-server-timestamp-format
-                                     (erc-string-to-emacs-time on-since))))
+                                     (string-to-number on-since))))
     (erc-update-user-nick nick nick nil nil nil
                           (and time (format "on since %s" time)))
     (if time
@@ -1802,7 +1800,7 @@ See `erc-display-server-message'." nil
 (define-erc-response-handler (329)
   "Channel creation date." nil
   (let ((channel (cadr (erc-response.command-args parsed)))
-        (time (erc-string-to-emacs-time
+        (time (string-to-number
                (nth 2 (erc-response.command-args parsed)))))
     (erc-display-message
      parsed 'notice (erc-get-buffer channel proc)
@@ -1844,7 +1842,7 @@ See `erc-display-server-message'." nil
   (pcase-let ((`(,channel ,nick ,time)
                (cdr (erc-response.command-args parsed))))
     (setq time (format-time-string erc-server-timestamp-format
-                                   (erc-string-to-emacs-time time)))
+                                   (string-to-number time)))
     (erc-update-channel-topic channel
                               (format "\C-o (%s, %s)" nick time)
                               'append)
diff --git a/lisp/erc/erc-button.el b/lisp/erc/erc-button.el
index 7599053..c8aa887 100644
--- a/lisp/erc/erc-button.el
+++ b/lisp/erc/erc-button.el
@@ -1,6 +1,6 @@
 ;; erc-button.el --- A way of buttonizing certain things in ERC buffers  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1996-2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Mario Lang <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/erc/erc-capab.el b/lisp/erc/erc-capab.el
index 85f18fd..210a773 100644
--- a/lisp/erc/erc-capab.el
+++ b/lisp/erc/erc-capab.el
@@ -1,6 +1,6 @@
 ;;; erc-capab.el --- support for dancer-ircd and hyperion's CAPAB
 
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 
diff --git a/lisp/erc/erc-compat.el b/lisp/erc/erc-compat.el
index ce66ff9..e724e36 100644
--- a/lisp/erc/erc-compat.el
+++ b/lisp/erc/erc-compat.el
@@ -1,6 +1,6 @@
 ;;; erc-compat.el --- ERC compatibility code for XEmacs
 
-;; Copyright (C) 2002-2003, 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2003, 2005-2019 Free Software Foundation, Inc.
 
 ;; Author: Alex Schroeder <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el
index 0ad7378..a6b7532 100644
--- a/lisp/erc/erc-dcc.el
+++ b/lisp/erc/erc-dcc.el
@@ -1,6 +1,6 @@
 ;;; erc-dcc.el --- CTCP DCC module for ERC
 
-;; Copyright (C) 1993-1995, 1998, 2002-2004, 2006-2018 Free Software
+;; Copyright (C) 1993-1995, 1998, 2002-2004, 2006-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Ben A. Mesander <address@hidden>
@@ -979,17 +979,20 @@ rather than every 1024 byte block, but nobody seems to 
care."
     (let ((inhibit-read-only t)
           received-bytes)
       (goto-char (point-max))
-      (insert (string-make-unibyte str))
+      (if str
+          (insert (string-make-unibyte str)))
 
       (when (> (point-max) erc-dcc-receive-cache)
         (erc-dcc-append-contents (current-buffer) erc-dcc-file-name))
-      (setq received-bytes (+ (buffer-size) erc-dcc-byte-count))
+      (setq received-bytes (buffer-size))
+      (if erc-dcc-byte-count
+          (setq received-bytes (+ received-bytes erc-dcc-byte-count)))
 
       (and erc-dcc-verbose
            (erc-display-message
             nil 'notice erc-server-process
             'dcc-get-bytes-received
-            ?f (file-name-nondirectory buffer-file-name)
+            ?f (file-name-nondirectory (buffer-name))
             ?b (number-to-string received-bytes)))
       (cond
        ((and (> (plist-get erc-dcc-entry-data :size) 0)
@@ -997,7 +1000,7 @@ rather than every 1024 byte block, but nobody seems to 
care."
         (erc-display-message
          nil '(notice error) 'active
          'dcc-get-file-too-long
-         ?f (file-name-nondirectory buffer-file-name))
+         ?f (file-name-nondirectory (buffer-name)))
         (delete-process proc))
        (t
         (process-send-string
@@ -1021,7 +1024,7 @@ transfer is complete."
      ?s (number-to-string erc-dcc-byte-count)
      ?t (format "%.0f"
                 (erc-time-diff (plist-get erc-dcc-entry-data :start-time)
-                               (erc-current-time)))))
+                               nil))))
   (kill-buffer (process-buffer proc))
   (delete-process proc))
 
diff --git a/lisp/erc/erc-desktop-notifications.el 
b/lisp/erc/erc-desktop-notifications.el
index 84db0f5..41b7420 100644
--- a/lisp/erc/erc-desktop-notifications.el
+++ b/lisp/erc/erc-desktop-notifications.el
@@ -1,6 +1,6 @@
-;; erc-desktop-notifications.el -- Send notification on PRIVMSG or mentions
+;; erc-desktop-notifications.el -- Send notification on PRIVMSG or mentions 
-*- lexical-binding:t -*-
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Julien Danjou <address@hidden>
 ;; Keywords: comm
@@ -59,13 +59,19 @@
 This will replace the last notification sent with this function."
   (dbus-ignore-errors
     (setq erc-notifications-last-notification
-          (notifications-notify :bus erc-notifications-bus
-                               :title (xml-escape-string nick)
-                                :body (xml-escape-string msg)
-                                :replaces-id 
erc-notifications-last-notification
-                                :app-icon erc-notifications-icon))))
-
-(defun erc-notifications-PRIVMSG (proc parsed)
+          (let ((channel (current-buffer)))
+            (notifications-notify :bus erc-notifications-bus
+                                  :title (format "%s in %s"
+                                                 (xml-escape-string nick)
+                                                 channel)
+                                  :body (xml-escape-string msg)
+                                  :replaces-id 
erc-notifications-last-notification
+                                  :app-icon erc-notifications-icon
+                                  :actions '("default" "Switch to buffer")
+                                  :on-action (lambda (&rest _)
+                                               (pop-to-buffer channel)))))))
+
+(defun erc-notifications-PRIVMSG (_proc parsed)
   (let ((nick (car (erc-parse-user (erc-response.sender parsed))))
         (target (car (erc-response.command-args parsed)))
         (msg (erc-response.contents parsed)))
diff --git a/lisp/erc/erc-ezbounce.el b/lisp/erc/erc-ezbounce.el
index 5869750..a2c9336 100644
--- a/lisp/erc/erc-ezbounce.el
+++ b/lisp/erc/erc-ezbounce.el
@@ -1,6 +1,6 @@
 ;;; erc-ezbounce.el ---  Handle EZBounce bouncer commands
 
-;; Copyright (C) 2002, 2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Andreas Fuchs <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/erc/erc-fill.el b/lisp/erc/erc-fill.el
index 5efb854..934b52a 100644
--- a/lisp/erc/erc-fill.el
+++ b/lisp/erc/erc-fill.el
@@ -1,6 +1,6 @@
 ;;; erc-fill.el --- Filling IRC messages in various ways
 
-;; Copyright (C) 2001-2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Andreas Fuchs <address@hidden>
 ;;         Mario Lang <address@hidden>
diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el
index 2d5aede..884c594 100644
--- a/lisp/erc/erc-goodies.el
+++ b/lisp/erc/erc-goodies.el
@@ -1,6 +1,6 @@
 ;; erc-goodies.el --- Collection of ERC modules
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Jorgen Schaefer <address@hidden>
 ;; Maintainer: address@hidden
@@ -548,7 +548,7 @@ channel that has weird people talking in morse to each 
other.
 
 See also `unmorse-region'."
   (goto-char (point-min))
-  (when (re-search-forward "[.-]+\\([.-]*/? *\\)+[.-]+/?" nil t)
+  (when (re-search-forward "[.-]+[./ -]*[.-]/?" nil t)
     (save-restriction
       (narrow-to-region (match-beginning 0) (match-end 0))
       ;; Turn " / " into "  "
diff --git a/lisp/erc/erc-ibuffer.el b/lisp/erc/erc-ibuffer.el
index 93a9573..149c858 100644
--- a/lisp/erc/erc-ibuffer.el
+++ b/lisp/erc/erc-ibuffer.el
@@ -1,6 +1,6 @@
 ;;; erc-ibuffer.el --- ibuffer integration with ERC
 
-;; Copyright (C) 2002, 2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Mario Lang <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/erc/erc-identd.el b/lisp/erc/erc-identd.el
index d710d95..d95e0ea 100644
--- a/lisp/erc/erc-identd.el
+++ b/lisp/erc/erc-identd.el
@@ -1,6 +1,6 @@
 ;;; erc-identd.el --- RFC1413 (identd authentication protocol) server
 
-;; Copyright (C) 2003, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/erc/erc-imenu.el b/lisp/erc/erc-imenu.el
index f038216..08f52f1 100644
--- a/lisp/erc/erc-imenu.el
+++ b/lisp/erc/erc-imenu.el
@@ -1,6 +1,6 @@
 ;;; erc-imenu.el -- Imenu support for ERC
 
-;; Copyright (C) 2001-2002, 2004, 2006-2018 Free Software Foundation,
+;; Copyright (C) 2001-2002, 2004, 2006-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Mario Lang <address@hidden>
diff --git a/lisp/erc/erc-join.el b/lisp/erc/erc-join.el
index d7ae933..896521e 100644
--- a/lisp/erc/erc-join.el
+++ b/lisp/erc/erc-join.el
@@ -1,6 +1,6 @@
 ;;; erc-join.el --- autojoin channels on connect and reconnects
 
-;; Copyright (C) 2002-2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Alex Schroeder <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/erc/erc-lang.el b/lisp/erc/erc-lang.el
index 02823e7..f0dbe69 100644
--- a/lisp/erc/erc-lang.el
+++ b/lisp/erc/erc-lang.el
@@ -1,6 +1,6 @@
 ;;; erc-lang.el --- provide the LANG command to ERC
 
-;; Copyright (C) 2002, 2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Alex Schroeder <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/erc/erc-list.el b/lisp/erc/erc-list.el
index 0bb962d..d8d9e17 100644
--- a/lisp/erc/erc-list.el
+++ b/lisp/erc/erc-list.el
@@ -1,6 +1,6 @@
 ;;; erc-list.el --- /list support for ERC  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Tom Tromey <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/erc/erc-log.el b/lisp/erc/erc-log.el
index 584f566..4153f5c 100644
--- a/lisp/erc/erc-log.el
+++ b/lisp/erc/erc-log.el
@@ -1,6 +1,6 @@
 ;;; erc-log.el --- Logging facilities for ERC.
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author: Lawrence Mitchell <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/erc/erc-match.el b/lisp/erc/erc-match.el
index 534a5b7..cc4b4a8 100644
--- a/lisp/erc/erc-match.el
+++ b/lisp/erc/erc-match.el
@@ -1,6 +1,6 @@
 ;;; erc-match.el --- Highlight messages matching certain regexps
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Andreas Fuchs <address@hidden>
 ;; Maintainer: address@hidden
@@ -601,7 +601,7 @@ See `erc-log-match-format'."
                                                       'timestamp))))
                  (away-time (erc-emacs-time-to-erc-time (erc-away-time))))
             (when (and away-time last-msg-time
-                       (erc-time-gt last-msg-time away-time))
+                       (time-less-p away-time last-msg-time))
               (erc-display-message
                nil 'notice 'active
                (format "You have logged messages waiting in \"%s\"."
diff --git a/lisp/erc/erc-menu.el b/lisp/erc/erc-menu.el
index 4270ec6..8173829 100644
--- a/lisp/erc/erc-menu.el
+++ b/lisp/erc/erc-menu.el
@@ -1,6 +1,6 @@
 ;; erc-menu.el -- Menu-bar definitions for ERC
 
-;; Copyright (C) 2001-2002, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2002, 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Mario Lang <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/erc/erc-netsplit.el b/lisp/erc/erc-netsplit.el
index 885fc49..87c3a61 100644
--- a/lisp/erc/erc-netsplit.el
+++ b/lisp/erc/erc-netsplit.el
@@ -1,6 +1,6 @@
 ;;; erc-netsplit.el --- Reduce JOIN/QUIT messages on netsplits
 
-;; Copyright (C) 2002-2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Mario Lang <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/erc/erc-networks.el b/lisp/erc/erc-networks.el
index 824c482..eca8ad6 100644
--- a/lisp/erc/erc-networks.el
+++ b/lisp/erc/erc-networks.el
@@ -1,6 +1,6 @@
 ;;; erc-networks.el --- IRC networks
 
-;; Copyright (C) 2002, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Mario Lang <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/erc/erc-notify.el b/lisp/erc/erc-notify.el
index 2666598..45dae89 100644
--- a/lisp/erc/erc-notify.el
+++ b/lisp/erc/erc-notify.el
@@ -1,6 +1,6 @@
 ;;; erc-notify.el --- Online status change notification  -*- lexical-binding:t 
-*-
 
-;; Copyright (C) 2002-2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Mario Lang <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/erc/erc-page.el b/lisp/erc/erc-page.el
index 4d78a8c..cb57883 100644
--- a/lisp/erc/erc-page.el
+++ b/lisp/erc/erc-page.el
@@ -1,6 +1,6 @@
 ;; erc-page.el - CTCP PAGE support for ERC
 
-;; Copyright (C) 2002, 2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 
diff --git a/lisp/erc/erc-pcomplete.el b/lisp/erc/erc-pcomplete.el
index db0359c..dd2da85 100644
--- a/lisp/erc/erc-pcomplete.el
+++ b/lisp/erc/erc-pcomplete.el
@@ -1,6 +1,6 @@
 ;;; erc-pcomplete.el --- Provides programmable completion for ERC
 
-;; Copyright (C) 2002-2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Sacha Chua <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/erc/erc-replace.el b/lisp/erc/erc-replace.el
index f321ae0..2e0e54a 100644
--- a/lisp/erc/erc-replace.el
+++ b/lisp/erc/erc-replace.el
@@ -1,6 +1,6 @@
 ;; erc-replace.el -- wash and massage messages inserted into the buffer
 
-;; Copyright (C) 2001-2002, 2004, 2006-2018 Free Software Foundation,
+;; Copyright (C) 2001-2002, 2004, 2006-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Andreas Fuchs <address@hidden>
diff --git a/lisp/erc/erc-ring.el b/lisp/erc/erc-ring.el
index 7e315d3..5459d8b 100644
--- a/lisp/erc/erc-ring.el
+++ b/lisp/erc/erc-ring.el
@@ -1,6 +1,6 @@
 ;; erc-ring.el -- Command history handling for erc using ring.el
 
-;; Copyright (C) 2001-2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Alex Schroeder <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/erc/erc-services.el b/lisp/erc/erc-services.el
index ac49a3e..886ba60 100644
--- a/lisp/erc/erc-services.el
+++ b/lisp/erc/erc-services.el
@@ -1,6 +1,6 @@
 ;;; erc-services.el --- Identify to NickServ  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2002-2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 
diff --git a/lisp/erc/erc-sound.el b/lisp/erc/erc-sound.el
index 8df8ded..34f7ce6 100644
--- a/lisp/erc/erc-sound.el
+++ b/lisp/erc/erc-sound.el
@@ -1,6 +1,6 @@
 ;;; erc-sound.el --- CTCP SOUND support for ERC
 
-;; Copyright (C) 2002-2003, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2003, 2006-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 
diff --git a/lisp/erc/erc-speedbar.el b/lisp/erc/erc-speedbar.el
index 58eefd8..0a1e38f 100644
--- a/lisp/erc/erc-speedbar.el
+++ b/lisp/erc/erc-speedbar.el
@@ -1,6 +1,6 @@
 ;;; erc-speedbar.el --- Speedbar support for ERC
 
-;; Copyright (C) 2001-2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Mario Lang <address@hidden>
 ;; Contributor: Eric M. Ludlam <address@hidden>
@@ -140,7 +140,7 @@ This will add a speedbar major display mode."
        t))))
 
 (defun erc-speedbar-expand-server (text server indent)
-  (cond ((string-match "+" text)
+  (cond ((string-match "\\+" text)
         (speedbar-change-expand-button-char ?-)
         (if (speedbar-with-writable
               (save-excursion
@@ -185,7 +185,7 @@ This will add a speedbar major display mode."
   "For the line matching TEXT, in CHANNEL, expand or contract a line.
 INDENT is the current indentation level."
   (cond
-   ((string-match "+" text)
+   ((string-match "\\+" text)
     (speedbar-change-expand-button-char ?-)
     (speedbar-with-writable
      (save-excursion
@@ -285,7 +285,7 @@ is only done when the channel is actually expanded already."
        (erc-speedbar-expand-channel "+" buffer 1)))))
 
 (defun erc-speedbar-expand-user (text token indent)
-  (cond ((string-match "+" text)
+  (cond ((string-match "\\+" text)
         (speedbar-change-expand-button-char ?-)
         (speedbar-with-writable
           (save-excursion
diff --git a/lisp/erc/erc-spelling.el b/lisp/erc/erc-spelling.el
index 3a34ea3..69a83fa 100644
--- a/lisp/erc/erc-spelling.el
+++ b/lisp/erc/erc-spelling.el
@@ -1,6 +1,6 @@
 ;;; erc-spelling.el --- use flyspell in ERC
 
-;; Copyright (C) 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005-2019 Free Software Foundation, Inc.
 
 ;; Author: Jorgen Schaefer <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/erc/erc-stamp.el b/lisp/erc/erc-stamp.el
index 6a648e7..860fdbb 100644
--- a/lisp/erc/erc-stamp.el
+++ b/lisp/erc/erc-stamp.el
@@ -1,6 +1,6 @@
 ;;; erc-stamp.el --- Timestamping for ERC messages
 
-;; Copyright (C) 2002-2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Mario Lang <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/erc/erc-track.el b/lisp/erc/erc-track.el
index d1f4d4a..e51e605 100644
--- a/lisp/erc/erc-track.el
+++ b/lisp/erc/erc-track.el
@@ -1,6 +1,6 @@
 ;;; erc-track.el --- Track modified channel buffers  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Mario Lang <address@hidden>
 ;; Maintainer: address@hidden
@@ -630,8 +630,8 @@ only consider active buffers visible.")
   (if erc-track-when-inactive
       (when erc-buffer-activity; could be nil
        (and (erc-track-get-buffer-window buffer erc-track-visibility)
-            (<= (erc-time-diff erc-buffer-activity (erc-current-time))
-                erc-buffer-activity-timeout)))
+            (not (time-less-p erc-buffer-activity-timeout
+                              (erc-time-diff erc-buffer-activity nil)))))
     (erc-track-get-buffer-window buffer erc-track-visibility)))
 
 ;;; Tracking the channel modifications
@@ -640,7 +640,7 @@ only consider active buffers visible.")
   (unless (minibuffer-window-active-p (minibuffer-window))
     ;; delay this until command has finished to make sure window is
     ;; actually visible before clearing activity
-    (add-hook 'post-command-hook 'erc-modified-channels-update)))
+    (erc-modified-channels-update)))
 
 (defvar erc-modified-channels-update-inside nil
   "Variable to prevent running `erc-modified-channels-update' multiple
@@ -669,8 +669,7 @@ ARGS are ignored."
                  (erc-modified-channels-remove-buffer buffer))))
            erc-modified-channels-alist)
       (when removed-channel
-       (erc-modified-channels-display)))
-    (remove-hook 'post-command-hook 'erc-modified-channels-update)))
+       (erc-modified-channels-display)))))
 
 (defvar erc-track-mouse-face (if (featurep 'xemacs)
                                 'modeline-mousable
diff --git a/lisp/erc/erc-truncate.el b/lisp/erc/erc-truncate.el
index d4359c5..0417429 100644
--- a/lisp/erc/erc-truncate.el
+++ b/lisp/erc/erc-truncate.el
@@ -1,6 +1,6 @@
 ;;; erc-truncate.el --- Functions for truncating ERC buffers
 
-;; Copyright (C) 2003-2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Andreas Fuchs <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/erc/erc-xdcc.el b/lisp/erc/erc-xdcc.el
index 0d66fe5..162b22e 100644
--- a/lisp/erc/erc-xdcc.el
+++ b/lisp/erc/erc-xdcc.el
@@ -1,6 +1,6 @@
 ;;; erc-xdcc.el --- XDCC file-server support for ERC
 
-;; Copyright (C) 2003-2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Mario Lang <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 60f877f..d1fa5c7 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -1,6 +1,6 @@
 ;; erc.el --- An Emacs Internet Relay Chat client  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
 ;; Author: Alexander L. Belikoff (address@hidden)
 ;; Contributors: Sergey Berezin (address@hidden),
@@ -62,9 +62,6 @@
 ;;; History:
 ;;
 
-(defconst erc-version-string (format "\C-bERC\C-b (IRC client for Emacs %s)" 
emacs-version)
-  "ERC version.  This is used by function `erc-version'.")
-
 ;;; Code:
 
 (load "erc-loaddefs" nil t)
@@ -2525,10 +2522,7 @@ Returns NICK unmodified unless `erc-lurker-trim-nicks' is
 non-nil."
   (if erc-lurker-trim-nicks
       (replace-regexp-in-string
-       (format "[%s]"
-               (mapconcat (lambda (char)
-                            (regexp-quote (char-to-string char)))
-                          erc-lurker-ignore-chars ""))
+       (regexp-opt-charset (string-to-list erc-lurker-ignore-chars))
        "" nick)
     nick))
 
@@ -2568,8 +2562,8 @@ consumption for long-lived IRC or Emacs sessions."
      (maphash
       (lambda (nick last-PRIVMSG-time)
         (when
-            (> (float-time (time-subtract nil last-PRIVMSG-time))
-               erc-lurker-threshold-time)
+           (time-less-p erc-lurker-threshold-time
+                        (time-since last-PRIVMSG-time))
           (remhash nick hash)))
       hash)
      (if (zerop (hash-table-count hash))
@@ -2634,9 +2628,8 @@ server within `erc-lurker-threshold-time'.  See also
           (gethash (erc-lurker-maybe-trim nick)
                    (gethash server erc-lurker-state (make-hash-table)))))
     (or (null last-PRIVMSG-time)
-        (> (float-time
-            (time-subtract nil last-PRIVMSG-time))
-           erc-lurker-threshold-time))))
+       (time-less-p erc-lurker-threshold-time
+                    (time-since last-PRIVMSG-time)))))
 
 (defcustom erc-common-server-suffixes
   '(("openprojects.net\\'" . "OPN")
@@ -3415,7 +3408,7 @@ Otherwise leave the channel indicated by LINE."
 
 (defun erc-cmd-PING (recipient)
   "Ping RECIPIENT."
-  (let ((time (format "%f" (erc-current-time))))
+  (let ((time (format-time-string "%s.%6N")))
     (erc-log (format "cmd: PING: %s" time))
     (erc-cmd-CTCP recipient "PING" time)))
 
@@ -4289,7 +4282,7 @@ and as second argument the event parsed as a vector."
 (defun erc-is-message-ctcp-and-not-action-p (message)
   "Check if MESSAGE is a CTCP message or not."
   (and (erc-is-message-ctcp-p message)
-       (not (string-match "^\C-a\\ACTION.*\C-a$" message))))
+       (not (string-match "^\C-aACTION.*\C-a$" message))))
 
 (defun erc-format-privmessage (nick msg privp msgp)
   "Format a PRIVMSG in an insertable fashion."
@@ -4495,7 +4488,7 @@ See also: `erc-echo-notice-in-user-buffers',
                                     (mapcar #'upcase
                                             (cdr (split-string mode)))))
                         erc-channel-banlist)))
-                ((string-match "^+" mode)
+                ((string-match "^\\+" mode)
                  ;; Add the banned mask(s) to the ban list
                  (mapc
                   (lambda (mask)
@@ -4643,7 +4636,7 @@ See also `erc-display-message'."
                        (user-full-name)
                        (user-login-name)
                        (system-name))))
-          (ns (erc-time-diff erc-server-last-sent-time (erc-current-time))))
+          (ns (erc-time-diff erc-server-last-sent-time nil)))
       (when (> ns 0)
         (setq s (concat s " Idle for " (erc-sec-to-time ns))))
       (erc-send-ctcp-notice nick s)))
@@ -4732,8 +4725,7 @@ See also `erc-display-message'."
       nil
     (let ((time (match-string 1 msg)))
       (condition-case nil
-          (let ((delta (erc-time-diff (string-to-number time)
-                                      (erc-current-time))))
+          (let ((delta (erc-time-diff (string-to-number time) nil)))
             (erc-display-message
              nil 'notice 'active
              'CTCP-PING ?n nick
@@ -4791,10 +4783,7 @@ If non-nil, return from being away."
                  (erc-default-target)
                  (if away-time
                      (format "is back (gone for %s)"
-                             (erc-sec-to-time
-                              (erc-time-diff
-                               (erc-emacs-time-to-erc-time away-time)
-                               (erc-current-time))))
+                             (erc-sec-to-time (erc-time-diff away-time nil)))
                    "is back")))))))))
     (erc-update-mode-line)))
 
@@ -5386,10 +5375,10 @@ submitted line to be intentional."
 (defun erc-send-current-line ()
   "Parse current line and send it to IRC."
   (interactive)
-  (let ((now (float-time)))
+  (let ((now (current-time)))
     (if (or (not erc-accidental-paste-threshold-seconds)
-            (< erc-accidental-paste-threshold-seconds
-               (- now erc-last-input-time)))
+            (time-less-p erc-accidental-paste-threshold-seconds
+                        (time-subtract now erc-last-input-time)))
         (save-restriction
           (widen)
           (if (< (point) (erc-beg-of-input-line))
@@ -6039,22 +6028,20 @@ non-nil value is found.
 
 ;; time routines
 
-(defun erc-string-to-emacs-time (string)
-  "Convert the long number represented by STRING into an Emacs timestamp."
-  (let* ((n (string-to-number (concat string ".0"))))
-    (list (truncate (/ n 65536))
-          (truncate (mod n 65536)))))
+(define-obsolete-function-alias 'erc-string-to-emacs-time 'string-to-number
+  "27.1")
 
 (defalias 'erc-emacs-time-to-erc-time 'float-time)
 (defalias 'erc-current-time 'float-time)
 
 (defun erc-time-diff (t1 t2)
-  "Return the time difference in seconds between T1 and T2."
-  (abs (- t2 t1)))
+  "Return the absolute value of the difference in seconds between T1 and T2."
+  (abs (float-time (time-subtract t1 t2))))
 
 (defun erc-time-gt (t1 t2)
   "Check whether T1 > T2."
-  (> t1 t2))
+  (declare (obsolete time-less-p "27.1"))
+  (time-less-p t2 t1))
 
 (defun erc-sec-to-time (ns)
   "Convert NS to a time string HH:MM.SS."
diff --git a/lisp/eshell/em-alias.el b/lisp/eshell/em-alias.el
index c5125fd..c465d46 100644
--- a/lisp/eshell/em-alias.el
+++ b/lisp/eshell/em-alias.el
@@ -1,6 +1,6 @@
 ;;; em-alias.el --- creation and management of command aliases  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -90,7 +90,7 @@
 
 ;;; Code:
 
-(require 'eshell)
+(require 'esh-mode)
 
 ;;;###autoload
 (progn
@@ -141,12 +141,12 @@ file named by `eshell-aliases-file'.")
 (defvar eshell-failed-commands-alist nil
   "An alist of command name failures.")
 
-(defun eshell-alias-initialize ()
+(defun eshell-alias-initialize ()    ;Called from `eshell-mode' via 
intern-soft!
   "Initialize the alias handling code."
   (make-local-variable 'eshell-failed-commands-alist)
-  (add-hook 'eshell-alternate-command-hook 'eshell-fix-bad-commands t t)
+  (add-hook 'eshell-alternate-command-hook #'eshell-fix-bad-commands t t)
   (eshell-read-aliases-list)
-  (add-hook 'eshell-named-command-hook 'eshell-maybe-replace-by-alias t t)
+  (add-hook 'eshell-named-command-hook #'eshell-maybe-replace-by-alias t t)
   (make-local-variable 'eshell-complex-commands)
   (add-to-list 'eshell-complex-commands 'eshell-command-aliased-p))
 
diff --git a/lisp/eshell/em-banner.el b/lisp/eshell/em-banner.el
index f8fd898..c284c1b 100644
--- a/lisp/eshell/em-banner.el
+++ b/lisp/eshell/em-banner.el
@@ -1,6 +1,6 @@
 ;;; em-banner.el --- sample module that displays a login banner  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -71,7 +71,7 @@ This can be any sexp, and should end with at least two 
newlines."
   :type 'hook
   :group 'eshell-banner)
 
-(defun eshell-banner-initialize ()
+(defun eshell-banner-initialize ()  ;Called from `eshell-mode' via intern-soft!
   "Output a welcome banner on initialization."
   ;; it's important to use `eshell-interactive-print' rather than
   ;; `insert', because `insert' doesn't know how to interact with the
diff --git a/lisp/eshell/em-basic.el b/lisp/eshell/em-basic.el
index 5201076..72a4e6b 100644
--- a/lisp/eshell/em-basic.el
+++ b/lisp/eshell/em-basic.el
@@ -1,6 +1,6 @@
 ;;; em-basic.el --- basic shell builtin commands  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -118,7 +118,7 @@ or `eshell-printn' for display."
 
 (defun eshell/printnl (&rest args)
   "Print out each of the arguments, separated by newlines."
-  (let ((elems (eshell-flatten-list args)))
+  (let ((elems (flatten-tree args)))
     (while elems
       (eshell-printn (eshell-echo (list (car elems))))
       (setq elems (cdr elems)))))
diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el
index e79b490..e3bfd8d 100644
--- a/lisp/eshell/em-cmpl.el
+++ b/lisp/eshell/em-cmpl.el
@@ -1,6 +1,6 @@
 ;;; em-cmpl.el --- completion using the TAB key  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -244,7 +244,7 @@ to writing a completion function."
   (let ((completion-at-point-functions '(lisp-completion-at-point)))
     (completion-at-point)))
 
-(defun eshell-cmpl-initialize ()
+(defun eshell-cmpl-initialize ()    ;Called from `eshell-mode' via intern-soft!
   "Initialize the completions module."
   (set (make-local-variable 'pcomplete-command-completion-function)
        eshell-command-completion-function)
@@ -288,9 +288,10 @@ to writing a completion function."
            (function
             (lambda ()
               (set (make-local-variable 'comint-file-name-quote-list)
-                   eshell-special-chars-outside-quoting))) nil t)
-  (add-hook 'pcomplete-quote-arg-hook 'eshell-quote-backslash nil t)
-  (define-key eshell-mode-map [(meta tab)] 'eshell-complete-lisp-symbol)
+                   eshell-special-chars-outside-quoting)))
+            nil t)
+  (add-hook 'pcomplete-quote-arg-hook #'eshell-quote-backslash nil t)
+  ;;(define-key eshell-mode-map [(meta tab)] 'eshell-complete-lisp-symbol) ; 
Redundant
   (define-key eshell-mode-map [(meta control ?i)] 'eshell-complete-lisp-symbol)
   (define-key eshell-command-map [(meta ?h)] 'eshell-completion-help)
   (define-key eshell-command-map [tab] 'pcomplete-expand-and-complete)
@@ -298,15 +299,14 @@ to writing a completion function."
     'pcomplete-expand-and-complete)
   (define-key eshell-command-map [space] 'pcomplete-expand)
   (define-key eshell-command-map [? ] 'pcomplete-expand)
-  (define-key eshell-mode-map [tab] 'eshell-pcomplete)
-  (define-key eshell-mode-map [(control ?i)] 'eshell-pcomplete)
+  ;;(define-key eshell-mode-map [tab] 'completion-at-point) ;Redundant!
+  (define-key eshell-mode-map [(control ?i)] 'completion-at-point)
   (add-hook 'completion-at-point-functions
             #'pcomplete-completions-at-point nil t)
   ;; jww (1999-10-19): Will this work on anything but X?
-  (if (featurep 'xemacs)
-      (define-key eshell-mode-map [iso-left-tab] 'pcomplete-reverse)
-    (define-key eshell-mode-map [backtab] 'pcomplete-reverse))
-  (define-key eshell-mode-map [(meta ??)] 'pcomplete-list))
+  (define-key eshell-mode-map
+    (if (featurep 'xemacs) [iso-left-tab] [backtab]) 'pcomplete-reverse)
+  (define-key eshell-mode-map [(meta ??)] 'completion-help-at-point))
 
 (defun eshell-completion-command-name ()
   "Return the command name, possibly sans globbing."
@@ -442,34 +442,24 @@ to writing a completion function."
         (if glob-name
             completions
           (setq completions
-                (append (and (eshell-using-module 'eshell-alias)
-                             (funcall (symbol-function 
'eshell-alias-completions)
-                                      filename))
+                (append (if (fboundp 'eshell-alias-completions)
+                             (eshell-alias-completions filename))
                         (eshell-winnow-list
                          (mapcar
                           (function
                            (lambda (name)
                              (substring name 7)))
                           (all-completions (concat "eshell/" filename)
-                                           obarray 'functionp))
+                                           obarray #'functionp))
                          nil '(eshell-find-alias-function))
                         completions))
           (append (and (or eshell-show-lisp-completions
                            (and eshell-show-lisp-alternatives
                                 (null completions)))
-                       (all-completions filename obarray 'functionp))
+                       (all-completions filename obarray #'functionp))
                   completions)))))))
 
-(defun eshell-pcomplete (&optional interactively)
-  "Eshell wrapper for `pcomplete'."
-  (interactive "p")
-  ;; Pretend to be pcomplete so that cycling works (bug#13293).
-  (setq this-command 'pcomplete)
-  (condition-case nil
-      (if interactively
-         (call-interactively 'pcomplete)
-       (pcomplete))
-    (text-read-only (completion-at-point)))) ; Workaround for bug#12838.
+(define-obsolete-function-alias 'eshell-pcomplete #'completion-at-point "27.1")
 
 (provide 'em-cmpl)
 
diff --git a/lisp/eshell/em-dirs.el b/lisp/eshell/em-dirs.el
index 8533828..c28fd72 100644
--- a/lisp/eshell/em-dirs.el
+++ b/lisp/eshell/em-dirs.el
@@ -1,6 +1,6 @@
 ;;; em-dirs.el --- directory navigation commands  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -42,7 +42,8 @@
 
 ;;; Code:
 
-(require 'eshell)
+(require 'esh-mode)                     ;For eshell-directory-name
+(require 'esh-var)                      ;For eshell-variable-aliases-list
 (require 'ring)
 (require 'esh-opt)
 
@@ -62,12 +63,11 @@ they lack somewhat in feel from the typical shell 
equivalents."
 (defcustom eshell-dirs-load-hook nil
   "A hook that gets run when `eshell-dirs' is loaded."
   :version "24.1"                      ; removed eshell-dirs-initialize
-  :type 'hook
-  :group 'eshell-dirs)
+  :type 'hook)
 
 (defcustom eshell-pwd-convert-function (if (eshell-under-windows-p)
-                                          'expand-file-name
-                                        'identity)
+                                          #'expand-file-name
+                                        #'identity)
   "The function used to normalize the value of Eshell's `pwd'.
 The value returned by `pwd' is also used when recording the
 last-visited directory in the last-dir-ring, so it will affect the
@@ -75,8 +75,7 @@ form of the list used by `cd ='."
   :type '(radio (function-item file-truename)
                (function-item expand-file-name)
                (function-item identity)
-               (function :tag "Other"))
-  :group 'eshell-dirs)
+               (function :tag "Other")))
 
 (defcustom eshell-ask-to-save-last-dir 'always
   "Determine if the last-dir-ring should be automatically saved.
@@ -88,63 +87,53 @@ If set to t, always ask if any Eshell buffers are open at 
exit time.
 If set to `always', the list-dir-ring will always be saved, silently."
   :type '(choice (const :tag "Never" nil)
                 (const :tag "Ask" t)
-                (const :tag "Always save" always))
-  :group 'eshell-dirs)
+                (const :tag "Always save" always)))
 
 (defcustom eshell-cd-shows-directory nil
   "If non-nil, using `cd' will report the directory it changes to."
-  :type 'boolean
-  :group 'eshell-dirs)
+  :type 'boolean)
 
 (defcustom eshell-cd-on-directory t
   "If non-nil, do a cd if a directory is in command position."
-  :type 'boolean
-  :group 'eshell-dirs)
+  :type 'boolean)
 
 (defcustom eshell-directory-change-hook nil
   "A hook to run when the current directory changes."
-  :type 'hook
-  :group 'eshell-dirs)
+  :type 'hook)
 
 (defcustom eshell-list-files-after-cd nil
   "If non-nil, call \"ls\" with any remaining args after doing a cd.
 This is provided for convenience, since the same effect is easily
 achieved by adding a function to `eshell-directory-change-hook' that
 calls \"ls\" and references `eshell-last-arguments'."
-  :type 'boolean
-  :group 'eshell-dirs)
+  :type 'boolean)
 
 (defcustom eshell-pushd-tohome nil
   "If non-nil, make pushd with no arg behave as `pushd ~' (like `cd').
 This mirrors the optional behavior of tcsh."
-  :type 'boolean
-  :group 'eshell-dirs)
+  :type 'boolean)
 
 (defcustom eshell-pushd-dextract nil
   "If non-nil, make \"pushd +n\" pop the nth dir to the stack top.
 This mirrors the optional behavior of tcsh."
-  :type 'boolean
-  :group 'eshell-dirs)
+  :type 'boolean)
 
 (defcustom eshell-pushd-dunique nil
   "If non-nil, make pushd only add unique directories to the stack.
 This mirrors the optional behavior of tcsh."
-  :type 'boolean
-  :group 'eshell-dirs)
+  :type 'boolean)
 
 (defcustom eshell-dirtrack-verbose t
   "If non-nil, show the directory stack following directory change.
 This is effective only if directory tracking is enabled."
-  :type 'boolean
-  :group 'eshell-dirs)
+  :type 'boolean)
 
 (defcustom eshell-last-dir-ring-file-name
   (expand-file-name "lastdir" eshell-directory-name)
   "If non-nil, name of the file to read/write the last-dir-ring.
 See also `eshell-read-last-dir-ring' and `eshell-write-last-dir-ring'.
 If it is nil, the last-dir-ring will not be written to disk."
-  :type 'file
-  :group 'eshell-dirs)
+  :type 'file)
 
 (defcustom eshell-last-dir-ring-size 32
   "If non-nil, the size of the directory history ring.
@@ -164,13 +153,11 @@ directories gets pushed, and its size is unlimited.
 explicitly very much, but every once in a while would like to return to
 a previously visited directory without having to type in the whole
 thing again."
-  :type 'integer
-  :group 'eshell-dirs)
+  :type 'integer)
 
 (defcustom eshell-last-dir-unique t
   "If non-nil, `eshell-last-dir-ring' contains only unique entries."
-  :type 'boolean
-  :group 'eshell-dirs)
+  :type 'boolean)
 
 ;;; Internal Variables:
 
@@ -183,26 +170,28 @@ Thus, this does not include the current directory.")
 
 ;;; Functions:
 
-(defun eshell-dirs-initialize ()
+(defun eshell-dirs-initialize ()    ;Called from `eshell-mode' via intern-soft!
   "Initialize the builtin functions for Eshell."
   (make-local-variable 'eshell-variable-aliases-list)
   (setq eshell-variable-aliases-list
        (append
         eshell-variable-aliases-list
-        '(("-" (lambda (indices)
-                 (if (not indices)
-                     (unless (ring-empty-p eshell-last-dir-ring)
-                       (expand-file-name
-                        (ring-ref eshell-last-dir-ring 0)))
-                   (expand-file-name
-                    (eshell-apply-indices eshell-last-dir-ring indices)))))
-          ("+" "PWD")
-          ("PWD" (lambda (indices)
-                   (expand-file-name (eshell/pwd))) t)
-          ("OLDPWD" (lambda (indices)
+         `(("-" ,(lambda (indices)
+                  (if (not indices)
                       (unless (ring-empty-p eshell-last-dir-ring)
                         (expand-file-name
-                         (ring-ref eshell-last-dir-ring 0)))) t))))
+                         (ring-ref eshell-last-dir-ring 0)))
+                    (expand-file-name
+                     (eshell-apply-indices eshell-last-dir-ring indices)))))
+          ("+" "PWD")
+          ("PWD" ,(lambda (_indices)
+                    (expand-file-name (eshell/pwd)))
+            t)
+          ("OLDPWD" ,(lambda (_indices)
+                       (unless (ring-empty-p eshell-last-dir-ring)
+                         (expand-file-name
+                          (ring-ref eshell-last-dir-ring 0))))
+            t))))
 
   (when eshell-cd-on-directory
     (make-local-variable 'eshell-interpreter-alist)
@@ -213,14 +202,14 @@ Thus, this does not include the current directory.")
                eshell-interpreter-alist)))
 
   (add-hook 'eshell-parse-argument-hook
-           'eshell-parse-user-reference nil t)
+           #'eshell-parse-user-reference nil t)
   (if (eshell-under-windows-p)
       (add-hook 'eshell-parse-argument-hook
-               'eshell-parse-drive-letter nil t))
+               #'eshell-parse-drive-letter nil t))
 
   (when (eshell-using-module 'eshell-cmpl)
     (add-hook 'pcomplete-try-first-hook
-             'eshell-complete-user-reference nil t))
+             #'eshell-complete-user-reference nil t))
 
   (make-local-variable 'eshell-dirstack)
   (make-local-variable 'eshell-last-dir-ring)
@@ -230,9 +219,9 @@ Thus, this does not include the current directory.")
   (unless eshell-last-dir-ring
     (setq eshell-last-dir-ring (make-ring eshell-last-dir-ring-size)))
 
-  (add-hook 'eshell-exit-hook 'eshell-write-last-dir-ring nil t)
+  (add-hook 'eshell-exit-hook #'eshell-write-last-dir-ring nil t)
 
-  (add-hook 'kill-emacs-hook 'eshell-save-some-last-dir))
+  (add-hook 'kill-emacs-hook #'eshell-save-some-last-dir))
 
 (defun eshell-save-some-last-dir ()
   "Save the list-dir-ring for any open Eshell buffers."
@@ -259,7 +248,7 @@ Thus, this does not include the current directory.")
   (if (> (length args) 1)
       (error "%s: command not found" (car args))
     (throw 'eshell-replace-command
-          (eshell-parse-command "cd" (eshell-flatten-list args)))))
+          (eshell-parse-command "cd" (flatten-tree args)))))
 
 (defun eshell-parse-user-reference ()
   "An argument beginning with ~ is a filename to be expanded."
@@ -272,7 +261,7 @@ Thus, this does not include the current directory.")
 (defun eshell-parse-drive-letter ()
   "An argument beginning with X:[^/] is a drive letter reference."
   (when (and (not eshell-current-argument)
-            (looking-at "\\([A-Za-z]:\\)\\([^/\\\\]\\|\\'\\)"))
+            (looking-at "\\([A-Za-z]:\\)\\([^/\\]\\|\\'\\)"))
     (goto-char (match-end 1))
     (let* ((letter (match-string 1))
           (regexp (concat "\\`" letter))
@@ -307,13 +296,11 @@ Thus, this does not include the current directory.")
     (if (and (> len 1)
             (eq (aref path (1- len)) ?/)
             (not (and (eshell-under-windows-p)
-                      (string-match "\\`[A-Za-z]:[\\\\/]\\'" path))))
+                      (string-match "\\`[A-Za-z]:[\\/]\\'" path))))
        (setq path (substring path 0 (1- (length path)))))
-    (if eshell-pwd-convert-function
-       (funcall eshell-pwd-convert-function path)
-      path)))
+    (funcall (or eshell-pwd-convert-function #'identity) path)))
 
-(defun eshell-expand-multiple-dots (path)
+(defun eshell-expand-multiple-dots (filename)
   ;; FIXME: This advice recommendation is rather odd: it's somewhat
   ;; dangerous and it claims not to work with minibuffer-completion, which
   ;; makes it much less interesting.
@@ -326,16 +313,17 @@ in the minibuffer:
     (advice-add 'expand-file-name :around #'my-expand-multiple-dots)
     (defun my-expand-multiple-dots (orig-fun filename &rest args)
       (apply orig-fun (eshell-expand-multiple-dots filename) args))"
-  (while (string-match "\\(?:^\\|/\\)\\.\\.\\(\\.+\\)\\(?:$\\|/\\)" path)
-    (let* ((extra-dots (match-string 1 path))
+  (while (string-match "\\(?:\\`\\|/\\)\\.\\.\\(\\.+\\)\\(?:\\'\\|/\\)"
+                       filename)
+    (let* ((extra-dots (match-string 1 filename))
           (len (length extra-dots))
           replace-text)
       (while (> len 0)
        (setq replace-text (concat replace-text "/..")
              len (1- len)))
-      (setq path
-           (replace-match replace-text t t path 1))))
-  path)
+      (setq filename
+           (replace-match replace-text t t filename 1))))
+  filename)
 
 (defun eshell-find-previous-directory (regexp)
   "Find the most recent last-dir matching REGEXP."
@@ -353,7 +341,7 @@ in the minibuffer:
 
 (defun eshell/cd (&rest args)           ; all but first ignored
   "Alias to extend the behavior of `cd'."
-  (setq args (eshell-flatten-list args))
+  (setq args (flatten-tree args))
   (let ((path (car args))
        (subpath (car (cdr args)))
        (case-fold-search (eshell-under-windows-p))
diff --git a/lisp/eshell/em-glob.el b/lisp/eshell/em-glob.el
index ca7b1b8..99c52ea 100644
--- a/lisp/eshell/em-glob.el
+++ b/lisp/eshell/em-glob.el
@@ -1,6 +1,6 @@
 ;;; em-glob.el --- extended file name globbing  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -125,7 +125,7 @@ This option slows down recursive glob processing by quite a 
bit."
 
 ;;; Functions:
 
-(defun eshell-glob-initialize ()
+(defun eshell-glob-initialize ()    ;Called from `eshell-mode' via intern-soft!
   "Initialize the extended globbing code."
   ;; it's important that `eshell-glob-chars-list' come first
   (when (boundp 'eshell-special-chars-outside-quoting)
diff --git a/lisp/eshell/em-hist.el b/lisp/eshell/em-hist.el
index 1b240c0..adb0280 100644
--- a/lisp/eshell/em-hist.el
+++ b/lisp/eshell/em-hist.el
@@ -1,6 +1,6 @@
 ;;; em-hist.el --- history list management  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -59,6 +59,7 @@
 
 (require 'ring)
 (require 'esh-opt)
+(require 'esh-mode)
 (require 'em-pred)
 (require 'eshell)
 
@@ -152,7 +153,7 @@ element, regardless of any text on the command line.  In 
that case,
   :group 'eshell-hist)
 
 (defcustom eshell-hist-word-designator
-  "^:?\\([0-9]+\\|[$^%*]\\)?\\(\\*\\|-[0-9]*\\|[$^%*]\\)?"
+  "^:?\\([0-9]+\\|[$^%*]\\)?\\(-[0-9]*\\|[$^%*]\\)?"
   "The regexp used to identify history word designators."
   :type 'regexp
   :group 'eshell-hist)
@@ -192,7 +193,6 @@ element, regardless of any text on the command line.  In 
that case,
 (defvar eshell-isearch-map
   (let ((map (copy-keymap isearch-mode-map)))
     (define-key map [(control ?m)] 'eshell-isearch-return)
-    (define-key map [return] 'eshell-isearch-return)
     (define-key map [(control ?r)] 'eshell-isearch-repeat-backward)
     (define-key map [(control ?s)] 'eshell-isearch-repeat-forward)
     (define-key map [(control ?g)] 'eshell-isearch-abort)
@@ -216,11 +216,11 @@ Returns non-nil if INPUT is blank."
 Returns nil if INPUT is prepended by blank space, otherwise non-nil."
   (not (string-match-p "\\`\\s-+" input)))
 
-(defun eshell-hist-initialize ()
+(defun eshell-hist-initialize ()    ;Called from `eshell-mode' via intern-soft!
   "Initialize the history management code for one Eshell buffer."
   (when (eshell-using-module 'eshell-cmpl)
     (add-hook 'pcomplete-try-first-hook
-             'eshell-complete-history-reference nil t))
+             #'eshell-complete-history-reference nil t))
 
   (if (and (eshell-using-module 'eshell-rebind)
           (not eshell-non-interactive-p))
@@ -235,11 +235,13 @@ Returns nil if INPUT is prepended by blank space, 
otherwise non-nil."
                   (lambda ()
                     (if (>= (point) eshell-last-output-end)
                         (setq overriding-terminal-local-map
-                              eshell-isearch-map)))) nil t)
+                              eshell-isearch-map))))
+                  nil t)
        (add-hook 'isearch-mode-end-hook
                  (function
                   (lambda ()
-                    (setq overriding-terminal-local-map nil))) nil t))
+                    (setq overriding-terminal-local-map nil)))
+                  nil t))
     (define-key eshell-mode-map [up] 
'eshell-previous-matching-input-from-input)
     (define-key eshell-mode-map [down] 'eshell-next-matching-input-from-input)
     (define-key eshell-mode-map [(control up)] 'eshell-previous-input)
@@ -288,17 +290,17 @@ Returns nil if INPUT is prepended by blank space, 
otherwise non-nil."
     (if eshell-history-file-name
        (eshell-read-history nil t))
 
-    (add-hook 'eshell-exit-hook 'eshell-write-history nil t))
+    (add-hook 'eshell-exit-hook #'eshell-write-history nil t))
 
   (unless eshell-history-ring
     (setq eshell-history-ring (make-ring eshell-history-size)))
 
-  (add-hook 'eshell-exit-hook 'eshell-write-history nil t)
+  (add-hook 'eshell-exit-hook #'eshell-write-history nil t)
 
-  (add-hook 'kill-emacs-hook 'eshell-save-some-history)
+  (add-hook 'kill-emacs-hook #'eshell-save-some-history)
 
   (make-local-variable 'eshell-input-filter-functions)
-  (add-hook 'eshell-input-filter-functions 'eshell-add-to-history nil t)
+  (add-hook 'eshell-input-filter-functions #'eshell-add-to-history nil t)
 
   (define-key eshell-command-map [(control ?l)] 'eshell-list-history)
   (define-key eshell-command-map [(control ?x)] 'eshell-get-next-from-history))
@@ -754,7 +756,7 @@ matched."
        (setq nth (eshell-hist-word-reference nth)))
       (unless (numberp mth)
        (setq mth (eshell-hist-word-reference mth)))
-      (cons (mapconcat 'identity (eshell-sublist textargs nth mth) " ")
+      (cons (mapconcat #'identity (eshell-sublist textargs nth mth) " ")
            end))))
 
 (defun eshell-hist-parse-modifier (hist reference)
diff --git a/lisp/eshell/em-ls.el b/lisp/eshell/em-ls.el
index 1e09ed6..89969d3 100644
--- a/lisp/eshell/em-ls.el
+++ b/lisp/eshell/em-ls.el
@@ -1,6 +1,6 @@
 ;;; em-ls.el --- implementation of ls in Lisp  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -29,7 +29,8 @@
 (require 'cl-lib)
 (require 'esh-util)
 (require 'esh-opt)
-(eval-when-compile (require 'eshell))
+(require 'esh-proc)
+(require 'esh-cmd)
 
 ;;;###autoload
 (progn
diff --git a/lisp/eshell/em-pred.el b/lisp/eshell/em-pred.el
index c3b942d..9bc856a 100644
--- a/lisp/eshell/em-pred.el
+++ b/lisp/eshell/em-pred.el
@@ -1,6 +1,6 @@
 ;;; em-pred.el --- argument predicates and modifiers (ala zsh)  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -46,9 +46,7 @@
 
 ;;; Code:
 
-(require 'esh-util)
-(require 'esh-arg)
-(eval-when-compile (require 'eshell))
+(require 'esh-mode)
 
 ;;;###autoload
 (progn
@@ -247,10 +245,10 @@ EXAMPLES:
     (lambda ()
       (insert eshell-modifier-help-string)))))
 
-(defun eshell-pred-initialize ()
+(defun eshell-pred-initialize ()    ;Called from `eshell-mode' via intern-soft!
   "Initialize the predicate/modifier code."
   (add-hook 'eshell-parse-argument-hook
-           'eshell-parse-arg-modifier t t)
+           #'eshell-parse-arg-modifier t t)
   (define-key eshell-command-map [(meta ?q)] 'eshell-display-predicate-help)
   (define-key eshell-command-map [(meta ?m)] 'eshell-display-modifier-help))
 
@@ -421,9 +419,8 @@ resultant list of strings."
       (forward-char))
     (if (looking-at "[0-9]+")
        (progn
-         (setq when (- (float-time)
-                       (* (string-to-number (match-string 0))
-                          quantum)))
+         (setq when (time-since (* (string-to-number (match-string 0))
+                                   quantum)))
          (goto-char (match-end 0)))
       (setq open (char-after))
       (if (setq close (memq open '(?\( ?\[ ?\< ?\{)))
@@ -438,17 +435,17 @@ resultant list of strings."
             (attrs (file-attributes file)))
        (unless attrs
          (error "Cannot stat file `%s'" file))
-       (setq when (float-time (nth attr-index attrs))))
+       (setq when (nth attr-index attrs)))
       (goto-char (1+ end)))
     `(lambda (file)
        (let ((attrs (file-attributes file)))
         (if attrs
             (,(if (eq qual ?-)
-                  '<
+                  'time-less-p
                 (if (eq qual ?+)
-                    '>
-                  '=)) ,when (float-time
-                              (nth ,attr-index attrs))))))))
+                    '(lambda (a b) (time-less-p b a))
+                  'time-equal-p))
+             ,when (nth ,attr-index attrs)))))))
 
 (defun eshell-pred-file-type (type)
   "Return a test which tests that the file is of a certain TYPE.
diff --git a/lisp/eshell/em-prompt.el b/lisp/eshell/em-prompt.el
index e61b0eb..adc68b6 100644
--- a/lisp/eshell/em-prompt.el
+++ b/lisp/eshell/em-prompt.el
@@ -1,6 +1,6 @@
 ;;; em-prompt.el --- command prompts  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -99,7 +99,7 @@ arriving, or after."
 
 ;;; Functions:
 
-(defun eshell-prompt-initialize ()
+(defun eshell-prompt-initialize ()  ;Called from `eshell-mode' via intern-soft!
   "Initialize the prompting code."
   (unless eshell-non-interactive-p
     (add-hook 'eshell-post-command-hook 'eshell-emit-prompt nil t)
diff --git a/lisp/eshell/em-rebind.el b/lisp/eshell/em-rebind.el
index 064dcc7..a817edb 100644
--- a/lisp/eshell/em-rebind.el
+++ b/lisp/eshell/em-rebind.el
@@ -1,6 +1,6 @@
 ;;; em-rebind.el --- rebind keys when point is at current input  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -145,7 +145,7 @@ This is default behavior of shells like bash."
 
 ;;; Functions:
 
-(defun eshell-rebind-initialize ()
+(defun eshell-rebind-initialize ()  ;Called from `eshell-mode' via intern-soft!
   "Initialize the inputting code."
   (unless eshell-non-interactive-p
     (add-hook 'eshell-mode-hook 'eshell-setup-input-keymap nil t)
diff --git a/lisp/eshell/em-script.el b/lisp/eshell/em-script.el
index a5d8e96..4a3b84e 100644
--- a/lisp/eshell/em-script.el
+++ b/lisp/eshell/em-script.el
@@ -1,6 +1,6 @@
 ;;; em-script.el --- Eshell script files  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -23,8 +23,7 @@
 
 ;;; Code:
 
-(require 'eshell)
-(require 'esh-opt)
+(require 'esh-mode)
 
 ;;;###autoload
 (progn
@@ -57,7 +56,7 @@ This includes when running `eshell-command'."
 
 ;;; Functions:
 
-(defun eshell-script-initialize ()
+(defun eshell-script-initialize ()  ;Called from `eshell-mode' via intern-soft!
   "Initialize the script parsing code."
   (make-local-variable 'eshell-interpreter-alist)
   (setq eshell-interpreter-alist
@@ -73,13 +72,14 @@ This includes when running `eshell-command'."
   ;; to ruin it for other modules
   (let (eshell-inside-quote-regexp
        eshell-outside-quote-regexp)
-    (and (not eshell-non-interactive-p)
+    (and (not (bound-and-true-p eshell-non-interactive-p))
         eshell-login-script
         (file-readable-p eshell-login-script)
         (eshell-do-eval
          (list 'eshell-commands
                (catch 'eshell-replace-command
-                 (eshell-source-file eshell-login-script))) t))
+                 (eshell-source-file eshell-login-script)))
+          t))
     (and eshell-rc-script
         (file-readable-p eshell-rc-script)
         (eshell-do-eval
diff --git a/lisp/eshell/em-smart.el b/lisp/eshell/em-smart.el
index 53bbdfe..c7965b4 100644
--- a/lisp/eshell/em-smart.el
+++ b/lisp/eshell/em-smart.el
@@ -1,6 +1,6 @@
 ;;; em-smart.el --- smart display of output  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -166,7 +166,7 @@ The options are `begin', `after' or `end'."
 
 ;;; Functions:
 
-(defun eshell-smart-initialize ()
+(defun eshell-smart-initialize ()   ;Called from `eshell-mode' via intern-soft!
   "Setup Eshell smart display."
   (unless eshell-non-interactive-p
     ;; override a few variables, since they would interfere with the
diff --git a/lisp/eshell/em-term.el b/lisp/eshell/em-term.el
index ddde47f..dea9040 100644
--- a/lisp/eshell/em-term.el
+++ b/lisp/eshell/em-term.el
@@ -1,6 +1,6 @@
 ;;; em-term.el --- running visual commands  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -147,7 +147,7 @@ behavior for short-lived processes, see bug#18108."
 
 ;;; Functions:
 
-(defun eshell-term-initialize ()
+(defun eshell-term-initialize ()    ;Called from `eshell-mode' via intern-soft!
   "Initialize the `term' interface code."
   (make-local-variable 'eshell-interpreter-alist)
   (setq eshell-interpreter-alist
@@ -175,7 +175,7 @@ allowed."
   (let* (eshell-interpreter-alist
         (interp (eshell-find-interpreter (car args) (cdr args)))
         (program (car interp))
-        (args (eshell-flatten-list
+        (args (flatten-tree
                (eshell-stringify-list (append (cdr interp)
                                               (cdr args)))))
         (term-buf
@@ -191,7 +191,7 @@ allowed."
       (term-exec term-buf program program nil args)
       (let ((proc (get-buffer-process term-buf)))
        (if (and proc (eq 'run (process-status proc)))
-           (set-process-sentinel proc 'eshell-term-sentinel)
+           (set-process-sentinel proc #'eshell-term-sentinel)
          (error "Failed to invoke visual command")))
       (term-char-mode)
       (if eshell-escape-control-x
diff --git a/lisp/eshell/em-tramp.el b/lisp/eshell/em-tramp.el
index 9475f4e..c791636 100644
--- a/lisp/eshell/em-tramp.el
+++ b/lisp/eshell/em-tramp.el
@@ -1,6 +1,6 @@
 ;;; em-tramp.el --- Eshell features that require TRAMP  -*- lexical-binding:t 
-*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Aidan Gauland <address@hidden>
 
@@ -46,7 +46,7 @@
    :tag "TRAMP Eshell features"
    :group 'eshell-module))
 
-(defun eshell-tramp-initialize ()
+(defun eshell-tramp-initialize ()   ;Called from `eshell-mode' via intern-soft!
   "Initialize the TRAMP-using commands code."
   (when (eshell-using-module 'eshell-cmpl)
     (add-hook 'pcomplete-try-first-hook
@@ -62,7 +62,7 @@
   "Alias \"su\" to call TRAMP.
 
 Uses the system su through TRAMP's su method."
-  (setq args (eshell-stringify-list (eshell-flatten-list args)))
+  (setq args (eshell-stringify-list (flatten-tree args)))
   (let ((orig-args (copy-tree args)))
     (eshell-eval-using-options
      "su" args
@@ -100,7 +100,7 @@ Become another USER during a login session.")
   "Alias \"sudo\" to call Tramp.
 
 Uses the system sudo through TRAMP's sudo method."
-  (setq args (eshell-stringify-list (eshell-flatten-list args)))
+  (setq args (eshell-stringify-list (flatten-tree args)))
   (let ((orig-args (copy-tree args)))
     (eshell-eval-using-options
      "sudo" args
diff --git a/lisp/eshell/em-unix.el b/lisp/eshell/em-unix.el
index 3aecebc..2522181 100644
--- a/lisp/eshell/em-unix.el
+++ b/lisp/eshell/em-unix.el
@@ -1,6 +1,6 @@
 ;;; em-unix.el --- UNIX command aliases  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -35,8 +35,7 @@
 
 ;;; Code:
 
-(require 'eshell)
-(require 'esh-opt)
+(require 'esh-mode)
 (require 'pcomplete)
 
 ;;;###autoload
@@ -140,7 +139,7 @@ Otherwise, Emacs will attempt to use rsh to invoke du on 
the remote machine."
 
 ;;; Functions:
 
-(defun eshell-unix-initialize ()
+(defun eshell-unix-initialize ()    ;Called from `eshell-mode' via intern-soft!
   "Initialize the UNIX support/emulation code."
   (when (eshell-using-module 'eshell-cmpl)
     (add-hook 'pcomplete-try-first-hook
@@ -231,7 +230,7 @@ Otherwise, Emacs will attempt to use rsh to invoke du on 
the remote machine."
 This is implemented to call either `delete-file', `kill-buffer',
 `kill-process', or `unintern', depending on the nature of the
 argument."
-  (setq args (eshell-flatten-list args))
+  (setq args (flatten-tree args))
   (eshell-eval-using-options
    "rm" args
    '((?h "help" nil nil "show this usage screen")
@@ -481,7 +480,7 @@ Remove the DIRECTORY(ies), if they are empty.")
         (error "%s: missing destination file or directory" ,command))
      (if (= len 1)
         (nconc args '(".")))
-     (setq args (eshell-stringify-list (eshell-flatten-list args)))
+     (setq args (eshell-stringify-list (flatten-tree args)))
      (if (and ,(not (equal command "ln"))
              (string-match eshell-tar-regexp (car (last args)))
              (or (> (length args) 2)
@@ -606,7 +605,7 @@ with `--symbolic'.  When creating hard links, each TARGET 
must exist.")
   "Implementation of cat in Lisp.
 If in a pipeline, or the file is not a regular file, directory or
 symlink, then revert to the system's definition of cat."
-  (setq args (eshell-stringify-list (eshell-flatten-list args)))
+  (setq args (eshell-stringify-list (flatten-tree args)))
   (if (or eshell-in-pipeline-p
          (catch 'special
            (dolist (arg args)
@@ -670,7 +669,7 @@ Fallback to standard make when called synchronously."
        (compile (concat "make " (eshell-flatten-and-stringify args))))
     (throw 'eshell-replace-command
           (eshell-parse-command "*make" (eshell-stringify-list
-                                         (eshell-flatten-list args))))))
+                                         (flatten-tree args))))))
 
 (put 'eshell/make 'eshell-no-numeric-conversions t)
 
@@ -705,7 +704,7 @@ available..."
          (erase-buffer)
          (occur-mode)
          (let ((files (eshell-stringify-list
-                       (eshell-flatten-list (cdr args))))
+                       (flatten-tree (cdr args))))
                (inhibit-redisplay t)
                string)
            (when (car args)
@@ -750,11 +749,11 @@ external command."
        (throw 'eshell-replace-command
               (eshell-parse-command (concat "*" command)
                                     (eshell-stringify-list
-                                     (eshell-flatten-list args))))
+                                     (flatten-tree args))))
       (let* ((args (mapconcat 'identity
                              (mapcar 'shell-quote-argument
                                      (eshell-stringify-list
-                                      (eshell-flatten-list args)))
+                                      (flatten-tree args)))
                              " "))
             (cmd (progn
                    (set-text-properties 0 (length args)
@@ -876,7 +875,7 @@ external command."
 (defun eshell/du (&rest args)
   "Implementation of \"du\" in Lisp, passing ARGS."
   (setq args (if args
-                (eshell-stringify-list (eshell-flatten-list args))
+                (eshell-stringify-list (flatten-tree args))
               '(".")))
   (let ((ext-du (eshell-search-path "du")))
     (if (and ext-du
@@ -943,7 +942,8 @@ Summarize disk usage of each FILE, recursively for 
directories.")
 (defvar eshell-time-start nil)
 
 (defun eshell-show-elapsed-time ()
-  (let ((elapsed (format "%.3f secs\n" (- (float-time) eshell-time-start))))
+  (let ((elapsed (format "%.3f secs\n"
+                        (float-time (time-since eshell-time-start)))))
     (set-text-properties 0 (length elapsed) '(face bold) elapsed)
     (eshell-interactive-print elapsed))
   (remove-hook 'eshell-post-command-hook 'eshell-show-elapsed-time t))
@@ -976,7 +976,7 @@ Show wall-clock time elapsed during execution of COMMAND.")
            (eshell-parse-command (car time-args)
 ;;; https://lists.gnu.org/r/bug-gnu-emacs/2007-08/msg00205.html
                                  (eshell-stringify-list
-                                  (eshell-flatten-list (cdr time-args))))))))
+                                  (flatten-tree (cdr time-args))))))))
 
 (defun eshell/whoami (&rest _args)
   "Make \"whoami\" Tramp aware."
@@ -1000,7 +1000,7 @@ Show wall-clock time elapsed during execution of 
COMMAND.")
 
 (defun eshell/diff (&rest args)
   "Alias \"diff\" to call Emacs `diff' function."
-  (let ((orig-args (eshell-stringify-list (eshell-flatten-list args))))
+  (let ((orig-args (eshell-stringify-list (flatten-tree args))))
     (if (or eshell-plain-diff-behavior
            (not (and (eshell-interactive-output-p)
                      (not eshell-in-pipeline-p)
@@ -1056,7 +1056,7 @@ Show wall-clock time elapsed during execution of 
COMMAND.")
               (string-match "^-" (car args))))
       (throw 'eshell-replace-command
             (eshell-parse-command "*locate" (eshell-stringify-list
-                                             (eshell-flatten-list args))))
+                                             (flatten-tree args))))
     (save-selected-window
       (let ((locate-history-list (list (car args))))
        (locate-with-filter (car args) (cadr args))))))
diff --git a/lisp/eshell/em-xtra.el b/lisp/eshell/em-xtra.el
index cc84d19..602e841 100644
--- a/lisp/eshell/em-xtra.el
+++ b/lisp/eshell/em-xtra.el
@@ -1,6 +1,6 @@
 ;;; em-xtra.el --- extra alias functions  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -51,7 +51,7 @@ naturally accessible within Emacs."
   "Implementation of expr, using the calc package."
   (if (not (fboundp 'calc-eval))
       (throw 'eshell-replace-command
-            (eshell-parse-command "*expr" (eshell-flatten-list args)))
+            (eshell-parse-command "*expr" (flatten-tree args)))
     ;; to fool the byte-compiler...
     (let ((func 'calc-eval))
       (funcall func (eshell-flatten-and-stringify args)))))
diff --git a/lisp/eshell/esh-arg.el b/lisp/eshell/esh-arg.el
index 6709588..026edc5 100644
--- a/lisp/eshell/esh-arg.el
+++ b/lisp/eshell/esh-arg.el
@@ -1,6 +1,6 @@
 ;;; esh-arg.el --- argument processing  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -25,9 +25,9 @@
 ;; hook `eshell-parse-argument-hook'.  For a good example of this, see
 ;; `eshell-parse-drive-letter', defined in eshell-dirs.el.
 
-(provide 'esh-arg)
+;;; Code:
 
-(require 'esh-mode)
+(require 'esh-util)
 
 (defgroup eshell-arg nil
   "Argument parsing involves transforming the arguments passed on the
@@ -36,6 +36,48 @@ yield the values intended."
   :tag "Argument parsing"
   :group 'eshell)
 
+;;; Internal Variables:
+
+(defvar eshell-current-argument nil)
+(defvar eshell-current-modifiers nil)
+(defvar eshell-arg-listified nil)
+(defvar eshell-nested-argument nil)
+(defvar eshell-current-quoted nil)
+(defvar eshell-inside-quote-regexp nil)
+(defvar eshell-outside-quote-regexp nil)
+
+;;; User Variables:
+
+(defcustom eshell-arg-load-hook nil
+  "A hook that gets run when `eshell-arg' is loaded."
+  :version "24.1"                     ; removed eshell-arg-initialize
+  :type 'hook
+  :group 'eshell-arg)
+
+(defcustom eshell-delimiter-argument-list '(?\; ?& ?\| ?\> ?\s ?\t ?\n)
+  "List of characters to recognize as argument separators."
+  :type '(repeat character)
+  :group 'eshell-arg)
+
+(defcustom eshell-special-chars-inside-quoting '(?\\ ?\")
+  "Characters which are still special inside double quotes."
+  :type '(repeat character)
+  :group 'eshell-arg)
+
+(defcustom eshell-special-chars-outside-quoting
+  (append eshell-delimiter-argument-list '(?# ?! ?\\ ?\" ?\'))
+  "Characters that require escaping outside of double quotes.
+Without escaping them, they will introduce a change in the argument."
+  :type '(repeat character)
+  :group 'eshell-arg)
+
+(defsubst eshell-arg-delimiter (&optional pos)
+  "Return non-nil if POS is an argument delimiter.
+If POS is nil, the location of point is checked."
+  (let ((pos (or pos (point))))
+    (or (= pos (point-max))
+       (memq (char-after pos) eshell-delimiter-argument-list))))
+
 (defcustom eshell-parse-argument-hook
   (list
    ;; a term such as #<buffer NAME>, or #<process NAME> is a buffer
@@ -113,47 +155,13 @@ treated as a literal character."
   :type 'hook
   :group 'eshell-arg)
 
-;;; Code:
-
-;;; User Variables:
-
-(defcustom eshell-arg-load-hook nil
-  "A hook that gets run when `eshell-arg' is loaded."
-  :version "24.1"                     ; removed eshell-arg-initialize
-  :type 'hook
-  :group 'eshell-arg)
-
-(defcustom eshell-delimiter-argument-list '(?\; ?& ?\| ?\> ?\s ?\t ?\n)
-  "List of characters to recognize as argument separators."
-  :type '(repeat character)
-  :group 'eshell-arg)
-
-(defcustom eshell-special-chars-inside-quoting '(?\\ ?\")
-  "Characters which are still special inside double quotes."
-  :type '(repeat character)
-  :group 'eshell-arg)
-
-(defcustom eshell-special-chars-outside-quoting
-  (append eshell-delimiter-argument-list '(?# ?! ?\\ ?\" ?\'))
-  "Characters that require escaping outside of double quotes.
-Without escaping them, they will introduce a change in the argument."
-  :type '(repeat character)
-  :group 'eshell-arg)
-
-;;; Internal Variables:
-
-(defvar eshell-current-argument nil)
-(defvar eshell-current-modifiers nil)
-(defvar eshell-arg-listified nil)
-(defvar eshell-nested-argument nil)
-(defvar eshell-current-quoted nil)
-(defvar eshell-inside-quote-regexp nil)
-(defvar eshell-outside-quote-regexp nil)
-
 ;;; Functions:
 
-(defun eshell-arg-initialize ()
+(defun eshell-arg-initialize ()     ;Called from `eshell-mode' via intern-soft!
   "Initialize the argument parsing code."
+  ;; This is supposedly run after enabling esh-mode, when eshell-mode-map
+  ;; already exists.
+  (defvar eshell-command-map)
   (define-key eshell-command-map [(meta ?b)] 'eshell-insert-buffer-name)
   (set (make-local-variable 'eshell-inside-quote-regexp) nil)
   (set (make-local-variable 'eshell-outside-quote-regexp) nil))
@@ -195,13 +203,6 @@ Without escaping them, they will introduce a change in the 
argument."
       (setq eshell-current-argument argument))
   (throw 'eshell-arg-done t))
 
-(defsubst eshell-arg-delimiter (&optional pos)
-  "Return non-nil if POS is an argument delimiter.
-If POS is nil, the location of point is checked."
-  (let ((pos (or pos (point))))
-    (or (= pos (point-max))
-       (memq (char-after pos) eshell-delimiter-argument-list))))
-
 (defun eshell-quote-argument (string)
   "Return STRING with magic characters quoted.
 Magic characters are those in `eshell-special-chars-outside-quoting'."
@@ -405,4 +406,5 @@ If the form has no `type', the syntax is parsed as if 
`type' were
                   (char-to-string (char-after)))))
         (goto-char end)))))))
 
+(provide 'esh-arg)
 ;;; esh-arg.el ends here
diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el
index 8daaa0e..6e03bda 100644
--- a/lisp/eshell/esh-cmd.el
+++ b/lisp/eshell/esh-cmd.el
@@ -1,6 +1,6 @@
 ;;; esh-cmd.el --- command invocation  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -105,6 +105,8 @@
   (require 'eldoc))
 (require 'esh-arg)
 (require 'esh-proc)
+(require 'esh-module)
+(require 'esh-io)
 (require 'esh-ext)
 
 (eval-when-compile
@@ -122,24 +124,20 @@ however."
 
 (defcustom eshell-prefer-lisp-functions nil
   "If non-nil, prefer Lisp functions to external commands."
-  :type 'boolean
-  :group 'eshell-cmd)
+  :type 'boolean)
 
 (defcustom eshell-lisp-regexp "\\([(`]\\|#'\\)"
   "A regexp which, if matched at beginning of an argument, means Lisp.
 Such arguments will be passed to `read', and then evaluated."
-  :type 'regexp
-  :group 'eshell-cmd)
+  :type 'regexp)
 
 (defcustom eshell-pre-command-hook nil
   "A hook run before each interactive command is invoked."
-  :type 'hook
-  :group 'eshell-cmd)
+  :type 'hook)
 
 (defcustom eshell-post-command-hook nil
   "A hook run after each interactive command is invoked."
-  :type 'hook
-  :group 'eshell-cmd)
+  :type 'hook)
 
 (defcustom eshell-prepare-command-hook nil
   "A set of functions called to prepare a named command.
@@ -149,8 +147,7 @@ the value of these symbols if necessary.
 
 To prevent a command from executing at all, set
 `eshell-last-command-name' to nil."
-  :type 'hook
-  :group 'eshell-cmd)
+  :type 'hook)
 
 (defcustom eshell-named-command-hook nil
   "A set of functions called before a named command is invoked.
@@ -165,7 +162,7 @@ In order to substitute an alternate command form for 
execution, the
 hook function should throw it using the tag `eshell-replace-command'.
 For example:
 
-  (add-hook \\='eshell-named-command-hook \\='subst-with-cd)
+  (add-hook \\='eshell-named-command-hook #\\='subst-with-cd)
   (defun subst-with-cd (command args)
     (throw \\='eshell-replace-command
           (eshell-parse-command \"cd\" args)))
@@ -173,8 +170,7 @@ For example:
 Although useless, the above code will cause any non-glob, non-Lisp
 command (i.e., `ls' as opposed to `*ls' or `(ls)') to be replaced by a
 call to `cd' using the arguments that were passed to the function."
-  :type 'hook
-  :group 'eshell-cmd)
+  :type 'hook)
 
 (defcustom eshell-pre-rewrite-command-hook
   '(eshell-no-command-conversion
@@ -182,8 +178,7 @@ call to `cd' using the arguments that were passed to the 
function."
   "A hook run before command rewriting begins.
 The terms of the command to be rewritten is passed as arguments, and
 may be modified in place.  Any return value is ignored."
-  :type 'hook
-  :group 'eshell-cmd)
+  :type 'hook)
 
 (defcustom eshell-rewrite-command-hook
   '(eshell-rewrite-for-command
@@ -202,8 +197,7 @@ so by adding a function to this hook.  The first function 
to return a
 substitute command form is the one used.  Each function is passed the
 command's full argument list, which is a list of sexps (typically
 forms or strings)."
-  :type 'hook
-  :group 'eshell-cmd)
+  :type 'hook)
 
 (defvar eshell-post-rewrite-command-function #'identity
   "Function run after command rewriting is finished.
@@ -228,16 +222,14 @@ If an entry is a function, it will be called with the 
name, and should
 return non-nil if the command is complex."
   :type '(repeat :tag "Commands"
                 (choice (string :tag "Name")
-                        (function :tag "Predicate")))
-  :group 'eshell-cmd)
+                        (function :tag "Predicate"))))
 
 ;;; User Variables:
 
 (defcustom eshell-cmd-load-hook nil
   "A hook that gets run when `eshell-cmd' is loaded."
   :version "24.1"                     ; removed eshell-cmd-initialize
-  :type 'hook
-  :group 'eshell-cmd)
+  :type 'hook)
 
 (defcustom eshell-debug-command nil
   "If non-nil, enable Eshell debugging code.
@@ -247,9 +239,8 @@ you must re-load `esh-cmd.el'."
   :initialize 'custom-initialize-default
   :set (lambda (symbol value)
         (set symbol value)
-        (load-library "esh-cmd"))
-  :type 'boolean
-  :group 'eshell-cmd)
+        (load "esh-cmd"))
+  :type 'boolean)
 
 (defcustom eshell-deferrable-commands
   '(eshell-named-command
@@ -259,16 +250,14 @@ you must re-load `esh-cmd.el'."
 If they return a process object, execution of the calling Eshell
 command will wait for completion (in the background) before finishing
 the command."
-  :type '(repeat function)
-  :group 'eshell-cmd)
+  :type '(repeat function))
 
 (defcustom eshell-subcommand-bindings
   '((eshell-in-subcommand-p t)
     (default-directory default-directory)
     (process-environment (eshell-copy-environment)))
   "A list of `let' bindings for subcommand environments."
-  :type 'sexp
-  :group 'eshell-cmd)
+  :type 'sexp)
 
 (put 'risky-local-variable 'eshell-subcommand-bindings t)
 
@@ -298,7 +287,7 @@ otherwise t.")
   "Return currently running command process, if non-Lisp."
   eshell-last-async-proc)
 
-(defun eshell-cmd-initialize ()
+(defun eshell-cmd-initialize ()     ;Called from `eshell-mode' via intern-soft!
   "Initialize the Eshell command processing module."
   (set (make-local-variable 'eshell-current-command) nil)
   (set (make-local-variable 'eshell-command-name) nil)
@@ -307,7 +296,7 @@ otherwise t.")
   (set (make-local-variable 'eshell-last-command-name) nil)
   (set (make-local-variable 'eshell-last-async-proc) nil)
 
-  (add-hook 'eshell-kill-hook 'eshell-resume-command nil t)
+  (add-hook 'eshell-kill-hook #'eshell-resume-command nil t)
 
   ;; make sure that if a command is over, and no process is being
   ;; waited for, that `eshell-current-command' is set to nil.  This
@@ -317,16 +306,17 @@ otherwise t.")
            (function
             (lambda ()
               (setq eshell-current-command nil
-                    eshell-last-async-proc nil))) nil t)
+                    eshell-last-async-proc nil)))
+            nil t)
 
   (add-hook 'eshell-parse-argument-hook
-           'eshell-parse-subcommand-argument nil t)
+           #'eshell-parse-subcommand-argument nil t)
   (add-hook 'eshell-parse-argument-hook
-           'eshell-parse-lisp-argument nil t)
+           #'eshell-parse-lisp-argument nil t)
 
   (when (eshell-using-module 'eshell-cmpl)
     (add-hook 'pcomplete-try-first-hook
-             'eshell-complete-lisp-symbols nil t)))
+             #'eshell-complete-lisp-symbols nil t)))
 
 (defun eshell-complete-lisp-symbols ()
   "If there is a user reference, complete it."
@@ -724,6 +714,8 @@ ensconced in a list."
         eshell-current-subjob-p)
      ,object))
 
+(defvar eshell-this-command-hook nil)
+
 (defmacro eshell-trap-errors (object)
   "Trap any errors that occur, so they are not entirely fatal.
 Also, the variable `eshell-this-command-hook' is available for the
@@ -736,9 +728,9 @@ this grossness will be made to disappear by using 
`call/cc'..."
      (eshell-condition-case err
         (prog1
             ,object
-          (run-hooks 'eshell-this-command-hook))
+          (mapc #'funcall eshell-this-command-hook))
        (error
-       (run-hooks 'eshell-this-command-hook)
+       (mapc #'funcall eshell-this-command-hook)
        (eshell-errorn (error-message-string err))
        (eshell-close-handles 1)))))
 
@@ -1059,16 +1051,8 @@ be finished later after the completion of an 
asynchronous subprocess."
        ((eq (car form) 'setcdr)
        (setcar (cdr args) (eshell-do-eval (cadr args) synchronous-p))
        (eval form))
-       ((memq (car form) '(let catch condition-case unwind-protect))
-       ;; `let', `condition-case' and `unwind-protect' have to be
-       ;; handled specially, because we only want to call
-       ;; `eshell-do-eval' on their first form.
-       ;;
-       ;; NOTE: This requires obedience by all forms which this
-       ;; function might encounter, that they do not contain
-       ;; other special forms.
-       (if (and (eq (car form) 'let)
-                (not (eq (car (cadr args)) 'eshell-do-eval)))
+       ((eq (car form) 'let)
+       (if (not (eq (car (cadr args)) 'eshell-do-eval))
            (eshell-manipulate "evaluating let args"
              (dolist (letarg (car args))
                (if (and (listp letarg)
@@ -1076,6 +1060,21 @@ be finished later after the completion of an 
asynchronous subprocess."
                    (setcdr letarg
                            (list (eshell-do-eval
                                   (cadr letarg) synchronous-p)))))))
+        (cl-progv
+            (mapcar (lambda (binding) (if (consp binding) (car binding) 
binding))
+                    (car args))
+            ;; These expressions should all be constants now.
+            (mapcar (lambda (binding) (if (consp binding) (eval (cadr 
binding))))
+                    (car args))
+         (eshell-do-eval (macroexp-progn (cdr args)) synchronous-p)))
+       ((memq (car form) '(catch condition-case unwind-protect))
+       ;; `condition-case' and `unwind-protect' have to be
+       ;; handled specially, because we only want to call
+       ;; `eshell-do-eval' on their first form.
+       ;;
+       ;; NOTE: This requires obedience by all forms which this
+       ;; function might encounter, that they do not contain
+       ;; other special forms.
        (unless (eq (car form) 'unwind-protect)
          (setq args (cdr args)))
        (unless (eq (caar args) 'eshell-do-eval)
@@ -1158,10 +1157,9 @@ be finished later after the completion of an 
asynchronous subprocess."
          (setq name (substring name 1)
                direct t))
       (if (and (not direct)
-              (eshell-using-module 'eshell-alias)
+              (fboundp 'eshell-lookup-alias)
               (setq alias
-                    (funcall (symbol-function 'eshell-lookup-alias)
-                             name)))
+                    (eshell-lookup-alias name)))
          (setq program
                (concat name " is an alias, defined as \""
                        (cadr alias) "\"")))
@@ -1341,7 +1339,7 @@ messages, and errors."
          (eshell-print "\n"))
       (eshell-close-handles 0 (list 'quote result)))))
 
-(defalias 'eshell-lisp-command* 'eshell-lisp-command)
+(defalias 'eshell-lisp-command* #'eshell-lisp-command)
 
 (provide 'esh-cmd)
 
diff --git a/lisp/eshell/esh-ext.el b/lisp/eshell/esh-ext.el
index 244cc7f..978fc55 100644
--- a/lisp/eshell/esh-ext.el
+++ b/lisp/eshell/esh-ext.el
@@ -1,6 +1,6 @@
 ;;; esh-ext.el --- commands external to Eshell  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -31,17 +31,12 @@
 
 ;;; Code:
 
-(provide 'esh-ext)
-
 (require 'esh-util)
 
-(eval-when-compile
-  (require 'cl-lib)
-  (require 'esh-cmd))
+(eval-when-compile (require 'cl-lib))
 (require 'esh-io)
 (require 'esh-arg)
 (require 'esh-opt)
-(require 'esh-proc)
 
 (defgroup eshell-ext nil
   "External commands are invoked when operating system executables are
@@ -177,9 +172,9 @@ external version."
 
 ;;; Functions:
 
-(defun eshell-ext-initialize ()
+(defun eshell-ext-initialize ()     ;Called from `eshell-mode' via intern-soft!
   "Initialize the external command handling code."
-  (add-hook 'eshell-named-command-hook 'eshell-explicit-command nil t))
+  (add-hook 'eshell-named-command-hook #'eshell-explicit-command nil t))
 
 (defun eshell-explicit-command (command args)
   "If a command name begins with `*', call it externally always.
@@ -193,8 +188,6 @@ This bypasses all Lisp functions and aliases."
        (error "%s: external command not found"
               (substring command 1))))))
 
-(autoload 'eshell-close-handles "esh-io")
-
 (defun eshell-remote-command (command args)
   "Insert output from a remote COMMAND, using ARGS.
 A remote command is something that executes on a different machine.
@@ -211,7 +204,7 @@ causing the user to wonder if anything's really going on..."
        (progn
          (setq exitcode
                (shell-command
-                (mapconcat 'shell-quote-argument
+                (mapconcat #'shell-quote-argument
                            (append (list command) args) " ")
                 outbuf errbuf))
          (eshell-print (with-current-buffer outbuf (buffer-string)))
@@ -222,7 +215,7 @@ causing the user to wonder if anything's really going on..."
 
 (defun eshell-external-command (command args)
   "Insert output from an external COMMAND, using ARGS."
-  (setq args (eshell-stringify-list (eshell-flatten-list args)))
+  (setq args (eshell-stringify-list (flatten-tree args)))
   (let ((interp (eshell-find-interpreter
                 command
                 args
@@ -235,6 +228,8 @@ causing the user to wonder if anything's really going on..."
     (cl-assert interp)
     (if (functionp (car interp))
        (apply (car interp) (append (cdr interp) args))
+      (require 'esh-proc)
+      (declare-function eshell-gather-process-output "esh-proc" (command args))
       (eshell-gather-process-output
        (car interp) (append (cdr interp) args)))))
 
@@ -249,7 +244,7 @@ Adds the given PATH to $PATH.")
    (if args
        (progn
         (setq eshell-path-env (getenv "PATH")
-              args (mapconcat 'identity args path-separator)
+              args (mapconcat #'identity args path-separator)
               eshell-path-env
               (if prepend
                   (concat args path-separator eshell-path-env)
@@ -336,4 +331,5 @@ line of the form #!<interp>."
                            (cdr interp)))))
          (or interp (list fullname)))))))
 
+(provide 'esh-ext)
 ;;; esh-ext.el ends here
diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el
index 1bcf5fb..ce1d021 100644
--- a/lisp/eshell/esh-io.el
+++ b/lisp/eshell/esh-io.el
@@ -1,6 +1,6 @@
 ;;; esh-io.el --- I/O management  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -68,8 +68,6 @@
 
 ;;; Code:
 
-(provide 'esh-io)
-
 (require 'esh-arg)
 (require 'esh-util)
 
@@ -171,7 +169,7 @@ not be added to this variable."
 
 ;;; Functions:
 
-(defun eshell-io-initialize ()
+(defun eshell-io-initialize ()      ;Called from `eshell-mode' via intern-soft!
   "Initialize the I/O subsystem code."
   (add-hook 'eshell-parse-argument-hook
            'eshell-parse-redirection nil t)
@@ -511,4 +509,5 @@ Returns what was actually sent, or nil if nothing was sent."
        (eshell-output-object-to-target object (car target))
        (setq target (cdr target))))))
 
+(provide 'esh-io)
 ;;; esh-io.el ends here
diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el
index 0c25f41..cff29be 100644
--- a/lisp/eshell/esh-mode.el
+++ b/lisp/eshell/esh-mode.el
@@ -1,6 +1,6 @@
 ;;; esh-mode.el --- user interface  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -58,13 +58,10 @@
 
 ;;; Code:
 
-(provide 'esh-mode)
-
 (require 'esh-util)
 (require 'esh-module)
 (require 'esh-cmd)
-(require 'esh-io)
-(require 'esh-var)
+(require 'esh-arg)                      ;For eshell-parse-arguments
 
 (defgroup eshell-mode nil
   "This module contains code for handling input from the user."
@@ -202,6 +199,12 @@ This is used by `eshell-watch-for-password-prompt'."
   :type 'boolean
   :group 'eshell-mode)
 
+(defcustom eshell-directory-name
+  (locate-user-emacs-file "eshell/" ".eshell/")
+  "The directory where Eshell control files should be kept."
+  :type 'directory
+  :group 'eshell)
+
 (defvar eshell-first-time-p t
   "A variable which is non-nil the first time Eshell is loaded.")
 
@@ -292,7 +295,7 @@ and the hook `eshell-exit-hook'."
   ;; It's fine to run this unconditionally since it can be customized
   ;; via the `eshell-kill-processes-on-exit' variable.
   (and (fboundp 'eshell-query-kill-processes)
-       (not (memq 'eshell-query-kill-processes eshell-exit-hook))
+       (not (memq #'eshell-query-kill-processes eshell-exit-hook))
        (eshell-query-kill-processes))
   (run-hooks 'eshell-exit-hook))
 
@@ -334,7 +337,6 @@ and the hook `eshell-exit-hook'."
   (define-key eshell-command-map [(control ?b)] 'eshell-backward-argument)
   (define-key eshell-command-map [(control ?e)] 'eshell-show-maximum-output)
   (define-key eshell-command-map [(control ?f)] 'eshell-forward-argument)
-  (define-key eshell-command-map [return]       'eshell-copy-old-input)
   (define-key eshell-command-map [(control ?m)] 'eshell-copy-old-input)
   (define-key eshell-command-map [(control ?o)] 'eshell-kill-output)
   (define-key eshell-command-map [(control ?r)] 'eshell-show-output)
@@ -410,23 +412,23 @@ and the hook `eshell-exit-hook'."
       (when (and load-hook (boundp load-hook))
         (if (memq initfunc (symbol-value load-hook)) (setq initfunc nil))
         (run-hooks load-hook))
-      ;; So we don't need the -initialize functions on the hooks (b#5375).
+      ;; So we don't need the -initialize functions on the hooks (bug#5375).
       (and initfunc (fboundp initfunc) (funcall initfunc))))
 
   (if eshell-send-direct-to-subprocesses
-      (add-hook 'pre-command-hook 'eshell-intercept-commands t t))
+      (add-hook 'pre-command-hook #'eshell-intercept-commands t t))
 
   (if eshell-scroll-to-bottom-on-input
-      (add-hook 'pre-command-hook 'eshell-preinput-scroll-to-bottom t t))
+      (add-hook 'pre-command-hook #'eshell-preinput-scroll-to-bottom t t))
 
   (when eshell-scroll-show-maximum-output
     (set (make-local-variable 'scroll-conservatively) 1000))
 
   (when eshell-status-in-mode-line
-    (add-hook 'eshell-pre-command-hook 'eshell-command-started nil t)
-    (add-hook 'eshell-post-command-hook 'eshell-command-finished nil t))
+    (add-hook 'eshell-pre-command-hook #'eshell-command-started nil t)
+    (add-hook 'eshell-post-command-hook #'eshell-command-finished nil t))
 
-  (add-hook 'kill-buffer-hook 'eshell-kill-buffer-function t t)
+  (add-hook 'kill-buffer-hook #'eshell-kill-buffer-function t t)
 
   (if eshell-first-time-p
       (run-hooks 'eshell-first-time-mode-hook))
@@ -451,10 +453,10 @@ and the hook `eshell-exit-hook'."
   (if eshell-send-direct-to-subprocesses
       (progn
        (setq eshell-send-direct-to-subprocesses nil)
-       (remove-hook 'pre-command-hook 'eshell-intercept-commands t)
+       (remove-hook 'pre-command-hook #'eshell-intercept-commands t)
        (message "Sending subprocess input on RET"))
     (setq eshell-send-direct-to-subprocesses t)
-    (add-hook 'pre-command-hook 'eshell-intercept-commands t t)
+    (add-hook 'pre-command-hook #'eshell-intercept-commands t t)
     (message "Sending subprocess input directly")))
 
 (defun eshell-self-insert-command ()
@@ -543,7 +545,7 @@ and the hook `eshell-exit-hook'."
   "Push a mark at the end of the last input text."
   (push-mark (1- eshell-last-input-end) t))
 
-(custom-add-option 'eshell-pre-command-hook 'eshell-push-command-mark)
+(custom-add-option 'eshell-pre-command-hook #'eshell-push-command-mark)
 
 (defsubst eshell-goto-input-start ()
   "Goto the start of the last command input.
@@ -551,7 +553,7 @@ Putting this function on `eshell-pre-command-hook' will 
mimic Plan 9's
 9term behavior."
   (goto-char eshell-last-input-start))
 
-(custom-add-option 'eshell-pre-command-hook 'eshell-push-command-mark)
+(custom-add-option 'eshell-pre-command-hook #'eshell-goto-input-start)
 
 (defsubst eshell-interactive-print (string)
   "Print STRING to the eshell display buffer."
@@ -1021,4 +1023,5 @@ This function could be in the list 
`eshell-output-filter-functions'."
 (custom-add-option 'eshell-output-filter-functions
                   'eshell-handle-ansi-color)
 
+(provide 'esh-mode)
 ;;; esh-mode.el ends here
diff --git a/lisp/eshell/esh-module.el b/lisp/eshell/esh-module.el
index 06e94bd..1911a49 100644
--- a/lisp/eshell/esh-module.el
+++ b/lisp/eshell/esh-module.el
@@ -1,6 +1,6 @@
 ;;; esh-module.el --- Eshell modules  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2000, 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2000, 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 ;; Keywords: processes
@@ -22,9 +22,6 @@
 
 ;;; Code:
 
-(provide 'esh-module)
-
-(require 'eshell)
 (require 'esh-util)
 
 (defgroup eshell-module nil
@@ -101,4 +98,5 @@ customization group.  Example: `eshell-cmpl' for that 
module."
          (unload-feature module)
          (message "Unloading %s...done" (symbol-name module))))))
 
+(provide 'esh-module)
 ;;; esh-module.el ends here
diff --git a/lisp/eshell/esh-opt.el b/lisp/eshell/esh-opt.el
index d7a4494..3ea5873 100644
--- a/lisp/eshell/esh-opt.el
+++ b/lisp/eshell/esh-opt.el
@@ -1,6 +1,6 @@
 ;;; esh-opt.el --- command options processing  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -23,9 +23,6 @@
 
 ;;; Code:
 
-(provide 'esh-opt)
-
-(require 'esh-ext)
 
 ;; Unused.
 ;; (defgroup eshell-opt nil
@@ -36,6 +33,10 @@
 
 ;;; User Functions:
 
+;; Macro expansion of eshell-eval-using-options refers to eshell-stringify-list
+;; defined in esh-util.
+(require 'esh-util)
+
 (defmacro eshell-eval-using-options (name macro-args options &rest body-forms)
   "Process NAME's MACRO-ARGS using a set of command line OPTIONS.
 After doing so, stores settings in local symbols as declared by OPTIONS;
@@ -77,7 +78,7 @@ arguments, some do not.  The recognized :KEYWORDS are:
   arguments.
 
 :preserve-args
-  If present, do not pass MACRO-ARGS through `eshell-flatten-list'
+  If present, do not pass MACRO-ARGS through `flatten-tree'
 and `eshell-stringify-list'.
 
 :parse-leading-options-only
@@ -106,7 +107,7 @@ let-bound variable `args'."
            ,(if (memq ':preserve-args (cadr options))
                 macro-args
               (list 'eshell-stringify-list
-                    (list 'eshell-flatten-list macro-args))))
+                    (list 'flatten-tree macro-args))))
           (processed-args (eshell--do-opts ,name ,options temp-args))
           ,@(delete-dups
              (delq nil (mapcar (lambda (opt)
@@ -127,6 +128,8 @@ let-bound variable `args'."
 (defun eshell--do-opts (name options args)
   "Helper function for `eshell-eval-using-options'.
 This code doesn't really need to be macro expanded everywhere."
+  (require 'esh-ext)
+  (declare-function eshell-external-command "esh-ext" (command args))
   (let ((ext-command
          (catch 'eshell-ext-command
            (let ((usage-msg
@@ -145,6 +148,8 @@ This code doesn't really need to be macro expanded 
everywhere."
 
 (defun eshell-show-usage (name options)
   "Display the usage message for NAME, using OPTIONS."
+  (require 'esh-ext)
+  (declare-function eshell-search-path "esh-ext" (name))
   (let ((usage (format "usage: %s %s\n\n" name
                       (cadr (memq ':usage options))))
        (extcmd (memq ':external options))
@@ -273,4 +278,5 @@ switch is unrecognized."
                (setq index (1+ index))))))))
     (nconc (mapcar #'cdr opt-vals) eshell--args)))
 
+(provide 'esh-opt)
 ;;; esh-opt.el ends here
diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el
index 3735f30..32a3eec 100644
--- a/lisp/eshell/esh-proc.el
+++ b/lisp/eshell/esh-proc.el
@@ -1,6 +1,6 @@
 ;;; esh-proc.el --- process management  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -23,9 +23,7 @@
 
 ;;; Code:
 
-(provide 'esh-proc)
-
-(require 'esh-cmd)
+(require 'esh-io)
 
 (defgroup eshell-proc nil
   "When Eshell invokes external commands, it always does so
@@ -118,14 +116,17 @@ information, for example."
 Runs `eshell-reset-after-proc' and `eshell-kill-hook', passing arguments
 PROC and STATUS to functions on the latter."
   ;; Was there till 24.1, but it is not optional.
-  (if (memq 'eshell-reset-after-proc eshell-kill-hook)
-      (setq eshell-kill-hook (delq 'eshell-reset-after-proc eshell-kill-hook)))
+  (if (memq #'eshell-reset-after-proc eshell-kill-hook)
+      (setq eshell-kill-hook (delq #'eshell-reset-after-proc 
eshell-kill-hook)))
   (eshell-reset-after-proc status)
   (run-hook-with-args 'eshell-kill-hook proc status))
 
-(defun eshell-proc-initialize ()
+(defun eshell-proc-initialize ()    ;Called from `eshell-mode' via intern-soft!
   "Initialize the process handling code."
   (make-local-variable 'eshell-process-list)
+  ;; This is supposedly run after enabling esh-mode, when eshell-command-map
+  ;; already exists.
+  (defvar eshell-command-map)
   (define-key eshell-command-map [(meta ?i)] 'eshell-insert-process)
   (define-key eshell-command-map [(control ?c)]  'eshell-interrupt-process)
   (define-key eshell-command-map [(control ?k)]  'eshell-kill-process)
@@ -139,9 +140,11 @@ PROC and STATUS to functions on the latter."
   "Reset the command input location after a process terminates.
 The signals which will cause this to happen are matched by
 `eshell-reset-signals'."
-  (if (and (stringp status)
-          (string-match eshell-reset-signals status))
-      (eshell-reset)))
+  (when (and (stringp status)
+            (string-match eshell-reset-signals status))
+    (require 'esh-mode)
+    (declare-function eshell-reset "esh-mode" (&optional no-hooks))
+    (eshell-reset)))
 
 (defun eshell-wait-for-process (&rest procs)
   "Wait until PROC has successfully completed."
@@ -209,7 +212,8 @@ The prompt will be set to PROMPT."
                    (function
                     (lambda (proc)
                       (cons (process-name proc) t)))
-                   (process-list)) nil t))
+                   (process-list))
+                   nil t))
 
 (defun eshell-insert-process (process)
   "Insert the name of PROCESS into the current buffer at point."
@@ -220,10 +224,12 @@ The prompt will be set to PROMPT."
 
 (defsubst eshell-record-process-object (object)
   "Record OBJECT as now running."
-  (if (and (eshell-processp object)
-          eshell-current-subjob-p)
-      (eshell-interactive-print
-       (format "[%s] %d\n" (process-name object) (process-id object))))
+  (when (and (eshell-processp object)
+            eshell-current-subjob-p)
+    (require 'esh-mode)
+    (declare-function eshell-interactive-print "esh-mode" (string))
+    (eshell-interactive-print
+     (format "[%s] %d\n" (process-name object) (process-id object))))
   (setq eshell-process-list
        (cons (list object eshell-current-handles
                    eshell-current-subjob-p nil nil)
@@ -245,7 +251,11 @@ The prompt will be set to PROMPT."
   "A marker that tracks the beginning of output of the last subprocess.
 Used only on systems which do not support async subprocesses.")
 
-(defvar eshell-needs-pipe '("bc")
+(defvar eshell-needs-pipe
+  '("bc"
+    ;; xclip.el (in GNU ELPA) calls all of these with
+    ;; `process-connection-type' set to nil.
+    "pbpaste" "putclip" "xclip" "xsel" "wl-copy")
   "List of commands which need `process-connection-type' to be nil.
 Currently only affects commands in pipelines, and not those at
 the front.  If an element contains a directory part it must match
@@ -254,7 +264,7 @@ the full name of a command, otherwise just the nondirectory 
part must match.")
 (defun eshell-needs-pipe-p (command)
   "Return non-nil if COMMAND needs `process-connection-type' to be nil.
 See `eshell-needs-pipe'."
-  (and eshell-in-pipeline-p
+  (and (bound-and-true-p eshell-in-pipeline-p)
        (not (eq eshell-in-pipeline-p 'first))
        ;; FIXME should this return non-nil for anything that is
        ;; neither 'first nor 'last?  See bug#1388 discussion.
@@ -267,6 +277,8 @@ See `eshell-needs-pipe'."
 
 (defun eshell-gather-process-output (command args)
   "Gather the output from COMMAND + ARGS."
+  (require 'esh-var)
+  (declare-function eshell-environment-variables "esh-var" ())
   (unless (and (file-executable-p command)
               (file-regular-p (file-truename command)))
     (error "%s: not an executable file" command))
@@ -282,16 +294,15 @@ See `eshell-needs-pipe'."
            (let ((process-connection-type
                   (unless (eshell-needs-pipe-p command)
                     process-connection-type))
-                 ;; `start-process' can't deal with relative filenames.
                  (command (file-local-name (expand-file-name command))))
-             (apply 'start-file-process
+             (apply #'start-file-process
                     (file-name-nondirectory command) nil command args)))
       (eshell-record-process-object proc)
       (set-process-buffer proc (current-buffer))
-      (if (eshell-interactive-output-p)
-         (set-process-filter proc 'eshell-output-filter)
-       (set-process-filter proc 'eshell-insertion-filter))
-      (set-process-sentinel proc 'eshell-sentinel)
+      (set-process-filter proc (if (eshell-interactive-output-p)
+                                  #'eshell-output-filter
+                                 #'eshell-insertion-filter))
+      (set-process-sentinel proc #'eshell-sentinel)
       (run-hook-with-args 'eshell-exec-hook proc)
       (when (fboundp 'process-coding-system)
        (let ((coding-systems (process-coding-system proc)))
@@ -326,14 +337,14 @@ See `eshell-needs-pipe'."
        (set-buffer oldbuf)
        (run-hook-with-args 'eshell-exec-hook command)
        (setq exit-status
-             (apply 'call-process-region
+             (apply #'call-process-region
                     (append (list eshell-last-sync-output-start (point)
                                   command t
                                   eshell-scratch-buffer nil)
                             args)))
        ;; When in a pipeline, record the place where the output of
        ;; this process will begin.
-       (and eshell-in-pipeline-p
+       (and (bound-and-true-p eshell-in-pipeline-p)
             (set-marker eshell-last-sync-output-start (point)))
        ;; Simulate the effect of the process filter.
        (when (numberp exit-status)
@@ -350,11 +361,14 @@ See `eshell-needs-pipe'."
            (setq lbeg lend)
            (set-buffer proc-buf))
          (set-buffer oldbuf))
+        (require 'esh-mode)
+        (declare-function eshell-update-markers "esh-mode" (pmark))
+        (defvar eshell-last-output-end)         ;Defined in esh-mode.el.
        (eshell-update-markers eshell-last-output-end)
        ;; Simulate the effect of eshell-sentinel.
        (eshell-close-handles (if (numberp exit-status) exit-status -1))
        (eshell-kill-process-function command exit-status)
-       (or eshell-in-pipeline-p
+       (or (bound-and-true-p eshell-in-pipeline-p)
            (setq eshell-last-sync-output-start nil))
        (if (not (numberp exit-status))
          (error "%s: external command failed: %s" command exit-status))
@@ -499,7 +513,7 @@ See the variable `eshell-kill-processes-on-exit'."
                                        (buffer-name))))
          (eshell-round-robin-kill
           (if (eq eshell-kill-processes-on-exit 'every)
-              (format-message "Kill Eshell child process `%s'? "))))
+              "Kill Eshell child process `%s'? ")))
       (let ((buf (get-buffer "*Process List*")))
        (if (and buf (buffer-live-p buf))
            (kill-buffer buf)))
@@ -541,7 +555,11 @@ See the variable `eshell-kill-processes-on-exit'."
 (defun eshell-send-eof-to-process ()
   "Send EOF to process."
   (interactive)
+  (require 'esh-mode)
+  (declare-function eshell-send-input "esh-mode"
+                    (&optional use-region queue-p no-newline))
   (eshell-send-input nil nil t)
   (eshell-process-interact 'process-send-eof))
 
+(provide 'esh-proc)
 ;;; esh-proc.el ends here
diff --git a/lisp/eshell/esh-util.el b/lisp/eshell/esh-util.el
index 8fe8c46..6f355c7 100644
--- a/lisp/eshell/esh-util.el
+++ b/lisp/eshell/esh-util.el
@@ -1,6 +1,6 @@
 ;;; esh-util.el --- general utilities  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -285,15 +285,7 @@ Prepend remote identification of `default-directory', if 
any."
         ,@forms)
        (setq list-iter (cdr list-iter)))))
 
-(defun eshell-flatten-list (args)
-  "Flatten any lists within ARGS, so that there are no sublists."
-  (let ((new-list (list t)))
-    (dolist (a args)
-      (if (and (listp a)
-              (listp (cdr a)))
-         (nconc new-list (eshell-flatten-list a))
-       (nconc new-list (list a))))
-    (cdr new-list)))
+(define-obsolete-function-alias 'eshell-flatten-list #'flatten-tree "27.1")
 
 (defun eshell-uniquify-list (l)
   "Remove occurring multiples in L.  You probably want to sort first."
@@ -330,7 +322,7 @@ Prepend remote identification of `default-directory', if 
any."
 
 (defsubst eshell-flatten-and-stringify (&rest args)
   "Flatten and stringify all of the ARGS into a single string."
-  (mapconcat 'eshell-stringify (eshell-flatten-list args) " "))
+  (mapconcat 'eshell-stringify (flatten-tree args) " "))
 
 (defsubst eshell-directory-files (regexp &optional directory)
   "Return a list of files in the given DIRECTORY matching REGEXP."
@@ -486,24 +478,22 @@ list."
       (insert-file-contents (or filename eshell-hosts-file))
       (goto-char (point-min))
       (while (re-search-forward
-             "^\\([^#[:space:]]+\\)\\s-+\\(\\S-+\\)\\(\\s-*\\(\\S-+\\)\\)?" 
nil t)
-       (if (match-string 1)
-           (cl-pushnew (match-string 1) hosts :test #'equal))
-       (if (match-string 2)
-           (cl-pushnew (match-string 2) hosts :test #'equal))
-       (if (match-string 4)
-           (cl-pushnew (match-string 4) hosts :test #'equal))))
-    (sort hosts #'string-lessp)))
+              ;; "^ \t\\([^# \t\n]+\\)[ \t]+\\([^ \t\n]+\\)\\([ \t]*\\([^ 
\t\n]+\\)\\)?"
+             "^[ \t]*\\([^# \t\n]+\\)[ \t]+\\([^ \t\n].+\\)" nil t)
+        (push (cons (match-string 1)
+                    (split-string (match-string 2)))
+              hosts)))
+    (nreverse hosts)))
 
 (defun eshell-read-hosts (file result-var timestamp-var)
-  "Read the contents of /etc/passwd for user names."
+  "Read the contents of /etc/hosts for host names."
   (if (or (not (symbol-value result-var))
          (not (symbol-value timestamp-var))
          (time-less-p
           (symbol-value timestamp-var)
           (file-attribute-modification-time (file-attributes file))))
       (progn
-       (set result-var (eshell-read-hosts-file file))
+       (set result-var (apply #'nconc (eshell-read-hosts-file file)))
        (set timestamp-var (current-time))))
   (symbol-value result-var))
 
@@ -660,7 +650,7 @@ If NOSORT is non-nil, the list is not sorted--its order is 
unpredictable.
                        (setcar (nthcdr 0 moment) 0)
                        (setcar (nthcdr 1 moment) 0)
                        (setcar (nthcdr 2 moment) 0))
-                     (apply 'encode-time moment))
+                     (encode-time moment))
                  (ange-ftp-file-modtime (expand-file-name name dir))))
               symlink)
          (if (string-match "\\(.+\\) -> \\(.+\\)" name)
diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el
index b5dce80..b08a5d2 100644
--- a/lisp/eshell/esh-var.el
+++ b/lisp/eshell/esh-var.el
@@ -1,6 +1,6 @@
 ;;; esh-var.el --- handling of variables  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -105,11 +105,12 @@
 
 ;;; Code:
 
-(provide 'esh-var)
-
 (require 'esh-util)
 (require 'esh-cmd)
 (require 'esh-opt)
+(require 'esh-module)
+(require 'esh-arg)
+(require 'esh-io)
 
 (require 'pcomplete)
 (require 'env)
@@ -128,60 +129,55 @@ variable value, a subcommand, or even the result of a 
Lisp form."
 (defcustom eshell-var-load-hook nil
   "A list of functions to call when loading `eshell-var'."
   :version "24.1"                      ; removed eshell-var-initialize
-  :type 'hook
-  :group 'eshell-var)
+  :type 'hook)
 
 (defcustom eshell-prefer-lisp-variables nil
   "If non-nil, prefer Lisp variables to environment variables."
-  :type 'boolean
-  :group 'eshell-var)
+  :type 'boolean)
 
 (defcustom eshell-complete-export-definition t
   "If non-nil, completing names for `export' shows current definition."
-  :type 'boolean
-  :group 'eshell-var)
+  :type 'boolean)
 
 (defcustom eshell-modify-global-environment nil
   "If non-nil, using `export' changes Emacs's global environment."
-  :type 'boolean
-  :group 'eshell-var)
+  :type 'boolean)
 
 (defcustom eshell-variable-name-regexp "[A-Za-z0-9_-]+"
   "A regexp identifying what constitutes a variable name reference.
 Note that this only applies for `$NAME'.  If the syntax `$<NAME>' is
 used, then NAME can contain any character, including angle brackets,
 if they are quoted with a backslash."
-  :type 'regexp
-  :group 'eshell-var)
+  :type 'regexp)
 
 (defcustom eshell-variable-aliases-list
-  '(;; for eshell.el
-    ("COLUMNS" (lambda (indices) (window-width)) t)
-    ("LINES" (lambda (indices) (window-height)) t)
+  `(;; for eshell.el
+    ("COLUMNS" ,(lambda (_indices) (window-width)) t)
+    ("LINES" ,(lambda (_indices) (window-height)) t)
 
     ;; for eshell-cmd.el
-    ("_" (lambda (indices)
-          (if (not indices)
-              (car (last eshell-last-arguments))
-            (eshell-apply-indices eshell-last-arguments
-                                  indices))))
+    ("_" ,(lambda (indices)
+           (if (not indices)
+               (car (last eshell-last-arguments))
+             (eshell-apply-indices eshell-last-arguments
+                                   indices))))
     ("?" eshell-last-command-status)
     ("$" eshell-last-command-result)
     ("0" eshell-command-name)
-    ("1" (lambda (indices) (nth 0 eshell-command-arguments)))
-    ("2" (lambda (indices) (nth 1 eshell-command-arguments)))
-    ("3" (lambda (indices) (nth 2 eshell-command-arguments)))
-    ("4" (lambda (indices) (nth 3 eshell-command-arguments)))
-    ("5" (lambda (indices) (nth 4 eshell-command-arguments)))
-    ("6" (lambda (indices) (nth 5 eshell-command-arguments)))
-    ("7" (lambda (indices) (nth 6 eshell-command-arguments)))
-    ("8" (lambda (indices) (nth 7 eshell-command-arguments)))
-    ("9" (lambda (indices) (nth 8 eshell-command-arguments)))
-    ("*" (lambda (indices)
-          (if (not indices)
-              eshell-command-arguments
-            (eshell-apply-indices eshell-command-arguments
-                                  indices)))))
+    ("1" ,(lambda (_indices) (nth 0 eshell-command-arguments)))
+    ("2" ,(lambda (_indices) (nth 1 eshell-command-arguments)))
+    ("3" ,(lambda (_indices) (nth 2 eshell-command-arguments)))
+    ("4" ,(lambda (_indices) (nth 3 eshell-command-arguments)))
+    ("5" ,(lambda (_indices) (nth 4 eshell-command-arguments)))
+    ("6" ,(lambda (_indices) (nth 5 eshell-command-arguments)))
+    ("7" ,(lambda (_indices) (nth 6 eshell-command-arguments)))
+    ("8" ,(lambda (_indices) (nth 7 eshell-command-arguments)))
+    ("9" ,(lambda (_indices) (nth 8 eshell-command-arguments)))
+    ("*" ,(lambda (indices)
+           (if (not indices)
+               eshell-command-arguments
+             (eshell-apply-indices eshell-command-arguments
+                                   indices)))))
   "This list provides aliasing for variable references.
 It is very similar in concept to what `eshell-user-aliases-list' does
 for commands.  Each member of this defines the name of a command,
@@ -197,14 +193,13 @@ function), and the arguments passed to this function 
would be the list
 '(10 20)', and nil."
   :type '(repeat (list string sexp
                       (choice (const :tag "Copy to environment" t)
-                              (const :tag "Use only in Eshell" nil))))
-  :group 'eshell-var)
+                              (const :tag "Use only in Eshell" nil)))))
 
 (put 'eshell-variable-aliases-list 'risky-local-variable t)
 
 ;;; Functions:
 
-(defun eshell-var-initialize ()
+(defun eshell-var-initialize ()     ;Called from `eshell-mode' via intern-soft!
   "Initialize the variable handle code."
   ;; Break the association with our parent's environment.  Otherwise,
   ;; changing a variable will affect all of Emacs.
@@ -212,6 +207,9 @@ function), and the arguments passed to this function would 
be the list
     (set (make-local-variable 'process-environment)
         (eshell-copy-environment)))
 
+  ;; This is supposedly run after enabling esh-mode, when eshell-command-map
+  ;; already exists.
+  (defvar eshell-command-map)
   (define-key eshell-command-map [(meta ?v)] 'eshell-insert-envvar)
 
   (set (make-local-variable 'eshell-special-chars-inside-quoting)
@@ -219,16 +217,16 @@ function), and the arguments passed to this function 
would be the list
   (set (make-local-variable 'eshell-special-chars-outside-quoting)
        (append eshell-special-chars-outside-quoting '(?$)))
 
-  (add-hook 'eshell-parse-argument-hook 'eshell-interpolate-variable t t)
+  (add-hook 'eshell-parse-argument-hook #'eshell-interpolate-variable t t)
 
   (add-hook 'eshell-prepare-command-hook
-           'eshell-handle-local-variables nil t)
+           #'eshell-handle-local-variables nil t)
 
   (when (eshell-using-module 'eshell-cmpl)
     (add-hook 'pcomplete-try-first-hook
-             'eshell-complete-variable-reference nil t)
+             #'eshell-complete-variable-reference nil t)
     (add-hook 'pcomplete-try-first-hook
-             'eshell-complete-variable-assignment nil t)))
+             #'eshell-complete-variable-assignment nil t)))
 
 (defun eshell-handle-local-variables ()
   "Allow for the syntax `VAR=val <command> <args>'."
@@ -397,6 +395,8 @@ process any indices that come after the variable reference."
          indices (and (not (eobp))
                       (eq (char-after) ?\[)
                       (eshell-parse-indices))
+          ;; This is an expression that will be evaluated by `eshell-do-eval',
+          ;; which only support let-binding of dynamically-scoped vars
          value `(let ((indices ',indices)) ,value))
     (if get-len
        `(length ,value)
@@ -419,18 +419,17 @@ Possible options are:
       (if (not end)
           (throw 'eshell-incomplete ?\{)
         (prog1
-            (list 'eshell-convert
-                  (list 'eshell-command-to-value
-                        (list 'eshell-as-subcommand
-                              (eshell-parse-command
-                               (cons (1+ (point)) end)))))
+            `(eshell-convert
+              (eshell-command-to-value
+               (eshell-as-subcommand
+                ,(eshell-parse-command (cons (1+ (point)) end)))))
           (goto-char (1+ end))))))
    ((memq (char-after) '(?\' ?\"))
     (let ((name (if (eq (char-after) ?\')
                     (eshell-parse-literal-quote)
                   (eshell-parse-double-quote))))
       (if name
-         (list 'eshell-get-variable (eval name) 'indices))))
+         `(eshell-get-variable ,(eval name) indices))))
    ((eq (char-after) ?\<)
     (let ((end (eshell-find-delimiter ?\< ?\>)))
       (if (not end)
@@ -439,37 +438,30 @@ Possible options are:
                (cmd (concat (buffer-substring (1+ (point)) end)
                             " > " temp)))
           (prog1
-              (list
-               'let (list (list 'eshell-current-handles
-                                (list 'eshell-create-handles temp
-                                      (list 'quote 'overwrite))))
-               (list
-                'progn
-                (list 'eshell-as-subcommand
-                      (eshell-parse-command cmd))
-                (list 'ignore
-                      (list 'nconc 'eshell-this-command-hook
-                            (list 'list
-                                  (list 'function
-                                        (list 'lambda nil
-                                              (list 'delete-file temp))))))
-                (list 'quote temp)))
+              `(let ((eshell-current-handles
+                      (eshell-create-handles ,temp 'overwrite)))
+                 (progn
+                   (eshell-as-subcommand ,(eshell-parse-command cmd))
+                   (ignore
+                    (nconc eshell-this-command-hook
+                           (list (function (lambda ()
+                                              (delete-file ,temp))))))
+                   (quote ,temp)))
             (goto-char (1+ end)))))))
    ((eq (char-after) ?\()
     (condition-case nil
-        (list 'eshell-command-to-value
-              (list 'eshell-lisp-command
-                    (list 'quote (read (current-buffer)))))
+        `(eshell-command-to-value
+          (eshell-lisp-command
+           ',(read (current-buffer))))
       (end-of-file
        (throw 'eshell-incomplete ?\())))
    ((assoc (char-to-string (char-after))
            eshell-variable-aliases-list)
     (forward-char)
-    (list 'eshell-get-variable
-          (char-to-string (char-before)) 'indices))
+    `(eshell-get-variable ,(char-to-string (char-before)) indices))
    ((looking-at eshell-variable-name-regexp)
     (prog1
-        (list 'eshell-get-variable (match-string 0) 'indices)
+        `(eshell-get-variable ,(match-string 0) indices)
       (goto-char (match-end 0))))
    (t
     (error "Invalid variable reference"))))
@@ -544,7 +536,7 @@ For example, to retrieve the second element of a user's 
record in
              (setq separator (caar indices)
                    refs (cdr refs)))
          (setq value
-               (mapcar 'eshell-convert
+               (mapcar #'eshell-convert
                        (split-string value separator)))))
       (cond
        ((< (length refs) 0)
@@ -630,4 +622,5 @@ For example, to retrieve the second element of a user's 
record in
       (setq pcomplete-stub (substring arg pos))
       (throw 'pcomplete-completions (pcomplete-entries)))))
 
+(provide 'esh-var)
 ;;; esh-var.el ends here
diff --git a/lisp/eshell/eshell.el b/lisp/eshell/eshell.el
index f3c4a4a..db20f7d 100644
--- a/lisp/eshell/eshell.el
+++ b/lisp/eshell/eshell.el
@@ -1,6 +1,6 @@
 ;;; eshell.el --- the Emacs command shell  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 ;; Version: 2.4.2
@@ -175,7 +175,10 @@
 (eval-when-compile
   (require 'cl-lib))
 (require 'esh-util)
-(require 'esh-mode)
+(require 'esh-module)                   ;For eshell-using-module
+(require 'esh-proc)                     ;For eshell-wait-for-process
+(require 'esh-io)                       ;For eshell-last-command-status
+(require 'esh-cmd)
 
 (defgroup eshell nil
   "Command shell implemented entirely in Emacs Lisp.
@@ -217,12 +220,6 @@ shells such as bash, zsh, rc, 4dos."
   :type 'string
   :group 'eshell)
 
-(defcustom eshell-directory-name
-  (locate-user-emacs-file "eshell/" ".eshell/")
-  "The directory where Eshell control files should be kept."
-  :type 'directory
-  :group 'eshell)
-
 ;;;_* Running Eshell
 ;;
 ;; There are only three commands used to invoke Eshell.  The first two
@@ -256,11 +253,12 @@ buffer selected (or created)."
     buf))
 
 (defun eshell-return-exits-minibuffer ()
+  ;; This is supposedly run after enabling esh-mode, when eshell-mode-map
+  ;; already exists.
+  (defvar eshell-mode-map)
   (define-key eshell-mode-map [(control ?g)] 'abort-recursive-edit)
-  (define-key eshell-mode-map [return] 'exit-minibuffer)
   (define-key eshell-mode-map [(control ?m)] 'exit-minibuffer)
   (define-key eshell-mode-map [(control ?j)] 'exit-minibuffer)
-  (define-key eshell-mode-map [(meta return)] 'exit-minibuffer)
   (define-key eshell-mode-map [(meta control ?m)] 'exit-minibuffer))
 
 (defvar eshell-non-interactive-p nil
@@ -275,7 +273,6 @@ non-interactive sessions, such as when using 
`eshell-command'.")
   "Execute the Eshell command string COMMAND.
 With prefix ARG, insert output into the current buffer at point."
   (interactive)
-  (require 'esh-cmd)
   (unless arg
     (setq arg current-prefix-arg))
   (let ((eshell-non-interactive-p t))
@@ -363,7 +360,8 @@ corresponding to a successful execution."
        (let ((result (eshell-do-eval
                       (list 'eshell-commands
                             (list 'eshell-command-to-value
-                                  (eshell-parse-command command))) t)))
+                                  (eshell-parse-command command)))
+                       t)))
          (cl-assert (eq (car result) 'quote))
          (if (and status-var (symbolp status-var))
              (set status-var eshell-last-command-status))
@@ -404,5 +402,4 @@ Emacs."
 (run-hooks 'eshell-load-hook)
 
 (provide 'eshell)
-
 ;;; eshell.el ends here
diff --git a/lisp/expand.el b/lisp/expand.el
index 010ba60..0c4d343 100644
--- a/lisp/expand.el
+++ b/lisp/expand.el
@@ -1,6 +1,6 @@
 ;;; expand.el --- make abbreviations more usable
 
-;; Copyright (C) 1995-1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-1996, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Frederic Lepied <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/ezimage.el b/lisp/ezimage.el
index 86ced34..2b06878 100644
--- a/lisp/ezimage.el
+++ b/lisp/ezimage.el
@@ -1,6 +1,6 @@
 ;;; ezimage --- Generalized Image management
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: file, tags, tools
diff --git a/lisp/face-remap.el b/lisp/face-remap.el
index c6a976d..1a0cc64 100644
--- a/lisp/face-remap.el
+++ b/lisp/face-remap.el
@@ -1,6 +1,6 @@
 ;;; face-remap.el --- Functions for managing `face-remapping-alist'  -*- 
lexical-binding: t -*-
 ;;
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Miles Bader <address@hidden>
 ;; Keywords: faces, face remapping, display, user commands
diff --git a/lisp/facemenu.el b/lisp/facemenu.el
index 7c10d60..44b3941 100644
--- a/lisp/facemenu.el
+++ b/lisp/facemenu.el
@@ -1,6 +1,6 @@
 ;;; facemenu.el --- create a face menu for interactively adding fonts to text
 
-;; Copyright (C) 1994-1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1996, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Boris Goldowsky <address@hidden>
 ;; Keywords: faces
diff --git a/lisp/faces.el b/lisp/faces.el
index a8c1546..fa526c3 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -1,6 +1,6 @@
 ;;; faces.el --- Lisp faces -*- lexical-binding: t -*-
 
-;; Copyright (C) 1992-1996, 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992-1996, 1998-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: internal
@@ -55,6 +55,7 @@ This means to treat a terminal of type TYPE as if it were of 
type ALIAS."
   :group 'terminals
   :version "25.1")
 
+(declare-function display-graphic-p "frame" (&optional display))
 (declare-function xw-defined-colors "term/common-win" (&optional frame))
 
 (defvar help-xref-stack-item)
@@ -1239,7 +1240,7 @@ of a global face.  Value is the new attribute value."
               ;; explicitly in VALID, using color approximation code
               ;; in tty-colors.el.
               (when (and (memq attribute '(:foreground :background))
-                         (not (memq (window-system frame) '(x w32 ns)))
+                         (not (display-graphic-p frame))
                          (not (member new-value
                                       '("unspecified"
                                         "unspecified-fg" "unspecified-bg"))))
@@ -1833,7 +1834,7 @@ The argument FRAME specifies which frame to try.
 The value may be different for frames on different display types.
 If FRAME doesn't support colors, the value is nil.
 If FRAME is nil, that stands for the selected frame."
-  (if (memq (framep (or frame (selected-frame))) '(x w32 ns))
+  (if (display-graphic-p frame)
       (xw-defined-colors frame)
     (mapcar 'car (tty-color-alist frame))))
 (defalias 'x-defined-colors 'defined-colors)
@@ -1877,7 +1878,7 @@ or one of the strings \"unspecified-fg\" or 
\"unspecified-bg\".
 
 If FRAME is omitted or nil, use the selected frame."
   (unless (member color '(unspecified "unspecified-bg" "unspecified-fg"))
-    (if (member (framep (or frame (selected-frame))) '(x w32 ns))
+    (if (display-graphic-p frame)
        (xw-color-defined-p color frame)
       (numberp (tty-color-translate color frame)))))
 (defalias 'x-color-defined-p 'color-defined-p)
@@ -1903,7 +1904,7 @@ return value is nil."
   (cond
    ((member color '(unspecified "unspecified-fg" "unspecified-bg"))
     nil)
-   ((memq (framep (or frame (selected-frame))) '(x w32 ns))
+   ((display-graphic-p frame)
     (xw-color-values color frame))
    (t
     (tty-color-values color frame))))
@@ -1917,7 +1918,7 @@ return value is nil."
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display."
-  (if (memq (framep-on-display display) '(x w32 ns))
+  (if (display-graphic-p display)
       (xw-display-color-p display)
     (tty-display-color-p display)))
 (defalias 'x-display-color-p 'display-color-p)
@@ -1928,12 +1929,9 @@ If omitted or nil, that stands for the selected frame's 
display."
   "Return non-nil if frames on DISPLAY can display shades of gray.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display."
-  (let ((frame-type (framep-on-display display)))
-    (cond
-     ((memq frame-type '(x w32 ns))
-      (x-display-grayscale-p display))
-     (t
-      (> (tty-color-gray-shades display) 2)))))
+  (if (display-graphic-p display)
+      (x-display-grayscale-p display)
+    (> (tty-color-gray-shades display) 2)))
 
 (defun read-color (&optional prompt convert-to-RGB allow-empty-name msg)
   "Read a color name or RGB triplet.
diff --git a/lisp/ffap.el b/lisp/ffap.el
index b51929d..36e37e9 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -1,6 +1,6 @@
 ;;; ffap.el --- find file (or url) at point
 
-;; Copyright (C) 1995-1997, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-1997, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Michelangelo Grigni <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/filecache.el b/lisp/filecache.el
index 9dd6310..fb099c1 100644
--- a/lisp/filecache.el
+++ b/lisp/filecache.el
@@ -1,6 +1,6 @@
 ;;; filecache.el --- find files using a pre-loaded cache  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1996, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author:  Peter Breton <address@hidden>
 ;; Created: Sun Nov 10 1996
diff --git a/lisp/multifile.el b/lisp/fileloop.el
similarity index 77%
rename from lisp/multifile.el
rename to lisp/fileloop.el
index 712da5c..2e77811 100644
--- a/lisp/multifile.el
+++ b/lisp/fileloop.el
@@ -1,6 +1,6 @@
-;;; multifile.el --- Operations on multiple files  -*- lexical-binding: t; -*-
+;;; fileloop.el --- Operations on multiple files  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2018  Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 
@@ -24,11 +24,11 @@
 ;; version of etags.el.
 
 ;; TODO:
-;; - Maybe it would make sense to replace the multifile--* vars with a single
+;; - Maybe it would make sense to replace the fileloop--* vars with a single
 ;;   global var holding a struct, and then stash those structs into a history
-;;   of past operations, so you can perform a multifile-search while in the
-;;   middle of a multifile-replace and later go back to that
-;;   multifile-replace.
+;;   of past operations, so you can perform a fileloop-search while in the
+;;   middle of a fileloop-replace and later go back to that
+;;   fileloop-replace.
 ;; - Make multi-isearch work on top of this library (might require changes
 ;;   to this library, of course).
 
@@ -36,12 +36,12 @@
 
 (require 'generator)
 
-(defgroup multifile nil
+(defgroup fileloop nil
   "Operations on multiple files."
   :group 'tools)
 
-(defcustom multifile-revert-buffers 'silent
-  "Whether to revert files during multifile operation.
+(defcustom fileloop-revert-buffers 'silent
+  "Whether to revert files during fileloop operation.
   `silent' means to only do it if `revert-without-query' is applicable;
   t        means to offer to do it for all applicable files;
   nil      means never to do it"
@@ -49,17 +49,17 @@
 
 ;; FIXME: This already exists in GNU ELPA's iterator.el.  Maybe it should move
 ;; to generator.el?
-(iter-defun multifile--list-to-iterator (list)
+(iter-defun fileloop--list-to-iterator (list)
   (while list (iter-yield (pop list))))
 
-(defvar multifile--iterator iter-empty)
-(defvar multifile--scan-function
+(defvar fileloop--iterator iter-empty)
+(defvar fileloop--scan-function
   (lambda () (user-error "No operation in progress")))
-(defvar multifile--operate-function #'ignore)
-(defvar multifile--freshly-initialized nil)
+(defvar fileloop--operate-function #'ignore)
+(defvar fileloop--freshly-initialized nil)
 
 ;;;###autoload
-(defun multifile-initialize (files scan-function operate-function)
+(defun fileloop-initialize (files scan-function operate-function)
   "Initialize a new round of operation on several files.
 FILES can be either a list of file names, or an iterator (used with 
`iter-next')
 which returns a file name at each step.
@@ -69,18 +69,18 @@ OPERATE-FUNCTION is a function called with no argument; it 
is expected
 to perform the operation on the current file buffer and when done
 should return non-nil to mean that we should immediately continue
 operating on the next file and nil otherwise."
-  (setq multifile--iterator
+  (setq fileloop--iterator
         (if (and (listp files) (not (functionp files)))
-            (multifile--list-to-iterator files)
+            (fileloop--list-to-iterator files)
           files))
-  (setq multifile--scan-function scan-function)
-  (setq multifile--operate-function operate-function)
-  (setq multifile--freshly-initialized t))
+  (setq fileloop--scan-function scan-function)
+  (setq fileloop--operate-function operate-function)
+  (setq fileloop--freshly-initialized t))
 
-(defun multifile-next-file (&optional novisit)
+(defun fileloop-next-file (&optional novisit)
   ;; FIXME: Should we provide an interactive command, like tags-next-file?
   (let ((next (condition-case nil
-                  (iter-next multifile--iterator)
+                  (iter-next fileloop--iterator)
                 (iter-end-of-sequence nil))))
     (unless next
       (and novisit
@@ -91,9 +91,9 @@ operating on the next file and nil otherwise."
           (new (not buffer)))
       ;; Optionally offer to revert buffers
       ;; if the files have changed on disk.
-      (and buffer multifile-revert-buffers
+      (and buffer fileloop-revert-buffers
           (not (verify-visited-file-modtime buffer))
-           (if (eq multifile-revert-buffers 'silent)
+           (if (eq fileloop-revert-buffers 'silent)
                (and (not (buffer-modified-p buffer))
                     (let ((revertible nil))
                       (dolist (re revert-without-query)
@@ -118,7 +118,7 @@ operating on the next file and nil otherwise."
         (insert-file-contents new nil))
       new)))
 
-(defun multifile-continue ()
+(defun fileloop-continue ()
   "Continue last multi-file operation."
   (interactive)
   (let (new
@@ -131,10 +131,10 @@ operating on the next file and nil otherwise."
        (progn
          ;; Scan files quickly for the first or next interesting one.
          ;; This starts at point in the current buffer.
-         (while (or multifile--freshly-initialized file-finished
+         (while (or fileloop--freshly-initialized file-finished
                     (save-restriction
                       (widen)
-                      (not (funcall multifile--scan-function))))
+                      (not (funcall fileloop--scan-function))))
            ;; If nothing was found in the previous file, and
            ;; that file isn't in a temp buffer, restore point to
            ;; where it was.
@@ -142,17 +142,17 @@ operating on the next file and nil otherwise."
              (goto-char original-point))
 
            (setq file-finished nil)
-           (setq new (multifile-next-file t))
+           (setq new (fileloop-next-file t))
 
            ;; If NEW is non-nil, we got a temp buffer,
            ;; and NEW is the file name.
            (when (or messaged
-                     (and (not multifile--freshly-initialized)
+                     (and (not fileloop--freshly-initialized)
                           (> baud-rate search-slow-speed)
                           (setq messaged t)))
              (message "Scanning file %s..." (or new buffer-file-name)))
 
-           (setq multifile--freshly-initialized nil)
+           (setq fileloop--freshly-initialized nil)
            (setq original-point (if new nil (point)))
            (goto-char (point-min)))
 
@@ -172,13 +172,13 @@ operating on the next file and nil otherwise."
          ;; If value is non-nil, continue to scan the next file.
           (save-restriction
             (widen)
-            (funcall multifile--operate-function)))
+            (funcall fileloop--operate-function)))
       (setq file-finished t))))
 
 ;;;###autoload
-(defun multifile-initialize-search (regexp files case-fold)
+(defun fileloop-initialize-search (regexp files case-fold)
   (let ((last-buffer (current-buffer)))
-    (multifile-initialize
+    (fileloop-initialize
      files
      (lambda ()
        (let ((case-fold-search
@@ -191,16 +191,16 @@ operating on the next file and nil otherwise."
        nil))))
 
 ;;;###autoload
-(defun multifile-initialize-replace (from to files case-fold &optional 
delimited)
+(defun fileloop-initialize-replace (from to files case-fold &optional 
delimited)
   "Initialize a new round of query&replace on several files.
 FROM is a regexp and TO is the replacement to use.
-FILES describes the file, as in `multifile-initialize'.
+FILES describes the file, as in `fileloop-initialize'.
 CASE-FOLD can be t, nil, or `default', the latter one meaning to obey
 the default setting of `case-fold-search'.
 DELIMITED if non-nil means replace only word-delimited matches."
   ;; FIXME: Not sure how the delimited-flag interacts with the regexp-flag in
   ;; `perform-replace', so I just try to mimic the old code.
-  (multifile-initialize
+  (fileloop-initialize
    files
    (lambda ()
      (let ((case-fold-search
@@ -213,5 +213,5 @@ DELIMITED if non-nil means replace only word-delimited 
matches."
    (lambda ()
      (perform-replace from to t t delimited nil multi-query-replace-map))))
 
-(provide 'multifile)
-;;; multifile.el ends here
+(provide 'fileloop)
+;;; fileloop.el ends here
diff --git a/lisp/filenotify.el b/lisp/filenotify.el
index a133f9e..62dd1cd 100644
--- a/lisp/filenotify.el
+++ b/lisp/filenotify.el
@@ -1,6 +1,6 @@
 ;;; filenotify.el --- watch files for changes on disk  -*- lexical-binding:t 
-*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 
@@ -49,7 +49,7 @@ could use another implementation.")
   directory
   ;; Watched relative filename, nil if watching the directory.
   filename
-  ;; Function to propagate events to.
+  ;; Function to propagate events to, or nil if watch is being removed.
   callback)
 
 (defun file-notify--watch-absolute-filename (watch)
@@ -72,12 +72,15 @@ struct.")
 DESCRIPTOR should be an object returned by `file-notify-add-watch'.
 If it is registered in `file-notify-descriptors', a stopped event is sent."
   (when-let* ((watch (gethash descriptor file-notify-descriptors)))
-    ;; Send `stopped' event.
-    (unwind-protect
-        (funcall
-         (file-notify--watch-callback watch)
-         `(,descriptor stopped ,(file-notify--watch-absolute-filename watch)))
-      (remhash descriptor file-notify-descriptors))))
+    (let ((callback (file-notify--watch-callback watch)))
+      ;; Make sure this is the last time the callback is invoked.
+      (setf (file-notify--watch-callback watch) nil)
+      ;; Send `stopped' event.
+      (unwind-protect
+          (funcall
+           callback
+           `(,descriptor stopped ,(file-notify--watch-absolute-filename 
watch)))
+        (remhash descriptor file-notify-descriptors)))))
 
 ;; This function is used by `inotify', `kqueue', `gfilenotify' and
 ;; `w32notify' events.
@@ -114,7 +117,7 @@ Could be different from the directory watched by the 
backend library."
   (when-let* ((watch (gethash (car event) file-notify-descriptors)))
     (directory-file-name
      (expand-file-name
-      (or  (and (stringp (nth 2 event)) (nth 2 event)) "")
+      (or (and (stringp (nth 2 event)) (nth 2 event)) "")
       (file-notify--watch-directory watch)))))
 
 ;; Only `gfilenotify' could return two file names.
@@ -240,8 +243,10 @@ EVENT is the cadr of the event in 
`file-notify-handle-event'
                             (file-notify--watch-filename watch)
                             (file-name-nondirectory file1)))))
             ;;(message
-            ;;"file-notify-callback %S %S %S %S %S"
-            ;;desc action file file1 watch)
+            ;;"file-notify-callback %S %S %S %S %S %S %S"
+            ;;desc action file file1 watch
+            ;;(file-notify--event-watched-file event)
+            ;;(file-notify--watch-directory watch))
             (funcall (file-notify--watch-callback watch)
                      (if file1
                          `(,desc ,action ,file ,file1)
@@ -379,25 +384,27 @@ FILE is the name of the file whose event is being 
reported."
   "Remove an existing watch specified by its DESCRIPTOR.
 DESCRIPTOR should be an object returned by `file-notify-add-watch'."
   (when-let* ((watch (gethash descriptor file-notify-descriptors)))
-    (let ((handler (find-file-name-handler
-                    (file-notify--watch-directory watch)
-                    'file-notify-rm-watch)))
-      (condition-case nil
-          (if handler
-              ;; A file name handler could exist even if there is no
-              ;; local file notification support.
-              (funcall handler 'file-notify-rm-watch descriptor)
-
-            (funcall
-             (cond
-              ((eq file-notify--library 'inotify) 'inotify-rm-watch)
-              ((eq file-notify--library 'kqueue) 'kqueue-rm-watch)
-              ((eq file-notify--library 'gfilenotify) 'gfile-rm-watch)
-              ((eq file-notify--library 'w32notify) 'w32notify-rm-watch))
-             descriptor))
-        (file-notify-error nil)))
-    ;; Modify `file-notify-descriptors'.
-    (file-notify--rm-descriptor descriptor)))
+    ;; If we are called from a `stopped' event, do nothing.
+    (when (file-notify--watch-callback watch)
+      (let ((handler (find-file-name-handler
+                      (file-notify--watch-directory watch)
+                      'file-notify-rm-watch)))
+        (condition-case nil
+            (if handler
+                ;; A file name handler could exist even if there is no
+                ;; local file notification support.
+                (funcall handler 'file-notify-rm-watch descriptor)
+
+              (funcall
+               (cond
+                ((eq file-notify--library 'inotify) 'inotify-rm-watch)
+                ((eq file-notify--library 'kqueue) 'kqueue-rm-watch)
+                ((eq file-notify--library 'gfilenotify) 'gfile-rm-watch)
+                ((eq file-notify--library 'w32notify) 'w32notify-rm-watch))
+               descriptor))
+          (file-notify-error nil)))
+      ;; Modify `file-notify-descriptors' and send a `stopped' event.
+      (file-notify--rm-descriptor descriptor))))
 
 (defun file-notify-valid-p (descriptor)
   "Check a watch specified by its DESCRIPTOR.
@@ -419,11 +426,9 @@ DESCRIPTOR should be an object returned by 
`file-notify-add-watch'."
               descriptor))
            t))))
 
-
 ;; TODO:
-;; * Watching a /dir/file may receive events for dir.
-;;   (This may be the desired behavior.)
-;; * Watching a file in an already watched directory
+
+;; * Watching a file in an already watched directory.
 ;;   If the file is created and *then* a watch is added to that file, the
 ;;   watch might receive events which occurred prior to it being created,
 ;;   due to the way events are propagated during idle time.  Note: This
diff --git a/lisp/files-x.el b/lisp/files-x.el
index 5d87a4e..b71e920 100644
--- a/lisp/files-x.el
+++ b/lisp/files-x.el
@@ -1,6 +1,6 @@
 ;;; files-x.el --- extended file handling commands
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Juri Linkov <address@hidden>
 ;; Maintainer: address@hidden
@@ -582,7 +582,7 @@ changed by the user.")
 (setq ignored-local-variables
       (cons 'connection-local-variables-alist ignored-local-variables))
 
-(defvar connection-local-profile-alist '()
+(defvar connection-local-profile-alist nil
   "Alist mapping connection profiles to variable lists.
 Each element in this list has the form (PROFILE VARIABLES).
 PROFILE is the name of a connection profile (a symbol).
@@ -590,7 +590,7 @@ VARIABLES is a list that declares connection-local 
variables for
 PROFILE.  An element in VARIABLES is an alist whose elements are
 of the form (VAR . VALUE).")
 
-(defvar connection-local-criteria-alist '()
+(defvar connection-local-criteria-alist nil
   "Alist mapping connection criteria to connection profiles.
 Each element in this list has the form (CRITERIA PROFILES).
 CRITERIA is a plist identifying a connection and the application
@@ -685,7 +685,12 @@ This does nothing if `enable-connection-local-variables' 
is nil."
       ;; Loop over variables.
       (dolist (variable (connection-local-get-profile-variables profile))
         (unless (assq (car variable) connection-local-variables-alist)
-          (push variable connection-local-variables-alist))))))
+          (push variable connection-local-variables-alist))))
+    ;; Push them to `file-local-variables-alist'.  Connection-local
+    ;; variables do not appear from external files.  So we can regard
+    ;; them as safe.
+    (let ((enable-local-variables :all))
+      (hack-local-variables-filter connection-local-variables-alist nil))))
 
 ;;;###autoload
 (defun hack-connection-local-variables-apply (criteria)
@@ -697,24 +702,35 @@ will not be changed."
         (copy-tree connection-local-variables-alist)))
    (hack-local-variables-apply)))
 
+(defsubst connection-local-criteria-for-default-directory ()
+  "Return a connection-local criteria, which represents `default-directory'."
+  (when (file-remote-p default-directory)
+    `(:application tramp
+       :protocol ,(file-remote-p default-directory 'method)
+       :user     ,(file-remote-p default-directory 'user)
+       :machine  ,(file-remote-p default-directory 'host))))
+
 ;;;###autoload
-(defmacro with-connection-local-profiles (profiles &rest body)
-  "Apply connection-local variables according to PROFILES in current buffer.
+(defmacro with-connection-local-variables (&rest body)
+  "Apply connection-local variables according to `default-directory'.
 Execute BODY, and unwind connection-local variables."
-  (declare (indent 1) (debug t))
-  `(let ((enable-connection-local-variables t)
-         (old-buffer-local-variables (buffer-local-variables))
-        connection-local-variables-alist connection-local-criteria-alist)
-     (apply 'connection-local-set-profiles nil ,profiles)
-     (hack-connection-local-variables-apply nil)
-     (unwind-protect
-         (progn ,@body)
-       ;; Cleanup.
-       (dolist (variable connection-local-variables-alist)
-        (let ((elt (assq (car variable) old-buffer-local-variables)))
-          (if elt
-              (set (make-local-variable (car elt)) (cdr elt))
-           (kill-local-variable (car variable))))))))
+  (declare (debug t))
+  `(if (file-remote-p default-directory)
+       (let ((enable-connection-local-variables t)
+             (old-buffer-local-variables (buffer-local-variables))
+            connection-local-variables-alist)
+        (hack-connection-local-variables-apply
+         (connection-local-criteria-for-default-directory))
+        (unwind-protect
+             (progn ,@body)
+          ;; Cleanup.
+          (dolist (variable connection-local-variables-alist)
+            (let ((elt (assq (car variable) old-buffer-local-variables)))
+              (if elt
+                  (set (make-local-variable (car elt)) (cdr elt))
+                (kill-local-variable (car variable)))))))
+     ;; No connection-local variables to apply.
+     ,@body))
 
 
 
diff --git a/lisp/files.el b/lisp/files.el
index fb6cf01..c05d70a 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1,6 +1,6 @@
 ;;; files.el --- file input and output commands for Emacs  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1985-1987, 1992-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1987, 1992-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Package: emacs
@@ -802,9 +802,15 @@ The path separator is colon in GNU and GNU-like systems."
     (setq cd-path (or (parse-colon-path (getenv "CDPATH"))
                       (list "./"))))
   (cd-absolute
-   (or (locate-file dir cd-path nil
-                    (lambda (f) (and (file-directory-p f) 'dir-ok)))
-       (error "No such directory found via CDPATH environment variable"))))
+   (or
+    ;; locate-file doesn't support remote file names, so detect them
+    ;; and support them here by hand.
+    (and (file-remote-p (expand-file-name dir))
+         (file-accessible-directory-p (expand-file-name dir))
+         (expand-file-name dir))
+    (locate-file dir cd-path nil
+                 (lambda (f) (and (file-directory-p f) 'dir-ok)))
+    (error "No such directory found via CDPATH environment variable"))))
 
 (defun directory-files-recursively (dir regexp &optional include-directories)
   "Return list of all files under DIR that have file names matching REGEXP.
@@ -863,7 +869,7 @@ This function will normally skip directories, so if you 
want it to find
 directories, make sure the PREDICATE function returns `dir-ok' for them.
 
 PREDICATE can also be an integer to pass to the `access' system call,
-in which case file-name handlers are ignored.  This usage is deprecated.
+in which case file name handlers are ignored.  This usage is deprecated.
 For compatibility, PREDICATE can also be one of the symbols
 `executable', `readable', `writable', or `exists', or a list of
 one or more of those symbols."
@@ -1003,7 +1009,7 @@ directory if it does not exist."
        ;; Make sure `user-emacs-directory' exists,
        ;; unless we're in batch mode or dumping Emacs.
        (or noninteractive
-          purify-flag
+           dump-mode
           (let (errtype)
             (if (file-directory-p user-emacs-directory)
                 (or (file-accessible-directory-p user-emacs-directory)
@@ -1052,7 +1058,8 @@ REMOTE is non-nil, search on the remote host indicated by
         (when (stringp res) (file-local-name res)))
     ;; Use 1 rather than file-executable-p to better match the
     ;; behavior of call-process.
-    (locate-file command exec-path exec-suffixes 1)))
+    (let ((default-directory (file-name-quote default-directory 'top)))
+      (locate-file command exec-path exec-suffixes 1))))
 
 (defun load-library (library)
   "Load the Emacs Lisp library named LIBRARY.
@@ -1167,7 +1174,10 @@ consecutive checks.  For example:
 
 (defun file-local-name (file)
   "Return the local name component of FILE.
-It returns a file name which can be used directly as argument of
+This function removes from FILE the specification of the remote host
+and the method of accessing the host, leaving only the part that
+identifies FILE locally on the remote system.
+The returned file name can be used directly as argument of
 `process-file', `start-file-process', or `shell-command'."
   (or (file-remote-p file 'localname) file))
 
@@ -1193,10 +1203,11 @@ names beginning with `~'."
   "Splice DIRNAME to FILE like the operating system would.
 If FILE is relative, return DIRNAME concatenated to FILE.
 Otherwise return FILE, quoted as needed if DIRNAME and FILE have
-different handlers; although this quoting is dubious if DIRNAME
-is magic, it is not clear what would be better.  This function
-differs from `expand-file-name' in that DIRNAME must be a
-directory name and leading `~' and `/:' are not special in FILE."
+different file name handlers; although this quoting is dubious if
+DIRNAME is magic, it is not clear what would be better.  This
+function differs from `expand-file-name' in that DIRNAME must be
+a directory name and leading `~' and `/:' are not special in
+FILE."
   (let ((unquoted (if (files--name-absolute-system-p file)
                      file
                    (concat dirname file))))
@@ -2695,9 +2706,8 @@ 
ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|CBR\\|7Z\\)\\'" . archive-mo
      ("\\.dbk\\'" . xml-mode)
      ("\\.dtd\\'" . sgml-mode)
      ("\\.ds\\(ss\\)?l\\'" . dsssl-mode)
-     ("\\.jsm?\\'" . javascript-mode)
+     ("\\.js[mx]?\\'" . javascript-mode)
      ("\\.json\\'" . javascript-mode)
-     ("\\.jsx\\'" . js-jsx-mode)
      ("\\.[ds]?vh?\\'" . verilog-mode)
      ("\\.by\\'" . bovine-grammar-mode)
      ("\\.wy\\'" . wisent-grammar-mode)
@@ -3580,6 +3590,11 @@ local variables, but directory-local variables may still 
be applied."
        result)
     (unless (eq handle-mode t)
       (setq file-local-variables-alist nil)
+      (when (file-remote-p default-directory)
+        (with-demoted-errors "Connection-local variables error: %s"
+         ;; Note this is a no-op if enable-local-variables is nil.
+         (hack-connection-local-variables
+           (connection-local-criteria-for-default-directory))))
       (with-demoted-errors "Directory-local variables error: %s"
        ;; Note this is a no-op if enable-local-variables is nil.
        (hack-dir-local-variables)))
@@ -6301,7 +6316,7 @@ See also `auto-save-file-name-p'."
       ;; We do this on all platforms, because even if we are not
       ;; running on DOS/Windows, the current directory may be on a
       ;; mounted VFAT filesystem, such as a USB memory stick.
-      (while (string-match "[^A-Za-z0-9-_.~#+]" buffer-name limit)
+      (while (string-match "[^A-Za-z0-9_.~#+-]" buffer-name limit)
        (let* ((character (aref buffer-name (match-beginning 0)))
               (replacement
                 ;; For multibyte characters, this will produce more than
@@ -6738,7 +6753,7 @@ Valid wildcards are '*', '?', '[abc]' and '[a-z]'."
 ;;              dired-after-subdir-garbage (defines what a "total" line is)
 ;;   - variable dired-subdir-regexp
 ;; - may be passed "--dired" as the first argument in SWITCHES.
-;;   Filename handlers might have to remove this switch if their
+;;   File name handlers might have to remove this switch if their
 ;;   "ls" command does not support it.
 (defun insert-directory (file switches &optional wildcard full-directory-p)
   "Insert directory listing for FILE, formatted according to SWITCHES.
@@ -7103,7 +7118,8 @@ only these files will be asked to be saved."
         (default-directory
          (if (memq operation
                     '(insert-directory process-file start-file-process
-                                       shell-command temporary-file-directory))
+                                       make-process shell-command
+                                       temporary-file-directory))
              (directory-file-name
               (expand-file-name
                (unhandled-file-name-directory default-directory)))
@@ -7151,7 +7167,13 @@ only these files will be asked to be saved."
                           ;; These file-notify-* operations take a
                           ;; descriptor.
                           (file-notify-rm-watch)
-                          (file-notify-valid-p)))
+                          (file-notify-valid-p)
+                          ;; `make-process' uses keyword arguments and
+                          ;; doesn't mangle its filenames in any way.
+                          ;; It already strips /: from the binary
+                          ;; filename, so we don't have to do this
+                          ;; here.
+                          (make-process)))
                  ;; For all other operations, treat the first
                  ;; argument only as the file name.
                  '(nil 0))))
diff --git a/lisp/filesets.el b/lisp/filesets.el
index 8243b40..b74b4a8 100644
--- a/lisp/filesets.el
+++ b/lisp/filesets.el
@@ -1,6 +1,6 @@
 ;;; filesets.el --- handle group of files
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Thomas Link <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/find-cmd.el b/lisp/find-cmd.el
index 7a4e81e..66b850a 100644
--- a/lisp/find-cmd.el
+++ b/lisp/find-cmd.el
@@ -1,6 +1,6 @@
 ;;; find-cmd.el --- Build a valid find(1) command with sexps
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Philip Jackson <address@hidden>
 ;; Version: 0.6
diff --git a/lisp/find-dired.el b/lisp/find-dired.el
index 9a798b0..ef137be 100644
--- a/lisp/find-dired.el
+++ b/lisp/find-dired.el
@@ -1,6 +1,6 @@
 ;;; find-dired.el --- run a `find' command and dired the output  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1992, 1994-1995, 2000-2018 Free Software Foundation,
+;; Copyright (C) 1992, 1994-1995, 2000-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Roland McGrath <address@hidden>,
@@ -175,7 +175,7 @@ use in place of \"-ls\" as the final argument."
                          " " args " "
                          (shell-quote-argument ")")
                          " "))
-                      (if (string-match "\\`\\(.*\\) {} \\(\\\\;\\|+\\)\\'"
+                      (if (string-match "\\`\\(.*\\) {} \\(\\\\;\\|\\+\\)\\'"
                                         (car find-ls-option))
                           (format "%s %s %s"
                                   (match-string 1 (car find-ls-option))
diff --git a/lisp/find-file.el b/lisp/find-file.el
index bda6204..8731408 100644
--- a/lisp/find-file.el
+++ b/lisp/find-file.el
@@ -4,7 +4,7 @@
 ;; Maintainer: address@hidden
 ;; Keywords: c, matching, tools
 
-;; Copyright (C) 1994-1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/lisp/find-lisp.el b/lisp/find-lisp.el
index a3e4511..073e2bc 100644
--- a/lisp/find-lisp.el
+++ b/lisp/find-lisp.el
@@ -4,7 +4,7 @@
 ;; Created: Fri Mar 26 1999
 ;; Keywords: unix
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -342,16 +342,11 @@ list of ls option letters of which c and u are 
recognized).  Use
 the same method as \"ls\" to decide whether to show time-of-day or
 year, depending on distance between file date and NOW."
   (let* ((time (nth (find-lisp-time-index switches) file-attr))
-        (diff16 (- (car time) (car now)))
-        (diff (+ (ash diff16 16) (- (car (cdr time)) (car (cdr now)))))
-        (past-cutoff (- (* 6 30 24 60 60)))    ; 6 30-day months
+        (diff (encode-time (time-subtract time now) 'integer))
+        (past-cutoff -15778476)                ; 1/2 of a Gregorian year
         (future-cutoff (* 60 60)))             ; 1 hour
     (format-time-string
-     (if (and
-         (<= past-cutoff diff) (<= diff future-cutoff)
-         ;; Sanity check in case `diff' computation overflowed.
-         (<= (1- (ash past-cutoff -16)) diff16)
-         (<= diff16 (1+ (ash future-cutoff -16))))
+     (if (<= past-cutoff diff future-cutoff)
         "%b %e %H:%M"
        "%b %e  %Y")
      time)))
diff --git a/lisp/finder.el b/lisp/finder.el
index 7a642c7..54a0758 100644
--- a/lisp/finder.el
+++ b/lisp/finder.el
@@ -1,6 +1,6 @@
 ;;; finder.el --- topic & keyword-based code finder
 
-;; Copyright (C) 1992, 1997-1999, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1992, 1997-1999, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Eric S. Raymond <address@hidden>
diff --git a/lisp/flow-ctrl.el b/lisp/flow-ctrl.el
index 17ee283..e92b6b4 100644
--- a/lisp/flow-ctrl.el
+++ b/lisp/flow-ctrl.el
@@ -1,6 +1,6 @@
 ;;; flow-ctrl.el --- help for lusers on cu(1) or ttys with wired-in ^S/^Q flow 
control
 
-;; Copyright (C) 1990-1991, 1994, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1990-1991, 1994, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Kevin Gallagher
diff --git a/lisp/foldout.el b/lisp/foldout.el
index 34e3c6d..3ef88fe 100644
--- a/lisp/foldout.el
+++ b/lisp/foldout.el
@@ -1,6 +1,6 @@
 ;;; foldout.el --- folding extensions for outline-mode and outline-minor-mode
 
-;; Copyright (C) 1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Kevin Broadey <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/follow.el b/lisp/follow.el
index ed7b7d2..acc2b26 100644
--- a/lisp/follow.el
+++ b/lisp/follow.el
@@ -1,6 +1,6 @@
 ;;; follow.el --- synchronize windows showing the same buffer
 
-;; Copyright (C) 1995-1997, 1999, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1995-1997, 1999, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Anders Lindgren
diff --git a/lisp/font-core.el b/lisp/font-core.el
index c5b036e..6b26f0c 100644
--- a/lisp/font-core.el
+++ b/lisp/font-core.el
@@ -1,6 +1,6 @@
 ;;; font-core.el --- Core interface to font-lock
 
-;; Copyright (C) 1992-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: languages, faces
diff --git a/lisp/font-lock.el b/lisp/font-lock.el
index b4cf5b0..1475911 100644
--- a/lisp/font-lock.el
+++ b/lisp/font-lock.el
@@ -1,6 +1,6 @@
-;;; font-lock.el --- Electric font lock mode
+;;; font-lock.el --- Electric font lock mode  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1992-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992-2019 Free Software Foundation, Inc.
 
 ;; Author: Jamie Zawinski
 ;;     Richard Stallman
@@ -656,7 +656,7 @@ be enabled."
       (cond (font-lock-fontified
             nil)
            ((or (null max-size) (> max-size (buffer-size)))
-            (font-lock-fontify-buffer))
+             (with-no-warnings (font-lock-fontify-buffer)))
            (font-lock-verbose
             (message "Fontifying %s...buffer size greater than 
font-lock-maximum-size"
                      (buffer-name)))))))
@@ -1093,14 +1093,10 @@ accessible portion of the current buffer."
                 (or beg (point-min)) (or end (point-max)))))
 
 (defvar font-lock-ensure-function
-  (lambda (_beg _end)
+  (lambda (beg end)
     (unless font-lock-fontified
-      (font-lock-default-fontify-buffer)
-      (unless font-lock-mode
-        ;; If font-lock is not enabled, we don't have the hooks in place to
-        ;; track modifications, so a subsequent call to font-lock-ensure can't
-        ;; assume that the fontification is still valid.
-        (setq font-lock-fontified nil))))
+      (save-excursion
+        (font-lock-fontify-region (or beg (point-min)) (or end (point-max))))))
   "Function to make sure a region has been fontified.
 Called with two arguments BEG and END.")
 
@@ -1784,7 +1780,7 @@ If SYNTACTIC-KEYWORDS is non-nil, it means these keywords 
are used for
          (cons t (cons keywords
                        (mapcar #'font-lock-compile-keyword keywords))))
     (if (and (not syntactic-keywords)
-            (let ((beg-function syntax-begin-function))
+            (let ((beg-function (with-no-warnings syntax-begin-function)))
               (or (eq beg-function #'beginning-of-defun)
                    (if (symbolp beg-function)
                        (get beg-function 'font-lock-syntax-paren-check))))
diff --git a/lisp/format-spec.el b/lisp/format-spec.el
index 38ce69b..4455c59 100644
--- a/lisp/format-spec.el
+++ b/lisp/format-spec.el
@@ -1,6 +1,6 @@
 ;;; format-spec.el --- functions for formatting arbitrary formatting strings
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: tools
diff --git a/lisp/format.el b/lisp/format.el
index 49d3c71..93f131b 100644
--- a/lisp/format.el
+++ b/lisp/format.el
@@ -1,6 +1,6 @@
 ;;; format.el --- read and save files in multiple formats
 
-;; Copyright (C) 1994-1995, 1997, 1999, 2001-2018 Free Software
+;; Copyright (C) 1994-1995, 1997, 1999, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Boris Goldowsky <address@hidden>
diff --git a/lisp/forms.el b/lisp/forms.el
index dba9b36..a85ee94 100644
--- a/lisp/forms.el
+++ b/lisp/forms.el
@@ -1,6 +1,6 @@
 ;;; forms.el --- Forms mode: edit a file as a form to fill in
 
-;; Copyright (C) 1991, 1994-1997, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1991, 1994-1997, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Johan Vromans <address@hidden>
diff --git a/lisp/frame.el b/lisp/frame.el
index 56b8c54..539a0f4 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -1,6 +1,6 @@
 ;;; frame.el --- multi-frame management independent of window systems  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1993-1994, 1996-1997, 2000-2018 Free Software
+;; Copyright (C) 1993-1994, 1996-1997, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
@@ -316,10 +316,15 @@ there (in decreasing order of priority)."
   ;; want to use save-excursion here, because that may also try to set
   ;; the buffer of the selected window, which fails when the selected
   ;; window is the minibuffer.
-  (let ((old-buffer (current-buffer))
-       (window-system-frame-alist
-         (cdr (assq initial-window-system
-                    window-system-default-frame-alist))))
+  (let* ((old-buffer (current-buffer))
+        (window-system-frame-alist
+          (cdr (assq initial-window-system
+                     window-system-default-frame-alist)))
+         (minibuffer
+          (cdr (or (assq 'minibuffer initial-frame-alist)
+                  (assq 'minibuffer window-system-frame-alist)
+                  (assq 'minibuffer default-frame-alist)
+                  '(minibuffer . t)))))
 
     (when (and frame-notice-user-settings
               (null frame-initial-frame))
@@ -410,11 +415,7 @@ there (in decreasing order of priority)."
       ;; default-frame-alist in the parameters of the screen we
       ;; create here, so that its new value, gleaned from the user's
       ;; init file, will be applied to the existing screen.
-      (if (not (eq (cdr (or (assq 'minibuffer initial-frame-alist)
-                           (assq 'minibuffer window-system-frame-alist)
-                           (assq 'minibuffer default-frame-alist)
-                           '(minibuffer . t)))
-                  t))
+      (if (not (eq minibuffer t))
          ;; Create the new frame.
          (let (parms new)
            ;; MS-Windows needs this to avoid inflooping below.
@@ -442,7 +443,15 @@ there (in decreasing order of priority)."
                                parms
                                nil))
 
-           ;; Get rid of `reverse', because that was handled
+           (when (eq minibuffer 'child-frame)
+              ;; When the minibuffer shall be shown in a child frame,
+              ;; remove the 'minibuffer' parameter from PARMS.  It
+              ;; will get assigned by the usual routines to the child
+              ;; frame's root window below.
+              (setq parms (cons '(minibuffer)
+                               (delq (assq 'minibuffer parms) parms))))
+
+            ;; Get rid of `reverse', because that was handled
            ;; when we first made the frame.
            (setq parms (cons '(reverse) (delq (assq 'reverse parms) parms)))
 
@@ -465,7 +474,18 @@ there (in decreasing order of priority)."
            ;; the only frame with a minibuffer.  If it is, create a
            ;; new one.
            (or (delq frame-initial-frame (minibuffer-frame-list))
-               (make-initial-minibuffer-frame nil))
+                (and (eq minibuffer 'child-frame)
+                     ;; Create a minibuffer child frame and parent it
+                     ;; immediately.  Take any other parameters for
+                     ;; the child frame from 'minibuffer-frame-list'.
+                     (let* ((minibuffer-frame-alist
+                             (cons `(parent-frame . ,new) 
minibuffer-frame-alist)))
+                       (make-initial-minibuffer-frame nil)
+                       ;; With a minibuffer child frame we do not want
+                       ;; to select the minibuffer frame initially as
+                       ;; we do for standard minibuffer-only frames.
+                       (select-frame new)))
+                (make-initial-minibuffer-frame nil))
 
            ;; If the initial frame is serving as a surrogate
            ;; minibuffer frame for any frames, we need to wean them
@@ -644,9 +664,39 @@ Return nil if we don't know how to interpret DISPLAY."
 (defun make-frame-on-display (display &optional parameters)
   "Make a frame on display DISPLAY.
 The optional argument PARAMETERS specifies additional frame parameters."
-  (interactive "sMake frame on display: ")
+  (interactive (list (completing-read
+                      (format "Make frame on display: ")
+                      (delete-dups
+                       (mapcar (lambda (frame)
+                                 (frame-parameter frame 'display))
+                               (frame-list))))))
   (make-frame (cons (cons 'display display) parameters)))
 
+(defun make-frame-on-monitor (monitor &optional display parameters)
+  "Make a frame on monitor MONITOR.
+The optional argument DISPLAY can be a display name, and the optional
+argument PARAMETERS specifies additional frame parameters."
+  (interactive
+   (list
+    (let* ((default (cdr (assq 'name (frame-monitor-attributes)))))
+      (completing-read
+       (format "Make frame on monitor (default %s): " default)
+       (or (delq nil (mapcar (lambda (a)
+                               (cdr (assq 'name a)))
+                             (display-monitor-attributes-list)))
+           '(""))
+       nil nil nil nil default))))
+  (let* ((monitor-workarea
+          (catch 'done
+            (dolist (a (display-monitor-attributes-list display))
+              (when (equal (cdr (assq 'name a)) monitor)
+                (throw 'done (cdr (assq 'workarea a)))))))
+         (geometry-parameters
+          (when monitor-workarea
+            `((top . ,(nth 1 monitor-workarea))
+              (left . ,(nth 0 monitor-workarea))))))
+    (make-frame (append geometry-parameters parameters))))
+
 (declare-function x-close-connection "xfns.c" (terminal))
 
 (defun close-display-connection (display)
@@ -682,7 +732,9 @@ If DISPLAY is nil, that stands for the selected frame's 
display."
 (defun make-frame-command ()
   "Make a new frame, on the same terminal as the selected frame.
 If the terminal is a text-only terminal, this also selects the
-new frame."
+new frame.
+
+When called from Lisp, returns the new frame."
   (interactive)
   (if (display-graphic-p)
       (make-frame)
@@ -761,7 +813,7 @@ the new frame according to its own rules."
              (t window-system)))
         (oldframe (selected-frame))
         (params parameters)
-        frame)
+        frame child-frame)
 
     (unless (get w 'window-system-initialized)
       (let ((window-system w))          ;Hack attack!
@@ -777,17 +829,44 @@ the new frame according to its own rules."
     (dolist (p default-frame-alist)
       (unless (assq (car p) params)
        (push p params)))
-    ;; Now make the frame.
-    (run-hooks 'before-make-frame-hook)
 
 ;;     (setq frame-size-history '(1000))
 
-    (setq frame (let ((window-system w)) ;Hack attack!
+    (when (eq (cdr (or (assq 'minibuffer params) '(minibuffer . t)))
+              'child-frame)
+      ;; If the 'minibuffer' parameter equals 'child-frame' make a
+      ;; frame without minibuffer first using the root window of
+      ;; 'default-minibuffer-frame' as its minibuffer window
+      (setq child-frame t)
+      (setq params (cons '(minibuffer)
+                         (delq (assq 'minibuffer params) params))))
+
+    ;; Now make the frame.
+    (run-hooks 'before-make-frame-hook)
+
+    (setq frame (let ((window-system w)) ; Hack attack!
                   (frame-creation-function params)))
+
+    (when child-frame
+      ;; When we want to equip the new frame with a minibuffer-only
+      ;; child frame, make that frame and reparent it immediately.
+      (setq child-frame
+            (make-frame
+             (append
+              `((display . ,display) (minibuffer . only)
+                (parent-frame . ,frame))
+              minibuffer-frame-alist)))
+      (when (frame-live-p child-frame)
+        ;; Have the 'minibuffer' parameter of our new frame refer to
+        ;; its child frame's root window.
+        (set-frame-parameter
+         frame 'minibuffer (frame-root-window child-frame))))
+
     (normal-erase-is-backspace-setup-frame frame)
-    ;; Inherit the original frame's parameters.
+    ;; Inherit original frame's parameters unless they are overridden
+    ;; by explicit parameters.
     (dolist (param frame-inherited-parameters)
-      (unless (assq param parameters)   ;Overridden by explicit parameters.
+      (unless (assq param parameters)
         (let ((val (frame-parameter oldframe param)))
           (when val (set-frame-parameter frame param val)))))
 
@@ -895,7 +974,7 @@ recently selected windows nor the buffer list."
   (select-frame frame norecord)
   (raise-frame frame)
   ;; Ensure, if possible, that FRAME gets input focus.
-  (when (memq (window-system frame) '(x w32 ns))
+  (when (display-multi-frame-p frame)
     (x-focus-frame frame))
   ;; Move mouse cursor if necessary.
   (cond
@@ -948,16 +1027,15 @@ that variable should be nil."
   "Do whatever is right to suspend the current frame.
 Calls `suspend-emacs' if invoked from the controlling tty device,
 `suspend-tty' from a secondary tty device, and
-`iconify-or-deiconify-frame' from an X frame."
+`iconify-or-deiconify-frame' from a graphical frame."
   (interactive)
-  (let ((type (framep (selected-frame))))
-    (cond
-     ((memq type '(x ns w32)) (iconify-or-deiconify-frame))
-     ((eq type t)
-      (if (controlling-tty-p)
-         (suspend-emacs)
-       (suspend-tty)))
-     (t (suspend-emacs)))))
+  (cond
+   ((display-multi-frame-p) (iconify-or-deiconify-frame))
+   ((eq (framep (selected-frame)) t)
+    (if (controlling-tty-p)
+        (suspend-emacs)
+      (suspend-tty)))
+   (t (suspend-emacs))))
 
 (defun make-frame-names-alist ()
   ;; Only consider the frames on the same display.
@@ -1038,7 +1116,7 @@ face specs for the new background mode."
           (default-bg-mode
             (if (or (window-system frame)
                     (and tty-type
-                         (string-match "^\\(xterm\\|\\rxvt\\|dtterm\\|eterm\\)"
+                         (string-match "^\\(xterm\\|rxvt\\|dtterm\\|eterm\\)"
                                        tty-type)))
                 'light
               'dark))
@@ -1085,9 +1163,23 @@ face specs for the new background mode."
            ;; most faces are unmodified).
            (dolist (face (face-list))
              (and (not (get face 'face-override-spec))
-                  (not (face-spec-match-p face
-                                          (face-user-default-spec face)
-                                          (selected-frame)))
+                  (not (and
+                         ;; If the face was not yet realized for the
+                         ;; frame, face-spec-match-p will signal an
+                         ;; error, so treat such a missing face as
+                         ;; having a mismatched spec; the call to
+                         ;; face-spec-recalc below will then realize
+                         ;; the face for the frame.  This happens
+                         ;; during startup with -rv on the command
+                         ;; line for the initial frame, because frames
+                         ;; are not recorded in the pdump file.
+                         (assq face (frame-face-alist))
+                         (face-spec-match-p face
+                                            (face-user-default-spec face)
+                                            ;; FIXME: why selected-frame and
+                                            ;; not the frame that is the
+                                            ;; argument to this function?
+                                            (selected-frame))))
                   (push face locally-modified-faces)))
            ;; Now change to the new frame parameters
            (modify-frame-parameters frame params)
@@ -1518,14 +1610,16 @@ selected frame."
     (with-current-buffer (get-buffer-create "*frame-size-history*")
       (erase-buffer)
       (insert (format "Frame size history of %s\n" frame))
-      (while (listp (setq entry (pop history)))
+      (while (consp (setq entry (pop history)))
        (when (eq (car entry) frame)
           (pop entry)
           (insert (format "%s" (pop entry)))
           (move-to-column 24 t)
           (while entry
             (insert (format " %s" (pop entry))))
-          (insert "\n"))))))
+          (insert "\n")))
+      (unless frame-size-history
+        (insert "Frame size history is nil.\n")))))
 
 (declare-function x-frame-edges "xfns.c" (&optional frame type))
 (declare-function w32-frame-edges "w32fns.c" (&optional frame type))
@@ -1607,7 +1701,10 @@ keys and their meanings."
   (or frame (setq frame (selected-frame)))
   (cl-loop for attributes in (display-monitor-attributes-list frame)
           for frames = (cdr (assq 'frames attributes))
-          if (memq frame frames) return attributes))
+          if (memq frame frames) return attributes
+          ;; On broken frames monitor attributes,
+          ;; fall back to the last monitor.
+          finally return attributes))
 
 (defun frame-monitor-attribute (attribute &optional frame x y)
   "Return the value of ATTRIBUTE on FRAME's monitor.
@@ -1745,24 +1842,29 @@ for FRAME."
   (let* ((frame (window-normalize-frame frame))
          (root (frame-root-window frame))
          (mini (minibuffer-window frame))
-         (mini-height-before-size-change 0)
+         (mini-old-height 0)
          (mini-height 0))
     ;; FRAME's minibuffer window counts iff it's on FRAME and FRAME is
     ;; not a minibuffer-only frame.
     (when (and (eq (window-frame mini) frame) (not (eq mini root)))
-      (setq mini-height-before-size-change
-            (window-pixel-height-before-size-change mini))
+      (setq mini-old-height (window-old-pixel-height mini))
       (setq mini-height (window-pixel-height mini)))
     ;; Return non-nil when either the width of the root or the sum of
     ;; the heights of root and minibuffer window changed.
-    (or (/= (window-pixel-width-before-size-change root)
-            (window-pixel-width root))
-        (/= (+ (window-pixel-height-before-size-change root)
-               mini-height-before-size-change)
+    (or (/= (window-old-pixel-width root) (window-pixel-width root))
+        (/= (+ (window-old-pixel-height root) mini-old-height)
             (+ (window-pixel-height root) mini-height)))))
 
 ;;;; Frame/display capabilities.
 
+;; These functions should make the features they test explicit in
+;; their names, so that when capabilities or the corresponding Emacs
+;; features change, it will be easy to find all the tests for such
+;; capabilities by a simple text search.  See more about the history
+;; and the intent of these functions in
+;; http://lists.gnu.org/archive/html/bug-gnu-emacs/2019-04/msg00004.html
+;; or in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=35058#17.
+
 (declare-function msdos-mouse-p "dosfns.c")
 
 (defun display-mouse-p (&optional display)
@@ -1813,6 +1915,7 @@ frame's display)."
        (fboundp 'image-mask-p)
        (fboundp 'image-size)))
 
+(defalias 'display-blink-cursor-p 'display-graphic-p)
 (defalias 'display-multi-frame-p 'display-graphic-p)
 (defalias 'display-multi-font-p 'display-graphic-p)
 
@@ -1834,6 +1937,16 @@ frame's display)."
      (t
       nil))))
 
+(defun display-symbol-keys-p (&optional display)
+  "Return non-nil if DISPLAY supports symbol names as keys.
+This means that, for example, DISPLAY can differentiate between
+the keybinding RET and [return]."
+  (let ((frame-type (framep-on-display display)))
+    (or (memq frame-type '(x w32 ns pc))
+        ;; MS-DOS and MS-Windows terminals have built-in support for
+        ;; function (symbol) keys
+        (memq system-type '(ms-dos windows-nt)))))
+
 (declare-function x-display-screens "xfns.c" (&optional terminal))
 
 (defun display-screens (&optional display)
@@ -1990,7 +2103,7 @@ If DISPLAY is omitted or nil, it defaults to the selected 
frame's display."
      ((eq frame-type 'pc)
       4)
      (t
-      (truncate (log (length (tty-color-alist)) 2))))))
+      (logb (length (tty-color-alist)))))))
 
 (declare-function x-display-color-cells "xfns.c" (&optional terminal))
 
@@ -2453,7 +2566,7 @@ terminals, cursor blinking is controlled by the terminal."
   :init-value (not (or noninteractive
                       no-blinking-cursor
                       (eq system-type 'ms-dos)
-                      (not (memq window-system '(x w32 ns)))))
+                      (not (display-blink-cursor-p))))
   :initialize 'custom-initialize-delay
   :group 'cursor
   :global t
diff --git a/lisp/frameset.el b/lisp/frameset.el
index aa392be..3bc7375 100644
--- a/lisp/frameset.el
+++ b/lisp/frameset.el
@@ -1,6 +1,6 @@
 ;;; frameset.el --- save and restore frame and window setup -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Juanma Barranquero <address@hidden>
 ;; Keywords: convenience
diff --git a/lisp/fringe.el b/lisp/fringe.el
index 583a0e2..92387a2 100644
--- a/lisp/fringe.el
+++ b/lisp/fringe.el
@@ -1,6 +1,6 @@
 ;;; fringe.el --- fringe setup and control  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/generic-x.el b/lisp/generic-x.el
index d8a7fe3..c430be7 100644
--- a/lisp/generic-x.el
+++ b/lisp/generic-x.el
@@ -1,6 +1,6 @@
 ;;; generic-x.el --- A collection of generic modes
 
-;; Copyright (C) 1997-1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author:  Peter Breton <address@hidden>
 ;; Created: Tue Oct 08 1996
@@ -294,7 +294,7 @@ your changes into effect."
   nil
   nil
   ;; Hostname ? user date request return-code number-of-bytes
-  '(("^\\([-a-zA-z0-9.]+\\) - [-A-Za-z]+ \\(\\[.*\\]\\)"
+  '(("^\\([-a-zA-Z0-9.]+\\) - [-A-Za-z]+ \\(\\[.*\\]\\)"
      (1 font-lock-constant-face)
      (2 font-lock-variable-name-face)))
   '("access_log\\'")
@@ -1490,7 +1490,8 @@ like an INI file.  You can add this hook to 
`find-file-hook'."
      '("^\\([^:]+\\):\\([^:]*\\):\\([0-9]+\\):\\(.*\\)$"
        (1 font-lock-type-face)
        (4 font-lock-variable-name-face))))
-  '("/etc/passwd\\'" "/etc/group\\'")
+  ;; /etc/passwd- is a backup file for /etc/passwd, so is group- and shadow-
+  '("/etc/passwd-?\\'" "/etc/group-?\\'" "/etc/shadow-?\\'")
   (list
    (function
     (lambda ()
diff --git a/lisp/gnus/ChangeLog.1 b/lisp/gnus/ChangeLog.1
index 30fd75f..333da55 100644
--- a/lisp/gnus/ChangeLog.1
+++ b/lisp/gnus/ChangeLog.1
@@ -3702,7 +3702,7 @@
        * gnus.el: Quassia Gnus v0.1 is released.
 
 
-  Copyright (C) 1997-2018 Free Software Foundation, Inc.
+  Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/gnus/ChangeLog.2 b/lisp/gnus/ChangeLog.2
index b49a866..bc507d5 100644
--- a/lisp/gnus/ChangeLog.2
+++ b/lisp/gnus/ChangeLog.2
@@ -18538,7 +18538,7 @@
 
 See ChangeLog.1 for earlier changes.
 
-  Copyright (C) 2000-2002, 2004-2018 Free Software Foundation, Inc.
+  Copyright (C) 2000-2002, 2004-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/gnus/ChangeLog.3 b/lisp/gnus/ChangeLog.3
index f98a6dc..3bd9f89 100644
--- a/lisp/gnus/ChangeLog.3
+++ b/lisp/gnus/ChangeLog.3
@@ -26325,7 +26325,7 @@
 
 See ChangeLog.2 for earlier changes.
 
-  Copyright (C) 2004-2018 Free Software Foundation, Inc.
+  Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/gnus/canlock.el b/lisp/gnus/canlock.el
index 0bd47cd..7edc91a 100644
--- a/lisp/gnus/canlock.el
+++ b/lisp/gnus/canlock.el
@@ -1,6 +1,6 @@
 ;;; canlock.el --- functions for Cancel-Lock feature
 
-;; Copyright (C) 1998-1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-1999, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Katsumi Yamaoka <address@hidden>
 ;; Keywords: news, cancel-lock, hmac, sha1, rfc2104
diff --git a/lisp/gnus/deuglify.el b/lisp/gnus/deuglify.el
index 6286c53..2fdc34e 100644
--- a/lisp/gnus/deuglify.el
+++ b/lisp/gnus/deuglify.el
@@ -1,6 +1,6 @@
 ;;; deuglify.el --- deuglify broken Outlook (Express) articles
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Raymond Scholz <address@hidden>
 ;;         Thomas Steffen
diff --git a/lisp/gnus/gmm-utils.el b/lisp/gnus/gmm-utils.el
index 224299b..6e324f9 100644
--- a/lisp/gnus/gmm-utils.el
+++ b/lisp/gnus/gmm-utils.el
@@ -1,6 +1,6 @@
 ;;; gmm-utils.el --- Utility functions for Gnus, Message and MML
 
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Reiner Steib <address@hidden>
 ;; Keywords: news
diff --git a/lisp/gnus/gnus-agent.el b/lisp/gnus/gnus-agent.el
index 28d8ac6..9f7d2c9 100644
--- a/lisp/gnus/gnus-agent.el
+++ b/lisp/gnus/gnus-agent.el
@@ -1,6 +1,6 @@
 ;;; gnus-agent.el --- unplugged support for Gnus
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; This file is part of GNU Emacs.
@@ -225,7 +225,9 @@ NOTES:
 (defvar gnus-agent-overview-buffer nil)
 (defvar gnus-category-predicate-cache nil)
 (defvar gnus-category-group-cache nil)
-(defvar gnus-agent-spam-hashtb nil)
+(defvar gnus-agent-spam-hashtb nil
+  "Cache of message subjects for spam messages.
+Actually a hash table holding subjects mapped to t.")
 (defvar gnus-agent-file-name nil)
 (defvar gnus-agent-file-coding-system 'raw-text)
 (defvar gnus-agent-file-loading-cache nil)
@@ -274,7 +276,7 @@ NOTES:
 (defmacro gnus-agent-with-refreshed-group (group &rest body)
   "Performs the body then updates the group's line in the group
 buffer.  Automatically blocks multiple updates due to recursion."
-`(prog1 (let ((gnus-agent-inhibit-update-total-fetched-for t)) ,@body)
+  `(prog1 (let ((gnus-agent-inhibit-update-total-fetched-for t)) ,@body)
      (when (and gnus-agent-need-update-total-fetched-for
                (not gnus-agent-inhibit-update-total-fetched-for))
        (with-current-buffer gnus-group-buffer
@@ -309,9 +311,10 @@ buffer.  Automatically blocks multiple updates due to 
recursion."
 (defun gnus-agent-cat-set-property (category property value)
   (if value
       (setcdr (or (assq property category)
-              (let ((cell (cons property nil)))
+                  (let ((cell (cons property nil)))
                     (setcdr category (cons cell (cdr category)))
-                    cell)) value)
+                    cell))
+              value)
     (let ((category category))
       (while (cond ((eq property (caadr category))
                     (setcdr category (cddr category))
@@ -376,7 +379,8 @@ manipulated as follows:
              (setcdr (or (assq 'agent-groups category)
                          (let ((cell (cons 'agent-groups nil)))
                            (setcdr category (cons cell (cdr category)))
-                           cell)) new-g))
+                           cell))
+                     new-g))
             (t
              (let ((groups groups))
                (while groups
@@ -393,7 +397,8 @@ manipulated as follows:
              (setcdr (or (assq 'agent-groups category)
                          (let ((cell (cons 'agent-groups nil)))
                            (setcdr category (cons cell (cdr category)))
-                           cell)) groups))))))
+                           cell))
+                     groups))))))
 
 (defsubst gnus-agent-cat-make (name &optional default-agent-predicate)
   (list name `(agent-predicate . ,(or default-agent-predicate 'false))))
@@ -642,8 +647,8 @@ minor mode in all Gnus buffers."
 (defun gnus-agent-queue-setup (&optional group-name)
   "Make sure the queue group exists.
 Optional arg GROUP-NAME allows another group to be specified."
-  (unless (gnus-gethash (format "nndraft:%s" (or group-name "queue"))
-                       gnus-newsrc-hashtb)
+  (unless (gethash (format "nndraft:%s" (or group-name "queue"))
+                  gnus-newsrc-hashtb)
     (gnus-request-create-group (or group-name "queue") '(nndraft ""))
     (let ((gnus-level-default-subscribed 1))
       (gnus-subscribe-group (format "nndraft:%s" (or group-name "queue"))
@@ -1330,11 +1335,11 @@ downloaded into the agent."
           (when (re-search-forward
                  (concat "^" (regexp-quote group) " ") nil t)
             (save-excursion
-              (setq oactive-max (read (current-buffer))        ;; max
+              (setq oactive-max (read (current-buffer))          ;; max
                     oactive-min (read (current-buffer)))) ;; min
             (gnus-delete-line)))
        (when active
-         (insert (format "%S %d %d y\n" (intern group)
+         (insert (format "%s %d %d y\n" group
                          (max (or oactive-max (cdr active)) (cdr active))
                          (min (or oactive-min (car active)) (car active))))
          (goto-char (point-max))
@@ -1555,11 +1560,8 @@ downloaded into the agent."
                           (skip-chars-forward " ")
                           (setq crosses nil)
                           (while (looking-at "\\([^: \n]+\\):\\([0-9]+\\) *")
-                            (push (cons (buffer-substring (match-beginning 1)
-                                                          (match-end 1))
-                                        (string-to-number
-                                        (buffer-substring (match-beginning 2)
-                                                          (match-end 2))))
+                            (push (cons (match-string 1)
+                                        (string-to-number (match-string 2)))
                                   crosses)
                             (goto-char (match-end 0)))
                           (gnus-agent-crosspost crosses (caar pos) date)))
@@ -2161,7 +2163,10 @@ doesn't exist, to valid the overview buffer."
 
     (gnus-agent-update-view-total-fetched-for group nil)))
 
-(defvar gnus-agent-article-local nil)
+;; FIXME: Why would this be a hash table?  Wouldn't a simple alist or
+;; something suffice?
+(defvar gnus-agent-article-local nil
+  "Hashtable holding information about a group.")
 (defvar gnus-agent-article-local-times nil)
 (defvar gnus-agent-file-loading-local nil)
 
@@ -2173,12 +2178,12 @@ article counts for each of the method's subscribed 
groups."
              (zerop gnus-agent-article-local-times)
              (not (gnus-methods-equal-p
                    gnus-command-method
-                   (symbol-value (intern "+method" 
gnus-agent-article-local)))))
+                   (gethash "+method" gnus-agent-article-local))))
       (setq gnus-agent-article-local
            (gnus-cache-file-contents
             (gnus-agent-lib-file "local")
             'gnus-agent-file-loading-local
-            'gnus-agent-read-and-cache-local))
+            #'gnus-agent-read-and-cache-local))
       (when gnus-agent-article-local-times
        (cl-incf gnus-agent-article-local-times)))
     gnus-agent-article-local))
@@ -2188,14 +2193,15 @@ article counts for each of the method's subscribed 
groups."
 gnus-agent-article-local.  If that variable had `dirty' (also known as
 modified) original contents, they are first saved to their own file."
   (if (and gnus-agent-article-local
-           (symbol-value (intern "+dirty" gnus-agent-article-local)))
+           (gethash "+dirty" gnus-agent-article-local))
       (gnus-agent-save-local))
   (gnus-agent-read-local file))
 
 (defun gnus-agent-read-local (file)
   "Load FILE and do a `read' there."
-  (let ((my-obarray (gnus-make-hashtable (count-lines (point-min)
-                                                      (point-max))))
+  (let ((hashtb (gnus-make-hashtable
+                (count-lines (point-min)
+                             (point-max))))
         (line 1))
     (with-temp-buffer
       (condition-case nil
@@ -2204,7 +2210,8 @@ modified) original contents, they are first saved to 
their own file."
         (file-error))
 
       (goto-char (point-min))
-      ;; Skip any comments at the beginning of the file (the only place where 
they may appear)
+      ;; Skip any comments at the beginning of the file (the only
+      ;; place where they may appear)
       (while (= (following-char) ?\;)
         (forward-line 1)
         (setq line (1+ line)))
@@ -2214,33 +2221,32 @@ modified) original contents, they are first saved to 
their own file."
             (let (group
                   min
                   max
-                  (cur (current-buffer))
-                 (obarray my-obarray))
+                  (cur (current-buffer)))
               (setq group (read cur)
                     min (read cur)
                     max (read cur))
 
-              (when (stringp group)
-                (setq group (intern group my-obarray)))
+              (unless (stringp group)
+                (setq group (symbol-name group)))
 
               ;; NOTE: The '+ 0' ensure that min and max are both numerics.
-              (set group (cons (+ 0 min) (+ 0 max))))
+              (puthash group (cons (+ 0 min) (+ 0 max)) hashtb))
           (error
            (gnus-message 3 "Warning - invalid agent local: %s on line %d: %s"
                          file line (error-message-string err))))
         (forward-line 1)
         (setq line (1+ line))))
 
-    (set (intern "+dirty" my-obarray) nil)
-    (set (intern "+method" my-obarray) gnus-command-method)
-    my-obarray))
+    (puthash "+dirty" nil hashtb)
+    (puthash "+method" gnus-command-method hashtb)
+    hashtb))
 
 (defun gnus-agent-save-local (&optional force)
   "Save gnus-agent-article-local under it method's agent.lib directory."
-  (let ((my-obarray gnus-agent-article-local))
-    (when (and my-obarray
-               (or force (symbol-value (intern "+dirty" my-obarray))))
-      (let* ((gnus-command-method (symbol-value (intern "+method" my-obarray)))
+  (let ((hashtb gnus-agent-article-local))
+    (when (and hashtb
+               (or force (gethash "+dirty" hashtb)))
+      (let* ((gnus-command-method (gethash "+method" hashtb))
              ;; NOTE: gnus-command-method is used within gnus-agent-lib-file.
              (dest (gnus-agent-lib-file "local")))
         (gnus-make-directory (gnus-agent-lib-file ""))
@@ -2248,31 +2254,30 @@ modified) original contents, they are first saved to 
their own file."
        (let ((coding-system-for-write gnus-agent-file-coding-system)
              (file-name-coding-system nnmail-pathname-coding-system))
          (with-temp-file dest
-           (let ((gnus-command-method (symbol-value (intern "+method" 
my-obarray)))
+           ;; FIXME: Why are we letting this again?
+           (let ((gnus-command-method (gethash "+method" hashtb))
                  print-level print-length
                  (standard-output (current-buffer)))
-             (mapatoms (lambda (symbol)
-                         (cond ((not (boundp symbol))
-                                nil)
-                               ((member (symbol-name symbol) '("+dirty" 
"+method"))
-                                nil)
-                               (t
-                                (let ((range (symbol-value symbol)))
-                                  (when range
-                                    (prin1 symbol)
-                                    (princ " ")
-                                    (princ (car range))
-                                    (princ " ")
-                                    (princ (cdr range))
-                                    (princ "\n"))))))
-                       my-obarray))))))))
+             (maphash (lambda (group active)
+                        (cond ((null active)
+                               nil)
+                              ((member group '("+dirty" "+method"))
+                               nil)
+                              (t
+                               (when active
+                                 (prin1 group)
+                                 (princ " ")
+                                 (princ (car active))
+                                 (princ " ")
+                                 (princ (cdr active))
+                                 (princ "\n")))))
+                      hashtb))))))))
 
 (defun gnus-agent-get-local (group &optional gmane method)
   (let* ((gmane (or gmane (gnus-group-real-name group)))
          (gnus-command-method (or method (gnus-find-method-for-group group)))
          (local (gnus-agent-load-local))
-         (symb (intern gmane local))
-         (minmax (and (boundp symb) (symbol-value symb))))
+         (minmax (gethash gmane local)))
     (unless minmax
       ;; Bind these so that gnus-agent-load-alist doesn't change the
       ;; current alist (i.e. gnus-agent-article-alist)
@@ -2291,24 +2296,23 @@ modified) original contents, they are first saved to 
their own file."
   (let* ((gmane (or gmane (gnus-group-real-name group)))
          (gnus-command-method (or method (gnus-find-method-for-group group)))
          (local (or local (gnus-agent-load-local)))
-         (symb (intern gmane local))
-         (minmax (and (boundp symb) (symbol-value symb))))
+         (minmax (gethash gmane local)))
     (if (cond ((and minmax
                     (or (not (eq min (car minmax)))
                         (not (eq max (cdr minmax))))
                    min
                    max)
-               (setcar minmax min)
-               (setcdr minmax max)
+               (setcar (gethash gmane local) min)
+               (setcdr (gethash gmane local) max)
                t)
               (minmax
                nil)
               ((and min max)
-               (set symb (cons min max))
+               (puthash gmane (cons min max) local)
                t)
              (t
-              (unintern symb local)))
-        (set (intern "+dirty" local) t))))
+              (remhash gmane local)))
+        (puthash "+dirty" t local))))
 
 (defun gnus-agent-article-name (article group)
   (expand-file-name article
@@ -2878,8 +2882,8 @@ The following commands are available:
       nil
     (let ((string (gnus-simplify-subject (mail-header-subject gnus-headers))))
       (prog1
-         (gnus-gethash string gnus-agent-spam-hashtb)
-       (gnus-sethash string t gnus-agent-spam-hashtb)))))
+         (gethash string gnus-agent-spam-hashtb)
+       (puthash string t gnus-agent-spam-hashtb)))))
 
 (defun gnus-agent-short-p ()
   "Say whether an article is short or not."
@@ -2935,7 +2939,7 @@ The following commands are available:
         'or)
        ((memq (car predicate) gnus-category-not)
         'not))
-      ,@(mapcar 'gnus-category-make-function-1 (cdr predicate))))
+      ,@(mapcar #'gnus-category-make-function-1 (cdr predicate))))
    (t
     (error "Unknown predicate type: %s" predicate))))
 
@@ -2961,7 +2965,7 @@ return read articles, nil when it is known to always 
return read
 articles, and t_nil when the function may return both read and unread
 articles."
   (let ((func (car function))
-        (args (mapcar 'gnus-function-implies-unread-1 (cdr function))))
+        (args (mapcar #'gnus-function-implies-unread-1 (cdr function))))
     (cond ((eq func 'and)
            (cond ((memq t args) ; if any argument returns only unread articles
                   ;; then that argument constrains the result to only unread 
articles.
@@ -3007,13 +3011,13 @@ articles."
   (unless gnus-category-group-cache
     (setq gnus-category-group-cache (gnus-make-hashtable 1000))
     (let ((cs gnus-category-alist)
-         groups cat)
-      (while (setq cat (pop cs))
+         groups)
+      (dolist (cat cs)
        (setq groups (gnus-agent-cat-groups cat))
-       (while groups
-         (gnus-sethash (pop groups) cat gnus-category-group-cache)))))
-  (or (gnus-gethash group gnus-category-group-cache)
-      (assq 'default gnus-category-alist)))
+       (dolist (g groups)
+         (puthash g cat gnus-category-group-cache)))))
+  (gethash group gnus-category-group-cache
+          (assq 'default gnus-category-alist)))
 
 (defvar gnus-agent-expire-current-dirs)
 (defvar gnus-agent-expire-stats)
@@ -3053,7 +3057,7 @@ FORCE is equivalent to setting the expiration predicates 
to true."
                                    (count-lines (point-min) (point-max))))))
                     (save-excursion
                       (gnus-agent-expire-group-1
-                       group overview (gnus-gethash-safe group orig)
+                       group overview (gethash group orig)
                        articles force))))
               (kill-buffer overview))))
       (gnus-message 4 "%s" (gnus-agent-expire-done-message)))))
@@ -3147,38 +3151,37 @@ FORCE is equivalent to setting the expiration 
predicates to true."
              (nov-file (concat dir ".overview"))
              (cnt 0)
              (completed -1)
-             dlist
-             type)
-
-        ;; The normal article alist contains elements that look like
-        ;; (article# .  fetch_date) I need to combine other
-        ;; information with this list.  For example, a flag indicating
-        ;; that a particular article MUST BE KEPT.  To do this, I'm
-        ;; going to transform the elements to look like (article#
-        ;; fetch_date keep_flag NOV_entry_position) Later, I'll reverse
-        ;; the process to generate the expired article alist.
-
-        ;; Convert the alist elements to (article# fetch_date nil
-        ;; nil).
-        (setq dlist (mapcar (lambda (e)
-                              (list (car e) (cdr e) nil nil)) alist))
-
-        ;; Convert the keep lists to elements that look like (article#
-        ;; nil keep_flag nil) then append it to the expanded dlist
-        ;; These statements are sorted by ascending precedence of the
-        ;; keep_flag.
-        (setq dlist (nconc dlist
-                           (mapcar (lambda (e)
-                                     (list e nil 'unread  nil))
-                                   unreads)))
-        (setq dlist (nconc dlist
-                           (mapcar (lambda (e)
-                                     (list e nil 'marked  nil))
-                                   marked)))
-        (setq dlist (nconc dlist
-                           (mapcar (lambda (e)
-                                     (list e nil 'special nil))
-                                   specials)))
+             type
+
+              ;; The normal article alist contains elements that look like
+              ;; (article# .  fetch_date) I need to combine other
+              ;; information with this list.  For example, a flag indicating
+              ;; that a particular article MUST BE KEPT.  To do this, I'm
+              ;; going to transform the elements to look like (article#
+              ;; fetch_date keep_flag NOV_entry_position) Later, I'll reverse
+              ;; the process to generate the expired article alist.
+             (dlist
+               (nconc
+                ;; Convert the alist elements to (article# fetch_date nil nil).
+                (mapcar (lambda (e)
+                          (list (car e) (cdr e) nil nil))
+                        alist)
+
+                ;; Convert the keep lists to elements that look like (article#
+                ;; nil keep_flag nil) then append it to the expanded dlist
+                ;; These statements are sorted by ascending precedence of the
+                ;; keep_flag.
+                (mapcar (lambda (e)
+                          (list e nil 'unread  nil))
+                        unreads)
+
+                (mapcar (lambda (e)
+                          (list e nil 'marked  nil))
+                        marked)
+
+                (mapcar (lambda (e)
+                          (list e nil 'special nil))
+                        specials))))
 
         (set-buffer overview)
         (erase-buffer)
@@ -3387,7 +3390,7 @@ article alist" type) actions))
                   (when actions
                     (gnus-agent-message 8 "gnus-agent-expire: %s:%d: %s"
                                         decoded article-number
-                                        (mapconcat 'identity actions ", ")))))
+                                        (mapconcat #'identity actions ", ")))))
                (t
                 (gnus-agent-message
                  10 "gnus-agent-expire: %s:%d: Article kept as \
@@ -3471,9 +3474,7 @@ articles in every agentized group? "))
                                    (count-lines (point-min) (point-max))))))
                     (dolist (expiring-group (gnus-groups-from-server
                                              gnus-command-method))
-                      (let* ((active
-                              (gnus-gethash-safe expiring-group orig)))
-
+                      (let ((active (gethash expiring-group orig)))
                         (when active
                           (save-excursion
                             (gnus-agent-expire-group-1
@@ -3503,83 +3504,80 @@ articles in every agentized group? "))
 (defun gnus-agent-expire-unagentized-dirs ()
   (when (and gnus-agent-expire-unagentized-dirs
              (boundp 'gnus-agent-expire-current-dirs))
-    (let* ((keep (gnus-make-hashtable))
-          (file-name-coding-system nnmail-pathname-coding-system))
-
-      (gnus-sethash gnus-agent-directory t keep)
+    (let ((file-name-coding-system nnmail-pathname-coding-system)
+         ;; Another hash table that could just be a list.
+         (keep (gnus-make-hashtable 20))
+         to-remove)
+      (puthash gnus-agent-directory t keep)
       (dolist (dir gnus-agent-expire-current-dirs)
        (when (and (stringp dir)
                   (file-directory-p dir))
-         (while (not (gnus-gethash dir keep))
-           (gnus-sethash dir t keep)
+         (while (not (gethash dir keep))
+           (puthash dir t keep)
            (setq dir (file-name-directory (directory-file-name dir))))))
 
-      (let* (to-remove
-             checker
-             (checker
-              (function
-               (lambda (d)
-                 "Given a directory, check it and its subdirectories for
-              membership in the keep hash.  If it isn't found, add
-              it to to-remove."
-                 (let ((files (directory-files d))
-                       file)
-                   (while (setq file (pop files))
-                     (cond ((equal file ".") ; Ignore self
-                            nil)
-                           ((equal file "..") ; Ignore parent
-                            nil)
-                           ((equal file ".overview")
-                            ;; Directory must contain .overview to be
-                            ;; agent's cache of a group.
-                            (let ((d (file-name-as-directory d))
-                                  r)
-                              ;; Search ancestor's for last directory NOT
-                              ;; found in keep hash.
-                              (while (not (gnus-gethash
-                                           (setq d (file-name-directory d)) 
keep))
-                                (setq r d
-                                      d (directory-file-name d)))
-                              ;; if ANY ancestor was NOT in keep hash and
-                              ;; it's not already in to-remove, add it to
-                              ;; to-remove.
-                              (if (and r
-                                       (not (member r to-remove)))
-                                  (push r to-remove))))
-                           ((file-directory-p (setq file (nnheader-concat d 
file)))
-                            (funcall checker file)))))))))
-        (funcall checker (expand-file-name gnus-agent-directory))
-
-        (when (and to-remove
-                   (or gnus-expert-user
-                       (gnus-y-or-n-p
-                        "gnus-agent-expire has identified local directories 
that are\
+      (cl-labels ((checker
+                  (d)
+                  ;; Given a directory, check it and its subdirectories
+                  ;; for membership in the keep list.  If it isn't found,
+                  ;; add it to to-remove.
+                  (let ((files (directory-files d))
+                        file)
+                    (while (setq file (pop files))
+                      (cond ((equal file ".") ; Ignore self
+                             nil)
+                            ((equal file "..") ; Ignore parent
+                             nil)
+                            ((equal file ".overview")
+                             ;; Directory must contain .overview to be
+                             ;; agent's cache of a group.
+                             (let ((d (file-name-as-directory d))
+                                   r)
+                               ;; Search ancestors for last directory NOT
+                               ;; found in keep.
+                               (while (not (gethash (setq d 
(file-name-directory d)) keep))
+                                 (setq r d
+                                       d (directory-file-name d)))
+                               ;; if ANY ancestor was NOT in keep hash and
+                               ;; it's not already in to-remove, add it to
+                               ;; to-remove.
+                               (if (and r
+                                        (not (member r to-remove)))
+                                   (push r to-remove))))
+                            ((file-directory-p (setq file (nnheader-concat d 
file)))
+                             (checker file)))))))
+        (checker (expand-file-name gnus-agent-directory)))
+
+      (when (and to-remove
+                 (or gnus-expert-user
+                     (gnus-y-or-n-p
+                      "gnus-agent-expire has identified local directories that 
are\
  not currently required by any agentized group.  Do you wish to consider\
  deleting them?")))
-          (while to-remove
-            (let ((dir (pop to-remove)))
-              (if (or gnus-expert-user
-                     (gnus-y-or-n-p (format "Delete %s? " dir)))
-                  (let* (delete-recursive
-                        files f
-                         (delete-recursive
-                          (function
-                           (lambda (f-or-d)
-                             (ignore-errors
-                               (if (file-directory-p f-or-d)
-                                   (condition-case nil
-                                       (delete-directory f-or-d)
-                                     (file-error
-                                     (setq files (directory-files f-or-d))
-                                     (while files
-                                       (setq f (pop files))
-                                       (or (member f '("." ".."))
-                                           (funcall delete-recursive
-                                                    (nnheader-concat
-                                                     f-or-d f))))
-                                      (delete-directory f-or-d)))
-                                 (delete-file f-or-d)))))))
-                    (funcall delete-recursive dir))))))))))
+        (while to-remove
+          (let ((dir (pop to-remove)))
+            (if (or gnus-expert-user
+                   (gnus-y-or-n-p (format "Delete %s? " dir)))
+                (let* (delete-recursive
+                      files f
+                       (delete-recursive
+                        (function
+                         (lambda (f-or-d)
+                           (ignore-errors
+                             (if (file-directory-p f-or-d)
+                                 (condition-case nil
+                                     (delete-directory f-or-d)
+                                   (file-error
+                                   (setq files (directory-files f-or-d))
+                                   (while files
+                                     (setq f (pop files))
+                                     (or (member f '("." ".."))
+                                         (funcall delete-recursive
+                                                  (nnheader-concat
+                                                   f-or-d f))))
+                                    (delete-directory f-or-d)))
+                               (delete-file f-or-d)))))))
+                  (funcall delete-recursive dir)))))))))
 
 ;;;###autoload
 (defun gnus-agent-batch ()
@@ -3625,7 +3623,7 @@ If CACHED-HEADER is nil, articles are only excluded if 
the article itself
 has been fetched."
 
   ;; Logically equivalent to: (gnus-sorted-difference articles (mapcar
-  ;; 'car gnus-agent-article-alist))
+  ;; #'car gnus-agent-article-alist))
 
   ;; Functionally, I don't need to construct a temp list using mapcar.
 
@@ -4097,8 +4095,8 @@ agent has fetched."
      ;; if null, gnus-agent-group-pathname will calc method.
      (let* ((gnus-command-method method)
            (path (or path (gnus-agent-group-pathname group)))
-           (entry (or (gnus-gethash path gnus-agent-total-fetched-hashtb)
-                      (gnus-sethash path (make-list 3 0)
+           (entry (or (gethash path gnus-agent-total-fetched-hashtb)
+                      (puthash path (make-list 3 0)
                                     gnus-agent-total-fetched-hashtb)))
            (file-name-coding-system nnmail-pathname-coding-system))
        (when (file-exists-p path)
@@ -4128,7 +4126,7 @@ agent has fetched."
         (cl-incf (nth 2 entry) delta))))))
 
 (defun gnus-agent-update-view-total-fetched-for
-  (group agent-over &optional method path)
+    (group agent-over &optional method path)
   "Update, or set, the total disk space used by the .agentview and
 .overview files.  These files are calculated separately as they can be
 modified."
@@ -4138,9 +4136,9 @@ modified."
      ;; if null, gnus-agent-group-pathname will calc method.
      (let* ((gnus-command-method method)
            (path (or path (gnus-agent-group-pathname group)))
-           (entry (or (gnus-gethash path gnus-agent-total-fetched-hashtb)
-                      (gnus-sethash path (make-list 3 0)
-                                    gnus-agent-total-fetched-hashtb)))
+           (entry (or (gethash path gnus-agent-total-fetched-hashtb)
+                      (puthash path (make-list 3 0)
+                               gnus-agent-total-fetched-hashtb)))
            (file-name-coding-system nnmail-pathname-coding-system)
            (size (or (file-attribute-size (file-attributes
                                            (nnheader-concat
@@ -4155,12 +4153,13 @@ modified."
   "Get the total disk space used by the specified GROUP."
   (unless (equal group "dummy.group")
     (unless gnus-agent-total-fetched-hashtb
-      (setq gnus-agent-total-fetched-hashtb (gnus-make-hashtable 1024)))
+      (setq gnus-agent-total-fetched-hashtb
+           (gnus-make-hashtable 1000)))
 
     ;; if null, gnus-agent-group-pathname will calc method.
     (let* ((gnus-command-method method)
           (path (gnus-agent-group-pathname group))
-          (entry (gnus-gethash path gnus-agent-total-fetched-hashtb)))
+          (entry (gethash path gnus-agent-total-fetched-hashtb)))
       (if entry
          (apply '+ entry)
        (let ((gnus-agent-inhibit-update-total-fetched-for (not no-inhibit)))
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 28ee174..baa8a24 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -1,6 +1,6 @@
 ;;; gnus-art.el --- article mode commands for Gnus
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
@@ -3540,18 +3540,11 @@ possible values."
          (concat "Date: " (message-make-date time)))
         ;; Convert to Universal Time.
         ((eq type 'ut)
-         (concat "Date: "
-                 (substring
-                  (message-make-date
-                   (let* ((e (parse-time-string date))
-                          (tm (apply 'encode-time e))
-                          (ms (car tm))
-                          (ls (- (cadr tm) (car (current-time-zone time)))))
-                     (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
-                           ((> ls 65535) (list (1+ ms) (- ls 65536)))
-                           (t (list ms ls)))))
-                  0 -5)
-                 "UT"))
+         (let ((system-time-locale "C"))
+           (format-time-string
+            "Date: %a, %d %b %Y %T UT"
+            (encode-time (parse-time-string date))
+            t)))
         ;; Get the original date from the article.
         ((eq type 'original)
          (concat "Date: " (if (string-match "\n+$" date)
@@ -3569,13 +3562,7 @@ possible values."
              (concat "Date: " (format-time-string format time)))))
         ;; ISO 8601.
         ((eq type 'iso8601)
-         (let ((tz (car (current-time-zone time))))
-           (concat
-            "Date: "
-            (format-time-string "%Y%m%dT%H%M%S" time)
-            (format "%s%02d%02d"
-                    (if (> tz 0) "+" "-") (/ (abs tz) 3600)
-                    (/ (% (abs tz) 3600) 60)))))
+         (format-time-string "Date: %Y%m%dT%H%M%S%z" time))
         ;; Do a lapsed format.
         ((eq type 'lapsed)
          (concat "Date: " (article-lapsed-string time)))
@@ -3623,18 +3610,14 @@ possible values."
 (defun article-lapsed-string (time &optional max-segments)
   ;; If the date is seriously mangled, the timezone functions are
   ;; liable to bug out, so we ignore all errors.
-  (let* ((real-time (time-subtract nil time))
-        (real-sec (and real-time
-                       (+ (* (float (car real-time)) 65536)
-                          (cadr real-time))))
-        (sec (and real-time (abs real-sec)))
+  (let* ((real-time (time-since time))
+        (real-sec (float-time real-time))
+        (sec (abs real-sec))
         (segments 0)
         num prev)
     (unless max-segments
       (setq max-segments (length article-time-units)))
     (cond
-     ((null real-time)
-      "Unknown")
      ((zerop sec)
       "Now")
      (t
@@ -7393,9 +7376,8 @@ groups."
   :group 'gnus-article-buttons
   :type 'regexp)
 
-;; Regexp suggested by Felix Wiemann in <address@hidden>
 (defcustom gnus-button-valid-localpart-regexp
-  "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
+  "[-a-z0-9$%(*+./=?[_][^<>\")!;:,{}\n\t @]*"
   "Regular expression that matches a localpart of mail addresses or MIDs."
   :version "22.1"
   :group 'gnus-article-buttons
@@ -7491,7 +7473,7 @@ must return `mid', `mail', `invalid' or `ask'."
     (2.0   . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
   "An alist of (RATE . REGEXP) pairs for `gnus-button-mid-or-mail-heuristic'.
 
-A negative RATE indicates a message IDs, whereas a positive indicates a mail
+A negative RATE indicates a message ID, whereas a positive indicates a mail
 address.  The REGEXP is processed with `case-fold-search' set to nil."
   :version "22.1"
   :group 'gnus-article-buttons
@@ -7500,7 +7482,7 @@ address.  The REGEXP is processed with `case-fold-search' 
set to nil."
 
 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
   "Guess whether MID-OR-MAIL is a message ID or a mail address.
-Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
+Returns `mid' if MID-OR-MAIL is a message ID, `mail' if it's a mail
 address, `ask' if unsure and `invalid' if the string is invalid."
   (let ((case-fold-search nil)
        (list gnus-button-mid-or-mail-heuristic-alist)
diff --git a/lisp/gnus/gnus-async.el b/lisp/gnus/gnus-async.el
index ad25f80..4e2723e 100644
--- a/lisp/gnus/gnus-async.el
+++ b/lisp/gnus/gnus-async.el
@@ -1,6 +1,6 @@
 ;;; gnus-async.el --- asynchronous support for Gnus
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
@@ -84,7 +84,6 @@ that was fetched."
 (defvar gnus-async-article-alist nil)
 (defvar gnus-async-article-semaphore '(nil))
 (defvar gnus-async-fetch-list nil)
-(defvar gnus-async-hashtb nil)
 (defvar gnus-async-current-prefetch-group nil)
 (defvar gnus-async-current-prefetch-article nil)
 (defvar gnus-async-timer nil)
@@ -127,14 +126,11 @@ that was fetched."
 (defun gnus-async-close ()
   (gnus-kill-buffer gnus-async-prefetch-article-buffer)
   (gnus-kill-buffer gnus-async-prefetch-headers-buffer)
-  (setq gnus-async-hashtb nil
-       gnus-async-article-alist nil
+  (setq gnus-async-article-alist nil
        gnus-async-header-prefetched nil))
 
 (defun gnus-async-set-buffer ()
-  (nnheader-set-temp-buffer gnus-async-prefetch-article-buffer t)
-  (unless gnus-async-hashtb
-    (setq gnus-async-hashtb (gnus-make-hashtable 1023))))
+  (nnheader-set-temp-buffer gnus-async-prefetch-article-buffer t))
 
 (defun gnus-async-halt-prefetch ()
   "Stop prefetching."
@@ -242,13 +238,10 @@ that was fetched."
          (when gnus-async-post-fetch-function
            (funcall gnus-async-post-fetch-function summary))))
       (gnus-async-with-semaphore
-       (setq
-        gnus-async-article-alist
-        (cons (list (intern (format "%s-%d" group article)
-                            gnus-async-hashtb)
-                    mark (point-max-marker)
-                    group article)
-              gnus-async-article-alist))))
+       (push (list (format "%s-%d" group article)
+                   mark (point-max-marker)
+                   group article)
+             gnus-async-article-alist)))
     (if (not (gnus-buffer-live-p summary))
        (gnus-async-with-semaphore
          (setq gnus-async-fetch-list nil))
@@ -314,8 +307,7 @@ that was fetched."
     (set-marker (caddr entry) nil))
   (gnus-async-with-semaphore
     (setq gnus-async-article-alist
-         (delq entry gnus-async-article-alist))
-    (unintern (car entry) gnus-async-hashtb)))
+         (delete entry gnus-async-article-alist))))
 
 (defun gnus-async-prefetch-remove-group (group)
   "Remove all articles belonging to GROUP from the prefetch buffer."
@@ -331,9 +323,8 @@ that was fetched."
   "Return the entry for ARTICLE in GROUP if it has been prefetched."
   (let ((entry (save-excursion
                 (gnus-async-set-buffer)
-                (assq (intern-soft (format "%s-%d" group article)
-                                   gnus-async-hashtb)
-                      gnus-async-article-alist))))
+                (assoc (format "%s-%d" group article)
+                       gnus-async-article-alist))))
     ;; Perhaps something has emptied the buffer?
     (if (and entry
             (= (cadr entry) (caddr entry)))
@@ -342,7 +333,7 @@ that was fetched."
            (set-marker (cadr entry) nil)
            (set-marker (caddr entry) nil))
          (setq gnus-async-article-alist
-               (delq entry gnus-async-article-alist))
+               (delete entry gnus-async-article-alist))
          nil)
       entry)))
 
diff --git a/lisp/gnus/gnus-bcklg.el b/lisp/gnus/gnus-bcklg.el
index 95cb1ca..c5a0e3e 100644
--- a/lisp/gnus/gnus-bcklg.el
+++ b/lisp/gnus/gnus-bcklg.el
@@ -1,6 +1,6 @@
 ;;; gnus-bcklg.el --- backlog functions for Gnus
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
@@ -22,17 +22,16 @@
 
 ;;; Commentary:
 
+;; The backlog caches the text of a certain number of read articles in
+;; a separate buffer, so they can be retrieved quickly if the user
+;; opens them again.  Also see `gnus-keep-backlog'.
+
 ;;; Code:
 
 (require 'gnus)
 
-;;;
-;;; Buffering of read articles.
-;;;
-
 (defvar gnus-backlog-buffer " *Gnus Backlog*")
-(defvar gnus-backlog-articles nil)
-(defvar gnus-backlog-hashtb nil)
+(defvar gnus-backlog-articles '())
 
 (defun gnus-backlog-buffer ()
   "Return the backlog buffer."
@@ -42,11 +41,6 @@
        (setq buffer-read-only t)
        (get-buffer gnus-backlog-buffer))))
 
-(defun gnus-backlog-setup ()
-  "Initialize backlog variables."
-  (unless gnus-backlog-hashtb
-    (setq gnus-backlog-hashtb (gnus-make-hashtable 1024))))
-
 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
 
 (defun gnus-backlog-shutdown ()
@@ -54,46 +48,42 @@
   (interactive)
   (when (get-buffer gnus-backlog-buffer)
     (gnus-kill-buffer gnus-backlog-buffer))
-  (setq gnus-backlog-hashtb nil
-       gnus-backlog-articles nil))
+  (setq gnus-backlog-articles nil))
 
 (defun gnus-backlog-enter-article (group number buffer)
   (when (and (numberp number)
             (not (gnus-virtual-group-p group)))
-    (gnus-backlog-setup)
-    (let ((ident (intern (concat group ":" (int-to-string number))
-                        gnus-backlog-hashtb))
+    (let ((ident (format "%s:%d" group number))
          b)
-      (if (memq ident gnus-backlog-articles)
-         ()                            ; It's already kept.
-      ;; Remove the oldest article, if necessary.
-       (and (numberp gnus-keep-backlog)
-            (>= (length gnus-backlog-articles) gnus-keep-backlog)
-          (gnus-backlog-remove-oldest-article))
-       (push ident gnus-backlog-articles)
-       ;; Insert the new article.
-       (with-current-buffer (gnus-backlog-buffer)
-         (let (buffer-read-only)
-           (goto-char (point-max))
-           (unless (bolp)
-             (insert "\n"))
-           (setq b (point))
-           (insert-buffer-substring buffer)
-           ;; Tag the beginning of the article with the ident.
-           (if (> (point-max) b)
-             (put-text-property b (1+ b) 'gnus-backlog ident)
-             (gnus-error 3 "Article %d is blank" number))))))))
+     (unless (member ident gnus-backlog-articles) ; It's already kept.
+       ;; Remove the oldest article, if necessary.
+       (and (numberp gnus-keep-backlog)
+           (>= (length gnus-backlog-articles) gnus-keep-backlog)
+           (gnus-backlog-remove-oldest-article))
+       (push ident gnus-backlog-articles)
+       ;; Insert the new article.
+       (with-current-buffer (gnus-backlog-buffer)
+        (let (buffer-read-only)
+          (goto-char (point-max))
+          (unless (bolp)
+            (insert "\n"))
+          (setq b (point))
+          (insert-buffer-substring buffer)
+          ;; Tag the beginning of the article with the ident.
+          (if (> (point-max) b)
+              (put-text-property b (1+ b) 'gnus-backlog ident)
+            (gnus-error 3 "Article %d is blank" number))))))))
 
 (defun gnus-backlog-remove-oldest-article ()
   (with-current-buffer (gnus-backlog-buffer)
     (goto-char (point-min))
-    (if (zerop (buffer-size))
-       ()                              ; The buffer is empty.
+    (unless (zerop (buffer-size)) ; The buffer is empty.
       (let ((ident (get-text-property (point) 'gnus-backlog))
            buffer-read-only)
        ;; Remove the ident from the list of articles.
        (when ident
-         (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
+         (setq gnus-backlog-articles
+               (delete ident gnus-backlog-articles)))
        ;; Delete the article itself.
        (delete-region
         (point) (next-single-property-change
@@ -102,42 +92,40 @@
 (defun gnus-backlog-remove-article (group number)
   "Remove article NUMBER in GROUP from the backlog."
   (when (numberp number)
-    (gnus-backlog-setup)
-    (let ((ident (intern (concat group ":" (int-to-string number))
-                        gnus-backlog-hashtb))
-         beg end)
-      (when (memq ident gnus-backlog-articles)
+    (let ((ident (format "%s:%d" group number))
+         beg)
+      (when (member ident gnus-backlog-articles)
        ;; It was in the backlog.
        (with-current-buffer (gnus-backlog-buffer)
-         (let (buffer-read-only)
-           (when (setq beg (text-property-any
-                            (point-min) (point-max) 'gnus-backlog
-                            ident))
-             ;; Find the end (i. e., the beginning of the next article).
-             (setq end
-                   (next-single-property-change
-                    (1+ beg) 'gnus-backlog (current-buffer) (point-max)))
-             (delete-region beg end)
-             ;; Return success.
-             t))
-         (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))))))
+         (save-excursion
+           (let (buffer-read-only)
+             (goto-char (point-min))
+             (when (setq beg (gnus-text-property-search
+                              'gnus-backlog ident))
+               ;; Find the end (i. e., the beginning of the next article).
+               (goto-char
+                (next-single-property-change
+                 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))
+               (delete-region beg (point))
+               ;; Return success.
+               t)))
+         (setq gnus-backlog-articles
+               (delete ident gnus-backlog-articles)))))))
 
 (defun gnus-backlog-request-article (group number &optional buffer)
   (when (and (numberp number)
             (not (gnus-virtual-group-p group)))
-    (gnus-backlog-setup)
-    (let ((ident (intern (concat group ":" (int-to-string number))
-                        gnus-backlog-hashtb))
+    (let ((ident (format "%s:%d" group number))
          beg end)
-      (when (memq ident gnus-backlog-articles)
+      (when (member ident gnus-backlog-articles)
        ;; It was in the backlog.
        (with-current-buffer (gnus-backlog-buffer)
-         (if (not (setq beg (text-property-any
-                             (point-min) (point-max) 'gnus-backlog
-                             ident)))
+         (if (not (setq beg (gnus-text-property-search
+                             'gnus-backlog ident)))
              ;; It wasn't in the backlog after all.
              (ignore
-              (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
+              (setq gnus-backlog-articles
+                    (delete ident gnus-backlog-articles)))
            ;; Find the end (i. e., the beginning of the next article).
            (setq end
                  (next-single-property-change
diff --git a/lisp/gnus/gnus-bookmark.el b/lisp/gnus/gnus-bookmark.el
index 0d718e2..cc0a52f 100644
--- a/lisp/gnus/gnus-bookmark.el
+++ b/lisp/gnus/gnus-bookmark.el
@@ -1,6 +1,6 @@
 ;;; gnus-bookmark.el --- Bookmarks in Gnus
 
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: news
diff --git a/lisp/gnus/gnus-cache.el b/lisp/gnus/gnus-cache.el
index a16b61a..5e6483d 100644
--- a/lisp/gnus/gnus-cache.el
+++ b/lisp/gnus/gnus-cache.el
@@ -1,6 +1,6 @@
 ;;; gnus-cache.el --- cache interface for Gnus
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
@@ -272,7 +272,7 @@ it's not cached."
 (defun gnus-cache-possibly-alter-active (group active)
   "Alter the ACTIVE info for GROUP to reflect the articles in the cache."
   (when gnus-cache-active-hashtb
-    (let ((cache-active (gnus-gethash group gnus-cache-active-hashtb)))
+    (let ((cache-active (gethash group gnus-cache-active-hashtb)))
       (when cache-active
        (when (< (car cache-active) (car active))
          (setcar active (car cache-active)))
@@ -522,7 +522,7 @@ system for example was used.")
            (gnus-delete-line)))
       (unless (setq gnus-newsgroup-cached
                    (delq article gnus-newsgroup-cached))
-       (gnus-sethash gnus-newsgroup-name nil gnus-cache-active-hashtb)
+       (remhash gnus-newsgroup-name gnus-cache-active-hashtb)
        (setq gnus-cache-active-altered t))
       (gnus-summary-update-secondary-mark article)
       t)))
@@ -542,8 +542,8 @@ system for example was used.")
          (progn
            (gnus-cache-update-active group (car articles) t)
            (gnus-cache-update-active group (car (last articles))))
-       (when (gnus-gethash group gnus-cache-active-hashtb)
-         (gnus-sethash group nil gnus-cache-active-hashtb)
+       (when (gethash group gnus-cache-active-hashtb)
+         (remhash group gnus-cache-active-hashtb)
          (setq gnus-cache-active-altered t)))
       articles)))
 
@@ -666,13 +666,16 @@ $ emacs -batch -l ~/.emacs -l gnus -f gnus-jog-cache"
     ;; Mark the active hashtb as unaltered.
     (setq gnus-cache-active-altered nil)))
 
+;; FIXME: Why is there a `gnus-cache-possibly-alter-active',
+;; `gnus-cache-possibly-update-active', and
+;; `gnus-cache-update-active'?  Do we really need all three?
 (defun gnus-cache-possibly-update-active (group active)
   "Update active info bounds of GROUP with ACTIVE if necessary.
 The update is performed if ACTIVE contains a higher or lower bound
 than the current."
   (let ((lower t) (higher t))
     (if gnus-cache-active-hashtb
-       (let ((cache-active (gnus-gethash group gnus-cache-active-hashtb)))
+       (let ((cache-active (gethash group gnus-cache-active-hashtb)))
          (when cache-active
            (unless (< (car active) (car cache-active))
              (setq lower nil))
@@ -687,10 +690,10 @@ than the current."
 (defun gnus-cache-update-active (group number &optional low)
   "Update the upper bound of the active info of GROUP to NUMBER.
 If LOW, update the lower bound instead."
-  (let ((active (gnus-gethash group gnus-cache-active-hashtb)))
+  (let ((active (gethash group gnus-cache-active-hashtb)))
     (if (null active)
        ;; We just create a new active entry for this group.
-       (gnus-sethash group (cons number number) gnus-cache-active-hashtb)
+       (puthash group (cons number number) gnus-cache-active-hashtb)
       ;; Update the lower or upper bound.
       (if low
          (setcar active number)
@@ -734,10 +737,10 @@ If LOW, update the lower bound instead."
       ;; FIXME: this is kind of a workaround.  The active file should
       ;; be updated at the time articles are cached.  It will make
       ;; `gnus-cache-unified-group-names' needless.
-      (gnus-sethash (or (cdr (assoc group gnus-cache-unified-group-names))
-                       group)
-                   (cons (car nums) (car (last nums)))
-                   gnus-cache-active-hashtb))
+      (puthash (or (cdr (assoc group gnus-cache-unified-group-names))
+                  group)
+              (cons (car nums) (car (last nums)))
+              gnus-cache-active-hashtb))
     ;; Go through all the other files.
     (dolist (file alphs)
       (when (and (file-directory-p file)
@@ -798,13 +801,13 @@ supported."
     (unless gnus-cache-active-hashtb
       (gnus-cache-read-active))
     (let* ((old-group-hash-value
-           (gnus-gethash old-group gnus-cache-active-hashtb))
+           (gethash old-group gnus-cache-active-hashtb))
           (new-group-hash-value
-           (gnus-gethash new-group gnus-cache-active-hashtb))
+           (gethash new-group gnus-cache-active-hashtb))
           (delta
            (or old-group-hash-value new-group-hash-value)))
-      (gnus-sethash new-group old-group-hash-value gnus-cache-active-hashtb)
-      (gnus-sethash old-group nil gnus-cache-active-hashtb)
+      (puthash new-group old-group-hash-value gnus-cache-active-hashtb)
+      (puthash old-group nil gnus-cache-active-hashtb)
 
       (if no-save
          (setq gnus-cache-active-altered delta)
@@ -826,8 +829,8 @@ supported."
   (let ((no-save gnus-cache-active-hashtb))
     (unless gnus-cache-active-hashtb
       (gnus-cache-read-active))
-    (let* ((group-hash-value (gnus-gethash group gnus-cache-active-hashtb)))
-      (gnus-sethash group nil gnus-cache-active-hashtb)
+    (let* ((group-hash-value (gethash group gnus-cache-active-hashtb)))
+      (remhash group gnus-cache-active-hashtb)
 
       (if no-save
          (setq gnus-cache-active-altered group-hash-value)
@@ -849,9 +852,9 @@ supported."
   (when gnus-cache-total-fetched-hashtb
     (gnus-cache-with-refreshed-group
      group
-     (let* ((entry (or (gnus-gethash group gnus-cache-total-fetched-hashtb)
-                      (gnus-sethash group (make-vector 2 0)
-                                    gnus-cache-total-fetched-hashtb)))
+     (let* ((entry (or (gethash group gnus-cache-total-fetched-hashtb)
+                      (puthash group (make-vector 2 0)
+                               gnus-cache-total-fetched-hashtb)))
            size)
 
        (if file
@@ -874,8 +877,8 @@ supported."
   (when gnus-cache-total-fetched-hashtb
     (gnus-cache-with-refreshed-group
      group
-     (let* ((entry (or (gnus-gethash group gnus-cache-total-fetched-hashtb)
-                      (gnus-sethash group (make-list 2 0)
+     (let* ((entry (or (gethash group gnus-cache-total-fetched-hashtb)
+                      (puthash group (make-list 2 0)
                                     gnus-cache-total-fetched-hashtb)))
            (file-name-coding-system nnmail-pathname-coding-system)
            (size (or (file-attribute-size (file-attributes
@@ -888,22 +891,21 @@ supported."
 (defun gnus-cache-rename-group-total-fetched-for (old-group new-group)
   "Record of disk space used by OLD-GROUP now associated with NEW-GROUP."
   (when gnus-cache-total-fetched-hashtb
-    (let ((entry (gnus-gethash old-group gnus-cache-total-fetched-hashtb)))
-      (gnus-sethash new-group entry gnus-cache-total-fetched-hashtb)
-      (gnus-sethash old-group nil gnus-cache-total-fetched-hashtb))))
+    (let ((entry (gethash old-group gnus-cache-total-fetched-hashtb)))
+      (puthash new-group entry gnus-cache-total-fetched-hashtb)
+      (remhash old-group gnus-cache-total-fetched-hashtb))))
 
 (defun gnus-cache-delete-group-total-fetched-for (group)
   "Delete record of disk space used by GROUP being deleted."
   (when gnus-cache-total-fetched-hashtb
-      (gnus-sethash group nil gnus-cache-total-fetched-hashtb)))
+      (remhash group gnus-cache-total-fetched-hashtb)))
 
 (defun gnus-cache-total-fetched-for (group &optional no-inhibit)
   "Get total disk space used by the cache for the specified GROUP."
   (unless (equal group "dummy.group")
     (unless gnus-cache-total-fetched-hashtb
-      (setq gnus-cache-total-fetched-hashtb (gnus-make-hashtable 1024)))
-
-    (let* ((entry (gnus-gethash group gnus-cache-total-fetched-hashtb)))
+      (setq gnus-cache-total-fetched-hashtb (gnus-make-hashtable 1000)))
+    (let* ((entry (gethash group gnus-cache-total-fetched-hashtb)))
       (if entry
          (apply '+ entry)
        (let ((gnus-cache-inhibit-update-total-fetched-for (not no-inhibit)))
diff --git a/lisp/gnus/gnus-cite.el b/lisp/gnus/gnus-cite.el
index b48815b..7e431e7 100644
--- a/lisp/gnus/gnus-cite.el
+++ b/lisp/gnus/gnus-cite.el
@@ -1,6 +1,6 @@
 ;;; gnus-cite.el --- parse citations in articles for Gnus
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Author: Per Abhiddenware
 
@@ -92,7 +92,7 @@ The first regexp group should match the Supercite 
attribution."
 ;;     -----Original Message-----
 ;;     From: ...
 ;;     To: ...
-;;     Sent: ...   [date, in non-RFC-2822 format]
+;;     Sent: ...   [date, in non-RFC-822-or-later format]
 ;;     Subject: ...
 ;;
 ;;     Cited message, with no prefixes
@@ -1128,7 +1128,7 @@ Returns nil if there is no such line before LIMIT, t 
otherwise."
     (let ((cdepth (min (length (apply 'concat
                                      (split-string
                                       (match-string-no-properties 0)
-                                      "[ \t [:alnum:]]+")))
+                                      "[\t [:alnum:]]+")))
                       gnus-message-max-citation-depth))
          (mlist (make-list (* (1+ gnus-message-max-citation-depth) 2) nil))
          (start (point-at-bol))
diff --git a/lisp/gnus/gnus-cloud.el b/lisp/gnus/gnus-cloud.el
index 1aa8e71..485f815 100644
--- a/lisp/gnus/gnus-cloud.el
+++ b/lisp/gnus/gnus-cloud.el
@@ -1,6 +1,6 @@
 ;;; gnus-cloud.el --- storing and retrieving data via IMAP
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: mail
diff --git a/lisp/gnus/gnus-cus.el b/lisp/gnus/gnus-cus.el
index f4c0aa7..d56066e 100644
--- a/lisp/gnus/gnus-cus.el
+++ b/lisp/gnus/gnus-cus.el
@@ -1,6 +1,6 @@
 ;;; gnus-cus.el --- customization commands for Gnus
 
-;; Copyright (C) 1996, 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Per Abrahamsen <address@hidden>
 ;; Keywords: news
diff --git a/lisp/gnus/gnus-delay.el b/lisp/gnus/gnus-delay.el
index e9138f0..aabf239 100644
--- a/lisp/gnus/gnus-delay.el
+++ b/lisp/gnus/gnus-delay.el
@@ -1,6 +1,6 @@
 ;;; gnus-delay.el --- Delayed posting of articles
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Kai Großjohann <address@hidden>
 ;; Keywords: mail, news, extensions
@@ -98,19 +98,15 @@ DELAY is a string, giving the length of the time.  Possible 
values are:
           (setq hour   (string-to-number (match-string 1 delay))
                 minute (string-to-number (match-string 2 delay)))
           ;; Use current time, except...
-          (setq deadline (apply 'vector (decode-time)))
+          (setq deadline (decode-time))
           ;; ... for minute and hour.
-          (aset deadline 1 minute)
-          (aset deadline 2 hour)
-          ;; Convert to seconds.
-          (setq deadline (float-time (apply 'encode-time
-                                            (append deadline nil))))
+          (setq deadline (apply #'encode-time (car deadline) minute hour
+                                (nthcdr 3 deadline)))
           ;; If this time has passed already, add a day.
-          (when (< deadline (float-time))
-            (setq deadline (+ 86400 deadline))) ; 86400 secs/day
+          (when (time-less-p deadline nil)
+            (setq deadline (time-add 86400 deadline))) ; 86400 secs/day
           ;; Convert seconds to date header.
-          (setq deadline (message-make-date
-                          (seconds-to-time deadline))))
+          (setq deadline (message-make-date deadline)))
          ((string-match "\\([0-9]+\\)\\s-*\\([mhdwMY]\\)" delay)
           (setq num (match-string 1 delay))
           (setq unit (match-string 2 delay))
@@ -128,8 +124,7 @@ DELAY is a string, giving the length of the time.  Possible 
values are:
                  (setq delay (* num 60 60)))
                 (t
                  (setq delay (* num 60))))
-          (setq deadline (message-make-date
-                          (seconds-to-time (+ (float-time) delay)))))
+          (setq deadline (message-make-date (time-add nil delay))))
          (t (error "Malformed delay `%s'" delay)))
     (message-add-header (format "%s: %s" gnus-delay-header deadline)))
   (set-buffer-modified-p t)
@@ -164,11 +159,8 @@ DELAY is a string, giving the length of the time.  
Possible values are:
               nil t)
              (progn
                (setq deadline (nnheader-header-value))
-               (setq deadline (apply 'encode-time
-                                     (parse-time-string deadline)))
-               (setq deadline (time-since deadline))
-               (when (and (>= (nth 0 deadline) 0)
-                          (>= (nth 1 deadline) 0))
+               (setq deadline (encode-time (parse-time-string deadline)))
+               (unless (time-less-p nil deadline)
                  (message "Sending delayed article %d" article)
                  (gnus-draft-send article group)
                  (message "Sending delayed article %d...done" article)))
diff --git a/lisp/gnus/gnus-demon.el b/lisp/gnus/gnus-demon.el
index 2405c70..6c5e0b7 100644
--- a/lisp/gnus/gnus-demon.el
+++ b/lisp/gnus/gnus-demon.el
@@ -1,6 +1,6 @@
 ;;; gnus-demon.el --- daemonic Gnus behavior
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
@@ -93,7 +93,7 @@ Emacs has been idle for IDLE `gnus-demon-timestep's."
 
 (defun gnus-demon-idle-since ()
   "Return the number of seconds since when Emacs is idle."
-  (float-time (or (current-idle-time) '(0 0 0))))
+  (float-time (or (current-idle-time) 0)))
 
 (defun gnus-demon-run-callback (func &optional idle time special)
   "Run FUNC if Emacs has been idle for longer than IDLE seconds.
@@ -192,11 +192,9 @@ marked with SPECIAL."
                            (elt nowParts 6)
                            (elt nowParts 7)
                            (elt nowParts 8)))
-        ;; calculate number of seconds between NOW and THEN
-        (diff (+ (* 65536 (- (car then) (car now)))
-                 (- (cadr then) (cadr now)))))
-    ;; return number of timesteps in the number of seconds
-    (round (/ diff gnus-demon-timestep))))
+        (diff (float-time (time-subtract then now))))
+    ;; Return number of timesteps in the number of seconds.
+    (round diff gnus-demon-timestep)))
 
 (gnus-add-shutdown 'gnus-demon-cancel 'gnus)
 
diff --git a/lisp/gnus/gnus-diary.el b/lisp/gnus/gnus-diary.el
index b8ad424..ceb0d4a 100644
--- a/lisp/gnus/gnus-diary.el
+++ b/lisp/gnus/gnus-diary.el
@@ -1,6 +1,6 @@
 ;;; gnus-diary.el --- Wrapper around the NNDiary Gnus back end
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author:        Didier Verna <address@hidden>
 ;; Maintainer:    Didier Verna <address@hidden>
@@ -159,32 +159,29 @@ There are currently two built-in format functions:
   ;; Code partly stolen from article-make-date-line
   (let* ((extras (mail-header-extra header))
         (sched (gnus-diary-header-schedule extras))
-        (occur (nndiary-next-occurrence sched (current-time)))
         (now (current-time))
+        (occur (nndiary-next-occurrence sched now))
         (real-time (time-subtract occur now)))
-    (if (null real-time)
-       "?????"
-      (let* ((sec (+ (* (float (car real-time)) 65536) (cadr real-time)))
-            (past (< sec 0))
-            delay)
-       (and past (setq sec (- sec)))
-       (unless (zerop sec)
-         ;; This is a bit convoluted, but basically we go through the time
-         ;; units for years, weeks, etc, and divide things to see whether
-         ;; that results in positive answers.
-         (let ((units `((year . ,(* 365.25 24 3600))
-                        (month . ,(* 31 24 3600))
-                        (week . ,(* 7 24 3600))
-                        (day . ,(* 24 3600))
-                        (hour . 3600)
-                        (minute . 60)))
-               unit num)
-           (while (setq unit (pop units))
-             (unless (zerop (setq num (ffloor (/ sec (cdr unit)))))
-               (setq delay (append delay `((,(floor num) . ,(car unit))))))
-             (setq sec (- sec (* num (cdr unit)))))))
-       (funcall gnus-diary-delay-format-function past delay)))
-    ))
+    (let* ((sec (encode-time real-time 'integer))
+          (past (< sec 0))
+          delay)
+      (and past (setq sec (- sec)))
+      (unless (zerop sec)
+       ;; This is a bit convoluted, but basically we go through the time
+       ;; units for years, weeks, etc, and divide things to see whether
+       ;; that results in positive answers.
+       (let ((units `((year . ,(round (* 365.25 24 3600)))
+                      (month . ,(* 31 24 3600))
+                      (week . ,(* 7 24 3600))
+                      (day . ,(* 24 3600))
+                      (hour . 3600)
+                      (minute . 60)))
+             unit num)
+         (while (setq unit (pop units))
+           (unless (zerop (setq num (floor sec (cdr unit))))
+             (setq delay (append delay `((,num . ,(car unit))))))
+           (setq sec (mod sec (cdr unit))))))
+      (funcall gnus-diary-delay-format-function past delay))))
 
 ;; #### NOTE: Gnus sometimes gives me a HEADER not corresponding to any
 ;; message, with all fields set to nil here. I don't know what it is for, and
diff --git a/lisp/gnus/gnus-dired.el b/lisp/gnus/gnus-dired.el
index a46dd78..acb8fd7 100644
--- a/lisp/gnus/gnus-dired.el
+++ b/lisp/gnus/gnus-dired.el
@@ -1,6 +1,6 @@
 ;;; gnus-dired.el --- utility functions where gnus and dired meet
 
-;; Copyright (C) 1996-1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2001-2019 Free Software Foundation, Inc.
 
 ;; Authors: Benjamin Rutt <address@hidden>,
 ;;          Shenghuo Zhu <address@hidden>
diff --git a/lisp/gnus/gnus-draft.el b/lisp/gnus/gnus-draft.el
index 7d4be47..ad1aa62 100644
--- a/lisp/gnus/gnus-draft.el
+++ b/lisp/gnus/gnus-draft.el
@@ -1,6 +1,6 @@
 ;;; gnus-draft.el --- draft message support for Gnus
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
diff --git a/lisp/gnus/gnus-dup.el b/lisp/gnus/gnus-dup.el
index a03c6c1..4981614 100644
--- a/lisp/gnus/gnus-dup.el
+++ b/lisp/gnus/gnus-dup.el
@@ -1,6 +1,6 @@
-;;; gnus-dup.el --- suppression of duplicate articles in Gnus
+;;; gnus-dup.el --- suppression of duplicate articles in Gnus  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
@@ -44,7 +44,7 @@ seen in the same session."
   :type 'boolean)
 
 (defcustom gnus-duplicate-list-length 10000
-  "The number of Message-IDs to keep in the duplicate suppression list."
+  "The maximum number of duplicate Message-IDs to keep track of."
   :group 'gnus-duplicate
   :type 'integer)
 
@@ -55,10 +55,14 @@ seen in the same session."
 
 ;;; Internal variables
 
-(defvar gnus-dup-list nil)
-(defvar gnus-dup-hashtb nil)
+(defvar gnus-dup-list nil
+  "List of seen message IDs, as strings.")
 
-(defvar gnus-dup-list-dirty nil)
+(defvar gnus-dup-hashtb nil
+  "Hash table of seen message IDs, for fast lookup.")
+
+(defvar gnus-dup-list-dirty nil
+  "Non-nil if `gnus-dup-list' needs to be saved.")
 
 ;;;
 ;;; Starting and stopping
@@ -78,10 +82,10 @@ seen in the same session."
   (if gnus-save-duplicate-list
       (gnus-dup-read)
     (setq gnus-dup-list nil))
-  (setq gnus-dup-hashtb (gnus-make-hashtable gnus-duplicate-list-length))
+  (setq gnus-dup-hashtb (gnus-make-hashtable))
   ;; Enter all Message-IDs into the hash table.
-  (let ((obarray gnus-dup-hashtb))
-    (mapc 'intern gnus-dup-list)))
+  (dolist (g gnus-dup-list)
+    (puthash g t gnus-dup-hashtb)))
 
 (defun gnus-dup-read ()
   "Read the duplicate suppression list."
@@ -103,7 +107,7 @@ seen in the same session."
 
 (defun gnus-dup-enter-articles ()
   "Enter articles from the current group for future duplicate suppression."
-  (unless gnus-dup-list
+  (unless gnus-dup-hashtb
     (gnus-dup-open))
   (setq gnus-dup-list-dirty t)         ; mark list for saving
   (let (msgid)
@@ -116,29 +120,30 @@ seen in the same session."
                 (not (= (gnus-data-mark datum) gnus-canceled-mark))
                 (setq msgid (mail-header-id (gnus-data-header datum)))
                 (not (nnheader-fake-message-id-p msgid))
-                (not (intern-soft msgid gnus-dup-hashtb)))
+                (not (gethash msgid gnus-dup-hashtb)))
        (push msgid gnus-dup-list)
-       (intern msgid gnus-dup-hashtb))))
-  ;; Chop off excess Message-IDs from the list.
-  (let ((end (nthcdr gnus-duplicate-list-length gnus-dup-list)))
+       (puthash msgid t gnus-dup-hashtb))))
+  ;; Remove excess Message-IDs from the list and hash table.
+  (let* ((dups (cons nil gnus-dup-list))
+         (end  (nthcdr gnus-duplicate-list-length dups)))
     (when end
-      (mapc (lambda (id) (unintern id gnus-dup-hashtb)) (cdr end))
-      (setcdr end nil))))
+      (mapc (lambda (id) (remhash id gnus-dup-hashtb)) (cdr end))
+      (setcdr end nil))
+    (setq gnus-dup-list (cdr dups))))
 
 (defun gnus-dup-suppress-articles ()
   "Mark duplicate articles as read."
-  (unless gnus-dup-list
+  (unless gnus-dup-hashtb
     (gnus-dup-open))
   (gnus-message 8 "Suppressing duplicates...")
   (let ((auto (and gnus-newsgroup-auto-expire
                   (memq gnus-duplicate-mark gnus-auto-expirable-marks)))
        number)
     (dolist (header gnus-newsgroup-headers)
-      (when (and (intern-soft (mail-header-id header) gnus-dup-hashtb)
-                (gnus-summary-article-unread-p (mail-header-number header)))
-       (setq gnus-newsgroup-unreads
-             (delq (setq number (mail-header-number header))
-                   gnus-newsgroup-unreads))
+      (when (and (gethash (mail-header-id header) gnus-dup-hashtb)
+                 (setq number (mail-header-number header))
+                 (gnus-summary-article-unread-p number))
+        (setq gnus-newsgroup-unreads (delq number gnus-newsgroup-unreads))
        (if (not auto)
            (push (cons number gnus-duplicate-mark) gnus-newsgroup-reads)
          (push number gnus-newsgroup-expirable)
@@ -147,12 +152,13 @@ seen in the same session."
 
 (defun gnus-dup-unsuppress-article (article)
   "Stop suppression of ARTICLE."
-  (let* ((header (gnus-data-header (gnus-data-find article)))
-        (id     (when header (mail-header-id header))))
-    (when id
+  (let (header id)
+    (when (and gnus-dup-hashtb
+               (setq header (gnus-data-header (gnus-data-find article)))
+               (setq id (mail-header-id header)))
       (setq gnus-dup-list-dirty t)
       (setq gnus-dup-list (delete id gnus-dup-list))
-      (unintern id gnus-dup-hashtb))))
+      (remhash id gnus-dup-hashtb))))
 
 (provide 'gnus-dup)
 
diff --git a/lisp/gnus/gnus-eform.el b/lisp/gnus/gnus-eform.el
index 059d173..a1f71bb 100644
--- a/lisp/gnus/gnus-eform.el
+++ b/lisp/gnus/gnus-eform.el
@@ -1,6 +1,6 @@
 ;;; gnus-eform.el --- a mode for editing forms for Gnus
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
diff --git a/lisp/gnus/gnus-fun.el b/lisp/gnus/gnus-fun.el
index f1fd51d..8b71051 100644
--- a/lisp/gnus/gnus-fun.el
+++ b/lisp/gnus/gnus-fun.el
@@ -1,6 +1,6 @@
 ;;; gnus-fun.el --- various frivolous extension functions to Gnus
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
diff --git a/lisp/gnus/gnus-gravatar.el b/lisp/gnus/gnus-gravatar.el
index 95e0927..d271a52 100644
--- a/lisp/gnus/gnus-gravatar.el
+++ b/lisp/gnus/gnus-gravatar.el
@@ -1,6 +1,6 @@
 ;;; gnus-gravatar.el --- Gnus Gravatar support
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Julien Danjou <address@hidden>
 ;; Keywords: news
diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el
index c4ec9c1..c757c82 100644
--- a/lisp/gnus/gnus-group.el
+++ b/lisp/gnus/gnus-group.el
@@ -1,6 +1,6 @@
 ;;; gnus-group.el --- group mode commands for Gnus
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
@@ -38,6 +38,7 @@
 
 (eval-when-compile
   (require 'mm-url)
+  (require 'subr-x)
   (let ((features (cons 'gnus-group features)))
     (require 'gnus-sum))
   (unless (boundp 'gnus-cache-active-hashtb)
@@ -1142,7 +1143,7 @@ The following commands are available:
     (let ((gnus-process-mark ?\200)
          (gnus-group-update-hook nil)
          (gnus-group-marked '("dummy.group"))
-         (gnus-active-hashtb (make-vector 10 0)))
+         (gnus-active-hashtb (gnus-make-hashtable 10)))
       (gnus-set-active "dummy.group" '(0 . 0))
       (gnus-set-work-buffer)
       (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
@@ -1186,6 +1187,9 @@ The following commands are available:
   (unless (derived-mode-p 'gnus-group-mode)
     (gnus-group-mode)))
 
+;; FIXME: If we never have to coerce group names to unibyte now, how
+;; much of this is necessary?  How much encoding/decoding do we still
+;; have to do?
 (defun gnus-group-name-charset (method group)
   (unless method
     (setq method (gnus-find-method-for-group group)))
@@ -1267,20 +1271,14 @@ Also see the `gnus-group-use-permanent-levels' 
variable."
        ;; has disappeared in the new listing, try to find the next
        ;; one.  If no next one can be found, just leave point at the
        ;; first newsgroup in the buffer.
-       (when (not (gnus-goto-char
-                   (text-property-any
-                    (point-min) (point-max)
-                    'gnus-group (gnus-intern-safe
-                                 group gnus-active-hashtb))))
-         (let ((newsrc (cdddr (gnus-group-entry group))))
-           (while (and newsrc
-                       (not (gnus-goto-char
-                             (text-property-any
-                              (point-min) (point-max) 'gnus-group
-                              (gnus-intern-safe
-                               (caar newsrc) gnus-active-hashtb)))))
-             (setq newsrc (cdr newsrc)))
-           (unless newsrc
+       (when (not (gnus-text-property-search
+                   'gnus-group group nil 'goto))
+         (let ((groups (cdr-safe (member group gnus-group-list))))
+           (while (and groups
+                       (not (gnus-text-property-search
+                             'gnus-group (car groups) 'forward 'goto)))
+             (setq groups (cdr groups)))
+           (unless groups
              (goto-char (point-max))
              (forward-line -1)))))))
     ;; Adjust cursor point.
@@ -1313,7 +1311,6 @@ If REGEXP is a function, list dead groups that the 
function returns non-nil;
 if it is a string, only list groups matching REGEXP."
   (set-buffer gnus-group-buffer)
   (let ((buffer-read-only nil)
-       (newsrc (cdr gnus-newsrc-alist))
        (lowest (or lowest 1))
        (not-in-list (and gnus-group-listed-groups
                          (copy-sequence gnus-group-listed-groups)))
@@ -1321,12 +1318,11 @@ if it is a string, only list groups matching REGEXP."
     (erase-buffer)
     (when (or (< lowest gnus-level-zombie)
              gnus-group-listed-groups)
-      ;; List living groups.
-      (while newsrc
-       (setq info (car newsrc)
+      ;; List living groups, according to order in `gnus-group-list'.
+      (dolist (g (cdr gnus-group-list))
+        (setq info (gnus-get-info g)
              group (gnus-info-group info)
              params (gnus-info-params info)
-             newsrc (cdr newsrc)
              unread (gnus-group-unread group))
        (when not-in-list
          (setq not-in-list (delete group not-in-list)))
@@ -1393,39 +1389,35 @@ if it is a string, only list groups matching REGEXP."
   ;; List zombies and killed lists somewhat faster, which was
   ;; suggested by Jack Vinson <address@hidden>.  It does
   ;; this by ignoring the group format specification altogether.
-  (let (group)
-    (if (> (length groups) gnus-group-listing-limit)
-       (while groups
-         (setq group (pop groups))
-         (when (gnus-group-prepare-logic
-                group
-                (or (not regexp)
-                    (and (stringp regexp) (string-match regexp group))
-                    (and (functionp regexp) (funcall regexp group))))
-           (add-text-properties
-            (point) (prog1 (1+ (point))
-                      (insert " " mark "     *: "
-                              (gnus-group-decoded-name group)
-                              "\n"))
-            (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
-                  'gnus-unread t
-                  'gnus-level level))))
-      (while groups
-       (setq group (pop groups))
+  (if (nthcdr gnus-group-listing-limit groups)
+      (dolist (group groups)
        (when (gnus-group-prepare-logic
               group
-              (or (not regexp)
-                  (and (stringp regexp) (string-match regexp group))
-                  (and (functionp regexp) (funcall regexp group))))
-         (gnus-group-insert-group-line
-          group level nil
-          (let ((active (gnus-active group)))
-            (if active
-                (if (zerop (cdr active))
-                    0
-                  (- (1+ (cdr active)) (car active)))
-              nil))
-          (gnus-method-simplify (gnus-find-method-for-group group))))))))
+               (cond ((not regexp))
+                     ((stringp regexp) (string-match-p regexp group))
+                     ((functionp regexp) (funcall regexp group))))
+          (add-text-properties
+           (point) (prog1 (1+ (point))
+                     (insert " " mark "     *: "
+                             (gnus-group-decoded-name group)
+                             "\n"))
+           (list 'gnus-group group
+                 'gnus-unread t
+                 'gnus-level level))))
+    (dolist (group groups)
+      (when (gnus-group-prepare-logic
+             group
+             (cond ((not regexp))
+                   ((stringp regexp) (string-match-p regexp group))
+                   ((functionp regexp) (funcall regexp group))))
+        (gnus-group-insert-group-line
+         group level nil
+         (let ((active (gnus-active group)))
+           (and active
+                (if (zerop (cdr active))
+                    0
+                  (- (cdr active) (car active) -1))))
+         (gnus-method-simplify (gnus-find-method-for-group group)))))))
 
 (defun gnus-group-update-group-line ()
   "Update the current line in the group buffer."
@@ -1438,7 +1430,7 @@ if it is a string, only list groups matching REGEXP."
           (not (gnus-ephemeral-group-p group))
           (gnus-dribble-enter
            (concat "(gnus-group-set-info '"
-                   (gnus-prin1-to-string (nth 2 entry))
+                   (gnus-prin1-to-string (nth 1 entry))
                    ")")
            (concat "^(gnus-group-set-info '(\"" (regexp-quote group) "\"")))
       (setq gnus-group-indentation (gnus-group-group-indentation))
@@ -1455,7 +1447,7 @@ if it is a string, only list groups matching REGEXP."
     (if entry
        (progn
          ;; (Un)subscribed group.
-         (setq info (nth 2 entry))
+         (setq info (nth 1 entry))
          (gnus-group-insert-group-line
           group (gnus-info-level info) (gnus-info-marks info)
           (or (car entry) t) (gnus-info-method info)))
@@ -1472,7 +1464,7 @@ if it is a string, only list groups matching REGEXP."
        (gnus-method-simplify (gnus-find-method-for-group group))))))
 
 (defun gnus-number-of-unseen-articles-in-group (group)
-  (let* ((info (nth 2 (gnus-group-entry group)))
+  (let* ((info (nth 1 (gnus-group-entry group)))
         (marked (gnus-info-marks info))
         (seen (cdr (assq 'seen marked)))
         (active (gnus-active group)))
@@ -1531,7 +1523,7 @@ if it is a string, only list groups matching REGEXP."
              (int-to-string (max 0 (- gnus-tmp-number-total number)))
            "*"))
         (gnus-tmp-subscribed
-         (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
+          (cond ((<= gnus-tmp-level gnus-level-subscribed) ?\s)
                ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
                ((= gnus-tmp-level gnus-level-zombie) ?Z)
                (t ?K)))
@@ -1544,13 +1536,13 @@ if it is a string, only list groups matching REGEXP."
         (gnus-tmp-newsgroup-description
          (if gnus-description-hashtb
              (or (gnus-group-name-decode
-                  (gnus-gethash gnus-tmp-group gnus-description-hashtb)
+                  (gethash gnus-tmp-group gnus-description-hashtb)
                   group-name-charset) "")
            ""))
         (gnus-tmp-moderated
          (if (and gnus-moderated-hashtb
-                  (gnus-gethash gnus-tmp-group gnus-moderated-hashtb))
-             ?m ? ))
+                  (gethash gnus-tmp-group gnus-moderated-hashtb))
+              ?m ?\s))
         (gnus-tmp-moderated-string
          (if (eq gnus-tmp-moderated ?m) "(m)" ""))
          (gnus-tmp-group-icon (gnus-group-get-icon gnus-tmp-group))
@@ -1564,18 +1556,18 @@ if it is a string, only list groups matching REGEXP."
          (if (and (numberp number)
                   (zerop number)
                   (cdr (assq 'tick gnus-tmp-marked)))
-             ?* ? ))
+              ?* ?\s))
         (gnus-tmp-summary-live
          (if (and (not gnus-group-is-exiting-p)
                   (gnus-buffer-live-p (gnus-summary-buffer-name
                                        gnus-tmp-group)))
-             ?* ? ))
+              ?* ?\s))
         (gnus-tmp-process-marked
          (if (member gnus-tmp-group gnus-group-marked)
-             gnus-process-mark ? ))
+              gnus-process-mark ?\s))
         (buffer-read-only nil)
         beg end
-         gnus-tmp-header)      ; passed as parameter to user-funcs.
+         gnus-tmp-header)        ; passed as parameter to user-funcs.
     (beginning-of-line)
     (setq beg (point))
     (add-text-properties
@@ -1585,7 +1577,7 @@ if it is a string, only list groups matching REGEXP."
        (let ((gnus-tmp-decoded-group (gnus-group-name-decode
                                      gnus-tmp-group group-name-charset)))
         (eval gnus-group-line-format-spec)))
-     `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
+     `(gnus-group ,gnus-tmp-group
                  gnus-unread ,(if (numberp number)
                                   (string-to-number gnus-tmp-number-of-unread)
                                 t)
@@ -1619,7 +1611,7 @@ Some value are bound so the form can use them."
   (when list
     (let* ((entry (gnus-group-entry group))
            (active (gnus-active group))
-           (info (nth 2 entry))
+           (info (nth 1 entry))
            (method (inline (gnus-server-get-method
                            group (gnus-info-method info))))
            (marked (gnus-info-marks info))
@@ -1690,9 +1682,7 @@ already.  If INFO-UNCHANGED is non-nil, dribble buffer is 
not updated."
       ;; The buffer may be narrowed.
       (save-restriction
         (widen)
-        (let ((ident (gnus-intern-safe group gnus-active-hashtb))
-              (loc (point-min))
-              found buffer-read-only)
+        (let (found buffer-read-only)
          (unless info-unchanged
            ;; Enter the current status into the dribble buffer.
            (let ((entry (gnus-group-entry group)))
@@ -1700,37 +1690,33 @@ already.  If INFO-UNCHANGED is non-nil, dribble buffer 
is not updated."
                         (not (gnus-ephemeral-group-p group)))
                (gnus-dribble-enter
                 (concat "(gnus-group-set-info '"
-                        (gnus-prin1-to-string (nth 2 entry))
+                        (gnus-prin1-to-string (nth 1 entry))
                         ")")
                 (concat "^(gnus-group-set-info '(\""
                         (regexp-quote group) "\"")))))
-          ;; Find all group instances.  If topics are in use, each group
-          ;; may be listed in more than once.
-          (while (setq loc (text-property-any
-                            loc (point-max) 'gnus-group ident))
+          ;; Find all group instances.  If topics are in use, groups
+          ;; may be listed more than once.
+         (goto-char (point-min))
+          (while (gnus-text-property-search
+                  'gnus-group group 'forward 'goto)
             (setq found t)
-            (goto-char loc)
             (let ((gnus-group-indentation (gnus-group-group-indentation)))
               (gnus-delete-line)
               (gnus-group-insert-group-line-info group)
               (save-excursion
                 (forward-line -1)
-                (gnus-run-hooks 'gnus-group-update-group-hook)))
-            (setq loc (1+ loc)))
+                (gnus-run-hooks 'gnus-group-update-group-hook))))
           (unless (or found visible-only)
             ;; No such line in the buffer, find out where it's supposed to
             ;; go, and insert it there (or at the end of the buffer).
             (if gnus-goto-missing-group-function
                 (funcall gnus-goto-missing-group-function group)
-              (let ((entry (cddr (gnus-group-entry group))))
-                (while (and entry (car entry)
+              (let ((entry (cdr (member group gnus-group-list))))
+               (goto-char (point-min))
+                (while (and (car-safe entry)
                             (not
-                             (gnus-goto-char
-                              (text-property-any
-                               (point-min) (point-max)
-                               'gnus-group (gnus-intern-safe
-                                            (caar entry)
-                                            gnus-active-hashtb)))))
+                             (gnus-text-property-search
+                              'gnus-group (car entry) 'forward 'goto)))
                   (setq entry (cdr entry)))
                 (or entry (goto-char (point-max)))))
             ;; Finally insert the line.
@@ -1778,10 +1764,8 @@ already.  If INFO-UNCHANGED is non-nil, dribble buffer 
is not updated."
 (defun gnus-group-group-name ()
   "Get the name of the newsgroup on the current line."
   (let ((group (get-text-property (point-at-bol) 'gnus-group)))
-    (when group
-      (if (stringp group)
-         group
-       (symbol-name group)))))
+    (cond ((stringp group) group)
+          (group (symbol-name group)))))
 
 (defun gnus-group-group-level ()
   "Get the level of the newsgroup on the current line."
@@ -1801,7 +1785,7 @@ already.  If INFO-UNCHANGED is non-nil, dribble buffer is 
not updated."
 (defun gnus-group-new-mail (group)
   (if (nnmail-new-mail-p (gnus-group-real-name group))
       gnus-new-mail-mark
-    ? ))
+    ?\s))
 
 (defun gnus-group-level (group)
   "Return the estimated level of GROUP."
@@ -1891,7 +1875,7 @@ If FIRST-TOO, the current line is also eligible as a 
target."
        (if unmark
            (progn
              (setq gnus-group-marked (delete group gnus-group-marked))
-             (insert-char ? 1 t))
+              (insert-char ?\s 1 t))
           (setq gnus-group-marked
                 (cons group (delete group gnus-group-marked)))
           (insert-char gnus-process-mark 1 t)))
@@ -2062,7 +2046,7 @@ that group."
     (unless group
       (error "No group on current line"))
     (setq marked (gnus-info-marks
-                 (nth 2 (setq entry (gnus-group-entry group)))))
+                 (nth 1 (setq entry (gnus-group-entry group)))))
     ;; This group might be a dead group.  In that case we have to get
     ;; the number of unread articles from `gnus-active-hashtb'.
     (setq number
@@ -2137,6 +2121,7 @@ be permanent."
       (let ((group (gnus-group-group-name)))
        (when group
          (gnus-group-decoded-name group)))
+    ;; FIXME: Use rx.
     (let ((regexp "address@hidden,/:address@hidden
 \\(nn[a-z]+\\(?:address@hidden,/:address@hidden)?:\
 address@hidden,./:address@hidden(?:address@hidden,./:address@hidden)*\
@@ -2175,34 +2160,39 @@ be permanent."
 (defun gnus-group-completing-read (&optional prompt collection
                                             require-match initial-input hist
                                             def)
-  "Read a group name with completion.  Non-ASCII group names are allowed.
-The arguments are the same as `completing-read' except that COLLECTION
-and HIST default to `gnus-active-hashtb' and `gnus-group-history'
-respectively if they are omitted.  Regards COLLECTION as a hash table
-if it is not a list."
+  "Read a group name with completion.
+Non-ASCII group names are allowed.  The arguments are the same as
+`completing-read' except that COLLECTION and HIST default to
+`gnus-active-hashtb' and `gnus-group-history' respectively if
+they are omitted.  Can handle COLLECTION as a list, hash table,
+or vector."
   (or collection (setq collection gnus-active-hashtb))
-  (let (choices group)
-    (if (listp collection)
-       (dolist (symbol collection)
-         (setq group (symbol-name symbol))
-         (push (if (string-match "[^\000-\177]" group)
-                   (gnus-group-decoded-name group)
-                 group)
-               choices))
-      (mapatoms (lambda (symbol)
-                 (setq group (symbol-name symbol))
-                 (push (if (string-match "[^\000-\177]" group)
-                           (gnus-group-decoded-name group)
-                         group)
-                       choices))
-               collection))
-    (setq group (gnus-completing-read (or prompt "Group") (nreverse choices)
-                                     require-match initial-input
-                                     (or hist 'gnus-group-history)
-                                     def))
-    (unless (if (listp collection)
-               (member group (mapcar 'symbol-name collection))
-             (symbol-value (intern-soft group collection)))
+  (let* ((choices
+         (mapcar
+          (lambda (g)
+            (if (string-match "[^\000-\177]" g)
+                (gnus-group-decoded-name g)
+              g))
+          (cond ((listp collection)
+                 collection)
+                ((vectorp collection)
+                 (mapatoms #'symbol-name collection))
+                ((hash-table-p collection)
+                 (hash-table-keys collection)))))
+        (group
+         (gnus-completing-read (or prompt "Group") (reverse choices)
+                               require-match initial-input
+                               (or hist 'gnus-group-history)
+                               def)))
+    (unless (cond ((and (listp collection)
+                       (symbolp (car collection)))
+                  (member group (mapcar 'symbol-name collection)))
+                 ((listp collection)
+                  (member group collection))
+                 ((vectorp collection)
+                  (symbol-value (intern-soft group collection)))
+                 ((hash-table-p collection)
+                  (gethash group collection)))
       (setq group
            (encode-coding-string
             group (gnus-group-name-charset nil group))))
@@ -2280,7 +2270,8 @@ Return the name of the group if selection was successful."
     (nnheader-init-server-buffer)
     ;; Necessary because of funky inlining.
     (require 'gnus-cache)
-    (setq gnus-newsrc-hashtb (gnus-make-hashtable)))
+    (setq gnus-newsrc-hashtb (gnus-make-hashtable 100)
+         gnus-active-hashtb (gnus-make-hashtable 100)))
   ;; Transform the select method into a unique server.
   (when (stringp method)
     (setq method (gnus-server-to-method method)))
@@ -2297,23 +2288,23 @@ Return the name of the group if selection was 
successful."
                 (gnus-group-prefixed-name (gnus-group-real-name group)
                                           method))))
     (gnus-set-active group nil)
-    (gnus-sethash
+    (puthash
      group
-     `(-1 nil (,group
-              ,gnus-level-default-subscribed nil nil ,method
-              ,(cons
-                (cons 'quit-config
-                      (cond
-                       (quit-config
-                        quit-config)
-                       ((assq gnus-current-window-configuration
-                              gnus-buffer-configuration)
-                        (cons gnus-summary-buffer
-                              gnus-current-window-configuration))
-                       (t
-                        (cons (current-buffer)
-                              (current-window-configuration)))))
-                parameters)))
+     `(-1 (,group
+          ,gnus-level-default-subscribed nil nil ,method
+          ,(cons
+            (cons 'quit-config
+                  (cond
+                   (quit-config
+                    quit-config)
+                   ((assq gnus-current-window-configuration
+                          gnus-buffer-configuration)
+                    (cons gnus-summary-buffer
+                          gnus-current-window-configuration))
+                   (t
+                    (cons (current-buffer)
+                          (current-window-configuration)))))
+            parameters)))
      gnus-newsrc-hashtb)
     (push method gnus-ephemeral-servers)
     (when (gnus-buffer-live-p gnus-group-buffer)
@@ -2558,9 +2549,11 @@ If PROMPT (the prefix) is a number, use the prompt 
specified in
     (gnus-group-position-point)))
 
 (defun gnus-group-goto-group (group &optional far test-marked)
-  "Goto to newsgroup GROUP.
+  "Go to newsgroup GROUP.
 If FAR, it is likely that the group is not on the current line.
-If TEST-MARKED, the line must be marked."
+If TEST-MARKED, the line must be marked.
+
+Return nil if GROUP is not found."
   (when group
     (let ((start (point)))
       (beginning-of-line)
@@ -2568,24 +2561,21 @@ If TEST-MARKED, the line must be marked."
        ;; It's quite likely that we are on the right line, so
        ;; we check the current line first.
        ((and (not far)
-            (eq (get-text-property (point) 'gnus-group)
-                (gnus-intern-safe group gnus-active-hashtb))
+            (equal (get-text-property (point) 'gnus-group) group)
             (or (not test-marked) (gnus-group-mark-line-p)))
        (point))
        ;; Previous and next line are also likely, so we check them as well.
        ((and (not far)
             (save-excursion
               (forward-line -1)
-              (and (eq (get-text-property (point) 'gnus-group)
-                       (gnus-intern-safe group gnus-active-hashtb))
+              (and (equal (get-text-property (point) 'gnus-group) group)
                    (or (not test-marked) (gnus-group-mark-line-p)))))
        (forward-line -1)
        (point))
        ((and (not far)
             (save-excursion
               (forward-line 1)
-              (and (eq (get-text-property (point) 'gnus-group)
-                       (gnus-intern-safe group gnus-active-hashtb))
+              (and (equal (get-text-property (point) 'gnus-group) group)
                    (or (not test-marked) (gnus-group-mark-line-p)))))
        (forward-line 1)
        (point))
@@ -2593,21 +2583,16 @@ If TEST-MARKED, the line must be marked."
        (goto-char (point-min))
        (let (found)
          (while (and (not found)
-                     (gnus-goto-char
-                      (text-property-any
-                       (point) (point-max)
-                       'gnus-group
-                       (gnus-intern-safe group gnus-active-hashtb))))
+                     (gnus-text-property-search
+                      'gnus-group group 'forward 'goto))
            (if (gnus-group-mark-line-p)
                (setq found t)
              (forward-line 1)))
          found))
        (t
        ;; Search through the entire buffer.
-       (if (gnus-goto-char
-            (text-property-any
-             (point-min) (point-max)
-             'gnus-group (gnus-intern-safe group gnus-active-hashtb)))
+       (if (gnus-text-property-search
+            'gnus-group group nil 'goto)
            (point)
          (goto-char start)
          nil))))))
@@ -2775,9 +2760,7 @@ server."
     (gnus-group-change-level
      (setq info (list t nname gnus-level-default-subscribed nil nil meth))
      gnus-level-default-subscribed gnus-level-killed
-     (and (gnus-group-group-name)
-         (gnus-group-entry (gnus-group-group-name)))
-     t)
+     (gnus-group-group-name) t)
     ;; Make it active.
     (gnus-set-active nname (cons 1 0))
     (unless (gnus-ephemeral-group-p name)
@@ -2837,6 +2820,7 @@ If FORCE (the prefix) is non-nil, all the articles in the 
group will
 be deleted.  This is \"deleted\" as in \"removed forever from the face
 of the Earth\".  There is no undo.  The user will be prompted before
 doing the deletion.
+
 Note that you also have to specify FORCE if you want the group to
 be removed from the server, even when it's empty."
   (interactive
@@ -2848,12 +2832,11 @@ be removed from the server, even when it's empty."
     (error "This back end does not support group deletion"))
   (prog1
       (let ((group-decoded (gnus-group-decoded-name group)))
-       (if (and (not no-prompt)
-                (not (gnus-yes-or-no-p
-                      (format
-                       "Do you really want to delete %s%s? "
-                       group-decoded (if force " and all its contents" "")))))
-           ()                          ; Whew!
+       (when (or no-prompt
+                 (gnus-yes-or-no-p
+                  (format
+                   "Do you really want to delete %s%s? "
+                   group-decoded (if force " and all its contents" ""))))
          (gnus-message 6 "Deleting group %s..." group-decoded)
          (if (not (gnus-request-delete-group group force))
              (gnus-error 3 "Couldn't delete group %s" group-decoded)
@@ -3234,7 +3217,7 @@ mail messages or news articles in files that have numeric 
names."
     ;; Subscribe the new group after the group on the current line.
     (gnus-subscribe-group pgroup (gnus-group-group-name) method)
     (gnus-group-update-group pgroup)
-    (forward-line -1)
+    (forward-line)
     (gnus-group-position-point)))
 
 (defun gnus-group-enter-directory (dir)
@@ -3627,7 +3610,7 @@ The return value is the number of articles that were 
marked as read,
 or nil if no action could be taken."
   (let* ((entry (gnus-group-entry group))
         (num (car entry))
-        (marks (gnus-info-marks (nth 2 entry)))
+        (marks (gnus-info-marks (nth 1 entry)))
         (unread (gnus-sequence-of-unread-articles group)))
     ;; Remove entries for this group.
     (nnmail-purge-split-history (gnus-group-real-name group))
@@ -3809,8 +3792,7 @@ group line."
        (or (and (member group gnus-zombie-list)
                gnus-level-zombie)
           gnus-level-killed)
-       (when (gnus-group-group-name)
-        (gnus-group-entry (gnus-group-group-name))))
+       (gnus-group-group-name))
       (unless silent
        (gnus-group-update-group group)))
      (t (error "No such newsgroup: %s" group)))
@@ -3881,10 +3863,12 @@ of groups killed."
              `(progn
                 (gnus-group-goto-group ,(gnus-group-group-name))
                 (gnus-group-yank-group)))
-           (push (cons (car entry) (nth 2 entry))
+           (push (cons (car entry) (nth 1 entry))
                  gnus-list-of-killed-groups))
          (gnus-group-change-level
           (if entry entry group) gnus-level-killed (if entry nil level))
+         ;; FIXME: Since the group has already been removed from
+         ;; `gnus-newsrc-hashtb', this check will always return nil.
          (when (numberp (gnus-group-unread group))
            (gnus-request-update-group-status group 'unsubscribe))
          (message "Killed group %s" (gnus-group-decoded-name group)))
@@ -3902,7 +3886,7 @@ of groups killed."
                   group gnus-level-killed 3))
        (cond
         ((setq entry (gnus-group-entry group))
-         (push (cons (car entry) (nth 2 entry))
+         (push (cons (car entry) (nth 1 entry))
                gnus-list-of-killed-groups)
          (setcdr (cdr entry) (cdddr entry)))
         ((member group gnus-zombie-list)
@@ -3935,9 +3919,7 @@ yanked) a list of yanked groups is returned."
       ;; first newsgroup.
       (setq prev (gnus-group-group-name))
       (gnus-group-change-level
-       info (gnus-info-level (cdr info)) gnus-level-killed
-       (and prev (gnus-group-entry prev))
-       t)
+       info (gnus-info-level (cdr info)) gnus-level-killed prev t)
       (gnus-group-insert-group-line-info group)
       (gnus-request-update-group-status group 'subscribe)
       (gnus-undo-register
@@ -4021,28 +4003,15 @@ entail asking the server for the groups."
          (gnus-agent gnus-plugged)); If we're actually plugged, store the 
active file in the agent.
       (gnus-read-active-file)))
   ;; Find all groups and sort them.
-  (let ((groups
-        (sort
-         (let (list)
-           (mapatoms
-            (lambda (sym)
-              (and (boundp sym)
-                   (symbol-value sym)
-                   (push (symbol-name sym) list)))
-            gnus-active-hashtb)
-           list)
-         'string<))
-       (buffer-read-only nil)
-       group)
+  (let ((buffer-read-only nil))
     (erase-buffer)
-    (while groups
-      (setq group (pop groups))
+    (dolist (group (sort (hash-table-keys gnus-active-hashtb) #'string<))
       (add-text-properties
        (point) (prog1 (1+ (point))
                 (insert "       *: "
                         (gnus-group-decoded-name group)
                         "\n"))
-       (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
+       (list 'gnus-group group
             'gnus-unread t
             'gnus-level (inline (gnus-group-level group)))))
     (goto-char (point-min))))
@@ -4142,17 +4111,17 @@ If DONT-SCAN is non-nil, scan non-activated groups as 
well."
         desc)
     (when (and force
               gnus-description-hashtb)
-      (gnus-sethash mname nil gnus-description-hashtb))
+      (remhash mname gnus-description-hashtb))
     (unless group
       (error "No group name given"))
     (when (or (and gnus-description-hashtb
                   ;; We check whether this group's method has been
                   ;; queried for a description file.
-                  (gnus-gethash mname gnus-description-hashtb))
+                  (gethash mname gnus-description-hashtb))
              (setq desc (gnus-group-get-description group))
              (gnus-read-descriptions-file method))
       (gnus-message 1 "%s"
-                   (or desc (gnus-gethash group gnus-description-hashtb)
+                   (or desc (gethash group gnus-description-hashtb)
                        "No description available")))))
 
 ;; Suggested by Per Abrahamsen <address@hidden>.
@@ -4164,24 +4133,19 @@ If DONT-SCAN is non-nil, scan non-activated groups as 
well."
   (when (not (or gnus-description-hashtb
                 (gnus-read-all-descriptions-files)))
     (error "Couldn't request descriptions file"))
-  (let ((buffer-read-only nil)
-       b groups)
-    (mapatoms
-     (lambda (group)
-       (push (symbol-name group) groups))
-     gnus-description-hashtb)
-    (setq groups (sort groups 'string<))
+  (let ((buffer-read-only nil))
     (erase-buffer)
-    (dolist (group groups)
-      (setq b (point))
-      (let ((charset (gnus-group-name-charset nil group)))
+    (dolist (group (sort (hash-table-keys gnus-description-hashtb) #'string<))
+      (let ((b (point))
+            (desc (gethash group gnus-description-hashtb))
+            (charset (gnus-group-name-charset nil group)))
        (insert (format "      *: %-20s %s\n"
                        (gnus-group-name-decode group charset)
-                       (gnus-group-name-decode group charset))))
-      (add-text-properties
-       b (1+ b) (list 'gnus-group (intern group gnus-description-hashtb)
-                     'gnus-unread t 'gnus-marked nil
-                     'gnus-level (1+ gnus-level-subscribed))))
+                        (gnus-group-name-decode desc charset)))
+        (add-text-properties
+         b (1+ b) (list 'gnus-group group
+                        'gnus-unread t 'gnus-marked nil
+                        'gnus-level (1+ gnus-level-subscribed)))))
     (goto-char (point-min))
     (gnus-group-position-point)))
 
@@ -4193,20 +4157,16 @@ If DONT-SCAN is non-nil, scan non-activated groups as 
well."
        (obuf (current-buffer))
        groups des)
     ;; Go through all newsgroups that are known to Gnus.
-    (mapatoms
-     (lambda (group)
-       (and (symbol-name group)
-           (string-match regexp (symbol-name group))
-           (symbol-value group)
-           (push (symbol-name group) groups)))
+    (maphash
+     (lambda (g-name _)
+       (and (string-match regexp g-name)
+           (push g-name groups)))
      gnus-active-hashtb)
     ;; Also go through all descriptions that are known to Gnus.
     (when search-description
-      (mapatoms
-       (lambda (group)
-        (and (string-match regexp (symbol-value group))
-             (push (symbol-name group) groups)))
-       gnus-description-hashtb))
+      (dolist (g-name (hash-table-keys gnus-description-hashtb))
+       (when (string-match regexp g-name)
+         (push g-name groups))))
     (if (not groups)
        (gnus-message 3 "No groups matched \"%s\"." regexp)
       ;; Print out all the groups.
@@ -4222,8 +4182,8 @@ If DONT-SCAN is non-nil, scan non-activated groups as 
well."
            (let ((charset (gnus-group-name-charset nil prev)))
              (insert (gnus-group-name-decode prev charset) "\n")
              (when (and gnus-description-hashtb
-                        (setq des (gnus-gethash (car groups)
-                                                gnus-description-hashtb)))
+                        (setq des (gethash (car groups)
+                                           gnus-description-hashtb)))
                (insert "  " (gnus-group-name-decode des charset) "\n"))))
          (setq groups (cdr groups)))
        (goto-char (point-min))))
@@ -4468,7 +4428,7 @@ and the second element is the address."
     (let* ((entry (gnus-group-entry
                   (or method-only-group (gnus-info-group info))))
           (part-info info)
-          (info (if method-only-group (nth 2 entry) info))
+          (info (if method-only-group (nth 1 entry) info))
           method)
       (when method-only-group
        (unless entry
@@ -4510,7 +4470,7 @@ and the second element is the address."
       ;; can do the update.
       (if entry
          (progn
-           (setcar (nthcdr 2 entry) info)
+           (setcar (nthcdr 1 entry) info)
            (when (and (not (eq (car entry) t))
                       (gnus-active (gnus-info-group info)))
              (setcar entry (length
@@ -4578,8 +4538,7 @@ and the second element is the address."
 This function can be used in hooks like `gnus-select-group-hook'
 or `gnus-group-catchup-group-hook'."
   (when gnus-newsgroup-name
-    (let ((time (current-time)))
-      (setcdr (cdr time) nil)
+    (let ((time (encode-time nil 'integer)))
       (gnus-group-set-parameter gnus-newsgroup-name 'timestamp time))))
 
 (defsubst gnus-group-timestamp (group)
@@ -4588,11 +4547,11 @@ or `gnus-group-catchup-group-hook'."
 
 (defun gnus-group-timestamp-delta (group)
   "Return the offset in seconds from the timestamp for GROUP to the current 
time, as a floating point number."
-  (let* ((time (or (gnus-group-timestamp group)
-                  (list 0 0)))
-        (delta (time-subtract nil time)))
-    (+ (* (nth 0 delta) 65536.0)
-       (nth 1 delta))))
+  ;; FIXME: This should return a Lisp integer, not a Lisp float,
+  ;; since it is always an integer.
+  (let* ((time (or (gnus-group-timestamp group) 0))
+        (delta (time-since time)))
+    (float-time delta)))
 
 (defun gnus-group-timestamp-string (group)
   "Return a string of the timestamp for GROUP."
@@ -4620,11 +4579,11 @@ This command may read the active file."
                 (assq 'cache marks)))
           lowest
           #'(lambda (group)
-              (or (gnus-gethash group
-                                gnus-cache-active-hashtb)
+              (or (gethash group
+                           gnus-cache-active-hashtb)
                   ;; Cache active file might use "."
                   ;; instead of ":".
-                  (gnus-gethash
+                  (gethash
                    (mapconcat 'identity
                               (split-string group ":")
                               ".")
diff --git a/lisp/gnus/gnus-html.el b/lisp/gnus/gnus-html.el
index f097028..f36c389 100644
--- a/lisp/gnus/gnus-html.el
+++ b/lisp/gnus/gnus-html.el
@@ -1,6 +1,6 @@
 ;;; gnus-html.el --- Render HTML in a buffer.
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: html, web
diff --git a/lisp/gnus/gnus-icalendar.el b/lisp/gnus/gnus-icalendar.el
index 3365c82..53a20b9 100644
--- a/lisp/gnus/gnus-icalendar.el
+++ b/lisp/gnus/gnus-icalendar.el
@@ -1,6 +1,6 @@
-;;; gnus-icalendar.el --- reply to iCalendar meeting requests
+;;; gnus-icalendar.el --- reply to iCalendar meeting requests  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Jan Tatarik <address@hidden>
 ;; Keywords: mail, icalendar, org
@@ -147,7 +147,7 @@
                        (icalendar--get-event-property-attributes
                         event field) zone-map))
          (dtdate-dec (icalendar--decode-isodatetime dtdate nil dtdate-zone)))
-    (apply 'encode-time dtdate-dec)))
+    (encode-time dtdate-dec)))
 
 (defun gnus-icalendar-event--find-attendee (ical name-or-email)
   (let* ((event (car (icalendar--all-events ical)))
@@ -244,7 +244,7 @@
                                (map-property ical-property))
                               args)))))
       (mapc #'accumulate-args prop-map)
-      (apply 'make-instance event-class args))))
+      (apply #'make-instance event-class args))))
 
 (defun gnus-icalendar-event-from-buffer (buf &optional attendee-name-or-email)
   "Parse RFC5545 iCalendar in buffer BUF and return an event object.
@@ -301,7 +301,8 @@ status will be retrieved from the first matching attendee 
record."
                     ((string= key "DTSTAMP") (update-dtstamp))
                     ((member key '("ORGANIZER" "DTSTART" "DTEND"
                                    "LOCATION" "DURATION" "SEQUENCE"
-                                   "RECURRENCE-ID" "UID")) line)
+                                   "RECURRENCE-ID" "UID"))
+                      line)
                     (t nil))))
              (when new-line
                (push new-line reply-event-lines))))))
@@ -352,9 +353,9 @@ on the IDENTITIES list."
 
 ;;;
 ;;; gnus-icalendar-org
-;;;
-;;; TODO: this is an optional feature, and it's only available with org-mode
-;;; 7+, so will need to properly handle emacsen with no/outdated org-mode
+;;
+;; TODO: this is an optional feature, and it's only available with org-mode
+;; 7+, so will need to properly handle emacsen with no/outdated org-mode
 
 (require 'org)
 (require 'org-capture)
@@ -367,23 +368,19 @@ on the IDENTITIES list."
 
 (defcustom gnus-icalendar-org-capture-file nil
   "Target Org file for storing captured calendar events."
-  :type '(choice (const nil) file)
-  :group 'gnus-icalendar-org)
+  :type '(choice (const nil) file))
 
 (defcustom gnus-icalendar-org-capture-headline nil
   "Target outline in `gnus-icalendar-org-capture-file' for storing captured 
events."
-  :type '(repeat string)
-  :group 'gnus-icalendar-org)
+  :type '(repeat string))
 
 (defcustom gnus-icalendar-org-template-name "used by gnus-icalendar-org"
   "Org-mode template name."
-  :type '(string)
-  :group 'gnus-icalendar-org)
+  :type '(string))
 
 (defcustom gnus-icalendar-org-template-key "#"
   "Org-mode template hotkey."
-  :type '(string)
-  :group 'gnus-icalendar-org)
+  :type '(string))
 
 (defvar gnus-icalendar-org-enabled-p nil)
 
@@ -413,13 +410,12 @@ Return nil for non-recurring EVENT."
          (end-time (format-time-string "%H:%M" end))
          (end-at-midnight (string= end-time "00:00"))
          (start-end-date-diff
-         (/ (float-time (time-subtract
-                         (org-time-string-to-time end-date)
-                         (org-time-string-to-time start-date)))
-            86400))
+         (time-to-number-of-days (time-subtract
+                                  (org-time-string-to-time end-date)
+                                  (org-time-string-to-time start-date))))
          (org-repeat (gnus-icalendar-event:org-repeat event))
          (repeat (if org-repeat (concat " " org-repeat) ""))
-         (time-1-day '(0 86400)))
+        (time-1-day 86400))
 
     ;; NOTE: special care is needed with appointments ending at midnight
     ;; (typically all-day events): the end time has to be changed to 23:59 to
@@ -655,10 +651,7 @@ is searched."
 (defun gnus-icalendar-show-org-agenda (event)
   (let* ((time-delta (time-subtract (gnus-icalendar-event:end-time event)
                                     (gnus-icalendar-event:start-time event)))
-         (duration-days (1+ (/ (+ (* (car time-delta) (expt 2 16))
-                                  (cadr time-delta))
-                               86400))))
-
+         (duration-days (1+ (floor (encode-time time-delta 'integer) 86400))))
     (org-agenda-list nil (gnus-icalendar-event:start event) duration-days)))
 
 (cl-defmethod gnus-icalendar-event:sync-to-org ((event 
gnus-icalendar-event-request) reply-status)
@@ -666,7 +659,7 @@ is searched."
       (gnus-icalendar--update-org-event event reply-status)
     (gnus-icalendar:org-event-save event reply-status)))
 
-(cl-defmethod gnus-icalendar-event:sync-to-org ((event 
gnus-icalendar-event-cancel) reply-status)
+(cl-defmethod gnus-icalendar-event:sync-to-org ((event 
gnus-icalendar-event-cancel) _reply-status)
   (when (gnus-icalendar-find-org-event-file event)
     (gnus-icalendar--cancel-org-event event)))
 
@@ -689,8 +682,7 @@ is searched."
 
 (defcustom gnus-icalendar-reply-bufname "*CAL*"
   "Buffer used for building iCalendar invitation reply."
-  :type '(string)
-  :group 'gnus-icalendar)
+  :type '(string))
 
 (defcustom gnus-icalendar-additional-identities nil
   "We need to know your identity to make replies to calendar requests work.
@@ -706,17 +698,13 @@ Your identity is guessed automatically from the variables
 If you need even more aliases you can define them here.  It really
 only makes sense to define names or email addresses."
 
-  :type '(repeat string)
-  :group 'gnus-icalendar)
+  :type '(repeat string))
 
-(make-variable-buffer-local
- (defvar gnus-icalendar-reply-status nil))
+(defvar-local gnus-icalendar-reply-status nil)
 
-(make-variable-buffer-local
- (defvar gnus-icalendar-event nil))
+(defvar-local gnus-icalendar-event nil)
 
-(make-variable-buffer-local
- (defvar gnus-icalendar-handle nil))
+(defvar-local gnus-icalendar-handle nil)
 
 (defun gnus-icalendar-identities ()
   "Return list of regexp-quoted names and email addresses belonging to the 
user.
@@ -742,7 +730,8 @@ These will be used to retrieve the RSVP information from 
ical events."
                              (cadr x))))
 
     (with-slots (organizer summary description location recur uid
-                           method rsvp participation-type) event
+                           method rsvp participation-type)
+        event
       (let ((headers `(("Summary" ,summary)
                       ("Location" ,(or location ""))
                       ("Time" ,(gnus-icalendar-event:org-timestamp event))
@@ -767,7 +756,7 @@ These will be used to retrieve the RSVP information from 
ical events."
     `(let ((,charset (cdr (assoc 'charset (mm-handle-type ,handle)))))
        (with-temp-buffer
          (mm-insert-part ,handle)
-         (when (string= ,charset "utf-8")
+         (when (string= (downcase ,charset) "utf-8")
            (decode-coding-region (point-min) (point-max) 'utf-8))
          ,@body))))
 
@@ -848,7 +837,7 @@ These will be used to retrieve the RSVP information from 
ical events."
       ("Tentative" gnus-icalendar-reply (,handle tentative ,event))
       ("Decline" gnus-icalendar-reply (,handle declined ,event)))))
 
-(cl-defmethod gnus-icalendar-event:inline-reply-buttons ((event 
gnus-icalendar-event-reply) handle)
+(cl-defmethod gnus-icalendar-event:inline-reply-buttons ((_event 
gnus-icalendar-event-reply) _handle)
   "No buttons for REPLY events."
   nil)
 
@@ -857,7 +846,7 @@ These will be used to retrieve the RSVP information from 
ical events."
         (gnus-icalendar--get-org-event-reply-status event))
       "Not replied yet"))
 
-(cl-defmethod gnus-icalendar-event:inline-reply-status ((event 
gnus-icalendar-event-reply))
+(cl-defmethod gnus-icalendar-event:inline-reply-status ((_event 
gnus-icalendar-event-reply))
   "No reply status for REPLY events."
   nil)
 
@@ -884,7 +873,7 @@ These will be used to retrieve the RSVP information from 
ical events."
                (when org-entry-exists-p
                  `("Show Org Entry" gnus-icalendar--show-org-event ,event))))))
 
-
+;;;###autoload
 (defun gnus-icalendar-mm-inline (handle)
   (let ((event (gnus-icalendar-event-from-handle handle 
(gnus-icalendar-identities))))
 
@@ -896,7 +885,7 @@ These will be used to retrieve the RSVP information from 
ical events."
            (buttons)
            (when buttons
              (mapc (lambda (x)
-                     (apply 'gnus-icalendar-insert-button x)
+                     (apply #'gnus-icalendar-insert-button x)
                      (insert "    "))
                    buttons)
              (insert "\n\n"))))
@@ -977,6 +966,9 @@ These will be used to retrieve the RSVP information from 
ical events."
 (defvar gnus-mime-action-alist)         ; gnus-art
 
 (defun gnus-icalendar-setup ()
+  ;; FIXME: Get rid of this!
+  ;; The three add-to-list are now redundant (good), but I think the rest
+  ;; is still not automatically setup.
   (add-to-list 'mm-inlined-types "text/calendar")
   (add-to-list 'mm-automatic-display "text/calendar")
   (add-to-list 'mm-inline-media-tests '("text/calendar" 
gnus-icalendar-mm-inline identity))
@@ -991,7 +983,7 @@ These will be used to retrieve the RSVP information from 
ical events."
 
   (require 'gnus-art)
   (add-to-list 'gnus-mime-action-alist
-               (cons "save calendar event" 'gnus-icalendar-save-event)
+               (cons "save calendar event" #'gnus-icalendar-save-event)
                t))
 
 (provide 'gnus-icalendar)
diff --git a/lisp/gnus/gnus-int.el b/lisp/gnus/gnus-int.el
index 5d5f9eb..e23e53b 100644
--- a/lisp/gnus/gnus-int.el
+++ b/lisp/gnus/gnus-int.el
@@ -1,6 +1,6 @@
 ;;; gnus-int.el --- backend interface functions for Gnus
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
@@ -257,7 +257,8 @@ If it is down, start it up (again)."
       (insert (format-time-string "%H:%M:%S")
              (format " %.2fs %s %S\n"
                      (if (numberp gnus-backend-trace-elapsed)
-                         (- (float-time) gnus-backend-trace-elapsed)
+                         (float-time
+                          (time-since gnus-backend-trace-elapsed))
                        0)
                      type form))
       (setq gnus-backend-trace-elapsed (float-time)))))
diff --git a/lisp/gnus/gnus-kill.el b/lisp/gnus/gnus-kill.el
index e65ff51..a7ded39 100644
--- a/lisp/gnus/gnus-kill.el
+++ b/lisp/gnus/gnus-kill.el
@@ -1,6 +1,6 @@
 ;;; gnus-kill.el --- kill commands for Gnus
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Author: Masanobu UMEDA <address@hidden>
 ;;     Lars Magne Ingebrigtsen <address@hidden>
diff --git a/lisp/gnus/gnus-logic.el b/lisp/gnus/gnus-logic.el
index 2076d8a..90f7420 100644
--- a/lisp/gnus/gnus-logic.el
+++ b/lisp/gnus/gnus-logic.el
@@ -1,6 +1,6 @@
 ;;; gnus-logic.el --- advanced scoring code for Gnus
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
@@ -162,9 +162,9 @@
     (funcall type (or (aref gnus-advanced-headers index) 0) match)))
 
 (defun gnus-advanced-date (index match type)
-  (let ((date (apply 'encode-time (parse-time-string
-                                  (aref gnus-advanced-headers index))))
-       (match (apply 'encode-time (parse-time-string match))))
+  (let ((date (encode-time (parse-time-string
+                           (aref gnus-advanced-headers index))))
+       (match (encode-time (parse-time-string match))))
     (cond
      ((eq type 'at)
       (equal date match))
diff --git a/lisp/gnus/gnus-mh.el b/lisp/gnus/gnus-mh.el
index e91d4f8..1420d70 100644
--- a/lisp/gnus/gnus-mh.el
+++ b/lisp/gnus/gnus-mh.el
@@ -1,6 +1,6 @@
 ;;; gnus-mh.el --- mh-e interface for Gnus
 
-;; Copyright (C) 1994-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-2019 Free Software Foundation, Inc.
 
 ;; Author: Masanobu UMEDA <address@hidden>
 ;;     Lars Magne Ingebrigtsen <address@hidden>
diff --git a/lisp/gnus/gnus-ml.el b/lisp/gnus/gnus-ml.el
index 1c67f5f..6a264e0 100644
--- a/lisp/gnus/gnus-ml.el
+++ b/lisp/gnus/gnus-ml.el
@@ -1,6 +1,6 @@
 ;;; gnus-ml.el --- Mailing list minor mode for Gnus
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Julien Gilles  <address@hidden>
 ;; Keywords: news, mail
diff --git a/lisp/gnus/gnus-mlspl.el b/lisp/gnus/gnus-mlspl.el
index 599b9c6..e9c0de9 100644
--- a/lisp/gnus/gnus-mlspl.el
+++ b/lisp/gnus/gnus-mlspl.el
@@ -1,6 +1,6 @@
 ;;; gnus-mlspl.el --- a group params-based mail splitting mechanism
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Alexandre Oliva <address@hidden>
 ;; Keywords: news, mail
diff --git a/lisp/gnus/gnus-msg.el b/lisp/gnus/gnus-msg.el
index f469afd..b6d649d 100644
--- a/lisp/gnus/gnus-msg.el
+++ b/lisp/gnus/gnus-msg.el
@@ -1,6 +1,6 @@
 ;;; gnus-msg.el --- mail and post interface for Gnus
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Author: Masanobu UMEDA <address@hidden>
 ;;     Lars Magne Ingebrigtsen <address@hidden>
diff --git a/lisp/gnus/gnus-notifications.el b/lisp/gnus/gnus-notifications.el
index 1703df2..3476164 100644
--- a/lisp/gnus/gnus-notifications.el
+++ b/lisp/gnus/gnus-notifications.el
@@ -1,6 +1,6 @@
 ;; gnus-notifications.el -- Send notification on new message in Gnus
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Julien Danjou <address@hidden>
 ;; Keywords: news
diff --git a/lisp/gnus/gnus-picon.el b/lisp/gnus/gnus-picon.el
index b6bb5c9..18b46a1 100644
--- a/lisp/gnus/gnus-picon.el
+++ b/lisp/gnus/gnus-picon.el
@@ -1,6 +1,6 @@
 ;;; gnus-picon.el --- displaying pretty icons in Gnus
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news xpm annotation glyph faces
diff --git a/lisp/gnus/gnus-range.el b/lisp/gnus/gnus-range.el
index dd37935..b775def 100644
--- a/lisp/gnus/gnus-range.el
+++ b/lisp/gnus/gnus-range.el
@@ -1,6 +1,6 @@
 ;;; gnus-range.el --- range and sequence functions for Gnus
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el
index 229d057..634cf92 100644
--- a/lisp/gnus/gnus-registry.el
+++ b/lisp/gnus/gnus-registry.el
@@ -1,6 +1,6 @@
 ;;; gnus-registry.el --- article registry for Gnus
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Ted Zlatanov <address@hidden>
 ;; Keywords: news registry
diff --git a/lisp/gnus/gnus-rfc1843.el b/lisp/gnus/gnus-rfc1843.el
index 4b96845..344ac55 100644
--- a/lisp/gnus/gnus-rfc1843.el
+++ b/lisp/gnus/gnus-rfc1843.el
@@ -1,6 +1,6 @@
 ;;; gnus-rfc1843.el --- HZ (rfc1843) decoding interface functions for Gnus
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Shenghuo Zhu <address@hidden>
 ;; Keywords: news HZ HZ+ mail i18n
diff --git a/lisp/gnus/gnus-salt.el b/lisp/gnus/gnus-salt.el
index 5690c67..58c05e0 100644
--- a/lisp/gnus/gnus-salt.el
+++ b/lisp/gnus/gnus-salt.el
@@ -1,6 +1,6 @@
 ;;; gnus-salt.el --- alternate summary mode interfaces for Gnus
 
-;; Copyright (C) 1996-1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
diff --git a/lisp/gnus/gnus-score.el b/lisp/gnus/gnus-score.el
index 327cc69..2faf0f9 100644
--- a/lisp/gnus/gnus-score.el
+++ b/lisp/gnus/gnus-score.el
@@ -1,6 +1,6 @@
 ;;; gnus-score.el --- scoring code for Gnus
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Author: Per Abrahamsen <address@hidden>
 ;;     Lars Magne Ingebrigtsen <address@hidden>
@@ -1501,7 +1501,7 @@ If FORMAT, also format the current score file."
       (when (and gnus-summary-default-score
                 scores)
        (let* ((entries gnus-header-index)
-              (now (date-to-day (current-time-string)))
+              (now (time-to-days nil))
               (expire (and gnus-score-expiry-days
                            (- now gnus-score-expiry-days)))
               (headers gnus-newsgroup-headers)
@@ -2234,8 +2234,7 @@ score in `gnus-newsgroup-scored' by SCORE."
          (let* ((score (or (nth 1 kill) gnus-score-interactive-default-score))
                 (date (nth 2 kill))
                 found)
-           (when (setq arts (intern-soft (nth 0 kill) hashtb))
-             (setq arts (symbol-value arts))
+           (when (setq arts (gethash (nth 0 kill) hashtb))
              (setq found t)
              (if trace
                  (while (setq art (pop arts))
@@ -2273,11 +2272,11 @@ score in `gnus-newsgroup-scored' by SCORE."
     (with-syntax-table gnus-adaptive-word-syntax-table
       (while (re-search-forward "\\b\\w+\\b" nil t)
        (setq val
-             (gnus-gethash
+             (gethash
               (setq word (downcase (buffer-substring
                                     (match-beginning 0) (match-end 0))))
               hashtb))
-       (gnus-sethash
+       (puthash
         word
         (append (get-text-property (point-at-eol) 'articles) val)
         hashtb)))
@@ -2289,7 +2288,7 @@ score in `gnus-newsgroup-scored' by SCORE."
                                "."))
                           gnus-default-ignored-adaptive-words)))
       (while ignored
-       (gnus-sethash (pop ignored) nil hashtb)))))
+       (remhash (pop ignored) hashtb)))))
 
 (defun gnus-score-string< (a1 a2)
   ;; Compare headers in articles A2 and A2.
@@ -2380,7 +2379,7 @@ score in `gnus-newsgroup-scored' by SCORE."
               (memq 'word gnus-newsgroup-adaptive))
       (with-temp-buffer
        (let* ((hashtb (gnus-make-hashtable 1000))
-              (date (date-to-day (current-time-string)))
+              (date (time-to-days nil))
               (data gnus-newsgroup-data)
               word d score val)
          (with-syntax-table gnus-adaptive-word-syntax-table
@@ -2400,8 +2399,8 @@ score in `gnus-newsgroup-scored' by SCORE."
                (goto-char (point-min))
                (while (re-search-forward "\\b\\w+\\b" nil t)
                  ;; Put the word and score into the hashtb.
-                 (setq val (gnus-gethash (setq word (match-string 0))
-                                         hashtb))
+                 (setq val (gethash (setq word (match-string 0))
+                                    hashtb))
                  (when (or (not gnus-adaptive-word-length-limit)
                            (> (length word)
                               gnus-adaptive-word-length-limit))
@@ -2409,7 +2408,7 @@ score in `gnus-newsgroup-scored' by SCORE."
                    (if (and gnus-adaptive-word-minimum
                             (< val gnus-adaptive-word-minimum))
                        (setq val gnus-adaptive-word-minimum))
-                   (gnus-sethash word val hashtb)))
+                   (puthash word val hashtb)))
                (erase-buffer))))
          ;; Make all the ignorable words ignored.
          (let ((ignored (append gnus-ignored-adaptive-words
@@ -2420,16 +2419,14 @@ score in `gnus-newsgroup-scored' by SCORE."
                                      "."))
                                 gnus-default-ignored-adaptive-words)))
            (while ignored
-             (gnus-sethash (pop ignored) nil hashtb)))
+             (remhash (pop ignored) hashtb)))
          ;; Now we have all the words and scores, so we
          ;; add these rules to the ADAPT file.
          (set-buffer gnus-summary-buffer)
-         (mapatoms
-          (lambda (word)
-            (when (symbol-value word)
-              (gnus-summary-score-entry
-               "subject" (symbol-name word) 'w (symbol-value word)
-               date nil t)))
+         (maphash
+          (lambda (word val)
+            (gnus-summary-score-entry
+             "subject" word 'w val date nil t))
           hashtb))))))
 
 (defun gnus-score-edit-done ()
diff --git a/lisp/gnus/gnus-sieve.el b/lisp/gnus/gnus-sieve.el
index f09478d..fc0bf30 100644
--- a/lisp/gnus/gnus-sieve.el
+++ b/lisp/gnus/gnus-sieve.el
@@ -1,6 +1,6 @@
 ;;; gnus-sieve.el --- Utilities to manage sieve scripts for Gnus
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: NAGY Andras <address@hidden>,
 ;;     Simon Josefsson <address@hidden>
diff --git a/lisp/gnus/gnus-spec.el b/lisp/gnus/gnus-spec.el
index 4b5f15f..b236f0a 100644
--- a/lisp/gnus/gnus-spec.el
+++ b/lisp/gnus/gnus-spec.el
@@ -1,6 +1,6 @@
 ;;; gnus-spec.el --- format spec functions for Gnus
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
diff --git a/lisp/gnus/gnus-srvr.el b/lisp/gnus/gnus-srvr.el
index 5bdf358..76a0f7d 100644
--- a/lisp/gnus/gnus-srvr.el
+++ b/lisp/gnus/gnus-srvr.el
@@ -1,6 +1,6 @@
 ;;; gnus-srvr.el --- virtual server support for Gnus
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
diff --git a/lisp/gnus/gnus-start.el b/lisp/gnus/gnus-start.el
index f15d645..2f8a260 100644
--- a/lisp/gnus/gnus-start.el
+++ b/lisp/gnus/gnus-start.el
@@ -1,6 +1,6 @@
 ;;; gnus-start.el --- startup functions for Gnus
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
@@ -543,29 +543,21 @@ Can be used to turn version control on or off."
                (message "Descend hierarchy %s? ([y]nsq): "
                         (substring prefix 1 (1- (length prefix)))))
              (cond ((= ans ?n)
-                    (while (and groups
-                                (setq group (car groups)
-                                      real-group (gnus-group-real-name group))
-                                (string-match prefix real-group))
-                      (push group gnus-killed-list)
-                      (gnus-sethash group group gnus-killed-hashtb)
-                      (setq groups (cdr groups)))
+                    (dolist (g groups)
+                      (when (string-match prefix (gnus-group-real-name g))
+                        (push g gnus-killed-list)
+                        (puthash g t gnus-killed-hashtb)))
                     (setq starts (cdr starts)))
                    ((= ans ?s)
-                    (while (and groups
-                                (setq group (car groups)
-                                      real-group (gnus-group-real-name group))
-                                (string-match prefix real-group))
-                      (gnus-sethash group group gnus-killed-hashtb)
-                      (gnus-subscribe-alphabetically (car groups))
-                      (setq groups (cdr groups)))
+                    (dolist (g groups)
+                      (when (string-match prefix (gnus-group-real-name g))
+                        (puthash g t gnus-killed-hashtb)
+                        (gnus-subscribe-alphabetically g)))
                     (setq starts (cdr starts)))
                    ((= ans ?q)
-                    (while groups
-                      (setq group (car groups))
-                      (push group gnus-killed-list)
-                      (gnus-sethash group group gnus-killed-hashtb)
-                      (setq groups (cdr groups))))
+                    (dolist (g groups)
+                      (push g gnus-killed-list)
+                      (puthash g t gnus-killed-hashtb)))
                    (t nil)))
          (message "Subscribe %s? ([n]yq)" (car groups))
          (while (not (memq (setq ans (read-char-exclusive))
@@ -575,16 +567,14 @@ Can be used to turn version control on or off."
          (setq group (car groups))
          (cond ((= ans ?y)
                 (gnus-subscribe-alphabetically (car groups))
-                (gnus-sethash group group gnus-killed-hashtb))
+                (puthash group t gnus-killed-hashtb))
                ((= ans ?q)
-                (while groups
-                  (setq group (car groups))
-                  (push group gnus-killed-list)
-                  (gnus-sethash group group gnus-killed-hashtb)
-                  (setq groups (cdr groups))))
+                (dolist (g groups)
+                  (push g gnus-killed-list)
+                  (puthash g t gnus-killed-hashtb)))
                (t
                 (push group gnus-killed-list)
-                (gnus-sethash group group gnus-killed-hashtb)))
+                (puthash group t gnus-killed-hashtb)))
          (setq groups (cdr groups)))))))
 
 (defun gnus-subscribe-randomly (newsgroup)
@@ -647,7 +637,7 @@ the first newsgroup."
     ;; We subscribe the group by changing its level to `subscribed'.
     (gnus-group-change-level
      newsgroup gnus-level-default-subscribed
-     gnus-level-killed (gnus-group-entry (or next "dummy.group")))
+     gnus-level-killed (or next "dummy.group"))
     (gnus-request-update-group-status newsgroup 'subscribe)
     (gnus-message 5 "Subscribe newsgroup: %s" newsgroup)
     (run-hook-with-args 'gnus-subscribe-newsgroup-functions newsgroup)
@@ -696,6 +686,7 @@ the first newsgroup."
         gnus-agent-file-loading-cache nil
         gnus-server-method-cache nil
        gnus-newsrc-alist nil
+       gnus-group-list nil
        gnus-newsrc-hashtb nil
        gnus-killed-list nil
        gnus-zombie-list nil
@@ -1018,7 +1009,7 @@ If LEVEL is non-nil, the news will be set up at level 
LEVEL."
              (eq gnus-read-active-file 'some))
       (gnus-update-active-hashtb-from-killed))
     (unless gnus-active-hashtb
-      (setq gnus-active-hashtb (gnus-make-hashtable 4096)))
+      (setq gnus-active-hashtb (gnus-make-hashtable 4000)))
     ;; Initialize the cache.
     (when gnus-use-cache
       (gnus-cache-open))
@@ -1108,7 +1099,7 @@ for new groups, and subscribe the new groups as zombies."
         (gnus-ask-server-for-new-groups)
       ;; Go through the active hashtb and look for new groups.
       (let ((groups 0)
-            group new-newsgroups)
+            new-newsgroups)
         (gnus-message 5 "Looking for new newsgroups...")
         (unless gnus-have-read-active-file
           (gnus-read-active-file))
@@ -1117,30 +1108,26 @@ for new groups, and subscribe the new groups as 
zombies."
           (gnus-make-hashtable-from-killed))
         ;; Go though every newsgroup in `gnus-active-hashtb' and compare
         ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
-        (mapatoms
-         (lambda (sym)
-           (if (or (null (setq group (symbol-name sym)))
-                   (not (boundp sym))
-                   (null (symbol-value sym))
-                   (gnus-gethash group gnus-killed-hashtb)
-                   (gnus-gethash group gnus-newsrc-hashtb))
-               ()
-             (let ((do-sub (gnus-matches-options-n group)))
+        (maphash
+         (lambda (g-name active)
+           (unless (or (gethash g-name gnus-killed-hashtb)
+                       (gethash g-name gnus-newsrc-hashtb))
+             (let ((do-sub (gnus-matches-options-n g-name)))
                (cond
                 ((eq do-sub 'subscribe)
                  (setq groups (1+ groups))
-                 (gnus-sethash group group gnus-killed-hashtb)
+                 (puthash g-name t gnus-killed-hashtb)
                  (gnus-call-subscribe-functions
-                  gnus-subscribe-options-newsgroup-method group))
+                  gnus-subscribe-options-newsgroup-method g-name))
                 ((eq do-sub 'ignore)
                  nil)
                 (t
                  (setq groups (1+ groups))
-                 (gnus-sethash group group gnus-killed-hashtb)
+                 (puthash g-name t gnus-killed-hashtb)
                  (if gnus-subscribe-hierarchical-interactive
-                     (push group new-newsgroups)
+                     (push g-name new-newsgroups)
                    (gnus-call-subscribe-functions
-                    gnus-subscribe-newsgroup-method group)))))))
+                    gnus-subscribe-newsgroup-method g-name)))))))
          gnus-active-hashtb)
         (when new-newsgroups
           (gnus-subscribe-hierarchical-interactive new-newsgroups))
@@ -1213,36 +1200,32 @@ for new groups, and subscribe the new groups as 
zombies."
          ;; Enter all the new groups into a hashtable.
          (gnus-active-to-gnus-format method hashtb 'ignore))
        ;; Now all new groups from `method' are in `hashtb'.
-       (mapatoms
-        (lambda (group-sym)
-          (if (or (null (setq group (symbol-name group-sym)))
-                  (not (boundp group-sym))
-                  (null (symbol-value group-sym))
-                  (gnus-gethash group gnus-newsrc-hashtb)
-                  (member group gnus-zombie-list)
-                  (member group gnus-killed-list))
-              ;; The group is already known.
-              ()
+       (maphash
+        (lambda (g-name val)
+          (unless (or (null val) ; The group is already known.
+                      (gethash g-name gnus-newsrc-hashtb)
+                      (member g-name gnus-zombie-list)
+                      (member g-name gnus-killed-list))
             ;; Make this group active.
-            (when (symbol-value group-sym)
-              (gnus-set-active group (symbol-value group-sym)))
+            (when val
+              (gnus-set-active g-name val))
             ;; Check whether we want it or not.
-            (let ((do-sub (gnus-matches-options-n group)))
+            (let ((do-sub (gnus-matches-options-n g-name)))
               (cond
                ((eq do-sub 'subscribe)
                 (cl-incf groups)
-                (gnus-sethash group group gnus-killed-hashtb)
+                (puthash g-name group gnus-killed-hashtb)
                 (gnus-call-subscribe-functions
-                 gnus-subscribe-options-newsgroup-method group))
+                 gnus-subscribe-options-newsgroup-method g-name))
                ((eq do-sub 'ignore)
                 nil)
                (t
                 (cl-incf groups)
-                (gnus-sethash group group gnus-killed-hashtb)
+                (puthash g-name group gnus-killed-hashtb)
                 (if gnus-subscribe-hierarchical-interactive
-                    (push group new-newsgroups)
+                    (push g-name new-newsgroups)
                   (gnus-call-subscribe-functions
-                   gnus-subscribe-newsgroup-method group)))))))
+                   gnus-subscribe-newsgroup-method g-name)))))))
         hashtb))
       (when new-newsgroups
        (gnus-subscribe-hierarchical-interactive new-newsgroups)))
@@ -1263,29 +1246,28 @@ for new groups, and subscribe the new groups as 
zombies."
    gnus-level-default-subscribed gnus-level-killed previous t)
   t)
 
-;; `gnus-group-change-level' is the fundamental function for changing
-;; subscription levels of newsgroups.  This might mean just changing
-;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
-;; again, which subscribes/unsubscribes a group, which is equally
-;; trivial.  Changing from 1-7 to 8-9 means that you kill a group, and
-;; from 8-9 to 1-7 means that you remove the group from the list of
-;; killed (or zombie) groups and add them to the (kinda) subscribed
-;; groups.  And last but not least, moving from 8 to 9 and 9 to 8,
-;; which is trivial.
-;; ENTRY can either be a string (newsgroup name) or a list (if
-;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
-;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
-;; entries.
-;; LEVEL is the new level of the group, OLDLEVEL is the old level and
-;; PREVIOUS is the group (in hashtb entry format) to insert this group
-;; after.
+
 (defun gnus-group-change-level (entry level &optional oldlevel
                                      previous fromkilled)
+  "Change level of group ENTRY to LEVEL.
+This is the fundamental function for changing subscription levels
+of newsgroups.  This might mean just changing from level 1 to 2,
+which is pretty trivial, from 2 to 6 or back again, which
+subscribes/unsubscribes a group, which is equally trivial.
+Changing from 1-7 to 8-9 means that you kill a group, and from
+8-9 to 1-7 means that you remove the group from the list of
+killed (or zombie) groups and add them to the (kinda) subscribed
+groups.  And last but not least, moving from 8 to 9 and 9 to 8,
+which is trivial.  ENTRY can either be a string (newsgroup name)
+or a list (if FROMKILLED is t, it's a list on the format (NUM
+INFO-LIST), otherwise it's a list in the format of the
+`gnus-newsrc-hashtb' entries.  LEVEL is the new level of the
+group, OLDLEVEL is the old level and PREVIOUS is the group (a
+string name) to insert this group after."
   (let (group info active num)
-    ;; Glean what info we can from the arguments
+    ;; Glean what info we can from the arguments.
     (if (consp entry)
-       (if fromkilled (setq group (nth 1 entry))
-         (setq group (car (nth 2 entry))))
+       (setq group (if fromkilled (nth 1 entry) (car (nth 1 entry))))
       (setq group entry))
     (when (and (stringp entry)
               oldlevel
@@ -1293,21 +1275,17 @@ for new groups, and subscribe the new groups as 
zombies."
       (setq entry (gnus-group-entry entry)))
     (if (and (not oldlevel)
             (consp entry))
-       (setq oldlevel (gnus-info-level (nth 2 entry)))
+       (setq oldlevel (gnus-info-level (nth 1 entry)))
       (setq oldlevel (or oldlevel gnus-level-killed)))
     (when (stringp previous)
       (setq previous (gnus-group-entry previous)))
-
-    (if (and (>= oldlevel gnus-level-zombie)
-            (gnus-group-entry group))
-       ;; We are trying to subscribe a group that is already
-       ;; subscribed.
-       ()                              ; Do nothing.
-
+    ;; Group is already subscribed.
+    (unless (and (>= oldlevel gnus-level-zombie)
+                (gnus-group-entry group))
       (unless (gnus-ephemeral-group-p group)
        (gnus-dribble-enter
         (format "(gnus-group-change-level %S %S %S %S %S)"
-                group level oldlevel (car (nth 2 previous)) fromkilled)))
+                group level oldlevel previous fromkilled)))
 
       ;; Then we remove the newgroup from any old structures, if needed.
       ;; If the group was killed, we remove it from the killed or zombie
@@ -1321,11 +1299,10 @@ for new groups, and subscribe the new groups as 
zombies."
        (t
        (when (and (>= level gnus-level-zombie)
                   entry)
-         (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
-         (when (nth 3 entry)
-           (setcdr (gnus-group-entry (car (nth 3 entry)))
-                   (cdr entry)))
-         (setcdr (cdr entry) (cdddr entry)))))
+         (remhash (car (nth 1 entry)) gnus-newsrc-hashtb)
+         (setq gnus-group-list (remove group gnus-group-list))
+         (setq gnus-newsrc-alist (delq (assoc group gnus-newsrc-alist)
+                                       gnus-newsrc-alist)))))
 
       ;; Finally we enter (if needed) the list where it is supposed to
       ;; go, and change the subscription level.  If it is to be killed,
@@ -1333,12 +1310,13 @@ for new groups, and subscribe the new groups as 
zombies."
       (cond
        ((>= level gnus-level-zombie)
        ;; Remove from the hash table.
-       (gnus-sethash group nil gnus-newsrc-hashtb)
+       (remhash group gnus-newsrc-hashtb)
+       (setq gnus-group-list (remove group gnus-group-list))
        (if (= level gnus-level-zombie)
            (push group gnus-zombie-list)
          (if (= oldlevel gnus-level-killed)
              ;; Remove from active hashtb.
-             (unintern group gnus-active-hashtb)
+             (remhash group gnus-active-hashtb)
            ;; Don't add it into killed-list if it was killed.
            (push group gnus-killed-list))))
        (t
@@ -1349,7 +1327,7 @@ for new groups, and subscribe the new groups as zombies."
            ;; It was alive, and it is going to stay alive, so we
            ;; just change the level and don't change any pointers or
            ;; hash table entries.
-           (setcar (cdaddr entry) level)
+           (setcar (cdadr entry) level)
          (if (listp entry)
              (setq info (cdr entry)
                    num (car entry))
@@ -1364,23 +1342,16 @@ for new groups, and subscribe the new groups as 
zombies."
              (if method
                  (setq info (list group level nil nil method))
                (setq info (list group level nil)))))
-         (unless previous
-           (setq previous
-                 (let ((p gnus-newsrc-alist))
-                   (while (cddr p)
-                     (setq p (cdr p)))
-                   p)))
-         (setq entry (cons info (cddr previous)))
-         (if (cdr previous)
-             (progn
-               (setcdr (cdr previous) entry)
-               (gnus-sethash group (cons num (cdr previous))
-                             gnus-newsrc-hashtb))
-           (setcdr previous entry)
-           (gnus-sethash group (cons num previous)
-                         gnus-newsrc-hashtb))
-         (when (cdr entry)
-           (setcdr (gnus-group-entry (caadr entry)) entry))
+         ;; Add group.  The exact ordering only matters for
+         ;; `gnus-group-list', though we need to keep the dummy group
+         ;; at the head of `gnus-newsrc-alist'.
+         (push info (cdr gnus-newsrc-alist))
+         (puthash group (list num info) gnus-newsrc-hashtb)
+         (let* ((prev-idx (seq-position gnus-group-list (caadr previous)))
+                (idx (if prev-idx
+                         (1+ prev-idx)
+                       (length gnus-group-list))))
+           (push group (nthcdr idx gnus-group-list)))
          (gnus-dribble-enter
           (format "(gnus-group-set-info '%S)" info)
           (concat "^(gnus-group-set-info '(\"" (regexp-quote group) "\"")))))
@@ -1455,7 +1426,7 @@ newsgroup."
   (defun gnus-cache-possibly-alter-active (group active)
     "Alter the ACTIVE info for GROUP to reflect the articles in the cache."
     (when gnus-cache-active-hashtb
-      (let ((cache-active (gnus-gethash group gnus-cache-active-hashtb)))
+      (let ((cache-active (gethash group gnus-cache-active-hashtb)))
        (when cache-active
          (when (< (car cache-active) (car active))
            (setcar active (car cache-active)))
@@ -1837,19 +1808,25 @@ backend check whether the group actually exists."
       (dolist (info infos)
        (gnus-activate-group (gnus-info-group info) nil nil method t))))))
 
-;; Create a hash table out of the newsrc alist.  The `car's of the
-;; alist elements are used as keys.
 (defun gnus-make-hashtable-from-newsrc-alist ()
+  "Create a hash table from `gnus-newsrc-alist'.
+The keys are group names, and values are a cons of (unread info),
+where unread is an integer count of calculated unread
+messages (or nil), and info is a regular gnus info entry.
+
+The info element is shared with the same element of
+`gnus-newrc-alist', so as to conserve space."
   (let ((alist gnus-newsrc-alist)
        (ohashtb gnus-newsrc-hashtb)
-       prev info method rest methods)
-    (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
+       info method gname rest methods)
+    (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist))
+         gnus-group-list nil)
     (setq alist
-         (setq prev (setq gnus-newsrc-alist
-                          (if (equal (caar gnus-newsrc-alist)
-                                     "dummy.group")
-                              gnus-newsrc-alist
-                            (cons (list "dummy.group" 0 nil) alist)))))
+         (setq gnus-newsrc-alist
+               (if (equal (caar gnus-newsrc-alist)
+                          "dummy.group")
+                   gnus-newsrc-alist
+                 (cons (list "dummy.group" 0 nil) alist))))
     (while alist
       (setq info (car alist))
       ;; Make the same select-methods identical Lisp objects.
@@ -1858,17 +1835,18 @@ backend check whether the group actually exists."
            (gnus-info-set-method info (car rest))
          (push method methods)))
       ;; Check for duplicates.
-      (if (gnus-gethash (car info) gnus-newsrc-hashtb)
+      (if (gethash (car info) gnus-newsrc-hashtb)
          ;; Remove this entry from the alist.
-         (setcdr prev (cddr prev))
-       (gnus-sethash
+         (setcdr alist (cddr alist))
+       (puthash
         (car info)
         ;; Preserve number of unread articles in groups.
-        (cons (and ohashtb (car (gnus-gethash (car info) ohashtb)))
-              prev)
+        (list (and ohashtb (car (gethash (car info) ohashtb)))
+              info)
         gnus-newsrc-hashtb)
-       (setq prev alist))
+       (push (car info) gnus-group-list))
       (setq alist (cdr alist)))
+    (setq gnus-group-list (nreverse gnus-group-list))
     ;; Make the same select-methods in `gnus-server-alist' identical
     ;; as well.
     (while methods
@@ -1883,10 +1861,10 @@ backend check whether the group actually exists."
     (setq gnus-killed-hashtb
          (gnus-make-hashtable
           (+ (length gnus-killed-list) (length gnus-zombie-list))))
-    (while lists
-      (setq list (symbol-value (pop lists)))
-      (while list
-       (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
+    (dolist (g (append gnus-killed-list gnus-zombie-list))
+      ;; NOTE: We have lost the ordering that used to be kept in this
+      ;; variable.
+      (puthash g t gnus-killed-hashtb))))
 
 (defun gnus-parse-active ()
   "Parse active info in the nntp server buffer."
@@ -1900,7 +1878,7 @@ backend check whether the group actually exists."
 
 (defun gnus-make-articles-unread (group articles)
   "Mark ARTICLES in GROUP as unread."
-  (let* ((info (nth 2 (or (gnus-group-entry group)
+  (let* ((info (nth 1 (or (gnus-group-entry group)
                          (gnus-group-entry
                           (gnus-group-real-name group)))))
         (ranges (gnus-info-read info))
@@ -1924,7 +1902,7 @@ backend check whether the group actually exists."
   "Mark ascending ARTICLES in GROUP as unread."
   (let* ((entry (or (gnus-group-entry group)
                     (gnus-group-entry (gnus-group-real-name group))))
-         (info (nth 2 entry))
+         (info (nth 1 entry))
         (ranges (gnus-info-read info))
          (r ranges)
         modified)
@@ -1987,12 +1965,11 @@ backend check whether the group actually exists."
       ;; Insert the change into the group buffer and the dribble file.
       (gnus-group-update-group group t))))
 
-;; Enter all dead groups into the hashtb.
 (defun gnus-update-active-hashtb-from-killed ()
-  (let ((hashtb (setq gnus-active-hashtb (gnus-make-hashtable 4096))))
-    (dolist (list (list gnus-killed-list gnus-zombie-list))
-      (dolist (group list)
-       (gnus-sethash group nil hashtb)))))
+  (let ((hashtb (setq gnus-active-hashtb
+                     (gnus-make-hashtable 4000))))
+    (dolist (g (append gnus-killed-list gnus-zombie-list))
+      (remhash g hashtb))))
 
 (defun gnus-get-killed-groups ()
   "Go through the active hashtb and mark all unknown groups as killed."
@@ -2003,20 +1980,16 @@ backend check whether the group actually exists."
   (unless gnus-killed-hashtb
     (gnus-make-hashtable-from-killed))
   ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
-  (mapatoms
-   (lambda (sym)
-     (let ((groups 0)
-          (group (symbol-name sym)))
-       (if (or (null group)
-              (gnus-gethash group gnus-killed-hashtb)
-              (gnus-gethash group gnus-newsrc-hashtb))
-          ()
-        (let ((do-sub (gnus-matches-options-n group)))
-          (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
-              ()
+  (maphash
+   (lambda (g-name active)
+     (let ((groups 0))
+       (unless (or (gethash g-name gnus-killed-hashtb)
+                  (gethash g-name gnus-newsrc-hashtb))
+        (let ((do-sub (gnus-matches-options-n g-name)))
+          (unless (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
             (setq groups (1+ groups))
-            (push group gnus-killed-list)
-            (gnus-sethash group group gnus-killed-hashtb))))))
+            (push g-name gnus-killed-list)
+            (puthash g-name t gnus-killed-hashtb))))))
    gnus-active-hashtb)
   (gnus-dribble-touch))
 
@@ -2129,11 +2102,13 @@ backend check whether the group actually exists."
                             (not (equal method gnus-select-method)))
                        gnus-active-hashtb
                      (setq gnus-active-hashtb
-                           (if (equal method gnus-select-method)
-                               (gnus-make-hashtable
-                                (count-lines (point-min) (point-max)))
-                             (gnus-make-hashtable 4096))))))
+                           (gnus-make-hashtable
+                            (if (equal method gnus-select-method)
+                                (count-lines (point-min) (point-max))
+                              4000))))))
        group max min)
+    (unless gnus-moderated-hashtb
+      (setq gnus-moderated-hashtb (gnus-make-hashtable 100)))
     ;; Delete unnecessary lines.
     (goto-char (point-min))
     (cond
@@ -2143,12 +2118,6 @@ backend check whether the group actually exists."
       (delete-matching-lines (concat "^to\\.\\|" gnus-ignored-newsgroups))))
 
     (goto-char (point-min))
-    (unless (re-search-forward "[\\\"]" nil t)
-      ;; Make the group names readable as a lisp expression even if they
-      ;; contain special characters.
-      (goto-char (point-max))
-      (while (re-search-backward "[][';?()#]" nil t)
-       (insert ?\\)))
 
     ;; Let the Gnus agent save the active file.
     (when (and gnus-agent real-active (gnus-online method))
@@ -2168,49 +2137,41 @@ backend check whether the group actually exists."
                      (insert prefix)
                      (zerop (forward-line 1)))))))
     ;; Store the active file in a hash table.
-    ;; Use a unibyte buffer in order to make `read' read non-ASCII
-    ;; group names (which have been encoded) as unibyte strings.
-    (mm-with-unibyte-buffer
+
+    (with-temp-buffer
       (insert-buffer-substring cur)
       (setq cur (current-buffer))
       (goto-char (point-min))
       (while (not (eobp))
        (condition-case ()
-           (progn
-             (narrow-to-region (point) (point-at-eol))
-             ;; group gets set to a symbol interned in the hash table
-             ;; (what a hack!!) - jwz
-             (setq group (let ((obarray hashtb)) (read cur)))
-             ;; ### The extended group name scheme makes
-             ;; the previous optimization strategy sort of pointless...
-             (when (stringp group)
-               (setq group (intern group hashtb)))
-             (if (and (numberp (setq max (read cur)))
-                      (numberp (setq min (read cur)))
-                      (progn
-                        (skip-chars-forward " \t")
-                        (not
-                         (or (eq (char-after) ?=)
-                             (eq (char-after) ?x)
-                             (eq (char-after) ?j)))))
-                 (progn
-                   (set group (cons min max))
-                   ;; if group is moderated, stick in moderation table
-                   (when (eq (char-after) ?m)
-                     (unless gnus-moderated-hashtb
-                       (setq gnus-moderated-hashtb (gnus-make-hashtable)))
-                     (gnus-sethash (symbol-name group) t
-                                   gnus-moderated-hashtb)))
-               (set group nil)))
+           (if (and (stringp (progn
+                               (setq group (read cur)
+                                     group
+                                     (cond ((numberp group)
+                                            (number-to-string group))
+                                           ((symbolp group)
+                                            (encode-coding-string
+                                             (symbol-name group)
+                                             'latin-1))
+                                           ((stringp group)
+                                            group)))))
+                    (numberp (setq max (read cur)))
+                    (numberp (setq min (read cur)))
+                    (null (progn
+                            (skip-chars-forward " \t")
+                            (memq (char-after)
+                                  '(?= ?x ?j)))))
+               (progn (puthash group (cons min max) hashtb)
+                      ;; If group is moderated, stick it in the
+                      ;; moderation cache.
+                      (when (eq (char-after) ?m)
+                        (puthash group t gnus-moderated-hashtb)))
+             (setq group nil))
          (error
-          (and group
-               (symbolp group)
-               (set group nil))
           (unless ignore-errors
             (gnus-message 3 "Warning - invalid active: %s"
                           (buffer-substring
                            (point-at-bol) (point-at-eol))))))
-       (widen)
        (forward-line 1)))))
 
 (defun gnus-groups-to-gnus-format (method &optional hashtb real-active)
@@ -2238,35 +2199,23 @@ backend check whether the group actually exists."
          (gnus-active-to-gnus-format method hashtb nil real-active))
 
       (goto-char (point-min))
-      ;; We split this into to separate loops, one with the prefix
-      ;; and one without to speed the reading up somewhat.
-      (if prefix
-         (let (min max opoint group)
-           (while (not (eobp))
-             (condition-case ()
-                 (progn
-                   (read cur) (read cur)
-                   (setq min (read cur)
-                         max (read cur)
-                         opoint (point))
-                   (skip-chars-forward " \t")
-                   (insert prefix)
-                   (goto-char opoint)
-                   (set (let ((obarray hashtb)) (read cur))
-                        (cons min max)))
-               (error (and group (symbolp group) (set group nil))))
-             (forward-line 1)))
-       (let (min max group)
-         (while (not (eobp))
-           (condition-case ()
-               (when (eq (char-after) ?2)
-                 (read cur) (read cur)
-                 (setq min (read cur)
-                       max (read cur))
-                 (set (setq group (let ((obarray hashtb)) (read cur)))
-                      (cons min max)))
-             (error (and group (symbolp group) (set group nil))))
-           (forward-line 1)))))))
+      (let (min max group)
+       (while (not (eobp))
+         (condition-case ()
+             (when (eq (char-after) ?2)
+               (read cur) (read cur)
+               (setq min (read cur)
+                     max (read cur)
+                     group (read cur)
+                     group (if (numberp group)
+                               (number-to-string group)
+                             (symbol-name group)))
+               (puthash (if prefix
+                            (concat prefix group)
+                            group)
+                        (cons min max) hashtb))
+           (error (remhash group hashtb)))
+         (forward-line 1))))))
 
 (defun gnus-read-newsrc-file (&optional force)
   "Read startup file.
@@ -2529,16 +2478,11 @@ If FORCE is non-nil, the .newsrc file is read."
   (setq gnus-newsrc-options-n nil)
 
   (unless gnus-active-hashtb
-    (setq gnus-active-hashtb (gnus-make-hashtable 4096)))
+    (setq gnus-active-hashtb (gnus-make-hashtable 4000)))
   (let ((buf (current-buffer))
        (already-read (> (length gnus-newsrc-alist) 1))
-       group subscribed options-symbol newsrc Options-symbol
-       symbol reads num1)
+       group subscribed newsrc reads num1)
     (goto-char (point-min))
-    ;; We intern the symbol `options' in the active hashtb so that we
-    ;; can `eq' against it later.
-    (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
-    (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
 
     (while (not (eobp))
       ;; We first read the first word on the line by narrowing and
@@ -2549,15 +2493,16 @@ If FORCE is non-nil, the .newsrc file is read."
        (point)
        (progn (skip-chars-forward "^ \t!:\n") (point)))
       (goto-char (point-min))
-      (setq symbol
+      (setq group
            (and (/= (point-min) (point-max))
-                (let ((obarray gnus-active-hashtb)) (read buf))))
+                (read buf))
+           group (if (numberp group)
+                     (number-to-string group)
+                   (symbol-name group)))
       (widen)
-      ;; Now, the symbol we have read is either `options' or a group
-      ;; name.  If it is an options line, we just add it to a string.
       (cond
-       ((or (eq symbol options-symbol)
-           (eq symbol Options-symbol))
+       ;; It's possible that "group" is actually an options line.
+       ((string-equal (downcase group) "options")
        (setq gnus-newsrc-options
              ;; This concatting is quite inefficient, but since our
              ;; thorough studies show that approx 99.37% of all
@@ -2571,19 +2516,13 @@ If FORCE is non-nil, the .newsrc file is read."
                                (point-at-bol))
                           (point)))))
        (forward-line -1))
-       (symbol
-       ;; Group names can be just numbers.
-       (when (numberp symbol)
-         (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
-       (unless (boundp symbol)
-         (set symbol nil))
+       (group
        ;; It was a group name.
        (setq subscribed (eq (char-after) ?:)
-             group (symbol-name symbol)
              reads nil)
        (if (eolp)
            ;; If the line ends here, this is clearly a buggy line, so
-           ;; we put point a the beginning of line and let the cond
+           ;; we put point at the beginning of line and let the cond
            ;; below do the error handling.
            (beginning-of-line)
          ;; We skip to the beginning of the ranges.
@@ -2622,7 +2561,7 @@ If FORCE is non-nil, the .newsrc file is read."
                ;; It was just a simple number, so we add it to the
                ;; list of ranges.
                (push num1 reads))
-             ;; If the next char in ?\n, then we have reached the end
+             ;; If the next char is ?\n, then we have reached the end
              ;; of the line and return nil.
              (not (eq (char-after) ?\n)))
             ((eq (char-after) ?\n)
@@ -2651,7 +2590,8 @@ If FORCE is non-nil, the .newsrc file is read."
          (let ((info (gnus-get-info group))
                level)
            (if info
-               ;; There is an entry for this file in the alist.
+               ;; There is an entry for this file in
+               ;; `gnus-newsrc-hashtb'.
                (progn
                  (gnus-info-set-read info (nreverse reads))
                  ;; We update the level very gently.  In fact, we
@@ -2679,8 +2619,7 @@ If FORCE is non-nil, the .newsrc file is read."
 
     (setq newsrc (nreverse newsrc))
 
-    (if (not already-read)
-       ()
+    (unless already-read
       ;; We now have two newsrc lists - `newsrc', which is what we
       ;; have read from .newsrc, and `gnus-newsrc-alist', which is
       ;; what we've read from .newsrc.eld.  We have to merge these
@@ -2777,9 +2716,10 @@ If FORCE is non-nil, the .newsrc file is read."
 
 (defvar gnus-save-newsrc-file-last-timestamp nil)
 (defun gnus-save-newsrc-file (&optional force)
-  "Save .newsrc file."
-  ;; Note: We cannot save .newsrc file if all newsgroups are removed
-  ;; from the variable gnus-newsrc-alist.
+  "Save .newsrc file.
+Use the group string names in `gnus-group-list' to pull info
+values from `gnus-newsrc-hashtb', and write a new value of
+`gnus-newsrc-alist'."
   (when (and (or gnus-newsrc-alist gnus-killed-list)
             gnus-current-startup-file)
     ;; Save agent range limits for the currently active method.
@@ -2895,7 +2835,13 @@ If FORCE is non-nil, the .newsrc file is read."
        (gnus-group-set-mode-line)))))
 
 (defun gnus-gnus-to-quick-newsrc-format (&optional minimal name &rest 
specific-variables)
-  "Print Gnus variables such as `gnus-newsrc-alist' in Lisp format."
+  "Print Gnus variables such as `gnus-newsrc-alist' in Lisp format.
+Unless optional argument MINIMAL is non-nil, print human-readable
+information in the header of the file, including the file
+version.  If NAME is present, print that as part of the header.
+
+Variables printed are either the variables specified in
+SPECIFIC-VARIABLES, or those in `gnus-variable-list'."
     (princ (format ";; -*- mode:emacs-lisp; coding: %s; -*-\n"
                   gnus-ding-file-coding-system))
     (if name
@@ -2929,9 +2875,18 @@ If FORCE is non-nil, the .newsrc file is read."
                  ;; Remove the `gnus-killed-list' from the list of variables
                  ;; to be saved, if required.
                  (delq 'gnus-killed-list (copy-sequence gnus-variable-list)))))
-          ;; Peel off the "dummy" group.
-          (gnus-newsrc-alist (cdr gnus-newsrc-alist))
           variable)
+      ;; A bit of a fake-out here: the original value of
+      ;; `gnus-newsrc-alist' isn't written to file, instead it is
+      ;; constructed at the last minute by combining the group
+      ;; ordering in `gnus-group-list' with the group infos from
+      ;; `gnus-newsrc-hashtb'.
+      (set (nth (seq-position gnus-variable-list 'gnus-newsrc-alist)
+               gnus-variable-list)
+          (mapcar (lambda (g)
+                    (nth 1 (gethash g gnus-newsrc-hashtb)))
+                  (delete "dummy.group" gnus-group-list)))
+
       ;; Insert the variables into the file.
       (while variables
        (when (and (boundp (setq variable (pop variables)))
@@ -2956,8 +2911,8 @@ If FORCE is non-nil, the .newsrc file is read."
   (interactive (list (gnus-y-or-n-p "write foreign groups too? ")))
   ;; Generate and save the .newsrc file.
   (with-current-buffer (create-file-buffer gnus-current-startup-file)
-    (let ((newsrc (cdr gnus-newsrc-alist))
-         (standard-output (current-buffer))
+    (let ((standard-output (current-buffer))
+         (groups (delete "dummy.group" (copy-sequence gnus-group-list)))
          info ranges range method)
       (setq buffer-file-name gnus-current-startup-file)
       (setq default-directory (file-name-directory buffer-file-name))
@@ -2971,13 +2926,14 @@ If FORCE is non-nil, the .newsrc file is read."
       (when gnus-newsrc-options
        (insert gnus-newsrc-options))
       ;; Write subscribed and unsubscribed.
-      (while (setq info (pop newsrc))
-       ;; Don't write foreign groups to .newsrc.
+      (dolist (g-name groups)
+       (setq info (nth 1 (gnus-group-entry g-name)))
+       ;; Maybe don't write foreign groups to .newsrc.
        (when (or (null (setq method (gnus-info-method info)))
                  (equal method "native")
                  (inline (gnus-server-equal method gnus-select-method))
                   foreign-ok)
-         (insert (gnus-info-group info)
+         (insert g-name
                  (if (> (gnus-info-level info) gnus-level-subscribed)
                      "!" ":"))
          (when (setq ranges (gnus-info-read info))
@@ -3105,10 +3061,10 @@ If FORCE is non-nil, the .newsrc file is read."
     ;; to avoid trying to re-read after a failed read.
     (unless gnus-description-hashtb
       (setq gnus-description-hashtb
-           (gnus-make-hashtable (length gnus-active-hashtb))))
+           (gnus-make-hashtable (hash-table-size gnus-active-hashtb))))
     ;; Mark this method's desc file as read.
-    (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
-                 gnus-description-hashtb)
+    (puthash (gnus-group-prefixed-name "" method) "Has read"
+            gnus-description-hashtb)
 
     (gnus-message 5 "Reading descriptions file via %s..." (car method))
     (cond
@@ -3144,29 +3100,26 @@ If FORCE is non-nil, the .newsrc file is read."
                                    (zerop (forward-line 1)))))))
          (goto-char (point-min))
          (while (not (eobp))
-           ;; If we get an error, we set group to 0, which is not a
-           ;; symbol...
            (setq group
                  (condition-case ()
-                     (let ((obarray gnus-description-hashtb))
-                       ;; Group is set to a symbol interned in this
-                       ;; hash table.
-                       (read nntp-server-buffer))
-                   (error 0)))
+                     (read nntp-server-buffer)
+                   (error nil)))
            (skip-chars-forward " \t")
-           ;; ...  which leads to this line being effectively ignored.
-           (when (symbolp group)
+           (when group
+             (setq group (if (numberp group)
+                             (number-to-string group)
+                           (symbol-name group)))
              (let* ((str (buffer-substring
                           (point) (progn (end-of-line) (point))))
-                    (name (symbol-name group))
                     (charset
-                     (or (gnus-group-name-charset method name)
-                         (gnus-parameter-charset name)
+                     (or (gnus-group-name-charset method group)
+                         (gnus-parameter-charset group)
                          gnus-default-charset)))
                ;; Fixme: Don't decode in unibyte mode.
+               ;; Double fixme: We're not in unibyte mode, are we?
                (when (and str charset)
                  (setq str (decode-coding-string str charset)))
-               (set group str)))
+               (puthash group str gnus-description-hashtb)))
            (forward-line 1))))
       (gnus-message 5 "Reading descriptions file...done")
       t))))
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 4baf4bc..b8aa302 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -1,6 +1,6 @@
 ;;; gnus-sum.el --- summary mode commands for Gnus
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
@@ -27,7 +27,34 @@
 (require 'cl-lib)
 
 (defvar tool-bar-mode)
+(defvar gnus-category-predicate-alist)
+(defvar gnus-category-predicate-cache)
+(defvar gnus-inhibit-article-treatments)
+(defvar gnus-inhibit-demon)
+(defvar gnus-tmp-article-number)
+(defvar gnus-tmp-closing-bracket)
+(defvar gnus-tmp-current)
+(defvar gnus-tmp-dummy)
+(defvar gnus-tmp-expirable)
+(defvar gnus-tmp-from)
+(defvar gnus-tmp-group-name)
 (defvar gnus-tmp-header)
+(defvar gnus-tmp-indentation)
+(defvar gnus-tmp-level)
+(defvar gnus-tmp-lines)
+(defvar gnus-tmp-number)
+(defvar gnus-tmp-opening-bracket)
+(defvar gnus-tmp-process)
+(defvar gnus-tmp-replied)
+(defvar gnus-tmp-score)
+(defvar gnus-tmp-score-char)
+(defvar gnus-tmp-subject)
+(defvar gnus-tmp-subject-or-nil)
+(defvar gnus-tmp-unread)
+(defvar gnus-tmp-unread-and-unselected)
+(defvar gnus-tmp-unread-and-unticked)
+(defvar gnus-tmp-user-defined)
+(defvar gnus-use-article-prefetch)
 
 (require 'gnus)
 (require 'gnus-group)
@@ -39,6 +66,8 @@
 (require 'gmm-utils)
 (require 'mm-decode)
 (require 'nnoo)
+(eval-when-compile
+  (require 'subr-x))
 
 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
 (autoload 'gnus-cache-write-active "gnus-cache")
@@ -782,7 +811,7 @@ score file."
   :group 'gnus-score-default
   :type 'integer)
 
-(defun gnus-widget-reversible-match (widget value)
+(defun gnus-widget-reversible-match (_widget value)
   "Ignoring WIDGET, convert VALUE to internal form.
 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
   ;; (debug value)
@@ -792,7 +821,7 @@ VALUE should have the form `FOO' or `(not FOO)', where FOO 
is an symbol."
            (eq (nth 0 value) 'not)
            (symbolp (nth 1 value)))))
 
-(defun gnus-widget-reversible-to-internal (widget value)
+(defun gnus-widget-reversible-to-internal (_widget value)
   "Ignoring WIDGET, convert VALUE to internal form.
 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
@@ -801,7 +830,7 @@ FOO is converted to (FOO nil) and (not FOO) is converted to 
(FOO t)."
       (list value nil)
     (list (nth 1 value) t)))
 
-(defun gnus-widget-reversible-to-external (widget value)
+(defun gnus-widget-reversible-to-external (_widget value)
   "Ignoring WIDGET, convert VALUE to external form.
 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
 \(FOO  nil) is converted to FOO and (FOO t) is converted to (not FOO)."
@@ -1361,7 +1390,15 @@ the normal Gnus MIME machinery."
 (defvar gnus-current-crosspost-group nil)
 (defvar gnus-newsgroup-display nil)
 
-(defvar gnus-newsgroup-dependencies nil)
+(defvar gnus-newsgroup-dependencies nil
+  "A hash table holding dependencies between messages.")
+;; Dependencies are held in a tree structure: a list with the root
+;; message as car, and each immediate child a sublist (perhaps
+;; containing further sublists).  Each message is represented as a
+;; vector of headers.  Each message's list can be looked up in the
+;; dependency table using the message's Message-ID as the key.  The
+;; root key is the string "none".
+
 (defvar gnus-newsgroup-adaptive nil)
 (defvar gnus-summary-display-article-function nil)
 (defvar gnus-summary-highlight-line-function nil
@@ -1375,7 +1412,8 @@ the normal Gnus MIME machinery."
     (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
        ?s)
     (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
-           gnus-tmp-from) ?s)
+           gnus-tmp-from)
+        ?s)
     (?F gnus-tmp-from ?s)
     (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
     (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
@@ -1387,12 +1425,15 @@ the normal Gnus MIME machinery."
     (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
     (?L gnus-tmp-lines ?s)
     (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header))
-           0) ?d)
+           0)
+        ?d)
     (?G (or (nnir-article-group (mail-header-number gnus-tmp-header))
-           "") ?s)
+           "")
+        ?s)
     (?g (or (gnus-group-short-name
             (nnir-article-group (mail-header-number gnus-tmp-header)))
-           "") ?s)
+           "")
+        ?s)
     (?O gnus-tmp-downloaded ?c)
     (?I gnus-tmp-indentation ?s)
     (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
@@ -1417,7 +1458,8 @@ the normal Gnus MIME machinery."
     (?P (gnus-pick-line-number) ?d)
     (?B gnus-tmp-thread-tree-header-string ?s)
     (user-date (gnus-user-date
-               ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
+               ,(macroexpand '(mail-header-date gnus-tmp-header)))
+               ?s))
   "An alist of format specifications that can appear in summary lines.
 These are paired with what variables they correspond with, along with
 the type of the variable (string, integer, character, etc).")
@@ -1662,6 +1704,7 @@ For example:
 (eval-when-compile
   ;; Bind features so that require will believe that gnus-sum has
   ;; already been loaded (avoids infinite recursion)
+  (with-no-warnings (defvar features))  ;Not just a local variable.
   (let ((features (cons 'gnus-sum features)))
     (require 'gnus-art)))
 
@@ -3043,6 +3086,11 @@ When FORCE, rebuild the tool bar."
 
 (defvar bidi-paragraph-direction)
 
+(defvar gnus-summary-mode-group nil
+  "Variable for communication with `gnus-summary-mode'.
+Allows the `gnus-newsgroup-name' local variable to be set before
+the summary mode hooks are run.")
+
 (define-derived-mode gnus-summary-mode gnus-mode "Summary"
   "Major mode for reading articles.
 \\<gnus-summary-mode-map>
@@ -3064,6 +3112,7 @@ The following commands are available:
   (let ((gnus-summary-local-variables gnus-newsgroup-variables))
     (gnus-summary-make-local-variables))
   (gnus-summary-make-local-variables)
+  (setq gnus-newsgroup-name gnus-summary-mode-group)
   (when (gnus-visual-p 'summary-menu 'menu)
     (gnus-summary-make-menu-bar)
     (gnus-summary-make-tool-bar))
@@ -3091,18 +3140,16 @@ The following commands are available:
 
 (defun gnus-summary-make-local-variables ()
   "Make all the local summary buffer variables."
-  (let (global)
-    (dolist (local gnus-summary-local-variables)
-      (if (consp local)
-         (progn
-           (if (eq (cdr local) 'global)
-               ;; Copy the global value of the variable.
-               (setq global (symbol-value (car local)))
-             ;; Use the value from the list.
-             (setq global (eval (cdr local))))
-           (set (make-local-variable (car local)) global))
-       ;; Simple nil-valued local variable.
-       (set (make-local-variable local) nil)))))
+  (dolist (local gnus-summary-local-variables)
+    (if (consp local)
+        (let ((global (if (eq (cdr local) 'global)
+                          ;; Copy the global value of the variable.
+                          (symbol-value (car local))
+                        ;; Use the value from the list.
+                        (eval (cdr local)))))
+          (set (make-local-variable (car local)) global))
+      ;; Simple nil-valued local variable.
+      (set (make-local-variable local) nil))))
 
 ;; Summary data functions.
 
@@ -3476,10 +3523,10 @@ Returns non-nil if the setup was successful."
          (not gnus-newsgroup-prepared))
       (set-buffer (gnus-get-buffer-create buffer))
       (setq gnus-summary-buffer (current-buffer))
-      (gnus-summary-mode)
+      (let ((gnus-summary-mode-group group))
+       (gnus-summary-mode))
       (when (gnus-group-quit-config group)
        (set (make-local-variable 'gnus-single-article-buffer) nil))
-      (setq gnus-newsgroup-name group)
       (turn-on-gnus-mailing-list-mode)
       ;; These functions don't currently depend on GROUP, but might in
       ;; the future.
@@ -3509,13 +3556,12 @@ buffer that was in action when the last article was 
fetched."
          (score-file gnus-current-score-file)
          (default-charset gnus-newsgroup-charset)
          vlist)
-      (let ((locals gnus-newsgroup-variables))
-       (while locals
-         (if (consp (car locals))
-             (push (eval (caar locals)) vlist)
-           (push (eval (car locals)) vlist))
-         (setq locals (cdr locals)))
-       (setq vlist (nreverse vlist)))
+      (dolist (local gnus-newsgroup-variables)
+        (push (eval (if (consp local) (car local)
+                      local)
+                    t)
+              vlist))
+      (setq vlist (nreverse vlist))
       (with-temp-buffer
        (setq gnus-newsgroup-name name
              gnus-newsgroup-marked marked
@@ -3530,12 +3576,11 @@ buffer that was in action when the last article was 
fetched."
              gnus-reffed-article-number reffed
              gnus-current-score-file score-file
              gnus-newsgroup-charset default-charset)
-       (let ((locals gnus-newsgroup-variables))
-         (while locals
-           (if (consp (car locals))
-               (set (caar locals) (pop vlist))
-             (set (car locals) (pop vlist)))
-           (setq locals (cdr locals))))))))
+       (dolist (local gnus-newsgroup-variables)
+          (set (if (consp local)
+                   (car local)
+                 local)
+               (pop vlist)))))))
 
 (defun gnus-summary-article-unread-p (article)
   "Say whether ARTICLE is unread or not."
@@ -3623,19 +3668,23 @@ buffer that was in action when the last article was 
fetched."
                pos)))
       (setq gnus-summary-mark-positions pos))))
 
-(defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
+(defun gnus-summary-insert-dummy-line (subject number)
   "Insert a dummy root in the summary buffer."
   (beginning-of-line)
   (add-text-properties
-   (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
-   (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
+   (point) (let ((gnus-tmp-subject subject)
+                 (gnus-tmp-number number))
+             (eval gnus-summary-dummy-line-format-spec t)
+             (point))
+   (list 'gnus-number number 'gnus-intangible number)))
 
 (defun gnus-summary-extract-address-component (from)
   (or (car (funcall gnus-extract-address-components from))
       from))
 
-(defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
-  (let ((mail-parse-charset gnus-newsgroup-charset)
+(defun gnus-summary-from-or-to-or-newsgroups (header from)
+  (let ((gnus-tmp-from from)
+        (mail-parse-charset gnus-newsgroup-charset)
        ;; Is it really necessary to do this next part for each summary line?
        ;; Luckily, doesn't seem to slow things down much.
        (mail-parse-ignored-charsets
@@ -3662,25 +3711,31 @@ buffer that was in action when the last article was 
fetched."
                     (and
                      (memq 'Newsgroups gnus-extra-headers)
                      (eq (car (gnus-find-method-for-group
-                               gnus-newsgroup-name)) 'nntp)
+                               gnus-newsgroup-name))
+                          'nntp)
                      (gnus-group-real-name gnus-newsgroup-name))))
              (concat gnus-summary-newsgroup-prefix newsgroups)))))
      (bidi-string-mark-left-to-right
       (inline
        (gnus-summary-extract-address-component gnus-tmp-from))))))
 
-(defun gnus-summary-insert-line (gnus-tmp-header
-                                gnus-tmp-level gnus-tmp-current
-                                undownloaded gnus-tmp-unread gnus-tmp-replied
-                                gnus-tmp-expirable gnus-tmp-subject-or-nil
-                                &optional gnus-tmp-dummy gnus-tmp-score
-                                gnus-tmp-process)
-  (if (>= gnus-tmp-level (length gnus-thread-indent-array))
+(defun gnus-summary-insert-line (header level current undownloaded
+                                 unread replied expirable subject-or-nil
+                                &optional dummy score process)
+  (if (>= level (length gnus-thread-indent-array))
       (gnus-make-thread-indent-array (max (* 2 (length 
gnus-thread-indent-array))
-                                         gnus-tmp-level)))
-  (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
+                                         level)))
+  (let* ((gnus-tmp-header header)
+         (gnus-tmp-level level)
+         (gnus-tmp-current current)
+         (gnus-tmp-unread unread)
+         (gnus-tmp-expirable expirable)
+         (gnus-tmp-subject-or-nil subject-or-nil)
+         (gnus-tmp-dummy dummy)
+         (gnus-tmp-process process)
+         (gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
         (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
-        (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
+        (gnus-tmp-score (or score gnus-summary-default-score 0))
         (gnus-tmp-score-char
          (if (or (null gnus-summary-default-score)
                  (<= (abs (- gnus-tmp-score gnus-summary-default-score))
@@ -3693,7 +3748,7 @@ buffer that was in action when the last article was 
fetched."
          (cond (gnus-tmp-process gnus-process-mark)
                ((memq gnus-tmp-current gnus-newsgroup-cached)
                 gnus-cached-mark)
-               (gnus-tmp-replied gnus-replied-mark)
+               (replied gnus-replied-mark)
                ((memq gnus-tmp-current gnus-newsgroup-forwarded)
                 gnus-forwarded-mark)
                ((memq gnus-tmp-current gnus-newsgroup-saved)
@@ -3849,20 +3904,20 @@ respectively."
 Returns \"  ?  \" if there's bad input or if another error occurs.
 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
   (condition-case ()
-      (let* ((messy-date (float-time (gnus-date-get-time messy-date)))
-            (now (float-time))
+      (let* ((messy-date (gnus-date-get-time messy-date))
+            (now (current-time))
             ;;If we don't find something suitable we'll use this one
             (my-format "%b %d '%y"))
-       (let* ((difference (- now messy-date))
+       (let* ((difference (time-subtract now messy-date))
               (templist gnus-user-date-format-alist)
               (top (eval (caar templist))))
-         (while (if (numberp top) (< top difference) (not top))
+         (while (if (numberp top) (time-less-p top difference) (not top))
            (progn
              (setq templist (cdr templist))
              (setq top (eval (caar templist)))))
          (if (stringp (cdr (car templist)))
              (setq my-format (cdr (car templist)))))
-       (format-time-string (eval my-format) (seconds-to-time messy-date)))
+       (format-time-string (eval my-format) messy-date))
     (error "  ?   ")))
 
 (defun gnus-summary-set-local-parameters (group)
@@ -3931,7 +3986,7 @@ If SELECT-ARTICLES, only select those articles from 
GROUP."
 
   ;; Killed foreign groups can't be entered.
   ;;  (when (and (not (gnus-group-native-p group))
-  ;;        (not (gnus-gethash group gnus-newsrc-hashtb)))
+  ;;        (not (gethash group gnus-newsrc-hashtb)))
   ;;    (error "Dead non-native groups can't be entered"))
   (gnus-message 7 "Retrieving newsgroup: %s..."
                (gnus-group-decoded-name group))
@@ -4161,7 +4216,7 @@ If SELECT-ARTICLES, only select those articles from 
GROUP."
   "Gather threads by looking at Subject headers."
   (if (not gnus-summary-make-false-root)
       threads
-    (let ((hashtb (gnus-make-hashtable 1024))
+    (let ((hashtb (gnus-make-hashtable 1000))
          (prev threads)
          (result threads)
          subject hthread whole-subject)
@@ -4170,7 +4225,7 @@ If SELECT-ARTICLES, only select those articles from 
GROUP."
                       (setq whole-subject (mail-header-subject
                                            (caar threads)))))
        (when subject
-         (if (setq hthread (gnus-gethash subject hashtb))
+         (if (setq hthread (gethash subject hashtb))
              (progn
                ;; We enter a dummy root into the thread, if we
                ;; haven't done that already.
@@ -4184,24 +4239,24 @@ If SELECT-ARTICLES, only select those articles from 
GROUP."
                (setcdr prev (cdr threads))
                (setq threads prev))
            ;; Enter this thread into the hash table.
-           (gnus-sethash subject
-                         (if gnus-summary-make-false-root-always
-                             (progn
-                               ;; If you want a dummy root above all
-                               ;; threads...
-                               (setcar threads (list whole-subject
-                                                     (car threads)))
-                               threads)
-                           threads)
-                         hashtb)))
+           (puthash subject
+                    (if gnus-summary-make-false-root-always
+                        (progn
+                          ;; If you want a dummy root above all
+                          ;; threads...
+                          (setcar threads (list whole-subject
+                                                (car threads)))
+                          threads)
+                      threads)
+                    hashtb)))
        (setq prev threads)
        (setq threads (cdr threads)))
       result)))
 
 (defun gnus-gather-threads-by-references (threads)
   "Gather threads by looking at References headers."
-  (let ((idhashtb (gnus-make-hashtable 1024))
-       (thhashtb (gnus-make-hashtable 1024))
+  (let ((idhashtb (gnus-make-hashtable 1000))
+       (thhashtb (gnus-make-hashtable 1000))
        (prev threads)
        (result threads)
        ids references id gthread gid entered ref)
@@ -4212,11 +4267,11 @@ If SELECT-ARTICLES, only select those articles from 
GROUP."
              entered nil)
        (while (setq ref (pop ids))
          (setq ids (delete ref ids))
-         (if (not (setq gid (gnus-gethash ref idhashtb)))
+         (if (not (setq gid (gethash ref idhashtb)))
              (progn
-               (gnus-sethash ref id idhashtb)
-               (gnus-sethash id threads thhashtb))
-           (setq gthread (gnus-gethash gid thhashtb))
+               (puthash ref id idhashtb)
+               (puthash id threads thhashtb))
+           (setq gthread (gethash gid thhashtb))
            (unless entered
              ;; We enter a dummy root into the thread, if we
              ;; haven't done that already.
@@ -4228,7 +4283,7 @@ If SELECT-ARTICLES, only select those articles from 
GROUP."
              (setcdr (car gthread)
                      (nconc (cdar gthread) (list (car threads)))))
            ;; Add it into the thread hash table.
-           (gnus-sethash id gthread thhashtb)
+           (puthash id gthread thhashtb)
            (setq entered t)
            ;; Remove it from the list of threads.
            (setcdr prev (cdr threads))
@@ -4261,12 +4316,12 @@ If SELECT-ARTICLES, only select those articles from 
GROUP."
          ;; We have found a loop.
          (let (ref-dep)
            (setcdr thread (delq (car th) (cdr thread)))
-           (if (boundp (setq ref-dep (intern "none"
-                                             gnus-newsgroup-dependencies)))
-               (setcdr (symbol-value ref-dep)
-                       (nconc (cdr (symbol-value ref-dep))
+           (if (setq ref-dep (gethash "none"
+                                      gnus-newsgroup-dependencies))
+               (setcdr ref-dep
+                       (nconc (cdr ref-dep)
                               (list (car th))))
-             (set ref-dep (list nil (car th))))
+             (puthash ref-dep (list nil (car th)) gnus-newsgroup-dependencies))
            (setq infloop 1
                  stack nil))
        ;; Push all the subthreads onto the stack.
@@ -4277,31 +4332,30 @@ If SELECT-ARTICLES, only select those articles from 
GROUP."
   "Go through the dependency hashtb and find the roots.  Return all threads."
   (let (threads)
     (while (catch 'infloop
-            (mapatoms
-             (lambda (refs)
+            (maphash
+             (lambda (_id refs)
                ;; Deal with self-referencing References loops.
-               (when (and (car (symbol-value refs))
+               (when (and (car refs)
                           (not (zerop
                                 (apply
                                  '+
                                  (mapcar
                                   (lambda (thread)
                                     (gnus-thread-loop-p
-                                     (car (symbol-value refs)) thread))
-                                  (cdr (symbol-value refs)))))))
+                                     (car refs) thread))
+                                  (cdr refs))))))
                  (setq threads nil)
                  (throw 'infloop t))
-               (unless (car (symbol-value refs))
+               (unless (car refs)
                  ;; These threads do not refer back to any other
                  ;; articles, so they're roots.
-                 (setq threads (append (cdr (symbol-value refs)) threads))))
+                 (setq threads (append (cdr refs) threads))))
              gnus-newsgroup-dependencies)))
     threads))
 
 ;; Build the thread tree.
 (defsubst gnus-dependencies-add-header (header dependencies force-new)
   "Enter HEADER into the DEPENDENCIES table if it is not already there.
-
 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
 if it was already present.
 
@@ -4312,33 +4366,38 @@ Message-ID before being entered.
 
 Returns HEADER if it was entered in the DEPENDENCIES.  Returns nil otherwise."
   (let* ((id (mail-header-id header))
-        (id-dep (and id (intern id dependencies)))
+        ;; An "id-dep" is a list holding the vector headers of this
+        ;; message, plus equivalent "id-deps" for each immediate
+        ;; child message.
+        (id-dep (and id (gethash id dependencies)))
         parent-id ref ref-dep ref-header replaced)
     ;; Enter this `header' in the `dependencies' table.
     (cond
-     ((not id-dep)
+     ((null id)
+      ;; Omit this article altogether if there is no Message-ID.
       (setq header nil))
-     ;; The first two cases do the normal part: enter a new `header'
-     ;; in the `dependencies' table.
-     ((not (boundp id-dep))
-      (set id-dep (list header)))
-     ((null (car (symbol-value id-dep)))
-      (setcar (symbol-value id-dep) header))
-
+     ;; Enter a new id and `header' in the `dependencies' table.
+     ((null id-dep)
+      (setq id-dep (puthash id (list header) dependencies)))
+     ;; A child message has already added this id, just insert the header.
+     ((null (car id-dep))
+      (setcar (gethash id dependencies) header)
+      (setq id-dep (gethash id dependencies)))
      ;; From here the `header' was already present in the
      ;; `dependencies' table.
      (force-new
       ;; Overrides an existing entry;
       ;; just set the header part of the entry.
-      (setcar (symbol-value id-dep) header)
+      (setcar (gethash id dependencies) header)
       (setq replaced t))
 
      ;; Renames the existing `header' to a unique Message-ID.
      ((not gnus-summary-ignore-duplicates)
       ;; An article with this Message-ID has already been seen.
       ;; We rename the Message-ID.
-      (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
-          (list header))
+      (setq id-dep (puthash (setq id (nnmail-message-id))
+                           (list header)
+                           dependencies))
       (mail-header-set-id header id))
 
      ;; The last case ignores an existing entry, except it adds any
@@ -4348,8 +4407,8 @@ Returns HEADER if it was entered in the DEPENDENCIES.  
Returns nil otherwise."
      ;; table was *not* modified.
      (t
       (mail-header-set-xref
-       (car (symbol-value id-dep))
-       (concat (or (mail-header-xref (car (symbol-value id-dep)))
+       (car id-dep)
+       (concat (or (mail-header-xref (car id-dep))
                   "")
               (or (mail-header-xref header) "")))
       (setq header nil)))
@@ -4359,23 +4418,27 @@ Returns HEADER if it was entered in the DEPENDENCIES.  
Returns nil otherwise."
       (setq parent-id (gnus-parent-id (mail-header-references header)))
       (setq ref parent-id)
       (while (and ref
-                 (setq ref-dep (intern-soft ref dependencies))
-                 (boundp ref-dep)
-                 (setq ref-header (car (symbol-value ref-dep))))
+                 (setq ref-dep (gethash ref dependencies))
+                 (setq ref-header (car-safe ref-dep)))
        (if (string= id ref)
            ;; Yuk!  This is a reference loop.  Make the article be a
            ;; root article.
            (progn
-             (mail-header-set-references (car (symbol-value id-dep)) "none")
+             (mail-header-set-references (car id-dep) "none")
              (setq ref nil)
              (setq parent-id nil))
          (setq ref (gnus-parent-id (mail-header-references ref-header)))))
-      (setq ref-dep (intern (or parent-id "none") dependencies))
-      (if (boundp ref-dep)
-         (setcdr (symbol-value ref-dep)
-                 (nconc (cdr (symbol-value ref-dep))
-                        (list (symbol-value id-dep))))
-       (set ref-dep (list nil (symbol-value id-dep)))))
+      (setq ref (or parent-id "none")
+           ref-dep (gethash ref dependencies))
+      ;; Add `header' to its parent's list of children, creating that
+      ;; list if the parent isn't yet registered in the dependency
+      ;; table.
+      (if ref-dep
+         (setcdr (gethash ref dependencies)
+                 (nconc (cdr ref-dep)
+                        (list id-dep)))
+       (puthash ref (list nil id-dep)
+                dependencies)))
     header))
 
 (defun gnus-extract-message-id-from-in-reply-to (string)
@@ -4437,16 +4500,15 @@ Returns HEADER if it was entered in the DEPENDENCIES.  
Returns nil otherwise."
   ;; build complete threads - if the roots haven't been expired by the
   ;; server, that is.
   (let ((mail-parse-charset gnus-newsgroup-charset)
-       id heads)
-    (mapatoms
-     (lambda (refs)
-       (when (not (car (symbol-value refs)))
-        (setq heads (cdr (symbol-value refs)))
+       heads)
+    (maphash
+     (lambda (id refs)
+       (when (not (car refs))
+        (setq heads (cdr refs))
         (while heads
           (if (memq (mail-header-number (caar heads))
                     gnus-newsgroup-dormant)
               (setq heads (cdr heads))
-            (setq id (symbol-name refs))
             (while (and (setq id (gnus-build-get-header id))
                         (not (car (gnus-id-to-thread id)))))
             (setq heads nil)))))
@@ -4462,7 +4524,6 @@ Returns HEADER if it was entered in the DEPENDENCIES.  
Returns nil otherwise."
 ;; on the beginning of the line.
 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
   (let ((eol (point-at-eol))
-       (buffer (current-buffer))
        header references in-reply-to)
 
     ;; overview: [num subject from date id refs chars lines misc]
@@ -4727,7 +4788,8 @@ If LINE, insert the rebuilt thread starting on line LINE."
 
 (defun gnus-id-to-thread (id)
   "Return the (sub-)thread where ID appears."
-  (gnus-gethash id gnus-newsgroup-dependencies))
+  (when (hash-table-p gnus-newsgroup-dependencies)
+    (gethash id gnus-newsgroup-dependencies)))
 
 (defun gnus-id-to-article (id)
   "Return the article number of ID."
@@ -4773,7 +4835,7 @@ If LINE, insert the rebuilt thread starting on line LINE."
   (let (headers thread last-id)
     ;; First go up in this thread until we find the root.
     (setq last-id (gnus-root-id id)
-         headers (message-flatten-list (gnus-id-to-thread last-id)))
+         headers (flatten-tree (gnus-id-to-thread last-id)))
     ;; We have now found the real root of this thread.  It might have
     ;; been gathered into some loose thread, so we have to search
     ;; through the threads to find the thread we wanted.
@@ -4916,8 +4978,16 @@ Note that THREAD must never, ever be anything else than 
a variable -
 using some other form will lead to serious barfage."
   (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
   ;; (8% speedup to gnus-summary-prepare, just for fun :-)
-  (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
-       (vector thread) 2))
+  (cond
+   ((and (boundp 'lexical-binding) lexical-binding)
+    ;; FIXME: This version could be a "defsubst" rather than a macro.
+    `(#[257 "\211:\203\16\0\211@;\203\15\0A@@\207"
+            [] 2]
+      ,thread))
+   (t
+    ;; Not sure how XEmacs handles these things, so let's keep the old code.
+    (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
+          (vector thread) 2))))
 
 (defsubst gnus-article-sort-by-number (h1 h2)
   "Sort articles by article number."
@@ -5069,7 +5139,7 @@ Unscored articles will be counted as having a score of 
zero."
   "Return the highest article number in THREAD."
   (apply 'max (mapcar (lambda (header)
                        (mail-header-number header))
-                     (message-flatten-list thread))))
+                     (flatten-tree thread))))
 
 (defun gnus-article-sort-by-most-recent-date (h1 h2)
   "Sort articles by number."
@@ -5089,7 +5159,7 @@ Unscored articles will be counted as having a score of 
zero."
         (mapcar (lambda (header) (float-time
                                   (gnus-date-get-time
                                    (mail-header-date header))))
-                (message-flatten-list thread))))
+                (flatten-tree thread))))
 
 (defun gnus-thread-total-score-1 (root)
   ;; This function find the total score of the thread below ROOT.
@@ -5580,7 +5650,7 @@ If SELECT-ARTICLES, only select those articles from 
GROUP."
          (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
              t
            gnus-summary-ignore-duplicates))
-        (info (nth 2 entry))
+        (info (nth 1 entry))
         charset articles fetched-articles cached)
 
     (unless (gnus-check-server
@@ -5599,7 +5669,7 @@ If SELECT-ARTICLES, only select those articles from 
GROUP."
           (decode-coding-string group charset)
           (decode-coding-string (gnus-status-message group) charset))))
 
-    (unless (gnus-request-group group t nil (gnus-get-info group))
+    (unless (gnus-request-group group t nil info)
       (when (derived-mode-p 'gnus-summary-mode)
        (gnus-kill-buffer (current-buffer)))
       (error "Couldn't request group %s: %s"
@@ -5948,7 +6018,7 @@ If SELECT-ARTICLES, only select those articles from 
GROUP."
         (min (car active))
         (max (cdr active))
         (types gnus-article-mark-lists)
-        marks var articles article mark mark-type
+         var articles article mark mark-type
          bgn end)
     ;; Hack to avoid adjusting marks for imap.
     (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
@@ -6202,22 +6272,21 @@ The resulting hash table is returned, or nil if no 
Xrefs were found."
          (setq number
                (string-to-number (substring xrefs (match-beginning 2)
                                          (match-end 2))))
-         (if (setq entry (gnus-gethash group xref-hashtb))
+         (if (setq entry (gethash group xref-hashtb))
              (setcdr entry (cons number (cdr entry)))
-           (gnus-sethash group (cons number nil) xref-hashtb)))))
+           (puthash group (cons number nil) xref-hashtb)))))
     (and start xref-hashtb)))
 
 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
   "Look through all the headers and mark the Xrefs as read."
   (let ((virtual (gnus-virtual-group-p from-newsgroup))
-       name info xref-hashtb idlist method nth4)
+       name info xref-hashtb method nth4)
     (with-current-buffer gnus-group-buffer
       (when (setq xref-hashtb
                  (gnus-create-xref-hashtb from-newsgroup headers unreads))
-       (mapatoms
-        (lambda (group)
-          (unless (string= from-newsgroup (setq name (symbol-name group)))
-            (setq idlist (symbol-value group))
+       (maphash
+        (lambda (group idlist)
+          (unless (string= from-newsgroup group)
             ;; Dead groups are not updated.
             (and (prog1
                      (setq info (gnus-get-info name))
@@ -6243,7 +6312,7 @@ The resulting hash table is returned, or nil if no Xrefs 
were found."
 
 (defun gnus-compute-read-articles (group articles)
   (let* ((entry (gnus-group-entry group))
-        (info (nth 2 entry))
+        (info (nth 1 entry))
         (active (gnus-active group))
         ninfo)
     (when entry
@@ -6280,7 +6349,7 @@ The resulting hash table is returned, or nil if no Xrefs 
were found."
   "Update the info of GROUP to say that ARTICLES are read."
   (let* ((num 0)
         (entry (gnus-group-entry group))
-        (info (nth 2 entry))
+        (info (nth 1 entry))
         (active (gnus-active group))
         (set-marks
          (gnus-method-option-p
@@ -7465,7 +7534,7 @@ The state which existed when entering the ephemeral is 
reset."
       (with-current-buffer buffer
        (gnus-deaden-summary))))))
 
-(defun gnus-summary-wake-up-the-dead (&rest args)
+(defun gnus-summary-wake-up-the-dead (&rest _)
   "Wake up the dead summary buffer."
   (interactive)
   (gnus-dead-summary-mode -1)
@@ -7691,6 +7760,12 @@ Given a prefix, will force an `article' buffer 
configuration."
     (gnus-article-setup-buffer))
   (gnus-set-global-variables)
   (with-current-buffer gnus-article-buffer
+    ;; The buffer may be non-empty and even narrowed, so go back to
+    ;; a sane state.
+    (widen)
+    ;; We're going to erase the buffer anyway so do it now: it can save us from
+    ;; uselessly performing multibyte-conversion of the current content.
+    (let ((inhibit-read-only t)) (erase-buffer))
     (setq gnus-article-charset gnus-newsgroup-charset)
     (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
     (mm-enable-multibyte))
@@ -7722,7 +7797,7 @@ be displayed."
   (unless (derived-mode-p 'gnus-summary-mode)
     (set-buffer gnus-summary-buffer))
   (let ((article (or article (gnus-summary-article-number)))
-       (all-headers (not (not all-headers))) ;Must be t or nil.
+        (all-headers (and all-headers t)) ; Must be t or nil.
        gnus-summary-display-article-function)
     (and (not pseudo)
         (gnus-summary-article-pseudo-p article)
@@ -7834,7 +7909,7 @@ If BACKWARD, the previous article is selected instead of 
the next."
          (gnus-summary-walk-group-buffer
           gnus-newsgroup-name cmd unread backward point))))))))
 
-(defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
+(defun gnus-summary-walk-group-buffer (_from-group cmd unread backward start)
   (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
                      (?\C-p (gnus-group-prev-unread-group 1))))
        (cursor-in-echo-area t)
@@ -8128,7 +8203,7 @@ score higher than the default score."
   "Select the first unread subject that has a score over the default score."
   (interactive)
   (let ((data gnus-newsgroup-data)
-       article score)
+       article)
     (while (and (setq article (gnus-data-number (car data)))
                (or (gnus-data-read-p (car data))
                    (not (> (gnus-summary-article-score article)
@@ -8541,7 +8616,7 @@ If UNREPLIED (the prefix), limit to unreplied articles."
     (gnus-summary-limit gnus-newsgroup-replied))
   (gnus-summary-position-point))
 
-(defun gnus-summary-limit-exclude-marks (marks &optional reverse)
+(defun gnus-summary-limit-exclude-marks (marks &optional _reverse)
   "Exclude articles that are marked with MARKS (e.g. \"DK\").
 If REVERSE, limit the summary buffer to articles that are marked
 with MARKS.  MARKS can either be a string of marks or a list of marks.
@@ -8842,11 +8917,11 @@ fetch-old-headers verbiage, and so on."
                   (null gnus-thread-expunge-below)))
     (push gnus-newsgroup-limit gnus-newsgroup-limits)
     (setq gnus-newsgroup-limit nil)
-    (mapatoms
-     (lambda (node)
-       (unless (car (symbol-value node))
+    (maphash
+     (lambda (_id deps)
+       (unless (car deps)
         ;; These threads have no parents -- they are roots.
-        (let ((nodes (cdr (symbol-value node)))
+        (let ((nodes (cdr deps))
               thread)
           (while nodes
             (if (and gnus-thread-expunge-below
@@ -9501,6 +9576,9 @@ fetched headers for, whether they are displayed or not."
        (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
        (case-fold-search t))
     (dolist (header gnus-newsgroup-headers)
+      ;; FIXME: when called from gnus-summary-limit-include-thread via
+      ;; gnus-summary-limit-include-matching-articles, `regexp' is a decoded
+      ;; string whereas the header isn't decoded.
       (when (string-match regexp (funcall func header))
        (push (mail-header-number header) articles)))
     (nreverse articles)))
@@ -9515,7 +9593,7 @@ be taken into consideration.  If NOT-CASE-FOLD, case 
won't be folded
 in the comparisons. If NOT-MATCHING, return a list of all articles that
 not match REGEXP on HEADER."
   (let ((case-fold-search (not not-case-fold))
-       articles d func)
+       articles func)
     (if (consp header)
        (if (eq (car header) 'extra)
            (setq func
@@ -9635,6 +9713,10 @@ to save in."
     (gnus-summary-remove-process-mark article))
   (ps-despool filename))
 
+(defvar ps-right-header)
+(defvar ps-left-header)
+(defvar shr-ignore-cache)
+
 (defun gnus-print-buffer ()
   (let ((ps-left-header
         (list
@@ -9860,7 +9942,7 @@ prefix specifies how many places to rotate each letter 
forward."
   ;; Create buttons and stuff...
   (gnus-treat-article nil))
 
-(defun gnus-summary-idna-message (&optional arg)
+(defun gnus-summary-idna-message (&optional _arg)
   "Decode IDNA encoded domain names in the current articles.
 IDNA encoded domain names looks like `xn--bar'.  If a string
 remain unencoded after running this function, it is likely an
@@ -9868,7 +9950,7 @@ invalid IDNA string (`xn--bar' is invalid).
 
 You must have GNU Libidn (URL `https://www.gnu.org/software/libidn/')
 installed for this command to work."
-  (interactive "P")
+  (interactive)
   (gnus-summary-select-article)
   (let ((mail-header-separator ""))
     (gnus-eval-in-buffer-window gnus-article-buffer
@@ -9880,9 +9962,9 @@ installed for this command to work."
            (replace-match (puny-decode-domain (match-string 1))))
          (set-window-start (get-buffer-window (current-buffer)) start))))))
 
-(defun gnus-summary-morse-message (&optional arg)
+(defun gnus-summary-morse-message (&optional _arg)
   "Morse decode the current article."
-  (interactive "P")
+  (interactive)
   (gnus-summary-select-article)
   (let ((mail-header-separator ""))
     (gnus-eval-in-buffer-window gnus-article-buffer
@@ -9940,11 +10022,11 @@ ACTION can be either `move' (the default), `crosspost' 
or `copy'."
   (cond ((and (eq action 'move)
              (not (gnus-check-backend-function
                    'request-move-article gnus-newsgroup-name)))
-        (error "The current group does not support article moving"))
+        (user-error "The current group does not support article moving"))
        ((and (eq action 'crosspost)
              (not (gnus-check-backend-function
                    'request-replace-article gnus-newsgroup-name)))
-        (error "The current group does not support article editing")))
+        (user-error "The current group does not support article editing")))
   (let ((articles (gnus-summary-work-articles n))
        (prefix (if (gnus-check-backend-function
                     'request-move-article gnus-newsgroup-name)
@@ -9961,8 +10043,7 @@ ACTION can be either `move' (the default), `crosspost' 
or `copy'."
     (unless (assq action names)
       (error "Unknown action %s" action))
     ;; Read the newsgroup name.
-    (when (and (not to-newsgroup)
-              (not select-method))
+    (unless (or to-newsgroup select-method)
       (if (and gnus-move-split-methods
               (not
                (and (memq gnus-current-article articles)
@@ -10007,6 +10088,7 @@ ACTION can be either `move' (the default), `crosspost' 
or `copy'."
                  (or (car select-method)
                      (gnus-group-decoded-name to-newsgroup))
                  articles)
+    ;; This `while' is not equivalent to a `dolist' (bug#33653#134).
     (while articles
       (setq article (pop articles))
       ;; Set any marks that may have changed in the summary buffer.
@@ -10017,8 +10099,9 @@ ACTION can be either `move' (the default), `crosspost' 
or `copy'."
        (cond
        ;; Move the article.
        ((eq action 'move)
-        ;; Remove this article from future suppression.
-        (gnus-dup-unsuppress-article article)
+         (when gnus-suppress-duplicates
+           ;; Remove this article from future suppression.
+           (gnus-dup-unsuppress-article article))
         (let* ((from-method (gnus-find-method-for-group
                              gnus-newsgroup-name))
                (to-method (or select-method
@@ -10209,7 +10292,7 @@ ACTION can be either `move' (the default), `crosspost' 
or `copy'."
                              to-newsgroup
                              select-method))
 
-        ;;;!!!Why is this necessary?
+        ;;!!!Why is this necessary?
        (set-buffer gnus-summary-buffer)
 
        (when (eq action 'move)
@@ -10575,7 +10658,7 @@ groups."
              (let ((mbl mml-buffer-list))
                (setq mml-buffer-list nil)
                (let ((rfc2047-quote-decoded-words-containing-tspecials t))
-                 (mime-to-mml ,'current-handles))
+                 (mime-to-mml ',current-handles))
                (let ((mbl1 mml-buffer-list))
                  (setq mml-buffer-list mbl)
                  (set (make-local-variable 'mml-buffer-list) mbl1))
@@ -10863,8 +10946,8 @@ the actual number of articles unmarked is returned."
       (set var (cons article (symbol-value var)))
       (if (memq type '(processable cached replied forwarded recent saved))
          (gnus-summary-update-secondary-mark article)
-       ;;; !!! This is bogus.  We should find out what primary
-       ;;; !!! mark we want to set.
+       ;; !!! This is bogus.  We should find out what primary
+       ;; !!! mark we want to set.
        (gnus-summary-update-mark gnus-del-mark 'unread)))))
 
 (defun gnus-summary-mark-as-expirable (n)
@@ -11993,10 +12076,10 @@ Argument REVERSE means reverse order."
   (interactive "P")
   (gnus-summary-sort 'marks reverse))
 
-(defun gnus-summary-sort-by-original (&optional reverse)
+(defun gnus-summary-sort-by-original (&optional _reverse)
   "Sort the summary buffer using the default sorting method.
 Argument REVERSE means reverse order."
-  (interactive "P")
+  (interactive)
   (let* ((inhibit-read-only t)
         (gnus-summary-prepare-hook nil))
     ;; We do the sorting by regenerating the threads.
@@ -12282,12 +12365,11 @@ save those articles instead."
     (nreverse split-name)))
 
 (defun gnus-valid-move-group-p (group)
-  (and (symbolp group)
-       (boundp group)
-       (symbol-name group)
-       (symbol-value group)
-       (gnus-get-function (gnus-find-method-for-group
-                          (symbol-name group)) 'request-accept-article t)))
+  (when (and (stringp group)
+            (null (string-empty-p group)))
+    (gnus-get-function (gnus-find-method-for-group
+                       group)
+                      'request-accept-article t)))
 
 (defun gnus-read-move-group-name (prompt default articles prefix)
   "Read a group name."
@@ -12298,27 +12380,24 @@ save those articles instead."
                  (if (> (length articles) 1)
                      (format "these %d articles" (length articles))
                    "this article")))
-        valid-names
+        (valid-names
+         (seq-filter #'gnus-valid-move-group-p
+                     (hash-table-keys gnus-active-hashtb)))
         (to-newsgroup
-         (progn
-           (mapatoms (lambda (g)
-                       (when (gnus-valid-move-group-p g)
-                         (push g valid-names)))
-                     gnus-active-hashtb)
-            (cond
-             ((null split-name)
-              (gnus-group-completing-read
-               prom
-               valid-names
-               nil prefix nil default))
-             ((= 1 (length split-name))
-              (gnus-group-completing-read
-               prom
-              valid-names
-               nil prefix 'gnus-group-history (car split-name)))
-             (t
-              (gnus-completing-read
-               prom (nreverse split-name) nil nil 'gnus-group-history)))))
+          (cond
+           ((null split-name)
+            (gnus-group-completing-read
+             prom
+            valid-names
+             nil prefix nil default))
+           ((= 1 (length split-name))
+            (gnus-group-completing-read
+             prom
+            valid-names
+             nil prefix 'gnus-group-history (car split-name)))
+           (t
+            (gnus-completing-read
+             prom (nreverse split-name) nil nil 'gnus-group-history))))
          (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
         encoded)
     (when to-newsgroup
@@ -12326,7 +12405,7 @@ save those articles instead."
              (string= to-newsgroup prefix))
          (setq to-newsgroup default))
       (unless to-newsgroup
-       (error "No group name entered"))
+       (user-error "No group name entered"))
       (setq encoded (encode-coding-string
                     to-newsgroup
                     (gnus-group-name-charset to-method to-newsgroup)))
@@ -12338,7 +12417,7 @@ save those articles instead."
                       (gnus-activate-group encoded nil nil to-method)
                       (gnus-subscribe-group encoded))
                  (error "Couldn't create group %s" to-newsgroup)))
-         (error "No such group: %s" to-newsgroup))
+         (user-error "No such group: %s" to-newsgroup))
       encoded)))
 
 (defvar gnus-summary-save-parts-counter)
@@ -12636,14 +12715,21 @@ If REVERSE, save parts that do not match TYPE."
                  (c cond)
                  (list gnus-summary-highlight))
             (while list
-              (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
-                             nil))
+              (setcdr c `((,(caar list) ',(cdar list))))
               (setq c (cdr c)
                     list (cdr list)))
-            (gnus-byte-compile (list 'lambda nil cond))))))
+            (gnus-byte-compile
+             `(lambda ()
+                (with-no-warnings     ;See docstring of gnus-summary-highlight.
+                  (defvar score) (defvar default) (defvar default-high)
+                  (defvar default-low) (defvar mark) (defvar uncached))
+                ,cond))))))
 
 (defun gnus-summary-highlight-line ()
   "Highlight current line according to `gnus-summary-highlight'."
+  (with-no-warnings                   ;See docstring of gnus-summary-highlight.
+    (defvar score) (defvar default) (defvar default-high) (defvar default-low)
+    (defvar mark) (defvar uncached))
   (let* ((beg (point-at-bol))
         (article (or (gnus-summary-article-number) gnus-current-article))
         (score (or (cdr (assq article
diff --git a/lisp/gnus/gnus-topic.el b/lisp/gnus/gnus-topic.el
index 06ffe95..e2c728d 100644
--- a/lisp/gnus/gnus-topic.el
+++ b/lisp/gnus/gnus-topic.el
@@ -1,6 +1,6 @@
 ;;; gnus-topic.el --- a folding minor mode for Gnus group buffers
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Author: Ilja Weis <address@hidden>
 ;;     Lars Magne Ingebrigtsen <address@hidden>
@@ -31,6 +31,8 @@
 (require 'gnus-group)
 (require 'gnus-start)
 (require 'gnus-util)
+(eval-when-compile
+  (require 'subr-x))
 
 (defgroup gnus-topic nil
   "Group topics."
@@ -99,8 +101,7 @@ See Info node `(gnus)Formatting Variables'."
 
 (defun gnus-group-topic-name ()
   "The name of the topic on the current line."
-  (let ((topic (get-text-property (point-at-bol) 'gnus-topic)))
-    (and topic (symbol-name topic))))
+  (get-text-property (point-at-bol) 'gnus-topic))
 
 (defun gnus-group-topic-level ()
   "The level of the topic on the current line."
@@ -144,8 +145,7 @@ See Info node `(gnus)Formatting Variables'."
 
 (defun gnus-topic-goto-topic (topic)
   (when topic
-    (gnus-goto-char (text-property-any (point-min) (point-max)
-                                      'gnus-topic (intern topic)))))
+    (gnus-text-property-search 'gnus-topic topic nil 'goto)))
 
 (defun gnus-topic-jump-to-topic (topic)
   "Go to TOPIC."
@@ -167,8 +167,7 @@ See Info node `(gnus)Formatting Variables'."
                                     (point) 'gnus-topic))
                    (get-text-property (max (1- (point)) (point-min))
                                       'gnus-topic))))))
-    (when result
-      (symbol-name result))))
+    result))
 
 (defun gnus-current-topics (&optional topic)
   "Return a list of all current topics, lowest in hierarchy first.
@@ -195,7 +194,7 @@ If RECURSIVE is t, return groups in its subtopics too."
     (while groups
       (when (setq group (pop groups))
        (setq entry (gnus-group-entry group)
-             info (nth 2 entry)
+             info (nth 1 entry)
              params (gnus-info-params info)
              active (gnus-active group)
              unread (or (car entry)
@@ -462,7 +461,7 @@ If LOWEST is non-nil, list all newsgroups of level LOWEST 
or higher."
        (gnus-group-prepare-flat-list-dead
         (seq-remove (lambda (group)
                           (or (gnus-group-entry group)
-                              (gnus-gethash group gnus-killed-hashtb)))
+                              (gethash group gnus-killed-hashtb)))
                         not-in-list)
         gnus-level-killed ?K regexp)))
 
@@ -536,7 +535,7 @@ articles in the topic and its subtopics."
                    (funcall regexp entry))
                   ((null regexp) t)
                   (t nil))))
-             (setq info (nth 2 entry))
+             (setq info (nth 1 entry))
              (gnus-group-prepare-logic
               (gnus-info-group info)
               (and (or (not gnus-group-listed-groups)
@@ -557,7 +556,7 @@ articles in the topic and its subtopics."
                      (car active))
               nil)
            ;; Living groups.
-           (when (setq info (nth 2 entry))
+           (when (setq info (nth 1 entry))
              (gnus-group-insert-group-line
               (gnus-info-group info)
               (gnus-info-level info) (gnus-info-marks info)
@@ -646,7 +645,7 @@ articles in the topic and its subtopics."
         (point)
         (prog1 (1+ (point))
           (eval gnus-topic-line-format-spec))
-        (list 'gnus-topic (intern name)
+        (list 'gnus-topic name
               'gnus-topic-level level
               'gnus-topic-unread unread
               'gnus-active active-topic
@@ -844,10 +843,9 @@ articles in the topic and its subtopics."
   ;; they belong to some topic.
   (let* ((tgroups (apply 'append (mapcar 'cdr gnus-topic-alist)))
         (entry (last (assoc (caar gnus-topic-topology) gnus-topic-alist)))
-        (newsrc (cdr gnus-newsrc-alist))
-        group)
-    (while newsrc
-      (unless (member (setq group (gnus-info-group (pop newsrc))) tgroups)
+        (groups (cdr gnus-group-list)))
+    (dolist (group groups)
+      (unless (member group tgroups)
        (setcdr entry (list group))
        (setq entry (cdr entry)))))
   ;; Go through all topics and make sure they contain only living groups.
@@ -888,7 +886,7 @@ articles in the topic and its subtopics."
        (while (setq group (pop topic))
          (when (and (or (gnus-active group)
                         (gnus-info-method (gnus-get-info group)))
-                    (not (gnus-gethash group gnus-killed-hashtb)))
+                    (not (gethash group gnus-killed-hashtb)))
            (push group filtered-topic)))
        (push (cons topic-name (nreverse filtered-topic)) result)))
     (setq gnus-topic-alist (nreverse result))))
@@ -898,7 +896,7 @@ articles in the topic and its subtopics."
   (with-current-buffer gnus-group-buffer
     (let ((inhibit-read-only t))
       (unless gnus-topic-inhibit-change-level
-       (gnus-group-goto-group (or (car (nth 2 previous)) group))
+       (gnus-group-goto-group (or (car (nth 1 previous)) group))
        (when (and gnus-topic-mode
                   gnus-topic-alist
                   (not gnus-topic-inhibit-change-level))
@@ -956,7 +954,7 @@ articles in the topic and its subtopics."
   (if (not group)
       (if (not (memq 'gnus-topic props))
          (goto-char (point-max))
-       (let ((topic (symbol-name (cadr (memq 'gnus-topic props)))))
+       (let ((topic (cadr (memq 'gnus-topic props))))
          (or (gnus-topic-goto-topic topic)
              (gnus-topic-goto-topic (gnus-topic-next-topic topic)))))
     (if (gnus-group-goto-group group)
@@ -992,12 +990,8 @@ articles in the topic and its subtopics."
   ;; First we make sure that we have really read the active file.
   (when (or force
            (not gnus-topic-active-alist))
-    (let (groups)
-      ;; Get a list of all groups available.
-      (mapatoms (lambda (g) (when (symbol-value g)
-                             (push (symbol-name g) groups)))
-               gnus-active-hashtb)
-      (setq groups (sort groups 'string<))
+    ;; Get a list of all groups available.
+    (let ((groups (sort (hash-table-keys gnus-active-hashtb) #'string<)))
       ;; Init the variables.
       (setq gnus-topic-active-topology (list (list "" 'visible)))
       (setq gnus-topic-active-alist nil)
@@ -1202,7 +1196,7 @@ If performed over a topic line, toggle folding the topic."
     (save-excursion
       (gnus-message 5 "Expiring groups in %s..." topic)
       (let ((gnus-group-marked
-            (mapcar (lambda (entry) (car (nth 2 entry)))
+            (mapcar (lambda (entry) (car (nth 1 entry)))
                     (gnus-topic-find-groups topic gnus-level-killed t
                                             nil t))))
        (gnus-group-expire-articles nil))
@@ -1216,7 +1210,7 @@ Also see `gnus-group-catchup'."
       (call-interactively 'gnus-group-catchup-current)
     (save-excursion
       (let* ((groups
-              (mapcar (lambda (entry) (car (nth 2 entry)))
+              (mapcar (lambda (entry) (car (nth 1 entry)))
                       (gnus-topic-find-groups topic gnus-level-killed t
                                               nil t)))
             (inhibit-read-only t)
@@ -1449,7 +1443,7 @@ If NON-RECURSIVE (which is the prefix) is t, don't mark 
its subtopics."
                                            (not non-recursive))))
        (while groups
          (funcall (if unmark 'gnus-group-remove-mark 'gnus-group-set-mark)
-                  (gnus-info-group (nth 2 (pop groups)))))))))
+                  (gnus-info-group (nth 1 (pop groups)))))))))
 
 (defun gnus-topic-unmark-topic (topic &optional _dummy non-recursive)
   "Remove the process mark from all groups in the TOPIC.
diff --git a/lisp/gnus/gnus-undo.el b/lisp/gnus/gnus-undo.el
index d487262..179679a 100644
--- a/lisp/gnus/gnus-undo.el
+++ b/lisp/gnus/gnus-undo.el
@@ -1,6 +1,6 @@
 ;;; gnus-undo.el --- minor mode for undoing in Gnus
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el
index e69aa2c..6b0f29b 100644
--- a/lisp/gnus/gnus-util.el
+++ b/lisp/gnus/gnus-util.el
@@ -1,6 +1,6 @@
 ;;; gnus-util.el --- utility functions for Gnus
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
@@ -35,6 +35,7 @@
 (eval-when-compile (require 'cl-lib))
 
 (require 'time-date)
+(require 'text-property-search)
 
 (defcustom gnus-completing-read-function 'gnus-emacs-completing-read
   "Function use to do completing read."
@@ -104,13 +105,6 @@ This is a compatibility function for different Emacsen."
 (put 'gnus-eval-in-buffer-window 'lisp-indent-function 1)
 (put 'gnus-eval-in-buffer-window 'edebug-form-spec '(form body))
 
-(defmacro gnus-intern-safe (string hashtable)
-  "Get hash value.  Arguments are STRING and HASHTABLE."
-  `(let ((symbol (intern ,string ,hashtable)))
-     (or (boundp symbol)
-        (set symbol nil))
-     symbol))
-
 (defsubst gnus-goto-char (point)
   (and point (goto-char point)))
 
@@ -139,7 +133,7 @@ This is a compatibility function for different Emacsen."
 
 (defun gnus-extract-address-components (from)
   "Extract address components from a From header.
-Given an RFC-822 address FROM, extract full name and canonical address.
+Given an RFC-822 (or later) address FROM, extract name and address.
 Returns a list of the form (FULL-NAME CANONICAL-ADDRESS).  Much more simple
 solution than `mail-header-parse-address', which works much better, but
 is slower."
@@ -199,6 +193,36 @@ is slower."
                   (search-forward ":" eol t)
                   (point)))))
 
+(defun gnus-text-property-search (prop value &optional forward-only goto end)
+  "Search current buffer for text property PROP with VALUE.
+Behaves like a combination of `text-property-any' and
+`text-property-search-forward'.  Searches for the beginning of a
+text property `equal' to VALUE.  Returns the value of point at
+the beginning of the matching text property span.
+
+If FORWARD-ONLY is non-nil, only search forward from point.
+
+If GOTO is non-nil, move point to the beginning of that span
+instead.
+
+If END is non-nil, use the end of the span instead."
+  (let* ((start (point))
+        (found (progn
+                 (unless forward-only
+                   (goto-char (point-min)))
+                 (text-property-search-forward
+                  prop value #'equal)))
+        (target (when found
+                  (if end
+                      (prop-match-end found)
+                    (prop-match-beginning found)))))
+    (when target
+      (if goto
+         (goto-char target)
+       (prog1
+           target
+         (goto-char start))))))
+
 (declare-function gnus-find-method-for-group "gnus" (group &optional info))
 (declare-function gnus-group-name-decode "gnus-group" (string charset))
 (declare-function gnus-group-name-charset "gnus-group" (method group))
@@ -390,22 +414,9 @@ Cache the result as a text property stored in DATE."
   "Quote all \"%\"'s in STRING."
   (replace-regexp-in-string "%" "%%" string))
 
-;; Make a hash table (default and minimum size is 256).
-;; Optional argument HASHSIZE specifies the table size.
-(defun gnus-make-hashtable (&optional hashsize)
-  (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 256) 256) 0))
-
-;; Make a number that is suitable for hashing; bigger than MIN and
-;; equal to some 2^x.  Many machines (such as sparcs) do not have a
-;; hardware modulo operation, so they implement it in software.  On
-;; many sparcs over 50% of the time to intern is spent in the modulo.
-;; Yes, it's slower than actually computing the hash from the string!
-;; So we use powers of 2 so people can optimize the modulo to a mask.
-(defun gnus-create-hash-size (min)
-  (let ((i 1))
-    (while (< i min)
-      (setq i (* 2 i)))
-    i))
+(defsubst gnus-make-hashtable (&optional size)
+  "Make a hash table of SIZE, testing on `equal'."
+  (make-hash-table :size (or size 300) :test #'equal))
 
 (defcustom gnus-verbose 6
   "Integer that says how verbose Gnus should be.
@@ -1174,18 +1185,16 @@ ARG is passed to the first function."
       ;; The buffer should be in the unibyte mode because group names
       ;; are ASCII text or encoded non-ASCII text (i.e., unibyte).
       (mm-disable-multibyte)
-      (mapatoms
-       (lambda (sym)
-        (when (and sym
-                   (boundp sym)
-                   (symbol-value sym))
-          (insert (format "%S %d %d y\n"
+      (maphash
+       (lambda (group active)
+        (when active
+          (insert (format "%s %d %d y\n"
                           (if full-names
-                              sym
-                            (intern (gnus-group-real-name (symbol-name sym))))
-                          (or (cdr (symbol-value sym))
-                              (car (symbol-value sym)))
-                          (car (symbol-value sym))))))
+                              group
+                            (gnus-group-real-name group))
+                          (or (cdr active)
+                              (car active))
+                          (car active)))))
        hashtb)
       (goto-char (point-max))
       (while (search-backward "\\." nil t)
diff --git a/lisp/gnus/gnus-uu.el b/lisp/gnus/gnus-uu.el
index a171a38..253ee24 100644
--- a/lisp/gnus/gnus-uu.el
+++ b/lisp/gnus/gnus-uu.el
@@ -1,6 +1,6 @@
 ;;; gnus-uu.el --- extract (uu)encoded files in Gnus
 
-;; Copyright (C) 1985-1987, 1993-1998, 2000-2018 Free Software
+;; Copyright (C) 1985-1987, 1993-1998, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
diff --git a/lisp/gnus/gnus-vm.el b/lisp/gnus/gnus-vm.el
index 24235d9..6042365 100644
--- a/lisp/gnus/gnus-vm.el
+++ b/lisp/gnus/gnus-vm.el
@@ -1,6 +1,6 @@
 ;;; gnus-vm.el --- vm interface for Gnus
 
-;; Copyright (C) 1994-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-2019 Free Software Foundation, Inc.
 
 ;; Author: Per Persson <address@hidden>
 ;; Keywords: news, mail
diff --git a/lisp/gnus/gnus-win.el b/lisp/gnus/gnus-win.el
index ff3073a..5f7154c 100644
--- a/lisp/gnus/gnus-win.el
+++ b/lisp/gnus/gnus-win.el
@@ -1,6 +1,6 @@
 ;;; gnus-win.el --- window configuration functions for Gnus
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el
index 1ac02b4..989347c 100644
--- a/lisp/gnus/gnus.el
+++ b/lisp/gnus/gnus.el
@@ -1,6 +1,6 @@
 ;;; gnus.el --- a newsreader for GNU Emacs  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1987-1990, 1993-1998, 2000-2018 Free Software
+;; Copyright (C) 1987-1990, 1993-1998, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Masanobu UMEDA <address@hidden>
@@ -29,7 +29,8 @@
 
 (run-hooks 'gnus-load-hook)
 
-(eval-when-compile (require 'cl-lib))
+(eval-when-compile (require 'cl-lib)
+                  (require 'subr-x))
 (require 'wid-edit)
 (require 'mm-util)
 (require 'nnheader)
@@ -2453,28 +2454,37 @@ such as a mark that says whether an article is stored 
in the cache
 gnus-registry.el will populate this if it's loaded.")
 
 (defvar gnus-newsrc-hashtb nil
-  "Hashtable of `gnus-newsrc-alist'.")
+  "Hash table of `gnus-newsrc-alist'.")
+
+(defvar gnus-group-list nil
+  "Ordered list of group names as strings.
+This variable only exists to provide easy access to the ordering
+of `gnus-newsrc-alist'.")
 
 (defvar gnus-killed-list nil
   "List of killed newsgroups.")
 
 (defvar gnus-killed-hashtb nil
-  "Hash table equivalent of `gnus-killed-list'.")
+  "Hash table equivalent of `gnus-killed-list'.
+This is a hash table purely for the fast membership test: values
+are always t.")
 
 (defvar gnus-zombie-list nil
   "List of almost dead newsgroups.")
 
 (defvar gnus-description-hashtb nil
-  "Descriptions of newsgroups.")
+  "Hash table mapping group names to their descriptions.")
 
 (defvar gnus-list-of-killed-groups nil
   "List of newsgroups that have recently been killed by the user.")
 
 (defvar gnus-active-hashtb nil
-  "Hashtable of active articles.")
+  "Hash table mapping group names to their active entry.")
 
 (defvar gnus-moderated-hashtb nil
-  "Hashtable of moderated newsgroups.")
+  "Hash table of moderated groups.
+This is a hash table purely for the fast membership test: values
+are always t.")
 
 ;; Save window configuration.
 (defvar gnus-prev-winconf nil)
@@ -2800,36 +2810,21 @@ See Info node `(gnus)Formatting Variables'."
 (defun gnus-header-from (header)
   (mail-header-from header))
 
-(defmacro gnus-gethash (string hashtable)
-  "Get hash value of STRING in HASHTABLE."
-  `(symbol-value (intern-soft ,string ,hashtable)))
-
-(defmacro gnus-gethash-safe (string hashtable)
-  "Get hash value of STRING in HASHTABLE.
-Return nil if not defined."
-  `(let ((sym (intern-soft ,string ,hashtable)))
-     (and (boundp sym) (symbol-value sym))))
-
-(defmacro gnus-sethash (string value hashtable)
-  "Set hash value.  Arguments are STRING, VALUE, and HASHTABLE."
-  `(set (intern ,string ,hashtable) ,value))
-(put 'gnus-sethash 'edebug-form-spec '(form form form))
-
 (defmacro gnus-group-unread (group)
   "Get the currently computed number of unread articles in GROUP."
-  `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
+  `(car (gethash ,group gnus-newsrc-hashtb)))
 
 (defmacro gnus-group-entry (group)
   "Get the newsrc entry for GROUP."
-  `(gnus-gethash ,group gnus-newsrc-hashtb))
+  `(gethash ,group gnus-newsrc-hashtb))
 
 (defmacro gnus-active (group)
   "Get active info on GROUP."
-  `(gnus-gethash ,group gnus-active-hashtb))
+  `(gethash ,group gnus-active-hashtb))
 
 (defmacro gnus-set-active (group active)
   "Set GROUP's active info."
-  `(gnus-sethash ,group ,active gnus-active-hashtb))
+  `(puthash ,group ,active gnus-active-hashtb))
 
 ;; Info access macros.
 
@@ -2893,10 +2888,10 @@ Return nil if not defined."
        (setcar rank (cons (car rank) ,score)))))
 
 (defmacro gnus-get-info (group)
-  `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
+  `(nth 1 (gethash ,group gnus-newsrc-hashtb)))
 
 (defun gnus-set-info (group info)
-  (setcar (nthcdr 2 (gnus-gethash group gnus-newsrc-hashtb))
+  (setcdr (gethash group gnus-newsrc-hashtb)
          info))
 
 
@@ -3185,7 +3180,7 @@ that that variable is buffer-local to the summary 
buffers."
 
 (defun gnus-kill-ephemeral-group (group)
   "Remove ephemeral GROUP from relevant structures."
-  (gnus-sethash group nil gnus-newsrc-hashtb))
+  (remhash group gnus-newsrc-hashtb))
 
 (defun gnus-simplify-mode-line ()
   "Make mode lines a bit simpler."
@@ -3751,7 +3746,7 @@ just the host name."
     ;; otherwise collapse to select method.
     (let* ((colon (string-match ":" group))
           (server (and colon (substring group 0 colon)))
-          (plus (and server (string-match "+" server))))
+          (plus (and server (string-match "\\+" server))))
       (when server
        (if plus
            (setq foreign (substring server (+ 1 plus)
diff --git a/lisp/gnus/gssapi.el b/lisp/gnus/gssapi.el
index d13aacc..7811763 100644
--- a/lisp/gnus/gssapi.el
+++ b/lisp/gnus/gssapi.el
@@ -1,6 +1,6 @@
 ;;; gssapi.el --- GSSAPI/Kerberos 5 interface for Emacs
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <address@hidden>
 ;;         Lars Magne Ingebrigtsen <address@hidden>
diff --git a/lisp/gnus/legacy-gnus-agent.el b/lisp/gnus/legacy-gnus-agent.el
index 128886e..5d5be44 100644
--- a/lisp/gnus/legacy-gnus-agent.el
+++ b/lisp/gnus/legacy-gnus-agent.el
@@ -1,6 +1,6 @@
 ;;; gnus-agent.el --- Legacy unplugged support for Gnus
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Kevin Greiner <address@hidden>
 ;; Keywords: news
diff --git a/lisp/gnus/mail-source.el b/lisp/gnus/mail-source.el
index 5af2920..7514e64 100644
--- a/lisp/gnus/mail-source.el
+++ b/lisp/gnus/mail-source.el
@@ -1,6 +1,6 @@
 ;;; mail-source.el --- functions for fetching mail
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news, mail
@@ -647,9 +647,9 @@ Deleting old (> %s day(s)) incoming mail file `%s'." diff 
bfile)
          ;; Don't check for old incoming files more than once per day to
          ;; save a lot of file accesses.
          (when (or (null mail-source-incoming-last-checked-time)
-                   (> (float-time
-                       (time-since mail-source-incoming-last-checked-time))
-                      (* 24 60 60)))
+                   (time-less-p
+                    (* 24 60 60)
+                    (time-since mail-source-incoming-last-checked-time)))
            (setq mail-source-incoming-last-checked-time (current-time))
            (mail-source-delete-old-incoming
             mail-source-delete-incoming
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el
index fdaa4e8..c8b6f0e 100644
--- a/lisp/gnus/message.el
+++ b/lisp/gnus/message.el
@@ -1,6 +1,6 @@
 ;;; message.el --- composing mail and news messages -*- lexical-binding: t -*-
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: mail, news
@@ -1285,11 +1285,10 @@ called and its result is inserted."
              (goto-char (point-min))
              (let ((case-fold-search nil))
                (re-search-forward "^OR\\>" nil t))))
-      ;; According to RFC822, "The field-name must be composed of printable
-      ;; ASCII characters (i. e., characters that have decimal values between
-      ;; 33 and 126, except colon)", i. e., any chars except ctl chars,
-      ;; space, or colon.
-      '(looking-at "[ \t]\\|[][!\"#$%&'()*+,-./0-9;<=>address@hidden|}~]+:"))
+      ;; According to RFC 822 and its successors, the field name must
+      ;; consist of printable US-ASCII characters other than colon,
+      ;; i.e., decimal 33-56 and 59-126.
+      '(looking-at "[ \t]\\|[][!\"#$%&'()*+,./0-9;<=>address@hidden|}~-]+:"))
   "Set this non-nil if the system's mailer runs the header and body together.
 \(This problem exists on Sunos 4 when sendmail is run in remote mode.)
 The value should be an expression to test whether the problem will
@@ -1733,7 +1732,7 @@ no, only reply back to the author."
   :type 'boolean)
 
 (defcustom message-user-fqdn nil
-  "Domain part of Message-Ids."
+  "Domain part of Message-IDs."
   :version "22.1"
   :group 'message-headers
   :link '(custom-manual "(message)News Headers")
@@ -1791,8 +1790,8 @@ You must have the \"hashcash\" binary installed, see 
`hashcash-path'."
     (concat
      "From "
 
-     ;; Many things can happen to an RFC 822 mailbox before it is put into
-     ;; a `From' line.  The leading phrase can be stripped, e.g.
+     ;; Many things can happen to an RFC 822 (or later) mailbox before it is
+     ;; put into a `From' line.  The leading phrase can be stripped, e.g.
      ;; `Joe <@w.x:address@hidden>' -> `<@w.x:address@hidden>'.  The <> can be 
stripped, e.g.
      ;; `<@x.y:address@hidden>' -> address@hidden:address@hidden'.  Everything 
starting with a CRLF
      ;; can be removed, e.g.
@@ -5400,6 +5399,17 @@ Otherwise, generate and save a value for 
`canlock-password' first."
             (message "Denied posting -- only quoted text.")
             nil)))))))
 
+(defun message--rotate-fixnum-left (n)
+  "Rotate the fixnum N left by one bit in a fixnum word.
+The result is a fixnum."
+  (logior (if (natnump n) 0 1)
+         (ash (cond ((< (ash most-positive-fixnum -1) n)
+                     (logior n most-negative-fixnum))
+                    ((< n (ash most-negative-fixnum -1))
+                     (logand n most-positive-fixnum))
+                    (n))
+              1)))
+
 (defun message-checksum ()
   "Return a \"checksum\" for the current buffer."
   (let ((sum 0))
@@ -5409,7 +5419,7 @@ Otherwise, generate and save a value for 
`canlock-password' first."
        (concat "^" (regexp-quote mail-header-separator) "$"))
       (while (not (eobp))
        (when (not (looking-at "[ \t\n]"))
-         (setq sum (logxor (ash sum 1) (if (natnump sum) 0 1)
+         (setq sum (logxor (message--rotate-fixnum-left sum)
                            (char-after))))
        (forward-char 1)))
     sum))
@@ -5531,7 +5541,7 @@ In posting styles use `(\"Expires\" (make-expires-date 
30))'."
   (let* ((cur (decode-time))
         (nday (+ days (nth 3 cur))))
     (setf (nth 3 cur) nday)
-    (message-make-date (apply 'encode-time cur))))
+    (message-make-date (encode-time cur))))
 
 (defun message-make-message-id ()
   "Make a unique Message-ID."
@@ -5721,7 +5731,7 @@ In posting styles use `(\"Expires\" (make-expires-date 
30))'."
        (insert fullname)
        (goto-char (point-min))
        ;; Look for a character that cannot appear unquoted
-       ;; according to RFC 822.
+       ;; according to RFC 822 (or later).
        (when (re-search-forward "[^- !#-'*+/-9=?A-Z^-~]" nil 1)
          ;; Quote fullname, escaping specials.
          (goto-char (point-min))
@@ -5735,8 +5745,7 @@ In posting styles use `(\"Expires\" (make-expires-date 
30))'."
        (let ((fullname-start (point)))
          (insert fullname)
          (goto-char fullname-start)
-         ;; RFC 822 says \ and nonmatching parentheses
-         ;; must be escaped in comments.
+         ;; \ and nonmatching parentheses must be escaped in comments.
          ;; Escape every instance of ()\ ...
          (while (re-search-forward "[()\\]" nil 1)
            (replace-match "\\\\\\&" t))
@@ -8015,18 +8024,11 @@ regular text mode tabbing command."
               (skip-chars-backward "^, \t\n") (point))))
        (completion-ignore-case t)
        (e (progn (skip-chars-forward "^,\t\n ") (point)))
-       group collection)
-    (when (and (boundp 'gnus-active-hashtb)
-              gnus-active-hashtb)
-      (mapatoms
-       (lambda (symbol)
-        (setq group (symbol-name symbol))
-        (push (if (string-match "[^\000-\177]" group)
-                  (gnus-group-decoded-name group)
-                group)
-              collection))
-       gnus-active-hashtb))
-    (completion-in-region b e collection)))
+       (collection (when (and (boundp 'gnus-active-hashtb)
+                              gnus-active-hashtb)
+                     (hash-table-keys gnus-active-hashtb))))
+    (when collection
+      (completion-in-region b e collection))))
 
 (defun message-expand-name ()
   (cond ((and (memq 'eudc message-expand-name-databases)
@@ -8051,7 +8053,7 @@ regular text mode tabbing command."
 If SHOW is non-nil, the arguments TEXT... are displayed in a temp buffer.
 The following arguments may contain lists of values."
   (if (and show
-          (setq text (message-flatten-list text)))
+          (setq text (flatten-tree text)))
       (save-window-excursion
         (with-output-to-temp-buffer " *MESSAGE information message*"
           (with-current-buffer " *MESSAGE information message*"
@@ -8061,15 +8063,7 @@ The following arguments may contain lists of values."
        (funcall ask question))
     (funcall ask question)))
 
-(defun message-flatten-list (list)
-  "Return a new, flat list that contains all elements of LIST.
-
-\(message-flatten-list \\='(1 (2 3 (4 5 (6))) 7))
-=> (1 2 3 4 5 6 7)"
-  (cond ((consp list)
-        (apply 'append (mapcar 'message-flatten-list list)))
-       (list
-        (list list))))
+(define-obsolete-function-alias 'message-flatten-list #'flatten-tree "27.1")
 
 (defun message-generate-new-buffer-clone-locals (name &optional varstr)
   "Create and return a buffer with name based on NAME using 
`generate-new-buffer'.
diff --git a/lisp/gnus/mm-archive.el b/lisp/gnus/mm-archive.el
index 6c6361a..7e2a914 100644
--- a/lisp/gnus/mm-archive.el
+++ b/lisp/gnus/mm-archive.el
@@ -1,6 +1,6 @@
 ;;; mm-archive.el --- Functions for parsing archive files as MIME
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; This file is part of GNU Emacs.
diff --git a/lisp/gnus/mm-bodies.el b/lisp/gnus/mm-bodies.el
index e292dac..e1e1a12 100644
--- a/lisp/gnus/mm-bodies.el
+++ b/lisp/gnus/mm-bodies.el
@@ -1,6 +1,6 @@
 ;;; mm-bodies.el --- Functions for decoding MIME things
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;;     MORIOKA Tomohiko <address@hidden>
@@ -35,7 +35,7 @@
 ;; BS, vertical TAB, form feed, and ^_
 ;;
 ;; Note that CR is *not* included, as that would allow a non-paired CR
-;; in the body contrary to RFC 2822:
+;; in the body contrary to RFC 822 (or later):
 ;;
 ;;   - CR and LF MUST only occur together as CRLF; they MUST NOT
 ;;     appear independently in the body.
diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el
index 3e6883b..3f25541 100644
--- a/lisp/gnus/mm-decode.el
+++ b/lisp/gnus/mm-decode.el
@@ -1,6 +1,6 @@
 ;;; mm-decode.el --- Functions for decoding MIME things  -*- lexical-binding:t 
-*-
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;;     MORIOKA Tomohiko <address@hidden>
@@ -190,45 +190,45 @@ before the external MIME handler is invoked."
   :group 'mime-display)
 
 (defcustom mm-inline-media-tests
-  '(("image/p?jpeg"
+  `(("image/p?jpeg"
      mm-inline-image
-     (lambda (handle)
+     ,(lambda (handle)
        (mm-valid-and-fit-image-p 'jpeg handle)))
     ("image/png"
      mm-inline-image
-     (lambda (handle)
+     ,(lambda (handle)
        (mm-valid-and-fit-image-p 'png handle)))
     ("image/gif"
      mm-inline-image
-     (lambda (handle)
+     ,(lambda (handle)
        (mm-valid-and-fit-image-p 'gif handle)))
     ("image/tiff"
      mm-inline-image
-     (lambda (handle)
+     ,(lambda (handle)
        (mm-valid-and-fit-image-p 'tiff handle)))
     ("image/xbm"
      mm-inline-image
-     (lambda (handle)
+     ,(lambda (handle)
        (mm-valid-and-fit-image-p 'xbm handle)))
     ("image/x-xbitmap"
      mm-inline-image
-     (lambda (handle)
+     ,(lambda (handle)
        (mm-valid-and-fit-image-p 'xbm handle)))
     ("image/xpm"
      mm-inline-image
-     (lambda (handle)
+     ,(lambda (handle)
        (mm-valid-and-fit-image-p 'xpm handle)))
     ("image/x-xpixmap"
      mm-inline-image
-     (lambda (handle)
+     ,(lambda (handle)
        (mm-valid-and-fit-image-p 'xpm handle)))
     ("image/bmp"
      mm-inline-image
-     (lambda (handle)
+     ,(lambda (handle)
        (mm-valid-and-fit-image-p 'bmp handle)))
     ("image/x-portable-bitmap"
      mm-inline-image
-     (lambda (handle)
+     ,(lambda (handle)
        (mm-valid-and-fit-image-p 'pbm handle)))
     ("text/plain" mm-inline-text identity)
     ("text/enriched" mm-inline-text identity)
@@ -246,13 +246,14 @@ before the external MIME handler is invoked."
     ("text/x-org" mm-display-org-inline identity)
     ("text/html"
      mm-inline-text-html
-     (lambda (handle)
+     ,(lambda (_handle)
        mm-text-html-renderer))
     ("text/x-vcard"
      mm-inline-text-vcard
-     (lambda (handle)
+     ,(lambda (_handle)
        (or (featurep 'vcard)
           (locate-library "vcard"))))
+    ("text/calendar" gnus-icalendar-mm-inline identity)
     ("message/delivery-status" mm-inline-text identity)
     ("message/rfc822" mm-inline-message identity)
     ("message/partial" mm-inline-partial identity)
@@ -261,13 +262,13 @@ before the external MIME handler is invoked."
     ("application/x-.?tar\\(-.*\\)?" mm-archive-dissect-and-inline identity)
     ("application/zip" mm-archive-dissect-and-inline identity)
     ("audio/wav" mm-inline-audio
-     (lambda (handle)
-       (and (or (featurep 'nas-sound) (featurep 'native-sound))
+     ,(lambda (_handle)
+       (and (fboundp 'device-sound-enabled-p)
            (device-sound-enabled-p))))
     ("audio/au"
      mm-inline-audio
-     (lambda (handle)
-       (and (or (featurep 'nas-sound) (featurep 'native-sound))
+     ,(lambda (_handle)
+       (and (fboundp 'device-sound-enabled-p)
            (device-sound-enabled-p))))
     ("application/pgp-signature" ignore identity)
     ("application/x-pkcs7-signature" ignore identity)
@@ -279,7 +280,7 @@ before the external MIME handler is invoked."
     ("multipart/related" ignore identity)
     ("image/.*"
      mm-inline-image
-     (lambda (handle)
+     ,(lambda (handle)
        (and (mm-valid-image-format-p 'imagemagick)
            (mm-with-unibyte-buffer
              (mm-insert-part handle)
@@ -331,6 +332,7 @@ a list of regexps."
 
 (defcustom mm-automatic-display
   '("text/plain" "text/enriched" "text/richtext" "text/html" "text/x-verbatim"
+    "text/calendar"
     "text/x-vcard" "image/.*" "message/delivery-status" "multipart/.*"
     "message/rfc822" "text/x-patch" "text/dns" "application/pgp-signature"
     "application/emacs-lisp" "application/x-emacs-lisp"
@@ -763,7 +765,7 @@ MIME-Version header before proceeding."
         (mb enable-multibyte-characters)
         beg)
     (goto-char (point-min))
-    (search-forward-regexp "^\n" nil t)
+    (search-forward-regexp "^\n" nil 'move) ;; There might be no body.
     (setq beg (point))
     (with-current-buffer
           (generate-new-buffer " *mm*")
@@ -890,6 +892,7 @@ external if displayed external."
            (when method
              (message "Viewing with %s" method))
            (let ((mm (current-buffer))
+                 (attachment-filename (mm-handle-filename handle))
                  (non-viewer (assq 'non-viewer
                                    (mailcap-mime-info
                                     (mm-handle-media-type handle) t))))
@@ -899,6 +902,9 @@ external if displayed external."
                        (when (and (boundp 'gnus-summary-buffer)
                                   (bufferp gnus-summary-buffer)
                                   (buffer-name gnus-summary-buffer))
+                         (when attachment-filename
+                           (with-current-buffer mm
+                             (rename-buffer (format "*mm* %s" 
attachment-filename) t)))
                          ;; So that we pop back to the right place, sort of.
                          (switch-to-buffer gnus-summary-buffer)
                          (switch-to-buffer mm))
diff --git a/lisp/gnus/mm-encode.el b/lisp/gnus/mm-encode.el
index 361e85f..7d10409 100644
--- a/lisp/gnus/mm-encode.el
+++ b/lisp/gnus/mm-encode.el
@@ -1,6 +1,6 @@
 ;;; mm-encode.el --- Functions for encoding MIME things
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;;     MORIOKA Tomohiko <address@hidden>
diff --git a/lisp/gnus/mm-extern.el b/lisp/gnus/mm-extern.el
index fbae669..c305443 100644
--- a/lisp/gnus/mm-extern.el
+++ b/lisp/gnus/mm-extern.el
@@ -1,6 +1,6 @@
 ;;; mm-extern.el --- showing message/external-body  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Shenghuo Zhu <address@hidden>
 ;; Keywords: message external-body
diff --git a/lisp/gnus/mm-partial.el b/lisp/gnus/mm-partial.el
index 51dc8b8..c68ab4a 100644
--- a/lisp/gnus/mm-partial.el
+++ b/lisp/gnus/mm-partial.el
@@ -1,6 +1,6 @@
 ;;; mm-partial.el --- showing message/partial
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Shenghuo Zhu <address@hidden>
 ;; Keywords: message partial
diff --git a/lisp/gnus/mm-url.el b/lisp/gnus/mm-url.el
index 1008c60..b53a1bc 100644
--- a/lisp/gnus/mm-url.el
+++ b/lisp/gnus/mm-url.el
@@ -1,6 +1,6 @@
 ;;; mm-url.el --- a wrapper of url functions/commands for Gnus
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Shenghuo Zhu <address@hidden>
 
diff --git a/lisp/gnus/mm-util.el b/lisp/gnus/mm-util.el
index ba54b4e..00a8a53 100644
--- a/lisp/gnus/mm-util.el
+++ b/lisp/gnus/mm-util.el
@@ -1,6 +1,6 @@
 ;;; mm-util.el --- Utility functions for Mule and low level things  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;;     MORIOKA Tomohiko <address@hidden>
diff --git a/lisp/gnus/mm-uu.el b/lisp/gnus/mm-uu.el
index cf6d6d1..a00d640 100644
--- a/lisp/gnus/mm-uu.el
+++ b/lisp/gnus/mm-uu.el
@@ -1,6 +1,6 @@
 ;;; mm-uu.el --- Return uu stuff as mm handles
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Shenghuo Zhu <address@hidden>
 ;; Keywords: postscript uudecode binhex shar forward gnatsweb pgp
diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el
index 15eac11..1e1d264 100644
--- a/lisp/gnus/mm-view.el
+++ b/lisp/gnus/mm-view.el
@@ -1,6 +1,6 @@
 ;;; mm-view.el --- functions for viewing MIME objects
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; This file is part of GNU Emacs.
@@ -370,10 +370,12 @@
          (enriched-decode (point-min) (point-max))))
       (mm-handle-set-undisplayer
        handle
-       `(lambda ()
-          (let ((inhibit-read-only t))
-           (delete-region ,(copy-marker (point-min) t)
-                          ,(point-max-marker))))))))
+       (if (= (point-min) (point-max))
+          #'ignore
+        `(lambda ()
+           (let ((inhibit-read-only t))
+             (delete-region ,(copy-marker (point-min) t)
+                            ,(point-max-marker)))))))))
 
 (defun mm-insert-inline (handle text)
   "Insert TEXT inline from HANDLE."
@@ -474,28 +476,32 @@ If MODE is not set, try to find mode automatically."
                     (mm-decode-string text charset))
                    (t
                     text)))
-      (require 'font-lock)
-      ;; I find font-lock a bit too verbose.
-      (let ((font-lock-verbose nil)
-           (font-lock-support-mode nil)
+      (let ((font-lock-verbose nil)     ; font-lock is a bit too verbose.
            (enable-local-variables nil))
-       ;; Disable support modes, e.g., jit-lock, lazy-lock, etc.
-       ;; Note: XEmacs people use `font-lock-mode-hook' to run those modes.
+        ;; We used to set font-lock-mode-hook to nil to avoid enabling
+        ;; support modes, but now that we use font-lock-ensure, support modes
+        ;; aren't a problem any more.  So we could probably get rid of this
+        ;; setting now, but it seems harmless and potentially still useful.
        (set (make-local-variable 'font-lock-mode-hook) nil)
         (setq buffer-file-name (mm-handle-filename handle))
        (with-demoted-errors
-         (if mode
-             (save-window-excursion
-               (switch-to-buffer (current-buffer))
-               (funcall mode))
+           (if mode
+                (save-window-excursion
+                  ;; According to Katsumi Yamaoka <address@hidden>, org-mode
+                  ;; requires the buffer to be temporarily displayed here, but
+                  ;; I could not reproduce this problem.  Furthermore, if
+                  ;; there's such a problem, we should fix org-mode rather than
+                  ;; use switch-to-buffer which can have undesirable
+                  ;; side-effects!
+                  ;;(switch-to-buffer (current-buffer))
+                 (funcall mode))
            (let ((auto-mode-alist
                   (delq (rassq 'doc-view-mode-maybe auto-mode-alist)
                         (copy-sequence auto-mode-alist))))
-             (set-auto-mode)))
-         ;; The mode function might have already turned on font-lock.
+             (set-auto-mode)
+             (setq mode major-mode)))
          ;; Do not fontify if the guess mode is fundamental.
-         (unless (or font-lock-mode
-                     (eq major-mode 'fundamental-mode))
+         (unless (eq major-mode 'fundamental-mode)
            (font-lock-ensure))))
       (setq text (buffer-string))
       (when (eq mode 'diff-mode)
@@ -505,7 +511,7 @@ If MODE is not set, try to find mode automatically."
       ;; Set buffer unmodified to avoid confirmation when killing the
       ;; buffer.
       (set-buffer-modified-p nil))
-    (let ((b (1- (point))))
+    (let ((b (- (point) (save-restriction (widen) (point-min)))))
       (mm-insert-inline handle text)
       (dolist (ov ovs)
        (move-overlay (nth 0 ov) (+ (nth 1 ov) b)
diff --git a/lisp/gnus/mml-sec.el b/lisp/gnus/mml-sec.el
index 9a64853..db7489f 100644
--- a/lisp/gnus/mml-sec.el
+++ b/lisp/gnus/mml-sec.el
@@ -1,6 +1,6 @@
 ;;; mml-sec.el --- A package with security functions for MML documents
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <address@hidden>
 
@@ -659,6 +659,8 @@ The passphrase is read and cached."
     (catch 'break
       (dolist (uid uids nil)
        (if (and (stringp (epg-user-id-string uid))
+                 (car (mail-header-parse-address
+                       (epg-user-id-string uid)))
                 (equal (downcase (car (mail-header-parse-address
                                        (epg-user-id-string uid))))
                        (downcase (car (mail-header-parse-address
diff --git a/lisp/gnus/mml-smime.el b/lisp/gnus/mml-smime.el
index 9df33d0..78fac8a 100644
--- a/lisp/gnus/mml-smime.el
+++ b/lisp/gnus/mml-smime.el
@@ -1,6 +1,6 @@
 ;;; mml-smime.el --- S/MIME support for MML
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <address@hidden>
 ;; Keywords: Gnus, MIME, S/MIME, MML
diff --git a/lisp/gnus/mml.el b/lisp/gnus/mml.el
index e232128..f6d358d 100644
--- a/lisp/gnus/mml.el
+++ b/lisp/gnus/mml.el
@@ -1,6 +1,6 @@
 ;;; mml.el --- A package for parsing and validating MML documents
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; This file is part of GNU Emacs.
@@ -29,6 +29,7 @@
 (require 'mml-sec)
 (eval-when-compile (require 'cl-lib))
 (eval-when-compile (require 'url))
+(eval-when-compile (require 'gnus-util))
 
 (autoload 'message-make-message-id "message")
 (declare-function gnus-setup-posting-charset "gnus-msg" (group))
@@ -982,8 +983,10 @@ If HANDLES is non-nil, use it instead reparsing the 
buffer."
   (unless handles
     (setq handles (mm-dissect-buffer t)))
   (goto-char (point-min))
-  (search-forward "\n\n" nil t)
-  (delete-region (point) (point-max))
+  (if (search-forward "\n\n" nil 'move)
+      (delete-region (point) (point-max))
+    ;; No content in the part that is the sole part of this message.
+    (insert (if (bolp) "\n" "\n\n")))
   (if (stringp (car handles))
       (mml-insert-mime handles)
     (mml-insert-mime handles t))
@@ -1545,7 +1548,6 @@ Should be adopted if code in `message-send-mail' is 
changed."
 
 (defvar mml-preview-buffer nil)
 
-(autoload 'gnus-make-hashtable "gnus-util")
 (autoload 'widget-button-press "wid-edit" nil t)
 (declare-function widget-event-point "wid-edit" (event))
 ;; If gnus-buffer-configuration is bound this is loaded.
diff --git a/lisp/gnus/mml1991.el b/lisp/gnus/mml1991.el
index b2056b2..ce282ec 100644
--- a/lisp/gnus/mml1991.el
+++ b/lisp/gnus/mml1991.el
@@ -1,6 +1,6 @@
 ;;; mml1991.el --- Old PGP message format (RFC 1991) support for MML
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Sascha Lüdecke <address@hidden>,
 ;;     Simon Josefsson <address@hidden> (Mailcrypt interface, Gnus glue)
diff --git a/lisp/gnus/mml2015.el b/lisp/gnus/mml2015.el
index 403b5e1..d7876a3 100644
--- a/lisp/gnus/mml2015.el
+++ b/lisp/gnus/mml2015.el
@@ -1,6 +1,6 @@
 ;;; mml2015.el --- MIME Security with Pretty Good Privacy (PGP)
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Shenghuo Zhu <address@hidden>
 ;; Keywords: PGP MIME MML
diff --git a/lisp/gnus/nnagent.el b/lisp/gnus/nnagent.el
index 1b2b13e..64f3a86 100644
--- a/lisp/gnus/nnagent.el
+++ b/lisp/gnus/nnagent.el
@@ -1,6 +1,6 @@
 ;;; nnagent.el --- offline backend for Gnus
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news, mail
diff --git a/lisp/gnus/nnbabyl.el b/lisp/gnus/nnbabyl.el
index 9f80a75..3b31645 100644
--- a/lisp/gnus/nnbabyl.el
+++ b/lisp/gnus/nnbabyl.el
@@ -1,6 +1,6 @@
 ;;; nnbabyl.el --- rmail mbox access for Gnus
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;;     Masanobu UMEDA <address@hidden>
@@ -624,7 +624,7 @@
 (defun nnbabyl-check-mbox ()
   "Go through the nnbabyl mbox and make sure that no article numbers are 
reused."
   (interactive)
-  (let ((idents (make-vector 1000 0))
+  (let ((idents (gnus-make-hashtable 1000))
        id)
     (save-excursion
       (when (or (not nnbabyl-mbox-buffer)
@@ -633,13 +633,13 @@
       (set-buffer nnbabyl-mbox-buffer)
       (goto-char (point-min))
       (while (re-search-forward "^X-Gnus-Newsgroup: \\([^ ]+\\) "  nil t)
-       (if (intern-soft (setq id (match-string 1)) idents)
+       (if (gethash (setq id (match-string 1)) idents)
            (progn
              (delete-region (point-at-bol) (progn (forward-line 1) (point)))
              (nnheader-message 7 "Moving %s..." id)
              (nnbabyl-save-mail
               (nnmail-article-group 'nnbabyl-active-number)))
-         (intern id idents)))
+         (puthash id t idents)))
       (when (buffer-modified-p (current-buffer))
        (save-buffer))
       (nnmail-save-active nnbabyl-group-alist nnbabyl-active-file)
diff --git a/lisp/gnus/nndiary.el b/lisp/gnus/nndiary.el
index 0b300c1..c8b7eed 100644
--- a/lisp/gnus/nndiary.el
+++ b/lisp/gnus/nndiary.el
@@ -1,6 +1,6 @@
 ;;; nndiary.el --- A diary back end for Gnus
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author:        Didier Verna <address@hidden>
 ;; Maintainer:    Didier Verna <address@hidden>
@@ -1278,28 +1278,28 @@ all.  This may very well take some time.")
       (push
        (cond ((eq (cdr reminder) 'minute)
              (time-subtract
-              (apply 'encode-time 0 (nthcdr 1 date-elts))
-              (seconds-to-time (* (car reminder) 60.0))))
+              (apply #'encode-time 0 (nthcdr 1 date-elts))
+              (encode-time (* (car reminder) 60.0))))
             ((eq (cdr reminder) 'hour)
              (time-subtract
-              (apply 'encode-time 0 0 (nthcdr 2 date-elts))
-              (seconds-to-time (* (car reminder) 3600.0))))
+              (apply #'encode-time 0 0 (nthcdr 2 date-elts))
+              (encode-time (* (car reminder) 3600.0))))
             ((eq (cdr reminder) 'day)
              (time-subtract
-              (apply 'encode-time 0 0 0 (nthcdr 3 date-elts))
-              (seconds-to-time (* (car reminder) 86400.0))))
+              (apply #'encode-time 0 0 0 (nthcdr 3 date-elts))
+              (encode-time (* (car reminder) 86400.0))))
             ((eq (cdr reminder) 'week)
              (time-subtract
-              (apply 'encode-time 0 0 0 monday (nthcdr 4 date-elts))
-              (seconds-to-time (* (car reminder) 604800.0))))
+              (apply #'encode-time 0 0 0 monday (nthcdr 4 date-elts))
+              (encode-time (* (car reminder) 604800.0))))
             ((eq (cdr reminder) 'month)
              (time-subtract
-              (apply 'encode-time 0 0 0 1 (nthcdr 4 date-elts))
-              (seconds-to-time (* (car reminder) 18748800.0))))
+              (apply #'encode-time 0 0 0 1 (nthcdr 4 date-elts))
+              (encode-time (* (car reminder) 18748800.0))))
             ((eq (cdr reminder) 'year)
              (time-subtract
-              (apply 'encode-time 0 0 0 1 1 (nthcdr 5 date-elts))
-              (seconds-to-time (* (car reminder) 400861056.0)))))
+              (apply #'encode-time 0 0 0 1 1 (nthcdr 5 date-elts))
+              (encode-time (* (car reminder) 400861056.0)))))
        res))
     (sort res 'time-less-p)))
 
diff --git a/lisp/gnus/nndir.el b/lisp/gnus/nndir.el
index 6dc6c33..82502df 100644
--- a/lisp/gnus/nndir.el
+++ b/lisp/gnus/nndir.el
@@ -1,6 +1,6 @@
 ;;; nndir.el --- single directory newsgroup access for Gnus
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
diff --git a/lisp/gnus/nndoc.el b/lisp/gnus/nndoc.el
index 76e785d..532ba11 100644
--- a/lisp/gnus/nndoc.el
+++ b/lisp/gnus/nndoc.el
@@ -1,6 +1,6 @@
 ;;; nndoc.el --- single file access for Gnus
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;;     Masanobu UMEDA <address@hidden>
@@ -701,7 +701,7 @@ from the document.")
 
 (defun nndoc-lanl-gov-announce-type-p ()
   (when (let ((case-fold-search nil))
-         (re-search-forward "^\\\\\\\\\n\\(Paper\\( (\\*cross-listing\\*)\\)?: 
[a-zA-Z-\\.]+/[0-9]+\\|arXiv:\\)" nil t))
+         (re-search-forward "^\\\\\\\\\n\\(Paper\\( (\\*cross-listing\\*)\\)?: 
[a-zA-Z\\.-]+/[0-9]+\\|arXiv:\\)" nil t))
     t))
 
 (defun nndoc-transform-lanl-gov-announce (article)
@@ -732,7 +732,7 @@ from the document.")
       (save-restriction
        (narrow-to-region (car entry) (nth 1 entry))
        (goto-char (point-min))
-       (when (looking-at "^\\(Paper.*: \\|arXiv:\\)\\([0-9a-zA-Z-\\./]+\\)")
+       (when (looking-at "^\\(Paper.*: \\|arXiv:\\)\\([0-9a-zA-Z\\./-]+\\)")
          (setq subject (concat " (" (match-string 2) ")"))
          (when (re-search-forward "^From: \\(.*\\)" nil t)
            (setq from (concat "<"
diff --git a/lisp/gnus/nndraft.el b/lisp/gnus/nndraft.el
index cee7c92..bc475ee 100644
--- a/lisp/gnus/nndraft.el
+++ b/lisp/gnus/nndraft.el
@@ -1,6 +1,6 @@
 ;;; nndraft.el --- draft article access for Gnus
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
diff --git a/lisp/gnus/nneething.el b/lisp/gnus/nneething.el
index ced75c8..f64007a 100644
--- a/lisp/gnus/nneething.el
+++ b/lisp/gnus/nneething.el
@@ -1,6 +1,6 @@
 ;;; nneething.el --- arbitrary file access for Gnus
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;;     Masanobu UMEDA <address@hidden>
@@ -319,7 +319,7 @@ included.")
      "Subject: " (file-name-nondirectory file) (or extra-msg "") "\n"
      "Message-ID: <nneething-" (nneething-encode-file-name file)
      "@" (system-name) ">\n"
-     (if (zerop (float-time (file-attribute-modification-time atts))) ""
+     (if (time-equal-p 0 (file-attribute-modification-time atts)) ""
        (concat "Date: "
               (current-time-string (file-attribute-modification-time atts))
               "\n"))
diff --git a/lisp/gnus/nnfolder.el b/lisp/gnus/nnfolder.el
index 8ef6f2a..1c83045 100644
--- a/lisp/gnus/nnfolder.el
+++ b/lisp/gnus/nnfolder.el
@@ -1,6 +1,6 @@
 ;;; nnfolder.el --- mail folder access for Gnus
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <address@hidden>
 ;;      ShengHuo Zhu <address@hidden> (adding NOV)
diff --git a/lisp/gnus/nngateway.el b/lisp/gnus/nngateway.el
index 8b7898c..92e36a2 100644
--- a/lisp/gnus/nngateway.el
+++ b/lisp/gnus/nngateway.el
@@ -1,6 +1,6 @@
 ;;; nngateway.el --- posting news via mail gateways
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news, mail
diff --git a/lisp/gnus/nnheader.el b/lisp/gnus/nnheader.el
index ca9f804..090b842 100644
--- a/lisp/gnus/nnheader.el
+++ b/lisp/gnus/nnheader.el
@@ -1,6 +1,6 @@
 ;;; nnheader.el --- header access macros for Gnus and its backends
 
-;; Copyright (C) 1987-1990, 1993-1998, 2000-2018 Free Software
+;; Copyright (C) 1987-1990, 1993-1998, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Masanobu UMEDA <address@hidden>
@@ -1042,12 +1042,7 @@ See `find-file-noselect' for the arguments."
 ;; When changing this function, consider changing `pop3-accept-process-output'
 ;; as well.
 (defun nnheader-accept-process-output (process)
-  (accept-process-output
-   process
-   (truncate nnheader-read-timeout)
-   (truncate (* (- nnheader-read-timeout
-                  (truncate nnheader-read-timeout))
-               1000))))
+  (accept-process-output process nnheader-read-timeout))
 
 (defun nnheader-update-marks-actions (backend-marks actions)
   (dolist (action actions)
@@ -1080,7 +1075,7 @@ See `find-file-noselect' for the arguments."
 (defvar nnheader-last-message-time '(0 0))
 (defun nnheader-message-maybe (&rest args)
   (let ((now (current-time)))
-    (when (> (float-time (time-subtract now nnheader-last-message-time)) 1)
+    (when (time-less-p 1 (time-subtract now nnheader-last-message-time))
       (setq nnheader-last-message-time now)
       (apply 'nnheader-message args))))
 
diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el
index 1a3b05d..ac1d286 100644
--- a/lisp/gnus/nnimap.el
+++ b/lisp/gnus/nnimap.el
@@ -1,6 +1,6 @@
 ;;; nnimap.el --- IMAP interface for Gnus
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;;         Simon Josefsson <address@hidden>
@@ -386,12 +386,12 @@ textual parts.")
        (with-current-buffer buffer
          (when (and nnimap-object
                     (nnimap-last-command-time nnimap-object)
-                    (> (float-time
-                        (time-subtract
-                         now
-                         (nnimap-last-command-time nnimap-object)))
-                       ;; More than five minutes since the last command.
-                       (* 5 60)))
+                    (time-less-p
+                     ;; More than five minutes since the last command.
+                     (* 5 60)
+                     (time-subtract
+                      now
+                      (nnimap-last-command-time nnimap-object))))
             (ignore-errors              ;E.g. "buffer foo has no process".
               (nnimap-send-command "NOOP"))))))))
 
@@ -413,8 +413,11 @@ textual parts.")
        nil
       stream)))
 
+;; This is only needed for Windows XP or earlier
 (defun nnimap-map-port (port)
-  (if (equal port "imaps")
+  (if (and (eq system-type 'windows-nt)
+           (<= (car (x-server-version)) 5)
+           (equal port "imaps"))
       "993"
     port))
 
@@ -804,7 +807,7 @@ textual parts.")
     (insert "\n--" boundary "--\n")))
 
 (defun nnimap-find-wanted-parts (structure)
-  (message-flatten-list (nnimap-find-wanted-parts-1 structure "")))
+  (flatten-tree (nnimap-find-wanted-parts-1 structure "")))
 
 (defun nnimap-find-wanted-parts-1 (structure prefix)
   (let ((num 1)
diff --git a/lisp/gnus/nnir.el b/lisp/gnus/nnir.el
index 62ac504..37a38a5 100644
--- a/lisp/gnus/nnir.el
+++ b/lisp/gnus/nnir.el
@@ -1,6 +1,6 @@
 ;;; nnir.el --- Search mail with various search engines  -*- lexical-binding:t 
-*-
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Kai Großjohann <address@hidden>
 ;; Swish-e and Swish++ backends by:
@@ -1185,7 +1185,7 @@ returning the one at the supplied position."
 
 (defun nnir-imap-end-of-input ()
   "Are we at the end of input?"
-  (skip-chars-forward "[[:blank:]]")
+  (skip-chars-forward "[:blank:]")
   (looking-at "$"))
 
 
diff --git a/lisp/gnus/nnmail.el b/lisp/gnus/nnmail.el
index 13c4303..b6dbbea 100644
--- a/lisp/gnus/nnmail.el
+++ b/lisp/gnus/nnmail.el
@@ -1,6 +1,6 @@
 ;;; nnmail.el --- mail support functions for the Gnus mail backends
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news, mail
@@ -489,7 +489,7 @@ Example:
     (from . "from\\|sender\\|resent-from")
     (nato . "to\\|cc\\|resent-to\\|resent-cc")
     (naany . "from\\|to\\|cc\\|sender\\|resent-from\\|resent-to\\|resent-cc")
-    (list . "list-id\\|list-post\\|x-mailing-list\||x-beenthere\\|x-loop"))
+    (list . "list-id\\|list-post\\|x-mailing-list\\|x-beenthere\\|x-loop"))
   "Alist of abbreviations allowed in `nnmail-split-fancy'."
   :group 'nnmail-split
   :type '(repeat (cons :format "%v" symbol regexp)))
@@ -663,7 +663,7 @@ nn*-request-list should have been called before calling 
this function."
            (narrow-to-region (point) (point-at-eol))
            (setq group (read buffer))
            (unless (stringp group)
-             (setq group (symbol-name group)))
+             (setq group (encode-coding-string (symbol-name group) 'latin-1)))
            (if (and (numberp (setq max (read buffer)))
                     (numberp (setq min (read buffer))))
                (push (list group (cons min max))
@@ -1543,11 +1543,8 @@ See the documentation for the variable 
`nnmail-split-fancy' for details."
                                               (format "%s-active-timestamp"
                                                       backend)))
                              (error 'none))))
-                    (not (consp timestamp))
-                    (equal timestamp '(0 0))
-                    (> (nth 0 file-time) (nth 0 timestamp))
-                    (and (= (nth 0 file-time) (nth 0 timestamp))
-                         (> (nth 1 file-time) (nth 1 timestamp))))))
+                    (eq timestamp 'none)
+                    (time-less-p timestamp file-time))))
        (save-excursion
          (or (eq timestamp 'none)
              (set (intern (format "%s-active-timestamp" backend))
@@ -1885,7 +1882,7 @@ If TIME is nil, then return the cutoff time for oldness 
instead."
             (setq days (days-to-time days))
             ;; Compare the time with the current time.
             (if (null time)
-                (time-subtract nil days)
+                (time-since days)
               (ignore-errors (time-less-p days (time-since time)))))))))
 
 (declare-function gnus-group-mark-article-read "gnus-group" (group article))
diff --git a/lisp/gnus/nnmaildir.el b/lisp/gnus/nnmaildir.el
index afaf3dc..9d02773 100644
--- a/lisp/gnus/nnmaildir.el
+++ b/lisp/gnus/nnmaildir.el
@@ -68,7 +68,9 @@
 (require 'message)
 (require 'nnmail)
 
-(eval-when-compile (require 'cl-lib))
+(eval-when-compile
+  (require 'cl-lib)
+  (require 'subr-x))
 
 (defconst nnmaildir-version "Gnus")
 
@@ -135,11 +137,10 @@ This variable is set by `nnmaildir-request-article'.")
 (defconst nnmaildir--delivery-pid (concat "P" (number-to-string (emacs-pid))))
 (defvar   nnmaildir--delivery-count nil)
 
-;; An obarry containing symbols whose names are server names and whose values
-;; are servers:
-(defvar nnmaildir--servers (make-vector 3 0))
-;; The current server:
-(defvar nnmaildir--cur-server nil)
+(defvar nnmaildir--servers nil
+  "Alist mapping server name strings to servers.")
+(defvar nnmaildir--cur-server nil
+  "The current server.")
 
 ;; A copy of nnmail-extra-headers
 (defvar nnmaildir--extra nil)
@@ -172,17 +173,17 @@ This variable is set by `nnmaildir-request-article'.")
   (nov    nil :type vector)) ;; cached nov structure, or nil
 
 (cl-defstruct nnmaildir--grp
-  (name  nil :type string)  ;; "group.name"
-  (new   nil :type list)    ;; new/ modtime
-  (cur   nil :type list)    ;; cur/ modtime
-  (min   1   :type natnum)  ;; minimum article number
-  (count 0   :type natnum)  ;; count of articles
-  (nlist nil :type list)    ;; list of articles, ordered descending by number
-  (flist nil :type vector)  ;; obarray mapping filename prefix->article
-  (mlist nil :type vector)  ;; obarray mapping message-id->article
-  (cache nil :type vector)  ;; nov cache
-  (index nil :type natnum)  ;; index of next cache entry to replace
-  (mmth  nil :type vector)) ;; obarray mapping mark name->dir modtime
+  (name  nil :type string)     ;; "group.name"
+  (new   nil :type list)       ;; new/ modtime
+  (cur   nil :type list)       ;; cur/ modtime
+  (min   1   :type natnum)     ;; minimum article number
+  (count 0   :type natnum)     ;; count of articles
+  (nlist nil :type list)       ;; list of articles, ordered descending by 
number
+  (flist nil :type hash-table)  ;; hash table mapping filename prefix->article
+  (mlist nil :type hash-table)  ;; hash table mapping message-id->article
+  (cache nil :type vector)     ;; nov cache
+  (index nil :type natnum)     ;; index of next cache entry to replace
+  (mmth  nil :type hash-table))        ;; hash table mapping mark name->dir 
modtime
                                        ; ("Mark Mod Time Hash")
 
 (cl-defstruct nnmaildir--srv
@@ -191,7 +192,7 @@ This variable is set by `nnmaildir-request-article'.")
   (prefix       nil :type string)         ;; "nnmaildir+address:"
   (dir          nil :type string)         ;; "/expanded/path/to/server/dir/"
   (ls           nil :type function)       ;; directory-files function
-  (groups       nil :type vector)         ;; obarray mapping group name->group
+  (groups       nil :type hash-table)     ;; hash table mapping group 
name->group
   (curgrp       nil :type nnmaildir--grp) ;; current group, or nil
   (error        nil :type string)         ;; last error message, or nil
   (mtime        nil :type list)           ;; modtime of dir
@@ -238,17 +239,17 @@ This variable is set by `nnmaildir-request-article'.")
       (setf (nnmaildir--grp-count group) count)
       (setf (nnmaildir--grp-nlist group) new-nlist)
       (setcdr nlist-pre nlist-post)
-      (unintern prefix flist)
-      (unintern msgid mlist))))
+      (remhash prefix flist)
+      (remhash msgid mlist))))
 
 (defun nnmaildir--nlist-art (group num)
   (let ((entry (assq num (nnmaildir--grp-nlist group))))
     (if entry
        (cdr entry))))
 (defmacro nnmaildir--flist-art (list file)
-  `(symbol-value (intern-soft ,file ,list)))
+  `(gethash ,file ,list))
 (defmacro nnmaildir--mlist-art (list msgid)
-  `(symbol-value (intern-soft ,msgid ,list)))
+  `(gethash ,msgid ,list))
 
 (defun nnmaildir--pgname (server gname)
   (let ((prefix (nnmaildir--srv-prefix server)))
@@ -337,12 +338,12 @@ This variable is set by `nnmaildir-request-article'.")
     (if (null server)
        (unless (setq server nnmaildir--cur-server)
          (throw 'return nil))
-      (unless (setq server (intern-soft server nnmaildir--servers))
+      (unless (setq server (alist-get server nnmaildir--servers
+                                     nil nil #'equal))
        (throw 'return nil))
-      (setq server (symbol-value server)
-           nnmaildir--cur-server server))
+      (setq nnmaildir--cur-server server))
     (let ((groups (nnmaildir--srv-groups server)))
-      (when groups
+      (when (and groups (null (hash-table-empty-p groups)))
        (unless (nnmaildir--srv-method server)
          (setf (nnmaildir--srv-method server)
                (or (gnus-server-to-method
@@ -350,7 +351,7 @@ This variable is set by `nnmaildir-request-article'.")
                    (throw 'return nil))))
        (if (null group)
            (nnmaildir--srv-curgrp server)
-         (symbol-value (intern-soft group groups)))))))
+         (gethash group groups))))))
 
 (defun nnmaildir--tab-to-space (string)
   (let ((pos 0))
@@ -574,15 +575,15 @@ This variable is set by `nnmaildir-request-article'.")
        (if insert-nlist
            (setcdr nlist (cons (cons num article) nlist-cdr))
          (setf (nnmaildir--grp-nlist group) nlist))
-       (set (intern (nnmaildir--art-prefix article)
-                    (nnmaildir--grp-flist group))
-            article)
-       (set (intern (nnmaildir--art-msgid article)
-                    (nnmaildir--grp-mlist group))
-            article)
-       (set (intern (nnmaildir--grp-name group)
-                    (nnmaildir--srv-groups server))
-            group))
+       (puthash (nnmaildir--art-prefix article)
+                article
+                (nnmaildir--grp-flist group))
+       (puthash (nnmaildir--art-msgid article)
+                article
+                (nnmaildir--grp-mlist group))
+       (puthash (nnmaildir--grp-name group)
+                group
+                (nnmaildir--srv-groups server)))
       (nnmaildir--cache-nov group article nov)
       t)))
 
@@ -650,9 +651,6 @@ This variable is set by `nnmaildir-request-article'.")
          (if (< (car entry) low) (throw 'iterate-loop nil))
          (funcall func (cdr entry)))))))
 
-(defun nnmaildir--up2-1 (n)
-  (if (zerop n) 1 (1- (ash 1 (1+ (logb n))))))
-
 (defun nnmaildir--system-name ()
   (replace-regexp-in-string
    ":" "\\072"
@@ -677,19 +675,20 @@ This variable is set by `nnmaildir-request-article'.")
        (nnmaildir--srv-groups nnmaildir--cur-server)
        t))
 
-(defun nnmaildir-open-server (server &optional defs)
-  (let ((x server)
-       dir size)
+(defun nnmaildir-open-server (server-string &optional defs)
+  (let ((server (alist-get server-string nnmaildir--servers
+                          nil nil #'equal))
+       dir size x)
     (catch 'return
-      (setq server (intern-soft x nnmaildir--servers))
       (if server
-         (and (setq server (symbol-value server))
-              (nnmaildir--srv-groups server)
+         (and (nnmaildir--srv-groups server)
               (setq nnmaildir--cur-server server)
               (throw 'return t))
-       (setq server (make-nnmaildir--srv :address x))
+       (setq server (make-nnmaildir--srv :address server-string))
        (let ((inhibit-quit t))
-         (set (intern x nnmaildir--servers) server)))
+         (setf (alist-get server-string nnmaildir--servers
+                          nil nil #'equal)
+               server)))
       (setq dir (assq 'directory defs))
       (unless dir
        (setf (nnmaildir--srv-error server)
@@ -713,8 +712,7 @@ This variable is set by `nnmaildir-request-article'.")
                (concat "Not a function: " (prin1-to-string x)))
          (throw 'return nil)))
       (setf (nnmaildir--srv-ls server) x)
-      (setq size (length (funcall x dir nil "\\`[^.]" 'nosort))
-           size (nnmaildir--up2-1 size))
+      (setq size (length (funcall x dir nil "\\`[^.]" 'nosort)))
       (and (setq x (assq 'get-new-mail defs))
           (setq x (cdr x))
           (car x)
@@ -734,7 +732,8 @@ This variable is set by `nnmaildir-request-article'.")
                    x (file-name-as-directory x))
              (setf (nnmaildir--srv-target-prefix server) x))
          (setf (nnmaildir--srv-target-prefix server) "")))
-      (setf (nnmaildir--srv-groups server) (make-vector size 0))
+      (setf (nnmaildir--srv-groups server)
+           (gnus-make-hashtable size))
       (setq nnmaildir--cur-server server)
       t)))
 
@@ -764,7 +763,7 @@ This variable is set by `nnmaildir-request-article'.")
 
 (defun nnmaildir--scan (gname scan-msgs groups _method srv-dir srv-ls)
   (catch 'return
-    (let ((36h-ago (- (float-time) 129600))
+    (let ((36h-ago (time-since 129600))
          absdir nndir tdir ndir cdir nattr cattr isnew pgname read-only ls
          files num dir flist group x)
       (setq absdir (nnmaildir--srvgrp-dir srv-dir gname)
@@ -833,10 +832,10 @@ This variable is set by `nnmaildir-request-article'.")
                       (cons (match-string 1 f) (match-string 2 f)))
                     files)))
       (when isnew
-       (setq num (nnmaildir--up2-1 (length files)))
-       (setf (nnmaildir--grp-flist group) (make-vector num 0))
-       (setf (nnmaildir--grp-mlist group) (make-vector num 0))
-       (setf (nnmaildir--grp-mmth group) (make-vector 1 0))
+       (setq num (length files))
+       (setf (nnmaildir--grp-flist group) (gnus-make-hashtable num))
+       (setf (nnmaildir--grp-mlist group) (gnus-make-hashtable num))
+       (setf (nnmaildir--grp-mmth group) (gnus-make-hashtable 1))
        (setq num (nnmaildir--param pgname 'nov-cache-size))
        (if (numberp num) (if (< num 1) (setq num 1))
          (setq num 16
@@ -862,7 +861,7 @@ This variable is set by `nnmaildir-request-article'.")
                (cl-incf num)))))
        (setf (nnmaildir--grp-cache group) (make-vector num nil))
         (let ((inhibit-quit t))
-          (set (intern gname groups) group))
+          (puthash gname group groups))
        (or scan-msgs (throw 'return t)))
       (setq flist (nnmaildir--grp-flist group)
            files (mapcar
@@ -901,49 +900,46 @@ This variable is set by `nnmaildir-request-article'.")
          groups (nnmaildir--srv-groups nnmaildir--cur-server)
          target-prefix (nnmaildir--srv-target-prefix nnmaildir--cur-server))
     (nnmaildir--with-work-buffer
-      (save-match-data
-       (if (stringp scan-group)
-           (if (nnmaildir--scan scan-group t groups method srv-dir srv-ls)
-               (if (nnmaildir--srv-gnm nnmaildir--cur-server)
-                   (nnmail-get-new-mail 'nnmaildir nil nil scan-group))
-             (unintern scan-group groups))
-         (setq x (file-attribute-modification-time (file-attributes srv-dir))
-               scan-group (null scan-group))
-         (if (equal x (nnmaildir--srv-mtime nnmaildir--cur-server))
-             (if scan-group
-                 (mapatoms (lambda (sym)
-                             (nnmaildir--scan (symbol-name sym) t groups
-                                              method srv-dir srv-ls))
-                           groups))
-           (setq dirs (funcall srv-ls srv-dir nil "\\`[^.]" 'nosort)
-                 dirs (if (zerop (length target-prefix))
-                          dirs
-                        (seq-remove
-                         (lambda (dir)
-                           (and (>= (length dir) (length target-prefix))
-                                (string= (substring dir 0
-                                                    (length target-prefix))
-                                         target-prefix)))
-                         dirs))
-                 seen (nnmaildir--up2-1 (length dirs))
-                 seen (make-vector seen 0))
-           (dolist (grp-dir dirs)
-             (if (nnmaildir--scan grp-dir scan-group groups method srv-dir
-                                  srv-ls)
-                 (intern grp-dir seen)))
-           (setq x nil)
-           (mapatoms (lambda (group)
-                       (setq group (symbol-name group))
-                       (unless (intern-soft group seen)
-                         (setq x (cons group x))))
-                     groups)
-           (dolist (grp x)
-             (unintern grp groups))
-           (setf (nnmaildir--srv-mtime nnmaildir--cur-server)
-                 (file-attribute-modification-time (file-attributes srv-dir))))
-         (and scan-group
-              (nnmaildir--srv-gnm nnmaildir--cur-server)
-              (nnmail-get-new-mail 'nnmaildir nil nil))))))
+     (save-match-data
+       (if (stringp scan-group)
+          (if (nnmaildir--scan scan-group t groups method srv-dir srv-ls)
+              (when (nnmaildir--srv-gnm nnmaildir--cur-server)
+                (nnmail-get-new-mail 'nnmaildir nil nil scan-group))
+            (remhash scan-group groups))
+        (setq x (file-attribute-modification-time (file-attributes srv-dir))
+              scan-group (null scan-group))
+        (if (equal x (nnmaildir--srv-mtime nnmaildir--cur-server))
+            (when scan-group
+              (maphash (lambda (group-name _group)
+                         (nnmaildir--scan group-name t groups
+                                          method srv-dir srv-ls))
+                       groups))
+          (setq dirs (funcall srv-ls srv-dir nil "\\`[^.]" 'nosort)
+                dirs (if (zerop (length target-prefix))
+                         dirs
+                       (seq-remove
+                        (lambda (dir)
+                          (and (>= (length dir) (length target-prefix))
+                               (string= (substring dir 0
+                                                   (length target-prefix))
+                                        target-prefix)))
+                        dirs)))
+          (dolist (grp-dir dirs)
+            (when (nnmaildir--scan grp-dir scan-group groups
+                                   method srv-dir srv-ls)
+              (push grp-dir seen)))
+          (setq x nil)
+          (maphash (lambda (gname _group)
+                     (unless (member gname seen)
+                       (push gname x)))
+                   groups)
+          (dolist (grp x)
+            (remhash grp groups))
+          (setf (nnmaildir--srv-mtime nnmaildir--cur-server)
+                (file-attribute-modification-time (file-attributes srv-dir))))
+        (and scan-group
+             (nnmaildir--srv-gnm nnmaildir--cur-server)
+             (nnmail-get-new-mail 'nnmaildir nil nil))))))
   t)
 
 (defun nnmaildir-request-list (&optional server)
@@ -952,10 +948,9 @@ This variable is set by `nnmaildir-request-article'.")
     (nnmaildir--prepare server nil)
     (nnmaildir--with-nntp-buffer
       (erase-buffer)
-      (mapatoms (lambda (group)
-                 (setq pgname (symbol-name group)
-                       pgname (nnmaildir--pgname nnmaildir--cur-server pgname)
-                       group (symbol-value group)
+      (maphash (lambda (gname group)
+                 (setq pgname (nnmaildir--pgname nnmaildir--cur-server gname)
+
                        ro (nnmaildir--param pgname 'read-only))
                  (insert (replace-regexp-in-string
                           " " "\\ "
@@ -1035,8 +1030,7 @@ This variable is set by `nnmaildir-request-article'.")
                       (append
                        (mapcar 'cdr nnmaildir-flag-mark-mapping)
                        (mapcar 'intern (funcall ls dir nil "\\`[^.]" 
'nosort))))
-           new-mmth (nnmaildir--up2-1 (length all-marks))
-           new-mmth (make-vector new-mmth 0)
+           new-mmth (make-hash-table :size (length all-marks))
            old-mmth (nnmaildir--grp-mmth group))
       (dolist (mark all-marks)
        (setq markdir (nnmaildir--subdir dir (symbol-name mark))
@@ -1063,8 +1057,8 @@ This variable is set by `nnmaildir-request-article'.")
                    curdir-mtime)
                   (t
                    markdir-mtime))))
-         (set (intern (symbol-name mark) new-mmth) mtime)
-         (when (equal mtime (symbol-value (intern-soft (symbol-name mark) 
old-mmth)))
+         (puthash mark mtime new-mmth)
+         (when (equal mtime (gethash mark old-mmth))
            (setq ranges (assq mark old-marks))
            (if ranges (setq ranges (cdr ranges)))
            (throw 'got-ranges nil))
@@ -1126,7 +1120,7 @@ This variable is set by `nnmaildir-request-article'.")
   (nnmaildir--prepare server nil)
   (catch 'return
     (let ((target-prefix (nnmaildir--srv-target-prefix nnmaildir--cur-server))
-         srv-dir dir groups)
+         srv-dir dir)
       (when (zerop (length gname))
        (setf (nnmaildir--srv-error nnmaildir--cur-server)
              "Invalid (empty) group name")
@@ -1140,8 +1134,8 @@ This variable is set by `nnmaildir-request-article'.")
              (concat "Invalid characters (null, tab, or /) in group name: "
                      gname))
        (throw 'return nil))
-      (setq groups (nnmaildir--srv-groups nnmaildir--cur-server))
-      (when (intern-soft gname groups)
+      (when (gethash
+            gname (nnmaildir--srv-groups nnmaildir--cur-server))
        (setf (nnmaildir--srv-error nnmaildir--cur-server)
              (concat "Group already exists: " gname))
        (throw 'return nil))
@@ -1186,7 +1180,7 @@ This variable is set by `nnmaildir-request-article'.")
                      new-name))
        (throw 'return nil))
       (if (string-equal gname new-name) (throw 'return t))
-      (when (intern-soft new-name
+      (when (gethash new-name
                         (nnmaildir--srv-groups nnmaildir--cur-server))
        (setf (nnmaildir--srv-error nnmaildir--cur-server)
              (concat "Group already exists: " new-name))
@@ -1199,16 +1193,18 @@ This variable is set by `nnmaildir-request-article'.")
         (setf (nnmaildir--srv-error nnmaildir--cur-server)
               (concat "Error renaming link: " (prin1-to-string err)))
         (throw 'return nil)))
+      ;; FIXME: Why are we making copies of the group and the groups
+      ;; hashtable?  Why not just set the group's new name, and puthash the
+      ;; group under that new name?
       (setq x (nnmaildir--srv-groups nnmaildir--cur-server)
-           groups (make-vector (length x) 0))
-      (mapatoms (lambda (sym)
-                 (unless (eq (symbol-value sym) group)
-                   (set (intern (symbol-name sym) groups)
-                        (symbol-value sym))))
+           groups (gnus-make-hashtable (hash-table-size x)))
+      (maphash (lambda (gname g)
+                 (unless (eq g group)
+                   (puthash gname g groups)))
                x)
       (setq group (copy-sequence group))
       (setf (nnmaildir--grp-name group) new-name)
-      (set (intern new-name groups) group)
+      (puthash new-name group groups)
       (setf (nnmaildir--srv-groups nnmaildir--cur-server) groups)
       t)))
 
@@ -1231,7 +1227,7 @@ This variable is set by `nnmaildir-request-article'.")
        (throw 'return nil))
       (if (eq group (nnmaildir--srv-curgrp nnmaildir--cur-server))
          (setf (nnmaildir--srv-curgrp nnmaildir--cur-server) nil))
-      (unintern gname (nnmaildir--srv-groups nnmaildir--cur-server))
+      (remhash gname (nnmaildir--srv-groups nnmaildir--cur-server))
       (if (not force)
          (progn
            (setq grp-dir (directory-file-name grp-dir))
@@ -1332,10 +1328,9 @@ This variable is set by `nnmaildir-request-article'.")
              article (nnmaildir--mlist-art list num-msgid))
        (if article (setq num-msgid (nnmaildir--art-num article))
          (catch 'found
-           (mapatoms
-              (lambda (group-sym)
-                (setq group (symbol-value group-sym)
-                      list (nnmaildir--grp-mlist group)
+           (maphash
+              (lambda (_gname group)
+                (setq list (nnmaildir--grp-mlist group)
                       article (nnmaildir--mlist-art list num-msgid))
                 (when article
                   (setq num-msgid (nnmaildir--art-num article))
@@ -1467,7 +1462,7 @@ This variable is set by `nnmaildir-request-article'.")
       (unless (string-equal nnmaildir--delivery-time file)
        (setq nnmaildir--delivery-time file
              nnmaildir--delivery-count 0))
-      (setq file (concat file "M" (number-to-string (caddr time))))
+      (setq file (concat file (format-time-string "M%6N" time)))
       (setq file (concat file nnmaildir--delivery-pid)
            file (concat file "Q" (number-to-string nnmaildir--delivery-count))
            file (concat file "." (nnmaildir--system-name))
@@ -1522,7 +1517,7 @@ This variable is set by `nnmaildir-request-article'.")
       (setq groups (nnmaildir--srv-groups nnmaildir--cur-server)
            ga (car group-art) group-art (cdr group-art)
            gname (car ga))
-      (or (intern-soft gname groups)
+      (or (gethash gname groups)
          (nnmaildir-request-create-group gname)
          (throw 'return nil)) ;; not that nnmail bothers to check :(
       (unless (nnmaildir-request-accept-article gname)
@@ -1539,7 +1534,7 @@ This variable is set by `nnmaildir-request-article'.")
            (mapcar
             (lambda (ga)
               (setq gname (car ga))
-              (and (or (intern-soft gname groups)
+              (and (or (gethash gname groups)
                        (nnmaildir-request-create-group gname))
                    (nnmaildir-request-accept-article gname)
                    ga))
@@ -1553,7 +1548,7 @@ This variable is set by `nnmaildir-request-article'.")
 (defun nnmaildir-request-expire-articles (ranges &optional gname server force)
   (let ((no-force (not force))
        (group (nnmaildir--prepare server gname))
-       pgname time boundary bound-iter high low target dir nlist
+       pgname time boundary high low target dir nlist
        didnt nnmaildir--file nnmaildir-article-file-name
        deactivate-mark)
     (catch 'return
@@ -1577,14 +1572,7 @@ This variable is set by `nnmaildir-request-article'.")
       (when no-force
        (unless (integerp time) ;; handle 'never
          (throw 'return (gnus-uncompress-range ranges)))
-       (setq boundary (current-time)
-             high (- (car boundary) (/ time 65536))
-             low (- (cadr boundary) (% time 65536)))
-       (if (< low 0)
-           (setq low (+ low 65536)
-                 high (1- high)))
-       (setcar (cdr boundary) low)
-       (setcar boundary high))
+       (setq boundary (time-since time)))
       (setq dir (nnmaildir--srv-dir nnmaildir--cur-server)
            dir (nnmaildir--srvgrp-dir dir gname)
            dir (nnmaildir--cur dir)
@@ -1602,15 +1590,8 @@ This variable is set by `nnmaildir-request-article'.")
            ((null time)
             (nnmaildir--expired-article group article))
            ((and no-force
-                 (progn
-                   (setq time (file-attribute-modification-time time)
-                         bound-iter boundary)
-                   (while (and bound-iter time
-                               (= (car bound-iter) (car time)))
-                     (setq bound-iter (cdr bound-iter)
-                           time (cdr time)))
-                   (and bound-iter time
-                        (car-less-than-car bound-iter time))))
+                 (time-less-p boundary
+                              (file-attribute-modification-time time)))
             (setq didnt (cons (nnmaildir--art-num article) didnt)))
            (t
             (setq nnmaildir-article-file-name nnmaildir--file
@@ -1763,36 +1744,38 @@ This variable is set by `nnmaildir-request-article'.")
                  (lambda (dir)
                    (cons dir (funcall ls dir nil "\\`[^.]" 'nosort)))
                  dirs)
-           files (funcall ls msgdir nil "\\`[^.]" 'nosort)
-           flist (nnmaildir--up2-1 (length files))
-           flist (make-vector flist 0))
+           files (funcall ls msgdir nil "\\`[^.]" 'nosort))
       (save-match-data
        (dolist (file files)
          (string-match "\\`\\([^:]*\\)\\(:.*\\)?\\'" file)
-         (intern (match-string 1 file) flist)))
+         (push (match-string 1 file) flist)))
       (dolist (dir dirs)
        (setq files (cdr dir)
              dir (file-name-as-directory (car dir)))
        (dolist (file files)
-         (unless (or (intern-soft file flist) (string= file ":"))
+         (unless (or (member file flist) (string= file ":"))
            (setq file (concat dir file))
            (delete-file file))))
       t)))
 
 (defun nnmaildir-close-server (&optional server)
-  (nnmaildir--prepare server nil)
-  (when nnmaildir--cur-server
+  "Close SERVER, or the current maildir server."
+  (when (nnmaildir--prepare server nil)
     (setq server nnmaildir--cur-server
          nnmaildir--cur-server nil)
-    (unintern (nnmaildir--srv-address server) nnmaildir--servers))
+
+    ;; This slightly obscure invocation of `alist-get' removes SERVER from
+    ;; `nnmaildir-servers'.
+    (setf (alist-get (nnmaildir--srv-address server)
+                    nnmaildir--servers server 'remove #'equal)
+         server))
   t)
 
 (defun nnmaildir-request-close ()
-  (let (servers buffer)
-    (mapatoms (lambda (server)
-               (setq servers (cons (symbol-name server) servers)))
-             nnmaildir--servers)
-    (mapc 'nnmaildir-close-server servers)
+  (let ((servers
+        (mapcar #'car nnmaildir--servers))
+       buffer)
+    (mapc #'nnmaildir-close-server servers)
     (setq buffer (get-buffer " *nnmaildir work*"))
     (if buffer (kill-buffer buffer))
     (setq buffer (get-buffer " *nnmaildir nov*"))
diff --git a/lisp/gnus/nnmairix.el b/lisp/gnus/nnmairix.el
index c8cf2d6..501ea1d 100644
--- a/lisp/gnus/nnmairix.el
+++ b/lisp/gnus/nnmairix.el
@@ -1,6 +1,6 @@
 ;;; nnmairix.el --- Mairix back end for Gnus, the Emacs newsreader
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: David Engster <address@hidden>
 ;; Keywords: mail searching
diff --git a/lisp/gnus/nnmbox.el b/lisp/gnus/nnmbox.el
index 05342da..bba4133 100644
--- a/lisp/gnus/nnmbox.el
+++ b/lisp/gnus/nnmbox.el
@@ -1,6 +1,6 @@
 ;;; nnmbox.el --- mail mbox access for Gnus
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;;     Masanobu UMEDA <address@hidden>
diff --git a/lisp/gnus/nnmh.el b/lisp/gnus/nnmh.el
index d0f8ec2..f4b36dc 100644
--- a/lisp/gnus/nnmh.el
+++ b/lisp/gnus/nnmh.el
@@ -1,6 +1,6 @@
 ;;; nnmh.el --- mhspool access for Gnus
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;;     Masanobu UMEDA <address@hidden>
diff --git a/lisp/gnus/nnml.el b/lisp/gnus/nnml.el
index e7a5b99..205e9e4 100644
--- a/lisp/gnus/nnml.el
+++ b/lisp/gnus/nnml.el
@@ -1,6 +1,6 @@
 ;;; nnml.el --- mail spool access for Gnus
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Authors: Didier Verna <address@hidden> (adding compaction)
 ;;     Simon Josefsson <address@hidden>
@@ -259,7 +259,7 @@ non-nil.")
      (t
       (nnheader-re-read-dir nnml-current-directory)
       (nnmail-activate 'nnml)
-      (let ((active (nth 1 (assoc group nnml-group-alist))))
+      (let ((active (nth 1 (assoc-string group nnml-group-alist))))
        (if (not active)
            (nnheader-report 'nnml "No such group: %s" decoded)
          (nnheader-report 'nnml "Selected group %s" decoded)
@@ -295,7 +295,7 @@ non-nil.")
     (nnheader-report 'nnml "%s is a file"
                     (directory-file-name (nnml-group-pathname group
                                                               nil server))))
-   ((assoc group nnml-group-alist)
+   ((assoc-string group nnml-group-alist)
     t)
    (t
     (let (active)
@@ -379,7 +379,7 @@ non-nil.")
                  (nnml-nov-delete-article group number))
              (push number rest)))
        (push number rest)))
-    (let ((active (nth 1 (assoc group nnml-group-alist))))
+    (let ((active (nth 1 (assoc-string group nnml-group-alist))))
       (when active
        (setcar active (or (and active-articles
                                (apply 'min active-articles))
@@ -520,7 +520,7 @@ non-nil.")
       (nnheader-report 'nnml "No such directory: %s/" file))
     ;; Remove the group from all structures.
     (setq nnml-group-alist
-         (delq (assoc group nnml-group-alist) nnml-group-alist)
+         (delq (assoc-string group nnml-group-alist) nnml-group-alist)
          nnml-current-group nil
          nnml-current-directory nil)
     ;; Save the active file.
@@ -549,7 +549,7 @@ non-nil.")
       (when (<= (length (directory-files old-dir)) 2)
        (ignore-errors (delete-directory old-dir)))
       ;; That went ok, so we change the internal structures.
-      (let ((entry (assoc group nnml-group-alist)))
+      (let ((entry (assoc-string group nnml-group-alist)))
        (when entry
          (setcar entry new-name))
        (setq nnml-current-directory nil
@@ -597,7 +597,7 @@ non-nil.")
     (when (setq path (nnml-article-to-file article))
       (when (file-writable-p path)
        (or (not nnmail-keep-last-article)
-           (not (eq (cdr (nth 1 (assoc group nnml-group-alist)))
+           (not (eq (cdr (nth 1 (assoc-string group nnml-group-alist)))
                     article)))))))
 
 ;; Find an article number in the current group given the Message-ID.
@@ -742,7 +742,7 @@ article number.  This function is called narrowed to an 
article."
   "Compute the next article number in GROUP on SERVER."
   (let* ((encoded (if nnmail-group-names-not-encoded-p
                      (nnml-encoded-group-name group server)))
-        (active (cadr (assoc (or encoded group) nnml-group-alist))))
+        (active (cadr (assoc-string (or encoded group) nnml-group-alist))))
     ;; The group wasn't known to nnml, so we just create an active
     ;; entry for it.
     (unless active
@@ -783,7 +783,7 @@ article number.  This function is called narrowed to an 
article."
            (cdr nnml-incremental-nov-buffer-alist)))))
 
 (defun nnml-open-incremental-nov (group)
-  (or (cdr (assoc group nnml-incremental-nov-buffer-alist))
+  (or (cdr (assoc-string group nnml-incremental-nov-buffer-alist))
       (let ((buffer (nnml-get-nov-buffer group t)))
        (push (cons group buffer) nnml-incremental-nov-buffer-alist)
        buffer)))
diff --git a/lisp/gnus/nnoo.el b/lisp/gnus/nnoo.el
index 1e69af6..0cf2362 100644
--- a/lisp/gnus/nnoo.el
+++ b/lisp/gnus/nnoo.el
@@ -1,6 +1,6 @@
 ;;; nnoo.el --- OO Gnus Backends
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
diff --git a/lisp/gnus/nnregistry.el b/lisp/gnus/nnregistry.el
index bb00caa..4bc74ce 100644
--- a/lisp/gnus/nnregistry.el
+++ b/lisp/gnus/nnregistry.el
@@ -1,7 +1,7 @@
 ;;; nnregistry.el --- access to articles via Gnus' message-id registry
 ;;; -*- coding: utf-8 -*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Authors: Ludovic Courtès <address@hidden>
 ;; Keywords: news, mail
diff --git a/lisp/gnus/nnrss.el b/lisp/gnus/nnrss.el
index f80e2c5..0bfecb2 100644
--- a/lisp/gnus/nnrss.el
+++ b/lisp/gnus/nnrss.el
@@ -1,6 +1,6 @@
 ;;; nnrss.el --- interfacing with RSS
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Shenghuo Zhu <address@hidden>
 ;; Keywords: RSS
@@ -340,10 +340,10 @@ for decoding when the cdr that the data specify is not 
available.")
   (let (elem)
     ;; There may be two or more entries in `nnrss-group-alist' since
     ;; this function didn't delete them formerly.
-    (while (setq elem (assoc group nnrss-group-alist))
+    (while (setq elem (assoc-string group nnrss-group-alist))
       (setq nnrss-group-alist (delq elem nnrss-group-alist))))
   (setq nnrss-server-data
-       (delq (assoc group nnrss-server-data) nnrss-server-data))
+       (delq (assoc-string group nnrss-server-data) nnrss-server-data))
   (nnrss-save-server-data server)
   (ignore-errors
     (let ((file-name-coding-system nnmail-pathname-coding-system))
@@ -367,7 +367,7 @@ for decoding when the cdr that the data specify is not 
available.")
   (with-current-buffer nntp-server-buffer
     (erase-buffer)
     (dolist (group groups)
-      (let ((elem (assoc (gnus-group-decoded-name group) nnrss-server-data)))
+      (let ((elem (assoc-string (gnus-group-decoded-name group) 
nnrss-server-data)))
        (insert (format "%S %s 1 y\n" group (or (cadr elem) 0)))))
     'active))
 
@@ -446,16 +446,16 @@ nnrss: %s: Not valid XML %s and libxml-parse-html-region 
doesn't work %s"
 (autoload 'timezone-parse-date "timezone")
 
 (defun nnrss-normalize-date (date)
-  "Return a date string of DATE in the RFC822 style.
+  "Return a date string of DATE in the style of RFC 822 and its successors.
 This function handles the ISO 8601 date format described in
-URL `http://www.w3.org/TR/NOTE-datetime', and also the RFC822 style
+URL `http://www.w3.org/TR/NOTE-datetime', and also the RFC 822 style
 which RSS 2.0 allows."
   (let (case-fold-search vector year month day time zone cts given)
     (cond ((null date))                        ; do nothing for this case
          ;; if the date is just digits (unix time stamp):
          ((string-match "^[0-9]+$" date)
-          (setq given (seconds-to-time (string-to-number date))))
-         ;; RFC822
+          (setq given (encode-time (string-to-number date))))
+         ;; RFC 822
          ((string-match " [0-9]+ " date)
           (setq vector (timezone-parse-date date)
                 year (string-to-number (aref vector 0)))
@@ -539,7 +539,7 @@ which RSS 2.0 allows."
   (if (hash-table-p nnrss-group-hashtb)
       (clrhash nnrss-group-hashtb)
     (setq nnrss-group-hashtb (make-hash-table :test 'equal)))
-  (let ((pair (assoc group nnrss-server-data)))
+  (let ((pair (assoc-string group nnrss-server-data)))
     (setq nnrss-group-max (or (cadr pair) 0))
     (setq nnrss-group-min (+ nnrss-group-max 1)))
   (let ((file (nnrss-make-filename group server))
@@ -644,8 +644,8 @@ which RSS 2.0 allows."
                                         (concat group ".xml"))
                                        nnrss-directory))))
        (setq xml (nnrss-fetch file t))
-      (setq url (or (nth 2 (assoc group nnrss-server-data))
-                   (cadr (assoc group nnrss-group-alist))))
+      (setq url (or (nth 2 (assoc-string group nnrss-server-data))
+                   (cadr (assoc-string group nnrss-group-alist))))
       (unless url
        (setq url
              (cdr
@@ -653,7 +653,7 @@ which RSS 2.0 allows."
                      (nnrss-discover-feed
                       (read-string
                        (format "URL to search for %s: " group) "http://";)))))
-       (let ((pair (assoc group nnrss-server-data)))
+       (let ((pair (assoc-string group nnrss-server-data)))
          (if pair
              (setcdr (cdr pair) (list url))
            (push (list group nnrss-group-max url) nnrss-server-data)))
@@ -721,7 +721,7 @@ which RSS 2.0 allows."
       (setq extra nil))
     (when changed
       (nnrss-save-group-data group server)
-      (let ((pair (assoc group nnrss-server-data)))
+      (let ((pair (assoc-string group nnrss-server-data)))
        (if pair
            (setcar (cdr pair) nnrss-group-max)
          (push (list group nnrss-group-max) nnrss-server-data)))
@@ -792,7 +792,7 @@ It is useful when `(setq nnrss-use-local t)'."
   (insert "RSSDIR='" (expand-file-name nnrss-directory) "'\n")
   (dolist (elem nnrss-server-data)
     (let ((url (or (nth 2 elem)
-                  (cadr (assoc (car elem) nnrss-group-alist)))))
+                  (cadr (assoc-string (car elem) nnrss-group-alist)))))
       (insert "$WGET -q -O \"$RSSDIR\"/'"
              (nnrss-translate-file-chars (concat (car elem) ".xml"))
              "' '" url "'\n"))))
diff --git a/lisp/gnus/nnspool.el b/lisp/gnus/nnspool.el
index 2f16b65..767631c 100644
--- a/lisp/gnus/nnspool.el
+++ b/lisp/gnus/nnspool.el
@@ -1,6 +1,6 @@
 ;;; nnspool.el --- spool access for GNU Emacs
 
-;; Copyright (C) 1988-1990, 1993-1998, 2000-2018 Free Software
+;; Copyright (C) 1988-1990, 1993-1998, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Masanobu UMEDA <address@hidden>
@@ -305,25 +305,18 @@ there.")
        (while (and (not (looking-at
                          "\\([^ ]+\\) +\\([0-9]+\\)[0-9][0-9][0-9] "))
                    (zerop (forward-line -1))))
-       ;; We require nnheader which requires gnus-util.
-       (let ((seconds (float-time (date-to-time date)))
+       (let ((seconds (encode-time (date-to-time date) 'integer))
              groups)
          ;; Go through lines and add the latest groups to a list.
          (while (and (looking-at "\\([^ ]+\\) +[0-9]+ ")
                      (progn
-                       ;; We insert a .0 to make the list reader
-                       ;; interpret the number as a float.  It is far
-                       ;; too big to be stored in a lisp integer.
-                       (goto-char (1- (match-end 0)))
-                       (insert ".0")
-                       (> (progn
-                            (goto-char (match-end 1))
-                            (read (current-buffer)))
-                          seconds))
-                     (push (buffer-substring
-                            (match-beginning 1) (match-end 1))
-                           groups)
-                     (zerop (forward-line -1))))
+                       (goto-char (match-end 1))
+                       (< seconds (read (current-buffer))))
+                     (progn
+                       (push (buffer-substring
+                              (match-beginning 1) (match-end 1))
+                             groups)
+                       (zerop (forward-line -1)))))
          (erase-buffer)
          (dolist (group groups)
            (insert group " 0 0 y\n")))
diff --git a/lisp/gnus/nntp.el b/lisp/gnus/nntp.el
index be9e495..e2fa1d8 100644
--- a/lisp/gnus/nntp.el
+++ b/lisp/gnus/nntp.el
@@ -1,6 +1,6 @@
 ;;; nntp.el --- nntp access for Gnus
 
-;; Copyright (C) 1987-1990, 1992-1998, 2000-2018 Free Software
+;; Copyright (C) 1987-1990, 1992-1998, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
diff --git a/lisp/gnus/nnvirtual.el b/lisp/gnus/nnvirtual.el
index 777c5c1..c80bbf6 100644
--- a/lisp/gnus/nnvirtual.el
+++ b/lisp/gnus/nnvirtual.el
@@ -1,6 +1,6 @@
 ;;; nnvirtual.el --- virtual newsgroups access for Gnus
 
-;; Copyright (C) 1994-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-2019 Free Software Foundation, Inc.
 
 ;; Author: David Moore <address@hidden>
 ;;     Lars Magne Ingebrigtsen <address@hidden>
@@ -234,14 +234,12 @@ component group will show up when you enter the virtual 
group.")
          nnvirtual-mapping-marks nil
          nnvirtual-info-installed nil)
     (when nnvirtual-component-regexp
-      ;; Go through the newsrc alist and find all component groups.
-      (let ((newsrc (cdr gnus-newsrc-alist))
-           group)
-       (while (setq group (car (pop newsrc)))
-         (when (string-match nnvirtual-component-regexp group) ; Match
-           ;; Add this group to the list of component groups.
-           (setq nnvirtual-component-groups
-                 (cons group (delete group nnvirtual-component-groups)))))))
+      ;; Go through the list of groups and find all component groups.
+      (dolist (group (cdr gnus-group-list))
+       (when (string-match nnvirtual-component-regexp group) ; Match
+         ;; Add this group to the list of component groups.
+         (setq nnvirtual-component-groups
+               (cons group (delete group nnvirtual-component-groups))))))
     (if (not nnvirtual-component-groups)
        (nnheader-report 'nnvirtual "No component groups: %s" server)
       t)))
@@ -372,7 +370,7 @@ component group will show up when you enter the virtual 
group.")
 (defun nnvirtual-convert-headers ()
   "Convert HEAD headers into NOV headers."
   (with-current-buffer nntp-server-buffer
-    (let* ((dependencies (make-vector 100 0))
+    (let* ((dependencies (make-hash-table :test #'equal))
           (headers (gnus-get-newsgroup-headers dependencies)))
       (erase-buffer)
       (mapc 'nnheader-insert-nov headers))))
diff --git a/lisp/gnus/nnweb.el b/lisp/gnus/nnweb.el
index a64f10f..7b87502 100644
--- a/lisp/gnus/nnweb.el
+++ b/lisp/gnus/nnweb.el
@@ -1,6 +1,6 @@
 ;;; nnweb.el --- retrieving articles via web search engines
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
@@ -109,7 +109,7 @@ Valid types include `google', `dejanews', and `gmane'.")
 (deffoo nnweb-request-scan (&optional group server)
   (nnweb-possibly-change-server group server)
   (if nnweb-ephemeral-p
-      (setq nnweb-hashtb (gnus-make-hashtable 4095))
+      (setq nnweb-hashtb (gnus-make-hashtable 4000))
     (unless nnweb-articles
       (nnweb-read-overview group)))
   (funcall (nnweb-definition 'map))
@@ -229,11 +229,11 @@ Valid types include `google', `dejanews', and `gmane'.")
        (nnheader-insert-nov (cadr (pop articles)))))))
 
 (defun nnweb-set-hashtb (header data)
-  (gnus-sethash (nnweb-identifier (mail-header-xref header))
+  (puthash (nnweb-identifier (mail-header-xref header))
                data nnweb-hashtb))
 
 (defun nnweb-get-hashtb (url)
-  (gnus-gethash (nnweb-identifier url) nnweb-hashtb))
+  (gethash (nnweb-identifier url) nnweb-hashtb))
 
 (defun nnweb-identifier (ident)
   (funcall (nnweb-definition 'identifier) ident))
@@ -268,7 +268,7 @@ Valid types include `google', `dejanews', and `gmane'.")
   (unless nnweb-group-alist
     (nnweb-read-active))
   (unless nnweb-hashtb
-    (setq nnweb-hashtb (gnus-make-hashtable 4095)))
+    (setq nnweb-hashtb (make-hash-table :size 4000 :test #'equal)))
   (when group
     (setq nnweb-group group)))
 
diff --git a/lisp/gnus/score-mode.el b/lisp/gnus/score-mode.el
index 9bceb4e..8ba1eae 100644
--- a/lisp/gnus/score-mode.el
+++ b/lisp/gnus/score-mode.el
@@ -1,6 +1,6 @@
 ;;; score-mode.el --- mode for editing Gnus score files
 
-;; Copyright (C) 1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news, mail
diff --git a/lisp/gnus/smiley.el b/lisp/gnus/smiley.el
index 226a4ce..fb1e8de 100644
--- a/lisp/gnus/smiley.el
+++ b/lisp/gnus/smiley.el
@@ -1,6 +1,6 @@
 ;;; smiley.el --- displaying smiley faces
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Love <address@hidden>
 ;; Keywords: news mail multimedia
diff --git a/lisp/gnus/smime.el b/lisp/gnus/smime.el
index ab2a5b0..9a38a6c 100644
--- a/lisp/gnus/smime.el
+++ b/lisp/gnus/smime.el
@@ -1,6 +1,6 @@
 ;;; smime.el --- S/MIME support library  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <address@hidden>
 ;; Keywords: SMIME X.509 PEM OpenSSL
diff --git a/lisp/gnus/spam-report.el b/lisp/gnus/spam-report.el
index e43c01b..f611a21 100644
--- a/lisp/gnus/spam-report.el
+++ b/lisp/gnus/spam-report.el
@@ -1,6 +1,6 @@
 ;;; spam-report.el --- Reporting spam
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Ted Zlatanov <address@hidden>
 ;; Keywords: network, spam, mail, gmane, report
diff --git a/lisp/gnus/spam-stat.el b/lisp/gnus/spam-stat.el
index 3625132..6cf43df 100644
--- a/lisp/gnus/spam-stat.el
+++ b/lisp/gnus/spam-stat.el
@@ -1,6 +1,6 @@
 ;;; spam-stat.el --- detecting spam based on statistics
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Alex Schroeder <address@hidden>
 ;; Keywords: network
diff --git a/lisp/gnus/spam-wash.el b/lisp/gnus/spam-wash.el
index 272d3d7..4d7975f 100644
--- a/lisp/gnus/spam-wash.el
+++ b/lisp/gnus/spam-wash.el
@@ -1,6 +1,6 @@
 ;;; spam-wash.el --- wash spam before analysis
 
-;; Copyright (C) 2004, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Andrew Cohen <address@hidden>
 ;; Keywords: mail
diff --git a/lisp/gnus/spam.el b/lisp/gnus/spam.el
index e4731f3..4d31d0a 100644
--- a/lisp/gnus/spam.el
+++ b/lisp/gnus/spam.el
@@ -1,6 +1,6 @@
 ;;; spam.el --- Identifying spam
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Maintainer: Ted Zlatanov <address@hidden>
diff --git a/lisp/help-at-pt.el b/lisp/help-at-pt.el
index fcc4b86..dc73ba5 100644
--- a/lisp/help-at-pt.el
+++ b/lisp/help-at-pt.el
@@ -1,6 +1,6 @@
 ;;; help-at-pt.el --- local help through the keyboard
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author: Luc Teirlinck <address@hidden>
 ;; Keywords: help
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 7979ef3..50d69e7 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -1,6 +1,6 @@
 ;;; help-fns.el --- Complex help functions -*- lexical-binding: t -*-
 
-;; Copyright (C) 1985-1986, 1993-1994, 1998-2018 Free Software
+;; Copyright (C) 1985-1986, 1993-1994, 1998-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
@@ -40,7 +40,21 @@
   "List of functions to run in help buffer in `describe-function'.
 Those functions will be run after the header line and argument
 list was inserted, and before the documentation will be inserted.
-The functions will receive the function name as argument.")
+The functions will receive the function name as argument.
+They can assume that a newline was output just before they were called,
+and they should terminate any of their own output with a newline.
+By convention they should indent their output by 2 spaces.")
+
+(defvar help-fns-describe-variable-functions nil
+  "List of functions to run in help buffer in `describe-variable'.
+Those functions will be run after the header line and value was inserted,
+and before the documentation will be inserted.
+The functions will receive the variable name as argument.
+They can assume that a newline was output just before they were called,
+and they should terminate any of their own output with a newline.
+By convention they should indent their output by 2 spaces.
+Current buffer is the buffer in which we queried the variable,
+and the output should go to `standard-output'.")
 
 ;; Functions
 
@@ -68,12 +82,15 @@ The functions will receive the function name as argument.")
 
 (defun help--loaded-p (file)
   "Try and figure out if FILE has already been loaded."
+  ;; FIXME: this regexp business is not good enough: for file
+  ;; `toto', it will say `toto' is loaded when in reality it was
+  ;; just cedet/semantic/toto that has been loaded.
   (or (let ((feature (intern-soft file)))
         (and feature (featurep feature)))
       (let* ((re (load-history-regexp file))
              (done nil))
         (dolist (x load-history)
-          (and (car x) (string-match-p re (car x)) (setq done t)))
+          (and (stringp (car x)) (string-match-p re (car x)) (setq done t)))
         done)))
 
 (defun help--load-prefixes (prefixes)
@@ -83,11 +100,9 @@ The functions will receive the function name as argument.")
     (dolist (file files)
       ;; FIXME: Should we scan help-definition-prefixes to remove
       ;; other prefixes of the same file?
-      ;; FIXME: this regexp business is not good enough: for file
-      ;; `toto', it will say `toto' is loaded when in reality it was
-      ;; just cedet/semantic/toto that has been loaded.
       (unless (help--loaded-p file)
-        (load file 'noerror 'nomessage)))))
+        (with-demoted-errors "while loading: %S"
+          (load file 'noerror 'nomessage))))))
 
 (defun help--symbol-completion-table (string pred action)
   (let ((prefixes (radix-tree-prefixes (help-definition-prefixes) string)))
@@ -411,7 +426,7 @@ suitable file is found, return nil."
 (defun help-fns--compiler-macro (function)
   (let ((handler (function-get function 'compiler-macro)))
     (when handler
-      (insert "\nThis function has a compiler macro")
+      (insert "  This function has a compiler macro")
       (if (symbolp handler)
           (progn
             (insert (format-message " `%s'" handler))
@@ -485,7 +500,7 @@ suitable file is found, return nil."
                           (get function
                                'derived-mode-parent))))
     (when parent-mode
-      (insert (substitute-command-keys "\nParent mode: `"))
+      (insert (substitute-command-keys "  Parent mode: `"))
       (let ((beg (point)))
         (insert (format "%s" parent-mode))
         (make-text-button beg (point)
@@ -499,15 +514,15 @@ suitable file is found, return nil."
                        (get function 'byte-obsolete-info)))
          (use (car obsolete)))
     (when obsolete
-      (insert "\nThis "
+      (insert "  This "
              (if (eq (car-safe (symbol-function function)) 'macro)
                  "macro"
                "function")
              " is obsolete")
       (when (nth 2 obsolete)
         (insert (format " since %s" (nth 2 obsolete))))
-      (insert (cond ((stringp use) (concat ";\n" use))
-                    (use (format-message ";\nuse `%s' instead." use))
+      (insert (cond ((stringp use) (concat ";\n  " use))
+                    (use (format-message ";\n  use `%s' instead." use))
                     (t "."))
               "\n"))))
 
@@ -520,7 +535,7 @@ FILE is the file where FUNCTION was probably defined."
         (target (cons t function))
         found)
     (while (and load-hist (not found))
-      (and (caar load-hist)
+      (and (stringp (caar load-hist))
           (equal (file-name-sans-extension (caar load-hist)) file)
           (setq found (member target (cdar load-hist))))
       (setq load-hist (cdr load-hist)))
@@ -537,17 +552,65 @@ FILE is the file where FUNCTION was probably defined."
                        (memq function
                              byte-compile-interactive-only-functions)))))
          (when interactive-only
-           (insert "\nThis function is for interactive use only"
+           (insert "  This function is for interactive use only"
                    ;; Cf byte-compile-form.
                    (cond ((stringp interactive-only)
-                          (format ";\nin Lisp code %s" interactive-only))
+                          (format ";\n  in Lisp code %s" interactive-only))
                          ((and (symbolp 'interactive-only)
                                (not (eq interactive-only t)))
-                          (format-message ";\nin Lisp code use `%s' instead."
+                          (format-message ";\n  in Lisp code use `%s' instead."
                                           interactive-only))
                          (t "."))
                    "\n")))))
 
+(add-hook 'help-fns-describe-function-functions #'help-fns--side-effects)
+(defun help-fns--side-effects (function)
+  (when (and (symbolp function)
+             (or (function-get function 'pure)
+                 (function-get function 'side-effect-free)))
+    (insert "  This function does not change global state, "
+            "including the match data.\n")))
+
+(defun help-fns--first-release (symbol)
+  "Return the likely first release that defined SYMBOL."
+  ;; Code below relies on the etc/NEWS* files.
+  ;; FIXME: Maybe we should also use the */ChangeLog* files when available.
+  ;; FIXME: Maybe we should also look for announcements of the addition
+  ;; of the *packages* in which the function is defined.
+  (let* ((name (symbol-name symbol))
+         (re (concat "\\_<" (regexp-quote name) "\\_>"))
+         (news (directory-files data-directory t "\\`NEWS.[1-9]"))
+         (first nil))
+    (with-temp-buffer
+      (dolist (f news)
+        (erase-buffer)
+        (insert-file-contents f)
+        (goto-char (point-min))
+        (search-forward "\n*")
+        (while (re-search-forward re nil t)
+          (save-excursion
+            ;; Almost all entries are of the form "* ... in Emacs NN.MM."
+            ;; but there are also a few in the form "* Emacs NN.MM is a bug
+            ;; fix release ...".
+            (if (not (re-search-backward "^\\*.* Emacs \\([0-9.]+[0-9]\\)"
+                                         nil t))
+                (message "Ref found in non-versioned section in %S"
+                         (file-name-nondirectory f))
+              (let ((version (match-string 1)))
+                (when (or (null first) (version< version first))
+                  (setq first version))))))))
+    first))
+
+(add-hook 'help-fns-describe-function-functions
+          #'help-fns--mention-first-release)
+(add-hook 'help-fns-describe-variable-functions
+          #'help-fns--mention-first-release)
+(defun help-fns--mention-first-release (object)
+  (let ((first (if (symbolp object) (help-fns--first-release object))))
+    (when first
+      (princ (format "  Probably introduced at or before Emacs version %s.\n"
+                     first)))))
+
 (defun help-fns-short-filename (filename)
   (let* ((abbrev (abbreviate-file-name filename))
          (short abbrev))
@@ -610,9 +673,9 @@ Returns a list of the form (REAL-FUNCTION DEF ALIASED 
REAL-DEF)."
                                  (memq (car-safe def) '(macro lambda closure)))
                              (stringp file-name)
                              (help-fns--autoloaded-p function file-name))
-                        (if (commandp def)
-                            "an interactive autoloaded "
-                          "an autoloaded ")
+                        (concat
+                         "an autoloaded " (if (commandp def)
+                                              "interactive "))
                       (if (commandp def) "an interactive " "a "))))
 
     ;; Print what kind of function-like object FUNCTION is.
@@ -626,14 +689,16 @@ Returns a list of the form (REAL-FUNCTION DEF ALIASED 
REAL-DEF)."
                 (aliased
                  (format-message "an alias for `%s'" real-def))
                 ((subrp def)
-                 (if (eq 'unevalled (cdr (subr-arity def)))
-                     (concat beg "special form")
-                   (concat beg "built-in function")))
+                 (concat beg (if (eq 'unevalled (cdr (subr-arity def)))
+                                 "special form"
+                                "built-in function")))
                 ((autoloadp def)
-                 (format "%s autoloaded %s"
-                         (if (commandp def) "an interactive" "an")
-                         (if (eq (nth 4 def) 'keymap) "keymap"
-                           (if (nth 4 def) "Lisp macro" "Lisp function"))))
+                 (format "an autoloaded %s"
+                          (cond
+                          ((commandp def) "interactive Lisp function")
+                          ((eq (nth 4 def) 'keymap) "keymap")
+                          ((nth 4 def) "Lisp macro")
+                           (t "Lisp function"))))
                 ((or (eq (car-safe def) 'macro)
                      ;; For advised macros, def is a lambda
                      ;; expression or a byte-code-function-p, so we
@@ -684,6 +749,10 @@ Returns a list of the form (REAL-FUNCTION DEF ALIASED 
REAL-DEF)."
            (help-xref-button 1 'help-function-def function file-name))))
       (princ "."))))
 
+(defun help-fns--ensure-empty-line ()
+  (unless (eolp) (insert "\n"))
+  (unless (eq ?\n (char-before (1- (point)))) (insert "\n")))
+
 ;;;###autoload
 (defun describe-function-1 (function)
   (let ((pt1 (with-current-buffer (help-buffer) (point))))
@@ -721,12 +790,10 @@ Returns a list of the form (REAL-FUNCTION DEF ALIASED 
REAL-DEF)."
                       real-function key-bindings-buffer)
                    ;; E.g. an alias for a not yet defined function.
                    ((invalid-function void-function) doc-raw))))
+        (help-fns--ensure-empty-line)
         (run-hook-with-args 'help-fns-describe-function-functions function)
-        (insert "\n" (or doc "Not documented.")))
-      (when (or (function-get function 'pure)
-                (function-get function 'side-effect-free))
-        (insert "\nThis function does not change global state, "
-                "including the match data."))
+        (help-fns--ensure-empty-line)
+        (insert (or doc "Not documented.")))
       ;; Avoid asking the user annoying questions if she decides
       ;; to save the help buffer, when her locale's codeset
       ;; isn't UTF-8.
@@ -829,7 +896,6 @@ it is displayed along with the global value."
        (message "You did not specify a variable")
       (save-excursion
        (let ((valvoid (not (with-current-buffer buffer (boundp variable))))
-             (permanent-local (get variable 'permanent-local))
              val val-start-pos locus)
          ;; Extract the value before setting up the output buffer,
          ;; in case `buffer' *is* the output buffer.
@@ -845,26 +911,26 @@ it is displayed along with the global value."
              (prin1 variable)
              (setq file-name (find-lisp-object-file-name variable 'defvar))
 
-             (if file-name
-                 (progn
-                   (princ (format-message
-                            " is a variable defined in `%s'.\n"
-                            (if (eq file-name 'C-source)
-                                "C source code"
-                              (file-name-nondirectory file-name))))
-                   (with-current-buffer standard-output
-                     (save-excursion
-                       (re-search-backward (substitute-command-keys
-                                             "`\\([^`']+\\)'")
-                                            nil t)
-                       (help-xref-button 1 'help-variable-def
-                                         variable file-name)))
-                   (if valvoid
-                       (princ "It is void as a variable.")
-                     (princ "Its ")))
-               (if valvoid
-                   (princ " is void as a variable.")
-                 (princ (substitute-command-keys "'s ")))))
+             (princ (if file-name
+                        (progn
+                          (princ (format-message
+                                   " is a variable defined in `%s'.\n"
+                                   (if (eq file-name 'C-source)
+                                       "C source code"
+                                     (file-name-nondirectory file-name))))
+                          (with-current-buffer standard-output
+                            (save-excursion
+                              (re-search-backward (substitute-command-keys
+                                                    "`\\([^`']+\\)'")
+                                                   nil t)
+                              (help-xref-button 1 'help-variable-def
+                                                variable file-name)))
+                          (if valvoid
+                              "It is void as a variable."
+                             "Its "))
+                       (if valvoid
+                          " is void as a variable."
+                         (substitute-command-keys "'s ")))))
            (unless valvoid
              (with-current-buffer standard-output
                (setq val-start-pos (point))
@@ -893,7 +959,7 @@ it is displayed along with the global value."
                  (let* ((sv (get variable 'standard-value))
                         (origval (and (consp sv)
                                       (condition-case nil
-                                          (eval (car sv))
+                                          (eval (car sv) t)
                                         (error :help-eval-error))))
                          from)
                    (when (and (consp sv)
@@ -968,132 +1034,17 @@ it is displayed along with the global value."
             (let* ((alias (condition-case nil
                               (indirect-variable variable)
                             (error variable)))
-                   (obsolete (get variable 'byte-obsolete-variable))
-                   (watchpoints (get-variable-watchers variable))
-                  (use (car obsolete))
-                  (safe-var (get variable 'safe-local-variable))
                    (doc (or (documentation-property
                              variable 'variable-documentation)
                             (documentation-property
-                             alias 'variable-documentation)))
-                   (extra-line nil))
+                             alias 'variable-documentation))))
 
-             ;; Mention if it's a local variable.
-             (cond
-              ((and (local-variable-if-set-p variable)
-                    (or (not (local-variable-p variable))
-                        (with-temp-buffer
-                          (local-variable-if-set-p variable))))
-                (setq extra-line t)
-                (princ "  Automatically becomes ")
-               (if permanent-local
-                   (princ "permanently "))
-               (princ "buffer-local when set.\n"))
-              ((not permanent-local))
-              ((bufferp locus)
-               (setq extra-line t)
-               (princ
-                (substitute-command-keys
-                 "  This variable's buffer-local value is permanent.\n")))
-              (t
-               (setq extra-line t)
-                (princ (substitute-command-keys
-                       "  This variable's value is permanent \
-if it is given a local binding.\n"))))
-
-             ;; Mention if it's an alias.
-              (unless (eq alias variable)
-                (setq extra-line t)
-                (princ (format-message
-                        "  This variable is an alias for `%s'.\n"
-                        alias)))
-
-              (when obsolete
-                (setq extra-line t)
-                (princ "  This variable is obsolete")
-                (if (nth 2 obsolete)
-                    (princ (format " since %s" (nth 2 obsolete))))
-               (princ (cond ((stringp use) (concat ";\n  " use))
-                            (use (format-message ";\n  use `%s' instead."
-                                                  (car obsolete)))
-                            (t ".")))
-                (terpri))
-
-              (when watchpoints
-                (setq extra-line t)
-                (princ "  Calls these functions when changed: ")
-                (princ watchpoints)
-                (terpri))
-
-             (when (member (cons variable val)
-                            (with-current-buffer buffer
-                              file-local-variables-alist))
-               (setq extra-line t)
-               (if (member (cons variable val)
-                             (with-current-buffer buffer
-                               dir-local-variables-alist))
-                   (let ((file (and (buffer-file-name buffer)
-                                      (not (file-remote-p
-                                            (buffer-file-name buffer)))
-                                      (dir-locals-find-file
-                                       (buffer-file-name buffer))))
-                          (is-directory nil))
-                     (princ (substitute-command-keys
-                             "  This variable's value is directory-local"))
-                      (when (consp file) ; result from cache
-                        ;; If the cache element has an mtime, we
-                        ;; assume it came from a file.
-                        (if (nth 2 file)
-                            ;; (car file) is a directory.
-                            (setq file (dir-locals--all-files (car file)))
-                          ;; Otherwise, assume it was set directly.
-                          (setq file (car file)
-                                is-directory t)))
-                      (if (null file)
-                          (princ ".\n")
-                        (princ ", set ")
-                        (princ (substitute-command-keys
-                                (cond
-                                 (is-directory "for the directory\n  `")
-                                 ;; Many files matched.
-                                 ((and (consp file) (cdr file))
-                                  (setq file (file-name-directory (car file)))
-                                  (format "by one of the\n  %s files in the 
directory\n  `"
-                                          dir-locals-file))
-                                 (t (setq file (car file))
-                                    "by the file\n  `"))))
-                       (with-current-buffer standard-output
-                         (insert-text-button
-                          file 'type 'help-dir-local-var-def
-                             'help-args (list variable file)))
-                       (princ (substitute-command-keys "'.\n"))))
-                 (princ (substitute-command-keys
-                         "  This variable's value is file-local.\n"))))
-
-             (when (memq variable ignored-local-variables)
-               (setq extra-line t)
-               (princ "  This variable is ignored as a file-local \
-variable.\n"))
-
-             ;; Can be both risky and safe, eg auto-fill-function.
-             (when (risky-local-variable-p variable)
-               (setq extra-line t)
-               (princ "  This variable may be risky if used as a \
-file-local variable.\n")
-               (when (assq variable safe-local-variable-values)
-                 (princ (substitute-command-keys
-                          "  However, you have added it to \
-`safe-local-variable-values'.\n"))))
-
-             (when safe-var
-                (setq extra-line t)
-               (princ "  This variable is safe as a file local variable ")
-               (princ "if its value\n  satisfies the predicate ")
-               (princ (if (byte-code-function-p safe-var)
-                          "which is a byte-compiled expression.\n"
-                        (format-message "`%s'.\n" safe-var))))
-
-              (if extra-line (terpri))
+              (with-current-buffer buffer
+                (run-hook-with-args 'help-fns-describe-variable-functions
+                                    variable))
+
+              (with-current-buffer standard-output
+                (help-fns--ensure-empty-line))
              (princ "Documentation:\n")
              (with-current-buffer standard-output
                (insert (or doc "Not documented as a variable."))))
@@ -1120,6 +1071,134 @@ file-local variable.\n")
              ;; Return the text we displayed.
              (buffer-string))))))))
 
+(add-hook 'help-fns-describe-variable-functions #'help-fns--var-safe-local)
+(defun help-fns--var-safe-local (variable)
+  (let ((safe-var (get variable 'safe-local-variable)))
+    (when safe-var
+      (princ "  This variable is safe as a file local variable ")
+      (princ "if its value\n  satisfies the predicate ")
+      (princ (if (byte-code-function-p safe-var)
+                "which is a byte-compiled expression.\n"
+              (format-message "`%s'.\n" safe-var))))))
+
+(add-hook 'help-fns-describe-variable-functions #'help-fns--var-risky)
+(defun help-fns--var-risky (variable)
+  ;; Can be both risky and safe, eg auto-fill-function.
+  (when (risky-local-variable-p variable)
+    (princ "  This variable may be risky if used as a \
+file-local variable.\n")
+    (when (assq variable safe-local-variable-values)
+      (princ (substitute-command-keys
+              "  However, you have added it to \
+`safe-local-variable-values'.\n")))))
+
+(add-hook 'help-fns-describe-variable-functions #'help-fns--var-ignored-local)
+(defun help-fns--var-ignored-local (variable)
+  (when (memq variable ignored-local-variables)
+    (princ "  This variable is ignored as a file-local \
+variable.\n")))
+
+(add-hook 'help-fns-describe-variable-functions #'help-fns--var-file-local)
+(defun help-fns--var-file-local (variable)
+  (when (boundp variable)
+    (let ((val (symbol-value variable)))
+      (when (member (cons variable val)
+                    file-local-variables-alist)
+        (if (member (cons variable val)
+                    dir-local-variables-alist)
+           (let ((file (and buffer-file-name
+                             (not (file-remote-p buffer-file-name))
+                             (dir-locals-find-file buffer-file-name)))
+                  (is-directory nil))
+             (princ (substitute-command-keys
+                     "  This variable's value is directory-local"))
+              (when (consp file)       ; result from cache
+                ;; If the cache element has an mtime, we
+                ;; assume it came from a file.
+                (if (nth 2 file)
+                    ;; (car file) is a directory.
+                    (setq file (dir-locals--all-files (car file)))
+                  ;; Otherwise, assume it was set directly.
+                  (setq file (car file)
+                        is-directory t)))
+              (if (null file)
+                  (princ ".\n")
+                (princ ", set ")
+                (princ (substitute-command-keys
+                        (cond
+                         (is-directory "for the directory\n  `")
+                         ;; Many files matched.
+                         ((and (consp file) (cdr file))
+                          (setq file (file-name-directory (car file)))
+                          (format "by one of the\n  %s files in the 
directory\n  `"
+                                  dir-locals-file))
+                         (t (setq file (car file))
+                            "by the file\n  `"))))
+               (with-current-buffer standard-output
+                 (insert-text-button
+                  file 'type 'help-dir-local-var-def
+                   'help-args (list variable file)))
+               (princ (substitute-command-keys "'.\n"))))
+          (princ (substitute-command-keys
+                 "  This variable's value is file-local.\n")))))))
+
+(add-hook 'help-fns-describe-variable-functions #'help-fns--var-watchpoints)
+(defun help-fns--var-watchpoints (variable)
+  (let ((watchpoints (get-variable-watchers variable)))
+    (when watchpoints
+      (princ "  Calls these functions when changed: ")
+      ;; FIXME: Turn function names into hyperlinks.
+      (princ watchpoints)
+      (terpri))))
+
+(add-hook 'help-fns-describe-variable-functions #'help-fns--var-obsolete)
+(defun help-fns--var-obsolete (variable)
+  (let* ((obsolete (get variable 'byte-obsolete-variable))
+        (use (car obsolete)))
+    (when obsolete
+      (princ "  This variable is obsolete")
+      (if (nth 2 obsolete)
+          (princ (format " since %s" (nth 2 obsolete))))
+      (princ (cond ((stringp use) (concat ";\n  " use))
+                  (use (format-message ";\n  use `%s' instead."
+                                        (car obsolete)))
+                  (t ".")))
+      (terpri))))
+
+(add-hook 'help-fns-describe-variable-functions #'help-fns--var-alias)
+(defun help-fns--var-alias (variable)
+  ;; Mention if it's an alias.
+  (let ((alias (condition-case nil
+                   (indirect-variable variable)
+                 (error variable))))
+    (unless (eq alias variable)
+      (princ (format-message
+              "  This variable is an alias for `%s'.\n"
+              alias)))))
+
+(add-hook 'help-fns-describe-variable-functions #'help-fns--var-bufferlocal)
+(defun help-fns--var-bufferlocal (variable)
+  (let ((permanent-local (get variable 'permanent-local))
+        (locus (variable-binding-locus variable)))
+    ;; Mention if it's a local variable.
+    (cond
+     ((and (local-variable-if-set-p variable)
+          (or (not (local-variable-p variable))
+              (with-temp-buffer
+                (local-variable-if-set-p variable))))
+      (princ "  Automatically becomes ")
+      (if permanent-local
+         (princ "permanently "))
+      (princ "buffer-local when set.\n"))
+     ((not permanent-local))
+     ((bufferp locus)
+      (princ
+       (substitute-command-keys
+        "  This variable's buffer-local value is permanent.\n")))
+     (t
+      (princ (substitute-command-keys
+             "  This variable's value is permanent \
+if it is given a local binding.\n"))))))
 
 (defvar help-xref-stack-item)
 
diff --git a/lisp/help-macro.el b/lisp/help-macro.el
index 86559eb..a16d1e3 100644
--- a/lisp/help-macro.el
+++ b/lisp/help-macro.el
@@ -1,6 +1,6 @@
 ;;; help-macro.el --- makes command line help such as help-for-help
 
-;; Copyright (C) 1993-1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Lynn Slater <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index 56cb080..6cc3f0d 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -1,6 +1,6 @@
 ;;; help-mode.el --- `help-mode' used by *Help* buffers
 
-;; Copyright (C) 1985-1986, 1993-1994, 1998-2018 Free Software
+;; Copyright (C) 1985-1986, 1993-1994, 1998-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/help.el b/lisp/help.el
index ad782f7..d1f4735 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -1,6 +1,6 @@
 ;;; help.el --- help commands for Emacs  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1985-1986, 1993-1994, 1998-2018 Free Software
+;; Copyright (C) 1985-1986, 1993-1994, 1998-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
@@ -425,13 +425,11 @@ is specified by the variable `message-log-max'."
 (defun view-order-manuals ()
   "Display information on how to buy printed copies of Emacs manuals."
   (interactive)
-;;  (view-help-file "ORDERS")
   (info "(emacs)Printed Books"))
 
 (defun view-emacs-FAQ ()
   "Display the Emacs Frequently Asked Questions (FAQ) file."
   (interactive)
-  ;; (find-file-read-only (expand-file-name "FAQ" data-directory))
   (info "(efaq)"))
 
 (defun view-emacs-problems ()
@@ -444,7 +442,8 @@ is specified by the variable `message-log-max'."
   (interactive)
   (view-help-file "DEBUG"))
 
-;; This used to visit MORE.STUFF; maybe it should just be removed.
+;; This used to visit a plain text file etc/MORE.STUFF;
+;; maybe this command should just be removed.
 (defun view-external-packages ()
   "Display info on where to get more Emacs packages."
   (interactive)
diff --git a/lisp/hex-util.el b/lisp/hex-util.el
index f79fcb3..26fb525 100644
--- a/lisp/hex-util.el
+++ b/lisp/hex-util.el
@@ -1,6 +1,6 @@
 ;;; hex-util.el --- Functions to encode/decode hexadecimal string -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Shuhei KOBAYASHI <address@hidden>
 ;; Keywords: data
diff --git a/lisp/hexl.el b/lisp/hexl.el
index 4070da8..c1c2d70 100644
--- a/lisp/hexl.el
+++ b/lisp/hexl.el
@@ -1,6 +1,6 @@
 ;;; hexl.el --- edit a file in a hex dump format using the hexl filter -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1989, 1994, 1998, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1989, 1994, 1998, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Keith Gabryelski <address@hidden>
diff --git a/lisp/hfy-cmap.el b/lisp/hfy-cmap.el
index ee6e18e..a34efa6 100644
--- a/lisp/hfy-cmap.el
+++ b/lisp/hfy-cmap.el
@@ -1,6 +1,6 @@
 ;;; hfy-cmap.el --- Fallback color name -> rgb mapping for `htmlfontify'
 
-;; Copyright (C) 2002-2003, 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2003, 2009-2019 Free Software Foundation, Inc.
 
 ;; Emacs Lisp Archive Entry
 ;; Package: htmlfontify
diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el
index f503c27..c2568a5 100644
--- a/lisp/hi-lock.el
+++ b/lisp/hi-lock.el
@@ -1,6 +1,6 @@
 ;;; hi-lock.el --- minor mode for interactive automatic highlighting  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: David M. Koppelman <address@hidden>
 ;; Keywords: faces, minor-mode, matching, display
@@ -177,6 +177,26 @@ Instead, each hi-lock command will cycle through the faces 
in
   "Face for hi-lock mode."
   :group 'hi-lock-faces)
 
+(defface hi-salmon
+  '((((min-colors 88) (background dark))
+     (:background "light salmon" :foreground "black"))
+    (((background dark)) (:background "red" :foreground "black"))
+    (((min-colors 88)) (:background "light salmon"))
+    (t (:background "red")))
+  "Face for hi-lock mode."
+  :group 'hi-lock-faces
+  :version "27.1")
+
+(defface hi-aquamarine
+  '((((min-colors 88) (background dark))
+     (:background "aquamarine" :foreground "black"))
+    (((background dark)) (:background "blue" :foreground "black"))
+    (((min-colors 88)) (:background "aquamarine"))
+    (t (:background "blue")))
+  "Face for hi-lock mode."
+  :group 'hi-lock-faces
+  :version "27.1")
+
 (defface hi-black-b
   '((t (:weight bold)))
   "Face for hi-lock mode."
@@ -189,13 +209,13 @@ Instead, each hi-lock command will cycle through the 
faces in
   :group 'hi-lock-faces)
 
 (defface hi-green-b
-  '((((min-colors 88)) (:weight bold :foreground "green1"))
+  '((((min-colors 88)) (:weight bold :foreground "green3"))
     (t (:weight bold :foreground "green")))
   "Face for hi-lock mode."
   :group 'hi-lock-faces)
 
 (defface hi-red-b
-  '((((min-colors 88)) (:weight bold :foreground "red1"))
+  '((((min-colors 88)) (:weight bold :foreground "firebrick2"))
     (t (:weight bold :foreground "red")))
   "Face for hi-lock mode."
   :group 'hi-lock-faces)
@@ -216,8 +236,8 @@ Instead, each hi-lock command will cycle through the faces 
in
 (define-obsolete-variable-alias 'hi-lock-face-history
                                 'hi-lock-face-defaults "23.1")
 (defvar hi-lock-face-defaults
-  '("hi-yellow" "hi-pink" "hi-green" "hi-blue" "hi-black-b"
-    "hi-blue-b" "hi-red-b" "hi-green-b" "hi-black-hb")
+  '("hi-yellow" "hi-pink" "hi-green" "hi-blue" "hi-salmon" "hi-aquamarine"
+    "hi-black-b" "hi-blue-b" "hi-red-b" "hi-green-b" "hi-black-hb")
   "Default faces for hi-lock interactive functions.")
 
 (define-obsolete-variable-alias 'hi-lock-regexp-history
diff --git a/lisp/hilit-chg.el b/lisp/hilit-chg.el
index 70bf6b4..272f758 100644
--- a/lisp/hilit-chg.el
+++ b/lisp/hilit-chg.el
@@ -1,6 +1,6 @@
 ;;; hilit-chg.el --- minor mode displaying buffer changes with special face
 
-;; Copyright (C) 1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Richard Sharman <address@hidden>
 ;; Keywords: faces
diff --git a/lisp/hippie-exp.el b/lisp/hippie-exp.el
index 2d286be..404f448 100644
--- a/lisp/hippie-exp.el
+++ b/lisp/hippie-exp.el
@@ -1,6 +1,6 @@
 ;;; hippie-exp.el --- expand text trying various ways to find its expansion
 
-;; Copyright (C) 1992, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Anders Holst <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/hl-line.el b/lisp/hl-line.el
index f0ee22a..1c09bc2 100644
--- a/lisp/hl-line.el
+++ b/lisp/hl-line.el
@@ -1,6 +1,6 @@
 ;;; hl-line.el --- highlight the current line  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author:  Dave Love <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/htmlfontify.el b/lisp/htmlfontify.el
index 10cfca3..9fc029e 100644
--- a/lisp/htmlfontify.el
+++ b/lisp/htmlfontify.el
@@ -1,6 +1,6 @@
 ;;; htmlfontify.el --- htmlize a buffer/source tree with optional hyperlinks 
-*- lexical-binding: t -*-
 
-;; Copyright (C) 2002-2003, 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2003, 2009-2019 Free Software Foundation, Inc.
 
 ;; Emacs Lisp Archive Entry
 ;; Package: htmlfontify
diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el
index 57ca9b0..1b69574 100644
--- a/lisp/ibuf-ext.el
+++ b/lisp/ibuf-ext.el
@@ -1,6 +1,6 @@
 ;;; ibuf-ext.el --- extensions for ibuffer  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Colin Walters <address@hidden>
 ;; Maintainer: John Paul Wallington <address@hidden>
@@ -1948,11 +1948,10 @@ Otherwise buffers whose name matches an element of
   (ibuffer-mark-on-buffer
    #'(lambda (buf)
        (with-current-buffer buf
-        ;; hacked from midnight.el
         (when buffer-display-time
-          (let* ((now (float-time))
-                 (then (float-time buffer-display-time)))
-            (> (- now then) (* 60 60 ibuffer-old-time))))))))
+          (time-less-p
+           (* 60 60 ibuffer-old-time)
+           (time-since buffer-display-time)))))))
 
 ;;;###autoload
 (defun ibuffer-mark-special-buffers ()
diff --git a/lisp/ibuf-macs.el b/lisp/ibuf-macs.el
index 72a35a5..2b28f18 100644
--- a/lisp/ibuf-macs.el
+++ b/lisp/ibuf-macs.el
@@ -1,6 +1,6 @@
 ;;; ibuf-macs.el --- macros for ibuffer  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Colin Walters <address@hidden>
 ;; Maintainer: John Paul Wallington <address@hidden>
diff --git a/lisp/ibuffer.el b/lisp/ibuffer.el
index b0c4b50..2d3c140 100644
--- a/lisp/ibuffer.el
+++ b/lisp/ibuffer.el
@@ -1,6 +1,6 @@
 ;;; ibuffer.el --- operate on buffers like dired  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Colin Walters <address@hidden>
 ;; Maintainer: John Paul Wallington <address@hidden>
@@ -155,7 +155,7 @@ elisp byte-compiler."
             (string-match ibuffer-compressed-file-name-regexp
                           buffer-file-name))
        font-lock-doc-face)
-    (20 (string-match "^*" (buffer-name)) font-lock-keyword-face)
+    (20 (string-match "^\\*" (buffer-name)) font-lock-keyword-face)
     (25 (and (string-match "^ " (buffer-name))
             (null buffer-file-name))
        italic)
diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index ad5a9d0..10fd3a6 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -1,6 +1,6 @@
-;;; icomplete.el --- minibuffer completion incremental feedback
+;;; icomplete.el --- minibuffer completion incremental feedback -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1992-1994, 1997, 1999, 2001-2018 Free Software
+;; Copyright (C) 1992-1994, 1997, 1999, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Ken Manheimer <address@hidden>
@@ -145,7 +145,7 @@ icompletion is occurring."
 
 (defvar icomplete-minibuffer-map
   (let ((map (make-sparse-keymap)))
-    (define-key map [?\M-\t] 'minibuffer-force-complete)
+    (define-key map [?\M-\t] 'icomplete-force-complete)
     (define-key map [?\C-j]  'icomplete-force-complete-and-exit)
     (define-key map [?\C-.]  'icomplete-forward-completions)
     (define-key map [?\C-,]  'icomplete-backward-completions)
@@ -162,6 +162,12 @@ the default otherwise."
       (minibuffer-force-complete-and-exit)
     (minibuffer-complete-and-exit)))
 
+(defun icomplete-force-complete ()
+  "Complete the icomplete minibuffer."
+  (interactive)
+  ;; We're not at all interested in cycling here (bug#34077).
+  (minibuffer-force-complete nil nil 'dont-cycle))
+
 (defun icomplete-forward-completions ()
   "Step forward completions by one entry.
 Second entry becomes the first and can be selected with
@@ -368,8 +374,21 @@ If there are multiple possibilities, `icomplete-separator' 
separates them.
 The displays for unambiguous matches have ` [Matched]' appended
 \(whether complete or not), or ` [No matches]', if no eligible
 matches exist."
-  (let* ((minibuffer-completion-table candidates)
-        (minibuffer-completion-predicate predicate)
+  (let* ((ignored-extension-re
+          (and minibuffer-completing-file-name
+               icomplete-with-completion-tables
+               completion-ignored-extensions
+               (concat "\\(?:\\`\\.\\./\\|"
+                       (regexp-opt completion-ignored-extensions)
+                       "\\)\\'")))
+         (minibuffer-completion-table candidates)
+        (minibuffer-completion-predicate
+          (if ignored-extension-re
+              (lambda (cand)
+                (and (not (string-match ignored-extension-re cand))
+                     (or (null predicate)
+                         (funcall predicate cand))))
+            predicate))
         (md (completion--field-metadata (icomplete--field-beg)))
         (comps (completion-all-sorted-completions
                  (icomplete--field-beg) (icomplete--field-end)))
@@ -380,11 +399,8 @@ matches exist."
     ;; `concat'/`mapconcat' is the slow part.
     (if (not (consp comps))
        (progn ;;(debug (format "Candidates=%S field=%S" candidates name))
-              (format " %sNo matches%s" open-bracket close-bracket))
+         (format " %sNo matches%s" open-bracket close-bracket))
       (if last (setcdr last nil))
-      (when (and minibuffer-completing-file-name
-                 icomplete-with-completion-tables)
-        (setq comps (completion-pcm--filename-try-filter comps)))
       (let* ((most-try
               (if (and base-size (> base-size 0))
                   (completion-try-completion
@@ -470,11 +486,11 @@ matches exist."
                  (if prefix-len (substring (car comps) prefix-len) (car comps))
                  comps (cdr comps))
            (setq prospects-len
-                           (+ (string-width comp)
-                             (string-width icomplete-separator)
-                             prospects-len))
-                    (if (< prospects-len prospects-max)
-                        (push comp prospects)
+                  (+ (string-width comp)
+                    (string-width icomplete-separator)
+                    prospects-len))
+           (if (< prospects-len prospects-max)
+               (push comp prospects)
              (setq limit t))))
        (setq prospects (nreverse prospects))
        ;; Decorate first of the prospects.
diff --git a/lisp/ido.el b/lisp/ido.el
index 69326d4..1a3a384 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -1,6 +1,6 @@
 ;;; ido.el --- interactively do things with buffers and files -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Kim F. Storm <address@hidden>
 ;; Based on: iswitchb by Stephen Eglen <address@hidden>
@@ -735,6 +735,14 @@ not provide the normal completion.  To show the 
completions, use \\[ido-toggle-i
                 (integer :tag "Size in bytes" 30000))
   :group 'ido)
 
+(defcustom ido-big-directories nil
+  "List of directory pattern strings that should be considered big.
+Ido won't attempt to list the contents of directories matching
+any of these regular expressions when completing file names."
+  :type '(repeat regexp)
+  :group 'ido
+  :version "27.1")
+
 (defcustom ido-rotate-file-list-default nil
   "Non-nil means that Ido will always rotate file list to get default in 
front."
   :type 'boolean
@@ -1515,20 +1523,20 @@ Removes badly formatted data and ignored directories."
                                (files (cdr (cdr (car l)))))
                            (and
                             (stringp dir)
-                            (consp time)
-                            (cond
-                             ((integerp (car time))
-                              (and (not (zerop (float-time time)))
-                                   (ido-may-cache-directory dir)))
-                             ((eq (car time) 'ftp)
-                              (and (numberp (cdr time))
-                                   (ido-is-ftp-directory dir)
-                                   (ido-cache-ftp-valid (cdr time))))
-                             ((eq (car time) 'unc)
-                              (and (numberp (cdr time))
-                                   (ido-is-unc-host dir)
-                                   (ido-cache-unc-valid (cdr time))))
-                             (t nil))
+                            (if (condition-case nil
+                                    (not (time-equal-p time 0))
+                                  (error))
+                                (ido-may-cache-directory dir)
+                              (and
+                               (consp time)
+                               (numberp (cdr time))
+                               (cond
+                                ((eq (car time) 'ftp)
+                                 (and (ido-is-ftp-directory dir)
+                                      (ido-cache-ftp-valid (cdr time))))
+                                ((eq (car time) 'unc)
+                                 (and (ido-is-unc-host dir)
+                                      (ido-cache-unc-valid (cdr time)))))))
                             (let ((s files) (ok t))
                               (while s
                                 (if (stringp (car s))
@@ -1743,13 +1751,16 @@ is enabled then some keybindings are changed in the 
keymap."
   ;; Return t if dir is a directory, but too big to show
   ;; Do not check for non-readable directories via tramp, as this causes a 
premature
   ;; connect on incomplete tramp paths (after entering just method:).
-  (let ((ido-enable-tramp-completion nil))
-    (and (numberp ido-max-directory-size)
-        (ido-final-slash dir)
-        (not (ido-is-unc-host dir))
-        (file-directory-p dir)
-        (> (file-attribute-size (file-attributes (file-truename dir)))
-           ido-max-directory-size))))
+  (let ((ido-enable-tramp-completion nil)
+        (case-fold-search nil))
+    (or (seq-some (lambda (regexp) (string-match-p regexp dir))
+                  ido-big-directories)
+        (and (numberp ido-max-directory-size)
+            (ido-final-slash dir)
+            (not (ido-is-unc-host dir))
+            (file-directory-p dir)
+            (> (file-attribute-size (file-attributes (file-truename dir)))
+               ido-max-directory-size)))))
 
 (defun ido-set-current-directory (dir &optional subdir no-merge)
   ;; Set ido's current directory to DIR or DIR/SUBDIR
@@ -3621,8 +3632,7 @@ Uses and updates `ido-dir-file-cache'."
                             (ido-cache-unc-valid (cdr ctime)))))
           (t
            (if attr
-               (setq valid (and (= (car ctime) (car mtime))
-                                (= (car (cdr ctime)) (car (cdr mtime))))))))
+               (setq valid (time-equal-p ctime mtime)))))
          (unless valid
            (setq ido-dir-file-cache (delq cached ido-dir-file-cache)
                  cached nil)))
@@ -3789,13 +3799,13 @@ frame, rather than all frames, regardless of value of 
`ido-all-frames'."
                       (not (and (eq ido-cur-item 'buffer)
                                 ido-buffer-disable-smart-matches))
                       (not ido-enable-regexp)
-                      (not (string-match "$\\'" rex0))
+                      (not (string-match "\\$\\'" rex0))
                       (concat "\\`" rex0 (if slash "/" "") "\\'")))
         (suffix-re (and do-full slash
                         (not (and (eq ido-cur-item 'buffer)
                                   ido-buffer-disable-smart-matches))
                         (not ido-enable-regexp)
-                        (not (string-match "$\\'" rex0))
+                        (not (string-match "\\$\\'" rex0))
                         (concat rex0 "/\\'")))
         (prefix-re (and full-re (not ido-enable-prefix)
                         (concat "\\`" rexq)))
@@ -3966,8 +3976,24 @@ If `ido-change-word-sub' cannot be found in WORD, return 
nil."
     (exit-minibuffer)
     t))
 
+;; This is a shameless copy of `switch-to-completions'.
+(defun ido-switch-to-completions ()
+  "Select the window showing `ido-completion-buffer'."
+  (interactive)
+  (let ((window (or (get-buffer-window ido-completion-buffer 0)
+                   ;; Make sure we have a completions window.
+                    (progn (ido-completion-help)
+                           (get-buffer-window ido-completion-buffer 0)))))
+    (when window
+      (select-window window)
+      ;; In the new buffer, go to the first completion.
+      ;; FIXME: Perhaps this should be done in `ido-completion-help'.
+      (when (bobp)
+       (next-completion 1)))))
+
+
 (defun ido-completion-help ()
-  "Show possible completions in a \"*File Completions*\" buffer."
+  "Show possible completions in the `ido-completion-buffer'."
   (interactive)
   (setq ido-rescan nil)
   (let ((temp-buf (and ido-completion-buffer
diff --git a/lisp/ielm.el b/lisp/ielm.el
index 8d1efcd..c7a31a2 100644
--- a/lisp/ielm.el
+++ b/lisp/ielm.el
@@ -1,6 +1,6 @@
 ;;; ielm.el --- interaction mode for Emacs Lisp  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Smith <address@hidden>
 ;; Maintainer: address@hidden
@@ -559,10 +559,11 @@ Customized bindings may be defined in `ielm-map', which 
currently contains:
   ;; Useful for `hs-minor-mode'.
   (setq-local comment-start ";")
   (setq-local comment-use-syntax t)
+  (setq-local lexical-binding t)
 
-  (set (make-local-variable 'indent-line-function) 'ielm-indent-line)
+  (set (make-local-variable 'indent-line-function) #'ielm-indent-line)
   (set (make-local-variable 'ielm-working-buffer) (current-buffer))
-  (set (make-local-variable 'fill-paragraph-function) 'lisp-fill-paragraph)
+  (set (make-local-variable 'fill-paragraph-function) #'lisp-fill-paragraph)
 
   ;; Value holders
   (set (make-local-variable '*) nil)
diff --git a/lisp/iimage.el b/lisp/iimage.el
index 22e1500..e51108e 100644
--- a/lisp/iimage.el
+++ b/lisp/iimage.el
@@ -1,6 +1,6 @@
 ;;; iimage.el --- Inline image minor mode.
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: KOSEKI Yoshinori <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index 17e566d..c9b31e9 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -1,6 +1,6 @@
 ;;; image-dired.el --- use dired to browse and manipulate your images -*- 
lexical-binding: t -*-
 ;;
-;; Copyright (C) 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005-2019 Free Software Foundation, Inc.
 ;;
 ;; Version: 0.4.11
 ;; Keywords: multimedia
diff --git a/lisp/image-file.el b/lisp/image-file.el
index 19dc787..abc4686 100644
--- a/lisp/image-file.el
+++ b/lisp/image-file.el
@@ -1,6 +1,6 @@
 ;;; image-file.el --- support for visiting image files
 ;;
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Miles Bader <address@hidden>
 ;; Keywords: multimedia
@@ -97,8 +97,9 @@ the variable is set using \\[customize]."
 ;;;###autoload
 (defun insert-image-file (file &optional visit beg end replace)
   "Insert the image file FILE into the current buffer.
-Optional arguments VISIT, BEG, END, and REPLACE are interpreted as for
-the command `insert-file-contents'."
+Optional arguments VISIT, BEG, END, and REPLACE are interpreted
+as for the command `insert-file-contents'.  Return list of
+absolute file name and number of characters inserted."
   (let ((rval
         (image-file-call-underlying #'insert-file-contents-literally
                                     'insert-file-contents
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index 92ba577..fa1362c 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -1,6 +1,6 @@
 ;;; image-mode.el --- support for visiting image files  -*- lexical-binding: t 
-*-
 ;;
-;; Copyright (C) 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Richard Stallman <address@hidden>
 ;; Keywords: multimedia
@@ -53,7 +53,7 @@ See `image-mode-winprops'.")
 It is called with one argument, the initial WINPROPS.")
 
 ;; FIXME this doesn't seem mature yet. Document in manual when it is.
-(defvar image-transform-resize nil
+(defvar-local image-transform-resize nil
   "The image resize operation.
 Its value should be one of the following:
  - nil, meaning no resizing.
@@ -61,10 +61,10 @@ Its value should be one of the following:
  - `fit-width', meaning to fit the image to the window width.
  - A number, which is a scale factor (the default size is 1).")
 
-(defvar image-transform-scale 1.0
+(defvar-local image-transform-scale 1.0
   "The scale factor of the image being displayed.")
 
-(defvar image-transform-rotation 0.0
+(defvar-local image-transform-rotation 0.0
   "Rotation angle for the image in the current Image mode buffer.")
 
 (defvar image-transform-right-angle-fudge 0.0001
@@ -741,9 +741,11 @@ was inserted."
         (type (if (image--imagemagick-wanted-p filename)
                   'imagemagick
                 (image-type file-or-data nil data-p)))
+         ;; :scale 1: If we do not set this, create-image will apply
+         ;; default scaling based on font size.
         (image (if (not edges)
-                   (create-image file-or-data type data-p)
-                 (create-image file-or-data type data-p
+                   (create-image file-or-data type data-p :scale 1)
+                 (create-image file-or-data type data-p :scale 1
                                :max-width (- (nth 2 edges) (nth 0 edges))
                                :max-height (- (nth 3 edges) (nth 1 edges)))))
         (inhibit-read-only t)
diff --git a/lisp/image.el b/lisp/image.el
index 74a2304..ba87d7f 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -1,6 +1,6 @@
 ;;; image.el --- image API  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: multimedia
@@ -415,13 +415,20 @@ must be available."
 (defun create-image (file-or-data &optional type data-p &rest props)
   "Create an image.
 FILE-OR-DATA is an image file name or image data.
+
 Optional TYPE is a symbol describing the image type.  If TYPE is omitted
 or nil, try to determine the image type from its first few bytes
 of image data.  If that doesn't work, and FILE-OR-DATA is a file name,
 use its file extension as image type.
+
 Optional DATA-P non-nil means FILE-OR-DATA is a string containing image data.
+
 Optional PROPS are additional image attributes to assign to the image,
-like, e.g. `:mask MASK'.
+like, e.g. `:mask MASK'.  If the property `:scale' is not given and the
+display has a high resolution (more exactly, when the average width of a
+character in the default font is more than 10 pixels), the image is
+automatically scaled up in proportion to the default font.
+
 Value is the image created, or nil if images of type TYPE are not supported.
 
 Images should not be larger than specified by `max-image-size'.
@@ -447,10 +454,10 @@ Internal use only."
         ;; plist.  Decouple plist entries where the key matches
         ;; the property.
         (if (eq (cadr image) property)
-            (setcdr image (cddr image))
+            (setcdr image (cdddr image))
           (setq image (cddr image))))
     ;; Just enter the new value.
-    (plist-put (cdr image) property value))
+    (setcdr image (plist-put (cdr image) property value)))
   value)
 
 (defun image-property (image property)
@@ -797,19 +804,22 @@ If the image has a non-nil :speed property, it acts as a 
multiplier
 for the animation speed.  A negative value means to animate in reverse."
   (when (and (buffer-live-p (plist-get (cdr image) :animate-buffer))
              ;; Delayed more than two seconds more than expected.
-            (or (<= (- (float-time) target-time) 2)
+            (or (time-less-p (time-since target-time) 2)
                 (progn
                   (message "Stopping animation; animation possibly too big")
                   nil)))
     (image-show-frame image n t)
     (let* ((speed (image-animate-get-speed image))
-          (time (float-time))
+          (time (current-time))
           (animation (image-multi-frame-p image))
+          (time-to-load-image (time-since time))
+          (stated-delay-time (/ (or (cdr animation)
+                                    image-default-frame-delay)
+                                (float (abs speed))))
           ;; Subtract off the time we took to load the image from the
           ;; stated delay time.
-          (delay (max (+ (* (or (cdr animation) image-default-frame-delay)
-                            (/ 1.0 (abs speed)))
-                         time (- (float-time)))
+          (delay (max (float-time (time-subtract stated-delay-time
+                                                 time-to-load-image))
                       image-minimum-frame-delay))
           done)
       (setq n (if (< speed 0)
@@ -918,7 +928,7 @@ has no effect."
   :version "24.3")
 
 (defcustom imagemagick-enabled-types
-  '(3FR ART ARW AVS BMP BMP2 BMP3 CAL CALS CMYK CMYKA CR2 CRW
+  '(3FR ARW AVS BMP BMP2 BMP3 CAL CALS CMYK CMYKA CR2 CRW
     CUR CUT DCM DCR DCX DDS DJVU DNG DPX EXR FAX FITS GBR GIF
     GIF87 GRB HRZ ICB ICO ICON J2C JNG JP2 JPC JPEG JPG JPX K25
     KDC MIFF MNG MRW MSL MSVG MTV NEF ORF OTB PBM PCD PCDS PCL
@@ -952,7 +962,7 @@ has no effect."
   :set (lambda (symbol value)
         (set-default symbol value)
         (imagemagick-register-types))
-  :version "24.3")
+  :version "26.2")                      ; remove ART (bug#22289)
 
 (imagemagick-register-types)
 
@@ -982,8 +992,8 @@ default is 20%."
     image))
 
 (defun image--get-imagemagick-and-warn ()
-  (unless (or (fboundp 'imagemagick-types) (featurep 'ns))
-    (error "Cannot rescale images without ImageMagick support"))
+  (unless (or (fboundp 'imagemagick-types) (image-scaling-p))
+    (error "Cannot rescale images on this terminal"))
   (let ((image (image--get-image)))
     (image-flush image)
     (when (fboundp 'imagemagick-types)
diff --git a/lisp/image/compface.el b/lisp/image/compface.el
index 67b9ca3..2375261 100644
--- a/lisp/image/compface.el
+++ b/lisp/image/compface.el
@@ -1,6 +1,6 @@
 ;;; compface.el --- functions for converting X-Face headers
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
diff --git a/lisp/image/gravatar.el b/lisp/image/gravatar.el
index e7c472d..cf61119 100644
--- a/lisp/image/gravatar.el
+++ b/lisp/image/gravatar.el
@@ -1,6 +1,6 @@
 ;;; gravatar.el --- Get Gravatars
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Julien Danjou <address@hidden>
 ;; Keywords: news
diff --git a/lisp/imenu.el b/lisp/imenu.el
index 09d50da..df39ff3 100644
--- a/lisp/imenu.el
+++ b/lisp/imenu.el
@@ -1,6 +1,6 @@
 ;;; imenu.el --- framework for mode-specific buffer indexes  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1994-1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Ake Stenhoff <address@hidden>
 ;;         Lars Lindberg <address@hidden>
diff --git a/lisp/indent.el b/lisp/indent.el
index 73a7d0e..bf87d6a 100644
--- a/lisp/indent.el
+++ b/lisp/indent.el
@@ -1,6 +1,6 @@
 ;;; indent.el --- indentation commands for Emacs  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1985, 1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Package: emacs
@@ -65,15 +65,17 @@ e.g., `c-tab-always-indent', and do not respect this 
variable."
   "Indent line in proper way for current major mode.
 Normally, this is done by calling the function specified by the
 variable `indent-line-function'.  However, if the value of that
-variable is `indent-relative' or `indent-relative-maybe', handle
-it specially (since those functions are used for tabbing); in
-that case, indent by aligning to the previous non-blank line."
+variable is `indent-relative' or `indent-relative-first-indent-point',
+handle it specially (since those functions are used for tabbing);
+in that case, indent by aligning to the previous non-blank line."
   (interactive)
   (save-restriction
     (widen)
   (syntax-propertize (line-end-position))
   (if (memq indent-line-function
-           '(indent-relative indent-relative-maybe))
+            '(indent-relative
+              indent-relative-maybe
+              indent-relative-first-indent-point))
       ;; These functions are used for tabbing, but can't be used for
       ;; indenting.  Replace with something ad-hoc.
       (let ((column (save-excursion
@@ -598,8 +600,9 @@ considered.
 
 If the previous nonblank line has no indent points beyond the
 column point starts at, then `tab-to-tab-stop' is done, if both
-FIRST-ONLY and UNINDENTED-OK are nil, otherwise nothing is done
-in this case.
+FIRST-ONLY and UNINDENTED-OK are nil, otherwise nothing is done.
+If there isn't a previous nonblank line and UNINDENTED-OK is nil,
+call `tab-to-tab-stop'.
 
 See also `indent-relative-first-indent-point'."
   (interactive "P")
diff --git a/lisp/info-look.el b/lisp/info-look.el
index dec16cf..1d761c7 100644
--- a/lisp/info-look.el
+++ b/lisp/info-look.el
@@ -1,7 +1,7 @@
 ;;; info-look.el --- major-mode-sensitive Info index lookup facility -*- 
lexical-binding: t -*-
 ;; An older version of this was known as libc.el.
 
-;; Copyright (C) 1995-1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-1999, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Ralph Schleicher <address@hidden>
 ;;         (did not show signs of life (Nov 2001)  -stef)
diff --git a/lisp/info-xref.el b/lisp/info-xref.el
index 5e029b0..c55398b 100644
--- a/lisp/info-xref.el
+++ b/lisp/info-xref.el
@@ -1,6 +1,6 @@
 ;;; info-xref.el --- check external references in an Info document -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author: Kevin Ryde <address@hidden>
 ;; Keywords: docs
@@ -71,7 +71,7 @@ you should set this variable to nil."
 (defun info-xref-lock-file-p (filename)
   "Return non-nil if FILENAME is an Emacs lock file.
 A lock file is \".#foo.txt\" etc per `lock-buffer'."
-  (string-match "\\(\\`\\|\\/\\)\\.#" filename))
+  (string-match "\\(\\`\\|/\\)\\.#" filename))
 
 (defun info-xref-subfile-p (filename)
   "Return t if FILENAME is an info subfile.
diff --git a/lisp/info.el b/lisp/info.el
index d2d315d..2882262 100644
--- a/lisp/info.el
+++ b/lisp/info.el
@@ -1,6 +1,6 @@
 ;; info.el --- Info package for Emacs  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1985-1986, 1992-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1986, 1992-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: help
@@ -642,14 +642,14 @@ Do the right thing if the file has been compressed or 
zipped."
          (insert-file-contents-literally fullname visit)
          (let ((inhibit-read-only t)
                (coding-system-for-write 'no-conversion)
-               (inhibit-null-byte-detection t) ; Index nodes include null bytes
+               (inhibit-nul-byte-detection t) ; Index nodes include null bytes
                (default-directory (or (file-name-directory fullname)
                                       default-directory)))
            (or (consp decoder)
                (setq decoder (list decoder)))
            (apply #'call-process-region (point-min) (point-max)
                   (car decoder) t t nil (cdr decoder))))
-      (let ((inhibit-null-byte-detection t)) ; Index nodes include null bytes
+      (let ((inhibit-nul-byte-detection t)) ; Index nodes include null bytes
        (insert-file-contents fullname visit)))
 
     ;; Clear the caches of modified Info files.
@@ -1377,7 +1377,7 @@ is non-nil)."
                          ;; Index nodes include null bytes.  DIR
                          ;; files should not have indices, but who
                          ;; knows...
-                         (let ((inhibit-null-byte-detection t))
+                         (let ((inhibit-nul-byte-detection t))
                            (insert-file-contents file)
                            (setq Info-dir-file-name file)
                            (push (current-buffer) buffers)
@@ -1531,7 +1531,7 @@ is non-nil)."
            (save-restriction
              (narrow-to-region start (point))
              (goto-char (point-min))
-             (while (re-search-forward "^* \\([^:\n]+:\\(:\\|[^.\n]+\\).\\)" 
nil 'move)
+             (while (re-search-forward "^\\* \\([^:\n]+:[^.\n]+.\\)" nil 'move)
                ;; Fold case straight away; `member-ignore-case' here wasteful.
                (let ((x (downcase (match-string 1))))
                  (if (member x seen)
@@ -1602,7 +1602,7 @@ is non-nil)."
   "Unescape double quotes and backslashes in VALUE."
   (let ((start 0)
        (unquote value))
-    (while (string-match "[^\\\"]*\\(\\\\\\)[\\\\\"]" unquote start)
+    (while (string-match "[^\\\"]*\\(\\\\\\)[\\\"]" unquote start)
       (setq unquote (replace-match "" t t unquote 1))
       (setq start (- (match-end 0) 1)))
     unquote))
@@ -1619,7 +1619,7 @@ escaped (\\\",\\\\)."
   (let ((start 0)
        (parameter-alist))
     (while (string-match
-           "\\s *\\([^=]+\\)=\\(?:\\([^\\s 
\"]+\\)\\|\\(?:\"\\(\\(?:[^\\\"]\\|\\\\[\\\\\"]\\)*\\)\"\\)\\)"
+           "\\s *\\([^=]+\\)=\\(?:\\([^\\s 
\"]+\\)\\|\\(?:\"\\(\\(?:[^\\\"]\\|\\\\[\\\"]\\)*\\)\"\\)\\)"
            parameter-string start)
       (setq start (match-end 0))
       (push (cons (match-string 1 parameter-string)
@@ -4268,8 +4268,9 @@ With a zero prefix arg, put the name inside a function 
call to `info'."
 ;; We deliberately fontify only ‘..’ quoting, and not `..', because
 ;; the former can be done much more reliably, i.e. without risking
 ;; false positives.
+;; FIXME: It doesn't handle nested quotes.
 (defvar Info-mode-font-lock-keywords
-  '(("‘\\([^’]*\\)’" (1 'Info-quoted))))
+  '(("‘\\([‘’]\\|[^‘’]*\\)’" (1 'Info-quoted))))
 
 ;; Autoload cookie needed by desktop.el
 ;;;###autoload
@@ -4768,7 +4769,7 @@ first line or header line, and for breadcrumb links.")
             ;; This is a serious problem for trying to handle multiple
             ;; frame types at once.  We want this text to be invisible
             ;; on frames that can display the font above.
-            (when (memq (framep (selected-frame)) '(x pc w32 ns))
+            (when (display-multi-font-p)
               (add-text-properties (1- (match-beginning 2)) (match-end 2)
                                    '(invisible t front-sticky nil 
rear-nonsticky t))))))
 
@@ -5204,7 +5205,7 @@ The INDENT level is ignored."
 TEXT is the text of the button we clicked on, a + or - item.
 TOKEN is data related to this node (NAME . FILE).
 INDENT is the current indentation depth."
-  (cond ((string-match "+" text)       ;we have to expand this file
+  (cond ((string-match "\\+" text)     ;we have to expand this file
         (speedbar-change-expand-button-char ?-)
         (if (speedbar-with-writable
              (save-excursion
diff --git a/lisp/informat.el b/lisp/informat.el
index ff34496..8108ffe 100644
--- a/lisp/informat.el
+++ b/lisp/informat.el
@@ -1,6 +1,6 @@
 ;;; informat.el --- info support functions package for Emacs
 
-;; Copyright (C) 1986, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1986, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: help
diff --git a/lisp/international/ccl.el b/lisp/international/ccl.el
index a80452f..51626f5 100644
--- a/lisp/international/ccl.el
+++ b/lisp/international/ccl.el
@@ -1,6 +1,6 @@
 ;;; ccl.el --- CCL (Code Conversion Language) compiler  -*- lexical-binding:t 
-*-
 
-;; Copyright (C) 1997-1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/international/characters.el b/lisp/international/characters.el
index 23d9df6..012827b 100644
--- a/lisp/international/characters.el
+++ b/lisp/international/characters.el
@@ -1,6 +1,6 @@
 ;;; characters.el --- set syntax and category for multibyte characters
 
-;; Copyright (C) 1997, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2000-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -987,11 +987,12 @@ with L, LRE, or LRO Unicode bidi character type.")
           (#x103D . #x103E)
           (#x1058 . #x1059)
           (#x105E . #x1160)
-          (#x1171 . #x1074)
+          (#x1071 . #x1074)
           (#x1082 . #x1082)
           (#x1085 . #x1086)
           (#x108D . #x108D)
           (#x109D . #x109D)
+           (#x1160 . #x11FF)
           (#x135D . #x135F)
           (#x1712 . #x1714)
           (#x1732 . #x1734)
@@ -1081,6 +1082,7 @@ with L, LRE, or LRO Unicode bidi character type.")
           (#xABE5 . #xABE5)
           (#xABE8 . #xABE8)
           (#xABED . #xABED)
+           (#xD7B0 . #xD7FB)
           (#xFB1E . #xFB1E)
           (#xFE00 . #xFE0F)
           (#xFE20 . #xFE2F)
@@ -1217,10 +1219,11 @@ with L, LRE, or LRO Unicode bidi character type.")
           (#xFE30 . #xFE6F)
           (#xFF01 . #xFF60)
           (#xFFE0 . #xFFE6)
-          (#x16FE0 . #x16FE1)
-          (#x17000 . #x187F1)
+          (#x16FE0 . #x16FE3)
+          (#x17000 . #x187F7)
           (#x18800 . #x18AF2)
-          (#x1B000 . #x1B11E)
+          (#x1B000 . #x1B152)
+           (#x1B164 . #x1B167)
            (#x1B170 . #x1B2FB)
           (#x1F004 . #x1F004)
           (#x1F0CF . #x1F0CF)
@@ -1250,17 +1253,22 @@ with L, LRE, or LRO Unicode bidi character type.")
           (#x1F680 . #x1F6C5)
           (#x1F6CC . #x1F6CC)
           (#x1F6D0 . #x1F6D2)
+           (#x1F6D5 . #x1F6D5)
           (#x1F6EB . #x1F6EC)
-          (#x1F6F4 . #x1F6F9)
-          (#x1F910 . #x1F93E)
-          (#x1F940 . #x1F970)
+          (#x1F6F4 . #x1F6FA)
+           (#x1F7E0 . #x1F7EB)
+          (#x1F90D . #x1F971)
           (#x1F973 . #x1F976)
-          (#x1F97A . #x1F97A)
-          (#x1F97C . #x1F9A2)
-          (#x1F9B0 . #x1F9B9)
-          (#x1F9C0 . #x1F9C2)
-           (#x1F9D0 . #x1F9FF)
+          (#x1F97A . #x1F9A2)
+           (#x1F9A5 . #x1F9AA)
+           (#x1F9AE . #x1F9CA)
+           (#x1F9CD . #x1F9FF)
+           (#x1FA00 . #x1FA53)
            (#x1FA60 . #x1FA6D)
+           (#x1FA70 . #x1FA73)
+           (#x1FA78 . #x1FA7A)
+           (#x1FA80 . #x1FA82)
+           (#x1FA90 . #x1FA95)
           (#x20000 . #x2FFFF)
           (#x30000 . #x3FFFF))))
   (dolist (elt l)
@@ -1334,7 +1342,7 @@ Setup char-width-table appropriate for non-CJK language 
environment."
 
 
 ;; Setting char-script-table.
-(if purify-flag
+(if dump-mode
     ;; While dumping, we can't use require, and international is not
     ;; in load-path.
     (load "international/charscript")
diff --git a/lisp/international/fontset.el b/lisp/international/fontset.el
index 143b7b7..0413646 100644
--- a/lisp/international/fontset.el
+++ b/lisp/international/fontset.el
@@ -1,6 +1,6 @@
 ;;; fontset.el --- commands for handling fontset
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -222,6 +222,7 @@
         (hanifi-rohingya #x10D00)
         (old-sogdian #x10F00)
         (sogdian #x10F30)
+        (elymaic #x10fe0)
        (mahajani #x11150)
        (sinhala-archaic-number #x111E1)
        (khojki #x11200)
@@ -234,6 +235,7 @@
        (takri #x11680)
         (dogra #x11800)
        (warang-citi #x118A1)
+        (nandinagari #x119a0)
         (zanabazar-square #x11A00)
         (soyombo #x11A50)
        (pau-cin-hau #x11AC0)
@@ -257,15 +259,19 @@
        (ancient-greek-musical-notation #x1D200)
        (tai-xuan-jing-symbol #x1D300)
        (counting-rod-numeral #x1D360)
+        (nyiakeng-puachue-hmong #x1e100)
+        (wancho #x1e2c0)
        (mende-kikakui #x1E810)
         (adlam #x1E900)
+        (indic-siyaq-number #x1ec71)
+        (ottoman-siyaq-number #x1ed01)
        (mahjong-tile #x1F000)
        (domino-tile #x1F030)))
 
 (defvar otf-script-alist)
 
-;; The below was synchronized with the latest Jul 23, 2017 version of
-;; https://www.microsoft.com/typography/otspec/scripttags.htm.
+;; The below was synchronized with the latest Aug 16, 2018 version of
+;; https://docs.microsoft.com/en-us/typography/opentype/spec/scripttags
 (setq otf-script-alist
       '((adlm . adlam)
         (ahom . ahom)
@@ -300,6 +306,7 @@
        (dsrt . deseret)
        (deva . devanagari)
        (dev2 . devanagari)
+        (dogr . dogra)
         (dupl . duployan-shorthand)
        (egyp . egyptian)
         (elba . elbasan)
@@ -311,11 +318,13 @@
        (grek . greek)
        (gujr . gujarati)
        (gjr2 . gujarati)
+        (gong . gunjala-gondi)
        (guru . gurmukhi)
        (gur2 . gurmukhi)
        (hani . han)
        (hang . hangul)
        (jamo . hangul)
+        (rohg . hanifi-rohingya)
        (hano . hanunoo)
         (hatr . hatran)
        (hebr . hebrew)
@@ -324,9 +333,9 @@
        (prti . inscriptional-parthian)
        (java . javanese)
        (kthi . kaithi)
-       (kana . kana)   ; Hiragana
        (knda . kannada)
        (knd2 . kannada)
+       (kana . kana)   ; Hiragana
        (kali . kayah-li)
        (khar . kharoshthi)
        (khmr . khmer)
@@ -342,12 +351,15 @@
         (lyci . lycian)
         (lydi . lydian)
         (mahj . mahajani)
+        (maka . makasar)
         (marc . marchen)
        (mlym . malayalam)
        (mlm2 . malayalam)
        (mand . mandaic)
         (mani . manichaean)
+        (gonm . masaram-gondi)
        (math . mathematical)
+        (medf . medefaidrin)
        (mtei . meetei-mayek)
         (mend . mende-kikakui)
        (merc . meroitic)
@@ -363,12 +375,14 @@
         (nbat . nabataean)
         (newa . newa)
        (nko\  . nko)
+        (nshu . nushu)
        (ogam . ogham)
        (olck . ol-chiki)
        (ital . old_italic)
        (xpeo . old_persian)
         (narb . old-north-arabian)
         (perm . old-permic)
+        (sogo . old-sogdian)
        (sarb . old-south-arabian)
        (orkh . old-turkic)
        (orya . oriya)
@@ -392,7 +406,9 @@
         (sidd . siddham)
         (sgnw . sutton-sign-writing)
        (sinh . sinhala)
+        (sogd . sogdian)
        (sora . sora-sompeng)
+        (soyo . soyombo)
        (sund . sundanese)
        (sylo . syloti_nagri)
        (syrc . syriac)
@@ -416,7 +432,8 @@
        (ugar . ugaritic)
        (vai\  . vai)
         (wara . warang-citi)
-       (yi\ \   . yi)))
+       (yi\ \   . yi)
+        (zanb . zanabazar-square)))
 
 ;; Set standard fontname specification of characters in the default
 ;; fontset to find an appropriate font for each script/charset.  The
diff --git a/lisp/international/isearch-x.el b/lisp/international/isearch-x.el
index 19a45c7..6c2a2dc 100644
--- a/lisp/international/isearch-x.el
+++ b/lisp/international/isearch-x.el
@@ -1,6 +1,6 @@
 ;;; isearch-x.el --- extended isearch handling commands
 
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/international/iso-ascii.el b/lisp/international/iso-ascii.el
index bcb285e..395e6c4 100644
--- a/lisp/international/iso-ascii.el
+++ b/lisp/international/iso-ascii.el
@@ -1,6 +1,6 @@
 ;;; iso-ascii.el --- set up char tables for ISO 8859/1 on ASCII terminals
 
-;; Copyright (C) 1987, 1995, 1998, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1987, 1995, 1998, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Howard Gayle
diff --git a/lisp/international/iso-cvt.el b/lisp/international/iso-cvt.el
index 452e2c2..7877c00 100644
--- a/lisp/international/iso-cvt.el
+++ b/lisp/international/iso-cvt.el
@@ -1,7 +1,7 @@
 ;;; iso-cvt.el --- translate ISO 8859-1 from/to various encodings -*- coding: 
utf-8 -*-
 ;; This file was formerly called gm-lingo.el.
 
-;; Copyright (C) 1993-1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1998, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Gschwind <address@hidden>
 ;; Keywords: tex, iso, latin, i18n
diff --git a/lisp/international/iso-transl.el b/lisp/international/iso-transl.el
index 0856b4f..b573e1e 100644
--- a/lisp/international/iso-transl.el
+++ b/lisp/international/iso-transl.el
@@ -1,6 +1,6 @@
 ;;; iso-transl.el --- keyboard input for ISO 10646 chars -*- coding: utf-8 -*-
 
-;; Copyright (C) 1987, 1993-1999, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1987, 1993-1999, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Howard Gayle
diff --git a/lisp/international/ja-dic-cnv.el b/lisp/international/ja-dic-cnv.el
index 60943f7..e721083 100644
--- a/lisp/international/ja-dic-cnv.el
+++ b/lisp/international/ja-dic-cnv.el
@@ -1,6 +1,6 @@
 ;;; ja-dic-cnv.el --- convert a Japanese dictionary (SKK-JISYO.L) to Emacs Lisp
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
@@ -32,15 +32,15 @@
 ;; input method (e.g. quail-japanese) can utilize the dictionary.
 
 ;; The format of SKK dictionary is quite simple.  Each line has the
-;; form "KANASTRING /CONV1/CONV2/.../" which means KANASTRING ($B2>L>J8(B
-;; $B;zNs(B) can be converted to one of CONVi.  CONVi is a Kanji ($B4A;z(B)
-;; and Kana ($B2>L>(B) mixed string.
+;; form "KANASTRING /CONV1/CONV2/.../" which means KANASTRING (仮名文
+;; 字列) can be converted to one of CONVi.  CONVi is a Kanji (漢字)
+;; and Kana (仮名) mixed string.
 ;;
-;; KANASTRING may have a trailing ASCII letter for Okurigana ($BAw$j2>L>(B)
+;; KANASTRING may have a trailing ASCII letter for Okurigana (送り仮名)
 ;; information.  For instance, the trailing letter `k' means that one
-;; of the following Okurigana is allowed: $B$+$-$/$1$3(B.  So, in that
-;; case, the string "KANASTRING$B$/(B" can be converted to one of 
"CONV1$B$/(B",
-;; CONV2$B$/(B, ...
+;; of the following Okurigana is allowed: かきくけこ.  So, in that
+;; case, the string "KANASTRINGく" can be converted to one of "CONV1く",
+;; CONV2く, ...
 
 ;;; Code:
 
@@ -76,25 +76,25 @@
 (defconst skkdic-postfix-list '(skkdic-postfix-list))
 
 (defconst skkdic-postfix-data
-  '(("$B$$$-(B" "$B9T(B")
-    ("$B$,$+$j(B" "$B78(B")
-    ("$B$,$/(B" "$B3X(B")
-    ("$B$,$o(B" "address@hidden(B")
-    ("$B$7$c(B" "$B<R(B")
-    ("$B$7$e$&(B" "$B=8(B")
-    ("$B$7$g$&(B" "$B>^(B" "$B>k(B")
-    ("$B$8$g$&(B" "$B>k(B")
-    ("$B$;$s(B" "address@hidden(B")
-    ("address@hidden(B" "$B3Y(B")
-    ("$B$A$c$/(B" "$BCe(B")
-    ("$B$F$s(B" "$BE9(B")
-    ("$B$H$&$2(B" "$BF=(B")
-    ("$B$I$*$j(B" "$BDL$j(B")
-    ("$B$d$^(B" "$B;3(B")
-    ("$B$P$7(B" "$B66(B")
-    ("$B$O$D(B" "$BH/(B")
-    ("$B$b$/(B" "$BL\(B")
-    ("$B$f$-(B" "$B9T(B")))
+  '(("いき" "行")
+    ("がかり" "係")
+    ("がく" "学")
+    ("がわ" "川")
+    ("しゃ" "社")
+    ("しゅう" "集")
+    ("しょう" "賞" "城")
+    ("じょう" "城")
+    ("せん" "線")
+    ("だけ" "岳")
+    ("ちゃく" "着")
+    ("てん" "店")
+    ("とうげ" "峠")
+    ("どおり" "通り")
+    ("やま" "山")
+    ("ばし" "橋")
+    ("はつ" "発")
+    ("もく" "目")
+    ("ゆき" "行")))
 
 (defun skkdic-convert-postfix (skkbuf buf)
   (message "Processing POSTFIX entries ...")
@@ -124,7 +124,7 @@
        (setq l (cdr l)))))
 
   ;; Search postfix entries.
-  (while (re-search-forward "^[#<>?]\\(\\(\\cH\\|$B!<(B\\)+\\) " nil t)
+  (while (re-search-forward "^[#<>?]\\(\\cH+\\) " nil t)
     (let ((kana (match-string-no-properties 1))
          str candidates)
       (while (looking-at "/[#0-9 ]*\\([^/\n]*\\)/")
@@ -157,7 +157,7 @@
     (insert ";; Setting prefix entries.\n"
            "(skkdic-set-prefix\n"))
   (save-excursion
-    (while (re-search-forward "^\\(\\(\\cH\\|$B!<(B\\)+\\)[<>?] " nil t)
+    (while (re-search-forward "^\\(\\cH+\\)[<>?] " nil t)
       (let ((kana (match-string-no-properties 1))
            str candidates)
        (while (looking-at "/\\([^/\n]+\\)/")
@@ -275,11 +275,11 @@
     (let ((progress (make-progress-reporter "Collecting OKURI-NASI entries"
                                             (point) (point-max)
                                             nil 10)))
-      (while (re-search-forward "^\\(\\(\\cH\\|$B!<(B\\)+\\) \\(/\\cj.*\\)/$"
+      (while (re-search-forward "^\\(\\cH+\\) \\(/\\cj.*\\)/$"
                                nil t)
         (let ((kana (match-string-no-properties 1))
-             (candidates (skkdic-get-candidate-list (match-beginning 3)
-                                                    (match-end 3))))
+             (candidates (skkdic-get-candidate-list (match-beginning 2)
+                                                    (match-end 2))))
          (setq skkdic-okuri-nasi-entries
                (cons (cons kana candidates) skkdic-okuri-nasi-entries))
           (progress-reporter-update progress (point))
@@ -452,7 +452,7 @@ To get complete usage, invoke:
       (aset vec i
            (if (< ch 128)              ; CH is an ASCII letter for OKURIGANA,
                (- ch)                  ;  represented by a negative code.
-             (if (= ch ?$B!<(B)              ; `$B!<(B' is represented by 
0.
+             (if (= ch ?ー)             ; `ー' is represented by 0.
                  0
                (- (logand (encode-char ch 'japanese-jisx0208) #xFF) 32))))
       (setq i (1+ i)))
@@ -541,9 +541,4 @@ To get complete usage, invoke:
         map)))
 
 (provide 'ja-dic-cnv)
-
-;; Local Variables:
-;; coding: iso-2022-7bit
-;; End:
-
 ;;; ja-dic-cnv.el ends here
diff --git a/lisp/international/ja-dic-utl.el b/lisp/international/ja-dic-utl.el
index 86ba374..498fb23 100644
--- a/lisp/international/ja-dic-utl.el
+++ b/lisp/international/ja-dic-utl.el
@@ -53,23 +53,23 @@
   "Nested alist for OKURI-NASI entries of SKK dictionary.")
 
 (defconst skkdic-okurigana-table
-  '((?$B$!(B . ?a) (?$B$"(B . ?a) (?$B$#(B . ?i) (?$B$$(B . ?i) 
(?$B$%(B . ?u)
-    (?$B$&(B . ?u) (?$B$'(B . ?e) (?$B$((B . ?e) (?$B$)(B . ?o) 
(?$B$*(B . ?o)
-    (?$B$+(B . ?k) (?$B$,(B . ?g) (?$B$-(B . ?k) (?$B$.(B . ?g) 
(?$B$/(B . ?k)
-    (?$B$0(B . ?g) (?$B$1(B . ?k) (?$B$2(B . ?g) (?$B$3(B . ?k) 
(?$B$4(B . ?g)
-    (?$B$5(B . ?s) (?$B$6(B . ?z) (?$B$7(B . ?s) (?$B$8(B . ?j) 
(?$B$9(B . ?s)
-    (?$B$:(B . ?z) (?$B$;(B . ?s) (?$B$<(B . ?z) (?$B$=(B . ?s) 
(?$B$>(B . ?z)
-    (?$B$?(B . ?t) (address@hidden(B . ?d) (?$B$A(B . ?t) (?$B$B(B . ?d) 
(?$B$C(B . ?t)
-    (?$B$D(B . ?t) (?$B$E(B . ?d) (?$B$F(B . ?t) (?$B$G(B . ?d) 
(?$B$H(B . ?t) (?$B$I(B . ?d)
-    (?$B$J(B . ?n) (?$B$K(B . ?n) (?$B$L(B . ?n) (?$B$M(B . ?n) 
(?$B$N(B . ?n)
-    (?$B$O(B . ?h) (?$B$P(B . ?b) (?$B$Q(B . ?p) (?$B$R(B . ?h) 
(?$B$S(B . ?b)
-    (?$B$T(B . ?p) (?$B$U(B . ?h) (?$B$V(B . ?b) (?$B$W(B . ?p) 
(?$B$X(B . ?h)
-    (?$B$Y(B . ?b) (?$B$Z(B . ?p) (?$B$[(B . ?h) (?$B$\(B . ?b) 
(?$B$](B . ?p)
-    (?$B$^(B . ?m) (?$B$_(B . ?m) (?$B$`(B . ?m) (?$B$a(B . ?m) 
(?$B$b(B . ?m)
-    (?$B$c(B . ?y) (?$B$d(B . ?y) (?$B$e(B . ?y) (?$B$f(B . ?y) 
(?$B$g(B . ?y) (?$B$h(B . ?y)
-    (?$B$i(B . ?r) (?$B$j(B . ?r) (?$B$k(B . ?r) (?$B$l(B . ?r) 
(?$B$m(B . ?r)
-    (?$B$o(B . ?w) (?$B$p(B . ?w) (?$B$q(B . ?w) (?$B$r(B . ?w)
-    (?$B$s(B . ?n)
+  '((?ぁ . ?a) (?あ . ?a) (?ぃ . ?i) (?い . ?i) (?ぅ . ?u)
+    (?う . ?u) (?ぇ . ?e) (?え . ?e) (?ぉ . ?o) (?お . ?o)
+    (?か . ?k) (?が . ?g) (?き . ?k) (?ぎ . ?g) (?く . ?k)
+    (?ぐ . ?g) (?け . ?k) (?げ . ?g) (?こ . ?k) (?ご . ?g)
+    (?さ . ?s) (?ざ . ?z) (?し . ?s) (?じ . ?j) (?す . ?s)
+    (?ず . ?z) (?せ . ?s) (?ぜ . ?z) (?そ . ?s) (?ぞ . ?z)
+    (?た . ?t) (?だ . ?d) (?ち . ?t) (?ぢ . ?d) (?っ . ?t)
+    (?つ . ?t) (?づ . ?d) (?て . ?t) (?で . ?d) (?と . ?t) (?ど . ?d)
+    (?な . ?n) (?に . ?n) (?ぬ . ?n) (?ね . ?n) (?の . ?n)
+    (?は . ?h) (?ば . ?b) (?ぱ . ?p) (?ひ . ?h) (?び . ?b)
+    (?ぴ . ?p) (?ふ . ?h) (?ぶ . ?b) (?ぷ . ?p) (?へ . ?h)
+    (?べ . ?b) (?ぺ . ?p) (?ほ . ?h) (?ぼ . ?b) (?ぽ . ?p)
+    (?ま . ?m) (?み . ?m) (?む . ?m) (?め . ?m) (?も . ?m)
+    (?ゃ . ?y) (?や . ?y) (?ゅ . ?y) (?ゆ . ?y) (?ょ . ?y) (?よ . ?y)
+    (?ら . ?r) (?り . ?r) (?る . ?r) (?れ . ?r) (?ろ . ?r)
+    (?わ . ?w) (?ゐ . ?w) (?ゑ . ?w) (?を . ?w)
+    (?ん . ?n)
     )
   "Alist of Okuriganas vs trailing ASCII letters in OKURI-ARI entry.")
 
@@ -125,14 +125,14 @@ LEIM is available from the same ftp directory as 
Emacs.")))
     ;; At first, generate vector VEC from SEQ for looking up SKK
     ;; alists.  Nth element in VEC corresponds to Nth element in SEQ.
     ;; The values are decided as follows.
-    ;;   If SEQ[N] is `$B!<(B', VEC[N] is 0,
+    ;;   If SEQ[N] is `ー', VEC[N] is 0,
     ;;   else if SEQ[N] is a Hiragana character, VEC[N] is:
     ;;     ((The 2nd position code of SEQ[N]) - 32),
     ;;   else VEC[N] is 128.
     (while (< i len)
       (let ((ch (aref seq i))
            code)
-       (cond ((= ch ?$B!<(B)
+       (cond ((= ch ?ー)
               (aset vec i 0))
              ((and (>= ch (car skkdic-jisx0208-hiragana-block))
                    (<= ch (cdr skkdic-jisx0208-hiragana-block)))
@@ -218,9 +218,4 @@ LEIM is available from the same ftp directory as Emacs.")))
 
 ;;
 (provide 'ja-dic-utl)
-
-;; Local Variables:
-;; coding: iso-2022-7bit
-;; End:
-
 ;;; ja-dic-utl.el ends here
diff --git a/lisp/international/kinsoku.el b/lisp/international/kinsoku.el
index ac660dd..690a80e 100644
--- a/lisp/international/kinsoku.el
+++ b/lisp/international/kinsoku.el
@@ -1,6 +1,6 @@
-;;; kinsoku.el --- `Kinsoku' processing funcs -*- coding: iso-2022-7bit; -*-
+;;; kinsoku.el --- `Kinsoku' processing funcs
 
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -62,19 +62,19 @@ The value 0 means there's no limitation.")
                   idx (1+ idx)))
           str2)
         ;; Katakana JISX0201
-        "(I!#'()*+,-./0^_(B"
+        "。」ァィゥェォャュョッー゙゚"
         ;; Japanese JISX0208
-        "$B!"!#!$!%!&!'!(!)!*!+!,!-!.!/!0!1!2!3!4!5!6!7!8!9!:!;!<!=!>(B\
address@hidden(B\
-$B$!$#$%$'$)$C$c$e$g$n%!%#%%%'%)%C%c%e%g%n%u%v(B"
+        "、。,.・:;?!゛゜´`¨^ ̄_ヽヾゝゞ〃仝々〆〇ー—‐\
+/\〜‖|…‥’”)〕]}〉》」』】°′″℃\
+ぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮヵヶ"
         ;; Chinese GB2312
-        "$A!"!##.#,!$!%!&!'!(!)!*!+!,!-!/!1#)!3!5!7!9!;!=(B\
-$A!?#;#:address@hidden/#\#"#_#~#|(e(B"
+        "、。.,・ˉˇ¨〃々―~‖…’”)〕〉》」』〗\
+】;:?!±×÷∶°′″℃/\"_ ̄|ㄥ"
         ;; Chinese BIG5
-        "$(0!"!#!$!%!&!'!(!)!*!+!,!-!.!/!0!1!2(B\
-$(0!3!4!5!6!7!8!9!:!;!<!=!?!A!C!E!G!I!K(B\
-$(0!M!O!Q!S!U!W!Y![!]!_!a!c!e!g!i!k!q(B\
-$(0"#"$"%"&"'"(")"*"+","2"3"4"j"k"l"x%7(B"))
+        ",、。.‧;:?!︰…‥﹐﹑﹒·﹔\
+﹕﹖﹗|–︱—︳╴︴﹏)︶}︸〕︺】\
+︼》︾〉﹀」﹂』﹄﹚﹜﹞’”〞′〃\
+¯ ̄_ˍ﹉﹊﹍﹎﹋﹌×÷±℃℉﹩°ㄥ"))
        (len (length kinsoku-bol))
        (idx 0)
        ch)
@@ -102,16 +102,16 @@ The value 0 means there's no limitation.")
                   idx (1+ idx)))
           str2)
         ;; JISX0201 Katakana
-        "(I"(B"
+        "「"
         ;; Japanese JISX0208
-        "$B!F!H!J!L!N!P!R!T!V!X!Z!k!l!m!n!w!x(B"
+        "‘“(〔[{〈《「『【°′″℃@§"
         ;; Chinese GB2312
-         "$A!.!0#"#(!2!4!6!8!:!<!>address@hidden(B\
-$A(E(F(G(H(I(J(K(L(M(N(O(P(Q(R(S(T(U(V(W(X(Y(h(B\
-\$(0!>address@hidden(B"
+         "‘“"(〔〈《「『〖【°′″@℃§\
+ㄅㄆㄇㄈㄉㄊㄋㄌㄍㄎㄏㄐㄑㄒㄓㄔㄕㄖㄗㄘㄙㄨ\
+\(︵{︷〔︹【︻《︽〈︿「﹁『﹃﹙﹛﹝"
         ;; Chinese BIG5
-        "$(0!d!f!h!j!k!q!p"i"j"k"n"x$u$v$w$x$y$z${(B\
-$(0$|$}$~%!%"%#%$%%%&%'%(%)%*%+%:(B"))
+        "‘“〝‵′〃§@℃℉﹫°ㄅㄆㄇㄈㄉㄊㄋ\
+ㄌㄍㄎㄏㄐㄑㄒㄓㄔㄕㄖㄗㄘㄙㄨ"))
        (len (length kinsoku-eol))
        (idx 0)
        ch)
diff --git a/lisp/international/kkc.el b/lisp/international/kkc.el
index a56d3cb..6691ee9 100644
--- a/lisp/international/kkc.el
+++ b/lisp/international/kkc.el
@@ -1,6 +1,6 @@
-;;; kkc.el --- Kana Kanji converter    -*- coding: iso-2022-7bit; -*-
+;;; kkc.el --- Kana Kanji converter
 
-;; Copyright (C) 1997-1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -36,7 +36,7 @@
 
 (require 'ja-dic-utl)
 
-(defvar kkc-input-method-title "$B4A(B"
+(defvar kkc-input-method-title "漢"
   "String denoting KKC input method.
 This string is shown at mode line when users are in KKC mode.")
 
diff --git a/lisp/international/latexenc.el b/lisp/international/latexenc.el
index 9afcd6d..83acce6 100644
--- a/lisp/international/latexenc.el
+++ b/lisp/international/latexenc.el
@@ -1,6 +1,6 @@
 ;;; latexenc.el --- guess correct coding system in LaTeX files -*-coding: 
utf-8 -*-
 
-;; Copyright (C) 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005-2019 Free Software Foundation, Inc.
 
 ;; Author: Arne Jørgensen <address@hidden>
 ;; Keywords: mule, coding system, latex
diff --git a/lisp/international/latin1-disp.el 
b/lisp/international/latin1-disp.el
index df2c1dc..1b7bc49 100644
--- a/lisp/international/latin1-disp.el
+++ b/lisp/international/latin1-disp.el
@@ -1,6 +1,6 @@
 ;;; latin1-disp.el --- display tables for other ISO 8859 on Latin-1 terminals 
-*-coding: utf-8;-*-
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Love <address@hidden>
 ;; Keywords: i18n
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index 9335549..dfa9e4e 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -1,6 +1,6 @@
 ;;; mule-cmds.el --- commands for multilingual environment  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -2181,22 +2181,27 @@ See `set-language-info-alist' for use in programs."
 (defconst locale-language-names
   (purecopy
    '(
-    ;; Locale names of the form address@hidden
-    ;; as specified in the Single Unix Spec, Version 2.
-    ;; LANGUAGE is a language code taken from ISO 639:1988 (E/F)
-    ;; with additions from ISO 639/RA Newsletter No.1/1989;
-    ;; see Internet RFC 2165 (1997-06) and
-    ;; http://www.evertype.com/standards/iso639/iso639-en.html
-    ;; TERRITORY is a country code taken from ISO 3166
-    ;; http://www.din.de/gremien/nas/nabd/iso3166ma/codlstp1/en_listp1.html.
-    ;; CODESET and MODIFIER are implementation-dependent.
+     ;; Locale names of the form address@hidden
+     ;; as specified in the Single Unix Spec, Version 2.
+     ;; LANGUAGE is a language code taken from ISO 639:1988 (E/F)
+     ;; with additions from ISO 639/RA Newsletter No.1/1989;
+     ;; see Internet RFC 2165 (1997-06) and
+     ;; http://www.evertype.com/standards/iso639/iso639-en.html
+     ;; TERRITORY is a country code taken from ISO 3166
+     ;; http://www.din.de/gremien/nas/nabd/iso3166ma/codlstp1/en_listp1.html.
+     ;; CODESET and MODIFIER are implementation-dependent.
+
+     ;; Language names for which there are no locales (yet) are
+     ;; commented out.
 
      ;; jasonr comments: MS Windows uses three letter codes for
      ;; languages instead of the two letter ISO codes that POSIX
-     ;; uses. In most cases the first two letters are the same, so
-     ;; most of the regexps in locale-language-names work. Japanese
-     ;; and Chinese are exceptions, which are listed in the
-     ;; non-standard section at the bottom of locale-language-names.
+     ;; uses.  In most cases the first two letters are the same, so
+     ;; most of the regexps in locale-language-names work.  Japanese,
+     ;; Chinese, and some others are exceptions, which are listed in the
+     ;; non-standard section at the bottom of locale-language-names, or
+     ;; in the main section, if otherwise we would pick up the wrong
+     ;; entry (because the first matching entry is used).
 
     ("aa_DJ" . "Latin-1") ; Afar
     ("aa" . "UTF-8")
@@ -2204,11 +2209,12 @@ See `set-language-info-alist' for use in programs."
     ("af" . "Latin-1") ; Afrikaans
     ("am" "Ethiopic" utf-8) ; Amharic
     ("an" . "Latin-9") ; Aragonese
+    ("arn" . "UTF-8") ; MS-Windows Mapudungun, Mapuche
     ("ar" . "Arabic")
-    ; as Assamese
+    ("as" . "UTF-8") ; Assamese
     ; ay Aymara
     ("az" . "UTF-8") ; Azerbaijani
-    ; ba Bashkir
+    ("ba" . "UTF-8") ; Bashkir, Cyrillic script
     ("be" "Belarusian" cp1251) ; Belarusian [Byelorussian until early 1990s]
     ("bg" "Bulgarian" cp1251) ; Bulgarian
     ; bh Bihari
@@ -2219,12 +2225,12 @@ See `set-language-info-alist' for use in programs."
     ("bs" . "Latin-2") ; Bosnian
     ("byn" . "UTF-8")  ; Bilin; Blin
     ("ca" "Catalan" iso-8859-1) ; Catalan
-    ; co Corsican
+    ("co" . "UTF-8") ; Corsican
     ("cs" "Czech" iso-8859-2)
     ("cy" "Welsh" iso-8859-14)
     ("da" . "Latin-1") ; Danish
     ("de" "German" iso-8859-1)
-    ; dv Divehi
+    ("dv" . "UTF-8") ; Divehi
     ; dz Bhutani
     ("ee" . "Latin-4") ; Ewe
     ("el" "Greek" iso-8859-7)
@@ -2238,6 +2244,8 @@ See `set-language-info-alist' for use in programs."
     ("et" . "Latin-9") ; Estonian
     ("eu" . "Latin-1") ; Basque
     ("fa" "Persian" utf-8) ; Persian
+    ("fil" . "UTF-8") ; Filipino
+    ("fpo" . "UTF-8") ; MS-Windows Filipino
     ("fi" . "Latin-9") ; Finnish
     ("fj" . "Latin-1") ; Fiji
     ("fo" . "Latin-1") ; Faroese
@@ -2246,6 +2254,7 @@ See `set-language-info-alist' for use in programs."
     ("ga" . "Latin-1") ; Irish Gaelic (new orthography)
     ("gd" . "Latin-9") ; Scots Gaelic
     ("gez" "Ethiopic" utf-8) ; Geez
+    ("gla" . "Latin-9") ; MS-Windows Scots Gaelic
     ("gl" . "Latin-1") ; Gallegan; Galician
     ; gn Guarani
     ("gu" "Gujarati" utf-8) ; Gujarati
@@ -2256,27 +2265,33 @@ See `set-language-info-alist' for use in programs."
     ("hni_IN" . "UTF-8") ; Chhattisgarhi
     ("hr" "Croatian" iso-8859-2) ; Croatian
     ("hu" . "Latin-2") ; Hungarian
-    ; hy Armenian
+    ("hy" . "UTF-8") ;  Armenian
     ; ia Interlingua
     ("id" . "Latin-1") ; Indonesian
     ; ie Interlingue
-    ; ik Inupiak
+    ("ig" . "UTF-8") ; Igbo (Nigeria)
+    ("ibo" . "UTF-8") ; MS-Windows Igbo
+    ; ik Inupiak, Inupiaq
     ("is" . "Latin-1") ; Icelandic
     ("it" "Italian" iso-8859-1) ; Italian
     ; iu Inuktitut
     ("iw" "Hebrew" iso-8859-8)
     ("ja" "Japanese" euc-jp)
     ; jw Javanese
+    ("kal" . "Latin-1") ; MS-Windows Greenlandic
     ("ka" "Georgian" georgian-ps) ; Georgian
-    ; kk Kazakh
+    ("kk" . "UTF-8") ; Kazakh
     ("kl" . "Latin-1") ; Greenlandic
     ("km" "Khmer" utf-8) ; Cambodian, Khmer
+    ("knk" "Devanagari" utf-8) ; MS-Windows Konkani
+    ("kok" "Devanagari" utf-8) ; Konkani
     ("kn" "Kannada" utf-8)
     ("ko" "Korean" euc-kr)
     ("ks" . "UTF-8") ; Kashmiri
     ; ku Kurdish
     ("kw" . "Latin-1") ; Cornish
     ("ky" . "UTF-8") ; Kirghiz
+    ("lao" "Lao" utf-8) ; MS-Windows Lao
     ("la" . "Latin-1") ; Latin
     ("lb" . "Latin-1") ; Luxemburgish
     ("lg" . "Latin-6") ; Ganda, a.k.a. Luganda
@@ -2287,18 +2302,22 @@ See `set-language-info-alist' for use in programs."
     ; mg Malagasy
     ("mi" . "Latin-7") ; Maori
     ("mk" "Cyrillic-ISO" iso-8859-5) ; Macedonian
+    ("mlt" . "Latin-3") ; MS-Windows Maltese
     ("ml" "Malayalam" utf-8)
     ("mn" . "UTF-8") ; Mongolian
-    ; mo Moldavian
+    ; mo Moldavian (retired)
+    ("mri" . "Latin-7") ; MS-Windows Maori
     ("mr" "Devanagari" utf-8) ; Marathi
     ("ms" . "Latin-1") ; Malay
     ("mt" . "Latin-3") ; Maltese
+    ("mym" "Malayalam" utf-8) ; MS-Windows Malayalam
     ("my" "Burmese" utf-8) ; Burmese
     ; na Nauru
     ("nb" . "Latin-1") ; Norwegian
     ("ne" "Devanagari" utf-8) ; Nepali
     ("nl" "Dutch" iso-8859-1)
     ("nn" . "Latin-1") ; Norwegian Nynorsk
+    ("non" . "Latin-1") ; MS-Windows Norwegian Nynorsk
     ("no" . "Latin-1") ; Norwegian
     ("nr_ZA" . "UTF-8") ; South Ndebele
     ("nso_ZA" . "UTF-8") ; Pedi
@@ -2308,7 +2327,8 @@ See `set-language-info-alist' for use in programs."
     ("or" "Oriya" utf-8)
     ("pa" "Punjabi" utf-8) ; Punjabi
     ("pl" "Polish" iso-8859-2) ; Polish
-    ; ps Pashto, Pushto
+    ("ps" . "UTF-8") ; Pashto, Pushto
+    ("pas" . "UTF-8") ; MS-Windows Pashto
     ("pt_BR" "Brazilian Portuguese" iso-8859-1) ; Brazilian Portuguese
     ("pt" . "Latin-1") ; Portuguese
     ; qu Quechua
@@ -2318,7 +2338,7 @@ See `set-language-info-alist' for use in programs."
     ("ru_RU.koi8r" "Cyrillic-KOI8" koi8-r)
     ("ru_RU" "Russian" iso-8859-5)
     ("ru_UA" "Russian" koi8-u)
-    ; rw Kinyarwanda
+    ("rw" . "UTF-8") ; Kinyarwanda
     ("sa" . "Devanagari") ; Sanskrit
     ; sd Sindhi
     ("se" . "UTF-8") ; Northern Sami
@@ -2339,6 +2359,7 @@ See `set-language-info-alist' for use in programs."
     ; su Sundanese
     ("sv" "Swedish" iso-8859-1)                ; Swedish
     ("sw" . "Latin-1") ; Swahili
+    ("taj" "Tajik" koi8-t) ; MS-Windows Tajik w/Cyrillic script
     ("ta" "Tamil" utf-8)
     ("te" "Telugu" utf-8) ; Telugu
     ("tg" "Tajik" koi8-t)
@@ -2348,15 +2369,17 @@ See `set-language-info-alist' for use in programs."
     ("th" "Thai" iso-8859-11)
     ("ti" "Ethiopic" utf-8) ; Tigrinya
     ("tig_ER" . "UTF-8") ; Tigre
-    ; tk Turkmen
+    ("tk" . "Latin-5") ; Turkmen
+    ("tuk" . "Latin-5") ; MS-Windows Turkmen
     ("tl" . "Latin-1") ; Tagalog
     ("tn" . "Latin-9") ; Setswana, Tswana
     ; to Tonga
     ("tr" "Turkish" iso-8859-9)
+    ("tsn" . "Latin-9") ; MS-Windows Tswana
     ("ts" . "Latin-1") ; Tsonga
     ("tt" . "UTF-8") ; Tatar
     ; tw Twi
-    ; ug Uighur
+    ("ug" . "UTF-8") ; Uighur
     ("uk" "Ukrainian" koi8-u)
     ("ur" . "UTF-8") ; Urdu
     ("address@hidden" . "UTF-8"); Uzbek
@@ -2365,10 +2388,10 @@ See `set-language-info-alist' for use in programs."
     ("vi" "Vietnamese" utf-8)
     ; vo Volapuk
     ("wa" . "Latin-1") ; Walloon
-    ; wo Wolof
+    ("wo" . "UTF-8") ; Wolof
     ("xh" . "Latin-1") ; Xhosa
     ("yi" . "Windows-1255") ; Yiddish
-    ; yo Yoruba
+    ("yo" . "UTF-8") ; Yoruba
     ; za Zhuang
     ("zh_HK" . "Chinese-Big5")
     ; zh_HK/BIG5-HKSCS \
@@ -2378,6 +2401,9 @@ See `set-language-info-alist' for use in programs."
     ("zh_CN.GB18030" "Chinese-GB18030")
     ("zh_CN.UTF-8" . "Chinese-GBK")
     ("zh_CN" . "Chinese-GB")
+    ("zhh" . "Chinese-Big5") ; MS-Windows Chinese (Hong Kong S.A.R.)
+    ("zhi" . "Chinese-GBK") ; MS-Windows Chinese (Singapore)
+    ("zhm" . "Chinese-Big5") ; MS-Windows Chinese (Macao S.A.R.)
     ("zh" . "Chinese-GB")
     ("zu" . "Latin-1") ; Zulu
 
@@ -2395,12 +2421,23 @@ See `set-language-info-alist' for use in programs."
     ("sp" . "Cyrillic-ISO") ; Serbian (Cyrillic alphabet), e.g. X11R6.4
     ("su" . "Latin-1") ; Finnish, e.g. Solaris 2.6
     ("jp" . "Japanese") ; e.g. MS Windows
-    ("chs" . "Chinese-GBK") ; MS Windows Chinese Simplified
-    ("cht" . "Chinese-BIG5") ; MS Windows Chinese Traditional
+    ("chs" . "Chinese-GBK") ; MS Windows Chinese Simplified (PRC)
+    ("cht" . "Chinese-BIG5") ; MS Windows Chinese Traditional (Taiwan)
     ("gbz" . "UTF-8") ; MS Windows Dari Persian
     ("div" . "UTF-8") ; MS Windows Divehi (Maldives)
     ("wee" . "Latin-2") ; MS Windows Lower Sorbian
     ("wen" . "Latin-2") ; MS Windows Upper Sorbian
+    ("ind" . "Latin-1") ; MS-Windows Indonesian
+    ("sme" . "UTF-8") ; MS-Windows Northern Sami (Norway)
+    ("smf" . "UTF-8") ; MS-Windows Northern Sami (Sweden)
+    ("smg" . "UTF-8") ; MS-Windows Northern Sami (Finland)
+    ("kdi" "Kannada" utf-8) ; MS-Windows Kannada
+    ("mar" "Devanagari" utf-8) ; MS-Windows Marathi
+    ("khm" "Khmer" utf-8) ; MS-Windows Khmer
+    ("iri" . "Latin-1") ; MS-Windows Irish Gaelic
+    ; mwk  MS-Windows Mohawk (Canada)
+    ("uig" . "UTF-8") ; MS-Windows Uighur
+    ("kin" . "UTF-8") ;  MS-Windows Kinyarwanda
     ))
   "Alist of locale regexps vs the corresponding languages and coding systems.
 Each element has this form:
@@ -2702,10 +2739,20 @@ See also `locale-charset-language-names', 
`locale-language-names',
              (output-coding
               (if noninteractive
                   (intern (format "cp%d" (w32-get-console-output-codepage)))
-                code-page-coding)))
-       (when (coding-system-p code-page-coding)
+                code-page-coding))
+             (multibyte-code-page-coding
+              (or (and (boundp 'w32-multibyte-code-page)
+                       (not (zerop w32-multibyte-code-page))
+                       (intern (format "cp%d" w32-multibyte-code-page)))
+                  code-page-coding))
+             (locale-coding
+              (if noninteractive
+                  code-page-coding
+                multibyte-code-page-coding)))
+       (when (and (coding-system-p code-page-coding)
+                   (coding-system-p locale-coding))
           (or output-coding (setq output-coding code-page-coding))
-         (unless frame (setq locale-coding-system code-page-coding))
+         (unless frame (setq locale-coding-system locale-coding))
          (set-keyboard-coding-system code-page-coding frame)
          (set-terminal-coding-system output-coding frame)
          (setq default-file-name-coding-system ansi-code-page-coding))))
@@ -2727,7 +2774,6 @@ See also `locale-charset-language-names', 
`locale-language-names',
       (let ((paper (locale-info 'paper))
             locale)
        (if paper
-           ;; This will always be null at the time of writing.
            (cond
             ((equal paper '(216 279))
              (setq ps-paper-type 'letter))
@@ -2930,12 +2976,13 @@ on encoding."
                (#x14400 . #x14646)
               ;; (#x14647 . #x167FF) unused
               (#x16800 . #x16F9F)
-               (#x16FE0 . #x16FE0)
+               (#x16FE0 . #x16FE3)
                ;; (#x17000 . #x187FF) Tangut Ideographs
                ;; (#x18800 . #x18AFF) Tangut Components
               ;; (#x18B00 . #x1AFFF) unused
-              (#x1B000 . #x1B12F)
-               ;; (#x1B130 . #x1B16F) unused
+              (#x1B000 . #x1B11F)
+               ;; (#x1B120 . #x1B14F) unused
+               (#x1B150 . #x1B16F)
                (#x1B170 . #x1B2FF)
               ;; (#x1B300 . #x1BBFF) unused
                (#x1BC00 . #x1BCAF)
diff --git a/lisp/international/mule-conf.el b/lisp/international/mule-conf.el
index 02323ea..c84dc81 100644
--- a/lisp/international/mule-conf.el
+++ b/lisp/international/mule-conf.el
@@ -1,6 +1,6 @@
 ;;; mule-conf.el --- configure multilingual environment
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 
2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
 ;;   Registration Number H14PRO021
diff --git a/lisp/international/mule-diag.el b/lisp/international/mule-diag.el
index c9829e3..472529f 100644
--- a/lisp/international/mule-diag.el
+++ b/lisp/international/mule-diag.el
@@ -1,6 +1,6 @@
 ;;; mule-diag.el --- show diagnosis of multilingual environment (Mule)
 
-;; Copyright (C) 1997-1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2000-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/international/mule-util.el b/lisp/international/mule-util.el
index 17bea54..8ad2127 100644
--- a/lisp/international/mule-util.el
+++ b/lisp/international/mule-util.el
@@ -1,6 +1,6 @@
 ;;; mule-util.el --- utility functions for multilingual environment (mule)  
-*- lexical-binding:t -*-
 
-;; Copyright (C) 1997-1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2000-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/international/mule.el b/lisp/international/mule.el
index 31003d1..ba30fee 100644
--- a/lisp/international/mule.el
+++ b/lisp/international/mule.el
@@ -1,6 +1,6 @@
 ;;; mule.el --- basic commands for multilingual environment
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -343,7 +343,7 @@ Return t if file exists."
            ;; Have the original buffer current while we eval.
            (eval-buffer buffer nil
                         ;; This is compatible with what `load' does.
-                        (if purify-flag file fullname)
+                         (if dump-mode file fullname)
                         nil t))
        (let (kill-buffer-hook kill-buffer-query-functions)
          (kill-buffer buffer)))
@@ -819,10 +819,10 @@ VALUE is a CCL program name defined by 
`define-ccl-program'.  The
 CCL program reads a character sequence and writes a byte sequence
 as an encoding result.
 
-`:inhibit-null-byte-detection'
+`:inhibit-nul-byte-detection'
 
 VALUE non-nil means Emacs ignore null bytes on code detection.
-See the variable `inhibit-null-byte-detection'.  This attribute
+See the variable `inhibit-nul-byte-detection'.  This attribute
 is meaningful only when `:coding-type' is `undecided'.
 
 `:inhibit-iso-escape-detection'
@@ -867,7 +867,7 @@ non-ASCII files.  This attribute is meaningful only when
                                      :ccl-encoder
                                      :valids))
                                   ((eq coding-type 'undecided)
-                                   '(:inhibit-null-byte-detection
+                                   '(:inhibit-nul-byte-detection
                                      :inhibit-iso-escape-detection
                                      :prefer-utf-8))))))
 
@@ -920,8 +920,8 @@ non-ASCII files.  This attribute is meaningful only when
          (cons :name (cons name (cons :docstring (cons (purecopy docstring)
                                                        props)))))
     (setcdr (assq :plist common-attrs) props)
-    (apply 'define-coding-system-internal
-          name (mapcar 'cdr (append common-attrs spec-attrs)))))
+    (apply #'define-coding-system-internal
+          name (mapcar #'cdr (append common-attrs spec-attrs)))))
 
 (defun coding-system-doc-string (coding-system)
   "Return the documentation string for CODING-SYSTEM."
@@ -1852,9 +1852,12 @@ or nil."
 
 Each function in this list should be written to operate on the
 current buffer, but should not modify it in any way.  The buffer
-will contain undecoded text of parts of the file.  Each function
+will contain the text of parts of the file.  Each function
 should take one argument, SIZE, which says how many characters
-\(starting from point) it should look at.
+\(starting from point) it should look at.  The function might be
+called both when the file is visited and Emacs wants to decode
+its contents, and when the file's buffer is about to be saved
+and Emacs wants to determine how to encode its contents.
 
 If one of these functions succeeds in determining a coding
 system, it should return that coding system.  Otherwise, it
@@ -2501,10 +2504,17 @@ This function is intended to be added to 
`auto-coding-functions'."
                   (let ((sym-type (coding-system-type sym))
                         (bfcs-type
                          (coding-system-type buffer-file-coding-system)))
-                    ;; 'charset' will signal an error in
-                    ;; coding-system-equal, since it isn't a
-                    ;; coding-system.  So test that up front.
-                    (if (and (not (equal sym-type 'charset))
+                    ;; If the buffer is unibyte, its encoding is
+                    ;; immaterial (it is just the default value of
+                    ;; buffer-file-coding-system), so we ignore it.
+                    ;; This situation happens when this function is
+                    ;; called as part of visiting a file, as opposed
+                    ;; to when saving a buffer to a file.
+                    (if (and enable-multibyte-characters
+                             ;; 'charset' will signal an error in
+                             ;; coding-system-equal, since it isn't a
+                             ;; coding-system.  So test that up front.
+                             (not (equal sym-type 'charset))
                              (coding-system-equal 'utf-8 sym-type)
                              (coding-system-equal 'utf-8 bfcs-type))
                         buffer-file-coding-system
@@ -2545,7 +2555,7 @@ This function is intended to be added to 
`auto-coding-functions'."
     ;; (allowing for whitespace at bob).  Note: 'DOCTYPE NETSCAPE' is
     ;; useful for Mozilla bookmark files.
     (when (and (re-search-forward 
"\\`[[:space:]\n]*\\(<!doctype[[:space:]\n]+\\(html\\|netscape\\)\\|<html\\)" 
size t)
-              (re-search-forward 
"<meta\\s-+\\(http-equiv=[\"']?content-type[\"']?\\s-+content=[\"']text/\\sw+;\\s-*\\)?charset=[\"']?\\(.+?\\)[\"'\\s-/>]"
 size t))
+              (re-search-forward 
"<meta\\s-+\\(http-equiv=[\"']?content-type[\"']?\\s-+content=[\"']text/\\sw+;\\s-*\\)?charset=[\"']?\\(.+?\\)[\"'[:space:]/>]"
 size t))
       (let* ((match (match-string 2))
             (sym (intern (downcase match))))
        (if (coding-system-p sym)
@@ -2556,7 +2566,8 @@ This function is intended to be added to 
`auto-coding-functions'."
             (let ((sym-type (coding-system-type sym))
                   (bfcs-type
                    (coding-system-type buffer-file-coding-system)))
-              (if (and (coding-system-equal 'utf-8 sym-type)
+              (if (and enable-multibyte-characters
+                       (coding-system-equal 'utf-8 sym-type)
                        (coding-system-equal 'utf-8 bfcs-type))
                   buffer-file-coding-system
                sym))
diff --git a/lisp/international/ogonek.el b/lisp/international/ogonek.el
index fe3e340..543f2e3 100644
--- a/lisp/international/ogonek.el
+++ b/lisp/international/ogonek.el
@@ -1,6 +1,6 @@
 ;;; ogonek.el --- change the encoding of Polish diacritics
 
-;; Copyright (C) 1997-1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Włodek Bzyl
 ;;        Ryszard Kubiak
diff --git a/lisp/international/quail.el b/lisp/international/quail.el
index ec15cca..3266b93 100644
--- a/lisp/international/quail.el
+++ b/lisp/international/quail.el
@@ -1,6 +1,6 @@
 ;;; quail.el --- provides simple input method for multilingual text
 
-;; Copyright (C) 1997-1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2000-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -568,7 +568,7 @@ While this input method is active, the variable
            (quail-delete-overlays)
            (setq describe-current-input-method-function nil)
            (quail-hide-guidance)
-           (remove-hook 'post-command-hook 'quail-show-guidance t)
+           (remove-hook 'post-command-hook #'quail-show-guidance t)
            (run-hooks 'quail-deactivate-hook))
        (kill-local-variable 'input-method-function))
     ;; Let's activate Quail input method.
@@ -579,19 +579,18 @@ While this input method is active, the variable
              (setq name (car (car quail-package-alist)))
            (error "No Quail package loaded"))
          (quail-select-package name)))
-    (setq deactivate-current-input-method-function 'quail-deactivate)
-    (setq describe-current-input-method-function 'quail-help)
+    (setq deactivate-current-input-method-function #'quail-deactivate)
+    (setq describe-current-input-method-function #'quail-help)
     (quail-delete-overlays)
     (setq quail-guidance-str "")
     (quail-show-guidance)
     ;; If we are in minibuffer, turn off the current input method
     ;; before exiting.
     (when (eq (selected-window) (minibuffer-window))
-      (add-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer)
-      (add-hook 'post-command-hook 'quail-show-guidance nil t))
+      (add-hook 'minibuffer-exit-hook #'quail-exit-from-minibuffer)
+      (add-hook 'post-command-hook #'quail-show-guidance nil t))
     (run-hooks 'quail-activate-hook)
-    (make-local-variable 'input-method-function)
-    (setq input-method-function 'quail-input-method)))
+    (setq-local input-method-function #'quail-input-method)))
 
 (define-obsolete-variable-alias
   'quail-inactivate-hook
@@ -1367,9 +1366,7 @@ If STR has `advice' text property, append the following 
special event:
   (let ((start (overlay-start overlay))
        (end (overlay-end overlay)))
     (if (< start end)
-       (prog1
-           (string-to-list (buffer-substring start end))
-         (delete-region start end)))))
+       (string-to-list (delete-and-extract-region start end)))))
 
 (defsubst quail-delete-region ()
   "Delete the text in the current translation region of Quail."
diff --git a/lisp/international/rfc1843.el b/lisp/international/rfc1843.el
index 84231d3..545ee4e 100644
--- a/lisp/international/rfc1843.el
+++ b/lisp/international/rfc1843.el
@@ -1,6 +1,6 @@
 ;;; rfc1843.el --- HZ (rfc1843) decoding  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Shenghuo Zhu <address@hidden>
 ;; Keywords: news HZ HZ+ mail i18n
diff --git a/lisp/international/titdic-cnv.el b/lisp/international/titdic-cnv.el
index e6ba3ad..e6065fb 100644
--- a/lisp/international/titdic-cnv.el
+++ b/lisp/international/titdic-cnv.el
@@ -1,6 +1,6 @@
-;;; titdic-cnv.el --- convert cxterm dictionary (TIT format) to Quail package 
-*- coding:iso-2022-7bit; -*-
+;;; titdic-cnv.el --- convert cxterm dictionary (TIT format) to Quail package 
-*- coding: utf-8-emacs; lexical-binding:t -*-
 
-;; Copyright (C) 1997-1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2000-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -83,9 +83,9 @@
 ;; how to select a translation from a list of candidates.
 
 (defvar quail-cxterm-package-ext-info
-  '(("chinese-4corner" "$(0(?-F(B")
-    ("chinese-array30" "$(0#R#O(B")
-    ("chinese-ccdospy" "$AKuF4(B"
+  '(("chinese-4corner" "四角")
+    ("chinese-array30" "30")
+    ("chinese-ccdospy" "缩拼"
      "Pinyin base input method for Chinese charset GB2312 (`chinese-gb2312').
 
 Pinyin is the standard Roman transliteration method for Chinese.
@@ -94,10 +94,10 @@ method `chinese-py'.
 
 This input method works almost the same way as `chinese-py'.  The
 difference is that you type a single key for these Pinyin spelling.
-    Pinyin:  zh  en  eng ang ch  an  ao  ai  ong sh  ing  yu($A(9(B)
+    Pinyin:  zh  en  eng ang ch  an  ao  ai  ong sh  ing  yu(ü)
     keyseq:   a   f   g   h   i   j   k   l   s   u   y   v
 For example:
-    Chinese:  $A0!(B    $A9{(B    $AVP(B    $AND(B    $A9b(B    
$ASq(B    $AH+(B
+    Chinese:  啊    果    中    文    光    玉    全
     Pinyin:   a    guo   zhong  wen  guang  yu   quan
     Keyseq:   a1   guo4   as1   wf4  guh1  yu..6 qvj6
 
@@ -106,14 +106,14 @@ For example:
 For double-width GB2312 characters corresponding to ASCII, use the
 input method `chinese-qj'.")
 
-    ("chinese-ecdict" "$(05CKH(B"
+    ("chinese-ecdict" "英漢"
 "In this input method, you enter a Chinese (Big5) character or word
 by typing the corresponding English word.  For example, if you type
-\"computer\", \"$(0IZH+(B\" is input.
+\"computer\", \"電腦\" is input.
 
 \\<quail-translation-docstring>")
 
-    ("chinese-etzy" "$(06/0D(B"
+    ("chinese-etzy" "倚注"
 "Zhuyin base input method for Chinese Big5 characters (`chinese-big5-1',
 `chinese-big5-2').
 
@@ -122,20 +122,20 @@ compose one Chinese character.
 
 In this input method, you enter a Chinese character by first typing
 keys corresponding to Zhuyin symbols (see the above table) followed by
-SPC, 1, 2, 3, or 4 specifying a tone (SPC:$(0?v(N(B, 1:$(0M=Vy(B, 
2:$(0Dm(N(B, 3: $(0&9Vy(B,
-4:$(0(+Vy(B).
+SPC, 1, 2, 3, or 4 specifying a tone (SPC:陰平, 1:輕聲, 2:陽平, 3: 上聲,
+4:去聲).
 
 \\<quail-translation-docstring>")
 
-    ("chinese-punct-b5" "$(0O:(BB"
+    ("chinese-punct-b5" "標B"
      "Input method for Chinese punctuation and symbols of Big5
 \(`chinese-big5-1' and `chinese-big5-2').")
 
-    ("chinese-punct" "$A1j(BG"
+    ("chinese-punct" "标G"
      "Input method for Chinese punctuation and symbols of GB2312
 \(`chinese-gb2312').")
 
-    ("chinese-py-b5" "$(03<(BB"
+    ("chinese-py-b5" "拼B"
      "Pinyin base input method for Chinese Big5 characters
 \(`chinese-big5-1', `chinese-big5-2').
 
@@ -153,28 +153,28 @@ method `chinese-qj-b5'.
 The input method `chinese-py' and `chinese-tonepy' are also Pinyin
 based, but for the character set GB2312 (`chinese-gb2312').")
 
-    ("chinese-qj-b5" "$(0)A(BB")
+    ("chinese-qj-b5" "全B")
 
-    ("chinese-qj" "$AH+(BG")
+    ("chinese-qj" "全G")
 
-    ("chinese-sw" "$AJWN2(B"
+    ("chinese-sw" "首尾"
 "Radical base input method for Chinese charset GB2312 (`chinese-gb2312').
 
 In this input method, you enter a Chinese character by typing two
-keys.  The first key corresponds to the first ($AJW(B) radical, the second
-key corresponds to the last ($AN2(B) radical.  The correspondence of keys
+keys.  The first key corresponds to the first (首) radical, the second
+key corresponds to the last (尾) radical.  The correspondence of keys
 and radicals is as below:
 
  first radical:
  a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z
- $APD(B $AZ"(B $AJ,(B $AX<(B $A;p(B $A?Z(B $A^P(B $Ac_(B 
$AZ%(B $A\3(B $AXi(B $AD>(B $Alj(B $Ab;(B $ATB(B $Afy(B 
$AJ/(B $AMu(B $A0K(B $AX/(B $AHU(B $AeA(B $Aak(B $AVq(B 
$AR;(B $AHK(B
+ 心 冖 尸 丶 火 口 扌 氵 讠 艹 亻 木 礻 饣 月 纟 石 王 八 丿 日 辶 犭 竹 一 人
  last radical:
  a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z
- $ASV(B $AI=(B $AMA(B $A56(B $AZb(B $A?Z(B $ARB(B $Aqb(B 
$A4s(B $A6!(B $A[L(B $Ala(B $AJ.(B $A4u(B $AXg(B $ACE(B 
$A=q(B $AX-(B $AE.(B $ARR(B $A`m(B $AP!(B $A3'(B $A3f(B 
$A_.(B $A27(B
+ 又 山 土 刀 阝 口 衣 疋 大 丁 厶 灬 十 歹 冂 门 今 丨 女 乙 囗 小 厂 虫 弋 卜
 
 \\<quail-translation-docstring>")
 
-    ("chinese-tonepy" "$A5wF4(B"
+    ("chinese-tonepy" "调拼"
      "Pinyin base input method for Chinese charset GB2312 (`chinese-gb2312').
 
 Pinyin is the standard roman transliteration method for Chinese.
@@ -183,18 +183,18 @@ method `chinese-py'.
 
 This input method works almost the same way as `chinese-py'.  The
 difference is that you must type 1..5 after each Pinyin spelling to
-specify a tone (1:$ARuF=(B, 2:$AQtF=(B, 3:$AIOIy(B, 4$AOBIy(B, 
5:$AGaIy(B).
+specify a tone (1:阴平, 2:阳平, 3:上声, 4下声, 5:轻声).
 
 \\<quail-translation-docstring>
 
-For instance, to input $ADc(B, you type \"n i 3 3\", the first \"n i\" is
+For instance, to input 你, you type \"n i 3 3\", the first \"n i\" is
 a Pinyin, the next \"3\" specifies tone, and the last \"3\" selects
 the third character from the candidate list.
 
 For double-width GB2312 characters corresponding to ASCII, use the
 input method `chinese-qj'.")
 
-    ("chinese-zozy" "$(0I\0D(B"
+    ("chinese-zozy" "零注"
 "Zhuyin base input method for Chinese Big5 characters (`chinese-big5-1',
 `chinese-big5-2').
 
@@ -203,8 +203,8 @@ compose a Chinese character.
 
 In this input method, you enter a Chinese character by first typing
 keys corresponding to Zhuyin symbols (see the above table) followed by
-SPC, 6, 3, 4, or 7 specifying a tone (SPC:$(0?v(N(B, 6:$(0Dm(N(B, 
3:$(0&9Vy(B, 4:$(0(+Vy(B,
-7:$(0M=Vy(B).
+SPC, 6, 3, 4, or 7 specifying a tone (SPC:陰平, 6:陽平, 3:上聲, 4:去聲,
+7:輕聲).
 
 \\<quail-translation-docstring>")))
 
@@ -348,7 +348,7 @@ SPC, 6, 3, 4, or 7 specifying a tone (SPC:$(0?v(N(B, 
6:$(0Dm(N(B, 3:$(0&9Vy
       (princ (nth 2 (assoc tit-encode tit-encode-list)))
       (princ "\" \"")
       (princ (or title
-                (if (string-match 
"[:$A!K$(0!(!J(B]+\\([^:$A!K$(0!(!K(B]+\\)" tit-prompt)
+                (if (string-match "[:∷:【]+\\([^:∷:】]+\\)" tit-prompt)
                     (substring tit-prompt (match-beginning 1) (match-end 1))
                   tit-prompt)))
       (princ "\"\n"))
@@ -417,9 +417,7 @@ SPC, 6, 3, 4, or 7 specifying a tone (SPC:$(0?v(N(B, 
6:$(0Dm(N(B, 3:$(0&9Vy
 ;; function call.
 (defun tit-process-body ()
   (message "Formatting translation rules...")
-  (let* ((template (list nil nil))
-        (second (cdr template))
-        (prev-key "")
+  (let* ((prev-key "")
         ch key translations pos)
     (princ "(quail-define-rules\n")
     (while (null (eobp))
@@ -500,8 +498,7 @@ the generated Quail package is saved."
            (goto-char (point-min))
            (decode-coding-region (point-min) (point-max) coding-system)
            ;; Explicitly set eol format to `unix'.
-           (setq coding-system-for-write
-                 (coding-system-change-eol-conversion coding-system 'unix))
+           (setq coding-system-for-write 'utf-8-unix)
            (remove-text-properties (point-min) (point-max) '(charset nil)))
 
          (set-buffer-multibyte t)
@@ -522,7 +519,6 @@ the generated Quail package is saved."
          (princ ";; Local Variables:\n")
          (princ ";; version-control: never\n")
          (princ ";; no-update-autoloads: t\n")
-         (princ (format ";; coding: %s\n" coding-system-for-write))
          (princ ";; End:\n"))))))
 
 ;;;###autoload
@@ -581,7 +577,7 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
 ;;    )
 
 (defvar quail-misc-package-ext-info
-  '(("chinese-b5-tsangchi" "$(06A(BB"
+  '(("chinese-b5-tsangchi" "倉B"
      "cangjie-table.b5" big5 "tsang-b5.el"
      tsang-b5-converter
      "\
@@ -591,7 +587,7 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
 ;; # unmodified versions is granted without royalty provided
 ;; # this notice is preserved.")
 
-    ("chinese-b5-quick" "$(0X|(BB"
+    ("chinese-b5-quick" "簡B"
      "cangjie-table.b5" big5 "quick-b5.el"
      quick-b5-converter
      "\
@@ -601,7 +597,7 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
 ;; # unmodified versions is granted without royalty provided
 ;; # this notice is preserved.")
 
-    ("chinese-cns-tsangchi" "$(GT?(BC"
+    ("chinese-cns-tsangchi" "倉C"
      "cangjie-table.cns" iso-2022-cn-ext "tsang-cns.el"
      tsang-cns-converter
      "\
@@ -611,7 +607,7 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
 ;; # unmodified versions is granted without royalty provided
 ;; # this notice is preserved.")
 
-    ("chinese-cns-quick" "$(Gv|(BC"
+    ("chinese-cns-quick" "簡C"
      "cangjie-table.cns" iso-2022-cn-ext "quick-cns.el"
      quick-cns-converter
      "\
@@ -621,7 +617,7 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
 ;; # unmodified versions is granted without royalty provided
 ;; # this notice is preserved.")
 
-    ("chinese-py" "$AF4(BG"
+    ("chinese-py" "拼G"
      "pinyin.map" cn-gb-2312 "PY.el"
      py-converter
      "\
@@ -649,7 +645,7 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
 ;; You should have received a copy of the GNU General Public License along with
 ;; CCE.  If not, see <https://www.gnu.org/licenses/>.")
 
-    ("chinese-ziranma" "$AWTH;(B"
+    ("chinese-ziranma" "自然"
      "ziranma.cin" cn-gb-2312 "ZIRANMA.el"
      ziranma-converter
      "\
@@ -677,7 +673,7 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
 ;; You should have received a copy of the GNU General Public License along with
 ;; CCE.  If not, see <https://www.gnu.org/licenses/>.")
 
-    ("chinese-ctlau" "$AAuTA(B"
+    ("chinese-ctlau" "刘粤"
      "CTLau.html" cn-gb-2312 "CTLau.el"
      ctlau-gb-converter
      "\
@@ -702,7 +698,7 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
 ;; # You should have received a copy of the GNU General Public License
 ;; # along with this program.  If not, see <https://www.gnu.org/licenses/>.")
 
-    ("chinese-ctlaub" "$(0N,Gn(B"
+    ("chinese-ctlaub" "劉粵"
      "CTLau-b5.html" big5 "CTLau-b5.el"
      ctlau-b5-converter
      "\
@@ -732,38 +728,38 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
 ;; dictionary in the buffer DICBUF.  The input method name of the
 ;; Quail package is NAME, and the title string is TITLE.
 
-;; TSANG-P is non-nil, generate $(06AQo(B input method.  Otherwise
-;; generate $(0X|/y(B (simple version of $(06AQo(B).  If BIG5-P is 
non-nil, the
+;; TSANG-P is non-nil, generate 倉頡 input method.  Otherwise
+;; generate 簡易 (simple version of 倉頡).  If BIG5-P is non-nil, the
 ;; input method is for inputting Big5 characters.  Otherwise the input
 ;; method is for inputting CNS characters.
 
-(defun tsang-quick-converter (dicbuf name title tsang-p big5-p)
-  (let ((fulltitle (if tsang-p (if big5-p "$(06AQo(B" "$(GT?on(B")
-                    (if big5-p "$(0X|/y(B" "$(Gv|Mx(B")))
+(defun tsang-quick-converter (dicbuf tsang-p big5-p)
+  (let ((fulltitle (if tsang-p (if big5-p "倉頡" "倉頡")
+                    (if big5-p "簡易" "簡易")))
        dic)
     (goto-char (point-max))
     (if big5-p
-       (insert (format "\"$(0&d'GTT&,!J(B%s$(0!K(BBIG5
+       (insert (format "\"中文輸入【%s】BIG5
 
-       $(0KHM$(B%s$(0TT&,WoOu(B
+       漢語%s輸入鍵盤
 
-   [Q $(0'D(B] [W $(0(q(B] [E $(0'V(B] [R $(0&H(B] [T $(0'>(B] [Y 
$(0&4(B] [U $(0&U(B] [I $(0'B(B] [O $(0&*(B] [P $(0'A(B]
+   [Q 手] [W 田] [E 水] [R 口] [T 廿] [Y 卜] [U 山] [I 戈] [O 人] [P 心]
 
-    [A $(0'K(B] [S $(0&T(B] [D $(0'N(B] [F $(0'W(B] [G $(0&I(B] [H 
$(0*M(B] [J $(0&3(B] [L $(0&d(B]
+    [A 日] [S 尸] [D 木] [F 火] [G 土] [H 竹] [J 十] [L 中]
 
-      [Z  ] [X $(0[E(B] [C $(01[(B] [V $(0&M(B] [B $(0'M(B] [N 
$(0&_(B] [M $(0&"(B]
+      [Z  ] [X 難] [C 金] [V 女] [B 月] [N 弓] [M 一]
 
 \\\\<quail-translation-docstring>\"\n"
                        fulltitle fulltitle))
-      (insert (format "\"$(GDcEFrSD+!J(B%s$(G!K(BCNS
+      (insert (format "\"中文輸入【%s】CNS
 
-       $(GiGk#(B%s$(GrSD+uomu(B
+       漢語%s輸入鍵盤
 
-   [Q $(GEC(B] [W $(GFp(B] [E $(GEU(B] [R $(GDG(B] [T $(GE=(B] [Y 
$(GD3(B] [U $(GDT(B] [I $(GEA(B] [O $(GD)(B] [P $(address@hidden(B]
+   [Q 手] [W 田] [E 水] [R 口] [T 廿] [Y 卜] [U 山] [I 戈] [O 人] [P 心]
 
-    [A $(GEJ(B] [S $(GDS(B] [D $(GEM(B] [F $(GEV(B] [G $(GDH(B] [H 
$(GHL(B] [J $(GD2(B] [L $(GDc(B]
+    [A 日] [S 尸] [D 木] [F 火] [G 土] [H 竹] [J 十] [L 中]
 
-      [Z  ] [X $(GyE(B] [C $(GOZ(B] [V $(GDL(B] [B $(GEL(B] [N 
$(GD^(B] [M $(GD!(B]
+      [Z  ] [X 難] [C 金] [V 女] [B 月] [N 弓] [M 一]
 
 \\\\<quail-translation-docstring>\"\n"
                      fulltitle fulltitle)))
@@ -782,7 +778,7 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
        (while (not (eobp))
          (forward-char 5)
          (let ((trans (char-to-string (following-char)))
-               key slot)
+               key)
            (re-search-forward "\\([A-Z]+\\)\r*$" nil t)
            (setq key (downcase
                       (if (or tsang-p
@@ -799,63 +795,63 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\"."
     (setq dic (sort dic (function (lambda (x y) (string< (car x ) (car y))))))
     (dolist (elt dic)
       (insert (format "(%S\t%S)\n" (car elt) (cdr elt))))
-    (let ((punctuation '((";" "$(0!'!2!"!#!.!/(B" "$(G!'!2!"!#!.!/(B")
-                        (":" "$(0!(!+!3!%!$!&!0!1(B" 
"$(G!(!+!3!%!$!&!0!1(B")
-                        ("'" "$(0!e!d(B" "$(G!e!d(B")
-                        ("\"" "$(0!g!f!h!i!q(B" "$(G!g!f!h!i!q(B")
-                        ("\\" "$(0"`"b#M(B" "$(G"`"b#M(B")
-                        ("|" "$(0!6!8!:"^(B" "$(G!6!8!:"^(B")
-                        ("/" "$(0"_"a#L(B" "$(G"_"a#L(B")
-                        ("?" "$(0!)!4(B" "$(G!)!4(B")
-                        ("<" "$(0!R"6"A!T"H(B" "$(G!R"6"A!T"H(B")
-                        (">" "$(0!S"7"B!U(B" "$(G!S"7"B!U(B")
-                        ("[" "$(0!F!J!b!H!L!V!Z!X!\(B" 
"$(G!F!J!b!H!L!V!Z!X!\(B")
-                        ("]" "$(0!G!K!c!I!M!W![!Y!](B" 
"$(G!G!K!c!I!M!W![!Y!](B")
-                        ("{" "$(0!B!`!D(B " "$(G!B!`!D(B ")
-                        ("}" "$(0!C!a!E(B" "$(G!C!a!E(B")
-                        ("`" "$(0!j!k(B" "$(G!j!k(B")
-                        ("~" "$(0"D"+",!<!=(B" "$(G"D"+",!<!=(B")
-                        ("!" "$(0!*!5(B" "$(G!*!5(B")
-                        ("@" "$(0"i"n(B" "$(G"i"n(B")
-                        ("#" "$(0!l"-(B" "$(G!l"-(B")
-                        ("$" "$(0"c"l(B" "$(G"c"l(B")
-                        ("%" "$(0"h"m(B" "$(G"h"m(B")
-                        ("&" "$(0!m".(B" "$(G!m".(B")
-                        ("*" "$(0!n"/!o!w!x(B" "$(G!n"/!o!w!x(B")
-                        ("(" "$(0!>address@hidden(B" "$(G!>address@hidden(B")
-                        (")" "$(0!?!_!A(B" "$(G!?!_!A(B")
-                        ("-" "$(0!7!9"#"$"1"@(B" "$(G!7!9"#"$"1"@(B")
-                        ("_" "$(0"%"&(B" "$(G"%"&(B")
-                        ("=" "$(0"8"C(B" "$(G"8"C(B")
-                        ("+" "$(0"0"?(B" "$(G"0"?(B"))))
+    (let ((punctuation '((";" ";﹔,、﹐﹑" ";﹔,、﹐﹑")
+                        (":" ":︰﹕.。‧﹒·" ":︰﹕.。・﹒·")
+                        ("'" "’‘" "’‘")
+                        ("\"" "”“〝〞〃" "”“〝〞〃")
+                        ("\\" "\﹨╲" "\﹨╲")
+                        ("|" "|︱︳∣" "︱︲��|")
+                        ("/" "/∕╱" "/∕╱")
+                        ("?" "?﹖" "?﹖")
+                        ("<" "〈<﹤︿∠" "〈<﹤︿∠")
+                        (">" "〉>﹥﹀" "〉>﹦﹀")
+                        ("[" "〔【﹝︹︻「『﹁﹃" "〔【﹝︹︻「『﹁﹃")
+                        ("]" "〕】﹞︺︼」』﹂﹄" "〕】﹞︺︼」』﹂﹄")
+                        ("{" "{﹛︷ " "{﹛︷ ")
+                        ("}" "}﹜︸" "}﹜︸")
+                        ("`" "‵′" "′‵")
+                        ("~" "~﹋﹌︴﹏" "∼﹋﹌����")
+                        ("!" "!﹗" "!﹗")
+                        ("@" "@﹫" "@﹫")
+                        ("#" "#﹟" "#﹟")
+                        ("$" "$﹩" "$﹩")
+                        ("%" "%﹪" "%﹪")
+                        ("&" "&﹠" "&﹠")
+                        ("*" "*﹡※☆★" "*﹡※☆★")
+                        ("(" "(﹙︵" "(﹙︵")
+                        (")" ")﹚︶" ")﹚︶")
+                        ("-" "–—¯ ̄-﹣" "—–‾��-﹣")
+                        ("_" "_ˍ" "_��")
+                        ("=" "=﹦" "=﹥")
+                        ("+" "+﹢" "+﹢"))))
     (dolist (elt punctuation)
       (insert (format "(%S %S)\n" (concat "z" (car elt))
                      (if big5-p (nth 1 elt) (nth 2 elt))))))
     (insert ")\n")))
 
-(defun tsang-b5-converter (dicbuf name title)
-  (tsang-quick-converter dicbuf name title t t))
+(defun tsang-b5-converter (dicbuf)
+  (tsang-quick-converter dicbuf t t))
 
-(defun quick-b5-converter (dicbuf name title)
-  (tsang-quick-converter dicbuf name title nil t))
+(defun quick-b5-converter (dicbuf)
+  (tsang-quick-converter dicbuf nil t))
 
-(defun tsang-cns-converter (dicbuf name title)
-  (tsang-quick-converter dicbuf name title t nil))
+(defun tsang-cns-converter (dicbuf)
+  (tsang-quick-converter dicbuf t nil))
 
-(defun quick-cns-converter (dicbuf name title)
-  (tsang-quick-converter dicbuf name title nil nil))
+(defun quick-cns-converter (dicbuf)
+  (tsang-quick-converter dicbuf nil nil))
 
 ;; Generate a code of a Quail package in the current buffer from
 ;; Pinyin dictionary in the buffer DICBUF.  The input method name of
 ;; the Quail package is NAME, and the title string is TITLE.
 
-(defun py-converter (dicbuf name title)
+(defun py-converter (dicbuf)
   (goto-char (point-max))
-  (insert (format "%S\n" "$A::WVJdHk!KF4Rt!K(B
+  (insert (format "%S\n" "汉字输入∷拼音∷
 
-       $AF4Rt7=08(B
+       拼音方案
 
- $AP!P4S"NDWVD84z1m!8F4Rt!97{:E#,(B \"u(yu) $ATrSC(B u: $A1mJ>!C(B
+ 小写英文字母代表「拼音」符号, \"u(yu) 则用 u: 表示∶
 
 Pinyin base input method for Chinese charset GB2312 (`chinese-gb2312').
 
@@ -869,14 +865,14 @@ character.  The sequence is made by the combination of 
the initials
           iang ing iong u ua uo uai ui uan un uan ueng yu yue yuan yun
 
   (Note: In the correct Pinyin writing, the sequence \"yu\" in the last
-   four finals should be written by the character u-umlaut `$A(9(B'.)
+   four finals should be written by the character u-umlaut `ü'.)
 
 With this input method, you enter a Chinese character by first
 entering its pinyin spelling.
 
 \\<quail-translation-docstring>
 
-For instance, to input $ADc(B, you type \"n i C-n 3\".  The first \"n i\"
+For instance, to input 你, you type \"n i C-n 3\".  The first \"n i\"
 is a Pinyin, \"C-n\" selects the next group of candidates (each group
 contains at most 10 characters), \"3\" select the third character in
 that group.
@@ -924,14 +920,14 @@ method `chinese-tonepy' with which you must specify tones 
by digits
 ;; Ziranma dictionary in the buffer DICBUF.  The input method name of
 ;; the Quail package is NAME, and the title string is TITLE.
 
-(defun ziranma-converter (dicbuf name title)
+(defun ziranma-converter (dicbuf)
   (let (dic)
     (with-current-buffer dicbuf
       (goto-char (point-min))
       (search-forward "\n%keyname end")
       (forward-line 1)
       (let ((table (make-hash-table :test 'equal))
-           elt pos key trans val)
+           pos key trans val)
        (while (not (eobp))
          (setq pos (point))
          (skip-chars-forward "^ \t")
@@ -959,22 +955,22 @@ method `chinese-tonepy' with which you must specify tones 
by digits
                 table)))
     (setq dic (sort dic (function (lambda (x y) (string< (car x) (car y))))))
     (goto-char (point-max))
-    (insert (format "%S\n" "$A::WVJdHk!K!>WTH;!?!K(B
-
-                            $A<|EL6TUU1m(B:
- $A)3)%)%)W)%)%)W)%)%)W)%)%)W)%)%)W)%)%)W)%)%)W)%)%)W)%)%)W)%)%)7(B
- $A)'#Q(B  $A)'#W(B  $A)'#E(B  $A)'#R(B  $A)'#T(B  $A)'#Y(B  
$A)'#U(Bsh$A)'#I(Bch$A)'#O(B  $A)'#P(B  $A)'(B
- $A)'(B  iu$A)'(B  ua$A)'(B   e$A)'(B uan$A)'(B  ue$A)'(B 
uai$A)'(B   u$A)'(B   i$A)'(B   o$A)'(B  un$A)'(B
- $A)'(B    $A)'(B  ia$A)'(B    $A)'(B van$A)'(B  ve$A)'(B 
ing$A)'(B    $A)'(B    $A)'(B  uo$A)'(B  vn$A)'(B
- $A);)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)?(B
-   $A)'#A(B  $A)'#S(B  $A)'#D(B  $A)'#F(B  $A)'#G(B  $A)'#H(B  
$A)'#J(B  $A)'#K(B  $A)'#L(B  $A)'(B
-   $A)'(B   a$A)'(Biong$A)'(Buang$A)'(B  en$A)'(B eng$A)'(B 
ang$A)'(B  an$A)'(B  ao$A)'(B  ai$A)'(B
-   $A)'(B    $A)'(B ong$A)'(Biang$A)'(B    $A)'(B  ng$A)'(B    
$A)'(B    $A)'(B    $A)'(B    $A)'(B
-   $A);)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)_)W)%)%)7(B
-     $A)'#Z(B  $A)'#X(B  $A)'#C(B  $A)'#V(Bzh$A)'#B(B  $A)'#N(B  
$A)'#M(B  $A)'#,(B  $A)'#.(B  $A)'(B $A#/(B $A)'(B
-     $A)'(B  ei$A)'(B  ie$A)'(B iao$A)'(B  ui$A)'(B  ou$A)'(B  
in$A)'(B ian$A)'G0R3)':sR3)'7{:E)'(B
-     $A)'(B    $A)'(B    $A)'(B    $A)'(B   v$A)'(B    $A)'(B    
$A)'(B    $A)'(B    $A)'(B    $A)'(B    $A)'(B
-     $A);)%)%)_)%)%)_)%)%)_)%)%)_)%)%)_)%)%)_)%)%)_)%)%)_)%)%)_)%)%)?(B
+    (insert (format "%S\n" "汉字输入∷【自然】∷
+
+                            键盘对照表:
+ ┏━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┳━━┓
+ ┃Q  ┃W  ┃E  ┃R  ┃T  ┃Y  ┃Ush┃Ich┃O  ┃P  ┃
+ ┃  iu┃  ua┃   e┃ uan┃  ue┃ uai┃   u┃   i┃   o┃  un┃
+ ┃    ┃  ia┃    ┃ van┃  ve┃ ing┃    ┃    ┃  uo┃  vn┃
+ ┗┳━┻┳━┻┳━┻┳━┻┳━┻┳━┻┳━┻┳━┻┳━┻┳━┛
+   ┃A  ┃S  ┃D  ┃F  ┃G  ┃H  ┃J  ┃K  ┃L  ┃
+   ┃   a┃iong┃uang┃  en┃ eng┃ ang┃  an┃  ao┃  ai┃
+   ┃    ┃ ong┃iang┃    ┃  ng┃    ┃    ┃    ┃    ┃
+   ┗┳━┻┳━┻┳━┻┳━┻┳━┻┳━┻┳━┻┳━┻┳━┻┳━━┓
+     ┃Z  ┃X  ┃C  ┃Vzh┃B  ┃N  ┃M  ┃,  ┃.  ┃ / ┃
+     ┃  ei┃  ie┃ iao┃  ui┃  ou┃  in┃ ian┃前页┃后页┃符号┃
+     ┃    ┃    ┃    ┃   v┃    ┃    ┃    ┃    ┃    ┃    ┃
+     ┗━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┻━━┛
 
 
 Pinyin base input method for Chinese GB2312 characters (`chinese-gb2312').
@@ -986,34 +982,34 @@ method `chinese-py'.
 Unlike the standard spelling of Pinyin, in this input method all
 initials and finals are assigned to single keys (see the above table).
 For instance, the initial \"ch\" is assigned to the key `i', the final
-\"iu\" is assigned to the key `q', and tones 1, 2, 3, 4, and $AGaIy(B are
+\"iu\" is assigned to the key `q', and tones 1, 2, 3, 4, and 轻声 are
 assigned to the keys `q', `w', `e', `r', `t' respectively.
 
 \\<quail-translation-docstring>
 
 To input one-letter words, you type 4 keys, the first two for the
 Pinyin of the letter, next one for tone, and the last one is always a
-quote (').  For instance, \"vsq'\" input $AVP(B.  Exceptions are these
+quote (').  For instance, \"vsq'\" input 中.  Exceptions are these
 letters.  You can input them just by typing a single key.
 
-       Character: $A04(B $A2;(B $A4N(B $A5D(B $A6~(B $A7"(B 
$A8v(B $A:M(B $A3v(B $A<0(B $A?I(B $AAK(B $AC;(B
+       Character: 按 不 次 的 二 发 个 和 出 及 可 了 没
        Key:       a  b  c  d  e  f  g  h  i  j  k  l  m
-       Character: $ADc(B $AE7(B $AF,(B $AF_(B $AHK(B $AH}(B 
$AK{(B $AJG(B $AWE(B $ANR(B $AP!(B $AR;(B $ATZ(B
+       Character: 你 欧 片 七 人 三 他 是 着 我 小 一 在
        Key:       n  o  p  q  r  s  t  u  v  w  x  y  z
 
 To input two-letter words, you have two ways.  One way is to type 4
 keys, two for the first Pinyin, two for the second Pinyin.  For
-instance, \"vsgo\" inputs $AVP9z(B.  Another way is to type 3 keys: 2
+instance, \"vsgo\" inputs 中国.  Another way is to type 3 keys: 2
 initials of two letters, and quote (').  For instance, \"vg'\" also
-inputs $AVP9z(B.
+inputs 中国.
 
 To input three-letter words, you type 4 keys: initials of three
-letters, and the last is quote (').  For instance, \"bjy'2\" inputs $A11(B
-$A>)Q<(B (the last `2' is to select one of the candidates).
+letters, and the last is quote (').  For instance, \"bjy'2\" inputs 北
+京鸭 (the last `2' is to select one of the candidates).
 
 To input words of more than three letters, you type 4 keys, initials
 of the first three letters and the last letter.  For instance,
-\"bjdt\" inputs $A11>)5gJSL((B.
+\"bjdt\" inputs 北京电视台.
 
 To input symbols and punctuation, type `/' followed by one of `a' to
 `z', then select one of the candidates."))
@@ -1033,7 +1029,7 @@ To input symbols and punctuation, type `/' followed by 
one of `a' to
 ;; method name of the Quail package is NAME, and the title string is
 ;; TITLE.  DESCRIPTION is the string shown by describe-input-method.
 
-(defun ctlau-converter (dicbuf name title description)
+(defun ctlau-converter (dicbuf description)
   (goto-char (point-max))
   (insert (format "%S\n" description))
   (insert "  '((\"\C-?\" . quail-delete-last-char)
@@ -1043,7 +1039,7 @@ To input symbols and punctuation, type `/' followed by 
one of `a' to
    (\"<\" . quail-prev-translation))
   nil nil nil nil)\n\n")
   (insert "(quail-define-rules\n")
-  (let (dicbuf-start dicbuf-end key-start key (pos (point)))
+  (let (dicbuf-start dicbuf-end key-start (pos (point)))
     ;; Find the dictionary, which starts below a horizontal rule and
     ;; ends at the second to last line in the HTML file.
     (with-current-buffer dicbuf
@@ -1060,7 +1056,7 @@ To input symbols and punctuation, type `/' followed by 
one of `a' to
     ;; which the file is converted have no Big5 equivalent.  Go
     ;; through and delete them.
     (goto-char pos)
-    (while (search-forward "$(0!{(B" nil t)
+    (while (search-forward "□" nil t)
       (delete-char -1))
     ;; Uppercase keys in dictionary need to be downcased.  Backslashes
     ;; at the beginning of keys need to be turned into double
@@ -1082,33 +1078,33 @@ To input symbols and punctuation, type `/' followed by 
one of `a' to
       (forward-line 1)))
   (insert ")\n"))
 
-(defun ctlau-gb-converter (dicbuf name title)
-  (ctlau-converter dicbuf name title
-"$A::WVJdHk!KAuN}OiJ=TARt!K(B
+(defun ctlau-gb-converter (dicbuf)
+  (ctlau-converter dicbuf
+"汉字输入∷刘锡祥式粤音∷
 
- $AAuN}OiJ=TASoW"Rt7=08(B
+ 刘锡祥式粤语注音方案
  Sidney Lau's Cantonese transcription scheme as described in his book
  \"Elementary Cantonese\", The Government Printer, Hong Kong, 1972.
- This file was prepared by Fung Fung Lee (address@hidden(B).
+ This file was prepared by Fung Fung Lee (李枫峰).
  Originally converted from CTCPS3.tit
  Last modified: June 2, 1993.
 
  Some infrequent GB characters are accessed by typing \\, followed by
- the Cantonese romanization of the respective radical ($A2?JW(B)."))
+ the Cantonese romanization of the respective radical (部首)."))
 
-(defun ctlau-b5-converter (dicbuf name title)
-  (ctlau-converter dicbuf name title
-"$(0KH)tTT&,!(N,Tg>A*#Gn5x!((B
+(defun ctlau-b5-converter (dicbuf)
+  (ctlau-converter dicbuf
+"漢字輸入:劉錫祥式粵音:
 
- $(0N,Tg>A*#GnM$0D5x'J7{(B
+ 劉錫祥式粵語注音方案
  Sidney Lau's Cantonese transcription scheme as described in his book
  \"Elementary Cantonese\", The Government Printer, Hong Kong, 1972.
- This file was prepared by Fung Fung Lee ($(0,XFS76(B).
+ This file was prepared by Fung Fung Lee (李楓峰).
  Originally converted from CTCPS3.tit
  Last modified: June 2, 1993.
 
  Some infrequent characters are accessed by typing \\, followed by
- the Cantonese romanization of the respective radical ($(0?f5}(B)."))
+ the Cantonese romanization of the respective radical (部首)."))
 
 (declare-function dos-8+3-filename "dos-fns.el" (filename))
 
@@ -1122,8 +1118,7 @@ the generated Quail package is saved."
   (let ((tail quail-misc-package-ext-info)
        coding-system-for-write
        slot
-       name title dicfile coding quailfile converter copyright
-       dicbuf)
+       name title dicfile coding quailfile converter copyright)
     (while tail
       (setq slot (car tail)
            dicfile (nth 2 slot)
@@ -1148,8 +1143,7 @@ the generated Quail package is saved."
              copyright (nth 6 slot))
        (message "Converting %s to %s..." dicfile quailfile)
        ;; Explicitly set eol format to `unix'.
-       (setq coding-system-for-write
-             (coding-system-change-eol-conversion coding 'unix))
+       (setq coding-system-for-write 'utf-8-unix)
        (with-temp-file (expand-file-name quailfile dirname)
          (insert (format-message ";; Quail package `%s'\n" name))
          (insert (format-message
@@ -1174,11 +1168,10 @@ the generated Quail package is saved."
               (insert-file-contents filename)
               (let ((dicbuf (current-buffer)))
                 (with-current-buffer dstbuf
-                  (funcall converter dicbuf name title)))))
+                  (funcall converter dicbuf)))))
          (insert ";; Local Variables:\n"
                  ";; version-control: never\n"
                  ";; no-update-autoloads: t\n"
-                 (format ";; coding: %s\n" coding)
                  ";; End:\n\n"
                  ";;; " quailfile " ends here\n"))
        (message "Converting %s to %s...done" dicfile quailfile))
@@ -1210,6 +1203,38 @@ to store generated Quail packages."
        (miscdic-convert filename dir))))
   (kill-emacs 0))
 
+(defun pinyin-convert ()
+  "Convert text file pinyin.map into an elisp library.
+The library is named pinyin.el, and contains the constant
+`pinyin-character-map'."
+  (let ((src-file (car command-line-args-left))
+        (dst-file (cadr command-line-args-left))
+        (coding-system-for-write 'utf-8-unix))
+    (with-temp-file dst-file
+      (insert ";; This file is automatically generated from pinyin.map,\
+ by the\n;; function pinyin-convert.\n\n")
+      (insert "(defconst pinyin-character-map\n'(")
+      (let ((pos (point)))
+        (insert-file-contents src-file)
+        (goto-char pos)
+        (re-search-forward "^[a-z]")
+        (beginning-of-line)
+        (delete-region pos (point))
+        (while (not (eobp))
+          (insert "(\"")
+          (skip-chars-forward "a-z")
+          (insert "\" . \"")
+          (delete-char 1)
+          (end-of-line)
+          (while (= (preceding-char) ?\r)
+           (delete-char -1))
+          (insert "\")")
+          (forward-line 1)))
+      (insert ")\n\"An alist holding correspondences between pinyin syllables\
+ and\nChinese characters.\")\n\n")
+      (insert "(provide 'pinyin)\n"))
+    (kill-emacs 0)))
+
 ;; Prevent "Local Variables" above confusing Emacs.
 
 
diff --git a/lisp/international/ucs-normalize.el 
b/lisp/international/ucs-normalize.el
index a43c900..6f1e770 100644
--- a/lisp/international/ucs-normalize.el
+++ b/lisp/international/ucs-normalize.el
@@ -1,6 +1,6 @@
 ;;; ucs-normalize.el --- Unicode normalization NFC/NFD/NFKD/NFKC
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Taichi Kawabata <address@hidden>
 ;; Keywords: unicode, normalization
@@ -30,7 +30,7 @@
 ;;
 ;; HFS-Normalization:
 ;; Reference:
-;; http://developer.apple.com/technotes/tn/tn1150.html
+;; https://developer.apple.com/library/archive/technotes/tn/tn1150.html
 ;;
 ;; HFS Normalization excludes following area for decomposition.
 ;;
@@ -109,7 +109,9 @@
 
 (defconst ucs-normalize-version "1.2")
 
-(eval-when-compile (require 'cl-lib))
+(eval-when-compile
+  (require 'cl-lib)
+  (require 'regexp-opt))
 
 (declare-function nfd "ucs-normalize" (char))
 
diff --git a/lisp/international/utf-7.el b/lisp/international/utf-7.el
index 513422b..876baf2 100644
--- a/lisp/international/utf-7.el
+++ b/lisp/international/utf-7.el
@@ -1,6 +1,6 @@
 ;;; utf-7.el --- utf-7 coding system
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Love <address@hidden>
 ;; Keywords: i18n, mail
diff --git a/lisp/international/utf7.el b/lisp/international/utf7.el
index 61c698c..0e67a62 100644
--- a/lisp/international/utf7.el
+++ b/lisp/international/utf7.el
@@ -1,6 +1,6 @@
 ;;; utf7.el --- UTF-7 encoding/decoding for Emacs   -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Jon K Hellan <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/isearch.el b/lisp/isearch.el
index dcd119a..6280afe 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -1,6 +1,6 @@
 ;;; isearch.el --- incremental search minor mode -*- lexical-binding: t -*-
 
-;; Copyright (C) 1992-1997, 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992-1997, 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Daniel LaLiberte <address@hidden>
 ;; Maintainer: address@hidden
@@ -199,11 +199,14 @@ or to the end of the buffer for a backward search.")
 to the search status stack.")
 
 (defvar isearch-filter-predicate #'isearch-filter-visible
-  "Predicate that filters the search hits that would normally be available.
-Search hits that dissatisfy the predicate are skipped.  The function
-has two arguments: the positions of start and end of text matched by
-the search.  If this function returns nil, continue searching without
-stopping at this match.
+  "Predicate to filter hits of Isearch and replace commands.
+Isearch hits that don't satisfy the predicate will be skipped.
+The value should be a function of two arguments; it will be
+called with the the positions of the start and the end of the
+text matched by Isearch and replace commands.  If this function
+returns nil, Isearch and replace commands will continue searching
+without stopping at resp. replacing this match.
+
 If you use `add-function' to modify this variable, you can use the
 `isearch-message-prefix' advice property to specify the prefix string
 displayed in the search message.")
@@ -1357,6 +1360,7 @@ NOPUSH is t and EDIT is t."
   (setq minibuffer-message-timeout isearch-original-minibuffer-message-timeout)
   (isearch-dehighlight)
   (lazy-highlight-cleanup lazy-highlight-cleanup)
+  (setq isearch-lazy-highlight-last-string nil)
   (let ((found-start (window-group-start))
        (found-point (point)))
     (when isearch-window-configuration
@@ -2811,10 +2815,10 @@ the bottom."
 If `shift', extend the search string by motion commands while holding down
 the shift key.  The search string is extended by yanking text that
 ends at the new position after moving point in the current buffer.
-If t, extend the search string without the shift key pressed
-by motion commands that have the `isearch-move' property on their
-symbols equal to `enabled', or for which the shift-translated command
-is not disabled by the value `disabled' of property `isearch-move'."
+If t, extend the search string without the shift key pressed.
+To enable motion commands, put the `isearch-move' property on their
+symbols to `enabled', or to disable an automatically detected
+shift-translated command, use the property value `disabled'."
   :type '(choice (const :tag "Motion keys exit Isearch" nil)
                  (const :tag "Motion keys extend the search string" t)
                  (const :tag "Shifted motion keys extend the search string" 
shift))
@@ -2864,14 +2868,16 @@ See more for options in `search-exit-option'."
       (read-event)
       (setq this-command 'isearch-edit-string))
      ;; Don't terminate the search for motion commands.
-     ((or (and (eq isearch-yank-on-move t)
-               (symbolp this-command)
-               (or (eq (get this-command 'isearch-move) 'enabled)
-                   (and (not (eq (get this-command 'isearch-move) 'disabled))
-                        (stringp (nth 1 (interactive-form this-command)))
-                        (string-match-p "^^" (nth 1 (interactive-form 
this-command))))))
-          (and (eq isearch-yank-on-move 'shift)
-               this-command-keys-shift-translated))
+     ((and isearch-yank-on-move
+           (symbolp this-command)
+           (not (eq (get this-command 'isearch-move) 'disabled))
+           (or (eq (get this-command 'isearch-move) 'enabled)
+               (and (eq isearch-yank-on-move t)
+                    (stringp (nth 1 (interactive-form this-command)))
+                    (string-match-p "^\\^"
+                                   (nth 1 (interactive-form this-command))))
+               (and (eq isearch-yank-on-move 'shift)
+                    this-command-keys-shift-translated)))
       (setq this-command-keys-shift-translated nil)
       (setq isearch-pre-move-point (point)))
      ;; Append control characters to the search string
@@ -3507,10 +3513,13 @@ Optional third argument, if t, means if fail just 
return nil (no error).
              (setq isearch-hidden t)))))))
 
 (defun isearch-filter-visible (beg end)
-  "Test whether the current search hit is visible at least partially.
-Return non-nil if the text from BEG to END is visible to Isearch as
-determined by `isearch-range-invisible' unless invisible text can be
-searched too when `search-invisible' is t."
+  "Return non-nil if text between BEG and END is deemed visible by Isearch.
+This function is intended to be used as `isearch-filter-predicate'.
+It returns non-nil if the text between BEG and END is visible to
+Isearch, at least partially, as determined by `isearch-range-invisible'.
+If `search-invisible' is t, which allows Isearch matches inside
+invisible text, this function will always return non-nil, regardless
+of what `isearch-range-invisible' says."
   (or (eq search-invisible t)
       (not (isearch-range-invisible beg end))))
 
@@ -3767,7 +3776,7 @@ by other Emacs features."
     (when isearch-lazy-count-current
       (setq isearch-lazy-count-current
             (gethash (point) isearch-lazy-count-hash 0))
-      (isearch-message nil t))))
+      (isearch-message))))
 
 (defun isearch-lazy-highlight-search (string bound)
   "Search ahead for the next or previous match, for lazy highlighting.
@@ -3970,7 +3979,7 @@ Attempt to do the search exactly the way the pending 
Isearch would."
                    (setq isearch-lazy-count-total 0))
                  (setq isearch-lazy-count-current
                        (gethash opoint isearch-lazy-count-hash 0))
-                 (isearch-message nil t))
+                 (isearch-message))
              (setq isearch-lazy-highlight-timer
                    (run-at-time lazy-highlight-interval nil
                                 'isearch-lazy-highlight-buffer-update)))))))))
diff --git a/lisp/isearchb.el b/lisp/isearchb.el
index 87922ca..ee392b3 100644
--- a/lisp/isearchb.el
+++ b/lisp/isearchb.el
@@ -1,6 +1,6 @@
 ;;; isearchb --- a marriage between iswitchb and isearch
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/jit-lock.el b/lisp/jit-lock.el
index 2b13c60..48998a8 100644
--- a/lisp/jit-lock.el
+++ b/lisp/jit-lock.el
@@ -1,6 +1,6 @@
 ;;; jit-lock.el --- just-in-time fontification  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Gerd Moellmann <address@hidden>
 ;; Keywords: faces files
diff --git a/lisp/jka-cmpr-hook.el b/lisp/jka-cmpr-hook.el
index d800b60..3aa84f4 100644
--- a/lisp/jka-cmpr-hook.el
+++ b/lisp/jka-cmpr-hook.el
@@ -1,6 +1,6 @@
 ;;; jka-cmpr-hook.el --- preloaded code to enable jka-compr.el
 
-;; Copyright (C) 1993-1995, 1997, 1999-2000, 2002-2018 Free Software
+;; Copyright (C) 1993-1995, 1997, 1999-2000, 2002-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Jay K. Adams <address@hidden>
diff --git a/lisp/jka-compr.el b/lisp/jka-compr.el
index bb43e88..63fb449 100644
--- a/lisp/jka-compr.el
+++ b/lisp/jka-compr.el
@@ -1,6 +1,6 @@
 ;;; jka-compr.el --- reading/writing/loading compressed files
 
-;; Copyright (C) 1993-1995, 1997, 1999-2018 Free Software Foundation,
+;; Copyright (C) 1993-1995, 1997, 1999-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Jay K. Adams <address@hidden>
diff --git a/lisp/json.el b/lisp/json.el
index 1840972..44b3c33 100644
--- a/lisp/json.el
+++ b/lisp/json.el
@@ -1,6 +1,6 @@
 ;;; json.el --- JavaScript Object Notation parser / generator -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Theresa O'Connor <address@hidden>
 ;; Version: 1.4
@@ -49,10 +49,13 @@
 ;; 2008-02-21 - Installed in GNU Emacs.
 ;; 2011-10-17 - Patch `json-alist-p' and `json-plist-p' to avoid recursion -tzz
 ;; 2012-10-25 - Added pretty-printed reformatting -Ryan Crum (address@hidden)
+;; 2019-02-02 - Pretty-printing now uses replace-region-contents and support 
for
+;;              minimization -tsdh
 
 ;;; Code:
 
 (require 'map)
+(require 'subr-x)
 
 ;; Parameters
 
@@ -730,36 +733,50 @@ Advances point just past JSON object."
         ((hash-table-p object) (json-encode-hash-table object))
         (t                     (signal 'json-error (list object)))))
 
-;; Pretty printing
-
-(defun json-pretty-print-buffer ()
-  "Pretty-print current buffer."
-  (interactive)
-  (json-pretty-print (point-min) (point-max)))
-
-(defun json-pretty-print (begin end)
-  "Pretty-print selected region."
-  (interactive "r")
-  (atomic-change-group
-    (let ((json-encoding-pretty-print t)
-          ;; Distinguish an empty objects from 'null'
-          (json-null :json-null)
-          ;; Ensure that ordering is maintained
-          (json-object-type 'alist)
-          (txt (delete-and-extract-region begin end)))
-      (insert (json-encode (json-read-from-string txt))))))
-
-(defun json-pretty-print-buffer-ordered ()
-  "Pretty-print current buffer with object keys ordered."
-  (interactive)
+;; Pretty printing & minimizing
+
+(defun json-pretty-print-buffer (&optional minimize)
+  "Pretty-print current buffer.
+With prefix argument MINIMIZE, minimize it instead."
+  (interactive "P")
+  (json-pretty-print (point-min) (point-max) minimize))
+
+(defvar json-pretty-print-max-secs 2.0
+  "Maximum time for `json-pretty-print's comparison.
+The function `json-pretty-print' uses `replace-region-contents'
+(which see) passing the value of this variable as argument
+MAX-SECS.")
+
+(defun json-pretty-print (begin end &optional minimize)
+  "Pretty-print selected region.
+With prefix argument MINIMIZE, minimize it instead."
+  (interactive "r\nP")
+  (let ((json-encoding-pretty-print (null minimize))
+        ;; Distinguish an empty objects from 'null'
+        (json-null :json-null)
+        ;; Ensure that ordering is maintained
+        (json-object-type 'alist))
+    (replace-region-contents
+     begin end
+     (lambda () (json-encode (json-read)))
+     json-pretty-print-max-secs
+     ;; FIXME: What's a good value here?  Can we use something better,
+     ;; e.g., by deriving a value from the size of the region?
+     64)))
+
+(defun json-pretty-print-buffer-ordered (&optional minimize)
+  "Pretty-print current buffer with object keys ordered.
+With prefix argument MINIMIZE, minimize it instead."
+  (interactive "P")
   (let ((json-encoding-object-sort-predicate 'string<))
-    (json-pretty-print-buffer)))
+    (json-pretty-print-buffer minimize)))
 
-(defun json-pretty-print-ordered (begin end)
-  "Pretty-print the region with object keys ordered."
-  (interactive "r")
+(defun json-pretty-print-ordered (begin end &optional minimize)
+  "Pretty-print the region with object keys ordered.
+With prefix argument MINIMIZE, minimize it instead."
+  (interactive "r\nP")
   (let ((json-encoding-object-sort-predicate 'string<))
-    (json-pretty-print begin end)))
+    (json-pretty-print begin end minimize)))
 
 (provide 'json)
 
diff --git a/lisp/jsonrpc.el b/lisp/jsonrpc.el
index 020d7f5..c02e685 100644
--- a/lisp/jsonrpc.el
+++ b/lisp/jsonrpc.el
@@ -1,12 +1,12 @@
 ;;; jsonrpc.el --- JSON-RPC library                  -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; Author: João Távora <address@hidden>
 ;; Maintainer: João Távora <address@hidden>
 ;; Keywords: processes, languages, extensions
 ;; Package-Requires: ((emacs "25.2"))
-;; Version: 1.0.6
+;; Version: 1.0.7
 
 ;; This is an Elpa :core package.  Don't use functionality that is not
 ;; compatible with Emacs 25.2.
@@ -421,13 +421,13 @@ connection object, called when the process dies .")
 With optional CLEANUP, kill any associated buffers. "
   (unwind-protect
       (cl-loop
-       with proc = (jsonrpc--process conn)
+       with proc = (jsonrpc--process conn) for i from 0
+       while (not (process-get proc 'jsonrpc-sentinel-cleanup-started))
+       unless (zerop i) do
+       (jsonrpc--warn "Sentinel for %s still hasn't run,  deleting it!" proc)
        do
        (delete-process proc)
-       (accept-process-output nil 0.1)
-       while (not (process-get proc 'jsonrpc-sentinel-done))
-       do (jsonrpc--warn
-           "Sentinel for %s still hasn't run,  deleting it!" proc))
+       (accept-process-output nil 0.1))
     (when cleanup
       (kill-buffer (process-buffer (jsonrpc--process conn)))
       (kill-buffer (jsonrpc-stderr-buffer conn)))))
@@ -486,6 +486,7 @@ With optional CLEANUP, kill any associated buffers. "
                  (pcase-let ((`(,_success ,_error ,timeout) triplet))
                    (when timeout (cancel-timer timeout))))
                (jsonrpc--request-continuations connection))
+      (process-put proc 'jsonrpc-sentinel-cleanup-started t)
       (unwind-protect
           ;; Call all outstanding error handlers
           (maphash (lambda (_id triplet)
@@ -493,7 +494,6 @@ With optional CLEANUP, kill any associated buffers. "
                        (funcall error '(:code -1 :message "Server died"))))
                    (jsonrpc--request-continuations connection))
         (jsonrpc--message "Server exited with status %s" (process-exit-status 
proc))
-        (process-put proc 'jsonrpc-sentinel-done t)
         (delete-process proc)
         (funcall (jsonrpc--on-shutdown connection) connection)))))
 
diff --git a/lisp/kermit.el b/lisp/kermit.el
index 8108fca..f6ed1fb 100644
--- a/lisp/kermit.el
+++ b/lisp/kermit.el
@@ -1,6 +1,6 @@
 ;;; kermit.el --- additions to shell mode for use with kermit
 
-;; Copyright (C) 1988, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Jeff Norden <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/kmacro.el b/lisp/kmacro.el
index 08a27ae..fc34e16 100644
--- a/lisp/kmacro.el
+++ b/lisp/kmacro.el
@@ -1,6 +1,6 @@
 ;;; kmacro.el --- enhanced keyboard macros -*- lexical-binding: t -*-
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Kim F. Storm <address@hidden>
 ;; Keywords: keyboard convenience
@@ -256,7 +256,10 @@ Can be set directly via `kmacro-set-format', which see.")
 (defun kmacro-insert-counter (arg)
   "Insert current value of `kmacro-counter', then increment it by ARG.
 Interactively, ARG defaults to 1.  With \\[universal-argument], insert
-current value of `kmacro-counter', but do not increment it."
+the previous value of `kmacro-counter', and do not increment the
+current value.
+The previous value of the counter is the one it had before
+the last increment."
   (interactive "P")
   (if kmacro-initial-counter-value
       (setq kmacro-counter kmacro-initial-counter-value
@@ -685,9 +688,10 @@ the current value of `kmacro-counter').
 
 When used during defining/executing a macro, inserts the current value
 of `kmacro-counter' and increments the counter value by ARG (or by 1 if no
-prefix argument).  With just \\[universal-argument], inserts the current value
-of `kmacro-counter', but does not modify the counter; this is the
-same as incrementing the counter by zero.
+prefix argument).  With just \\[universal-argument], inserts the previous
+value of `kmacro-counter', and does not modify the counter; this is
+different from incrementing the counter by zero.  (The previous value
+of the counter is the one it had before the last increment.)
 
 The macro counter can be set directly via \\[kmacro-set-counter] and 
\\[kmacro-add-counter].
 The format of the inserted value of the counter can be controlled
diff --git a/lisp/language/china-util.el b/lisp/language/china-util.el
index 3004d5f..1638565 100644
--- a/lisp/language/china-util.el
+++ b/lisp/language/china-util.el
@@ -1,6 +1,6 @@
 ;;; china-util.el --- utilities for Chinese  -*- coding: utf-8 -*-
 
-;; Copyright (C) 1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -168,7 +168,7 @@ Return the length of resulting text."
              ;; ESC ESC -> ESC
              (delete-char 1)
            (forward-char -1)
-           (if (looking-at iso2022-gb-designation)
+           (if (looking-at "\e\\$A")
                (progn
                  (delete-region (match-beginning 0) (match-end 0))
                  (insert hz-gb-designation)
diff --git a/lisp/language/chinese.el b/lisp/language/chinese.el
index af9ff63..5f8dea5 100644
--- a/lisp/language/chinese.el
+++ b/lisp/language/chinese.el
@@ -1,6 +1,6 @@
 ;;; chinese.el --- support for Chinese -*- coding: utf-8; -*-
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/language/cyril-util.el b/lisp/language/cyril-util.el
index a86ce2d..2db320c 100644
--- a/lisp/language/cyril-util.el
+++ b/lisp/language/cyril-util.el
@@ -1,6 +1,6 @@
 ;;; cyril-util.el --- utilities for Cyrillic scripts
 
-;; Copyright (C) 1997-1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Keywords: mule, multilingual, Cyrillic
 
diff --git a/lisp/language/cyrillic.el b/lisp/language/cyrillic.el
index 3d007d1..75d4249 100644
--- a/lisp/language/cyrillic.el
+++ b/lisp/language/cyrillic.el
@@ -1,6 +1,6 @@
 ;;; cyrillic.el --- support for Cyrillic -*- coding: utf-8; -*-
 
-;; Copyright (C) 1997-1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/language/czech.el b/lisp/language/czech.el
index 7d1c6db..b43d956 100644
--- a/lisp/language/czech.el
+++ b/lisp/language/czech.el
@@ -1,6 +1,6 @@
 ;;; czech.el --- support for Czech -*- coding: utf-8 -*-
 
-;; Copyright (C) 1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Milan Zamazal <address@hidden>
 ;; Maintainer: Pavel Janík <address@hidden>
diff --git a/lisp/language/english.el b/lisp/language/english.el
index d3fdbfe..09ed423 100644
--- a/lisp/language/english.el
+++ b/lisp/language/english.el
@@ -1,6 +1,6 @@
 ;;; english.el --- support for English
 
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 ;;   2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/language/ethio-util.el b/lisp/language/ethio-util.el
index 0729a6d..2741538 100644
--- a/lisp/language/ethio-util.el
+++ b/lisp/language/ethio-util.el
@@ -1,6 +1,6 @@
 ;;; ethio-util.el --- utilities for Ethiopic   -*- coding: utf-8-emacs; -*-
 
-;; Copyright (C) 1997-1998, 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2002-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 ;;   2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -804,7 +804,7 @@ The 2nd and 3rd arguments BEGIN and END specify the region."
 
     ;; Special Ethiopic punctuation.
     (goto-char (point-min))
-    (while (re-search-forward "\\ce[»\\.\\?]\\|«\\ce" nil t)
+    (while (re-search-forward "\\ce[».?]\\|«\\ce" nil t)
       (cond
        ((= (setq ch (preceding-char)) ?\»)
        (delete-char -1)
diff --git a/lisp/language/ethiopic.el b/lisp/language/ethiopic.el
index 1e59cbf..52d1fb0 100644
--- a/lisp/language/ethiopic.el
+++ b/lisp/language/ethiopic.el
@@ -1,6 +1,6 @@
 ;;; ethiopic.el --- support for Ethiopic       -*- coding: utf-8-emacs; -*-
 
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/language/european.el b/lisp/language/european.el
index cd98aad..8c38175 100644
--- a/lisp/language/european.el
+++ b/lisp/language/european.el
@@ -1,6 +1,6 @@
 ;;; european.el --- support for European languages -*- coding: utf-8; -*-
 
-;; Copyright (C) 1997-1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2000-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/language/georgian.el b/lisp/language/georgian.el
index 34304e7..2c3d3fb 100644
--- a/lisp/language/georgian.el
+++ b/lisp/language/georgian.el
@@ -1,6 +1,6 @@
 ;;; georgian.el --- language support for Georgian
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Love <address@hidden>
 ;; Keywords: i18n
diff --git a/lisp/language/greek.el b/lisp/language/greek.el
index 7408bef..bb5cdbf 100644
--- a/lisp/language/greek.el
+++ b/lisp/language/greek.el
@@ -1,6 +1,6 @@
 ;;; greek.el --- support for Greek
 
-;; Copyright (C) 2002, 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2013-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/language/hanja-util.el b/lisp/language/hanja-util.el
index 97189b8..0c7ed51 100644
--- a/lisp/language/hanja-util.el
+++ b/lisp/language/hanja-util.el
@@ -1,6 +1,6 @@
 ;;; hanja-util.el --- Korean Hanja util module  -*- coding: utf-8 -*-
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Jihyun Cho <address@hidden>
 ;; Keywords: multilingual, input method, Korean, Hanja
diff --git a/lisp/language/hebrew.el b/lisp/language/hebrew.el
index 52188f4..b493c29 100644
--- a/lisp/language/hebrew.el
+++ b/lisp/language/hebrew.el
@@ -1,6 +1,6 @@
 ;;; hebrew.el --- support for Hebrew -*- coding: utf-8 -*-
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/language/ind-util.el b/lisp/language/ind-util.el
index e5eaf1c..9061a63 100644
--- a/lisp/language/ind-util.el
+++ b/lisp/language/ind-util.el
@@ -1,6 +1,6 @@
 ;;; ind-util.el --- Transliteration and Misc. Tools for Indian Languages -*- 
coding: utf-8-emacs; -*-
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer:  KAWABATA, Taichi <address@hidden>
 ;; Keywords: multilingual, Indian, Devanagari
diff --git a/lisp/language/indian.el b/lisp/language/indian.el
index e4f8ba5..d63e9b4 100644
--- a/lisp/language/indian.el
+++ b/lisp/language/indian.el
@@ -1,6 +1,6 @@
 ;;; indian.el --- Indian languages support -*- coding: utf-8; -*-
 
-;; Copyright (C) 1997, 1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1999, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
 ;;   Registration Number H14PRO021
diff --git a/lisp/language/japan-util.el b/lisp/language/japan-util.el
index 19ef063..b1eb3d9 100644
--- a/lisp/language/japan-util.el
+++ b/lisp/language/japan-util.el
@@ -1,6 +1,6 @@
-;;; japan-util.el --- utilities for Japanese -*- coding: iso-2022-7bit; -*-
+;;; japan-util.el --- utilities for Japanese
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -29,36 +29,34 @@
 
 ;;;###autoload
 (defun setup-japanese-environment-internal ()
-  ;; By default, we use 'japanese-iso-8bit for file names.  But, the
-  ;; following prefer-coding-system will override it.
-  (if (memq system-type '(windows-nt ms-dos cygwin))
-      (prefer-coding-system 'japanese-shift-jis)
-    (prefer-coding-system 'japanese-iso-8bit))
+  (prefer-coding-system (if (memq system-type '(windows-nt ms-dos cygwin))
+                           'japanese-shift-jis
+                         'utf-8))
   (use-cjk-char-width-table 'ja_JP))
 
 (defconst japanese-kana-table
-  '((?$B$"(B ?$B%"(B ?(I1(B) (?$B$$(B ?$B%$(B ?(I2(B) (?$B$&(B 
?$B%&(B ?(I3(B) (?$B$((B ?$B%((B ?(I4(B) (?$B$*(B ?$B%*(B 
?(I5(B)
-    (?$B$+(B ?$B%+(B ?(I6(B) (?$B$-(B ?$B%-(B ?(I7(B) (?$B$/(B 
?$B%/(B ?(I8(B) (?$B$1(B ?$B%1(B ?(I9(B) (?$B$3(B ?$B%3(B 
?(I:(B)
-    (?$B$5(B ?$B%5(B ?(I;(B) (?$B$7(B ?$B%7(B ?(I<(B) (?$B$9(B 
?$B%9(B ?(I=(B) (?$B$;(B ?$B%;(B ?(I>(B) (?$B$=(B ?$B%=(B 
?(I?(B)
-    (?$B$?(B ?$B%?(B ?(address@hidden(B) (?$B$A(B ?$B%A(B ?(IA(B) 
(?$B$D(B ?$B%D(B ?(IB(B) (?$B$F(B ?$B%F(B ?(IC(B) (?$B$H(B 
?$B%H(B ?(ID(B)
-    (?$B$J(B ?$B%J(B ?(IE(B) (?$B$K(B ?$B%K(B ?(IF(B) (?$B$L(B 
?$B%L(B ?(IG(B) (?$B$M(B ?$B%M(B ?(IH(B) (?$B$N(B ?$B%N(B 
?(II(B)
-    (?$B$O(B ?$B%O(B ?(IJ(B) (?$B$R(B ?$B%R(B ?(IK(B) (?$B$U(B 
?$B%U(B ?(IL(B) (?$B$X(B ?$B%X(B ?(IM(B) (?$B$[(B ?$B%[(B 
?(IN(B)
-    (?$B$^(B ?$B%^(B ?(IO(B) (?$B$_(B ?$B%_(B ?(IP(B) (?$B$`(B 
?$B%`(B ?(IQ(B) (?$B$a(B ?$B%a(B ?(IR(B) (?$B$b(B ?$B%b(B 
?(IS(B)
-    (?$B$d(B ?$B%d(B ?(IT(B) (?$B$f(B ?$B%f(B ?(IU(B) (?$B$h(B 
?$B%h(B ?(IV(B)
-    (?$B$i(B ?$B%i(B ?(IW(B) (?$B$j(B ?$B%j(B ?(IX(B) (?$B$k(B 
?$B%k(B ?(IY(B) (?$B$l(B ?$B%l(B ?(IZ(B) (?$B$m(B ?$B%m(B 
?(I[(B)
-    (?$B$o(B ?$B%o(B ?(I\(B) (?$B$p(B ?$B%p(B "(I2(B") (?$B$q(B 
?$B%q(B "(I4(B") (?$B$r(B ?$B%r(B ?(I&(B)
-    (?$B$s(B ?$B%s(B ?(I](B)
-    (?$B$,(B ?$B%,(B "(I6^(B") (?$B$.(B ?$B%.(B "(I7^(B") 
(?$B$0(B ?$B%0(B "(I8^(B") (?$B$2(B ?$B%2(B "(I9^(B") (?$B$4(B 
?$B%4(B "(I:^(B")
-    (?$B$6(B ?$B%6(B "(I;^(B") (?$B$8(B ?$B%8(B "(I<^(B") 
(?$B$:(B ?$B%:(B "(I=^(B") (?$B$<(B ?$B%<(B "(I>^(B") (?$B$>(B 
?$B%>(B "(I?^(B")
-    (address@hidden(B address@hidden(B "(address@hidden(B") (?$B$B(B 
?$B%B(B "(IA^(B") (?$B$E(B ?$B%E(B "(IB^(B") (?$B$G(B ?$B%G(B 
"(IC^(B") (?$B$I(B ?$B%I(B "(ID^(B")
-    (?$B$P(B ?$B%P(B "(IJ^(B") (?$B$S(B ?$B%S(B "(IK^(B") 
(?$B$V(B ?$B%V(B "(IL^(B") (?$B$Y(B ?$B%Y(B "(IM^(B") (?$B$\(B 
?$B%\(B "(IN^(B")
-    (?$B$Q(B ?$B%Q(B "(IJ_(B") (?$B$T(B ?$B%T(B "(IK_(B") 
(?$B$W(B ?$B%W(B "(IL_(B") (?$B$Z(B ?$B%Z(B "(IM_(B") (?$B$](B 
?$B%](B "(IN_(B")
-    (?$B$!(B ?$B%!(B ?(I'(B) (?$B$#(B ?$B%#(B ?(I((B) (?$B$%(B 
?$B%%(B ?(I)(B) (?$B$'(B ?$B%'(B ?(I*(B) (?$B$)(B ?$B%)(B 
?(I+(B)
-    (?$B$C(B ?$B%C(B ?(I/(B)
-    (?$B$c(B ?$B%c(B ?(I,(B) (?$B$e(B ?$B%e(B ?(I-(B) (?$B$g(B 
?$B%g(B ?(I.(B)
-    (?$B$n(B ?$B%n(B "(I\(B")
-    (?$B!5(B ?$B!3(B) (?$B!6(B ?$B!4(B)
-    ("$B$&!+(B" ?$B%t(B "(I3^(B") (nil ?$B%u(B "(I6(B") (nil 
?$B%v(B "(I9(B"))
+  '((?あ ?ア ?ア) (?い ?イ ?イ) (?う ?ウ ?ウ) (?え ?エ ?エ) (?お ?オ ?オ)
+    (?か ?カ ?カ) (?き ?キ ?キ) (?く ?ク ?ク) (?け ?ケ ?ケ) (?こ ?コ ?コ)
+    (?さ ?サ ?サ) (?し ?シ ?シ) (?す ?ス ?ス) (?せ ?セ ?セ) (?そ ?ソ ?ソ)
+    (?た ?タ ?タ) (?ち ?チ ?チ) (?つ ?ツ ?ツ) (?て ?テ ?テ) (?と ?ト ?ト)
+    (?な ?ナ ?ナ) (?に ?ニ ?ニ) (?ぬ ?ヌ ?ヌ) (?ね ?ネ ?ネ) (?の ?ノ ?ノ)
+    (?は ?ハ ?ハ) (?ひ ?ヒ ?ヒ) (?ふ ?フ ?フ) (?へ ?ヘ ?ヘ) (?ほ ?ホ ?ホ)
+    (?ま ?マ ?マ) (?み ?ミ ?ミ) (?む ?ム ?ム) (?め ?メ ?メ) (?も ?モ ?モ)
+    (?や ?ヤ ?ヤ) (?ゆ ?ユ ?ユ) (?よ ?ヨ ?ヨ)
+    (?ら ?ラ ?ラ) (?り ?リ ?リ) (?る ?ル ?ル) (?れ ?レ ?レ) (?ろ ?ロ ?ロ)
+    (?わ ?ワ ?ワ) (?ゐ ?ヰ "イ") (?ゑ ?ヱ "エ") (?を ?ヲ ?ヲ)
+    (?ん ?ン ?ン)
+    (?が ?ガ "ガ") (?ぎ ?ギ "ギ") (?ぐ ?グ "グ") (?げ ?ゲ "ゲ") (?ご ?ゴ "ゴ")
+    (?ざ ?ザ "ザ") (?じ ?ジ "ジ") (?ず ?ズ "ズ") (?ぜ ?ゼ "ゼ") (?ぞ ?ゾ "ゾ")
+    (?だ ?ダ "ダ") (?ぢ ?ヂ "ヂ") (?づ ?ヅ "ヅ") (?で ?デ "デ") (?ど ?ド "ド")
+    (?ば ?バ "バ") (?び ?ビ "ビ") (?ぶ ?ブ "ブ") (?べ ?ベ "ベ") (?ぼ ?ボ "ボ")
+    (?ぱ ?パ "パ") (?ぴ ?ピ "ピ") (?ぷ ?プ "プ") (?ぺ ?ペ "ペ") (?ぽ ?ポ "ポ")
+    (?ぁ ?ァ ?ァ) (?ぃ ?ィ ?ィ) (?ぅ ?ゥ ?ゥ) (?ぇ ?ェ ?ェ) (?ぉ ?ォ ?ォ)
+    (?っ ?ッ ?ッ)
+    (?ゃ ?ャ ?ャ) (?ゅ ?ュ ?ュ) (?ょ ?ョ ?ョ)
+    (?ゎ ?ヮ "ワ")
+    (?ゝ ?ヽ) (?ゞ ?ヾ)
+    ("う゛" ?ヴ "ヴ") (nil ?ヵ "カ") (nil ?ヶ "ケ"))
   "Japanese JISX0208 Kana character table.
 Each element is of the form (HIRAGANA KATAKANA HANKAKU-KATAKANA), where
 HIRAGANA and KATAKANA belong to `japanese-jisx0208',
@@ -98,15 +96,15 @@ HANKAKU-KATAKANA belongs to `japanese-jisx0201-kana'.")
          (put-char-code-property jisx0201 'jisx0208 katakana)))))
 
 (defconst japanese-symbol-table
-  '((?\$B!!(B ?\ ) (?$B!$(B ?, ?(I$(B) (?$B!%(B ?. ?(I!(B) 
(?$B!"(B ?, ?(I$(B) (?$B!#(B ?. ?(I!(B) (?$B!&(B nil ?(I%(B)
-    (?$B!'(B ?:) (?$B!((B ?\;) (?$B!)(B ??) (?$B!*(B ?!) (?$B!+(B 
nil ?(I^(B) (?$B!,(B nil ?(I_(B)
-    (?$B!-(B ?') (?$B!.(B ?`) (?$B!0(B ?^) (?$B!2(B ?_) (?$B!<(B ?- 
?(I0(B) (?$B!=(B ?-) (?$B!>(B ?-)
-    (?$B!?(B ?/) (address@hidden(B ?\\) (?$B!A(B ?~)  (?$B!C(B ?|) 
(?$B!F(B ?`) (?$B!G(B ?') (?$B!H(B ?\") (?$B!I(B ?\")
-    (?\$B!J(B ?\() (?\$B!K(B ?\)) (?\$B!N(B ?\[) (?\$B!O(B ?\]) 
(?\$B!P(B ?{) (?\$B!Q(B ?})
-    (?$B!R(B ?<) (?$B!S(B ?>) (?\$B!V(B nil ?\(I"(B) (?\$B!W(B nil 
?\(I#(B)
-    (?$B!\(B ?+) (?$B!](B ?-) (?$B!a(B ?=) (?$B!c(B ?<) (?$B!d(B ?>)
-    (?$B!l(B ?') (?$B!m(B ?\") (?$B!o(B ?\\) (?$B!p(B ?$) (?$B!s(B 
?%) (?$B!t(B ?#) (?$B!u(B ?&) (?$B!v(B ?*)
-    (?$B!w(B ?@)
+  '((?\  ?\ ) (?, ?, ?、) (?. ?. ?。) (?、 ?, ?、) (?。 ?. ?。) (?・ nil ?・)
+    (?: ?:) (?; ?\;) (?? ??) (?! ?!) (?゛ nil ?゙) (?゜ nil ?゚)
+    (?´ ?') (?` ?`) (?^ ?^) (?_ ?_) (?ー ?- ?ー) (?— ?-) (?‐ ?-)
+    (?/ ?/) (?\ ?\\) (?〜 ?~)  (?| ?|) (?‘ ?`) (?’ ?') (?“ ?\") (?” ?\")
+    (?\( ?\() (?\) ?\)) (?\[ ?\[) (?\] ?\]) (?\{ ?{) (?\} ?})
+    (?〈 ?<) (?〉 ?>) (?\「 nil ?\「) (?\」 nil ?\」)
+    (?+ ?+) (?− ?-) (?= ?=) (?< ?<) (?> ?>)
+    (?′ ?') (?″ ?\") (?¥ ?\\) (?$ ?$) (?% ?%) (?# ?#) (?& ?&) (?* ?*)
+    (?@ ?@)
     ;; cp932-2-byte
     (#x2015 ?-) (#xFF5E ?~) (#xFF0D ?-))
   "Japanese JISX0208 and CP932 symbol character table.
@@ -134,18 +132,18 @@ and HANKAKU belongs to `japanese-jisx0201-kana'.")
              (put-char-code-property jisx0201 'jisx0208 jisx0208))))))
 
 (defconst japanese-alpha-numeric-table
-  '((?$B#0(B . ?0) (?$B#1(B . ?1) (?$B#2(B . ?2) (?$B#3(B . ?3) 
(?$B#4(B . ?4)
-    (?$B#5(B . ?5) (?$B#6(B . ?6) (?$B#7(B . ?7) (?$B#8(B . ?8) 
(?$B#9(B . ?9)
-    (?$B#A(B . ?A) (?$B#B(B . ?B) (?$B#C(B . ?C) (?$B#D(B . ?D) 
(?$B#E(B . ?E)
-    (?$B#F(B . ?F) (?$B#G(B . ?G) (?$B#H(B . ?H) (?$B#I(B . ?I) 
(?$B#J(B . ?J)
-    (?$B#K(B . ?K) (?$B#L(B . ?L) (?$B#M(B . ?M) (?$B#N(B . ?N) 
(?$B#O(B . ?O)
-    (?$B#P(B . ?P) (?$B#Q(B . ?Q) (?$B#R(B . ?R) (?$B#S(B . ?S) 
(?$B#T(B . ?T)
-    (?$B#U(B . ?U) (?$B#V(B . ?V) (?$B#W(B . ?W) (?$B#X(B . ?X) 
(?$B#Y(B . ?Y) (?$B#Z(B . ?Z)
-    (?$B#a(B . ?a) (?$B#b(B . ?b) (?$B#c(B . ?c) (?$B#d(B . ?d) 
(?$B#e(B . ?e)
-    (?$B#f(B . ?f) (?$B#g(B . ?g) (?$B#h(B . ?h) (?$B#i(B . ?i) 
(?$B#j(B . ?j)
-    (?$B#k(B . ?k) (?$B#l(B . ?l) (?$B#m(B . ?m) (?$B#n(B . ?n) 
(?$B#o(B . ?o)
-    (?$B#p(B . ?p) (?$B#q(B . ?q) (?$B#r(B . ?r) (?$B#s(B . ?s) 
(?$B#t(B . ?t)
-    (?$B#u(B . ?u) (?$B#v(B . ?v) (?$B#w(B . ?w) (?$B#x(B . ?x) 
(?$B#y(B . ?y) (?$B#z(B . ?z))
+  '((?0 . ?0) (?1 . ?1) (?2 . ?2) (?3 . ?3) (?4 . ?4)
+    (?5 . ?5) (?6 . ?6) (?7 . ?7) (?8 . ?8) (?9 . ?9)
+    (?A . ?A) (?B . ?B) (?C . ?C) (?D . ?D) (?E . ?E)
+    (?F . ?F) (?G . ?G) (?H . ?H) (?I . ?I) (?J . ?J)
+    (?K . ?K) (?L . ?L) (?M . ?M) (?N . ?N) (?O . ?O)
+    (?P . ?P) (?Q . ?Q) (?R . ?R) (?S . ?S) (?T . ?T)
+    (?U . ?U) (?V . ?V) (?W . ?W) (?X . ?X) (?Y . ?Y) (?Z . ?Z)
+    (?a . ?a) (?b . ?b) (?c . ?c) (?d . ?d) (?e . ?e)
+    (?f . ?f) (?g . ?g) (?h . ?h) (?i . ?i) (?j . ?j)
+    (?k . ?k) (?l . ?l) (?m . ?m) (?n . ?n) (?o . ?o)
+    (?p . ?p) (?q . ?q) (?r . ?r) (?s . ?s) (?t . ?t)
+    (?u . ?u) (?v . ?v) (?w . ?w) (?x . ?x) (?y . ?y) (?z . ?z))
   "Japanese JISX0208 alpha numeric character table.
 Each element is of the form (ALPHA-NUMERIC . ASCII), where ALPHA-NUMERIC
 belongs to `japanese-jisx0208', ASCII belongs to `ascii'.")
diff --git a/lisp/language/japanese.el b/lisp/language/japanese.el
index b1fb569..7a0fd74 100644
--- a/lisp/language/japanese.el
+++ b/lisp/language/japanese.el
@@ -1,6 +1,6 @@
-;;; japanese.el --- support for Japanese -*- coding: iso-2022-7bit -*-
+;;; japanese.el --- support for Japanese
 
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -210,7 +210,7 @@ eucJP-ms is defined in 
<http://www.opengroup.or.jp/jvc/cde/appendix.html>."
                                iso-2022-jp-2)
              (input-method . "japanese")
              (features japan-util)
-             (sample-text . "Japanese ($BF|K\8l(B)   $B$3$s$K$A$O(B, 
(I:]FAJ(B")
+             (sample-text . "Japanese (日本語)    こんにちは, コンニチハ")
              (documentation . t)))
 
 (let ((map
diff --git a/lisp/language/korea-util.el b/lisp/language/korea-util.el
index 04f7e8d..464a4ce 100644
--- a/lisp/language/korea-util.el
+++ b/lisp/language/korea-util.el
@@ -1,6 +1,6 @@
 ;;; korea-util.el --- utilities for Korean
 
-;; Copyright (C) 1997, 1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1999, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
 ;;   2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/language/korean.el b/lisp/language/korean.el
index 8e5ecb9..2c9780e 100644
--- a/lisp/language/korean.el
+++ b/lisp/language/korean.el
@@ -1,6 +1,6 @@
 ;;; korean.el --- support for Korean -*- coding: utf-8 -*-
 
-;; Copyright (C) 1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/language/lao-util.el b/lisp/language/lao-util.el
index 4d58be2..d253203 100644
--- a/lisp/language/lao-util.el
+++ b/lisp/language/lao-util.el
@@ -1,6 +1,6 @@
 ;;; lao-util.el --- utilities for Lao -*- coding: utf-8; -*-
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
 ;;   2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/language/lao.el b/lisp/language/lao.el
index 04ccd66..ff6578d 100644
--- a/lisp/language/lao.el
+++ b/lisp/language/lao.el
@@ -1,6 +1,6 @@
 ;;; lao.el --- support for Lao -*- coding: utf-8 -*-
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
 ;;   2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/language/romanian.el b/lisp/language/romanian.el
index c91726e..0a5d0ca 100644
--- a/lisp/language/romanian.el
+++ b/lisp/language/romanian.el
@@ -1,6 +1,6 @@
 ;;; romanian.el --- support for Romanian -*- coding: utf-8 -*-
 
-;; Copyright (C) 1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author:    Dan Nicolaescu <address@hidden>
 ;; Keywords: multilingual, Romanian, i18n
diff --git a/lisp/language/slovak.el b/lisp/language/slovak.el
index 2e935f8..4dfdb54 100644
--- a/lisp/language/slovak.el
+++ b/lisp/language/slovak.el
@@ -1,6 +1,6 @@
 ;;; slovak.el --- support for Slovak -*- coding: utf-8 -*-
 
-;; Copyright (C) 1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Authors:    Tibor Šimko <address@hidden>,
 ;;             Milan Zamazal <address@hidden>
diff --git a/lisp/language/tai-viet.el b/lisp/language/tai-viet.el
index fb5904f..b202abf 100644
--- a/lisp/language/tai-viet.el
+++ b/lisp/language/tai-viet.el
@@ -1,6 +1,6 @@
 ;;; tai-viet.el --- support for Tai Viet -*- coding: utf-8 -*-
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
 ;;   Registration Number H13PRO009
diff --git a/lisp/language/thai-util.el b/lisp/language/thai-util.el
index 638d483..e330395 100644
--- a/lisp/language/thai-util.el
+++ b/lisp/language/thai-util.el
@@ -1,6 +1,6 @@
 ;;; thai-util.el --- utilities for Thai -*- coding: utf-8; -*-
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/language/thai.el b/lisp/language/thai.el
index a896fe5..01ec0c0 100644
--- a/lisp/language/thai.el
+++ b/lisp/language/thai.el
@@ -1,6 +1,6 @@
 ;;; thai.el --- support for Thai -*- coding: utf-8 -*-
 
-;; Copyright (C) 1997-1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2000-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/language/tibet-util.el b/lisp/language/tibet-util.el
index a1aad7f..68faf20 100644
--- a/lisp/language/tibet-util.el
+++ b/lisp/language/tibet-util.el
@@ -1,6 +1,6 @@
 ;;; tibet-util.el --- utilities for Tibetan   -*- coding: utf-8-emacs; -*-
 
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/language/tibetan.el b/lisp/language/tibetan.el
index 3d1df3d..4be25ce 100644
--- a/lisp/language/tibetan.el
+++ b/lisp/language/tibetan.el
@@ -1,6 +1,6 @@
 ;;; tibetan.el --- support for Tibetan language -*- coding: utf-8-emacs; -*-
 
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 ;;   2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/language/utf-8-lang.el b/lisp/language/utf-8-lang.el
index 5d8a044..d4897c9 100644
--- a/lisp/language/utf-8-lang.el
+++ b/lisp/language/utf-8-lang.el
@@ -1,6 +1,6 @@
 ;;; utf-8-lang.el --- generic UTF-8 language environment
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Love <address@hidden>
 ;; Keywords: i18n
diff --git a/lisp/language/viet-util.el b/lisp/language/viet-util.el
index a926c19..d83aeb5 100644
--- a/lisp/language/viet-util.el
+++ b/lisp/language/viet-util.el
@@ -1,6 +1,6 @@
 ;;; viet-util.el --- utilities for Vietnamese  -*- coding: utf-8; -*-
 
-;; Copyright (C) 1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/language/vietnamese.el b/lisp/language/vietnamese.el
index 9524349..432dd3e 100644
--- a/lisp/language/vietnamese.el
+++ b/lisp/language/vietnamese.el
@@ -1,6 +1,6 @@
 ;;; vietnamese.el --- support for Vietnamese -*- coding: utf-8; -*-
 
-;; Copyright (C) 1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 ;;   2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/ldefs-boot.el b/lisp/ldefs-boot.el
index f90815d..ccf2cdc 100644
--- a/lisp/ldefs-boot.el
+++ b/lisp/ldefs-boot.el
@@ -33,25 +33,17 @@ Quit current game           \\[5x5-quit-game]
 \(fn &optional SIZE)" t nil)
 
 (autoload '5x5-crack-randomly "5x5" "\
-Attempt to crack 5x5 using random solutions.
-
-\(fn)" t nil)
+Attempt to crack 5x5 using random solutions." t nil)
 
 (autoload '5x5-crack-mutating-current "5x5" "\
-Attempt to crack 5x5 by mutating the current solution.
-
-\(fn)" t nil)
+Attempt to crack 5x5 by mutating the current solution." t nil)
 
 (autoload '5x5-crack-mutating-best "5x5" "\
-Attempt to crack 5x5 by mutating the best solution.
-
-\(fn)" t nil)
+Attempt to crack 5x5 by mutating the best solution." t nil)
 
 (autoload '5x5-crack-xor-mutate "5x5" "\
 Attempt to crack 5x5 by xoring the current and best solution.
-Mutate the result.
-
-\(fn)" t nil)
+Mutate the result." t nil)
 
 (autoload '5x5-crack "5x5" "\
 Attempt to find a solution for 5x5.
@@ -99,9 +91,7 @@ Ada mode is the major mode for editing Ada code.
 ;;; Generated autoloads from progmodes/ada-stmt.el
 
 (autoload 'ada-header "ada-stmt" "\
-Insert a descriptive header at the top of the file.
-
-\(fn)" t nil)
+Insert a descriptive header at the top of the file." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"ada-stmt" '("ada-")))
 
@@ -149,9 +139,7 @@ ChangeLog entry, one element will be chosen at random.")
 (custom-autoload 'add-log-mailing-address "add-log" t)
 
 (autoload 'prompt-for-change-log-name "add-log" "\
-Prompt for a change log name.
-
-\(fn)" nil nil)
+Prompt for a change log name." nil nil)
 
 (autoload 'find-change-log "add-log" "\
 Find a change log file for \\[add-change-log-entry] and return the name.
@@ -242,9 +230,7 @@ identifiers followed by `:' or `='.  See variables
 `add-log-current-defun-header-regexp' and
 `add-log-current-defun-function'.
 
-Has a preference of looking backwards.
-
-\(fn)" nil nil)
+Has a preference of looking backwards." nil nil)
 
 (autoload 'change-log-merge "add-log" "\
 Merge the contents of change log file OTHER-LOG with this buffer.
@@ -490,16 +476,12 @@ to be colored.
 \(fn BEG END TITLE &optional RULES EXCLUDE-RULES)" t nil)
 
 (autoload 'align-unhighlight-rule "align" "\
-Remove any highlighting that was added by `align-highlight-rule'.
-
-\(fn)" t nil)
+Remove any highlighting that was added by `align-highlight-rule'." t nil)
 
 (autoload 'align-newline-and-indent "align" "\
 A replacement function for `newline-and-indent', aligning as it goes.
 The alignment is done by calling `align' on the region that was
-indented.
-
-\(fn)" t nil)
+indented." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"align" '("align-")))
 
@@ -523,9 +505,7 @@ Establishes allout processing as part of visiting a file if
 `allout-auto-activation' is non-nil, or removes it otherwise.
 
 The proper way to use this is through customizing the setting of
-`allout-auto-activation'.
-
-\(fn)" nil nil)
+`allout-auto-activation'." nil nil)
 
 (defvar allout-auto-activation nil "\
 Configure allout outline mode auto-activation.
@@ -577,9 +557,7 @@ With value nil, inhibit any automatic allout-mode 
activation.")
 (put 'allout-layout 'safe-local-variable (lambda (x) (or (numberp x) (listp x) 
(memq x '(: * + -)))))
 
 (autoload 'allout-mode-p "allout" "\
-Return t if `allout-mode' is active in current buffer.
-
-\(fn)" nil t)
+Return t if `allout-mode' is active in current buffer." nil t)
 
 (autoload 'allout-mode "allout" "\
 Toggle Allout outline mode.
@@ -990,9 +968,7 @@ the buffer *Birthday-Present-for-Name*.
 (push (purecopy '(ansi-color 3 4 2)) package--builtin-versions)
 
 (autoload 'ansi-color-for-comint-mode-on "ansi-color" "\
-Set `ansi-color-for-comint-mode' to t.
-
-\(fn)" t nil)
+Set `ansi-color-for-comint-mode' to t." t nil)
 
 (autoload 'ansi-color-process-output "ansi-color" "\
 Maybe translate SGR control sequences of comint output into text properties.
@@ -1033,9 +1009,7 @@ the rules.
 If the file for a super-grammar cannot be determined, special file names
 are used according to variable `antlr-unknown-file-formats' and a
 commentary with value `antlr-help-unknown-file-text' is added.  The
-*Help* buffer always starts with the text in `antlr-help-rules-intro'.
-
-\(fn)" t nil)
+*Help* buffer always starts with the text in `antlr-help-rules-intro'." t nil)
 
 (autoload 'antlr-mode "antlr-mode" "\
 Major mode for editing ANTLR grammar files.
@@ -1044,9 +1018,7 @@ Major mode for editing ANTLR grammar files.
 
 (autoload 'antlr-set-tabs "antlr-mode" "\
 Use ANTLR's convention for TABs according to `antlr-tab-offset-alist'.
-Used in `antlr-mode'.  Also a useful function in `java-mode-hook'.
-
-\(fn)" nil nil)
+Used in `antlr-mode'.  Also a useful function in `java-mode-hook'." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"antlr-mode" '("antlr-")))
 
@@ -1566,9 +1538,7 @@ let-binding.")
 (push (purecopy '(auth-source-pass 4 0 1)) package--builtin-versions)
 
 (autoload 'auth-source-pass-enable "auth-source-pass" "\
-Enable auth-source-password-store.
-
-\(fn)" nil nil)
+Enable auth-source-password-store." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"auth-source-pass" '("auth-source-pass-")))
 
@@ -1654,9 +1624,7 @@ Major mode for editing Autoconf configure.ac files.
 
 (autoload 'auto-insert "autoinsert" "\
 Insert default contents into new files if variable `auto-insert' is non-nil.
-Matches the visited file name against the elements of `auto-insert-alist'.
-
-\(fn)" t nil)
+Matches the visited file name against the elements of `auto-insert-alist'." t 
nil)
 
 (autoload 'define-auto-insert "autoinsert" "\
 Associate CONDITION with (additional) ACTION in `auto-insert-alist'.
@@ -1738,9 +1706,7 @@ write its autoloads into the specified file instead.
 Update loaddefs.el autoloads in batch mode.
 Calls `update-directory-autoloads' on the command line arguments.
 Definitions are written to `generated-autoload-file' (which
-should be non-nil).
-
-\(fn)" nil nil)
+should be non-nil)." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"autoload" '("autoload-" "generate" "make-autoload" "no-update-autoloads")))
 
@@ -1774,9 +1740,7 @@ without being changed in the part that is already in the 
buffer.
 Turn on Auto-Revert Mode.
 
 This function is designed to be added to hooks, for example:
-  (add-hook \\='c-mode-hook #\\='turn-on-auto-revert-mode)
-
-\(fn)" nil nil)
+  (add-hook \\='c-mode-hook #\\='turn-on-auto-revert-mode)" nil nil)
 
 (autoload 'auto-revert-tail-mode "autorevert" "\
 Toggle reverting tail of buffer when the file grows.
@@ -1807,9 +1771,7 @@ Use `auto-revert-mode' for changes other than appends!
 Turn on Auto-Revert Tail Mode.
 
 This function is designed to be added to hooks, for example:
-  (add-hook \\='my-logfile-mode-hook #\\='turn-on-auto-revert-tail-mode)
-
-\(fn)" nil nil)
+  (add-hook \\='my-logfile-mode-hook #\\='turn-on-auto-revert-tail-mode)" nil 
nil)
 
 (defvar global-auto-revert-mode nil "\
 Non-nil if Global Auto-Revert mode is enabled.
@@ -1907,9 +1869,7 @@ definition of \"random distance\".)
 
 (autoload 'backtrace "backtrace" "\
 Print a trace of Lisp function calls currently active.
-Output stream used is value of `standard-output'.
-
-\(fn)" nil nil)
+Output stream used is value of `standard-output'." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"backtrace" '("backtrace-")))
 
@@ -1942,9 +1902,7 @@ Run script using `bat-run' and `bat-run-args'.
 (autoload 'battery "battery" "\
 Display battery status information in the echo area.
 The text being displayed in the echo area is controlled by the variables
-`battery-echo-area-format' and `battery-status-function'.
-
-\(fn)" t nil)
+`battery-echo-area-format' and `battery-status-function'." t nil)
 
 (defvar display-battery-mode nil "\
 Non-nil if Display-Battery mode is enabled.
@@ -2443,9 +2401,7 @@ probably because we were called from there.
 \(fn BOOKMARK-NAME &optional BATCH)" t nil)
 
 (autoload 'bookmark-write "bookmark" "\
-Write bookmarks to a file (reading the file name with the minibuffer).
-
-\(fn)" t nil)
+Write bookmarks to a file (reading the file name with the minibuffer)." t nil)
 
 (function-put 'bookmark-write 'interactive-only 'bookmark-save)
 
@@ -2492,18 +2448,14 @@ unique numeric suffixes \"<2>\", \"<3>\", etc.
 Display a list of existing bookmarks.
 The list is displayed in a buffer named `*Bookmark List*'.
 The leftmost column displays a D if the bookmark is flagged for
-deletion, or > if it is flagged for displaying.
-
-\(fn)" t nil)
+deletion, or > if it is flagged for displaying." t nil)
 
 (defalias 'list-bookmarks 'bookmark-bmenu-list)
 
 (defalias 'edit-bookmarks 'bookmark-bmenu-list)
 
 (autoload 'bookmark-bmenu-search "bookmark" "\
-Incremental search of bookmarks, hiding the non-matches as we go.
-
-\(fn)" t nil)
+Incremental search of bookmarks, hiding the non-matches as we go." t nil)
 
 (defvar menu-bar-bookmark-map (let ((map (make-sparse-keymap "Bookmark 
functions"))) (bindings--define-key map [load] '(menu-item "Load a Bookmark 
File..." bookmark-load :help "Load bookmarks from a bookmark file)")) 
(bindings--define-key map [write] '(menu-item "Save Bookmarks As..." 
bookmark-write :help "Write bookmarks to a file (reading the file name with the 
minibuffer)")) (bindings--define-key map [save] '(menu-item "Save Bookmarks" 
bookmark-save :help "Save currently defined bookm [...]
 
@@ -2547,9 +2499,7 @@ narrowed.
 \(fn &optional BUFFER)" t nil)
 
 (autoload 'browse-url-of-dired-file "browse-url" "\
-In Dired, ask a WWW browser to display the file named on this line.
-
-\(fn)" t nil)
+In Dired, ask a WWW browser to display the file named on this line." t nil)
 
 (autoload 'browse-url-of-region "browse-url" "\
 Ask a WWW browser to display the current region.
@@ -2872,21 +2822,15 @@ from `browse-url-elinks-wrapper'.
 (autoload 'bs-cycle-next "bs" "\
 Select next buffer defined by buffer cycling.
 The buffers taking part in buffer cycling are defined
-by buffer configuration `bs-cycle-configuration-name'.
-
-\(fn)" t nil)
+by buffer configuration `bs-cycle-configuration-name'." t nil)
 
 (autoload 'bs-cycle-previous "bs" "\
 Select previous buffer defined by buffer cycling.
 The buffers taking part in buffer cycling are defined
-by buffer configuration `bs-cycle-configuration-name'.
-
-\(fn)" t nil)
+by buffer configuration `bs-cycle-configuration-name'." t nil)
 
 (autoload 'bs-customize "bs" "\
-Customization of group bs for Buffer Selection Menu.
-
-\(fn)" t nil)
+Customization of group bs for Buffer Selection Menu." t nil)
 
 (autoload 'bs-show "bs" "\
 Make a menu of buffers so you can manipulate buffers or the buffer list.
@@ -2923,9 +2867,7 @@ columns on its right towards the left.
 \\[bubbles-set-game-easy] sets the difficulty to easy.
 \\[bubbles-set-game-medium] sets the difficulty to medium.
 \\[bubbles-set-game-difficult] sets the difficulty to difficult.
-\\[bubbles-set-game-hard] sets the difficulty to hard.
-
-\(fn)" t nil)
+\\[bubbles-set-game-hard] sets the difficulty to hard." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"bubbles" '("bubbles-")))
 
@@ -3065,9 +3007,7 @@ invoked interactively.
 (autoload 'batch-byte-compile-if-not-done "bytecomp" "\
 Like `byte-compile-file' but doesn't recompile if already up to date.
 Use this from the command line, with `-batch';
-it won't work in an interactive Emacs.
-
-\(fn)" nil nil)
+it won't work in an interactive Emacs." nil nil)
 
 (autoload 'batch-byte-compile "bytecomp" "\
 Run `byte-compile-file' on the files remaining on the command line.
@@ -3627,9 +3567,7 @@ See Info node `(calc)Defining Functions'.
 
 (autoload 'calculator "calculator" "\
 Run the Emacs calculator.
-See the documentation for `calculator-mode' for more information.
-
-\(fn)" t nil)
+See the documentation for `calculator-mode' for more information." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"calculator" '("calculator-")))
 
@@ -3739,9 +3677,7 @@ it fails.
 ;;; Generated autoloads from progmodes/cc-engine.el
 
 (autoload 'c-guess-basic-syntax "cc-engine" "\
-Return the syntactic context of the current line.
-
-\(fn)" nil nil)
+Return the syntactic context of the current line." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"cc-engine" '("c-")))
 
@@ -3919,9 +3855,7 @@ should be used.
 
 This function attempts to use file contents to determine whether
 the code is C or C++ and based on that chooses whether to enable
-`c-mode' or `c++-mode'.
-
-\(fn)" nil nil)
+`c-mode' or `c++-mode'." nil nil)
 
 (autoload 'c++-mode "cc-mode" "\
 Major mode for editing C++ code.
@@ -4494,9 +4428,7 @@ to the action header.
 \(fn)" t nil)
 
 (autoload 'cfengine-auto-mode "cfengine" "\
-Choose `cfengine2-mode' or `cfengine3-mode' by buffer contents.
-
-\(fn)" t nil)
+Choose `cfengine2-mode' or `cfengine3-mode' by buffer contents." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"cfengine" '("cfengine")))
 
@@ -4574,9 +4506,7 @@ Return t when OBJ is a list of strings.
 (autoload 'checkdoc "checkdoc" "\
 Interactively check the entire buffer for style errors.
 The current status of the check will be displayed in a buffer which
-the users will view as each check is completed.
-
-\(fn)" t nil)
+the users will view as each check is completed." t nil)
 
 (autoload 'checkdoc-interactive "checkdoc" "\
 Interactively check the current buffer for doc string errors.
@@ -4604,9 +4534,7 @@ checkdoc status window instead of the usual behavior.
 Evaluate and check documentation for the current buffer.
 Evaluation is done first because good documentation for something that
 doesn't work is just not useful.  Comments, doc strings, and rogue
-spacing are all verified.
-
-\(fn)" t nil)
+spacing are all verified." t nil)
 
 (autoload 'checkdoc-current-buffer "checkdoc" "\
 Check current buffer for document, comment, error style, and rogue spaces.
@@ -4664,9 +4592,7 @@ Optional argument TAKE-NOTES causes all errors to be 
logged.
 Evaluate the current form with `eval-defun' and check its documentation.
 Evaluation is done first so the form will be read before the
 documentation is checked.  If there is a documentation error, then the display
-of what was evaluated will be overwritten by the diagnostic message.
-
-\(fn)" t nil)
+of what was evaluated will be overwritten by the diagnostic message." t nil)
 
 (autoload 'checkdoc-defun "checkdoc" "\
 Examine the doc string of the function or variable under point.
@@ -4680,65 +4606,47 @@ space at the end of each line.
 (autoload 'checkdoc-ispell "checkdoc" "\
 Check the style and spelling of everything interactively.
 Calls `checkdoc' with spell-checking turned on.
-Prefix argument is the same as for `checkdoc'
-
-\(fn)" t nil)
+Prefix argument is the same as for `checkdoc'" t nil)
 
 (autoload 'checkdoc-ispell-current-buffer "checkdoc" "\
 Check the style and spelling of the current buffer.
 Calls `checkdoc-current-buffer' with spell-checking turned on.
-Prefix argument is the same as for `checkdoc-current-buffer'
-
-\(fn)" t nil)
+Prefix argument is the same as for `checkdoc-current-buffer'" t nil)
 
 (autoload 'checkdoc-ispell-interactive "checkdoc" "\
 Check the style and spelling of the current buffer interactively.
 Calls `checkdoc-interactive' with spell-checking turned on.
-Prefix argument is the same as for `checkdoc-interactive'
-
-\(fn)" t nil)
+Prefix argument is the same as for `checkdoc-interactive'" t nil)
 
 (autoload 'checkdoc-ispell-message-interactive "checkdoc" "\
 Check the style and spelling of message text interactively.
 Calls `checkdoc-message-interactive' with spell-checking turned on.
-Prefix argument is the same as for `checkdoc-message-interactive'
-
-\(fn)" t nil)
+Prefix argument is the same as for `checkdoc-message-interactive'" t nil)
 
 (autoload 'checkdoc-ispell-message-text "checkdoc" "\
 Check the style and spelling of message text interactively.
 Calls `checkdoc-message-text' with spell-checking turned on.
-Prefix argument is the same as for `checkdoc-message-text'
-
-\(fn)" t nil)
+Prefix argument is the same as for `checkdoc-message-text'" t nil)
 
 (autoload 'checkdoc-ispell-start "checkdoc" "\
 Check the style and spelling of the current buffer.
 Calls `checkdoc-start' with spell-checking turned on.
-Prefix argument is the same as for `checkdoc-start'
-
-\(fn)" t nil)
+Prefix argument is the same as for `checkdoc-start'" t nil)
 
 (autoload 'checkdoc-ispell-continue "checkdoc" "\
 Check the style and spelling of the current buffer after point.
 Calls `checkdoc-continue' with spell-checking turned on.
-Prefix argument is the same as for `checkdoc-continue'
-
-\(fn)" t nil)
+Prefix argument is the same as for `checkdoc-continue'" t nil)
 
 (autoload 'checkdoc-ispell-comments "checkdoc" "\
 Check the style and spelling of the current buffer's comments.
 Calls `checkdoc-comments' with spell-checking turned on.
-Prefix argument is the same as for `checkdoc-comments'
-
-\(fn)" t nil)
+Prefix argument is the same as for `checkdoc-comments'" t nil)
 
 (autoload 'checkdoc-ispell-defun "checkdoc" "\
 Check the style and spelling of the current defun with Ispell.
 Calls `checkdoc-defun' with spell-checking turned on.
-Prefix argument is the same as for `checkdoc-defun'
-
-\(fn)" t nil)
+Prefix argument is the same as for `checkdoc-defun'" t nil)
 
 (autoload 'checkdoc-minor-mode "checkdoc" "\
 Toggle automatic docstring checking (Checkdoc minor mode).
@@ -4757,9 +4665,7 @@ checking of documentation strings.
 \(fn &optional ARG)" t nil)
 
 (autoload 'checkdoc-package-keywords "checkdoc" "\
-Find package keywords that aren't in `finder-known-keywords'.
-
-\(fn)" t nil)
+Find package keywords that aren't in `finder-known-keywords'." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"checkdoc" '("checkdoc-")))
 
@@ -4776,9 +4682,7 @@ Return the length of resulting text.
 \(fn BEG END)" t nil)
 
 (autoload 'decode-hz-buffer "china-util" "\
-Decode HZ/ZW encoded text in the current buffer.
-
-\(fn)" t nil)
+Decode HZ/ZW encoded text in the current buffer." t nil)
 
 (autoload 'encode-hz-region "china-util" "\
 Encode the text in the current region to HZ.
@@ -4787,9 +4691,7 @@ Return the length of resulting text.
 \(fn BEG END)" t nil)
 
 (autoload 'encode-hz-buffer "china-util" "\
-Encode the text in the current buffer to HZ.
-
-\(fn)" t nil)
+Encode the text in the current buffer to HZ." t nil)
 
 (autoload 'post-read-decode-hz "china-util" "\
 
@@ -4823,9 +4725,7 @@ The number of commands listed is controlled by 
`list-command-history-max'.
 Calls value of `list-command-history-filter' (if non-nil) on each history
 element to judge if that element should be excluded from the list.
 
-The buffer is left in Command History mode.
-
-\(fn)" t nil)
+The buffer is left in Command History mode." t nil)
 
 (autoload 'command-history "chistory" "\
 Examine commands from `command-history' in a buffer.
@@ -4838,9 +4738,7 @@ and digits provide prefix arguments.  Tab does not indent.
 \\{command-history-map}
 
 This command always recompiles the Command History listing
-and runs the normal hook `command-history-hook'.
-
-\(fn)" t nil)
+and runs the normal hook `command-history-hook'." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"chistory" '("command-history-" "default-command-history-filter" 
"list-command-history-")))
 
@@ -5526,9 +5424,7 @@ doesn't have enough contents to decide, this is identical 
to
 See also `conf-space-mode', `conf-colon-mode', `conf-javaprop-mode',
 `conf-ppd-mode' and `conf-xdefaults-mode'.
 
-\\{conf-mode-map}
-
-\(fn)" t nil)
+\\{conf-mode-map}" t nil)
 
 (autoload 'conf-unix-mode "conf-mode" "\
 Conf Mode starter for Unix style Conf files.
@@ -5720,9 +5616,7 @@ interactively.
 Convert 2 digit years to 4 digit years.
 Uses heuristic: year >= 50 means 19xx, < 50 means 20xx.
 If `copyright-year-ranges' (which see) is non-nil, also
-independently replaces consecutive years with a range.
-
-\(fn)" t nil)
+independently replaces consecutive years with a range." t nil)
 
 (autoload 'copyright "copyright" "\
 Insert a copyright by $ORGANIZATION notice at cursor.
@@ -5932,9 +5826,7 @@ Run `perldoc' on WORD.
 \(fn WORD)" t nil)
 
 (autoload 'cperl-perldoc-at-point "cperl-mode" "\
-Run a `perldoc' on the word around point.
-
-\(fn)" t nil)
+Run a `perldoc' on the word around point." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"cperl-mode" '("cperl-" "pod2man-program")))
 
@@ -5952,9 +5844,7 @@ A prefix arg suppresses display of that buffer.
 \(fn ARG)" t nil)
 
 (autoload 'cpp-parse-edit "cpp" "\
-Edit display information for cpp conditionals.
-
-\(fn)" t nil)
+Edit display information for cpp conditionals." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"cpp" '("cpp-")))
 
@@ -6112,7 +6002,10 @@ if ARG is `toggle'; disable the mode otherwise.
 ;;;;;;  (0 0 0 0))
 ;;; Generated autoloads from emacs-lisp/cursor-sensor.el
 
-(defvar cursor-sensor-inhibit nil)
+(defvar cursor-sensor-inhibit nil "\
+When non-nil, suspend `cursor-sensor-mode' and `cursor-intangible-mode'.
+By convention, this is a list of symbols where each symbol stands for the
+\"cause\" of the suspension.")
 
 (autoload 'cursor-intangible-mode "cursor-sensor" "\
 Keep cursor outside of any `cursor-intangible' text property.
@@ -6230,9 +6123,7 @@ the resulting list value now.  Otherwise, add an entry to
 Select a customization buffer which you can use to set user options.
 User options are structured into \"groups\".
 Initially the top-level group `Emacs' and its immediate subgroups
-are shown; the contents of those subgroups are initially hidden.
-
-\(fn)" t nil)
+are shown; the contents of those subgroups are initially hidden." t nil)
 
 (autoload 'customize-mode "cus-edit" "\
 Customize options related to a major or minor mode.
@@ -6335,19 +6226,13 @@ suggest to customize that face, if it's customizable.
 \(fn &optional FACE)" t nil)
 
 (autoload 'customize-unsaved "cus-edit" "\
-Customize all options and faces set in this session but not saved.
-
-\(fn)" t nil)
+Customize all options and faces set in this session but not saved." t nil)
 
 (autoload 'customize-rogue "cus-edit" "\
-Customize all user variables modified outside customize.
-
-\(fn)" t nil)
+Customize all user variables modified outside customize." t nil)
 
 (autoload 'customize-saved "cus-edit" "\
-Customize all saved options and faces.
-
-\(fn)" t nil)
+Customize all saved options and faces." t nil)
 
 (autoload 'customize-apropos "cus-edit" "\
 Customize loaded options, faces and groups matching PATTERN.
@@ -6380,9 +6265,7 @@ Customize all loaded groups matching REGEXP.
 (autoload 'custom-prompt-customize-unsaved-options "cus-edit" "\
 Prompt user to customize any unsaved customization options.
 Return non-nil if user chooses to customize, for use in
-`kill-emacs-query-functions'.
-
-\(fn)" nil nil)
+`kill-emacs-query-functions'." nil nil)
 
 (autoload 'custom-buffer-create "cus-edit" "\
 Create a buffer containing OPTIONS.
@@ -6446,14 +6329,10 @@ and hence will not set `custom-file' to that file 
either.")
 (custom-autoload 'custom-file "cus-edit" t)
 
 (autoload 'custom-save-all "cus-edit" "\
-Save all customizations in `custom-file'.
-
-\(fn)" nil nil)
+Save all customizations in `custom-file'." nil nil)
 
 (autoload 'customize-save-customized "cus-edit" "\
-Save all user options which have been set in this session.
-
-\(fn)" t nil)
+Save all user options which have been set in this session." t nil)
 
 (autoload 'custom-menu-create "cus-edit" "\
 Create menu for customization group SYMBOL.
@@ -6851,7 +6730,7 @@ Trigger a debugger invocation when VARIABLE is changed.
 
 When called interactively, prompt for VARIABLE in the minibuffer.
 
-This works by calling `add-variable-watch' on VARIABLE.  If you
+This works by calling `add-variable-watcher' on VARIABLE.  If you
 quit from the debugger, this will abort the change (unless the
 change is caused by the termination of a let-binding).
 
@@ -6886,9 +6765,7 @@ To specify a nil argument interactively, exit with an 
empty minibuffer.
 ;;; Generated autoloads from play/decipher.el
 
 (autoload 'decipher "decipher" "\
-Format a buffer of ciphertext for cryptanalysis and enter Decipher mode.
-
-\(fn)" t nil)
+Format a buffer of ciphertext for cryptanalysis and enter Decipher mode." t 
nil)
 
 (autoload 'decipher-mode "decipher" "\
 Major mode for decrypting monoalphabetic substitution ciphers.
@@ -6904,9 +6781,7 @@ The most useful commands are:
 \\[decipher-frequency-count]  Display the frequency of each ciphertext letter
 \\[decipher-adjacency-list]  Show adjacency list for current letter (lists 
letters appearing next to it)
 \\[decipher-make-checkpoint]  Save the current cipher alphabet (checkpoint)
-\\[decipher-restore-checkpoint]  Restore a saved cipher alphabet (checkpoint)
-
-\(fn)" t nil)
+\\[decipher-restore-checkpoint]  Restore a saved cipher alphabet (checkpoint)" 
t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"decipher" '("decipher-")))
 
@@ -6917,9 +6792,7 @@ The most useful commands are:
 (push (purecopy '(delim-col 2 1)) package--builtin-versions)
 
 (autoload 'delimit-columns-customize "delim-col" "\
-Customization of `columns' group.
-
-\(fn)" t nil)
+Customization of `columns' group." t nil)
 
 (autoload 'delimit-columns-region "delim-col" "\
 Prettify all columns in a text region.
@@ -7098,9 +6971,7 @@ of `eldoc-echo-area-use-multiline-p' variable and width of
 minibuffer window for width limit.
 
 This function is meant to be used as a value of
-`eldoc-documentation-function' variable.
-
-\(fn)" nil nil)
+`eldoc-documentation-function' variable." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"descr-text" '("describe-")))
 
@@ -7259,9 +7130,7 @@ a regular expression in the list 
`desktop-clear-preserve-buffers'.
 Furthermore, it clears the variables listed in `desktop-globals-to-clear'.
 When called interactively and `desktop-restore-frames' is non-nil, it also
 deletes all frames except the selected one (and its minibuffer frame,
-if different).
-
-\(fn)" t nil)
+if different)." t nil)
 
 (autoload 'desktop-save "desktop" "\
 Save the desktop in a desktop file.
@@ -7293,9 +7162,7 @@ without further confirmation.
 
 (autoload 'desktop-remove "desktop" "\
 Delete desktop file in `desktop-dirname'.
-This function also sets `desktop-dirname' to nil.
-
-\(fn)" t nil)
+This function also sets `desktop-dirname' to nil." t nil)
 
 (autoload 'desktop-read "desktop" "\
 Read and process the desktop file in directory DIRNAME.
@@ -7317,14 +7184,10 @@ directory DIRNAME.
 \(fn DIRNAME)" t nil)
 
 (autoload 'desktop-save-in-desktop-dir "desktop" "\
-Save the desktop in directory `desktop-dirname'.
-
-\(fn)" t nil)
+Save the desktop in directory `desktop-dirname'." t nil)
 
 (autoload 'desktop-revert "desktop" "\
-Revert to the last loaded desktop.
-
-\(fn)" t nil)
+Revert to the last loaded desktop." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"desktop" '("desktop-")))
 
@@ -7356,9 +7219,7 @@ NODISPLAY is non-nil, don't redisplay the article buffer.
 \(fn &optional NODISPLAY)" t nil)
 
 (autoload 'gnus-article-outlook-deuglify-article "deuglify" "\
-Deuglify broken Outlook (Express) articles and redisplay.
-
-\(fn)" t nil)
+Deuglify broken Outlook (Express) articles and redisplay." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"deuglify" '("gnus-")))
 
@@ -7717,9 +7578,7 @@ redefine OBJECT if it is a symbol.
 ;;; Generated autoloads from disp-table.el
 
 (autoload 'make-display-table "disp-table" "\
-Return a new, empty display table.
-
-\(fn)" nil nil)
+Return a new, empty display table." nil nil)
 
 (autoload 'display-table-slot "disp-table" "\
 Return the value of the extra slot in DISPLAY-TABLE named SLOT.
@@ -7743,9 +7602,7 @@ Describe the display table DT in a help buffer.
 \(fn DT)" nil nil)
 
 (autoload 'describe-current-display-table "disp-table" "\
-Describe the display table in use in the selected window and buffer.
-
-\(fn)" t nil)
+Describe the display table in use in the selected window and buffer." t nil)
 
 (autoload 'standard-display-8bit "disp-table" "\
 Display characters representing raw bytes in the range L to H literally.
@@ -7943,9 +7800,7 @@ Turning on DNS mode runs `dns-mode-hook'.
  (defalias 'zone-mode 'dns-mode)
 
 (autoload 'dns-mode-soa-increment-serial "dns-mode" "\
-Locate SOA record and increment the serial field.
-
-\(fn)" t nil)
+Locate SOA record and increment the serial field." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"dns-mode" '("dns-mode-")))
 
@@ -7969,16 +7824,12 @@ and DVI files (as PNG images) in Emacs buffers.
 
 You can use \\<doc-view-mode-map>\\[doc-view-toggle-display] to
 toggle between displaying the document or editing it as text.
-\\{doc-view-mode-map}
-
-\(fn)" t nil)
+\\{doc-view-mode-map}" t nil)
 
 (autoload 'doc-view-mode-maybe "doc-view" "\
 Switch to `doc-view-mode' if possible.
 If the required external tools are not available, then fallback
-to the next best mode.
-
-\(fn)" nil nil)
+to the next best mode." nil nil)
 
 (autoload 'doc-view-minor-mode "doc-view" "\
 Toggle displaying buffer via Doc View (Doc View minor mode).
@@ -8005,9 +7856,7 @@ See the command `doc-view-mode' for more information on 
this mode.
 ;;; Generated autoloads from play/doctor.el
 
 (autoload 'doctor "doctor" "\
-Switch to *doctor* buffer and start giving psychotherapy.
-
-\(fn)" t nil)
+Switch to *doctor* buffer and start giving psychotherapy." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"doctor" '("doc" "make-doctor-variables")))
 
@@ -8066,9 +7915,7 @@ strings when pressed twice.  See `double-map' for details.
 (push (purecopy '(dunnet 2 2)) package--builtin-versions)
 
 (autoload 'dunnet "dunnet" "\
-Switch to *dungeon* buffer and start game.
-
-\(fn)" t nil)
+Switch to *dungeon* buffer and start game." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"dunnet" '("dun" "obj-special")))
 
@@ -8429,9 +8276,7 @@ To implement dynamic menus, either call this from
 (push (purecopy '(ebnf2ps 4 4)) package--builtin-versions)
 
 (autoload 'ebnf-customize "ebnf2ps" "\
-Customization for ebnf group.
-
-\(fn)" t nil)
+Customization for ebnf group." t nil)
 
 (autoload 'ebnf-print-directory "ebnf2ps" "\
 Generate and print a PostScript syntactic chart image of DIRECTORY.
@@ -8502,9 +8347,7 @@ Generate and spool a PostScript syntactic chart image of 
the buffer.
 Like `ebnf-print-buffer' except that the PostScript image is saved in a
 local buffer to be sent to the printer later.
 
-Use the command `ebnf-despool' to send the spooled images to the printer.
-
-\(fn)" t nil)
+Use the command `ebnf-despool' to send the spooled images to the printer." t 
nil)
 
 (autoload 'ebnf-spool-region "ebnf2ps" "\
 Generate a PostScript syntactic chart image of the region and spool locally.
@@ -8554,9 +8397,7 @@ The EPS file name has the following form:
             file name used in this case will be \"ebnf--A_B_+_C.eps\".
 
 WARNING: This function does *NOT* ask any confirmation to override existing
-        files.
-
-\(fn)" t nil)
+        files." t nil)
 
 (autoload 'ebnf-eps-region "ebnf2ps" "\
 Generate a PostScript syntactic chart image of the region in an EPS file.
@@ -8605,9 +8446,7 @@ See also `ebnf-syntax-buffer'.
 \(fn FILE &optional DO-NOT-KILL-BUFFER-WHEN-DONE)" t nil)
 
 (autoload 'ebnf-syntax-buffer "ebnf2ps" "\
-Do a syntactic analysis of the current buffer.
-
-\(fn)" t nil)
+Do a syntactic analysis of the current buffer." t nil)
 
 (autoload 'ebnf-syntax-region "ebnf2ps" "\
 Do a syntactic analysis of a region.
@@ -8615,9 +8454,7 @@ Do a syntactic analysis of a region.
 \(fn FROM TO)" t nil)
 
 (autoload 'ebnf-setup "ebnf2ps" "\
-Return the current ebnf2ps setup.
-
-\(fn)" nil nil)
+Return the current ebnf2ps setup." nil nil)
 
 (autoload 'ebnf-find-style "ebnf2ps" "\
 Return style definition if NAME is already defined; otherwise, return nil.
@@ -8683,9 +8520,7 @@ Returns the old style symbol.
 
 See also `ebnf-push-style'.
 
-See `ebnf-style-database' documentation.
-
-\(fn)" t nil)
+See `ebnf-style-database' documentation." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"ebnf2ps" '("ebnf-")))
 
@@ -8707,9 +8542,7 @@ Tree mode key bindings:
 \(fn)" t nil)
 
 (autoload 'ebrowse-electric-choose-tree "ebrowse" "\
-Return a buffer containing a tree or nil if no tree found or canceled.
-
-\(fn)" t nil)
+Return a buffer containing a tree or nil if no tree found or canceled." t nil)
 
 (autoload 'ebrowse-member-mode "ebrowse" "\
 Major mode for Ebrowse member buffers.
@@ -8717,54 +8550,34 @@ Major mode for Ebrowse member buffers.
 \(fn)" t nil)
 
 (autoload 'ebrowse-tags-view-declaration "ebrowse" "\
-View declaration of member at point.
-
-\(fn)" t nil)
+View declaration of member at point." t nil)
 
 (autoload 'ebrowse-tags-find-declaration "ebrowse" "\
-Find declaration of member at point.
-
-\(fn)" t nil)
+Find declaration of member at point." t nil)
 
 (autoload 'ebrowse-tags-view-definition "ebrowse" "\
-View definition of member at point.
-
-\(fn)" t nil)
+View definition of member at point." t nil)
 
 (autoload 'ebrowse-tags-find-definition "ebrowse" "\
-Find definition of member at point.
-
-\(fn)" t nil)
+Find definition of member at point." t nil)
 
 (autoload 'ebrowse-tags-find-declaration-other-window "ebrowse" "\
-Find declaration of member at point in other window.
-
-\(fn)" t nil)
+Find declaration of member at point in other window." t nil)
 
 (autoload 'ebrowse-tags-view-definition-other-window "ebrowse" "\
-View definition of member at point in other window.
-
-\(fn)" t nil)
+View definition of member at point in other window." t nil)
 
 (autoload 'ebrowse-tags-find-definition-other-window "ebrowse" "\
-Find definition of member at point in other window.
-
-\(fn)" t nil)
+Find definition of member at point in other window." t nil)
 
 (autoload 'ebrowse-tags-find-declaration-other-frame "ebrowse" "\
-Find definition of member at point in other frame.
-
-\(fn)" t nil)
+Find definition of member at point in other frame." t nil)
 
 (autoload 'ebrowse-tags-view-definition-other-frame "ebrowse" "\
-View definition of member at point in other frame.
-
-\(fn)" t nil)
+View definition of member at point in other frame." t nil)
 
 (autoload 'ebrowse-tags-find-definition-other-frame "ebrowse" "\
-Find definition of member at point in other frame.
-
-\(fn)" t nil)
+Find definition of member at point in other frame." t nil)
 
 (autoload 'ebrowse-tags-complete-symbol "ebrowse" "\
 Perform completion on the C++ symbol preceding point.
@@ -8816,14 +8629,10 @@ Prefix arg ARG says how much.
 \(fn ARG)" t nil)
 
 (autoload 'ebrowse-electric-position-menu "ebrowse" "\
-List positions in the position stack in an electric buffer.
-
-\(fn)" t nil)
+List positions in the position stack in an electric buffer." t nil)
 
 (autoload 'ebrowse-save-tree "ebrowse" "\
-Save current tree in same file it was loaded from.
-
-\(fn)" t nil)
+Save current tree in same file it was loaded from." t nil)
 
 (autoload 'ebrowse-save-tree-as "ebrowse" "\
 Write the current tree data structure to a file.
@@ -8833,9 +8642,7 @@ Otherwise, FILE-NAME specifies the file to save the tree 
in.
 \(fn &optional FILE-NAME)" t nil)
 
 (autoload 'ebrowse-statistics "ebrowse" "\
-Display statistics for a class tree.
-
-\(fn)" t nil)
+Display statistics for a class tree." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"ebrowse" '("ebrowse-" "electric-buffer-menu-mode-hook")))
 
@@ -8893,9 +8700,7 @@ With prefix arg NOCONFIRM, execute current line as-is 
without editing.
 ;;; Generated autoloads from ecomplete.el
 
 (autoload 'ecomplete-setup "ecomplete" "\
-Read the .ecompleterc file.
-
-\(fn)" nil nil)
+Read the .ecompleterc file." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"ecomplete" '("ecomplete-")))
 
@@ -9253,19 +9058,13 @@ If the current defun is actually a call to `defvar' or 
`defcustom',
 evaluating it this way resets the variable using its initial value
 expression even if the variable already has some other value.
 \(Normally `defvar' and `defcustom' do not alter the value if there
-already is one.)
-
-\(fn)" t nil)
+already is one.)" t nil)
 
 (autoload 'edebug-all-defs "edebug" "\
-Toggle edebugging of all definitions.
-
-\(fn)" t nil)
+Toggle edebugging of all definitions." t nil)
 
 (autoload 'edebug-all-forms "edebug" "\
-Toggle edebugging of all forms.
-
-\(fn)" t nil)
+Toggle edebugging of all forms." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"edebug" '("cancel-edebug-on-entry" "edebug" "get-edebug-spec" 
"global-edebug-")))
 
@@ -9296,9 +9095,7 @@ arguments after setting up the Ediff buffers.
 (autoload 'ediff-current-file "ediff" "\
 Start ediff between current buffer and its file on disk.
 This command can be used instead of `revert-buffer'.  If there is
-nothing to revert then this command fails.
-
-\(fn)" t nil)
+nothing to revert then this command fails." t nil)
 
 (autoload 'ediff-backup "ediff" "\
 Run Ediff on FILE and its backup file.
@@ -9560,9 +9357,7 @@ arguments after setting up the Ediff buffers.
 
 (autoload 'ediff-version "ediff" "\
 Return string describing the version of Ediff.
-When called interactively, displays the version.
-
-\(fn)" t nil)
+When called interactively, displays the version." t nil)
 
 (autoload 'ediff-documentation "ediff" "\
 Display Ediff's manual.
@@ -9571,44 +9366,28 @@ With optional NODE, goes to that node.
 \(fn &optional NODE)" t nil)
 
 (autoload 'ediff-files-command "ediff" "\
-Call `ediff-files' with the next two command line arguments.
-
-\(fn)" nil nil)
+Call `ediff-files' with the next two command line arguments." nil nil)
 
 (autoload 'ediff3-files-command "ediff" "\
-Call `ediff3-files' with the next three command line arguments.
-
-\(fn)" nil nil)
+Call `ediff3-files' with the next three command line arguments." nil nil)
 
 (autoload 'ediff-merge-command "ediff" "\
-Call `ediff-merge-files' with the next two command line arguments.
-
-\(fn)" nil nil)
+Call `ediff-merge-files' with the next two command line arguments." nil nil)
 
 (autoload 'ediff-merge-with-ancestor-command "ediff" "\
-Call `ediff-merge-files-with-ancestor' with the next three command line 
arguments.
-
-\(fn)" nil nil)
+Call `ediff-merge-files-with-ancestor' with the next three command line 
arguments." nil nil)
 
 (autoload 'ediff-directories-command "ediff" "\
-Call `ediff-directories' with the next three command line arguments.
-
-\(fn)" nil nil)
+Call `ediff-directories' with the next three command line arguments." nil nil)
 
 (autoload 'ediff-directories3-command "ediff" "\
-Call `ediff-directories3' with the next four command line arguments.
-
-\(fn)" nil nil)
+Call `ediff-directories3' with the next four command line arguments." nil nil)
 
 (autoload 'ediff-merge-directories-command "ediff" "\
-Call `ediff-merge-directories' with the next three command line arguments.
-
-\(fn)" nil nil)
+Call `ediff-merge-directories' with the next three command line arguments." 
nil nil)
 
 (autoload 'ediff-merge-directories-with-ancestor-command "ediff" "\
-Call `ediff-merge-directories-with-ancestor' with the next four command line 
arguments.
-
-\(fn)" nil nil)
+Call `ediff-merge-directories-with-ancestor' with the next four command line 
arguments." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"ediff" '("ediff-")))
 
@@ -9624,10 +9403,7 @@ Call `ediff-merge-directories-with-ancestor' with the 
next four command line arg
 ;;;### (autoloads nil "ediff-help" "vc/ediff-help.el" (0 0 0 0))
 ;;; Generated autoloads from vc/ediff-help.el
 
-(autoload 'ediff-customize "ediff-help" "\
-
-
-\(fn)" t nil)
+(autoload 'ediff-customize "ediff-help" nil t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"ediff-help" '("ediff-")))
 
@@ -9651,9 +9427,7 @@ Call `ediff-merge-directories-with-ancestor' with the 
next four command line arg
 ;;; Generated autoloads from vc/ediff-mult.el
 
 (autoload 'ediff-show-registry "ediff-mult" "\
-Display Ediff's registry.
-
-\(fn)" t nil)
+Display Ediff's registry." t nil)
 
 (defalias 'eregistry 'ediff-show-registry)
 
@@ -9674,16 +9448,12 @@ Display Ediff's registry.
 (autoload 'ediff-toggle-multiframe "ediff-util" "\
 Switch from multiframe display to single-frame display and back.
 To change the default, set the variable `ediff-window-setup-function',
-which see.
-
-\(fn)" t nil)
+which see." t nil)
 
 (autoload 'ediff-toggle-use-toolbar "ediff-util" "\
 Enable or disable Ediff toolbar.
 Works only in versions of Emacs that support toolbars.
-To change the default, set the variable `ediff-use-toolbar-p', which see.
-
-\(fn)" t nil)
+To change the default, set the variable `ediff-use-toolbar-p', which see." t 
nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"ediff-util" '("ediff-")))
 
@@ -9766,9 +9536,7 @@ Argument BOTTOM is the bottom margin in number of lines 
or percent of window.
 \(fn TOP BOTTOM)" t nil)
 
 (autoload 'edt-emulation-on "edt" "\
-Turn on EDT Emulation.
-
-\(fn)" t nil)
+Turn on EDT Emulation." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"edt" '("edt-")))
 
@@ -9996,15 +9764,11 @@ A complicated directory may require a lot of memory.
 
 (autoload 'elint-current-buffer "elint" "\
 Lint the current buffer.
-If necessary, this first calls `elint-initialize'.
-
-\(fn)" t nil)
+If necessary, this first calls `elint-initialize'." t nil)
 
 (autoload 'elint-defun "elint" "\
 Lint the function at point.
-If necessary, this first calls `elint-initialize'.
-
-\(fn)" t nil)
+If necessary, this first calls `elint-initialize'." t nil)
 
 (autoload 'elint-initialize "elint" "\
 Initialize elint.
@@ -10046,9 +9810,7 @@ For example, to instrument all ELP functions, do the 
following:
 Display current profiling results.
 If `elp-reset-after-results' is non-nil, then current profiling
 information for all instrumented functions is reset after results are
-displayed.
-
-\(fn)" t nil)
+displayed." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"elp" '("elp-")))
 
@@ -10258,15 +10020,9 @@ Run Emerge on two buffers, giving another buffer as 
the ancestor.
 
 \(fn BUFFER-A BUFFER-B BUFFER-ANCESTOR &optional STARTUP-HOOKS QUIT-HOOKS)" t 
nil)
 
-(autoload 'emerge-files-command "emerge" "\
-
-
-\(fn)" nil nil)
-
-(autoload 'emerge-files-with-ancestor-command "emerge" "\
+(autoload 'emerge-files-command "emerge" nil nil nil)
 
-
-\(fn)" nil nil)
+(autoload 'emerge-files-with-ancestor-command "emerge" nil nil nil)
 
 (autoload 'emerge-files-remote "emerge" "\
 
@@ -10529,24 +10285,16 @@ Insert selected KEYS after the point.
 ;;; Generated autoloads from epa-dired.el
 
 (autoload 'epa-dired-do-decrypt "epa-dired" "\
-Decrypt marked files.
-
-\(fn)" t nil)
+Decrypt marked files." t nil)
 
 (autoload 'epa-dired-do-verify "epa-dired" "\
-Verify marked files.
-
-\(fn)" t nil)
+Verify marked files." t nil)
 
 (autoload 'epa-dired-do-sign "epa-dired" "\
-Sign marked files.
-
-\(fn)" t nil)
+Sign marked files." t nil)
 
 (autoload 'epa-dired-do-encrypt "epa-dired" "\
-Encrypt marked files.
-
-\(fn)" t nil)
+Encrypt marked files." t nil)
 
 ;;;***
 
@@ -10558,15 +10306,9 @@ Encrypt marked files.
 
 \(fn OPERATION &rest ARGS)" nil nil)
 
-(autoload 'epa-file-enable "epa-file" "\
-
-
-\(fn)" t nil)
-
-(autoload 'epa-file-disable "epa-file" "\
-
+(autoload 'epa-file-enable "epa-file" nil t nil)
 
-\(fn)" t nil)
+(autoload 'epa-file-disable "epa-file" nil t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"epa-file" '("epa-")))
 
@@ -10587,17 +10329,13 @@ if ARG is `toggle'; disable the mode otherwise.
 
 (autoload 'epa-mail-decrypt "epa-mail" "\
 Decrypt OpenPGP armors in the current buffer.
-The buffer is expected to contain a mail message.
-
-\(fn)" t nil)
+The buffer is expected to contain a mail message." t nil)
 
 (function-put 'epa-mail-decrypt 'interactive-only 't)
 
 (autoload 'epa-mail-verify "epa-mail" "\
 Verify OpenPGP cleartext signed messages in the current buffer.
-The buffer is expected to contain a mail message.
-
-\(fn)" t nil)
+The buffer is expected to contain a mail message." t nil)
 
 (function-put 'epa-mail-verify 'interactive-only 't)
 
@@ -10626,9 +10364,7 @@ SIGNERS is a list of keys to sign the message with.
 
 (autoload 'epa-mail-import-keys "epa-mail" "\
 Import keys in the OpenPGP armor format in the current buffer.
-The buffer is expected to contain a mail message.
-
-\(fn)" t nil)
+The buffer is expected to contain a mail message." t nil)
 
 (function-put 'epa-mail-import-keys 'interactive-only 't)
 
@@ -10686,9 +10422,7 @@ version requirement is met.
 \(fn PROTOCOL &optional NO-CACHE PROGRAM-ALIST)" nil nil)
 
 (autoload 'epg-configuration "epg-config" "\
-Return a list of internal configuration parameters of `epg-gpg-program'.
-
-\(fn)" nil nil)
+Return a list of internal configuration parameters of `epg-gpg-program'." nil 
nil)
 
 (make-obsolete 'epg-configuration 'epg-find-configuration '"25.1")
 
@@ -10716,9 +10450,7 @@ Look at CONFIG and try to expand GROUP.
 (push (purecopy '(erc 5 3)) package--builtin-versions)
 
 (autoload 'erc-select-read-args "erc" "\
-Prompt the user for values of nick, server, port, and password.
-
-\(fn)" nil nil)
+Prompt the user for values of nick, server, port, and password." nil nil)
 
 (autoload 'erc "erc" "\
 ERC is a powerful, modular, and extensible IRC client.
@@ -10925,14 +10657,10 @@ Otherwise, connect to HOST:PORT as USER and /join 
CHANNEL.
 (autoload 'erc-determine-network "erc-networks" "\
 Return the name of the network or \"Unknown\" as a symbol.  Use the
 server parameter NETWORK if provided, otherwise parse the server name and
-search for a match in `erc-networks-alist'.
-
-\(fn)" nil nil)
+search for a match in `erc-networks-alist'." nil nil)
 
 (autoload 'erc-server-select "erc-networks" "\
-Interactively select a server to connect to using `erc-server-alist'.
-
-\(fn)" t nil)
+Interactively select a server to connect to using `erc-server-alist'." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"erc-networks" '("erc-")))
 
@@ -11119,9 +10847,7 @@ Display the documentation for TEST-OR-TEST-NAME (a 
symbol or ert-test).
 (put 'ert-with-test-buffer 'lisp-indent-function 1)
 
 (autoload 'ert-kill-all-test-buffers "ert-x" "\
-Kill all test buffers that are still live.
-
-\(fn)" t nil)
+Kill all test buffers that are still live." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"ert-x" '("ert-")))
 
@@ -11335,14 +11061,9 @@ Returns t if it visits a tags table, or nil if there 
are no more in the list.
 Return a list of files in the current tags table.
 Assumes the tags table is the current buffer.  The file names are returned
 as they appeared in the `etags' command that created the table, usually
-without directory names.
-
-\(fn)" nil nil)
-
-(autoload 'tags-lazy-completion-table "etags" "\
-
+without directory names." nil nil)
 
-\(fn)" nil nil)
+(autoload 'tags-lazy-completion-table "etags" nil nil nil)
  (defun tags-completion-at-point-function ()
   (if (or tags-table-list tags-file-name)
       (progn
@@ -11490,7 +11211,7 @@ argument is passed to `next-file', which see).
 
 \(fn &optional FIRST-TIME)" t nil)
 
-(make-obsolete 'tags-loop-continue 'multifile-continue '"27.1")
+(make-obsolete 'tags-loop-continue 'fileloop-continue '"27.1")
 
 (autoload 'tags-search "etags" "\
 Search through all files listed in tags table for match for REGEXP.
@@ -11509,7 +11230,7 @@ Do `query-replace-regexp' of FROM with TO on all files 
listed in tags table.
 Third arg DELIMITED (prefix arg) means replace only word-delimited matches.
 If you exit (\\[keyboard-quit], RET or q), you can resume the query replace
 with the command \\[tags-loop-continue].
-For non-interactive use, superceded by `multifile-initialize-replace'.
+For non-interactive use, superceded by `fileloop-initialize-replace'.
 
 \(fn FROM TO &optional DELIMITED FILES)" t nil)
 
@@ -11533,22 +11254,15 @@ Display list of all tags in tags table REGEXP matches.
 (autoload 'select-tags-table "etags" "\
 Select a tags table file from a menu of those you have already used.
 The list of tags tables to select from is stored in `tags-table-set-list';
-see the doc of that variable if you want to add names to the list.
-
-\(fn)" t nil)
+see the doc of that variable if you want to add names to the list." t nil)
 
 (autoload 'complete-tag "etags" "\
 Perform tags completion on the text around point.
 Completes to the set of names listed in the current tags table.
 The string to complete is chosen in the same way as the default
-for \\[find-tag] (which see).
-
-\(fn)" t nil)
-
-(autoload 'etags--xref-backend "etags" "\
+for \\[find-tag] (which see)." t nil)
 
-
-\(fn)" nil nil)
+(autoload 'etags--xref-backend "etags" nil nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"etags" '("default-tags-table-function" "etags-" "file-of-tag" "find-tag-" 
"goto-tag-location-function" "initialize-new-tags-table" "last-tag" 
"list-tags-function" "select-tags-table-" "snarf-tag-function" "tag" 
"verify-tags-table-function" "xref-")))
 
@@ -11558,10 +11272,7 @@ for \\[find-tag] (which see).
 ;;;;;;  0 0))
 ;;; Generated autoloads from language/ethio-util.el
 
-(autoload 'setup-ethiopic-environment-internal "ethio-util" "\
-
-
-\(fn)" nil nil)
+(autoload 'setup-ethiopic-environment-internal "ethio-util" nil nil nil)
 
 (autoload 'ethio-sera-to-fidel-buffer "ethio-util" "\
 Convert the current buffer from SERA to FIDEL.
@@ -11650,9 +11361,7 @@ The markers \"<sera>\" and \"</sera>\" themselves are 
not deleted.
 \(fn &optional FORCE)" t nil)
 
 (autoload 'ethio-modify-vowel "ethio-util" "\
-Modify the vowel of the FIDEL that is under the cursor.
-
-\(fn)" t nil)
+Modify the vowel of the FIDEL that is under the cursor." t nil)
 
 (autoload 'ethio-replace-space "ethio-util" "\
 Replace ASCII spaces with Ethiopic word separators in the region.
@@ -11675,14 +11384,10 @@ This function is deprecated.
 \(fn ARG)" t nil)
 
 (autoload 'ethio-fidel-to-tex-buffer "ethio-util" "\
-Convert each fidel characters in the current buffer into a fidel-tex command.
-
-\(fn)" t nil)
+Convert each fidel characters in the current buffer into a fidel-tex command." 
t nil)
 
 (autoload 'ethio-tex-to-fidel-buffer "ethio-util" "\
-Convert fidel-tex commands in the current buffer into fidel chars.
-
-\(fn)" t nil)
+Convert fidel-tex commands in the current buffer into fidel chars." t nil)
 
 (autoload 'ethio-fidel-to-java-buffer "ethio-util" "\
 Convert Ethiopic characters into the Java escape sequences.
@@ -11691,24 +11396,16 @@ Each escape sequence is of the form \\uXXXX, where 
XXXX is the
 character's codepoint (in hex) in Unicode.
 
 If `ethio-java-save-lowercase' is non-nil, use [0-9a-f].
-Otherwise, [0-9A-F].
-
-\(fn)" nil nil)
+Otherwise, [0-9A-F]." nil nil)
 
 (autoload 'ethio-java-to-fidel-buffer "ethio-util" "\
-Convert the Java escape sequences into corresponding Ethiopic characters.
-
-\(fn)" nil nil)
+Convert the Java escape sequences into corresponding Ethiopic characters." nil 
nil)
 
 (autoload 'ethio-find-file "ethio-util" "\
-Transliterate file content into Ethiopic depending on filename suffix.
-
-\(fn)" nil nil)
+Transliterate file content into Ethiopic depending on filename suffix." nil 
nil)
 
 (autoload 'ethio-write-file "ethio-util" "\
-Transliterate Ethiopic characters in ASCII depending on the file extension.
-
-\(fn)" nil nil)
+Transliterate Ethiopic characters in ASCII depending on the file extension." 
nil nil)
 
 (autoload 'ethio-insert-ethio-space "ethio-util" "\
 Insert the Ethiopic word delimiter (the colon-like character).
@@ -11771,9 +11468,7 @@ queries the server for the existing fields and displays 
a corresponding form.
 
 (autoload 'eudc-load-eudc "eudc" "\
 Load the Emacs Unified Directory Client.
-This does nothing except loading eudc by autoload side-effect.
-
-\(fn)" t nil)
+This does nothing except loading eudc by autoload side-effect." t nil)
 
 (defvar eudc-tools-menu (let ((map (make-sparse-keymap "Directory Servers"))) 
(define-key map [phone] `(menu-item ,(purecopy "Get Phone") eudc-get-phone 
:help ,(purecopy "Get the phone field of name from the directory server"))) 
(define-key map [email] `(menu-item ,(purecopy "Get Email") eudc-get-email 
:help ,(purecopy "Get the email field of NAME from the directory server"))) 
(define-key map [separator-eudc-email] menu-bar-separator) (define-key map 
[expand-inline] `(menu-item ,(purecop [...]
 
@@ -11825,14 +11520,10 @@ Display a button for the JPEG DATA.
 
 (autoload 'eudc-insert-record-at-point-into-bbdb "eudc-export" "\
 Insert record at point into the BBDB database.
-This function can only be called from a directory query result buffer.
-
-\(fn)" t nil)
+This function can only be called from a directory query result buffer." t nil)
 
 (autoload 'eudc-try-bbdb-insert "eudc-export" "\
-Call `eudc-insert-record-at-point-into-bbdb' if on a record.
-
-\(fn)" t nil)
+Call `eudc-insert-record-at-point-into-bbdb' if on a record." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"eudc-export" '("eudc-")))
 
@@ -11843,9 +11534,7 @@ Call `eudc-insert-record-at-point-into-bbdb' if on a 
record.
 ;;; Generated autoloads from net/eudc-hotlist.el
 
 (autoload 'eudc-edit-hotlist "eudc-hotlist" "\
-Edit the hotlist of directory servers in a specialized buffer.
-
-\(fn)" t nil)
+Edit the hotlist of directory servers in a specialized buffer." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"eudc-hotlist" '("eudc-hotlist-")))
 
@@ -11923,7 +11612,10 @@ Fetch URL and render the page.
 If the input doesn't look like an URL or a domain name, the
 word(s) will be searched for via `eww-search-prefix'.
 
-\(fn URL)" t nil)
+If called with a prefix ARG, use a new buffer instead of reusing
+the default EWW buffer.
+
+\(fn URL &optional ARG)" t nil)
  (defalias 'browse-web 'eww)
 
 (autoload 'eww-open-file "eww" "\
@@ -11936,9 +11628,7 @@ Search the web for the text between BEG and END.
 If region is active (and not whitespace), search the web for
 the text between BEG and END.  Else, prompt the user for a search
 string.  See the `eww-search-prefix' variable for the search
-engine used.
-
-\(fn)" t nil)
+engine used." t nil)
 
 (autoload 'eww-mode "eww" "\
 Mode for browsing the web.
@@ -11951,9 +11641,7 @@ Mode for browsing the web.
 \(fn URL &optional NEW-WINDOW)" nil nil)
 
 (autoload 'eww-list-bookmarks "eww" "\
-Display the bookmarks.
-
-\(fn)" t nil)
+Display the bookmarks." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"eww" '("eww-")))
 
@@ -11989,9 +11677,7 @@ executable.
 (autoload 'executable-make-buffer-file-executable-if-script-p "executable" "\
 Make file executable according to umask if not already executable.
 If file already has any execute bits set at all, do not change existing
-file modes.
-
-\(fn)" nil nil)
+file modes." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"executable" '("executable-")))
 
@@ -12026,21 +11712,15 @@ If ARG is omitted, point is placed at the end of the 
expanded text.
 
 (autoload 'expand-abbrev-hook "expand" "\
 Abbrev hook used to do the expansion job of expand abbrevs.
-See `expand-add-abbrevs'.  Value is non-nil if expansion was done.
-
-\(fn)" nil nil)
+See `expand-add-abbrevs'.  Value is non-nil if expansion was done." nil nil)
 
 (autoload 'expand-jump-to-previous-slot "expand" "\
 Move the cursor to the previous slot in the last abbrev expansion.
-This is used only in conjunction with `expand-add-abbrevs'.
-
-\(fn)" t nil)
+This is used only in conjunction with `expand-add-abbrevs'." t nil)
 
 (autoload 'expand-jump-to-next-slot "expand" "\
 Move the cursor to the next slot in the last abbrev expansion.
-This is used only in conjunction with `expand-add-abbrevs'.
-
-\(fn)" t nil)
+This is used only in conjunction with `expand-add-abbrevs'." t nil)
  (define-key abbrev-map "p" 'expand-jump-to-previous-slot)
  (define-key abbrev-map "n" 'expand-jump-to-next-slot)
 
@@ -12294,9 +11974,7 @@ Besides the choice of face, it is the same as 
`buffer-face-mode'.
 (push (purecopy '(faceup 0 0 6)) package--builtin-versions)
 
 (autoload 'faceup-view-buffer "faceup" "\
-Display the faceup representation of the current buffer.
-
-\(fn)" t nil)
+Display the faceup representation of the current buffer." t nil)
 
 (autoload 'faceup-write-file "faceup" "\
 Save the faceup representation of the current buffer to the file FILE-NAME.
@@ -12316,9 +11994,7 @@ Convert BUFFER containing Faceup markup to a new buffer 
and display it.
 \(fn &optional BUFFER)" t nil)
 
 (autoload 'faceup-clean-buffer "faceup" "\
-Remove faceup markup from buffer.
-
-\(fn)" t nil)
+Remove faceup markup from buffer." t nil)
 
 (autoload 'faceup-defexplainer "faceup" "\
 Define an Ert explainer function for FUNCTION.
@@ -12339,9 +12015,7 @@ FUNCTION must return an explanation when the test fails 
and
 (autoload 'feedmail-send-it "feedmail" "\
 Send the current mail buffer using the Feedmail package.
 This is a suitable value for `send-mail-function'.  It can be used
-with various lower-level mechanisms to provide features such as queueing.
-
-\(fn)" nil nil)
+with various lower-level mechanisms to provide features such as queueing." nil 
nil)
 
 (autoload 'feedmail-run-the-queue-no-prompts "feedmail" "\
 Like `feedmail-run-the-queue', but suppress confirmation prompts.
@@ -12441,14 +12115,10 @@ If `dired-at-point-require-prefix' is set, the prefix 
meaning is reversed.
 
 (autoload 'ffap-guess-file-name-at-point "ffap" "\
 Try to get a file name at point.
-This hook is intended to be put in `file-name-at-point-functions'.
-
-\(fn)" nil nil)
+This hook is intended to be put in `file-name-at-point-functions'." nil nil)
 
 (autoload 'ffap-bindings "ffap" "\
-Evaluate the forms in variable `ffap-bindings'.
-
-\(fn)" t nil)
+Evaluate the forms in variable `ffap-bindings'." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"ffap" '("dired-at-point-" "ffap-" "find-file-literally-at-point")))
 
@@ -12513,6 +12183,41 @@ the name is considered already unique; only the second 
substitution
 
 ;;;***
 
+;;;### (autoloads nil "fileloop" "fileloop.el" (0 0 0 0))
+;;; Generated autoloads from fileloop.el
+
+(autoload 'fileloop-initialize "fileloop" "\
+Initialize a new round of operation on several files.
+FILES can be either a list of file names, or an iterator (used with 
`iter-next')
+which returns a file name at each step.
+SCAN-FUNCTION is a function called with no argument inside a buffer
+and it should return non-nil if that buffer has something on which to operate.
+OPERATE-FUNCTION is a function called with no argument; it is expected
+to perform the operation on the current file buffer and when done
+should return non-nil to mean that we should immediately continue
+operating on the next file and nil otherwise.
+
+\(fn FILES SCAN-FUNCTION OPERATE-FUNCTION)" nil nil)
+
+(autoload 'fileloop-initialize-search "fileloop" "\
+
+
+\(fn REGEXP FILES CASE-FOLD)" nil nil)
+
+(autoload 'fileloop-initialize-replace "fileloop" "\
+Initialize a new round of query&replace on several files.
+FROM is a regexp and TO is the replacement to use.
+FILES describes the file, as in `fileloop-initialize'.
+CASE-FOLD can be t, nil, or `default', the latter one meaning to obey
+the default setting of `case-fold-search'.
+DELIMITED if non-nil means replace only word-delimited matches.
+
+\(fn FROM TO FILES CASE-FOLD &optional DELIMITED)" nil nil)
+
+(if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"fileloop" '("fileloop-")))
+
+;;;***
+
 ;;;### (autoloads nil "filenotify" "filenotify.el" (0 0 0 0))
 ;;; Generated autoloads from filenotify.el
 
@@ -12579,19 +12284,13 @@ Delete all MODE settings of file-local VARIABLE from 
.dir-locals.el.
 \(fn MODE VARIABLE)" t nil)
 
 (autoload 'copy-file-locals-to-dir-locals "files-x" "\
-Copy file-local variables to .dir-locals.el.
-
-\(fn)" t nil)
+Copy file-local variables to .dir-locals.el." t nil)
 
 (autoload 'copy-dir-locals-to-file-locals "files-x" "\
-Copy directory-local variables to the Local Variables list.
-
-\(fn)" t nil)
+Copy directory-local variables to the Local Variables list." t nil)
 
 (autoload 'copy-dir-locals-to-file-locals-prop-line "files-x" "\
-Copy directory-local variables to the -*- line.
-
-\(fn)" t nil)
+Copy directory-local variables to the -*- line." t nil)
 
 (defvar enable-connection-local-variables t "\
 Non-nil means enable use of connection-local variables.")
@@ -12632,13 +12331,11 @@ will not be changed.
 
 \(fn CRITERIA)" nil nil)
 
-(autoload 'with-connection-local-profiles "files-x" "\
-Apply connection-local variables according to PROFILES in current buffer.
+(autoload 'with-connection-local-variables "files-x" "\
+Apply connection-local variables according to `default-directory'.
 Execute BODY, and unwind connection-local variables.
 
-\(fn PROFILES &rest BODY)" nil t)
-
-(function-put 'with-connection-local-profiles 'lisp-indent-function '1)
+\(fn &rest BODY)" nil t)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"files-x" '("connection-local-" "dir-locals-to-string" 
"hack-connection-local-variables" "modify-" "read-file-local-variable")))
 
@@ -12649,9 +12346,7 @@ Execute BODY, and unwind connection-local variables.
 
 (autoload 'filesets-init "filesets" "\
 Filesets initialization.
-Set up hooks, load the cache file -- if existing -- and build the menu.
-
-\(fn)" nil nil)
+Set up hooks, load the cache file -- if existing -- and build the menu." nil 
nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"filesets" '("filesets-")))
 
@@ -12983,19 +12678,13 @@ See `find-function-on-key'.
 \(fn KEY)" t nil)
 
 (autoload 'find-function-at-point "find-func" "\
-Find directly the function at point in the other window.
-
-\(fn)" t nil)
+Find directly the function at point in the other window." t nil)
 
 (autoload 'find-variable-at-point "find-func" "\
-Find directly the variable at point in the other window.
-
-\(fn)" t nil)
+Find directly the variable at point in the other window." t nil)
 
 (autoload 'find-function-setup-keys "find-func" "\
-Define some key bindings for the find-function family of functions.
-
-\(fn)" nil nil)
+Define some key bindings for the find-function family of functions." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"find-func" '("find-" "read-library-name")))
 
@@ -13028,9 +12717,7 @@ Change the filter on a `find-lisp-find-dired' buffer to 
REGEXP.
 (push (purecopy '(finder 1 0)) package--builtin-versions)
 
 (autoload 'finder-list-keywords "finder" "\
-Display descriptions of the keywords in the Finder buffer.
-
-\(fn)" t nil)
+Display descriptions of the keywords in the Finder buffer." t nil)
 
 (autoload 'finder-commentary "finder" "\
 Display FILE's commentary section.
@@ -13039,9 +12726,7 @@ FILE should be in a form suitable for passing to 
`locate-library'.
 \(fn FILE)" t nil)
 
 (autoload 'finder-by-keyword "finder" "\
-Find packages matching a given keyword.
-
-\(fn)" t nil)
+Find packages matching a given keyword." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"finder" '("finder-" "generated-finder-keywords-file")))
 
@@ -13089,7 +12774,7 @@ to get the effect of a C-q.
 
 ;;;### (autoloads nil "flymake" "progmodes/flymake.el" (0 0 0 0))
 ;;; Generated autoloads from progmodes/flymake.el
-(push (purecopy '(flymake 1 0)) package--builtin-versions)
+(push (purecopy '(flymake 1 0 5)) package--builtin-versions)
 
 (autoload 'flymake-log "flymake" "\
 Log, at level LEVEL, the message MSG formatted with ARGS.
@@ -13106,7 +12791,12 @@ TYPE is a key to symbol and TEXT is a description of 
the problem
 detected in this region.  DATA is any object that the caller
 wishes to attach to the created diagnostic for later retrieval.
 
-\(fn BUFFER BEG END TYPE TEXT &optional DATA)" nil nil)
+OVERLAY-PROPERTIES is an an alist of properties attached to the
+created diagnostic, overriding the default properties and any
+properties of `flymake-overlay-control' of the diagnostic's
+type.
+
+\(fn BUFFER BEG END TYPE TEXT &optional DATA OVERLAY-PROPERTIES)" nil nil)
 
 (autoload 'flymake-diagnostics "flymake" "\
 Get Flymake diagnostics in region determined by BEG and END.
@@ -13167,14 +12857,10 @@ special *Flymake log* buffer.
 \(fn &optional ARG)" t nil)
 
 (autoload 'flymake-mode-on "flymake" "\
-Turn Flymake mode on.
-
-\(fn)" nil nil)
+Turn Flymake mode on." nil nil)
 
 (autoload 'flymake-mode-off "flymake" "\
-Turn Flymake mode off.
-
-\(fn)" nil nil)
+Turn Flymake mode off." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"flymake" '("flymake-")))
 
@@ -13209,9 +12895,7 @@ REPORT-FN is Flymake's callback.
 ;;; Generated autoloads from textmodes/flyspell.el
 
 (autoload 'flyspell-prog-mode "flyspell" "\
-Turn on `flyspell-mode' for comments and strings.
-
-\(fn)" t nil)
+Turn on `flyspell-mode' for comments and strings." t nil)
 (defvar flyspell-mode nil "Non-nil if Flyspell mode is enabled.")
 
 (autoload 'flyspell-mode "flyspell" "\
@@ -13251,19 +12935,13 @@ in your init file.
 \(fn &optional ARG)" t nil)
 
 (autoload 'turn-on-flyspell "flyspell" "\
-Unconditionally turn on Flyspell mode.
-
-\(fn)" nil nil)
+Unconditionally turn on Flyspell mode." nil nil)
 
 (autoload 'turn-off-flyspell "flyspell" "\
-Unconditionally turn off Flyspell mode.
-
-\(fn)" nil nil)
+Unconditionally turn off Flyspell mode." nil nil)
 
 (autoload 'flyspell-mode-off "flyspell" "\
-Turn Flyspell mode off.
-
-\(fn)" nil nil)
+Turn Flyspell mode off." nil nil)
 
 (autoload 'flyspell-region "flyspell" "\
 Flyspell text between BEG and END.
@@ -13274,9 +12952,7 @@ of a misspelled word removed when you've corrected it.
 \(fn BEG END)" t nil)
 
 (autoload 'flyspell-buffer "flyspell" "\
-Flyspell whole buffer.
-
-\(fn)" t nil)
+Flyspell whole buffer." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"flyspell" '("flyspell-" "mail-mode-flyspell-verify" "make-flyspell-overlay" 
"sgml-mode-flyspell-verify" "tex")))
 
@@ -13294,14 +12970,10 @@ Flyspell whole buffer.
 ;;; Generated autoloads from follow.el
 
 (autoload 'turn-on-follow-mode "follow" "\
-Turn on Follow mode.  Please see the function `follow-mode'.
-
-\(fn)" nil nil)
+Turn on Follow mode.  Please see the function `follow-mode'." nil nil)
 
 (autoload 'turn-off-follow-mode "follow" "\
-Turn off Follow mode.  Please see the function `follow-mode'.
-
-\(fn)" nil nil)
+Turn off Follow mode.  Please see the function `follow-mode'." nil nil)
 
 (autoload 'follow-mode "follow" "\
 Toggle Follow mode.
@@ -14158,14 +13830,10 @@ prompt the user for the name of an NNTP server to use.
 ;;; Generated autoloads from gnus/gnus-agent.el
 
 (autoload 'gnus-unplugged "gnus-agent" "\
-Start Gnus unplugged.
-
-\(fn)" t nil)
+Start Gnus unplugged." t nil)
 
 (autoload 'gnus-plugged "gnus-agent" "\
-Start Gnus plugged.
-
-\(fn)" t nil)
+Start Gnus plugged." t nil)
 
 (autoload 'gnus-slave-unplugged "gnus-agent" "\
 Read news as a slave unplugged.
@@ -14181,14 +13849,10 @@ customize gnus-agent to nil.
 
 This will modify the `gnus-setup-news-hook', and
 `message-send-mail-real-function' variables, and install the Gnus agent
-minor mode in all Gnus buffers.
-
-\(fn)" t nil)
+minor mode in all Gnus buffers." t nil)
 
 (autoload 'gnus-agent-possibly-save-gcc "gnus-agent" "\
-Save GCC if Gnus is unplugged.
-
-\(fn)" nil nil)
+Save GCC if Gnus is unplugged." nil nil)
 
 (autoload 'gnus-agent-rename-group "gnus-agent" "\
 Rename fully-qualified OLD-GROUP as NEW-GROUP.
@@ -14209,9 +13873,7 @@ supported.
 \(fn GROUP)" nil nil)
 
 (autoload 'gnus-agent-get-undownloaded-list "gnus-agent" "\
-Construct list of articles that have not been downloaded.
-
-\(fn)" nil nil)
+Construct list of articles that have not been downloaded." nil nil)
 
 (autoload 'gnus-agent-possibly-alter-active "gnus-agent" "\
 Possibly expand a group's active range to include articles
@@ -14227,14 +13889,10 @@ variables.  Returns the first non-nil value found.
 \(fn GROUP SYMBOL)" nil nil)
 
 (autoload 'gnus-agent-batch-fetch "gnus-agent" "\
-Start Gnus and fetch session.
-
-\(fn)" t nil)
+Start Gnus and fetch session." t nil)
 
 (autoload 'gnus-agent-batch "gnus-agent" "\
-Start Gnus, send queue and fetch session.
-
-\(fn)" t nil)
+Start Gnus, send queue and fetch session." t nil)
 
 (autoload 'gnus-agent-regenerate "gnus-agent" "\
 Regenerate all agent covered files.
@@ -14250,9 +13908,7 @@ CLEAN is obsolete and ignored.
 ;;; Generated autoloads from gnus/gnus-art.el
 
 (autoload 'gnus-article-prepare-display "gnus-art" "\
-Make the current buffer look like a nice article.
-
-\(fn)" nil nil)
+Make the current buffer look like a nice article." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"gnus-art" '("article-" "gnus-")))
 
@@ -14277,9 +13933,7 @@ Make the current buffer look like a nice article.
 ;;; Generated autoloads from gnus/gnus-bookmark.el
 
 (autoload 'gnus-bookmark-set "gnus-bookmark" "\
-Set a bookmark for this article.
-
-\(fn)" t nil)
+Set a bookmark for this article." t nil)
 
 (autoload 'gnus-bookmark-jump "gnus-bookmark" "\
 Jump to a Gnus bookmark (BMK-NAME).
@@ -14290,9 +13944,7 @@ Jump to a Gnus bookmark (BMK-NAME).
 Display a list of existing Gnus bookmarks.
 The list is displayed in a buffer named `*Gnus Bookmark List*'.
 The leftmost column displays a D if the bookmark is flagged for
-deletion, or > if it is flagged for displaying.
-
-\(fn)" t nil)
+deletion, or > if it is flagged for displaying." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"gnus-bookmark" '("gnus-bookmark-")))
 
@@ -14305,9 +13957,7 @@ deletion, or > if it is flagged for displaying.
 Go through all groups and put the articles into the cache.
 
 Usage:
-$ emacs -batch -l ~/.emacs -l gnus -f gnus-jog-cache
-
-\(fn)" t nil)
+$ emacs -batch -l ~/.emacs -l gnus -f gnus-jog-cache" t nil)
 
 (autoload 'gnus-cache-generate-active "gnus-cache" "\
 Generate the cache active file.
@@ -14381,9 +14031,7 @@ DELAY is a string, giving the length of the time.  
Possible values are:
 \(fn DELAY)" t nil)
 
 (autoload 'gnus-delay-send-queue "gnus-delay" "\
-Send all the delayed messages that are due now.
-
-\(fn)" t nil)
+Send all the delayed messages that are due now." t nil)
 
 (autoload 'gnus-delay-initialize "gnus-delay" "\
 Initialize the gnus-delay package.
@@ -14427,9 +14075,7 @@ Checking delayed messages is skipped if optional arg 
NO-CHECK is non-nil.
 ;;; Generated autoloads from gnus/gnus-dired.el
 
 (autoload 'turn-on-gnus-dired-mode "gnus-dired" "\
-Convenience method to turn on gnus-dired-mode.
-
-\(fn)" t nil)
+Convenience method to turn on gnus-dired-mode." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"gnus-dired" '("gnus-dired-")))
 
@@ -14439,9 +14085,7 @@ Convenience method to turn on gnus-dired-mode.
 ;;; Generated autoloads from gnus/gnus-draft.el
 
 (autoload 'gnus-draft-reminder "gnus-draft" "\
-Reminder user if there are unsent drafts.
-
-\(fn)" t nil)
+Reminder user if there are unsent drafts." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"gnus-draft" '("gnus-")))
 
@@ -14474,14 +14118,10 @@ Return file from DIR with extension EXT, omitting 
matches of OMIT, processed by
 (autoload 'gnus-random-x-face "gnus-fun" "\
 Return X-Face header data chosen randomly from `gnus-x-face-directory'.
 
-Files matching `gnus-x-face-omit-files' are not considered.
-
-\(fn)" t nil)
+Files matching `gnus-x-face-omit-files' are not considered." t nil)
 
 (autoload 'gnus-insert-random-x-face-header "gnus-fun" "\
-Insert a random X-Face header from `gnus-x-face-directory'.
-
-\(fn)" t nil)
+Insert a random X-Face header from `gnus-x-face-directory'." t nil)
 
 (autoload 'gnus-x-face-from-file "gnus-fun" "\
 Insert an X-Face header based on an image FILE.
@@ -14515,14 +14155,10 @@ FILE should be a PNG file that's 48x48 and smaller 
than or equal to
 (autoload 'gnus-random-face "gnus-fun" "\
 Return randomly chosen Face from `gnus-face-directory'.
 
-Files matching `gnus-face-omit-files' are not considered.
-
-\(fn)" t nil)
+Files matching `gnus-face-omit-files' are not considered." t nil)
 
 (autoload 'gnus-insert-random-face-header "gnus-fun" "\
-Insert a random Face header from `gnus-face-directory'.
-
-\(fn)" nil nil)
+Insert a random Face header from `gnus-face-directory'." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"gnus-fun" '("gnus-")))
 
@@ -14588,6 +14224,11 @@ Pop up a frame and enter GROUP.
 ;;;;;;  0 0 0))
 ;;; Generated autoloads from gnus/gnus-icalendar.el
 
+(autoload 'gnus-icalendar-mm-inline "gnus-icalendar" "\
+
+
+\(fn HANDLE)" nil nil)
+
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"gnus-icalendar" '("gnus-icalendar")))
 
 ;;;***
@@ -14606,9 +14247,7 @@ Pop up a frame and enter GROUP.
 
 (autoload 'gnus-batch-score "gnus-kill" "\
 Run batched scoring.
-Usage: emacs -batch -l ~/.emacs -l gnus -f gnus-batch-score
-
-\(fn)" t nil)
+Usage: emacs -batch -l ~/.emacs -l gnus -f gnus-batch-score" t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"gnus-kill" '("gnus-")))
 
@@ -14631,10 +14270,7 @@ Usage: emacs -batch -l ~/.emacs -l gnus -f 
gnus-batch-score
 ;;;### (autoloads nil "gnus-ml" "gnus/gnus-ml.el" (0 0 0 0))
 ;;; Generated autoloads from gnus/gnus-ml.el
 
-(autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" "\
-
-
-\(fn)" nil nil)
+(autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil nil nil)
 
 (autoload 'gnus-mailing-list-insinuate "gnus-ml" "\
 Setup group parameters from List-Post header.
@@ -14698,9 +14334,7 @@ instead.  This variable is set by 
`gnus-group-split-setup'.
 Use information from group parameters in order to split mail.
 See `gnus-group-split-fancy' for more information.
 
-`gnus-group-split' is a valid value for `nnmail-split-methods'.
-
-\(fn)" nil nil)
+`gnus-group-split' is a valid value for `nnmail-split-methods'." nil nil)
 
 (autoload 'gnus-group-split-fancy "gnus-mlspl" "\
 Uses information from group parameters in order to split mail.
@@ -14798,9 +14432,7 @@ or equal to `gnus-notifications-minimum-level' and send 
a
 notification using `notifications-notify' for it.
 
 This is typically a function to add in
-`gnus-after-getting-new-news-hook'
-
-\(fn)" nil nil)
+`gnus-after-getting-new-news-hook'" nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"gnus-notifications" '("gnus-notifications-")))
 
@@ -14811,21 +14443,15 @@ This is typically a function to add in
 
 (autoload 'gnus-treat-from-picon "gnus-picon" "\
 Display picons in the From header.
-If picons are already displayed, remove them.
-
-\(fn)" t nil)
+If picons are already displayed, remove them." t nil)
 
 (autoload 'gnus-treat-mail-picon "gnus-picon" "\
 Display picons in the Cc and To headers.
-If picons are already displayed, remove them.
-
-\(fn)" t nil)
+If picons are already displayed, remove them." t nil)
 
 (autoload 'gnus-treat-newsgroups-picon "gnus-picon" "\
 Display picons in the Newsgroups and Followup-To headers.
-If picons are already displayed, remove them.
-
-\(fn)" t nil)
+If picons are already displayed, remove them." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"gnus-picon" '("gnus-picon-")))
 
@@ -14905,14 +14531,10 @@ Add NUM into sorted LIST by side effect.
 ;;; Generated autoloads from gnus/gnus-registry.el
 
 (autoload 'gnus-registry-initialize "gnus-registry" "\
-Initialize the Gnus registry.
-
-\(fn)" t nil)
+Initialize the Gnus registry." t nil)
 
 (autoload 'gnus-registry-install-hooks "gnus-registry" "\
-Install the registry hooks.
-
-\(fn)" t nil)
+Install the registry hooks." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"gnus-registry" '("gnus-")))
 
@@ -14948,22 +14570,15 @@ Update the Sieve script in gnus-sieve-file, by 
replacing the region
 between gnus-sieve-region-start and gnus-sieve-region-end with
 \(gnus-sieve-script gnus-sieve-select-method gnus-sieve-crosspost), then
 execute gnus-sieve-update-shell-command.
-See the documentation for these variables and functions for details.
-
-\(fn)" t nil)
+See the documentation for these variables and functions for details." t nil)
 
 (autoload 'gnus-sieve-generate "gnus-sieve" "\
 Generate the Sieve script in gnus-sieve-file, by replacing the region
 between gnus-sieve-region-start and gnus-sieve-region-end with
 \(gnus-sieve-script gnus-sieve-select-method gnus-sieve-crosspost).
-See the documentation for these variables and functions for details.
-
-\(fn)" t nil)
+See the documentation for these variables and functions for details." t nil)
 
-(autoload 'gnus-sieve-article-add-rule "gnus-sieve" "\
-
-
-\(fn)" t nil)
+(autoload 'gnus-sieve-article-add-rule "gnus-sieve" nil t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"gnus-sieve" '("gnus-sieve-")))
 
@@ -15132,9 +14747,7 @@ By default, goto-address binds `goto-address-at-point' 
to mouse-2 and C-c RET
 only on URLs and e-mail addresses.
 
 Also fontifies the buffer appropriately (see `goto-address-fontify-p' and
-`goto-address-highlight-p' for more information).
-
-\(fn)" t nil)
+`goto-address-highlight-p' for more information)." t nil)
 (put 'goto-address 'safe-local-eval-function t)
 
 (autoload 'goto-address-mode "goto-addr" "\
@@ -15212,7 +14825,7 @@ List of hook functions run by `grep-process-setup' (see 
`run-hooks').")
 
 (custom-autoload 'grep-setup-hook "grep" t)
 
-(defconst grep-regexp-alist `((,(concat "^\\(?:" 
"\\(?1:[^\0\n]+\\)\\(?3:\0\\)\\(?2:[0-9]+\\):" "\\|" "\\(?1:" 
"\\(?:[a-zA-Z]:\\)?" "[^\n:]+?[^\n/:]\\):[\11 ]*\\(?2:[1-9][0-9]*\\)[\11 ]*:" 
"\\)") 1 2 (,(lambda nil (when grep-highlight-matches (let* ((beg (match-end 
0)) (end (save-excursion (goto-char beg) (line-end-position))) (mbeg 
(text-property-any beg end 'font-lock-face 'grep-match-face))) (when mbeg (- 
mbeg beg))))) \, (lambda nil (when grep-highlight-matches (let* ((beg 
(match-end [...]
+(defconst grep-regexp-alist `((,(concat "^\\(?:" 
"\\(?1:[^\0\n]+\\)\\(?3:\0\\)\\(?2:[0-9]+\\):" "\\|" "\\(?1:" 
"\\(?:[a-zA-Z]:\\)?" "[^\n:]+?[^\n/:]\\):[\11 ]*\\(?2:[1-9][0-9]*\\)[\11 ]*:" 
"\\)") 1 2 (,(lambda nil (when grep-highlight-matches (let* ((beg (match-end 
0)) (end (save-excursion (goto-char beg) (line-end-position))) (mbeg 
(text-property-any beg end 'font-lock-face grep-match-face))) (when mbeg (- 
mbeg beg))))) \, (lambda nil (when grep-highlight-matches (let* ((beg 
(match-end  [...]
 Regexp used to match grep hits.
 See `compilation-error-regexp-alist' for format details.")
 
@@ -15247,14 +14860,9 @@ History list for grep-find.")
 
 (autoload 'grep-process-setup "grep" "\
 Setup compilation variables and buffer for `grep'.
-Set up `compilation-exit-message-function' and run `grep-setup-hook'.
-
-\(fn)" nil nil)
-
-(autoload 'grep-compute-defaults "grep" "\
+Set up `compilation-exit-message-function' and run `grep-setup-hook'." nil nil)
 
-
-\(fn)" nil nil)
+(autoload 'grep-compute-defaults "grep" nil nil nil)
 
 (autoload 'grep-mode "grep" "\
 Sets `grep-last-buffer' and `compilation-window-height'.
@@ -15581,9 +15189,7 @@ and `handwrite-13pt' set up for various sizes of output.
 Variables: `handwrite-linespace'     (default 12)
            `handwrite-fontsize'      (default 11)
            `handwrite-numlines'      (default 60)
-           `handwrite-pagenumbering' (default nil)
-
-\(fn)" t nil)
+           `handwrite-pagenumbering' (default nil)" t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"handwrite" '("handwrite-" "menu-bar-handwrite-map")))
 
@@ -15610,17 +15216,13 @@ Towers of Hanoi, UNIX doomsday version.
 Displays 32-ring towers that have been progressing at one move per
 second since 1970-01-01 00:00:00 GMT.
 
-Repent before ring 31 moves.
-
-\(fn)" t nil)
+Repent before ring 31 moves." t nil)
 
 (autoload 'hanoi-unix-64 "hanoi" "\
 Like hanoi-unix, but pretend to have a 64-bit clock.
 This is, necessarily (as of Emacs 20.3), a crock.  When the
 current-time interface is made s2G-compliant, hanoi.el will need
-to be updated.
-
-\(fn)" t nil)
+to be updated." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"hanoi" '("hanoi-")))
 
@@ -15687,9 +15289,7 @@ can also be t, if that is the value of the `kbd-help' 
property.
 Return the keyboard help string at point.
 If the `kbd-help' text or overlay property at point produces a
 string, return it.  Otherwise, use the `help-echo' property.
-If this produces no string either, return nil.
-
-\(fn)" nil nil)
+If this produces no string either, return nil." nil nil)
 
 (autoload 'display-local-help "help-at-pt" "\
 Display local help in the echo area.
@@ -15706,15 +15306,11 @@ mainly meant for use from Lisp.
 
 (autoload 'help-at-pt-cancel-timer "help-at-pt" "\
 Cancel any timer set by `help-at-pt-set-timer'.
-This disables `help-at-pt-display-when-idle'.
-
-\(fn)" t nil)
+This disables `help-at-pt-display-when-idle'." t nil)
 
 (autoload 'help-at-pt-set-timer "help-at-pt" "\
 Enable `help-at-pt-display-when-idle'.
-This is done by setting a timer, if none is currently active.
-
-\(fn)" t nil)
+This is done by setting a timer, if none is currently active." t nil)
 
 (defvar help-at-pt-display-when-idle 'never "\
 Automatically show local help on point-over.
@@ -15917,14 +15513,10 @@ Commands:
 \(fn)" t nil)
 
 (autoload 'help-mode-setup "help-mode" "\
-Enter Help Mode in the current buffer.
-
-\(fn)" nil nil)
+Enter Help Mode in the current buffer." nil nil)
 
 (autoload 'help-mode-finish "help-mode" "\
-Finalize Help Mode setup in current buffer.
-
-\(fn)" nil nil)
+Finalize Help Mode setup in current buffer." nil nil)
 
 (autoload 'help-setup-xref "help-mode" "\
 Invoked from commands using the \"*Help*\" buffer to install some xref info.
@@ -15946,9 +15538,7 @@ If `help-xref-following' is non-nil, this is the name 
of the
 current buffer.  Signal an error if this buffer is not derived
 from `help-mode'.
 Otherwise, return \"*Help*\", creating a buffer with that name if
-it does not already exist.
-
-\(fn)" nil nil)
+it does not already exist." nil nil)
 
 (autoload 'help-make-xrefs "help-mode" "\
 Parse and hyperlink documentation cross-references in the given BUFFER.
@@ -16012,14 +15602,10 @@ BOOKMARK is a bookmark name or a bookmark record.
 ;;; Generated autoloads from emacs-lisp/helper.el
 
 (autoload 'Helper-describe-bindings "helper" "\
-Describe local key bindings of current mode.
-
-\(fn)" t nil)
+Describe local key bindings of current mode." t nil)
 
 (autoload 'Helper-help "helper" "\
-Provide help for current mode.
-
-\(fn)" t nil)
+Provide help for current mode." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"helper" '("Helper-")))
 
@@ -16120,9 +15706,7 @@ and edit the file in `hexl-mode'.
 
 (autoload 'hexlify-buffer "hexl" "\
 Convert a binary buffer to hexl format.
-This discards the buffer's undo information.
-
-\(fn)" t nil)
+This discards the buffer's undo information." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"hexl" '("dehexlify-buffer" "hexl-")))
 
@@ -16282,9 +15866,7 @@ unless you use a prefix argument.
 Uses `find-tag-default-as-symbol-regexp' to retrieve the symbol at point.
 
 This uses Font lock mode if it is enabled; otherwise it uses overlays,
-in which case the highlighting will not update as you type.
-
-\(fn)" t nil)
+in which case the highlighting will not update as you type." t nil)
 
 (defalias 'unhighlight-regexp 'hi-lock-unface-buffer)
 
@@ -16302,9 +15884,7 @@ Write interactively added patterns, if any, into buffer 
at point.
 
 Interactively added patterns are those normally specified using
 `highlight-regexp' and `highlight-lines-matching-regexp'; they can
-be found in variable `hi-lock-interactive-patterns'.
-
-\(fn)" t nil)
+be found in variable `hi-lock-interactive-patterns'." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"hi-lock" '("hi-lock-" "turn-on-hi-lock-if-enabled")))
 
@@ -16419,9 +15999,7 @@ Key bindings:
 \(fn &optional ARG)" t nil)
 
 (autoload 'turn-off-hideshow "hideshow" "\
-Unconditionally turn off `hs-minor-mode'.
-
-\(fn)" nil nil)
+Unconditionally turn off `hs-minor-mode'." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"hideshow" '("hs-")))
 
@@ -16481,14 +16059,10 @@ This allows you to manually remove highlighting from 
uninteresting changes.
 \(fn BEG END)" t nil)
 
 (autoload 'highlight-changes-next-change "hilit-chg" "\
-Move to the beginning of the next change, if in Highlight Changes mode.
-
-\(fn)" t nil)
+Move to the beginning of the next change, if in Highlight Changes mode." t nil)
 
 (autoload 'highlight-changes-previous-change "hilit-chg" "\
-Move to the beginning of the previous change, if in Highlight Changes mode.
-
-\(fn)" t nil)
+Move to the beginning of the previous change, if in Highlight Changes mode." t 
nil)
 
 (autoload 'highlight-changes-rotate-faces "hilit-chg" "\
 Rotate the faces if in Highlight Changes mode and the changes are visible.
@@ -16502,9 +16076,7 @@ You can automatically rotate colors when the buffer is 
saved by adding
 this function to `write-file-functions' as a buffer-local value.  To do
 this, eval the following in the buffer to be saved:
 
-  (add-hook \\='write-file-functions \\='highlight-changes-rotate-faces nil t)
-
-\(fn)" t nil)
+  (add-hook \\='write-file-functions \\='highlight-changes-rotate-faces nil 
t)" t nil)
 
 (autoload 'highlight-compare-buffers "hilit-chg" "\
 Compare two buffers and highlight the differences.
@@ -17371,51 +16943,37 @@ RET   Select the buffer at the front of the list of 
matches.
 \\[ido-completion-help]        Show list of matching buffers in separate 
window.
 \\[ido-enter-find-file]        Drop into `ido-find-file'.
 \\[ido-kill-buffer-at-head]    Kill buffer at head of buffer list.
-\\[ido-toggle-ignore]  Toggle ignoring buffers listed in `ido-ignore-buffers'.
-
-\(fn)" t nil)
+\\[ido-toggle-ignore]  Toggle ignoring buffers listed in 
`ido-ignore-buffers'." t nil)
 
 (autoload 'ido-switch-buffer-other-window "ido" "\
 Switch to another buffer and show it in another window.
 The buffer name is selected interactively by typing a substring.
-For details of keybindings, see `ido-switch-buffer'.
-
-\(fn)" t nil)
+For details of keybindings, see `ido-switch-buffer'." t nil)
 
 (autoload 'ido-display-buffer "ido" "\
 Display a buffer in another window but don't select it.
 The buffer name is selected interactively by typing a substring.
-For details of keybindings, see `ido-switch-buffer'.
-
-\(fn)" t nil)
+For details of keybindings, see `ido-switch-buffer'." t nil)
 
 (autoload 'ido-display-buffer-other-frame "ido" "\
 Display a buffer preferably in another frame.
 The buffer name is selected interactively by typing a substring.
-For details of keybindings, see `ido-switch-buffer'.
-
-\(fn)" t nil)
+For details of keybindings, see `ido-switch-buffer'." t nil)
 
 (autoload 'ido-kill-buffer "ido" "\
 Kill a buffer.
 The buffer name is selected interactively by typing a substring.
-For details of keybindings, see `ido-switch-buffer'.
-
-\(fn)" t nil)
+For details of keybindings, see `ido-switch-buffer'." t nil)
 
 (autoload 'ido-insert-buffer "ido" "\
 Insert contents of a buffer in current buffer after point.
 The buffer name is selected interactively by typing a substring.
-For details of keybindings, see `ido-switch-buffer'.
-
-\(fn)" t nil)
+For details of keybindings, see `ido-switch-buffer'." t nil)
 
 (autoload 'ido-switch-buffer-other-frame "ido" "\
 Switch to another buffer and show it in another frame.
 The buffer name is selected interactively by typing a substring.
-For details of keybindings, see `ido-switch-buffer'.
-
-\(fn)" t nil)
+For details of keybindings, see `ido-switch-buffer'." t nil)
 
 (autoload 'ido-find-file-in-dir "ido" "\
 Switch to another file starting from DIR.
@@ -17463,100 +17021,72 @@ RET  Select the file at the front of the list of 
matches.
 \\[ido-toggle-case]    Toggle case-sensitive searching of file names.
 \\[ido-toggle-literal] Toggle literal reading of this file.
 \\[ido-completion-help]        Show list of matching files in separate window.
-\\[ido-toggle-ignore]  Toggle ignoring files listed in `ido-ignore-files'.
-
-\(fn)" t nil)
+\\[ido-toggle-ignore]  Toggle ignoring files listed in `ido-ignore-files'." t 
nil)
 
 (autoload 'ido-find-file-other-window "ido" "\
 Switch to another file and show it in another window.
 The file name is selected interactively by typing a substring.
-For details of keybindings, see `ido-find-file'.
-
-\(fn)" t nil)
+For details of keybindings, see `ido-find-file'." t nil)
 
 (autoload 'ido-find-alternate-file "ido" "\
 Find another file, select its buffer, kill previous buffer.
 The file name is selected interactively by typing a substring.
-For details of keybindings, see `ido-find-file'.
-
-\(fn)" t nil)
+For details of keybindings, see `ido-find-file'." t nil)
 
 (autoload 'ido-find-alternate-file-other-window "ido" "\
 Find file as a replacement for the file in the next window.
 The file name is selected interactively by typing a substring.
-For details of keybindings, see `ido-find-file'.
-
-\(fn)" t nil)
+For details of keybindings, see `ido-find-file'." t nil)
 
 (autoload 'ido-find-file-read-only "ido" "\
 Edit file read-only with name obtained via minibuffer.
 The file name is selected interactively by typing a substring.
-For details of keybindings, see `ido-find-file'.
-
-\(fn)" t nil)
+For details of keybindings, see `ido-find-file'." t nil)
 
 (autoload 'ido-find-file-read-only-other-window "ido" "\
 Edit file read-only in other window with name obtained via minibuffer.
 The file name is selected interactively by typing a substring.
-For details of keybindings, see `ido-find-file'.
-
-\(fn)" t nil)
+For details of keybindings, see `ido-find-file'." t nil)
 
 (autoload 'ido-find-file-read-only-other-frame "ido" "\
 Edit file read-only in other frame with name obtained via minibuffer.
 The file name is selected interactively by typing a substring.
-For details of keybindings, see `ido-find-file'.
-
-\(fn)" t nil)
+For details of keybindings, see `ido-find-file'." t nil)
 
 (autoload 'ido-display-file "ido" "\
 Display a file in another window but don't select it.
 The file name is selected interactively by typing a substring.
-For details of keybindings, see `ido-find-file'.
-
-\(fn)" t nil)
+For details of keybindings, see `ido-find-file'." t nil)
 
 (autoload 'ido-find-file-other-frame "ido" "\
 Switch to another file and show it in another frame.
 The file name is selected interactively by typing a substring.
-For details of keybindings, see `ido-find-file'.
-
-\(fn)" t nil)
+For details of keybindings, see `ido-find-file'." t nil)
 
 (autoload 'ido-write-file "ido" "\
 Write current buffer to a file.
 The file name is selected interactively by typing a substring.
-For details of keybindings, see `ido-find-file'.
-
-\(fn)" t nil)
+For details of keybindings, see `ido-find-file'." t nil)
 
 (autoload 'ido-insert-file "ido" "\
 Insert contents of file in current buffer.
 The file name is selected interactively by typing a substring.
-For details of keybindings, see `ido-find-file'.
-
-\(fn)" t nil)
+For details of keybindings, see `ido-find-file'." t nil)
 
 (autoload 'ido-dired "ido" "\
 Call `dired' the Ido way.
 The directory is selected interactively by typing a substring.
-For details of keybindings, see `ido-find-file'.
-
-\(fn)" t nil)
+For details of keybindings, see `ido-find-file'." t nil)
 
 (autoload 'ido-dired-other-window "ido" "\
 \"Edit\" a directory.  Like `ido-dired' but selects in another window.
 The directory is selected interactively by typing a substring.
-For details of keybindings, see `ido-find-file'.
-
-\(fn)" t nil)
+For details of keybindings, see `ido-find-file'." t nil)
 
 (autoload 'ido-dired-other-frame "ido" "\
 \"Edit\" a directory.  Like `ido-dired' but makes a new frame.
 The directory is selected interactively by typing a substring.
-For details of keybindings, see `ido-find-file'.
-
-\(fn)" t nil)
+For details of keybindings, see `ido-find-file'." t nil)
 
 (autoload 'ido-read-buffer "ido" "\
 Ido replacement for the built-in `read-buffer'.
@@ -17661,9 +17191,7 @@ be determined.
 (autoload 'image-type-from-buffer "image" "\
 Determine the image type from data in the current buffer.
 Value is a symbol specifying the image type or nil if type cannot
-be determined.
-
-\(fn)" nil nil)
+be determined." nil nil)
 
 (autoload 'image-type-from-file-header "image" "\
 Determine the type of image file FILE from its first few bytes.
@@ -17704,20 +17232,25 @@ The buffer is considered to contain an 
auto-detectable image if
 its beginning matches an image type in `image-type-header-regexps',
 and that image type is present in `image-type-auto-detectable' with a
 non-nil value.  If that value is non-nil, but not t, then the image type
-must be available.
-
-\(fn)" nil nil)
+must be available." nil nil)
 
 (autoload 'create-image "image" "\
 Create an image.
 FILE-OR-DATA is an image file name or image data.
+
 Optional TYPE is a symbol describing the image type.  If TYPE is omitted
 or nil, try to determine the image type from its first few bytes
 of image data.  If that doesn't work, and FILE-OR-DATA is a file name,
 use its file extension as image type.
+
 Optional DATA-P non-nil means FILE-OR-DATA is a string containing image data.
+
 Optional PROPS are additional image attributes to assign to the image,
-like, e.g. `:mask MASK'.
+like, e.g. `:mask MASK'.  If the property `:scale' is not given and the
+display has a high resolution (more exactly, when the average width of a
+character in the default font is more than 10 pixels), the image is
+automatically scaled up in proportion to the default font.
+
 Value is the image created, or nil if images of type TYPE are not supported.
 
 Images should not be larger than specified by `max-image-size'.
@@ -17835,9 +17368,7 @@ Emacs visits them in Image mode.  They are also added to
 `image-type-file-name-regexps', so that the `image-type' function
 recognizes these files as having image type `imagemagick'.
 
-If Emacs is compiled without ImageMagick support, this does nothing.
-
-\(fn)" nil nil)
+If Emacs is compiled without ImageMagick support, this does nothing." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"image" '("image")))
 
@@ -17923,9 +17454,7 @@ With prefix argument ARG, remove tag from file at point.
 \(fn ARG)" t nil)
 
 (autoload 'image-dired-jump-thumbnail-buffer "image-dired" "\
-Jump to thumbnail buffer.
-
-\(fn)" t nil)
+Jump to thumbnail buffer." t nil)
 
 (autoload 'image-dired-minor-mode "image-dired" "\
 Setup easy-to-use keybindings for the commands to be used in dired mode.
@@ -17942,19 +17471,13 @@ if ARG is `toggle'; disable the mode otherwise.
 (define-obsolete-function-alias 'image-dired-setup-dired-keybindings 
'image-dired-minor-mode "26.1")
 
 (autoload 'image-dired-display-thumbs-append "image-dired" "\
-Append thumbnails to `image-dired-thumbnail-buffer'.
-
-\(fn)" t nil)
+Append thumbnails to `image-dired-thumbnail-buffer'." t nil)
 
 (autoload 'image-dired-display-thumb "image-dired" "\
-Shorthand for `image-dired-display-thumbs' with prefix argument.
-
-\(fn)" t nil)
+Shorthand for `image-dired-display-thumbs' with prefix argument." t nil)
 
 (autoload 'image-dired-dired-display-external "image-dired" "\
-Display file at point using an external viewer.
-
-\(fn)" t nil)
+Display file at point using an external viewer." t nil)
 
 (autoload 'image-dired-dired-display-image "image-dired" "\
 Display current image file.
@@ -17964,9 +17487,7 @@ With prefix argument ARG, display image in its original 
size.
 \(fn &optional ARG)" t nil)
 
 (autoload 'image-dired-dired-comment-files "image-dired" "\
-Add comment to current or marked files in dired.
-
-\(fn)" t nil)
+Add comment to current or marked files in dired." t nil)
 
 (autoload 'image-dired-mark-tagged-files "image-dired" "\
 Use regexp to mark files with matching tag.
@@ -17974,16 +17495,12 @@ A `tag' is a keyword, a piece of meta data, 
associated with an
 image file and stored in image-dired's database file.  This command
 lets you input a regexp and this will be matched against all tags
 on all image files in the database file.  The files that have a
-matching tag will be marked in the dired buffer.
-
-\(fn)" t nil)
+matching tag will be marked in the dired buffer." t nil)
 
 (autoload 'image-dired-dired-edit-comment-and-tags "image-dired" "\
 Edit comment and tags of current or marked image files.
 Edit comment and tags for all marked image files in an
-easy-to-use form.
-
-\(fn)" t nil)
+easy-to-use form." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"image-dired" '("image-dired-")))
 
@@ -18017,9 +17534,7 @@ the variable is set using \\[customize].")
 (custom-autoload 'image-file-name-regexps "image-file" nil)
 
 (autoload 'image-file-name-regexp "image-file" "\
-Return a regular expression matching image-file filenames.
-
-\(fn)" nil nil)
+Return a regular expression matching image-file filenames." nil nil)
 
 (autoload 'insert-image-file "image-file" "\
 Insert the image file FILE into the current buffer.
@@ -18065,9 +17580,7 @@ You can use \\<image-mode-map>\\[image-toggle-display] 
or \\<image-mode-map>\\[i
 to toggle between display as an image and display as text or hex.
 
 Key bindings:
-\\{image-mode-map}
-
-\(fn)" t nil)
+\\{image-mode-map}" t nil)
 
 (autoload 'image-minor-mode "image-mode" "\
 Toggle Image minor mode in this buffer.
@@ -18086,9 +17599,7 @@ actual image.
 (autoload 'image-mode-to-text "image-mode" "\
 Set a non-image mode as major mode in combination with image minor mode.
 A non-mage major mode found from `auto-mode-alist' or fundamental mode
-displays an image file as text.
-
-\(fn)" nil nil)
+displays an image file as text." nil nil)
 
 (autoload 'image-bookmark-jump "image-mode" "\
 
@@ -18231,9 +17742,7 @@ See the command `imenu' for more information.
 (autoload 'imenu-add-menubar-index "imenu" "\
 Add an Imenu \"Index\" entry on the menu bar for the current buffer.
 
-A trivial interface to `imenu-add-to-menubar' suitable for use in a hook.
-
-\(fn)" t nil)
+A trivial interface to `imenu-add-to-menubar' suitable for use in a hook." t 
nil)
 
 (autoload 'imenu "imenu" "\
 Jump to a place in the buffer chosen using a buffer menu or mouse menu.
@@ -18351,21 +17860,15 @@ See a list of available Info commands in `Info-mode'.
 \(fn &optional FILE-OR-NODE BUFFER)" t nil)
 
 (autoload 'info-emacs-manual "info" "\
-Display the Emacs manual in Info mode.
-
-\(fn)" t nil)
+Display the Emacs manual in Info mode." t nil)
 
 (autoload 'info-emacs-bug "info" "\
-Display the \"Reporting Bugs\" section of the Emacs manual in Info mode.
-
-\(fn)" t nil)
+Display the \"Reporting Bugs\" section of the Emacs manual in Info mode." t 
nil)
 
 (autoload 'info-standalone "info" "\
 Run Emacs as a standalone Info reader.
 Usage:  emacs -f info-standalone [filename]
-In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself.
-
-\(fn)" nil nil)
+In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself." nil 
nil)
 
 (autoload 'Info-on-current-buffer "info" "\
 Use Info mode to browse the current Info buffer.
@@ -18375,9 +17878,7 @@ otherwise, that defaults to `Top'.
 \(fn &optional NODENAME)" t nil)
 
 (autoload 'Info-directory "info" "\
-Go to the Info directory node.
-
-\(fn)" t nil)
+Go to the Info directory node." t nil)
 
 (autoload 'Info-index "info" "\
 Look up a string TOPIC in the index for this manual and go to that entry.
@@ -18489,9 +17990,7 @@ the variable `Info-file-list-for-emacs'.
 
 (autoload 'Info-speedbar-browser "info" "\
 Initialize speedbar to display an Info node browser.
-This will add a speedbar major display mode.
-
-\(fn)" t nil)
+This will add a speedbar major display mode." t nil)
 
 (autoload 'Info-bookmark-jump "info" "\
 This implements the `handler' function interface for the record
@@ -18519,9 +18018,7 @@ completion alternatives to currently visited manuals.
 Throw away all cached data.
 This command is useful if the user wants to start at the beginning without
 quitting Emacs, for example, after some Info documents were updated on the
-system.
-
-\(fn)" t nil)
+system." t nil)
  (put 'info-lookup-symbol 'info-file "emacs")
 
 (autoload 'info-lookup-symbol "info-look" "\
@@ -18604,9 +18101,7 @@ info files don't necessarily have a \".info\" extension 
and in
 particular the Emacs manuals normally don't.  If you have a
 source code directory in `Info-directory-list' then a lot of
 extraneous files might be read.  This will be time consuming but
-should be harmless.
-
-\(fn)" t nil)
+should be harmless." t nil)
 
 (autoload 'info-xref-check-all-custom "info-xref" "\
 Check info references in all customize groups and variables.
@@ -18615,9 +18110,7 @@ of the `custom-links' for a variable.
 
 Any `custom-load' autoloads in variables are loaded in order to
 get full link information.  This will be a lot of Lisp packages
-and can take a long time.
-
-\(fn)" t nil)
+and can take a long time." t nil)
 
 (autoload 'info-xref-docstrings "info-xref" "\
 Check docstring info node references in source files.
@@ -18671,23 +18164,17 @@ should be saved in place of the original visited file.
 The subfiles are written in the same directory the original file is
 in, with names generated by appending `-' and a number to the original
 file name.  The indirect file still functions as an Info file, but it
-contains just the tag table and a directory of subfiles.
-
-\(fn)" t nil)
+contains just the tag table and a directory of subfiles." t nil)
 
 (autoload 'Info-validate "informat" "\
 Check current buffer for validity as an Info file.
-Check that every node pointer points to an existing node.
-
-\(fn)" t nil)
+Check that every node pointer points to an existing node." t nil)
 
 (autoload 'batch-info-validate "informat" "\
 Runs `Info-validate' on the files remaining on the command line.
 Must be used only with -batch, and kills Emacs on completion.
 Each file will be processed even if an error occurred previously.
-For example, invoke \"emacs -batch -f batch-info-validate $info/ ~/*.info\"
-
-\(fn)" nil nil)
+For example, invoke \"emacs -batch -f batch-info-validate $info/ ~/*.info\"" 
nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"informat" '("Info-validate-")))
 
@@ -18731,14 +18218,10 @@ Only checks one based on which kind of Emacs is being 
run.
 ;;; Generated autoloads from international/isearch-x.el
 
 (autoload 'isearch-toggle-specified-input-method "isearch-x" "\
-Select an input method and turn it on in interactive search.
-
-\(fn)" t nil)
+Select an input method and turn it on in interactive search." t nil)
 
 (autoload 'isearch-toggle-input-method "isearch-x" "\
-Toggle input method in interactive search.
-
-\(fn)" t nil)
+Toggle input method in interactive search." t nil)
 
 (autoload 'isearch-process-search-multibyte-characters "isearch-x" "\
 
@@ -18757,9 +18240,7 @@ Toggle input method in interactive search.
 Active isearchb mode for subsequent alphanumeric keystrokes.
 Executing this command again will terminate the search; or, if
 the search has not yet begun, will toggle to the last buffer
-accessed via isearchb.
-
-\(fn)" t nil)
+accessed via isearchb." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"isearchb" '("isearchb")))
 
@@ -18858,9 +18339,7 @@ Warn that format is write-only.
 \(fn &rest IGNORE)" t nil)
 
 (autoload 'iso-cvt-define-menu "iso-cvt" "\
-Add submenus to the File menu, to convert to and from various formats.
-
-\(fn)" t nil)
+Add submenus to the File menu, to convert to and from various formats." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"iso-cvt" '("iso-")))
 
@@ -18979,9 +18458,7 @@ SPC:   Accept word this time.
 `m':   Place typed-in value in personal dictionary, then recheck current word.
 `C-l':  Redraw screen.
 `C-r':  Recursive edit.
-`C-z':  Suspend Emacs or iconify frame.
-
-\(fn)" nil nil)
+`C-z':  Suspend Emacs or iconify frame." nil nil)
 
 (autoload 'ispell-kill-ispell "ispell" "\
 Kill current Ispell process (so that you may start a fresh one).
@@ -19007,14 +18484,10 @@ amount for last line processed.
 \(fn REG-START REG-END &optional RECHECKP SHIFT)" t nil)
 
 (autoload 'ispell-comments-and-strings "ispell" "\
-Check comments and strings in the current buffer for spelling errors.
-
-\(fn)" t nil)
+Check comments and strings in the current buffer for spelling errors." t nil)
 
 (autoload 'ispell-buffer "ispell" "\
-Check the current buffer for spelling errors interactively.
-
-\(fn)" t nil)
+Check the current buffer for spelling errors interactively." t nil)
 
 (autoload 'ispell-buffer-with-debug "ispell" "\
 `ispell-buffer' with some output sent to `ispell-debug-buffer' buffer.
@@ -19023,9 +18496,7 @@ If APPEND is non-n il, append the info to previous 
buffer if exists.
 \(fn &optional APPEND)" t nil)
 
 (autoload 'ispell-continue "ispell" "\
-Continue a halted spelling session beginning with the current word.
-
-\(fn)" t nil)
+Continue a halted spelling session beginning with the current word." t nil)
 
 (autoload 'ispell-complete-word "ispell" "\
 Try to complete the word before or at point.
@@ -19037,9 +18508,7 @@ Standard ispell choices are then available.
 \(fn &optional INTERIOR-FRAG)" t nil)
 
 (autoload 'ispell-complete-word-interior-frag "ispell" "\
-Completes word matching character sequence inside a word.
-
-\(fn)" t nil)
+Completes word matching character sequence inside a word." t nil)
 
 (autoload 'ispell "ispell" "\
 Interactively check a region or buffer for spelling errors.
@@ -19049,9 +18518,7 @@ that region.  Otherwise spell-check the buffer.
 Ispell dictionaries are not distributed with Emacs.  If you are
 looking for a dictionary, please see the distribution of the GNU ispell
 program, or do an Internet search; there are various dictionaries
-available on the net.
-
-\(fn)" t nil)
+available on the net." t nil)
 
 (autoload 'ispell-minor-mode "ispell" "\
 Toggle last-word spell checking (Ispell minor mode).
@@ -19092,9 +18559,7 @@ in your init file:
 
 You can bind this to the key C-c i in GNUS or mail by adding to
 `news-reply-mode-hook' or `mail-mode-hook' the following lambda expression:
-   (function (lambda () (local-set-key \"\\C-ci\" \\='ispell-message)))
-
-\(fn)" t nil)
+   (function (lambda () (local-set-key \"\\C-ci\" \\='ispell-message)))" t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"ispell" '("check-ispell-version" "ispell-")))
 
@@ -19120,10 +18585,7 @@ You can bind this to the key C-c i in GNUS or mail by 
adding to
 ;;;;;;  0 0))
 ;;; Generated autoloads from language/japan-util.el
 
-(autoload 'setup-japanese-environment-internal "japan-util" "\
-
-
-\(fn)" nil nil)
+(autoload 'setup-japanese-environment-internal "japan-util" nil nil nil)
 
 (autoload 'japanese-katakana "japan-util" "\
 Convert argument to Katakana and return that.
@@ -19213,9 +18675,7 @@ It is not recommended to set this variable permanently 
to anything but nil.")
 Uninstall jka-compr.
 This removes the entries in `file-name-handler-alist' and `auto-mode-alist'
 and `inhibit-local-variables-suffixes' that were added
-by `jka-compr-installed'.
-
-\(fn)" nil nil)
+by `jka-compr-installed'." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"jka-compr" '("compression-error" "jka-compr-")))
 
@@ -19260,7 +18720,7 @@ locally, like so:
 
 ;;;### (autoloads nil "jsonrpc" "jsonrpc.el" (0 0 0 0))
 ;;; Generated autoloads from jsonrpc.el
-(push (purecopy '(jsonrpc 1 0 6)) package--builtin-versions)
+(push (purecopy '(jsonrpc 1 0 7)) package--builtin-versions)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"jsonrpc" '("jrpc-default-request-timeout" "jsonrpc-")))
 
@@ -19457,9 +18917,10 @@ the current value of `kmacro-counter').
 
 When used during defining/executing a macro, inserts the current value
 of `kmacro-counter' and increments the counter value by ARG (or by 1 if no
-prefix argument).  With just \\[universal-argument], inserts the current value
-of `kmacro-counter', but does not modify the counter; this is the
-same as incrementing the counter by zero.
+prefix argument).  With just \\[universal-argument], inserts the previous
+value of `kmacro-counter', and does not modify the counter; this is
+different from incrementing the counter by zero.  (The previous value
+of the counter is the one it had before the last increment.)
 
 The macro counter can be set directly via \\[kmacro-set-counter] and 
\\[kmacro-add-counter].
 The format of the inserted value of the counter can be controlled
@@ -19502,10 +18963,7 @@ If kbd macro currently being defined end it before 
activating it.
 The kind of Korean keyboard for Korean input method.
 \"\" for 2, \"3\" for 3.")
 
-(autoload 'setup-korean-environment-internal "korea-util" "\
-
-
-\(fn)" nil nil)
+(autoload 'setup-korean-environment-internal "korea-util" nil nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"korea-util" '("exit-korean-environment" "isearch-" "korean-key-bindings" 
"quail-hangul-switch-" "toggle-korean-input-method")))
 
@@ -19969,9 +19427,7 @@ argument.")
 (autoload 'lpr-buffer "lpr" "\
 Print buffer contents without pagination or page headers.
 See the variables `lpr-switches' and `lpr-command'
-for customization of the printer command.
-
-\(fn)" t nil)
+for customization of the printer command." t nil)
 
 (autoload 'print-buffer "lpr" "\
 Paginate and print buffer contents.
@@ -19985,9 +19441,7 @@ Otherwise, the switches in `lpr-headers-switches' are 
used
 in the print command itself; we expect them to request pagination.
 
 See the variables `lpr-switches' and `lpr-command'
-for further customization of the printer command.
-
-\(fn)" t nil)
+for further customization of the printer command." t nil)
 
 (autoload 'lpr-region "lpr" "\
 Print region contents without pagination or page headers.
@@ -20142,7 +19596,8 @@ and then select the region of un-tablified names and use
 ;;; Generated autoloads from mail/mail-extr.el
 
 (autoload 'mail-extract-address-components "mail-extr" "\
-Given an RFC-822 address ADDRESS, extract full name and canonical address.
+Extract full name and canonical address from ADDRESS.
+ADDRESS should be in RFC 822 (or later) format.
 Returns a list of the form (FULL-NAME CANONICAL-ADDRESS).  If no
 name can be extracted, FULL-NAME will be nil.  Also see
 `mail-extr-ignore-single-names' and
@@ -20180,14 +19635,9 @@ Convert mail domain DOMAIN to the country it 
corresponds to.
 ;;; Generated autoloads from mail/mail-hist.el
 
 (autoload 'mail-hist-define-keys "mail-hist" "\
-Define keys for accessing mail header history.  For use in hooks.
-
-\(fn)" nil nil)
-
-(autoload 'mail-hist-enable "mail-hist" "\
+Define keys for accessing mail header history.  For use in hooks." nil nil)
 
-
-\(fn)" nil nil)
+(autoload 'mail-hist-enable "mail-hist" nil nil nil)
 
 (defvar mail-hist-keep-history t "\
 Non-nil means keep a history for headers and text of outgoing mail.")
@@ -20199,9 +19649,7 @@ Put headers and contents of this message into mail 
header history.
 Each header has its own independent history, as does the body of the
 message.
 
-This function normally would be called when the message is sent.
-
-\(fn)" nil nil)
+This function normally would be called when the message is sent." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"mail-hist" '("mail-hist-")))
 
@@ -20233,7 +19681,7 @@ This function normally would be called when the message 
is sent.
 ;;; Generated autoloads from mail/mail-utils.el
 
 (defvar mail-use-rfc822 nil "\
-If non-nil, use a full, hairy RFC822 parser on mail addresses.
+If non-nil, use a full, hairy RFC 822 (or later) parser on mail addresses.
 Otherwise, (the default) use a smaller, somewhat faster, and
 often correct parser.")
 
@@ -20334,9 +19782,7 @@ the entries in your `mail-personal-alias-file'.
 \(fn &optional ARG)" t nil)
 
 (autoload 'mail-abbrevs-setup "mailabbrev" "\
-Initialize use of the `mailabbrev' package.
-
-\(fn)" nil nil)
+Initialize use of the `mailabbrev' package." nil nil)
 
 (autoload 'build-mail-abbrevs "mailabbrev" "\
 Read mail aliases from personal mail alias file and set `mail-abbrevs'.
@@ -20397,9 +19843,7 @@ if it is quoted with double-quotes.
 
 (autoload 'mail-completion-at-point-function "mailalias" "\
 Compute completion data for mail aliases.
-For use on `completion-at-point-functions'.
-
-\(fn)" nil nil)
+For use on `completion-at-point-functions'." nil nil)
 
 (autoload 'mail-complete "mailalias" "\
 Perform completion on header field or word preceding point.
@@ -20427,9 +19871,7 @@ current header, calls `mail-complete-function' and 
passes prefix ARG if any.
 (autoload 'mailclient-send-it "mailclient" "\
 Pass current buffer on to the system's mail client.
 Suitable value for `send-mail-function'.
-The mail client is taken to be the handler of mailto URLs.
-
-\(fn)" nil nil)
+The mail client is taken to be the handler of mailto URLs." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"mailclient" '("mailclient-")))
 
@@ -20581,9 +20023,7 @@ An adapted `makefile-mode' that knows about imake.
 
 (autoload 'make-command-summary "makesum" "\
 Make a summary of current key bindings in the buffer *Summary*.
-Previous contents of that buffer are killed first.
-
-\(fn)" t nil)
+Previous contents of that buffer are killed first." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"makesum" '("double-column")))
 
@@ -20656,9 +20096,9 @@ Default bookmark handler for Man buffers.
 
 ;;;### (autoloads nil "map" "emacs-lisp/map.el" (0 0 0 0))
 ;;; Generated autoloads from emacs-lisp/map.el
-(push (purecopy '(map 1 2)) package--builtin-versions)
+(push (purecopy '(map 2 0)) package--builtin-versions)
 
-(if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"map" '("map")))
+(if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"map" '("map-")))
 
 ;;;***
 
@@ -20813,14 +20253,10 @@ If ARG, allow editing of the cancellation message.
 (autoload 'message-supersede "message" "\
 Start composing a message to supersede the current message.
 This is done simply by taking the old article and adding a Supersedes
-header line with the old Message-ID.
-
-\(fn)" t nil)
+header line with the old Message-ID." t nil)
 
 (autoload 'message-recover "message" "\
-Reread contents of current buffer from its last auto-save file.
-
-\(fn)" t nil)
+Reread contents of current buffer from its last auto-save file." t nil)
 
 (autoload 'message-forward "message" "\
 Forward the current message via mail.
@@ -20840,9 +20276,7 @@ Optional DIGEST will use digest to forward.
 \(fn FORWARD-BUFFER)" nil nil)
 
 (autoload 'message-insinuate-rmail "message" "\
-Let RMAIL use message to forward.
-
-\(fn)" t nil)
+Let RMAIL use message to forward." t nil)
 
 (autoload 'message-resend "message" "\
 Resend the current article to ADDRESS.
@@ -20853,9 +20287,7 @@ Resend the current article to ADDRESS.
 Re-mail the current message.
 This only makes sense if the current message is a bounce message that
 contains some mail you have written which has been bounced back to
-you.
-
-\(fn)" t nil)
+you." t nil)
 
 (autoload 'message-mail-other-window "message" "\
 Like `message-mail' command, but display mail buffer in another window.
@@ -20920,9 +20352,7 @@ Major mode for editing MetaPost sources.
 
 (autoload 'metamail-interpret-header "metamail" "\
 Interpret a header part of a MIME message in current buffer.
-Its body part is not interpreted at all.
-
-\(fn)" t nil)
+Its body part is not interpreted at all." t nil)
 
 (autoload 'metamail-interpret-body "metamail" "\
 Interpret a body part of a MIME message in current buffer.
@@ -20986,15 +20416,11 @@ redisplayed as output is inserted.
 
 (autoload 'mh-smail "mh-comp" "\
 Compose a message with the MH mail system.
-See `mh-send' for more details on composing mail.
-
-\(fn)" t nil)
+See `mh-send' for more details on composing mail." t nil)
 
 (autoload 'mh-smail-other-window "mh-comp" "\
 Compose a message with the MH mail system in other window.
-See `mh-send' for more details on composing mail.
-
-\(fn)" t nil)
+See `mh-send' for more details on composing mail." t nil)
 
 (autoload 'mh-smail-batch "mh-comp" "\
 Compose a message with the MH mail system.
@@ -21065,9 +20491,7 @@ Quit editing and delete draft message.
 If for some reason you are not happy with the draft, you can use
 this command to kill the draft buffer and delete the draft
 message. Use the command \\[kill-buffer] if you don't want to
-delete the draft message.
-
-\(fn)" t nil)
+delete the draft message." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"mh-comp" '("mh-")))
 
@@ -21091,9 +20515,7 @@ delete the draft message.
 (put 'mh-lib-progs 'risky-local-variable t)
 
 (autoload 'mh-version "mh-e" "\
-Display version information about MH-E and the MH mail handling system.
-
-\(fn)" t nil)
+Display version information about MH-E and the MH mail handling system." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"mh-e" '("defcustom-mh" "defface-mh" "defgroup-mh" "mh-")))
 
@@ -21353,9 +20775,7 @@ The relevant variables are 
`clean-buffer-list-delay-general',
 While processing buffers, this procedure displays messages containing
 the current date/time, buffer name, how many seconds ago it was
 displayed (can be nil if the buffer was never displayed) and its
-lifetime, i.e., its \"age\" when it will be purged.
-
-\(fn)" t nil)
+lifetime, i.e., its \"age\" when it will be purged." t nil)
 
 (autoload 'midnight-delay-set "midnight" "\
 Modify `midnight-timer' according to `midnight-delay'.
@@ -21422,14 +20842,10 @@ Ignores CHAR at point.
 \(fn ARG CHAR)" t nil)
 
 (autoload 'mark-beginning-of-buffer "misc" "\
-Set mark at the beginning of the buffer.
-
-\(fn)" t nil)
+Set mark at the beginning of the buffer." t nil)
 
 (autoload 'mark-end-of-buffer "misc" "\
-Set mark at the end of the buffer.
-
-\(fn)" t nil)
+Set mark at the end of the buffer." t nil)
 
 (autoload 'upcase-char "misc" "\
 Uppercasify ARG chars starting from point.  Point doesn't move.
@@ -21456,9 +20872,7 @@ upper atmosphere.  These cause momentary pockets of 
higher-pressure
 air to form, which act as lenses that deflect incoming cosmic rays,
 focusing them to strike the drive platter and flip the desired bit.
 You can type `M-x butterfly C-M-c' to run it.  This is a permuted
-variation of `C-x M-c M-butterfly' from url `http://xkcd.com/378/'.
-
-\(fn)" t nil)
+variation of `C-x M-c M-butterfly' from url `http://xkcd.com/378/'." t nil)
 
 (autoload 'list-dynamic-libraries "misc" "\
 Display a list of all dynamic libraries known to Emacs.
@@ -21519,9 +20933,7 @@ Sequence of files visited by multiple file buffers 
Isearch.")
 
 (autoload 'multi-isearch-setup "misearch" "\
 Set up isearch to search multiple buffers.
-Intended to be added to `isearch-mode-hook'.
-
-\(fn)" nil nil)
+Intended to be added to `isearch-mode-hook'." nil nil)
 
 (autoload 'multi-isearch-buffers "misearch" "\
 Start multi-buffer Isearch on a list of BUFFERS.
@@ -21704,9 +21116,7 @@ Assume text has been decoded if DECODED is non-nil.
 ;;; Generated autoloads from gnus/mml.el
 
 (autoload 'mml-to-mime "mml" "\
-Translate the current buffer from MML to MIME.
-
-\(fn)" nil nil)
+Translate the current buffer from MML to MIME." nil nil)
 
 (autoload 'mml-attach-file "mml" "\
 Attach a file to the outgoing MIME message.
@@ -21795,10 +21205,7 @@ will be computed and used.
 
 \(fn CONT)" nil nil)
 
-(autoload 'mml2015-self-encrypt "mml2015" "\
-
-
-\(fn)" nil nil)
+(autoload 'mml2015-self-encrypt "mml2015" nil nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"mml2015" '("mml2015-")))
 
@@ -21935,9 +21342,7 @@ To test this function, evaluate:
 ;;; Generated autoloads from mpc.el
 
 (autoload 'mpc "mpc" "\
-Main entry point for MPC.
-
-\(fn)" t nil)
+Main entry point for MPC." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"mpc" '("mpc-" "tag-browser-tagtypes")))
 
@@ -21947,9 +21352,7 @@ Main entry point for MPC.
 ;;; Generated autoloads from play/mpuz.el
 
 (autoload 'mpuz "mpuz" "\
-Multiplication puzzle with GNU Emacs.
-
-\(fn)" t nil)
+Multiplication puzzle with GNU Emacs." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"mpuz" '("mpuz-")))
 
@@ -22058,14 +21461,10 @@ in place of `..':
   `default-process-coding-system' for read
   eol-type of `default-process-coding-system' for read
   `default-process-coding-system' for write
-  eol-type of `default-process-coding-system'
-
-\(fn)" t nil)
+  eol-type of `default-process-coding-system'" t nil)
 
 (autoload 'describe-current-coding-system "mule-diag" "\
-Display coding systems currently used, in detail.
-
-\(fn)" t nil)
+Display coding systems currently used, in detail." t nil)
 
 (autoload 'list-coding-systems "mule-diag" "\
 Display a list of all coding systems.
@@ -22077,9 +21476,7 @@ but still contains full information about each coding 
system.
 \(fn &optional ARG)" t nil)
 
 (autoload 'list-coding-categories "mule-diag" "\
-Display a list of all coding categories.
-
-\(fn)" nil nil)
+Display a list of all coding categories." nil nil)
 
 (autoload 'describe-font "mule-diag" "\
 Display information about a font whose name is FONTNAME.
@@ -22102,9 +21499,7 @@ see the function `describe-fontset' for the format of 
the list.
 \(fn ARG)" t nil)
 
 (autoload 'list-input-methods "mule-diag" "\
-Display information about all input methods.
-
-\(fn)" t nil)
+Display information about all input methods." t nil)
 
 (autoload 'mule-diag "mule-diag" "\
 Display diagnosis of the multilingual environment (Mule).
@@ -22112,9 +21507,7 @@ Display diagnosis of the multilingual environment 
(Mule).
 This shows various information related to the current multilingual
 environment, including lists of input methods, coding systems,
 character sets, and fontsets (if Emacs is running under a window
-system which uses fontsets).
-
-\(fn)" t nil)
+system which uses fontsets)." t nil)
 
 (autoload 'font-show-log "mule-diag" "\
 Show log of font listing and opening.
@@ -22283,41 +21676,6 @@ QUALITY can be:
 
 ;;;***
 
-;;;### (autoloads nil "multifile" "multifile.el" (0 0 0 0))
-;;; Generated autoloads from multifile.el
-
-(autoload 'multifile-initialize "multifile" "\
-Initialize a new round of operation on several files.
-FILES can be either a list of file names, or an iterator (used with 
`iter-next')
-which returns a file name at each step.
-SCAN-FUNCTION is a function called with no argument inside a buffer
-and it should return non-nil if that buffer has something on which to operate.
-OPERATE-FUNCTION is a function called with no argument; it is expected
-to perform the operation on the current file buffer and when done
-should return non-nil to mean that we should immediately continue
-operating on the next file and nil otherwise.
-
-\(fn FILES SCAN-FUNCTION OPERATE-FUNCTION)" nil nil)
-
-(autoload 'multifile-initialize-search "multifile" "\
-
-
-\(fn REGEXP FILES CASE-FOLD)" nil nil)
-
-(autoload 'multifile-initialize-replace "multifile" "\
-Initialize a new round of query&replace on several files.
-FROM is a regexp and TO is the replacement to use.
-FILES describes the file, as in `multifile-initialize'.
-CASE-FOLD can be t, nil, or `default', the latter one meaning to obey
-the default setting of `case-fold-search'.
-DELIMITED if non-nil means replace only word-delimited matches.
-
-\(fn FROM TO FILES CASE-FOLD &optional DELIMITED)" nil nil)
-
-(if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"multifile" '("multifile-")))
-
-;;;***
-
 ;;;### (autoloads nil "mwheel" "mwheel.el" (0 0 0 0))
 ;;; Generated autoloads from mwheel.el
 
@@ -22329,29 +21687,19 @@ DELIMITED if non-nil means replace only 
word-delimited matches.
 ;;; Generated autoloads from net/net-utils.el
 
 (autoload 'ifconfig "net-utils" "\
-Run `ifconfig-program' and display diagnostic output.
-
-\(fn)" t nil)
+Run `ifconfig-program' and display diagnostic output." t nil)
 
 (autoload 'iwconfig "net-utils" "\
-Run `iwconfig-program' and display diagnostic output.
-
-\(fn)" t nil)
+Run `iwconfig-program' and display diagnostic output." t nil)
 
 (autoload 'netstat "net-utils" "\
-Run `netstat-program' and display diagnostic output.
-
-\(fn)" t nil)
+Run `netstat-program' and display diagnostic output." t nil)
 
 (autoload 'arp "net-utils" "\
-Run `arp-program' and display diagnostic output.
-
-\(fn)" t nil)
+Run `arp-program' and display diagnostic output." t nil)
 
 (autoload 'route "net-utils" "\
-Run `route-program' and display diagnostic output.
-
-\(fn)" t nil)
+Run `route-program' and display diagnostic output." t nil)
 
 (autoload 'traceroute "net-utils" "\
 Run `traceroute-program' for TARGET.
@@ -22376,9 +21724,7 @@ This command uses `nslookup-program' for looking up the 
DNS information.
 \(fn HOST &optional NAME-SERVER)" t nil)
 
 (autoload 'nslookup "net-utils" "\
-Run `nslookup-program'.
-
-\(fn)" t nil)
+Run `nslookup-program'." t nil)
 
 (autoload 'dns-lookup-host "net-utils" "\
 Look up the DNS information for HOST (name or IP address).
@@ -22420,10 +21766,7 @@ The port is deduced from 
`network-connection-service-alist'.
 
 \(fn ARG SEARCH-STRING)" t nil)
 
-(autoload 'whois-reverse-lookup "net-utils" "\
-
-
-\(fn)" t nil)
+(autoload 'whois-reverse-lookup "net-utils" nil t nil)
 
 (autoload 'network-connection-to-service "net-utils" "\
 Open a network connection to SERVICE on HOST.
@@ -22570,9 +21913,7 @@ gnutls-boot (as returned by `gnutls-boot-parameters').
 (autoload 'newsticker-running-p "newst-backend" "\
 Check whether newsticker is running.
 Return t if newsticker is running, nil otherwise.  Newsticker is
-considered to be running if the newsticker timer list is not empty.
-
-\(fn)" nil nil)
+considered to be running if the newsticker timer list is not empty." nil nil)
 
 (autoload 'newsticker-start "newst-backend" "\
 Start the newsticker.
@@ -22592,9 +21933,7 @@ Run `newsticker-start-hook' if newsticker was not 
running already.
 ;;; Generated autoloads from net/newst-plainview.el
 
 (autoload 'newsticker-plainview "newst-plainview" "\
-Start newsticker plainview.
-
-\(fn)" t nil)
+Start newsticker plainview." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"newst-plainview" '("newsticker-")))
 
@@ -22605,9 +21944,7 @@ Start newsticker plainview.
 ;;; Generated autoloads from net/newst-reader.el
 
 (autoload 'newsticker-show-news "newst-reader" "\
-Start reading news.  You may want to bind this to a key.
-
-\(fn)" t nil)
+Start reading news.  You may want to bind this to a key." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"newst-reader" '("newsticker-")))
 
@@ -22621,16 +21958,12 @@ Start reading news.  You may want to bind this to a 
key.
 Check whether newsticker's actual ticker is running.
 Return t if ticker is running, nil otherwise.  Newsticker is
 considered to be running if the newsticker timer list is not
-empty.
-
-\(fn)" nil nil)
+empty." nil nil)
 
 (autoload 'newsticker-start-ticker "newst-ticker" "\
 Start newsticker's ticker (but not the news retrieval).
 Start display timer for the actual ticker if wanted and not
-running already.
-
-\(fn)" t nil)
+running already." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"newst-ticker" '("newsticker-")))
 
@@ -22641,9 +21974,7 @@ running already.
 ;;; Generated autoloads from net/newst-treeview.el
 
 (autoload 'newsticker-treeview "newst-treeview" "\
-Start newsticker treeview.
-
-\(fn)" t nil)
+Start newsticker treeview." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"newst-treeview" '("newsticker-")))
 
@@ -22724,9 +22055,7 @@ symbol in the alist.
 
 (autoload 'nnfolder-generate-active-file "nnfolder" "\
 Look for mbox folders in the nnfolder directory and make them into groups.
-This command does not work if you use short group names.
-
-\(fn)" t nil)
+This command does not work if you use short group names." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"nnfolder" '("nnfolder-")))
 
@@ -23472,9 +22801,7 @@ Many aspects this mode can be customized using
  (add-to-list 'auto-mode-alist '("\\.m\\'" . octave-maybe-mode))
 
 (autoload 'octave-maybe-mode "octave" "\
-Select `octave-mode' if the current buffer seems to hold Octave code.
-
-\(fn)" nil nil)
+Select `octave-mode' if the current buffer seems to hold Octave code." nil nil)
 
 (autoload 'octave-mode "octave" "\
 Major mode for editing Octave code.
@@ -23584,14 +22911,10 @@ FULL is given.
 \(fn &optional HERE FULL MESSAGE)" t nil)
 
 (autoload 'turn-on-orgtbl "org" "\
-Unconditionally turn on `orgtbl-mode'.
-
-\(fn)" nil nil)
+Unconditionally turn on `orgtbl-mode'." nil nil)
 
 (autoload 'org-clock-persistence-insinuate "org" "\
-Set up hooks for clock persistence.
-
-\(fn)" nil nil)
+Set up hooks for clock persistence." nil nil)
 
 (autoload 'org-mode "org" "\
 Outline-based notes management and organizer, alias
@@ -23689,14 +23012,10 @@ if ARG is `toggle'; disable the mode otherwise.
 \(fn &optional ARG)" t nil)
 
 (autoload 'turn-on-orgstruct "org" "\
-Unconditionally turn on `orgstruct-mode'.
-
-\(fn)" nil nil)
+Unconditionally turn on `orgstruct-mode'." nil nil)
 
 (autoload 'turn-on-orgstruct++ "org" "\
-Unconditionally turn on `orgstruct++-mode'.
-
-\(fn)" nil nil)
+Unconditionally turn on `orgstruct++-mode'." nil nil)
 
 (autoload 'org-run-like-in-org-mode "org" "\
 Run a command, pretending that the current buffer is in Org mode.
@@ -23726,18 +23045,14 @@ active region.
 
 (autoload 'org-insert-link-global "org" "\
 Insert a link like Org mode does.
-This command can be called in any mode to insert a link in Org syntax.
-
-\(fn)" t nil)
+This command can be called in any mode to insert a link in Org syntax." t nil)
 
 (autoload 'org-open-at-point-global "org" "\
 Follow a link or time-stamp like Org mode does.
 This command can be called in any mode to follow an external link
 or a time-stamp that has Org mode syntax.  Its behavior is
 undefined when called on internal links (e.g., fuzzy links).
-Raise an error when there is nothing to follow.  
-
-\(fn)" t nil)
+Raise an error when there is nothing to follow.  " t nil)
 
 (autoload 'org-open-link-from-string "org" "\
 Open a link in the string S, as if it was in Org mode.
@@ -23756,9 +23071,7 @@ With `\\[universal-argument] \\[universal-argument]' 
prefix, restrict available
 (autoload 'org-cycle-agenda-files "org" "\
 Cycle through the files in `org-agenda-files'.
 If the current buffer visits an agenda file, find the next one in the list.
-If the current buffer does not, find the first agenda file.
-
-\(fn)" t nil)
+If the current buffer does not, find the first agenda file." t nil)
 
 (autoload 'org-submit-bug-report "org" "\
 Submit a bug report on Org via mail.
@@ -23767,9 +23080,7 @@ Don't hesitate to report any problems or inaccurate 
documentation.
 
 If you don't have setup sending mail from (X)Emacs, please copy the
 output buffer into your mail program, as it gives us important
-information about your Org version and configuration.
-
-\(fn)" t nil)
+information about your Org version and configuration." t nil)
 
 (autoload 'org-reload "org" "\
 Reload all Org Lisp files.
@@ -23778,9 +23089,7 @@ With prefix arg UNCOMPILED, load the uncompiled 
versions.
 \(fn &optional UNCOMPILED)" t nil)
 
 (autoload 'org-customize "org" "\
-Call the customize function with org as argument.
-
-\(fn)" t nil)
+Call the customize function with org as argument." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"org" '("org" "turn-on-org-cdlatex")))
 
@@ -24018,9 +23327,7 @@ in the file.  Otherwise, restriction will be to the 
current subtree.
 
 (autoload 'org-calendar-goto-agenda "org-agenda" "\
 Compute the Org agenda for the calendar date displayed at the cursor.
-This is a command that has to be installed in `calendar-mode-map'.
-
-\(fn)" t nil)
+This is a command that has to be installed in `calendar-mode-map'." t nil)
 
 (autoload 'org-agenda-to-appt "org-agenda" "\
 Activate appointments found in `org-agenda-files'.
@@ -24132,9 +23439,7 @@ of the day at point (if any) or the current HH:MM time.
 \(fn &optional GOTO KEYS)" t nil)
 
 (autoload 'org-capture-import-remember-templates "org-capture" "\
-Set `org-capture-templates' to be similar to `org-remember-templates'.
-
-\(fn)" t nil)
+Set `org-capture-templates' to be similar to `org-remember-templates'." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"org-capture" '("org-")))
 
@@ -24152,14 +23457,9 @@ Set `org-capture-templates' to be similar to 
`org-remember-templates'.
 ;;; Generated autoloads from org/org-colview.el
 
 (autoload 'org-columns-remove-overlays "org-colview" "\
-Remove all currently active column overlays.
-
-\(fn)" t nil)
-
-(autoload 'org-columns-get-format-and-top-level "org-colview" "\
+Remove all currently active column overlays." t nil)
 
-
-\(fn)" nil nil)
+(autoload 'org-columns-get-format-and-top-level "org-colview" nil nil nil)
 
 (autoload 'org-columns "org-colview" "\
 Turn on column view on an Org mode file.
@@ -24205,14 +23505,10 @@ PARAMS is a property list of parameters:
 \(fn PARAMS)" nil nil)
 
 (autoload 'org-columns-insert-dblock "org-colview" "\
-Create a dynamic block capturing a column view table.
-
-\(fn)" t nil)
+Create a dynamic block capturing a column view table." t nil)
 
 (autoload 'org-agenda-columns "org-colview" "\
-Turn on or update column view in the agenda.
-
-\(fn)" t nil)
+Turn on or update column view in the agenda." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"org-colview" '("org-")))
 
@@ -24222,9 +23518,7 @@ Turn on or update column view in the agenda.
 ;;; Generated autoloads from org/org-compat.el
 
 (autoload 'org-check-version "org-compat" "\
-Try very hard to provide sensible version strings.
-
-\(fn)" nil t)
+Try very hard to provide sensible version strings." nil t)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"org-compat" '("org-")))
 
@@ -24264,9 +23558,7 @@ Try very hard to provide sensible version strings.
 ;;; Generated autoloads from org/org-duration.el
 
 (autoload 'org-duration-set-regexps "org-duration" "\
-Set duration related regexps.
-
-\(fn)" t nil)
+Set duration related regexps." t nil)
 
 (autoload 'org-duration-p "org-duration" "\
 Non-nil when string S is a time duration.
@@ -24547,15 +23839,11 @@ Load FILE with optional arguments NOERROR and 
MUSTSUFFIX.
 
 (autoload 'org-release "org-version" "\
 The release version of Org.
-Inserted by installing Org mode or when a release is made.
-
-\(fn)" nil nil)
+Inserted by installing Org mode or when a release is made." nil nil)
 
 (autoload 'org-git-version "org-version" "\
 The Git version of Org mode.
-Inserted by installing Org or when a release is made.
-
-\(fn)" nil nil)
+Inserted by installing Org or when a release is made." nil nil)
 
 ;;;***
 
@@ -24751,9 +24039,7 @@ that code in the early init-file.
 
 (autoload 'package-activate-all "package" "\
 Activate all installed packages.
-The variable `package-load-list' controls which packages to load.
-
-\(fn)" nil nil)
+The variable `package-load-list' controls which packages to load." nil nil)
 
 (autoload 'package-import-keyring "package" "\
 Import keys from FILE.
@@ -24793,9 +24079,7 @@ Specially, if current buffer is a directory, the -pkg.el
 description file is not mandatory, in which case the information
 is derived from the main .el file in the directory.
 
-Downloads and installs required packages as needed.
-
-\(fn)" t nil)
+Downloads and installs required packages as needed." t nil)
 
 (autoload 'package-install-file "package" "\
 Install a package from a file.
@@ -24806,9 +24090,7 @@ directory.
 
 (autoload 'package-install-selected-packages "package" "\
 Ensure packages in `package-selected-packages' are installed.
-If some packages are not installed propose to install them.
-
-\(fn)" t nil)
+If some packages are not installed propose to install them." t nil)
 
 (autoload 'package-reinstall "package" "\
 Reinstall package PKG.
@@ -24822,9 +24104,7 @@ Remove packages that are no more needed.
 
 Packages that are no more needed by other packages in
 `package-selected-packages' and their dependencies
-will be deleted.
-
-\(fn)" t nil)
+will be deleted." t nil)
 
 (autoload 'describe-package "package" "\
 Display the full documentation of PACKAGE (a symbol).
@@ -24847,9 +24127,7 @@ short description.
 Return the version number of the package in which this is used.
 Assumes it is used from an Elisp file placed inside the top-level directory
 of an installed ELPA package.
-The return value is a string (or nil in case we can't find it).
-
-\(fn)" nil nil)
+The return value is a string (or nil in case we can't find it)." nil nil)
 
 (function-put 'package-get-version 'pure 't)
 
@@ -24910,7 +24188,7 @@ matching parenthesis is highlighted in 
`show-paren-style' after
 
 (autoload 'parse-time-string "parse-time" "\
 Parse the time-string STRING into (SEC MIN HOUR DAY MON YEAR DOW DST TZ).
-STRING should be on something resembling an RFC2822 string, a la
+STRING should be something resembling an RFC 822 (or later) date-time, e.g.,
 \"Fri, 25 Mar 2016 16:24:56 +0100\", but this function is
 somewhat liberal in what format it accepts, and will attempt to
 return a \"likely\" value even for somewhat malformed strings.
@@ -25046,6 +24324,10 @@ Emacs Lisp manual for more information and examples.
 
 (function-put 'pcase 'lisp-indent-function '1)
 
+(put 'pcase 'function-documentation '(pcase--make-docstring))
+
+(autoload 'pcase--make-docstring "pcase" nil nil nil)
+
 (autoload 'pcase-exhaustive "pcase" "\
 The exhaustive version of `pcase' (which see).
 If EXP fails to match any of the patterns in CASES, an error is signaled.
@@ -25133,9 +24415,7 @@ for the result of evaluating EXP (first arg to `pcase').
 ;;; Generated autoloads from pcmpl-cvs.el
 
 (autoload 'pcomplete/cvs "pcmpl-cvs" "\
-Completion rules for the `cvs' command.
-
-\(fn)" nil nil)
+Completion rules for the `cvs' command." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"pcmpl-cvs" '("pcmpl-cvs-")))
 
@@ -25145,29 +24425,19 @@ Completion rules for the `cvs' command.
 ;;; Generated autoloads from pcmpl-gnu.el
 
 (autoload 'pcomplete/gzip "pcmpl-gnu" "\
-Completion for `gzip'.
-
-\(fn)" nil nil)
+Completion for `gzip'." nil nil)
 
 (autoload 'pcomplete/bzip2 "pcmpl-gnu" "\
-Completion for `bzip2'.
-
-\(fn)" nil nil)
+Completion for `bzip2'." nil nil)
 
 (autoload 'pcomplete/make "pcmpl-gnu" "\
-Completion for GNU `make'.
-
-\(fn)" nil nil)
+Completion for GNU `make'." nil nil)
 
 (autoload 'pcomplete/tar "pcmpl-gnu" "\
-Completion for the GNU tar utility.
-
-\(fn)" nil nil)
+Completion for the GNU tar utility." nil nil)
 
 (autoload 'pcomplete/find "pcmpl-gnu" "\
-Completion for the GNU find utility.
-
-\(fn)" nil nil)
+Completion for the GNU find utility." nil nil)
 
 (defalias 'pcomplete/gdb 'pcomplete/xargs)
 
@@ -25179,19 +24449,13 @@ Completion for the GNU find utility.
 ;;; Generated autoloads from pcmpl-linux.el
 
 (autoload 'pcomplete/kill "pcmpl-linux" "\
-Completion for GNU/Linux `kill', using /proc filesystem.
-
-\(fn)" nil nil)
+Completion for GNU/Linux `kill', using /proc filesystem." nil nil)
 
 (autoload 'pcomplete/umount "pcmpl-linux" "\
-Completion for GNU/Linux `umount'.
-
-\(fn)" nil nil)
+Completion for GNU/Linux `umount'." nil nil)
 
 (autoload 'pcomplete/mount "pcmpl-linux" "\
-Completion for GNU/Linux `mount'.
-
-\(fn)" nil nil)
+Completion for GNU/Linux `mount'." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"pcmpl-linux" '("pcmpl-linux-" "pcomplete-pare-list")))
 
@@ -25201,9 +24465,7 @@ Completion for GNU/Linux `mount'.
 ;;; Generated autoloads from pcmpl-rpm.el
 
 (autoload 'pcomplete/rpm "pcmpl-rpm" "\
-Completion for the `rpm' command.
-
-\(fn)" nil nil)
+Completion for the `rpm' command." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"pcmpl-rpm" '("pcmpl-rpm-")))
 
@@ -25213,54 +24475,36 @@ Completion for the `rpm' command.
 ;;; Generated autoloads from pcmpl-unix.el
 
 (autoload 'pcomplete/cd "pcmpl-unix" "\
-Completion for `cd'.
-
-\(fn)" nil nil)
+Completion for `cd'." nil nil)
 
 (defalias 'pcomplete/pushd 'pcomplete/cd)
 
 (autoload 'pcomplete/rmdir "pcmpl-unix" "\
-Completion for `rmdir'.
-
-\(fn)" nil nil)
+Completion for `rmdir'." nil nil)
 
 (autoload 'pcomplete/rm "pcmpl-unix" "\
-Completion for `rm'.
-
-\(fn)" nil nil)
+Completion for `rm'." nil nil)
 
 (autoload 'pcomplete/xargs "pcmpl-unix" "\
-Completion for `xargs'.
-
-\(fn)" nil nil)
+Completion for `xargs'." nil nil)
 
 (defalias 'pcomplete/time 'pcomplete/xargs)
 
 (autoload 'pcomplete/which "pcmpl-unix" "\
-Completion for `which'.
-
-\(fn)" nil nil)
+Completion for `which'." nil nil)
 
 (autoload 'pcomplete/chown "pcmpl-unix" "\
-Completion for the `chown' command.
-
-\(fn)" nil nil)
+Completion for the `chown' command." nil nil)
 
 (autoload 'pcomplete/chgrp "pcmpl-unix" "\
-Completion for the `chgrp' command.
-
-\(fn)" nil nil)
+Completion for the `chgrp' command." nil nil)
 
 (autoload 'pcomplete/ssh "pcmpl-unix" "\
-Completion rules for the `ssh' command.
-
-\(fn)" nil nil)
+Completion rules for the `ssh' command." nil nil)
 
 (autoload 'pcomplete/scp "pcmpl-unix" "\
 Completion rules for the `scp' command.
-Includes files as well as host names followed by a colon.
-
-\(fn)" nil nil)
+Includes files as well as host names followed by a colon." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"pcmpl-unix" '("pcmpl-")))
 
@@ -25270,23 +24514,17 @@ Includes files as well as host names followed by a 
colon.
 ;;; Generated autoloads from pcmpl-x.el
 
 (autoload 'pcomplete/tlmgr "pcmpl-x" "\
-Completion for the `tlmgr' command.
-
-\(fn)" nil nil)
+Completion for the `tlmgr' command." nil nil)
 
 (autoload 'pcomplete/ack "pcmpl-x" "\
 Completion for the `ack' command.
 Start an argument with `-' to complete short options and `--' for
-long options.
-
-\(fn)" nil nil)
+long options." nil nil)
 
 (defalias 'pcomplete/ack-grep 'pcomplete/ack)
 
 (autoload 'pcomplete/ag "pcmpl-x" "\
-Completion for the `ag' command.
-
-\(fn)" nil nil)
+Completion for the `ag' command." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"pcmpl-x" '("pcmpl-x-")))
 
@@ -25303,36 +24541,24 @@ completion functions list (it should occur fairly 
early in the list).
 \(fn &optional INTERACTIVELY)" t nil)
 
 (autoload 'pcomplete-reverse "pcomplete" "\
-If cycling completion is in use, cycle backwards.
-
-\(fn)" t nil)
+If cycling completion is in use, cycle backwards." t nil)
 
 (autoload 'pcomplete-expand-and-complete "pcomplete" "\
 Expand the textual value of the current argument.
-This will modify the current buffer.
-
-\(fn)" t nil)
+This will modify the current buffer." t nil)
 
 (autoload 'pcomplete-continue "pcomplete" "\
-Complete without reference to any cycling completions.
-
-\(fn)" t nil)
+Complete without reference to any cycling completions." t nil)
 
 (autoload 'pcomplete-expand "pcomplete" "\
 Expand the textual value of the current argument.
-This will modify the current buffer.
-
-\(fn)" t nil)
+This will modify the current buffer." t nil)
 
 (autoload 'pcomplete-help "pcomplete" "\
-Display any help information relative to the current argument.
-
-\(fn)" t nil)
+Display any help information relative to the current argument." t nil)
 
 (autoload 'pcomplete-list "pcomplete" "\
-Show the list of possible completions for the current argument.
-
-\(fn)" t nil)
+Show the list of possible completions for the current argument." t nil)
 
 (autoload 'pcomplete-comint-setup "pcomplete" "\
 Setup a comint buffer to use pcomplete.
@@ -25343,9 +24569,7 @@ this is `comint-dynamic-complete-functions'.
 \(fn COMPLETEF-SYM)" nil nil)
 
 (autoload 'pcomplete-shell-setup "pcomplete" "\
-Setup `shell-mode' to use pcomplete.
-
-\(fn)" nil nil)
+Setup `shell-mode' to use pcomplete." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"pcomplete" '("pcomplete-")))
 
@@ -25603,9 +24827,7 @@ by supplying an argument.
 Entry to this mode calls the value of `picture-mode-hook' if non-nil.
 
 Note that Picture mode commands will work outside of Picture mode, but
-they are not by default assigned to keys.
-
-\(fn)" t nil)
+they are not by default assigned to keys." t nil)
 
 (defalias 'edit-picture 'picture-mode)
 
@@ -25613,6 +24835,13 @@ they are not by default assigned to keys.
 
 ;;;***
 
+;;;### (autoloads nil "pinyin" "language/pinyin.el" (0 0 0 0))
+;;; Generated autoloads from language/pinyin.el
+
+(if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"pinyin" '("pinyin-character-map")))
+
+;;;***
+
 ;;;### (autoloads nil "pixel-scroll" "pixel-scroll.el" (0 0 0 0))
 ;;; Generated autoloads from pixel-scroll.el
 
@@ -25680,9 +24909,7 @@ Move left and right bats and try to bounce the ball to 
your opponent.
 
 pong-mode keybindings:\\<pong-mode-map>
 
-\\{pong-mode-map}
-
-\(fn)" t nil)
+\\{pong-mode-map}" t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"pong" '("pong-")))
 
@@ -25712,9 +24939,7 @@ to make output that `read' can handle, whenever this is 
possible.
 \(fn OBJECT)" nil nil)
 
 (autoload 'pp-buffer "pp" "\
-Prettify the current buffer with printed representation of a Lisp object.
-
-\(fn)" nil nil)
+Prettify the current buffer with printed representation of a Lisp object." nil 
nil)
 
 (autoload 'pp "pp" "\
 Output the pretty-printed representation of OBJECT, any Lisp object.
@@ -25976,16 +25201,12 @@ See also documentation for `pr-list-directory'.
 (autoload 'pr-printify-buffer "printing" "\
 Replace nonprinting characters in buffer with printable representations.
 The printable representations use ^ (for ASCII control characters) or hex.
-The characters tab, linefeed, space, return and formfeed are not affected.
-
-\(fn)" t nil)
+The characters tab, linefeed, space, return and formfeed are not affected." t 
nil)
 
 (autoload 'pr-printify-region "printing" "\
 Replace nonprinting characters in region with printable representations.
 The printable representations use ^ (for ASCII control characters) or hex.
-The characters tab, linefeed, space, return and formfeed are not affected.
-
-\(fn)" t nil)
+The characters tab, linefeed, space, return and formfeed are not affected." t 
nil)
 
 (autoload 'pr-txt-directory "printing" "\
 Print directory using text printer.
@@ -26001,19 +25222,13 @@ See also documentation for `pr-list-directory'.
 \(fn &optional DIR FILE-REGEXP)" t nil)
 
 (autoload 'pr-txt-buffer "printing" "\
-Print buffer using text printer.
-
-\(fn)" t nil)
+Print buffer using text printer." t nil)
 
 (autoload 'pr-txt-region "printing" "\
-Print region using text printer.
-
-\(fn)" t nil)
+Print region using text printer." t nil)
 
 (autoload 'pr-txt-mode "printing" "\
-Print major mode using text printer.
-
-\(fn)" t nil)
+Print major mode using text printer." t nil)
 
 (autoload 'pr-despool-preview "printing" "\
 Preview spooled PostScript.
@@ -26111,9 +25326,7 @@ file name.
 \(fn N-UP IFILENAME &optional OFILENAME)" t nil)
 
 (autoload 'pr-toggle-file-duplex "printing" "\
-Toggle duplex for PostScript file.
-
-\(fn)" t nil)
+Toggle duplex for PostScript file." t nil)
 
 (autoload 'pr-toggle-file-tumble "printing" "\
 Toggle tumble for PostScript file.
@@ -26121,34 +25334,22 @@ Toggle tumble for PostScript file.
 If tumble is off, produces a printing suitable for binding on the left or
 right.
 If tumble is on, produces a printing suitable for binding at the top or
-bottom.
-
-\(fn)" t nil)
+bottom." t nil)
 
 (autoload 'pr-toggle-file-landscape "printing" "\
-Toggle landscape for PostScript file.
-
-\(fn)" t nil)
+Toggle landscape for PostScript file." t nil)
 
 (autoload 'pr-toggle-ghostscript "printing" "\
-Toggle printing using ghostscript.
-
-\(fn)" t nil)
+Toggle printing using ghostscript." t nil)
 
 (autoload 'pr-toggle-faces "printing" "\
-Toggle printing with faces.
-
-\(fn)" t nil)
+Toggle printing with faces." t nil)
 
 (autoload 'pr-toggle-spool "printing" "\
-Toggle spooling.
-
-\(fn)" t nil)
+Toggle spooling." t nil)
 
 (autoload 'pr-toggle-duplex "printing" "\
-Toggle duplex.
-
-\(fn)" t nil)
+Toggle duplex." t nil)
 
 (autoload 'pr-toggle-tumble "printing" "\
 Toggle tumble.
@@ -26156,54 +25357,34 @@ Toggle tumble.
 If tumble is off, produces a printing suitable for binding on the left or
 right.
 If tumble is on, produces a printing suitable for binding at the top or
-bottom.
-
-\(fn)" t nil)
+bottom." t nil)
 
 (autoload 'pr-toggle-landscape "printing" "\
-Toggle landscape.
-
-\(fn)" t nil)
+Toggle landscape." t nil)
 
 (autoload 'pr-toggle-upside-down "printing" "\
-Toggle upside-down.
-
-\(fn)" t nil)
+Toggle upside-down." t nil)
 
 (autoload 'pr-toggle-line "printing" "\
-Toggle line number.
-
-\(fn)" t nil)
+Toggle line number." t nil)
 
 (autoload 'pr-toggle-zebra "printing" "\
-Toggle zebra stripes.
-
-\(fn)" t nil)
+Toggle zebra stripes." t nil)
 
 (autoload 'pr-toggle-header "printing" "\
-Toggle printing header.
-
-\(fn)" t nil)
+Toggle printing header." t nil)
 
 (autoload 'pr-toggle-header-frame "printing" "\
-Toggle printing header frame.
-
-\(fn)" t nil)
+Toggle printing header frame." t nil)
 
 (autoload 'pr-toggle-lock "printing" "\
-Toggle menu lock.
-
-\(fn)" t nil)
+Toggle menu lock." t nil)
 
 (autoload 'pr-toggle-region "printing" "\
-Toggle whether the region is automagically detected.
-
-\(fn)" t nil)
+Toggle whether the region is automagically detected." t nil)
 
 (autoload 'pr-toggle-mode "printing" "\
-Toggle auto mode.
-
-\(fn)" t nil)
+Toggle auto mode." t nil)
 
 (autoload 'pr-customize "printing" "\
 Customization of the `printing' group.
@@ -26221,19 +25402,13 @@ Help for the printing package.
 \(fn &rest IGNORE)" t nil)
 
 (autoload 'pr-ps-name "printing" "\
-Interactively select a PostScript printer.
-
-\(fn)" t nil)
+Interactively select a PostScript printer." t nil)
 
 (autoload 'pr-txt-name "printing" "\
-Interactively select a text printer.
-
-\(fn)" t nil)
+Interactively select a text printer." t nil)
 
 (autoload 'pr-ps-utility "printing" "\
-Interactively select a PostScript utility.
-
-\(fn)" t nil)
+Interactively select a PostScript utility." t nil)
 
 (autoload 'pr-show-ps-setup "printing" "\
 Show current ps-print settings.
@@ -26426,28 +25601,24 @@ pattern to search for.
 (autoload 'project-find-file "project" "\
 Visit a file (with completion) in the current project's roots.
 The completion default is the filename at point, if one is
-recognized.
-
-\(fn)" t nil)
+recognized." t nil)
 
 (autoload 'project-or-external-find-file "project" "\
 Visit a file (with completion) in the current project's roots or external 
roots.
 The completion default is the filename at point, if one is
-recognized.
-
-\(fn)" t nil)
+recognized." t nil)
 
 (autoload 'project-search "project" "\
 Search for REGEXP in all the files of the project.
 Stops when a match is found.
-To continue searching for next match, use command \\[multifile-continue].
+To continue searching for next match, use command \\[fileloop-continue].
 
 \(fn REGEXP)" t nil)
 
-(autoload 'project-query-replace "project" "\
+(autoload 'project-query-replace-regexp "project" "\
 Search for REGEXP in all the files of the project.
 Stops when a match is found.
-To continue searching for next match, use command \\[multifile-continue].
+To continue searching for next match, use command \\[fileloop-continue].
 
 \(fn FROM TO)" t nil)
 
@@ -26593,9 +25764,7 @@ Any other value is treated as t.")
 (custom-autoload 'ps-print-color-p "ps-print" t)
 
 (autoload 'ps-print-customize "ps-print" "\
-Customization of ps-print group.
-
-\(fn)" t nil)
+Customization of ps-print group." t nil)
 
 (autoload 'ps-print-buffer "ps-print" "\
 Generate and print a PostScript image of the buffer.
@@ -26637,9 +25806,7 @@ Generate and spool a PostScript image of the buffer.
 Like `ps-print-buffer' except that the PostScript image is saved in a local
 buffer to be sent to the printer later.
 
-Use the command `ps-despool' to send the spooled images to the printer.
-
-\(fn)" t nil)
+Use the command `ps-despool' to send the spooled images to the printer." t nil)
 
 (autoload 'ps-spool-buffer-with-faces "ps-print" "\
 Generate and spool a PostScript image of the buffer.
@@ -26647,9 +25814,7 @@ Like the command `ps-spool-buffer', but includes font, 
color, and underline
 information in the generated image.  This command works only if you are using
 a window system, so it has a way to determine color values.
 
-Use the command `ps-despool' to send the spooled images to the printer.
-
-\(fn)" t nil)
+Use the command `ps-despool' to send the spooled images to the printer." t nil)
 
 (autoload 'ps-spool-region "ps-print" "\
 Generate a PostScript image of the region and spool locally.
@@ -26686,9 +25851,7 @@ image in a file with that name.
 Display the correspondence between a line length and a font size.
 Done using the current ps-print setup.
 Try: pr -t file | awk \\='{printf \"%3d %s
-\", length($0), $0}\\=' | sort -r | head
-
-\(fn)" t nil)
+\", length($0), $0}\\=' | sort -r | head" t nil)
 
 (autoload 'ps-nb-pages-buffer "ps-print" "\
 Display number of pages to print this buffer, for various font heights.
@@ -26703,9 +25866,7 @@ The table depends on the current ps-print setup.
 \(fn NB-LINES)" t nil)
 
 (autoload 'ps-setup "ps-print" "\
-Return the current PostScript-generation setup.
-
-\(fn)" nil nil)
+Return the current PostScript-generation setup." nil nil)
 
 (autoload 'ps-extend-face-list "ps-print" "\
 Extend face in ALIST-SYM.
@@ -26856,9 +26017,7 @@ them into characters should be done separately.
 ;;; Generated autoloads from international/quail.el
 
 (autoload 'quail-title "quail" "\
-Return the title of the current Quail package.
-
-\(fn)" nil nil)
+Return the title of the current Quail package." nil nil)
 
 (autoload 'quail-use-package "quail" "\
 Start using Quail package PACKAGE-NAME.
@@ -27242,9 +26401,7 @@ Browse the URL, with `completing-read' prompt, 
associated with LOOKUP.
 \(fn LOOKUP)" t nil)
 
 (autoload 'quickurl-edit-urls "quickurl" "\
-Pull `quickurl-url-file' into a buffer for hand editing.
-
-\(fn)" t nil)
+Pull `quickurl-url-file' into a buffer for hand editing." t nil)
 
 (autoload 'quickurl-list-mode "quickurl" "\
 A mode for browsing the quickurl URL list.
@@ -27256,9 +26413,7 @@ The key bindings for `quickurl-list-mode' are:
 \(fn)" t nil)
 
 (autoload 'quickurl-list "quickurl" "\
-Display `quickurl-list' as a formatted list using `quickurl-list-mode'.
-
-\(fn)" t nil)
+Display `quickurl-list' as a formatted list using `quickurl-list-mode'." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"quickurl" '("quickurl-")))
 
@@ -27328,9 +26483,7 @@ the regexp builder.  It displays a buffer named 
\"*RE-Builder*\"
 in another window, initially containing an empty regexp.
 
 As you edit the regexp in the \"*RE-Builder*\" buffer, the
-matching parts of the target buffer will be highlighted.
-
-\(fn)" t nil)
+matching parts of the target buffer will be highlighted." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"re-builder" '("re-builder-unload-function" "reb-")))
 
@@ -27421,9 +26574,7 @@ Copy the region-rectangle and save it as the last 
killed one.
 \(fn START END)" t nil)
 
 (autoload 'yank-rectangle "rect" "\
-Yank the last killed rectangle with upper left corner at point.
-
-\(fn)" t nil)
+Yank the last killed rectangle with upper left corner at point." t nil)
 
 (autoload 'insert-rectangle "rect" "\
 Insert text of RECTANGLE with upper left corner at point.
@@ -27565,9 +26716,7 @@ For true \"word wrap\" behavior, use `visual-line-mode' 
instead.
 (autoload 'reftex-index-phrases-mode "reftex-index" nil t)
 
 (autoload 'turn-on-reftex "reftex" "\
-Turn on RefTeX mode.
-
-\(fn)" nil nil)
+Turn on RefTeX mode." nil nil)
 
 (autoload 'reftex-mode "reftex" "\
 Minor mode with distinct support for \\label, \\ref and \\cite in LaTeX.
@@ -27609,9 +26758,7 @@ on the menu bar.
 
 (autoload 'reftex-reset-scanning-information "reftex" "\
 Reset the symbols containing information from buffer scanning.
-This enforces rescanning the buffer on next use.
-
-\(fn)" nil nil)
+This enforces rescanning the buffer on next use." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"reftex" '("reftex-")))
 
@@ -27707,9 +26854,12 @@ This enforces rescanning the buffer on next use.
 
 (autoload 'regexp-opt "regexp-opt" "\
 Return a regexp to match a string in the list STRINGS.
-Each string should be unique in STRINGS and should not contain
-any regexps, quoted or not.  Optional PAREN specifies how the
-returned regexp is surrounded by grouping constructs.
+Each member of STRINGS is treated as a fixed string, not as a regexp.
+Optional PAREN specifies how the returned regexp is surrounded by
+grouping constructs.
+
+If STRINGS is the empty list, the return value is a regexp that
+never matches anything.
 
 The optional argument PAREN can be any of the following:
 
@@ -27732,8 +26882,14 @@ nil
     necessary to ensure that a postfix operator appended to it will
     apply to the whole expression.
 
-The resulting regexp is equivalent to but usually more efficient
-than that of a simplified version:
+The optional argument KEEP-ORDER, if nil or omitted, allows the
+returned regexp to match the strings in any order.  If non-nil,
+the match is guaranteed to be performed in the order given, as if
+the strings were made into a regexp by joining them with the
+`\\|' operator.
+
+Up to reordering, the resulting regexp is equivalent to but
+usually more efficient than that of a simplified version:
 
  (defun simplified-regexp-opt (strings &optional paren)
    (let ((parens
@@ -27742,11 +26898,11 @@ than that of a simplified version:
                 ((eq paren \\='symbols) \\='(\"\\\\_<\\\\(\" . 
\"\\\\)\\\\_>\"))
                 ((null paren)          \\='(\"\\\\(?:\" . \"\\\\)\"))
                 (t                       \\='(\"\\\\(\" . \"\\\\)\")))))
-     (concat (car paren)
+     (concat (car parens)
              (mapconcat \\='regexp-quote strings \"\\\\|\")
-             (cdr paren))))
+             (cdr parens))))
 
-\(fn STRINGS &optional PAREN)" nil nil)
+\(fn STRINGS &optional PAREN KEEP-ORDER)" nil nil)
 
 (autoload 'regexp-opt-depth "regexp-opt" "\
 Return the depth of REGEXP.
@@ -27794,14 +26950,10 @@ Call `remember' in another frame.
 
 (autoload 'remember-clipboard "remember" "\
 Remember the contents of the current clipboard.
-Most useful for remembering things from other applications.
-
-\(fn)" t nil)
+Most useful for remembering things from other applications." t nil)
 
 (autoload 'remember-diary-extract-entries "remember" "\
-Extract diary entries from the region.
-
-\(fn)" nil nil)
+Extract diary entries from the region." nil nil)
 
 (autoload 'remember-notes "remember" "\
 Return the notes buffer, creating it if needed, and maybe switch to it.
@@ -28251,9 +27403,7 @@ Instead, these commands are available:
 \\[rmail-summary-by-recipients]   Summarize only messages with particular 
recipient(s).
 \\[rmail-summary-by-regexp]   Summarize only messages with particular 
regexp(s).
 \\[rmail-summary-by-topic]   Summarize only messages with subject line 
regexp(s).
-\\[rmail-toggle-header]        Toggle display of complete header.
-
-\(fn)" t nil)
+\\[rmail-toggle-header]        Toggle display of complete header." t nil)
 
 (autoload 'rmail-input "rmail" "\
 Run Rmail on file FILENAME.
@@ -28476,9 +27626,7 @@ Return a pattern.
 (autoload 'rng-nxml-mode-init "rng-nxml" "\
 Initialize `nxml-mode' to take advantage of `rng-validate-mode'.
 This is typically called from `nxml-mode-hook'.
-Validation will be enabled if `rng-nxml-auto-validate-flag' is non-nil.
-
-\(fn)" t nil)
+Validation will be enabled if `rng-nxml-auto-validate-flag' is non-nil." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"rng-nxml" '("rng-")))
 
@@ -28636,14 +27784,10 @@ To terminate the ROT13 display, delete that window.  
As long as that window
 is not deleted, any buffer displayed in it will become instantly encoded
 in ROT13.
 
-See also `toggle-rot13-mode'.
-
-\(fn)" t nil)
+See also `toggle-rot13-mode'." t nil)
 
 (autoload 'toggle-rot13-mode "rot13" "\
-Toggle the use of ROT13 encoding for the current window.
-
-\(fn)" t nil)
+Toggle the use of ROT13 encoding for the current window." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"rot13" '("rot13-")))
 
@@ -28769,6 +27913,7 @@ CHAR
      matches any character in SET ....  SET may be a character or string.
      Ranges of characters can be specified as `A-Z' in strings.
      Ranges may also be specified as conses like `(?A . ?Z)'.
+     Reversed ranges like `Z-A' and `(?Z . ?A)' are not permitted.
 
      SET may also be the name of a character class: `digit',
      `control', `hex-digit', `blank', `graph', `print', `alnum',
@@ -28829,7 +27974,7 @@ CHAR
      matches 0 through 9.
 
 `control', `cntrl'
-     matches ASCII control characters.
+     matches any character whose code is in the range 0-31.
 
 `hex-digit', `hex', `xdigit'
      matches 0 through 9, a through f and A through F.
@@ -28916,7 +28061,9 @@ CHAR
      matches a character with category CATEGORY.  CATEGORY must be
      either a character to use for C, or one of the following symbols.
 
-     `consonant'                       (\\c0 in string notation)
+     `space-for-indent'                 (\\c\\s in string notation)
+     `base'                             (\\c.)
+     `consonant'                       (\\c0)
      `base-vowel'                      (\\c1)
      `upper-diacritical-mark'          (\\c2)
      `lower-diacritical-mark'          (\\c3)
@@ -28934,7 +28081,9 @@ CHAR
      `japanese-hiragana-two-byte'      (\\cH)
      `indian-two-byte'                 (\\cI)
      `japanese-katakana-two-byte'      (\\cK)
+     `strong-left-to-right'             (\\cL)
      `korean-hangul-two-byte'          (\\cN)
+     `strong-right-to-left'             (\\cR)
      `cyrillic-two-byte'               (\\cY)
      `combining-diacritic'             (\\c^)
      `ascii'                           (\\ca)
@@ -30032,7 +29181,7 @@ Otherwise, let mailer send back a message to report 
errors.")
 (defvar send-mail-function (if (and (boundp 'smtpmail-smtp-server) 
smtpmail-smtp-server) 'smtpmail-send-it 'sendmail-query-once) "\
 Function to call to send the current buffer as mail.
 The headers should be delimited by a line which is
-not a valid RFC822 header or continuation line,
+not a valid RFC 822 (or later) header or continuation line,
 that matches the variable `mail-header-separator'.
 This is used by the default mail-sending commands.  See also
 `message-send-mail-function' for use with the Message package.")
@@ -30146,9 +29295,7 @@ before you edit the message, so you can edit or delete 
the lines.")
 
 (autoload 'sendmail-query-once "sendmail" "\
 Query for `send-mail-function' and send mail with it.
-This also saves the value of `send-mail-function' via Customize.
-
-\(fn)" nil nil)
+This also saves the value of `send-mail-function' via Customize." nil nil)
 
 (define-mail-user-agent 'sendmail-user-agent 'sendmail-user-agent-compose 
'mail-send-and-exit)
 
@@ -30271,7 +29418,7 @@ Like `mail' command, but display mail buffer in another 
frame.
 
 ;;;### (autoloads nil "seq" "emacs-lisp/seq.el" (0 0 0 0))
 ;;; Generated autoloads from emacs-lisp/seq.el
-(push (purecopy '(seq 2 20)) package--builtin-versions)
+(push (purecopy '(seq 2 21)) package--builtin-versions)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"seq" '("seq-")))
 
@@ -30390,9 +29537,7 @@ part):
 \\{ses-mode-print-map}
 These are active only in the minibuffer, when entering or editing a
 formula:
-\\{ses-mode-edit-map}
-
-\(fn)" t nil)
+\\{ses-mode-edit-map}" t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"ses" '("1value" "noreturn" "ses")))
 
@@ -30602,9 +29747,7 @@ sites in the cluster.
 Declare a single file to be shared between sites.
 It may have different filenames on each site.  When this file is edited, the
 new version will be copied to each of the other locations.  Sites can be
-specific hostnames, or names of clusters (see `shadow-define-cluster').
-
-\(fn)" t nil)
+specific hostnames, or names of clusters (see `shadow-define-cluster')." t nil)
 
 (autoload 'shadow-define-regexp-group "shadowfile" "\
 Make each of a group of files be shared between hosts.
@@ -30612,14 +29755,10 @@ Prompts for regular expression; files matching this 
are shared between a list
 of sites, which are also prompted for.  The filenames must be identical on all
 hosts (if they aren't, use `shadow-define-literal-group' instead of this
 function).  Each site can be either a hostname or the name of a cluster (see
-`shadow-define-cluster').
-
-\(fn)" t nil)
+`shadow-define-cluster')." t nil)
 
 (autoload 'shadow-initialize "shadowfile" "\
-Set up file shadowing.
-
-\(fn)" t nil)
+Set up file shadowing." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"shadowfile" '("shadow")))
 
@@ -30966,9 +30105,7 @@ if ARG is `toggle'; disable the mode otherwise.
 
 (autoload 'smerge-start-session "smerge-mode" "\
 Turn on `smerge-mode' and move point to first conflict marker.
-If no conflict maker is found, turn off `smerge-mode'.
-
-\(fn)" t nil)
+If no conflict maker is found, turn off `smerge-mode'." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"smerge-mode" '("smerge-")))
 
@@ -31010,15 +30147,10 @@ interactively.  If there's no argument, do it at the 
current buffer.
 ;;;### (autoloads nil "smtpmail" "mail/smtpmail.el" (0 0 0 0))
 ;;; Generated autoloads from mail/smtpmail.el
 
-(autoload 'smtpmail-send-it "smtpmail" "\
-
-
-\(fn)" nil nil)
+(autoload 'smtpmail-send-it "smtpmail" nil nil nil)
 
 (autoload 'smtpmail-send-queued-mail "smtpmail" "\
-Send mail that was queued as a result of setting `smtpmail-queue-mail'.
-
-\(fn)" t nil)
+Send mail that was queued as a result of setting `smtpmail-queue-mail'." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"smtpmail" '("smtpmail-")))
 
@@ -31041,9 +30173,7 @@ Snake mode keybindings:
 \\[snake-move-left]    Makes the snake move left
 \\[snake-move-right]   Makes the snake move right
 \\[snake-move-up]      Makes the snake move up
-\\[snake-move-down]    Makes the snake move down
-
-\(fn)" t nil)
+\\[snake-move-down]    Makes the snake move down" t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"snake" '("snake-")))
 
@@ -31060,9 +30190,7 @@ Comments start with -- and end with newline or another 
--.
 Delete converts tabs to spaces as it moves back.
 \\{snmp-mode-map}
 Turning on snmp-mode runs the hooks in `snmp-common-mode-hook', then
-`snmp-mode-hook'.
-
-\(fn)" t nil)
+`snmp-mode-hook'." t nil)
 
 (autoload 'snmpv2-mode "snmp-mode" "\
 Major mode for editing SNMPv2 MIBs.
@@ -31072,9 +30200,7 @@ Comments start with -- and end with newline or another 
--.
 Delete converts tabs to spaces as it moves back.
 \\{snmp-mode-map}
 Turning on snmp-mode runs the hooks in `snmp-common-mode-hook',
-then `snmpv2-mode-hook'.
-
-\(fn)" t nil)
+then `snmpv2-mode-hook'." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"snmp-mode" '("snmp")))
 
@@ -31427,16 +30553,12 @@ Customize `spam-report-url-ping-function' to use this 
function.
 Add spam-report support to the Agent.
 Spam reports will be queued with \\[spam-report-url-to-file] when
 the Agent is unplugged, and will be submitted in a batch when the
-Agent is plugged.
-
-\(fn)" t nil)
+Agent is plugged." t nil)
 
 (autoload 'spam-report-deagentize "spam-report" "\
 Remove spam-report support from the Agent.
 Spam reports will be queued with the method used when
-\\[spam-report-agentize] was run.
-
-\(fn)" t nil)
+\\[spam-report-agentize] was run." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"spam-report" '("spam-report-")))
 
@@ -31474,9 +30596,7 @@ supported at a time.
 (autoload 'speedbar-get-focus "speedbar" "\
 Change frame focus to or from the speedbar frame.
 If the selected frame is not speedbar, then speedbar frame is
-selected.  If the speedbar frame is active, then select the attached frame.
-
-\(fn)" t nil)
+selected.  If the speedbar frame is active, then select the attached frame." t 
nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"speedbar" '("speedbar-")))
 
@@ -31486,14 +30606,10 @@ selected.  If the speedbar frame is active, then 
select the attached frame.
 ;;; Generated autoloads from play/spook.el
 
 (autoload 'spook "spook" "\
-Adds that special touch of class to your outgoing mail.
-
-\(fn)" t nil)
+Adds that special touch of class to your outgoing mail." t nil)
 
 (autoload 'snarf-spooks "spook" "\
-Return a vector containing the lines from `spook-phrases-file'.
-
-\(fn)" nil nil)
+Return a vector containing the lines from `spook-phrases-file'." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"spook" '("spook-phrase")))
 
@@ -31889,8 +31005,7 @@ The default comes from `process-coding-system-alist' and
 your might try undecided-dos as a coding system.  If this doesn't help,
 Try to set `comint-output-filter-functions' like this:
 
-\(setq comint-output-filter-functions (append comint-output-filter-functions
-                                            \\='(comint-strip-ctrl-m)))
+\(add-hook 'comint-output-filter-functions #\\='comint-strip-ctrl-m 'append)
 
 \(Type \\[describe-mode] in the SQL buffer for a list of commands.)
 
@@ -32243,14 +31358,10 @@ Displays the command which STROKE maps to, reading 
STROKE interactively.
 \(fn STROKE)" t nil)
 
 (autoload 'strokes-help "strokes" "\
-Get instruction on using the Strokes package.
-
-\(fn)" t nil)
+Get instruction on using the Strokes package." t nil)
 
 (autoload 'strokes-load-user-strokes "strokes" "\
-Load user-defined strokes from file named by `strokes-file'.
-
-\(fn)" t nil)
+Load user-defined strokes from file named by `strokes-file'." t nil)
 
 (autoload 'strokes-list-strokes "strokes" "\
 Pop up a buffer containing an alphabetical listing of strokes in STROKES-MAP.
@@ -32301,9 +31412,7 @@ Optional FORCE non-nil will ignore the buffer's 
read-only status.
 \(fn &optional BUFFER FORCE)" t nil)
 
 (autoload 'strokes-compose-complex-stroke "strokes" "\
-Read a complex stroke and insert its glyph into the current buffer.
-
-\(fn)" t nil)
+Read a complex stroke and insert its glyph into the current buffer." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"strokes" '("strokes-")))
 
@@ -32323,16 +31432,14 @@ Studlify-case the current word, or COUNT words if 
given an argument.
 \(fn COUNT)" t nil)
 
 (autoload 'studlify-buffer "studly" "\
-Studlify-case the current buffer.
-
-\(fn)" t nil)
+Studlify-case the current buffer." t nil)
 
 ;;;***
 
 ;;;### (autoloads nil "subr-x" "emacs-lisp/subr-x.el" (0 0 0 0))
 ;;; Generated autoloads from emacs-lisp/subr-x.el
 
-(if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"subr-x" '("and-let*" "hash-table-" "if-let" "internal--" "string-" "thread-" 
"when-let")))
+(if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"subr-x" '("and-let*" "hash-table-" "if-let" "internal--" 
"replace-region-contents" "string-" "thread-" "when-let")))
 
 ;;;***
 
@@ -32460,9 +31567,7 @@ original message but it does require a few things:
 
 The region need not be active (and typically isn't when this
 function is called).  Also, the hook `sc-pre-hook' is run before,
-and `sc-post-hook' is run after the guts of this function.
-
-\(fn)" nil nil)
+and `sc-post-hook' is run after the guts of this function." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"supercite" '("sc-")))
 
@@ -32702,10 +31807,7 @@ all the table specific features.
 
 \(fn &optional ARG)" t nil)
 
-(autoload 'table-unrecognize "table" "\
-
-
-\(fn)" t nil)
+(autoload 'table-unrecognize "table" nil t nil)
 
 (autoload 'table-recognize-region "table" "\
 Recognize all tables within region.
@@ -32729,10 +31831,7 @@ the table specific features.
 
 \(fn &optional ARG)" t nil)
 
-(autoload 'table-unrecognize-table "table" "\
-
-
-\(fn)" t nil)
+(autoload 'table-unrecognize-table "table" nil t nil)
 
 (autoload 'table-recognize-cell "table" "\
 Recognize a table cell that contains current point.
@@ -32744,10 +31843,7 @@ plain text and loses all the table specific features.
 
 \(fn &optional FORCE NO-COPY ARG)" t nil)
 
-(autoload 'table-unrecognize-cell "table" "\
-
-
-\(fn)" t nil)
+(autoload 'table-unrecognize-cell "table" nil t nil)
 
 (autoload 'table-heighten-cell "table" "\
 Heighten the current cell by N lines by expanding the cell vertically.
@@ -32838,15 +31934,11 @@ DIRECTION is one of symbols; right, left, above or 
below.
 
 (autoload 'table-split-cell-vertically "table" "\
 Split current cell vertically.
-Creates a cell above and a cell below the current point location.
-
-\(fn)" t nil)
+Creates a cell above and a cell below the current point location." t nil)
 
 (autoload 'table-split-cell-horizontally "table" "\
 Split current cell horizontally.
-Creates a cell on the left and a cell on the right of the current point 
location.
-
-\(fn)" t nil)
+Creates a cell on the left and a cell on the right of the current point 
location." t nil)
 
 (autoload 'table-split-cell "table" "\
 Split current cell in ORIENTATION.
@@ -33113,9 +32205,7 @@ companion command to `table-capture' this way.
 Convert a table into plain text by removing the frame from a table.
 Remove the frame from a table and deactivate the table.  This command
 converts a table into plain text without frames.  It is a companion to
-`table-capture' which does the opposite process.
-
-\(fn)" t nil)
+`table-capture' which does the opposite process." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"table" '("*table--" "table-")))
 
@@ -33137,9 +32227,7 @@ Connect to display DISPLAY for the Emacs talk group.
 \(fn DISPLAY)" t nil)
 
 (autoload 'talk "talk" "\
-Connect to the Emacs talk group from the current X display or tty frame.
-
-\(fn)" t nil)
+Connect to the Emacs talk group from the current X display or tty frame." t 
nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"talk" '("talk-")))
 
@@ -33327,9 +32415,7 @@ If BYTE-COMPILE is non-nil, byte compile each function 
after instrumenting.
 \(fn FILENAME &optional BYTE-COMPILE)" t nil)
 
 (autoload 'testcover-this-defun "testcover" "\
-Start coverage on function under point.
-
-\(fn)" t nil)
+Start coverage on function under point." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"testcover" '("testcover-")))
 
@@ -33356,7 +32442,7 @@ tetris-mode keybindings:
 \\[tetris-rotate-next] Rotates the shape anticlockwise
 \\[tetris-move-bottom] Drops the shape to the bottom of the playing area
 
-\(fn)" t nil)
+" t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"tetris" '("tetris-")))
 
@@ -33511,9 +32597,7 @@ Tries to determine (by looking at the beginning of the 
file) whether
 this file is for plain TeX, LaTeX, or SliTeX and calls `plain-tex-mode',
 `latex-mode', or `slitex-mode', respectively.  If it cannot be determined,
 such as if there are no commands in the file, the value of `tex-default-mode'
-says which mode to use.
-
-\(fn)" t nil)
+says which mode to use." t nil)
 
 (defalias 'TeX-mode 'tex-mode)
 
@@ -33651,10 +32735,7 @@ Entering SliTeX mode runs the hook `text-mode-hook', 
then the hook
 
 \(fn)" t nil)
 
-(autoload 'tex-start-shell "tex-mode" "\
-
-
-\(fn)" nil nil)
+(autoload 'tex-start-shell "tex-mode" nil nil nil)
 
 (autoload 'doctex-mode "tex-mode" "\
 Major mode to edit DocTeX files.
@@ -33825,9 +32906,7 @@ Compose Thai characters in STRING and return the 
resulting string.
 \(fn STRING)" nil nil)
 
 (autoload 'thai-compose-buffer "thai-util" "\
-Compose Thai characters in the current buffer.
-
-\(fn)" t nil)
+Compose Thai characters in the current buffer." t nil)
 
 (autoload 'thai-composition-function "thai-util" "\
 
@@ -33889,19 +32968,13 @@ a symbol as a valid THING.
 \(fn THING &optional NO-PROPERTIES)" nil nil)
 
 (autoload 'sexp-at-point "thingatpt" "\
-Return the sexp at point, or nil if none is found.
-
-\(fn)" nil nil)
+Return the sexp at point, or nil if none is found." nil nil)
 
 (autoload 'symbol-at-point "thingatpt" "\
-Return the symbol at point, or nil if none is found.
-
-\(fn)" nil nil)
+Return the symbol at point, or nil if none is found." nil nil)
 
 (autoload 'number-at-point "thingatpt" "\
-Return the number at point, or nil if none is found.
-
-\(fn)" nil nil)
+Return the number at point, or nil if none is found." nil nil)
 
 (autoload 'list-at-point "thingatpt" "\
 Return the Lisp list at point, or nil if none is found.
@@ -33925,9 +32998,7 @@ An EVENT has the format
 \(fn EVENT)" t nil)
 
 (autoload 'list-threads "thread" "\
-Display a list of threads.
-
-\(fn)" t nil)
+Display a list of threads." t nil)
  (put 'list-threads 'disabled "Beware: manually canceling threads can ruin 
your Emacs session.")
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"thread" '("thread-list-")))
@@ -33950,21 +33021,15 @@ and SAME-WINDOW to show thumbs in the same window.
 \(fn DIR &optional REG SAME-WINDOW)" t nil)
 
 (autoload 'thumbs-dired-show-marked "thumbs" "\
-In dired, make a thumbs buffer with marked files.
-
-\(fn)" t nil)
+In dired, make a thumbs buffer with marked files." t nil)
 
 (autoload 'thumbs-dired-show "thumbs" "\
-In dired, make a thumbs buffer with all files in current directory.
-
-\(fn)" t nil)
+In dired, make a thumbs buffer with all files in current directory." t nil)
 
 (defalias 'thumbs 'thumbs-show-from-dir)
 
 (autoload 'thumbs-dired-setroot "thumbs" "\
-In dired, call the setroot program on the image at point.
-
-\(fn)" t nil)
+In dired, call the setroot program on the image at point." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"thumbs" '("thumbs-")))
 
@@ -34025,15 +33090,11 @@ are decomposed into normal Tibetan character 
sequences.
 
 (autoload 'tibetan-decompose-buffer "tibet-util" "\
 Decomposes Tibetan characters in the buffer into their components.
-See also the documentation of the function `tibetan-decompose-region'.
-
-\(fn)" t nil)
+See also the documentation of the function `tibetan-decompose-region'." t nil)
 
 (autoload 'tibetan-compose-buffer "tibet-util" "\
 Composes Tibetan character components in the buffer.
-See also docstring of the function tibetan-compose-region.
-
-\(fn)" t nil)
+See also docstring of the function tibetan-compose-region." t nil)
 
 (autoload 'tibetan-post-read-conversion "tibet-util" "\
 
@@ -34100,9 +33161,7 @@ Otherwise, if
    `tildify-space-string' variable,
 remove the hard space and leave only the space character.
 
-This function is meant to be used as a `post-self-insert-hook'.
-
-\(fn)" t nil)
+This function is meant to be used as a `post-self-insert-hook'." t nil)
 
 (autoload 'tildify-mode "tildify" "\
 Adds electric behavior to space character.
@@ -34141,9 +33200,7 @@ Enable display of time, load level, and mail flag in 
mode lines.
 This display updates automatically every minute.
 If `display-time-day-and-date' is non-nil, the current day and date
 are displayed as well.
-This runs the normal hook `display-time-hook' after each update.
-
-\(fn)" t nil)
+This runs the normal hook `display-time-hook' after each update." t nil)
 
 (defvar display-time-mode nil "\
 Non-nil if Display-Time mode is enabled.
@@ -34174,9 +33231,7 @@ runs the normal hook `display-time-hook' after each 
update.
 (autoload 'display-time-world "time" "\
 Enable updating display of times in various time zones.
 `display-time-world-list' specifies the zones.
-To turn off the world time display, go to that window and type `q'.
-
-\(fn)" t nil)
+To turn off the world time display, go to that window and type `q'." t nil)
 
 (autoload 'emacs-uptime "time" "\
 Return a string giving the uptime of this instance of Emacs.
@@ -34186,9 +33241,7 @@ For example, the Unix uptime command format is \"%D, 
%z%2h:%.2m\".
 \(fn &optional FORMAT)" t nil)
 
 (autoload 'emacs-init-time "time" "\
-Return a string giving the duration of the Emacs initialization.
-
-\(fn)" t nil)
+Return a string giving the duration of the Emacs initialization." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"time" '("display-time-" "legacy-style-world-list" "time--display-world-list" 
"zoneinfo-style-world-list")))
 
@@ -34200,6 +33253,7 @@ Return a string giving the duration of the Emacs 
initialization.
 
 (autoload 'date-to-time "time-date" "\
 Parse a string DATE that represents a date-time and return a time value.
+DATE should be in one of the forms recognized by `parse-time-string'.
 If DATE lacks timezone information, GMT is assumed.
 
 \(fn DATE)" nil nil)
@@ -34317,9 +33371,7 @@ The format of the time stamp is set by the variable 
`time-stamp-pattern' or
 `time-stamp-format'.  The variables `time-stamp-pattern',
 `time-stamp-line-limit', `time-stamp-start', `time-stamp-end',
 `time-stamp-count', and `time-stamp-inserts-lines' control finding
-the template.
-
-\(fn)" t nil)
+the template." t nil)
 
 (autoload 'time-stamp-toggle-active "time-stamp" "\
 Toggle `time-stamp-active', setting whether \\[time-stamp] updates a buffer.
@@ -34405,15 +33457,11 @@ working on.
 
 (autoload 'timeclock-query-out "timeclock" "\
 Ask the user whether to clock out.
-This is a useful function for adding to `kill-emacs-query-functions'.
-
-\(fn)" nil nil)
+This is a useful function for adding to `kill-emacs-query-functions'." nil nil)
 
 (autoload 'timeclock-reread-log "timeclock" "\
 Re-read the timeclock, to account for external changes.
-Returns the new value of `timeclock-discrepancy'.
-
-\(fn)" t nil)
+Returns the new value of `timeclock-discrepancy'." t nil)
 
 (autoload 'timeclock-workday-remaining-string "timeclock" "\
 Return a string representing the amount of time left today.
@@ -34486,7 +33534,7 @@ To get complete usage, invoke \"emacs -batch -f 
batch-titdic-convert -h\".
 
 \(fn &optional FORCE)" nil nil)
 
-(if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"titdic-cnv" '("batch-miscdic-convert" "ctlau-" "miscdic-convert" 
"py-converter" "quail-" "quick-" "tit-" "tsang-" "ziranma-converter")))
+(if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"titdic-cnv" '("batch-miscdic-convert" "ctlau-" "miscdic-convert" 
"pinyin-convert" "py-converter" "quail-" "quick-" "tit-" "tsang-" 
"ziranma-converter")))
 
 ;;;***
 
@@ -34747,7 +33795,7 @@ the output buffer or changing the window configuration.
 
 ;;;### (autoloads nil "tramp" "net/tramp.el" (0 0 0 0))
 ;;; Generated autoloads from net/tramp.el
-(push (purecopy '(tramp 2 4 1 -1)) package--builtin-versions)
+(push (purecopy '(tramp 2 4 2 -1)) package--builtin-versions)
 
 (defvar tramp-mode t "\
 Whether Tramp is enabled.
@@ -34790,9 +33838,7 @@ Unload Tramp file name handlers from 
`file-name-handler-alist'." (dolist (fnh fi
 If non-nil, external packages signal that they are in file name completion.")
 
 (autoload 'tramp-unload-tramp "tramp" "\
-Discard Tramp from loading remote files.
-
-\(fn)" t nil)
+Discard Tramp from loading remote files." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"tramp" '("tramp-" "with-")))
 
@@ -34823,14 +33869,14 @@ It must be supported by libarchive(3).")
 (defmacro tramp-archive-autoload-file-name-regexp nil "\
 Regular expression matching archive file names." '(concat "\\`" "\\(" ".+" 
"\\." (regexp-opt tramp-archive-suffixes) "\\(?:" "\\." (regexp-opt 
tramp-archive-compression-suffixes) "\\)*" "\\)" "\\(" "/" ".*" "\\)" "\\'"))
 
-(defalias 'tramp-archive-autoload-file-name-handler 
'tramp-autoload-file-name-handler)
+(defalias 'tramp-archive-autoload-file-name-handler 
#'tramp-autoload-file-name-handler)
 
 (defun tramp-register-archive-file-name-handler nil "\
-Add archive file name handler to `file-name-handler-alist'." (when 
tramp-archive-enabled (add-to-list 'file-name-handler-alist (cons 
(tramp-archive-autoload-file-name-regexp) 
'tramp-archive-autoload-file-name-handler)) (put 
'tramp-archive-autoload-file-name-handler 'safe-magic t)))
+Add archive file name handler to `file-name-handler-alist'." (when 
tramp-archive-enabled (add-to-list 'file-name-handler-alist (cons 
(tramp-archive-autoload-file-name-regexp) 
#'tramp-archive-autoload-file-name-handler)) (put 
'tramp-archive-autoload-file-name-handler 'safe-magic t)))
 
-(add-hook 'after-init-hook 'tramp-register-archive-file-name-handler)
+(add-hook 'after-init-hook #'tramp-register-archive-file-name-handler)
 
-(add-hook 'tramp-archive-unload-hook (lambda nil (remove-hook 'after-init-hook 
'tramp-register-archive-file-name-handler)))
+(add-hook 'tramp-archive-unload-hook (lambda nil (remove-hook 'after-init-hook 
#'tramp-register-archive-file-name-handler)))
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"tramp-archive" '("tramp-" "with-parsed-tramp-archive-file-name")))
 
@@ -34861,11 +33907,6 @@ Add archive file name handler to 
`file-name-handler-alist'." (when tramp-archive
 ;;;### (autoloads nil "tramp-ftp" "net/tramp-ftp.el" (0 0 0 0))
 ;;; Generated autoloads from net/tramp-ftp.el
 
-(autoload 'tramp-ftp-enable-ange-ftp "tramp-ftp" "\
-Reenable Ange-FTP, when Tramp is unloaded.
-
-\(fn)" nil nil)
-
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"tramp-ftp" '("tramp-")))
 
 ;;;***
@@ -34877,6 +33918,14 @@ Reenable Ange-FTP, when Tramp is unloaded.
 
 ;;;***
 
+;;;### (autoloads nil "tramp-integration" "net/tramp-integration.el"
+;;;;;;  (0 0 0 0))
+;;; Generated autoloads from net/tramp-integration.el
+
+(if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"tramp-integration" '("tramp-")))
+
+;;;***
+
 ;;;### (autoloads nil "tramp-rclone" "net/tramp-rclone.el" (0 0 0
 ;;;;;;  0))
 ;;; Generated autoloads from net/tramp-rclone.el
@@ -34899,6 +33948,14 @@ Reenable Ange-FTP, when Tramp is unloaded.
 
 ;;;***
 
+;;;### (autoloads nil "tramp-sudoedit" "net/tramp-sudoedit.el" (0
+;;;;;;  0 0 0))
+;;; Generated autoloads from net/tramp-sudoedit.el
+
+(if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"tramp-sudoedit" '("tramp-sudoedit-")))
+
+;;;***
+
 ;;;### (autoloads nil "tramp-uu" "net/tramp-uu.el" (0 0 0 0))
 ;;; Generated autoloads from net/tramp-uu.el
 
@@ -34980,9 +34037,7 @@ Associate another buffer with this one in two-column 
minor mode.
 Can also be used to associate a just previously visited file, by
 accepting the proposed default buffer.
 
-\(See  \\[describe-mode] .)
-
-\(fn)" t nil)
+\(See  \\[describe-mode] .)" t nil)
 
 (autoload '2C-split "two-column" "\
 Split a two-column text at point, into two buffers in two-column minor mode.
@@ -35106,16 +34161,12 @@ During the break, a demo selected from the functions 
listed in
 `type-break-demo-functions' is run.
 
 After the typing break is finished, the next break is scheduled
-as per the function `type-break-schedule'.
-
-\(fn)" t nil)
+as per the function `type-break-schedule'." t nil)
 
 (autoload 'type-break-statistics "type-break" "\
 Print statistics about typing breaks in a temporary buffer.
 This includes the last time a typing break was taken, when the next one is
-scheduled, the keystroke thresholds and the current keystroke count, etc.
-
-\(fn)" t nil)
+scheduled, the keystroke thresholds and the current keystroke count, etc." t 
nil)
 
 (autoload 'type-break-guesstimate-keystroke-threshold "type-break" "\
 Guess values for the minimum/maximum keystroke threshold for typing breaks.
@@ -35265,9 +34316,7 @@ Convert old-style Rmail Babyl files to mbox format.
 Specify the input Rmail Babyl file names as command line arguments.
 For each Rmail file, the corresponding output file name
 is made by adding `.mail' at the end.
-For example, invoke `emacs -batch -f batch-unrmail RMAIL'.
-
-\(fn)" nil nil)
+For example, invoke `emacs -batch -f batch-unrmail RMAIL'." nil nil)
 
 (autoload 'unrmail "unrmail" "\
 Convert old-style Rmail Babyl file FILE to mbox format file TO-FILE.
@@ -35578,16 +34627,16 @@ the arguments that would have been passed to 
OPERATION.
 
 (autoload 'url-copy-file "url-handlers" "\
 Copy URL to NEWNAME.  Both args must be strings.
-Signals a `file-already-exists' error if file NEWNAME already exists,
+Signal a `file-already-exists' error if file NEWNAME already exists,
 unless a third argument OK-IF-ALREADY-EXISTS is supplied and non-nil.
 A number as third arg means request confirmation if NEWNAME already exists.
 This is what happens in interactive use with M-x.
 Fourth arg KEEP-TIME non-nil means give the new file the same
 last-modified time as the old one.  (This works on only some systems.)
-Fifth arg PRESERVE-UID-GID is ignored.
+Args PRESERVE-UID-GID and PRESERVE-PERMISSIONS are ignored.
 A prefix arg makes KEEP-TIME non-nil.
 
-\(fn URL NEWNAME &optional OK-IF-ALREADY-EXISTS KEEP-TIME PRESERVE-UID-GID)" 
nil nil)
+\(fn URL NEWNAME &optional OK-IF-ALREADY-EXISTS KEEP-TIME PRESERVE-UID-GID 
PRESERVE-PERMISSIONS)" nil nil)
 
 (autoload 'url-file-local-copy "url-handlers" "\
 Copy URL into a temporary file on this machine.
@@ -35847,9 +34896,7 @@ parses to
 ;;; Generated autoloads from url/url-privacy.el
 
 (autoload 'url-setup-privacy-info "url-privacy" "\
-Setup variables that expose info about you and your system.
-
-\(fn)" t nil)
+Setup variables that expose info about you and your system." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"url-privacy" '("url-device-type")))
 
@@ -36260,7 +35307,12 @@ first backend that could register the file is used.
 \(fn &optional VC-FILESET COMMENT)" t nil)
 
 (autoload 'vc-version-diff "vc" "\
-Report diffs between revisions of the fileset in the repository history.
+Report diffs between REV1 and REV2 revisions of the fileset.
+
+\(fn FILES REV1 REV2)" t nil)
+
+(autoload 'vc-root-version-diff "vc" "\
+Report diffs between REV1 and REV2 revisions of the whole tree.
 
 \(fn FILES REV1 REV2)" t nil)
 
@@ -36275,6 +35327,12 @@ saving the buffer.
 
 \(fn &optional HISTORIC NOT-URGENT)" t nil)
 
+(autoload 'vc-diff-mergebase "vc" "\
+Report diffs between the merge base of REV1 and REV2 revisions.
+The merge base is a common ancestor between REV1 and REV2 revisions.
+
+\(fn FILES REV1 REV2)" t nil)
+
 (autoload 'vc-version-ediff "vc" "\
 Show differences between revisions of the fileset in the
 repository history using ediff.
@@ -36306,9 +35364,7 @@ saving the buffer.
 
 (autoload 'vc-root-dir "vc" "\
 Return the root directory for the current VC tree.
-Return nil if the root directory cannot be identified.
-
-\(fn)" nil nil)
+Return nil if the root directory cannot be identified." nil nil)
 
 (autoload 'vc-revision-other-window "vc" "\
 Visit revision REV of the current file in another window.
@@ -36320,9 +35376,7 @@ If `F.~REV~' already exists, use it instead of checking 
it out again.
 (autoload 'vc-insert-headers "vc" "\
 Insert headers into a file for use with a version control system.
 Headers desired are inserted at point, and are pulled from
-the variable `vc-BACKEND-header'.
-
-\(fn)" t nil)
+the variable `vc-BACKEND-header'." t nil)
 
 (autoload 'vc-merge "vc" "\
 Perform a version control merge operation.
@@ -36336,9 +35390,7 @@ between two revisions into the current fileset.  This 
asks for
 two revisions to merge from in the minibuffer.  If the first
 revision is a branch number, then merge all changes from that
 branch.  If the first revision is empty, merge the most recent
-changes from the current branch.
-
-\(fn)" t nil)
+changes from the current branch." t nil)
 
 (autoload 'vc-message-unresolved-conflicts "vc" "\
 Display a message indicating unresolved conflicts in FILENAME.
@@ -36347,6 +35399,9 @@ Display a message indicating unresolved conflicts in 
FILENAME.
 
 (defalias 'vc-resolve-conflicts 'smerge-ediff)
 
+(autoload 'vc-find-conflicted-file "vc" "\
+Visit the next conflicted file in the current project." t nil)
+
 (autoload 'vc-create-tag "vc" "\
 Descending recursively from DIR, make a tag called NAME.
 For each registered file, the working revision becomes part of
@@ -36406,6 +35461,12 @@ When called interactively with a prefix argument, 
prompt for REMOTE-LOCATION.
 
 \(fn &optional REMOTE-LOCATION)" t nil)
 
+(autoload 'vc-log-mergebase "vc" "\
+Show a log of changes between the merge base of REV1 and REV2 revisions.
+The merge base is a common ancestor between REV1 and REV2 revisions.
+
+\(fn FILES REV1 REV2)" t nil)
+
 (autoload 'vc-region-history "vc" "\
 Show the history of the region between FROM and TO.
 
@@ -36417,9 +35478,7 @@ mark.
 (autoload 'vc-revert "vc" "\
 Revert working copies of the selected fileset to their repository contents.
 This asks for confirmation if the buffer contents are not identical
-to the working revision (except for keyword expansion).
-
-\(fn)" t nil)
+to the working revision (except for keyword expansion)." t nil)
 
 (define-obsolete-function-alias 'vc-revert-buffer 'vc-revert "23.1")
 
@@ -37546,9 +36605,7 @@ positions (integers or markers) specifying the stretch 
of the region.
 \(fn FROM TO)" t nil)
 
 (autoload 'viet-decode-viqr-buffer "viet-util" "\
-Convert `VIQR' mnemonics of the current buffer to Vietnamese characters.
-
-\(fn)" t nil)
+Convert `VIQR' mnemonics of the current buffer to Vietnamese characters." t 
nil)
 
 (autoload 'viet-encode-viqr-region "viet-util" "\
 Convert Vietnamese characters of the current region to `VIQR' mnemonics.
@@ -37558,9 +36615,7 @@ positions (integers or markers) specifying the stretch 
of the region.
 \(fn FROM TO)" t nil)
 
 (autoload 'viet-encode-viqr-buffer "viet-util" "\
-Convert Vietnamese characters of the current buffer to `VIQR' mnemonics.
-
-\(fn)" t nil)
+Convert Vietnamese characters of the current buffer to `VIQR' mnemonics." t 
nil)
 
 (autoload 'viqr-post-read-conversion "viet-util" "\
 
@@ -37828,9 +36883,7 @@ This function runs the normal hook `view-mode-hook'.
 \(fn &optional QUIT-RESTORE EXIT-ACTION)" nil nil)
 
 (autoload 'View-exit-and-edit "view" "\
-Exit View mode and make the current buffer editable.
-
-\(fn)" t nil)
+Exit View mode and make the current buffer editable." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"view" '("View-" "view-")))
 
@@ -37842,14 +36895,10 @@ Exit View mode and make the current buffer editable.
 
 (autoload 'toggle-viper-mode "viper" "\
 Toggle Viper on/off.
-If Viper is enabled, turn it off.  Otherwise, turn it on.
-
-\(fn)" t nil)
+If Viper is enabled, turn it off.  Otherwise, turn it on." t nil)
 
 (autoload 'viper-mode "viper" "\
-Turn on Viper emulation of Vi in Emacs. See Info node `(viper)Top'.
-
-\(fn)" t nil)
+Turn on Viper emulation of Vi in Emacs. See Info node `(viper)Top'." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"viper" '("set-viper-state-in-major-mode" "this-major-mode-requires-vi-state" 
"viper-")))
 
@@ -38043,9 +37092,7 @@ buffer, the target of the links, and the permission 
bits of the
 files.  After typing \\[wdired-finish-edit], Emacs modifies the files and
 directories to reflect your edits.
 
-See `wdired-mode'.
-
-\(fn)" t nil)
+See `wdired-mode'." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"wdired" '("wdired-")))
 
@@ -38061,9 +37108,7 @@ See the documentation for the `webjump-sites' variable 
for how to customize the
 hotlist.
 
 Please submit bug reports and other feedback to the author, Neil W. Van Dyke
-<address@hidden>.
-
-\(fn)" t nil)
+<address@hidden>." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"webjump" '("webjump-")))
 
@@ -38384,9 +37429,7 @@ The problems cleaned up are:
    `space-after-tab::space', replace TABs by SPACEs.
 
 See `whitespace-style', `indent-tabs-mode' and `tab-width' for
-documentation.
-
-\(fn)" t nil)
+documentation." t nil)
 
 (autoload 'whitespace-cleanup-region "whitespace" "\
 Cleanup some blank problems at region.
@@ -38548,9 +37591,7 @@ Recommended as a parent keymap for modes using widgets.
 Note that such modes will need to require wid-edit.")
 
 (autoload 'widget-setup "wid-edit" "\
-Setup current buffer so editing string widgets works.
-
-\(fn)" nil nil)
+Setup current buffer so editing string widgets works." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"wid-edit" '("widget-")))
 
@@ -38686,6 +37727,27 @@ a single modifier.  Default value of PREFIX is `C-x' 
and MODIFIERS is `shift'.
 
 \(fn &optional PREFIX MODIFIERS)" t nil)
 
+(autoload 'windmove-swap-states-left "windmove" "\
+Swap the states with the window on the left from the current one." t nil)
+
+(autoload 'windmove-swap-states-up "windmove" "\
+Swap the states with the window above from the current one." t nil)
+
+(autoload 'windmove-swap-states-down "windmove" "\
+Swap the states with the window below from the current one." t nil)
+
+(autoload 'windmove-swap-states-right "windmove" "\
+Swap the states with the window on the right from the current one." t nil)
+
+(autoload 'windmove-swap-states-default-keybindings "windmove" "\
+Set up keybindings for directional window swap states.
+Keys are bound to commands that swap the states of the selected window
+with the window in the specified direction.  Keybindings are of the form
+MODIFIERS-{left,right,up,down}, where MODIFIERS is either a list of modifiers
+or a single modifier.  Default value of MODIFIERS is `shift-super'.
+
+\(fn &optional MODIFIERS)" t nil)
+
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"windmove" '("windmove-")))
 
 ;;;***
@@ -38751,9 +37813,7 @@ should be a topic string and non-nil RE-CACHE forces 
re-caching.
 \(fn &optional TOPIC RE-CACHE)" t nil)
 
 (autoload 'woman-dired-find-file "woman" "\
-In dired, run the WoMan man-page browser on this file.
-
-\(fn)" t nil)
+In dired, run the WoMan man-page browser on this file." t nil)
 
 (autoload 'woman-find-file "woman" "\
 Find, decode and browse a specific UN*X man-page source file FILE-NAME.
@@ -38876,20 +37936,13 @@ If LIMIT is non-nil, then do not consider characters 
beyond LIMIT.
 ;;;### (autoloads nil "xref" "progmodes/xref.el" (0 0 0 0))
 ;;; Generated autoloads from progmodes/xref.el
 
-(autoload 'xref-find-backend "xref" "\
-
-
-\(fn)" nil nil)
+(autoload 'xref-find-backend "xref" nil nil nil)
 
 (autoload 'xref-pop-marker-stack "xref" "\
-Pop back to where \\[xref-find-definitions] was last invoked.
-
-\(fn)" t nil)
+Pop back to where \\[xref-find-definitions] was last invoked." t nil)
 
 (autoload 'xref-marker-stack-empty-p "xref" "\
-Return t if the marker stack is empty; nil otherwise.
-
-\(fn)" nil nil)
+Return t if the marker stack is empty; nil otherwise." nil nil)
 
 (autoload 'xref-find-definitions "xref" "\
 Find the definition of the identifier at point.
@@ -39023,9 +38076,7 @@ Yenc decode region between START and END using an 
internal decoder.
 \(fn START END)" t nil)
 
 (autoload 'yenc-extract-filename "yenc" "\
-Extract file name from an yenc header.
-
-\(fn)" nil nil)
+Extract file name from an yenc header." nil nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"yenc" '("yenc-")))
 
@@ -39042,9 +38093,7 @@ Extract file name from an yenc header.
 ;;; Generated autoloads from play/zone.el
 
 (autoload 'zone "zone" "\
-Zone out, completely.
-
-\(fn)" t nil)
+Zone out, completely." t nil)
 
 (if (fboundp 'register-definition-prefixes) (register-definition-prefixes 
"zone" '("zone-")))
 
@@ -39146,19 +38195,19 @@ Zone out, completely.
 ;;;;;;  "leim/quail/latin-ltx.el" "leim/quail/latin-post.el" 
"leim/quail/latin-pre.el"
 ;;;;;;  "leim/quail/persian.el" "leim/quail/programmer-dvorak.el"
 ;;;;;;  "leim/quail/py-punct.el" "leim/quail/pypunct-b5.el" 
"leim/quail/quick-b5.el"
-;;;;;;  "leim/quail/quick-cns.el" "leim/quail/rfc1345.el" 
"leim/quail/sgml-input.el"
-;;;;;;  "leim/quail/slovak.el" "leim/quail/symbol-ksc.el" 
"leim/quail/tamil-dvorak.el"
-;;;;;;  "leim/quail/tsang-b5.el" "leim/quail/tsang-cns.el" 
"leim/quail/vntelex.el"
-;;;;;;  "leim/quail/vnvni.el" "leim/quail/welsh.el" "loadup.el" 
"mail/blessmail.el"
-;;;;;;  "mail/rmailedit.el" "mail/rmailkwd.el" "mail/rmailmm.el"
-;;;;;;  "mail/rmailmsc.el" "mail/rmailsort.el" "mail/rmailsum.el"
-;;;;;;  "mail/undigest.el" "menu-bar.el" "mh-e/mh-gnus.el" 
"mh-e/mh-loaddefs.el"
-;;;;;;  "minibuffer.el" "mouse.el" "net/tramp-loaddefs.el" "newcomment.el"
-;;;;;;  "obarray.el" "org/ob-core.el" "org/ob-keys.el" "org/ob-lob.el"
-;;;;;;  "org/ob-matlab.el" "org/ob-tangle.el" "org/ob.el" "org/org-archive.el"
-;;;;;;  "org/org-attach.el" "org/org-bbdb.el" "org/org-clock.el"
-;;;;;;  "org/org-datetree.el" "org/org-element.el" "org/org-feed.el"
-;;;;;;  "org/org-footnote.el" "org/org-id.el" "org/org-indent.el"
+;;;;;;  "leim/quail/quick-cns.el" "leim/quail/rfc1345.el" "leim/quail/sami.el"
+;;;;;;  "leim/quail/sgml-input.el" "leim/quail/slovak.el" 
"leim/quail/symbol-ksc.el"
+;;;;;;  "leim/quail/tamil-dvorak.el" "leim/quail/tsang-b5.el" 
"leim/quail/tsang-cns.el"
+;;;;;;  "leim/quail/vntelex.el" "leim/quail/vnvni.el" "leim/quail/welsh.el"
+;;;;;;  "loadup.el" "mail/blessmail.el" "mail/rmailedit.el" "mail/rmailkwd.el"
+;;;;;;  "mail/rmailmm.el" "mail/rmailmsc.el" "mail/rmailsort.el"
+;;;;;;  "mail/rmailsum.el" "mail/undigest.el" "menu-bar.el" "mh-e/mh-gnus.el"
+;;;;;;  "mh-e/mh-loaddefs.el" "minibuffer.el" "mouse.el" 
"net/tramp-loaddefs.el"
+;;;;;;  "newcomment.el" "obarray.el" "org/ob-core.el" "org/ob-keys.el"
+;;;;;;  "org/ob-lob.el" "org/ob-matlab.el" "org/ob-tangle.el" "org/ob.el"
+;;;;;;  "org/org-archive.el" "org/org-attach.el" "org/org-bbdb.el"
+;;;;;;  "org/org-clock.el" "org/org-datetree.el" "org/org-element.el"
+;;;;;;  "org/org-feed.el" "org/org-footnote.el" "org/org-id.el" 
"org/org-indent.el"
 ;;;;;;  "org/org-install.el" "org/org-irc.el" "org/org-mobile.el"
 ;;;;;;  "org/org-plot.el" "org/org-table.el" "org/org-timer.el" 
"org/ox-ascii.el"
 ;;;;;;  "org/ox-beamer.el" "org/ox-html.el" "org/ox-icalendar.el"
diff --git a/lisp/leim/quail/arabic.el b/lisp/leim/quail/arabic.el
index c4e1268..cf2effd 100644
--- a/lisp/leim/quail/arabic.el
+++ b/lisp/leim/quail/arabic.el
@@ -1,6 +1,6 @@
 ;;; arabic.el --- Quail package for inputting Arabic   -*- coding: utf-8;-*-
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Cloos <address@hidden>
 ;; Keywords: mule, input method, Arabic
diff --git a/lisp/leim/quail/croatian.el b/lisp/leim/quail/croatian.el
index 6124254..9d3def9 100644
--- a/lisp/leim/quail/croatian.el
+++ b/lisp/leim/quail/croatian.el
@@ -1,6 +1,6 @@
 ;;; croatian.el -- Quail package for inputting Croatian  -*-coding: utf-8;-*-
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author: Hrvoje Nikšić <address@hidden>
 ;; Keywords: i18n
diff --git a/lisp/leim/quail/cyril-jis.el b/lisp/leim/quail/cyril-jis.el
index 2876bae..67271ab 100644
--- a/lisp/leim/quail/cyril-jis.el
+++ b/lisp/leim/quail/cyril-jis.el
@@ -1,6 +1,6 @@
 ;;; cyril-jis.el --- Quail package for inputting JISX0208 Cyrillic letters
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 ;;   2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -32,114 +32,110 @@
 ;;; Code:
 
 (quail-define-package
- "cyrillic-jis-russian" "Cyrillic" "$B'('+(B" nil
- "$B'+'8'5','&'/(B keyboard layout same as JCUKEN (JIS X0208.1983 encoding)"
+ "cyrillic-jis-russian" "Cyrillic" "ЖЙ" nil
+ "ЙЦУКЕН keyboard layout same as JCUKEN (JIS X0208.1983 encoding)"
  nil t t t t nil nil nil nil nil t)
 
-;;  1! 2@ 3# 4" 5: 6, 7. 8* 9( 0) -_ =+ ,L!(B
-;;   ,L9(B  ,LF(B  ,LC(B  ,L:(B  ,L5(B  ,L=(B  ,L3(B  ,LH(B  
,LI(B  ,L7(B  ,LE(B  ,Lj(B
-;;    ,LD(B  ,LK(B  ,L2(B  ,L0(B  ,L?(B  ,address@hidden(B  ,L>(B 
 ,L;(B  ,L4(B  ,L6(B  ,LM(B
-;;     ,LO(B  ,LG(B  ,LA(B  ,L<(B  ,L8(B  ,LB(B  ,LL(B  ,L1(B  
,LN(B  /?
+;;  1! 2@ 3# 4" 5: 6, 7. 8* 9( 0) -_ =+ Ё
+;;   Й  Ц  У  К  Е  Н  Г  Ш  Щ  З  Х  ъ
+;;    Ф  Ы  В  А  П  Р  О  Л  Д  Ж  Э
+;;     Я  Ч  С  М  И  Т  Ь  Б  Ю  /?
 
 (quail-define-rules
- ("1" ?$B#1(B)
- ("2" ?$B#2(B)
- ("3" ?$B#3(B)
- ("4" ?$B#4(B)
- ("5" ?$B#5(B)
- ("6" ?$B#6(B)
- ("7" ?$B#7(B)
- ("8" ?$B#8(B)
- ("9" ?$B#9(B)
- ("0" ?$B#0(B)
- ("-" ?$B!](B)
- ("=" ?$B!a(B)
- ("`" ?$B'W(B)
- ("q" ?$B'[(B)
- ("w" ?$B'h(B)
- ("e" ?$B'e(B)
- ("r" ?$B'\(B)
- ("t" ?$B'V(B)
- ("y" ?$B'_(B)
- ("u" ?$B'T(B)
- ("i" ?$B'j(B)
- ("o" ?$B'k(B)
- ("p" ?$B'Y(B)
- ("[" ?$B'g(B)
- ("]" ?$B'l(B)
- ("a" ?$B'f(B)
- ("s" ?$B'm(B)
- ("d" ?$B'S(B)
- ("f" ?$B'Q(B)
- ("g" ?$B'a(B)
- ("h" ?$B'b(B)
- ("j" ?$B'`(B)
- ("k" ?$B'](B)
- ("l" ?$B'U(B)
- (";" ?$B'X(B)
- ("'" ?$B'o(B)
- ("\\" address@hidden(B)
- ("z" ?$B'q(B)
- ("x" ?$B'i(B)
- ("c" ?$B'c(B)
- ("v" ?$B'^(B)
- ("b" ?$B'Z(B)
- ("n" ?$B'd(B)
- ("m" ?$B'n(B)
- ("," ?$B'R(B)
- ("." ?$B'p(B)
- ("/" ?$B!?(B)
+ ("1" ?1)
+ ("2" ?2)
+ ("3" ?3)
+ ("4" ?4)
+ ("5" ?5)
+ ("6" ?6)
+ ("7" ?7)
+ ("8" ?8)
+ ("9" ?9)
+ ("0" ?0)
+ ("-" ?−)
+ ("=" ?=)
+ ("`" ?ё)
+ ("q" ?й)
+ ("w" ?ц)
+ ("e" ?у)
+ ("r" ?к)
+ ("t" ?е)
+ ("y" ?н)
+ ("u" ?г)
+ ("i" ?ш)
+ ("o" ?щ)
+ ("p" ?з)
+ ("[" ?х)
+ ("]" ?ъ)
+ ("a" ?ф)
+ ("s" ?ы)
+ ("d" ?в)
+ ("f" ?а)
+ ("g" ?п)
+ ("h" ?р)
+ ("j" ?о)
+ ("k" ?л)
+ ("l" ?д)
+ (";" ?ж)
+ ("'" ?э)
+ ("\\" ?\)
+ ("z" ?я)
+ ("x" ?ч)
+ ("c" ?с)
+ ("v" ?м)
+ ("b" ?и)
+ ("n" ?т)
+ ("m" ?ь)
+ ("," ?б)
+ ("." ?ю)
+ ("/" ?/)
 
- ("!" ?$B!*(B)
- ("@" ?$B!w(B)
- ("#" ?$B!t(B)
- ("$" ?$B!I(B)
- ("%" ?$B!'(B)
- ("^" ?$B!$(B)
- ("&" ?$B!%(B)
- ("*" ?$B!v(B)
- ("(" ?$B!J(B)
-  (")" ?$B!K(B)
- ("_" ?$B!2(B)
- ("+" ?$B!\(B)
- ("~" ?$B''(B)
- ("Q" ?$B'+(B)
- ("W" ?$B'8(B)
- ("E" ?$B'5(B)
- ("R" ?$B',(B)
- ("T" ?$B'&(B)
- ("Y" ?$B'/(B)
- ("U" ?$B'$(B)
- ("I" ?$B':(B)
- ("O" ?$B';(B)
- ("P" ?$B')(B)
- ("{" ?$B'7(B)
- ("}" ?$B'<(B)
- ("A" ?$B'6(B)
- ("S" ?$B'=(B)
- ("D" ?$B'#(B)
- ("F" ?$B'!(B)
- ("G" ?$B'1(B)
- ("H" ?$B'2(B)
- ("J" ?$B'0(B)
- ("K" ?$B'-(B)
- ("L" ?$B'%(B)
- (":" ?$B'((B)
- ("\"" ?$B'?(B)
- ("|" ?$B!C(B)
- ("Z" ?$B'A(B)
- ("X" ?$B'9(B)
- ("C" ?$B'3(B)
- ("V" ?$B'.(B)
- ("B" ?$B'*(B)
- ("N" ?$B'4(B)
- ("M" ?$B'>(B)
- ("<" ?$B'"(B)
- (">" ?$B'@(B)
- ("?" ?$B!)(B))
-
-;; Local Variables:
-;; coding: iso-2022-7bit
-;; End:
+ ("!" ?!)
+ ("@" ?@)
+ ("#" ?#)
+ ("$" ?”)
+ ("%" ?:)
+ ("^" ?,)
+ ("&" ?.)
+ ("*" ?*)
+ ("(" ?()
+  (")" ?))
+ ("_" ?_)
+ ("+" ?+)
+ ("~" ?Ё)
+ ("Q" ?Й)
+ ("W" ?Ц)
+ ("E" ?У)
+ ("R" ?К)
+ ("T" ?Е)
+ ("Y" ?Н)
+ ("U" ?Г)
+ ("I" ?Ш)
+ ("O" ?Щ)
+ ("P" ?З)
+ ("{" ?Х)
+ ("}" ?Ъ)
+ ("A" ?Ф)
+ ("S" ?Ы)
+ ("D" ?В)
+ ("F" ?А)
+ ("G" ?П)
+ ("H" ?Р)
+ ("J" ?О)
+ ("K" ?Л)
+ ("L" ?Д)
+ (":" ?Ж)
+ ("\"" ?Э)
+ ("|" ?|)
+ ("Z" ?Я)
+ ("X" ?Ч)
+ ("C" ?С)
+ ("V" ?М)
+ ("B" ?И)
+ ("N" ?Т)
+ ("M" ?Ь)
+ ("<" ?Б)
+ (">" ?Ю)
+ ("?" ??))
 
 ;;; cyril-jis.el ends here
diff --git a/lisp/leim/quail/cyrillic.el b/lisp/leim/quail/cyrillic.el
index 118e750..d004177 100644
--- a/lisp/leim/quail/cyrillic.el
+++ b/lisp/leim/quail/cyrillic.el
@@ -1,6 +1,6 @@
 ;;; cyrillic.el --- Quail package for inputting Cyrillic characters
 
-;; Copyright (C) 1997-1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 ;;   2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/leim/quail/czech.el b/lisp/leim/quail/czech.el
index 6ce1602..305b739 100644
--- a/lisp/leim/quail/czech.el
+++ b/lisp/leim/quail/czech.el
@@ -1,6 +1,6 @@
 ;;; czech.el --- Quail package for inputting Czech -*-coding: utf-8;-*-
 
-;; Copyright (C) 1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Milan Zamazal <address@hidden>
 ;; Maintainer: Pavel Janík <address@hidden>
diff --git a/lisp/leim/quail/georgian.el b/lisp/leim/quail/georgian.el
index 4fdb4c3..61003b8 100644
--- a/lisp/leim/quail/georgian.el
+++ b/lisp/leim/quail/georgian.el
@@ -1,6 +1,6 @@
 ;;; georgian.el --- Quail package for inputting Georgian characters  
-*-coding: utf-8;-*-
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Love <address@hidden>
 ;; Keywords: i18n
diff --git a/lisp/leim/quail/greek.el b/lisp/leim/quail/greek.el
index e41d225..66a17a2 100644
--- a/lisp/leim/quail/greek.el
+++ b/lisp/leim/quail/greek.el
@@ -1,6 +1,6 @@
 ;;; greek.el --- Quail package for inputting Greek -*-coding: utf-8-*-
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 ;;   2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/leim/quail/hangul.el b/lisp/leim/quail/hangul.el
index ba2b320..448f2d7 100644
--- a/lisp/leim/quail/hangul.el
+++ b/lisp/leim/quail/hangul.el
@@ -1,6 +1,6 @@
 ;;; hangul.el --- Korean Hangul input method
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Jihyun Cho <address@hidden>
 ;; Keywords: multilingual, input method, Korean, Hangul
diff --git a/lisp/leim/quail/hanja-jis.el b/lisp/leim/quail/hanja-jis.el
index 79730b8..6f75325 100644
--- a/lisp/leim/quail/hanja-jis.el
+++ b/lisp/leim/quail/hanja-jis.el
@@ -1,4 +1,4 @@
-;;; hanja-jis.el --- Quail package for inputting Korean Hanja (JISX0208)  
-*-coding: iso-2022-7bit;-*-
+;;; hanja-jis.el --- Quail package for inputting Korean Hanja (JISX0208)
 
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 ;;   2006, 2007, 2008, 2009, 2010, 2011
@@ -29,499 +29,499 @@
 (require 'quail)
 
 (quail-define-package
- "korean-hanja-jis" "Korean" "$B4A(B2" t
- "2$(C9z=D(BJIS$B4A;z(B: $B3:aD$(CGO4B(B $B4A;z$(address@hidden(B 
$B1$$(C@;(B $(CGQ1[(B2$(C9z$B<0$(address@hidden(B $B8F=P$(CGO?)(B 
$BA*Z$(B"
+ "korean-hanja-jis" "Korean" "漢2" t
+ "2벌식JIS漢字: 該當하는 漢字의 韻을 한글2벌式으로 呼出하여 選擇"
  nil nil nil nil nil nil t)
 
 (quail-define-rules
- ("rk" "$B1]2>address@hidden'[H[I`]aPcwgWhSkEkhlKlhmF(B")
- ("rkr"        "$B3F3J3L3P3Q3S3U5Q5S9oH9RJS>T=WmXBZ([d]W`Bk4l;r((B")
- ("rks"        
"$B064%4&4)4/43444B4G4H4J4N4V:&:):1?{U!XLYc[8[K[Y[e`CarcCecgek]s*su(B")
- ("rkf"        "$B2p3e3i3k3l7GP"[+brcqf;iypbpv(B")
- ("rka"        
"$B4*4.46484:4;4E4F4U7g848::0QaT,T0VHY"Y~\m]>address@hidden|(B")
- ("rkq"        "$B2!389C9gL(R:b5fpo^(B")
- ("rkd"        
"$B2,3`6/607D9/959>9G9K9P9V9]9_9dFzP6Q,S3U*V>XMY,[:[|aEbee,eZf5i(jvlora(B")
- ("ro" "$B2B2U2p2r2~3'3)3+3,3.313435383;8DP"P$PCQsXAXhYb\4^taNb5k;(B")
- ("ror"        "$B5RS=(B")
- ("rod"        "$B9#99dkf=f>o3(B")
- ("ri" "$B2X(B")
- ("rir"        "$BnS(B")
- ("rj" "$B5n5o5p5q5r5t5w5x<V?x?~P`PbTRZ!Z)address@hidden(gplwn1nSnj(B")
- ("rjs"        "$B4%6R7o7r7z80X4Ykg'iJkim!qZ(B")
- ("rjf"        "$B3i7G7f8pC4KqPu[?[\]ccq(B")
- ("rja"        "$B4;address@hidden(B")
- ("rjq"        "$B5h619e=&Qg(B")
- ("rp" "$B7F7GPuX\br(B")
- ("rur"        "$B2>3J3V3W7b7cPqYH\|g-h#k.ojqnr/rps&(B")
- ("rus"        "$B3_3o7x8#8$8(8*8+8/G{KzLzPWVtWz[G`Fa+d*f0l$s$(B")
- ("ruf"        "address@hidden(B")
- ("rua"        "$B3y7s8,XDY:]>d/heni(B")
- ("ruq"        "$B3fKKXDnw(B")
- ("rud"        
"address@hidden<9E9L:"P7Q?QDQHQmR&R'S+WMX]\{_i`{a9a[b~e%e4e;fVfzh3krmKmtpopts](B")
- ("rP" 
"$B2|3#3&3,5(787<address@hidden:fFOU|address@hidden)[G^da8b#c4d"e;eki)kSl0r!s1(B")
- ("rh" 
"$B6l8E8G8H8I8K8N8O8S8T8V8Z8[8\8]9F9M9Q9b9i9p;)<J?,C!ONPFQYQjRmZ?ZJZ^[W[][^\I\_]xa`b(bPb\cLd2f*f6fxiVjCk8kFkUlKmcn~pQrurzsi(B")
- ("rhr"        "$B6J9p9r9s9tC+H#S-ZO[g\`mXq~(B")
- ("rhs"        "$B:$:%:+:-:.TgVBW}[~^xhBjnrArJs.(B")
- ("rhf"        "$B3j9|\K]qs3(B")
- ("rhd"        "$B6!6&62636u8x8y9&9)95969WPeW0YJ[}\Jd3iOi^i_lop_(B")
- ("rhk"        "$B1;2I2J2L2[2]2a8S8X8YFiTFTnTrXyfxhTixjglvpy(B")
- ("rhkr"       "$B3G3TZ2Z<[v\Zayb_oWp9(B")
- ("rhks"       
"$B4'4142474=4>4C4I4P4Q4S4X4[4\6z?{P%QN]Y^ub9eEeGf%k7oQopsA(B")
- ("rhkf"       "$B3g3hH&I0Qi[XfZ(B")
- ("rhkd"       "$B3H6)688w9-9[9\T]W"Z2[%[&[Z^+bhc~d!e&e-fykToJ(B")
- ("rho"        "$B3]757SS%XyYL[Jjh(B")
- ("rhl"        "$B2q2t2u2x2z2}3!P*PzTUW_XC\G`skK(B")
- ("rhlr"       "$Bg2qE(B")
- ("rhld"       "$B9(9I9O9l^3mDo)(B")
- ("ry" 
"$B3I3P3S3z5j6#6+6,65666:6>8r8s9'9*9;9J9Y9Z;->7R{UHYxZJ\r_$`Db)c#c\fKg1i`m]n[q-qaqb(B")
- ("rn" 
"$B11192$2%2*3C555V5W5X5_5a5d5e5f5l5q6e6f6g6h6i6j6k6m6n6o6p6q7)8{8}9$949=9B9XC!G#H7KUP}QJR"R?RkSRU=UBUdVOV}V~WaW|address@hidden)n9nlplq'qDq\r-szs}(B")
- ("rnr"        "$B5E5F5G6I9m9qSxT"[xdxkqlr(B")
- ("rns"        "$B7/727374[ub0b1c[f:je(B")
- ("rnf"        "$B6~7!7"KYPcRPVA(B")
- ("rnd"        "$B5\5]5gcVm;(B")
- ("rnjs"       "$B4+4,5s7q7t7w7}7~8"R%R0RKT!X+[{\^bGe<ipq"(B")
- ("rnjf"       "$B7!OOP-RP`Um,om(B")
- ("rnp"        "$B4y5"50B|DYQ\R<[z]$]Eb'dOgLkLlnm,q9q?(B")
- ("rnl"        "$B5"address@hidden's}(B")
- ("rnlr"       "$BDOVn(B")
- ("rb" "$B0*1.5,5j6+6e7=7>:"DPTwYdYw\\b#bkcad}eYj_lbm|oaqDr-(B")
- ("rbs"        "$B556Q6]d0nbsKs}(B")
- ("rbf"        "$B5L(B")
- ("rmr"        "$B2D3W6K7`7a7d9nP4QnUqV![yh{n<(B")
- ("rms"        "$B6O6P6R6T6Z6\6`6a:,Xi\]`wbbhAk3ncq<(B")
- ("rmf"        "address@hidden(B")
- ("rma"        "$B6S6W6X6Y6^6_6b8i:#SaZ"jPsX(B")
- ("rmq"        "$B075Z5^5b5h5i5kV)(B")
- ("rmd"        "$B919NOJOKQ>Wqbb(B")
- ("rl" 
"$B0k4k4l4o4p4q4s4t4v4w4z4{4|4}4~5!5$5%5&5'5*5-5/5253585;address@hidden:j:k:l<(B6H)IIL'P4PXQCQpSOSZT-TtV?W1YVZ\Zz[.[9[L[w\H]c]f]k^?aCc2cEe:address@hidden(B")
- ("rlr"        "$B5J(B")
- ("rls"        "$B6[(B")
- ("rlf"        "$B5H5K5MPKYI(B")
- ("rla"        "$B6b(B")
- ("Rlr"        "$B5J(B")
- ("sk" "$BF`FaFqQ5U1XoY.Y<Y=[kdy(B")
- ("skr"        "$BBz(B")
- ("sks"        "$BCHFqZ:_kl_(B")
- ("skf"        "$BFhYT^:(B")
- ("ska"        "$BCKFnFoSGU3n((B")
- ("skq"        "$BG<jU(B")
- ("skd"        "$BG9L<[((B")
- ("so" "$BBQF`FbFwG5G6G=mr(B")
- ("sid"        "$B>nUP(B")
- ("su" "$B=wY<Y=h'(B")
- ("sus"        "$BG/G2bzmY(B")
- ("suf"        "$BYT^:(B")
- ("sua"        "address@hidden,(B")
- ("suq"        "address@hidden:oR(B")
- ("sud"        "$BG+Sf_?`Xfd(B")
- ("sP" "$BG)Zc(B")
- ("sh" "$BEXE[E\G>RsUWVfW8`obug*gBqN(B")
- ("shd"        "$BG;address@hidden/(B")
- ("shk"        "$B<6(B")
- ("shl"        "$BG:G>X=g*q/(B")
- ("sy" "$BE.G"U>Yz\vo?o_r)(B")
- ("sn" "$BfU(B")
- ("sns"        "$BUD(B")
- ("snf"        "$BRefmkD(B")
- ("sb" "$BI3WY`=nf(B")
- ("sbr"        "$BWYjHjI(B")
- ("smd"        "$BG=(B")
- ("sl" "$BE%FtG)G*Wb_>_Pg7(B")
- ("slr"        "$BE.F?(B")
- ("slf"        "$BFtWbZc(B")
- ("sla"        "$BDBWl(B")
- ("ek" "$BB?BgCcTl(B")
- ("eks"        "$B1_C"C0C1C4C6C;C<address@hidden|nBs((B")
- ("ekf"        "$BC#RtU'WeZ%_}`\m}orpZpg(B")
- ("eka"        "$BC4C8C9C?CLF^S7S8T`XkY?]__,_8abb>g<i!k)k}q5(B")
- ("ekq"        "$B7#EkEzF'Quh)(B")
- ("ekd"        "$BE^EbEdEvE|F2F5Q8Vq[c\+^oaDbUc'j0j;j}oFs^(B")
- ("eo" "$B10BPBRBSBTBWB^B_BbBcBeBgFXT2UtVhZ,Z-`^gJi7o>p0(B")
- ("ejr"        "$BFAW\(B")
- ("eh" 
"$B0p?^D)D7EHEIEKELEOEQERESETEUEYE]EaEgEhEiEmEnEpEqEsExE~F(F+F3F:F;R[T&V:Y[Y\YqZ.[7[m\*]%]9^9^mbQcKe6eBeCe{h8h9k/lum%mmokpkqC(B")
- ("ehr"        "$B<3FBFDFEFFFGFHFI`1`9`We{l&qqsb(B")
- ("ehs"        "$B=cFUFWFXFYFZF[F\Z}_wa&n,q+(B")
- ("ehf"        "$BFMF\Rt[S(B")
- ("ehd"        "$B4R6ME_E`ElEoF!F/F0F1F4F6F7F8F9F<Q*\u_.aVdig^gtr<s)sj(B")
- ("en" "$B1%3u?`EMENEZEwF&F,FIP5Y5ceflh:iQjEjFl&nFr((B")
- ("ens"        "$BFVF[F\F_g=n,(B")
- ("emr"        "address@hidden(B")
- ("emd"        "$BEPEtEuEyF#F%F*F-VS\t^naVc$d[d\eX(B")
- ("fk" "$B;IMeMfMgSIXqapaziGn6oUozq`(B")
- ("fkr"        "$B3J3ZMlMmMnMoS>\[_``8`dqQ(B")
- ("fks"        "$BMpMqMsMvP,UO]3_Q_s`%k&oVolsB(B")
- ("fkf"        "address@hidden(B")
- ("fka"        "$BMrMtMuMwQ0U:Z0]4dWeqe|k"k5nN(B")
- ("fkq"        "$B@"O9YG[VgDgEoM(B")
- ("fkd"        "$BBlBmO-O/O1O2O5O:[-`f`gh>j'lplt(B")
- ("fo" "$BPTWR(B")
- ("fod"        "$BNd(B")
- ("fir"        "$BN+N,address@hidden(B")
- ("fid"        "$BL:N+N<N>address@hidden(B")
- ("fu" 
"$B023BEWK{N7N8N9NeNoO$O?Q6R/S:W*[q]-`4`5avbjdze8eFg0gFh-i<iCiZjBoLocqfqk(B")
- ("fur"        "$BNONqNrV'[6]+],]._Ma|c*m`mapNr/(B")
- ("fus"        "$BNgNmNxNyNzN{N}N~O!O"O#SXXxYcZ;\Bf_gHmSo:rY(B")
- ("fuf"        "$BNsNtNuNvQXY`^0(B")
- ("fua"        "$B3yNwN|R=T~ZL_2_R(B")
- ("fuq"        "$BND`Zr'(B")
- ("fud"        "$BNNNaNbNfNgNhNjNkNmNnNpSz]2_:f9fYiYpMryst(B")
- ("fP" "$BK-NcNiNlc9h-nTp1rg(B")
- ("fh" 
"$B02:mH'IyN:O%O&O'O(O)O*O+O4O7R)S$Y}[E_#_3_I_N`$atb:gbgcgdiCmJmboNoOq!qfrisC(B")
- ("fhr"        "$B3Q9w</C+NPO<O=O?[rbqc3m\(B")
- ("fhs"        "address@hidden(B")
- ("fhd"        "$BBlBmN5N6O.O6O8S/T;Tb[0\Y`|dFiDp/(B")
- ("fhl"        "address@hidden(Q4T^Z']*azb}d]f#fPi2iAkQlO(B")
- ("fy" "$BN;address@hidden|["_yegfXhznRoAs>(B")
- ("fyd"        "$BN5N6iD(B")
- ("fn" "$B<HN^N_O,O0O3Q$\l`4`5aqdMe_e`j3jzo;o{qp(B")
- ("fnl"        "$BN^^%(B")
- ("fb" "$BI5LxN-N.N/N0N1N2N\N]N_N`R-ShT^W!ZX\X^%_H`eaneYe`g{nvo9pEq:(B")
- ("fbr"        "$BN&O;R-Y$hz(B")
- ("fbs"        "address@hidden(B")
- ("fbf"        "$B7*N'N(N*XKdE(B")
- ("fbd"        "$BN4VWcc(B")
- ("fmr"        "$BO>P>pU(B")
- ("fma"        "$BQ[W)XnhR(B")
- ("fmd"        "$B0=I)KSN?NGNMVE\AhQi3(B")
- ("fl" 
"$B3=8qA8C,DsKiMxMyMzM{M|M}M~N!N"N#N$N%NRNoP]P^X&Xm_"address@hidden>nZqkr5rEsW(B")
- ("fls"        "$BNUNYNZN[RgX'iBm8m9nC(B")
- ("fla"        "$BNSNTNVNWaepC(B")
- ("flq"        "$B3^N)N3g~(B")
- ("ak" "address@hidden(B")
- ("akr"        "$BGyG|KFKkKlLNUki8(B")
- ("aks"        
"$B17HTHUHZJZK|K}K~L!L"OQRDRXV]VoW>W?Xp^`_TbVe\h_jGktm*mNo8q=r#(B")
- ("akf"        "$BKuKvKwbFcBg}k$p\pi(B")
- ("akd"        "$BK4K:K;K>LQLVX1f&f(gjh+hOj<j=nzr3(B")
- ("ao" "$BGMG^G_G`GaGcGdJrK?KdKeKfKgKhL%Ug`pgugvlNn2pJ(B")
- ("aor"        "$BG|G~I4L.`Sfwl=lBoyq^sN(B")
- ("aod"        "$B0:K(LALTLUQ3]ba0hNsf(B")
- ("aur"        "$BQLQQVm]qf2k,(B")
- ("aus"        "address@hidden(B")
- ("auf"        "$BJNLG(B")
- ("aud"        "$B;.L=L>address@hidden,j&nIsf(B")
- ("aP" "$BjV(B")
- ("ah" 
"$B18243}G|InJgJhJiJkJlK9K?KAKEKFKHKlL0L6L7LNLOLSLWU(ZV`S`pa(b&bHcjdwfNfnhOkuqxr|(B")
- ("ahr"        "$BI$KRKTLZL\Q^[7]teYg|s/(B")
- ("ahf"        "$BKWL^]G]s(B")
- ("ahd"        "$BL4LXQOTm[$[/](_Bb^ga(B")
- ("ay" "$B1,@&address@hidden/ZbZe^]b?eMg{i8(B")
- ("an" 
"$B@&I5IoIpIqIsJjJlK4K?KEKGL3L5L6L7L8L9LPU(V`W'XcXlYEZ[\>bHeYhOj]kX(B")
- ("anr"        "$BKAKOK|L[`Tfn(B")
- ("ans"        "$B2cJ-J8J9JZLHLdLfLgLhPnQfX$XpY_e$(B")
- ("anf"        "$BJ*L^(B")
- ("al" "$B3aFfHxHyH}H~JFL#L$LBLoU;VKW9W=_>_Pdve[i/m?sHsSs`(B")
- ("als"        "$BIRL1LeV1X>XbZa^#eNf+o\sf(B")
- ("alf"        "$BL)L*\ikm(B")
- ("qkr"        "$B9}GmGnGoGqGsGtGuGvGwGzG}JmKPKQP8YsYv\w^p`a`yg.p;qPr0rX(B")
- ("qks"        "$BH<H>address@hidden/amcme+fvj6k'm*(B")
- ("qkf"        "$BH-H.H/H0H1H4KVUVX#Y6Y{^_b"b$cAlmq{r1(B")
- ("qkd"        "$BJoJ|J}K'K,K.K5K7K8K<address@hidden|cmg/gVhpiSkno%qwr7(B")
- ("qo" "$BGPGRGSGUGVGXGZG[G\G]GeGfGrKLT/WQX`YA^\_d`jfujj(B")
- ("qor"        "$B3|GFGlGoGpGrGuI4PQVg[1`aa)cndjr0(B")
- ("qjs"        "$BH(H?HKHMHQHVHYK]ZYZZ\h_/_xc)address@hidden(B")
- ("qjf"        "$BH2H3H5H6f/(B")
- ("qja"        "$BHAHEHFHHHOK^[p^"c{gw(B")
- ("qjq"        "$BK!`k(B")
- ("qur"        "$BI{I}JHJIJJJKQ|Z&]!`za2i0j~m2mdospH(B")
- ("qus"        "$BHPJQJTJUJXJ[MhQ~RFY(Y7ZN]repg&jokfmgn4n5qX(B")
- ("quf"        "$BHcJDJLJMP(Z~sh(B")
- ("qud"        "$BIBIMISJ:J;J<JAJBL_V"Vu[D\V_[c=cme3m~q6qX(B")
- ("qh" "$BD=F>IVIaIcIhJ]JbJcJdJeJnJsJuTHUoUph^jppfse(B")
- ("qhr"        
"$BIzI{I|I}I~J!J"J#J$KMKNKPR6Z=Z>\w]M_Ad9h*hyiui}j`m.mUmVqFrX(B")
- ("qhs"        "$BK\TqlL(B")
- ("qhd"        "$B0)HFIuJpJtJvJwJ{K%K)K*K/address@hidden"_bcsdK(B")
- ("qn" 
"$B3x4L<address@hidden|J#J$JmJsK6P=PZPmP|RuS_T4UUU[Y8YC[T[U[o\T]M^pf)g%gYgxijk>lRlgmUn>n]rjrksOsPse(B")
- ("qnr"        "$BKL(B")
- ("qns"        
"$BBNHRH[J,J.J/J0J1J2J3J4J5J6J7K[K_RfW][C]d]p_9`6a'a=cic|gnlL(B")
- ("qnf"        "$BITJ&J'J(J)PGWJWgYD[,`Ac1q|sd(B")
- ("qnd"        "$BC*J+JxJ~K2TDW:boe^(B")
- ("qmr"        "$BR6(B")
- ("ql" 
"$B7%H[H\H]H^H_HaHbHcHeHfHgHjHkHlHnHpHqHsHtHwHzH{H|I!J(JOP#PlR8SgU&U9U{X`[,\R`Aa]acbNbgc0c>dDdcdue#f1fGg#g$g>hKhoitjkl"address@hidden)pBp[pfqorL(B")
- ("qls"        "$BIFIKILINIOIPIQLFUMZ/]'address@hidden@p~r&(B")
- ("qld"        "$BI9QRQVQ_U2Xaf[qHqU(B")
- ("tk" 
"$B278%:3:6:;:=:>:?:@:p;E;G;H;J;K;L;M;N;U;W;[;`;b;d;e;l;r;t;v;w;{<%<-<K<L<M<N<O<P<R<S<U<X<Y?)?ZFcGAL&L,LcP/PXQPRSSNTzU0UmWP[O[h\L]y^/^V_C_S`:`[aBc+c,codAdBdCe/fSfhgRh5iImfnanmqJqKrBr^sM(B")
- ("tkr"        "$B:o:s:w?tSVZK\N`#oK(B")
- ("tks"        "$B;1;3;5;6;9;:;;;@IGQh[<]haMedlioYo[(B")
- ("tkf"        "$B;&;';5hq(B")
- ("tka"        "$B;0;2?9?yRTWD^zdsexf.glhujN(B")
- ("tkq"        "$B07=BA^Yg]=_'_(address@hidden(B")
- ("tkd"        
"$B7,8~=}=~>&>(>0>2>E>M>X>\>]>^>e>o>uAPASAVA[AjAzA|BlBmErF=FKH"MMRVUCURVyV{XS\k]O`.a3fFjak<ksrh(B")
- ("to" "$B:I<%^/_Sg(lPp{rT(B")
- ("tor"        "$B:I:p:w?'T'XG\ecQi,(B")
- ("tod"        "$B1y>address@hidden@8`Ocy(B")
- ("tid"        "$Bq.(B")
- ("tj" "$B5P:address@hidden@4@>@@@BAMD)L;P0ScTPTfVYY3ZFZGd.e1fTf]fqsUsk(B")
- ("tjr"        
"$B3c<.<M<a<address@hidden@address@hidden@address@hidden@YM<^Hb,hnirj.jinYnq(B")
- ("tjs"        
"address@hidden@address@hidden@address@hidden@address@hidden@address@hidden@~A"A#A%A*A-A/A1A5A6A7C1OKQ"SEUIUvX:^/address@hidden(B")
- ("tjf"        
"$B1L6}7@@address@hidden@address@hidden@eC-FQSwYM\8]u^Xe(e2eJi-jxsv(B")
- ("tja"        "address@hidden(B")
- ("tjq"        "$B=&>D@"@]RYSqXRXwYpfcm:oRq#(B")
- ("tjd"        
"$B>J>address@hidden@address@hidden@address@hidden@;@<@address@hidden)(B")
- ("tp" "$B:P:Y:address@hidden@address@hidden@address@hidden/ih(B")
- ("th" 
"$B037+:i<D=j>$>%>,>.>/><>?>B>C>F>K>P>R>S>dA:AAABAGAIAJALA]A_AcAgA{B}I%R#SbU?XG[`\f][]{^j_O_va4d,dTg[hvi+i?l!lsmvn:n[nyp<ppq[rCrM(B")
- ("thr"        "address@hidden/B0B3V$etkll^(B")
- ("ths"        "$B;AB9B;B=C'(B")
- ("thf"        "$BN(j+(B")
- ("thd"        "$B>>>address@hidden"(B")
- ("thkf"       "$B:~(B")
- ("tho"        "$B:?:U:~;&;/^/_S`tbl(B")
- ("thl"        "$B?h?jTj(B")
- ("tn" 
"$B<i<j<l<m<s<u<w<x<y<z<{<|<}=$=%=(=+=/=2=7=C=I?\?b?c?e?g?k?o?p?q?tA\AiB5C(C/D\JfLyM"N(address@hidden,^l^{_|`Yc.cOdXdoe5e7elf7f{g!g;h%h5hki.j-l(l3n.nHnsnxo5p$p+qrr$(B")
- ("tnr"        "$B=G=H=I=J=L=M=N=OPhUY`GfihChr(B")
- ("tns"        "$B=V=X=Y=[=\=]=^=_=b=c=d=f=gFkWNWv^-d#d$f|h&hsh|kNkYo>s((B")
- ("tnf"        "$B=Q=RN(WuX|[2(B")
- ("tnd"        "$B?r?shE(B")
- ("tnl"        "$BPfPg^C(B")
- ("tmf"        "$BI(`niMi|(B")
- ("tmq"        "$B<>=&=,=1_<jyp.(B")
- ("tmd"        "$B>!>#>5>:>g>h>jANFlGhP+QtR4[Fejj$o~(B")
- ("tl" 
"$B0;3A:|;&;H;O;S;T;\;k;m;n;x;{;~<(<,<E<F@'DsLpRQSASOS]UyU}W#W6WtYy`JfBg(gShahikkl5l9p{(B")
- ("tlr"        "$B6t<0<1>}>~?!?"?#?)?*B)Uf_omHq3(B")
- ("tls"        "$B:address@hidden"UbXFY;Zo_~iglYpur`(B")
- ("tlf"        "$B<:<<<=<BUi\Cj)(B")
- ("tla"        "$B;2?3?4?<?D?R?SRTWZ\;]n_)_Dh~o=(B")
- ("tlq"        "$B=&=:===BDTRARB_'_(a#cgdb(B")
- ("Tkd"        "$BAPRV(B")
- ("Tl" "$B;a(B")
- ("dk" 
"$B0!0"0$2d2e2f2g2j2k2m2n368f;yP3Q;S(U.U4V6[s`Ha^h0jKk(kCn{o<rms!s"(B")
- ("dkr"        "$B0!0-0.0/3Y3Z3\DWOLP3RxTAVVVjX(X3\[hUhVh`k`n?s-sys{(B")
- ("dks"        "$B0B0D0F0H4_4c4f4g4i8APtZg]Vpzr=rnro(B")
- ("dkf"        "$B060D1ZX~Y!]"address@hidden(B")
- ("dka"        "$B0C0E0G1^264`4b4dVIV^h?k^pws_sa(B")
- ("dkq"        "$B0(address@hidden(B")
- ("dkd"        "$B1{6D97Wi]J]vc?pYrs(B")
- ("do" "$B0%0&0'3336373eS1SNS`T<V=[#]7b-bJbYbvc(ghi=oup'pKpOq>(B")
- ("dor"        "$B1U3[LkLqY/YUf~mCoup'(B")
- ("dod"        "$BSm]/f"address@hidden(B")
- ("di" "$B<M<P<Y<c<fG8LiLjLkLlLmLnYh\?s,(B")
- ("dir"        "$B0s<c<eLsLtLvU>Ynd`h`hji;oPs4s~(B")
- ("did"        
"$B>\>m>n>w>y>zMHMLMMMNMSM[M\PSTaUPWyZ7ZfZx\k_!_G_laZagaxc:cUjwl*nVqh(B")
- ("dj" "$B1w5y5z5{8f8lS0S}S~^Kq,qGrNsw(B")
- ("djr"        "$B2/21225?M^\z(B")
- ("djs"        "address@hidden'PpUA_adN(B")
- ("djf"        "$B]"]1(B")
- ("dja"        "$B1b1f264`4d8387Q7RLSnV^Vx^;f,ofqd(B")
- ("djq"        "$B6H(B")
- ("dp" "$BWk]P(B")
- ("du" "$BFrG!M=M>address@hidden'i1ikl%q1(B")
- ("dur"        "$B0W0h1V1X5U<MKrLrLuXdehinl#o`ogp?qcrH(B")
- ("dus"        
"$B0v1c1d1h1i1l1m1o1t8&8'<!A3FPFpG3J%RdSkU+U/WzYPYa\=])^'^2^7^=_]d'gCh/address@hidden'(B")
- ("duf"        "address@hidden(B")
- ("dua"        "address@hidden(B")
- ("duq"        "$B1^MUSq[!pT(B")
- ("dud"        
"$B1D1E1F1G1I1J1K1M1N1O1P1Q1S7J7^RiS[TJU$U%Zu\3\F^s_J`r`}`~ewj>lWn;pD(B")
- ("dP" 
"$B0e1C1H1L1T4"7X7];y<address@hidden)P.PdQ;Q<St[*]u`IbKbOcRfJghi"i#i:iRjcl%l?p?rIsL(B")
- ("dh" 
"$B0-1(1*1w1x1|2(8^8`8a8b8c8d8g8h8mP~S*SKSSTITTT|U<UhWXX(XeZDZm_4_r_z`3`iiej(n+o2rbsg(B")
- ("dhr"        "$B0$206L9vM`(B")
- ("dhs"        "$B292:X2aicSi%i>jrr[r\(B")
- ("dhf"        "$BQ:\Eg,(B")
- ("dhd"        "$B2'MJTYW+a%a1a~c<hcp6s0(B")
- ("dhk"        "$B0#122i3?4$7&RwSyc]hbiwkBkw(B")
- ("dhks"       "$B08404K4P4X4a4e4hOPOROSU6^1_5iol2op(B")
- ("dhkf"       "$B[)(B")
- ("dhkd"       "$B1}2"2&9DUwWH[>]j(B")
- ("dho"        "$B0#3?OARwbdiw(B")
- ("dhl"        "$B0Z307(VLV[`Pbvi'r>(B")
- ("dy" 
"$B1z3Z6F9x>qD8F+LsMEMIMKMRMTMWMXMZQ'TpU-UKULVRVvWTWUY9YjYz\[\v]H_$`"`vcXc_eeh}j4kon-n3qAs8t!t#t$(B")
- ("dyr"        "$B?+C+M]M_MaV;^ieUhljs(B")
- ("dyd"        "$B23B{M&M/M0MCMFMGMOMPMQMVMYP\XJXY\Wa5f`gNill}o0ps(B")
- ("dn" 
"$B0r1&1'1)1*1+2$2%5m6h6r6s6v6w6x6y?uKtL`M$M%M'M+M4M9P2P}R^R_VJ\d]?]XaOb3c;c<d~foi9kpsIsz(B")
- ("dnr"        "$B000jR(TT_4_z(B")
- ("dns"        "$B0w1$1>address@hidden"fQp(pq(B")
- ("dnf"        "$B080S1516]5_q(B")
- ("dnd"        "$B7'M:(B")
- ("dnjs"       "address@hidden;I2QMT$T(U6UcXE^S`)gkiojOkdmWn|ovp((B")
- ("dnjf"       "$B1[7nXz[)denh(B")
- ("dnl"        
"$B010L0N0O0Q0R0S0V0Y0^0_0`0b0c161R4m56OAQ&address@hidden<ivjLm{pjr2(B")
- ("db" 
"$B0T0]0d:y<address@hidden(KnL{L|L}L~M!M"M#M(M)M*M-M.M1M2M3M5M6M7MDPRQASHS|address@hidden"address@hidden|n'nXo+pds[sl(B")
- ("dbr"        "$B0i4!FyS|]Zdx(B")
- ("dbs"        "$B0t0}1<=aUzlVnJ(B")
- ("dbf"        "$Bffrr(B")
- ("dbd"        "$B=?M;e0(B")
- ("dms"        "address@hidden;p,su(B")
- ("dmf"        "$B255?(B")
- ("dma"        "$B0{0|0~1"2;address@hidden;pF(B")
- ("dmq"        "$B5cM,M8X%(B")
- ("dmd"        "address@hidden(B")
- ("dml"        
"$B0M0U0X0a365#57595<5?5A5B5C5DODPaV=VTVXXt]:_q`Hbcc&ePg_nPq>(B")
- ("dl" 
"$B0;0J0K0P0W0[0\1B;\<$<)<*<X?)BBBfCPFRFsFvP1U)UuVaW3W4W^^&`ba-aXfggokHlFlHlIm_mnp0(B")
- ("dlr"        "$B1WMbMcVXW5[;fDkjs2(B")
- ("dls"        "$B0u0v0x0y0z1l?M?N?O?YFRG&G'address@hidden;iNpW(B")
- ("dlf"        "$B0l0m0n0oF|P!PETejRn_o-(B")
- ("dla"        "$B1A?QDBG$G%L-U,WljSjT(B")
- ("dlq"        "$B9~F{F~R]T)rl(B")
- ("dld"        "$B>jP;QtUT(B")
- ("wk" 
"$B040q:4:8:::^:n;F;I;P;Q;R;Z;g;p;q;s;z;|<"<'<+<Q<address@hidden@QDSI&PwQ}RoR~UZWs^h_Ua*aSbDbEdggsh$hti4i5k9lGlZl`r8s:sn(B")
- ("wkr"        "$B:n:r<[<]<^<_<`?]?}SpU"UeZQ[P_Zd+e?ginLs'(B")
- ("wks"        "$B;7;DV#X}\"]L_%b7(B")
- ("wka"        "$B;=;address@hidden>dQjDlQo4(B")
- ("wkq"        "$B;(AYA^C}SrYgd4p7p8(B")
- ("wkd"        
"$B>">)>->1>8>@>O>Q>U>_>c>f>l>s>uATAqArAuB!B"D"D%D2D9F5P?TGTVTcTyT}U#UrVQW2\u\~^J^y`-`/`R`xaog6gGgIg`h7hIi,i6jfl[l\o6rc(B")
- ("wo" "$B:F:H:K:M:R:X:[:\:_:`:b<address@hidden(B")
- ("wod"        "$BA9AdAhAyVDVl`'bUd7d8kZo#(B")
- ("wj" 
"$B093n5O<Q=m=s=t={=|A;address@hidden:]|_L`2aTbicle*f8fTgsiWk:kIl7m0p3sr(B")
- ("wjr"        
"$B2.<Z<address@hidden@address@hidden@address@hidden@XB1C`CdD$D_E&E(E)E*E+E,E-LvR*W/_U`?a{c!d{gii4k6mlmqmx(B")
- ("wjs"        
"$B<address@hidden@address@hidden@address@hidden'A,A0A4B7C.DQE5E6E8E;E>E?EAEBECEDEEG{H*KjMdQ#QrR4RdSsT{UsV\W%X"X}Y%ZBZS]a^!_E`0a/aYaub!c"d%d5d?euf?fHg"lcm7mYm[nonto"oCp4pSp|q4qBs6s7t"(B")
- ("wjf"        
"address@hidden@address@hidden@address@hidden@dCbLERERGRzY#ZqZr^6cffOlkmE(B")
- ("wja"        "$B0>@address@hidden(B")
- ("wjq"        "address@hidden&\7\D]~^XfcrW(B")
- ("wjd"        
"$B0f;*>=>Z>`>p>t>{@,@/@address@hidden@:@EBGCzD.D:DbDdDeDgDhDjDmDnDrDuDvDwDxDzD{E"E#E$FTKoLwMdP'RZVlY]ZW[l^F^[a6aKbMcWf^hGj:mwn&nDnKoFp=pP(B")
- ("wp" 
"$B1-:O:Q:W:]:^=t=|@)@address@hidden@^BhBiBjDiDkDoDpDsDtD}P_Q1Q}Z+Zq_;bDbEbIgAi5lZm3pIpmpnsn(B")
- ("wh" 
"$B3v7+:x;4<D=u><>H>[>rA;A<ADAEAFAHAKA`AaAbAeAfAgAlAtAxB$BdC{C|D$D&D+D,D/D4D7D8D;DUD^D_D`FXGBH%POPYS^SdWIXNXTXjY2Y4Zj[j[t\'\*_6`,bic/cGcZc^cud|e6f-fTfrg]iskGkPl!ldm/oXp:qt(B")
- ("whr"        "$BB-B2dHhwo7(B")
- ("whs"        "$BB:YO(B")
- ("whf"        "address@hidden@`L(B")
- ("whd"        "$B<o<p=!=*=>=D>a>bAnI"P:WOXQ\#\$\b^JdpeTj*l{m'm)oG(B")
- ("whk"        "$B:4:8:A:B:C(B")
- ("whl"        "$B:a(B")
- ("wy" "$Bn[(B")
- ("wn" 
"$B3t:n<g<k<n<r<v<~=#='=.=5=;=K?_AUAvB-B2ChCkClCmCpCqCrCsD4D]I*L+P&PMPvQ2QISUW$ZlaFaGcGdVdZe!eBfthwiakOlam4mTn$oIsG(B")
- ("wnr"        "$B4!C]dx(B")
- ("wns"        "$B1==S=T=W=Y=`=c=eFVH;KpQ.RETSWvX"X6^4_=b/jAm-mu(B")
- ("wnd"        "$B=0=ECfCg(B")
- ("wmr"        "$BB(B1(B")
- ("wmf"        "$B6{(B")
- ("wma"        "$BWc(B")
- ("wmq"        "$B=4=AIxM,\7eI(B")
- ("wmd"        "$B3(9y>I>Z>xA9A=A>A}A~B#D'YN\t__kz(B")
- ("wl" 
"$B4t5@;V;X;Y;];^;_;c;f;h;i;j;o;}<1<A<G?%B~CNCOCRCSCXCYDRDlDqEVG7S!T.TMVcW7Yu[L]ma\c-fMfsgSk:lDlSlflym5mIn/owr?s9(B")
- ("wlr"        "$B?%?&D>SDcFcM(B")
- ("wls"        
"$B?0?6?8?:?>???A?G?J?L?P?T?XC$DADCDDDEE6FxKyPVSQZi]I_~`_a+a;b8bCbSeVgKhmjWlcmGo/(B")
- ("wlf"        "$B<8<;<@<ACaCbE3IHLEPERzSDT9Ve[_fOg4g5lDlkmE(B")
- ("wla"        "$BD?ZPnErq(B")
- ("wlq"        "$B<9=4=8=AeI(B")
- ("wld"        "address@hidden'D(_-(B")
- ("ck" "$B3n:!:5:7:9:<<V<W<ZOMPNSMV+VMY-Ym[3\Lbxd4gsm"n`(B")
- ("ckr"        "$B:q:u:address@hidden'eSm0oXsqsx(B")
- ("cks"        "$B;8;<;>;?;address@hidden&cbdlesl-lUo4oSoTqB(B")
- ("ckf"        "$B;!;";$;%QkY)`\e'(B")
- ("cka"        "$B;2;4;BA2Q(Q)RTTOVPVZXNXOXPXrXs\ackk{k|l)l+q](B")
- ("ckd"        
"$B>'>+>3>4>;>T?zAOARAdAkAsD*D1H+PiQlRRX0XHYoZHZd^E^k^}`KalcYgZm#r.(B")
- ("co" "$B:9:D:L:N:S:V:W:Z<address@hidden(B")
- ("cor"        "$B:p:t:u:v:address@hidden<QFSTY>[Pbyd)dG(B")
- ("cj" "$B:J=h@(address@hidden(B")
- ("cjr"        
"$B;I<address@hidden@address@hidden@TD=QqRhWFZ3^~akinljm$m(m6p"s5(B")
- ("cjs"        
"$B0+6N6z6|;address@hidden@address@hidden@address@hidden@|A$A&A(A)A+C)E7PBPjQdSCV_Z#[a\9^I^Y_Ea$chh(lMlxoqotph(B")
- ("cjf"        "$BDVE/E0E1E2E4FLFmS5V%YZmPnno$oDoEq8(B")
- ("cja"        "address@hidden:E<Q!W[Ww\a\y]~b]dSdUd^d_j9k-k[k~(B")
- ("cjq"        "$B>*>9>vC}D!D-D5E=aHaIaJbLjymLmM(B")
- ("cjd"        "$B;*;,@address@hidden@address@hidden,W-fehGiq(B")
- ("cp" "address@hidden|D~FeFmSFSiSjYZ\<^8^|bIbfh\hxjim<m=n*pLqsqv(B")
- ("ch" 
"$B7-=i>%>6>7>A>G>K>L>S>V>d?]A?ACApD6D8ICQvR#R+V%V9X!X7X^[B\%^W_VcDggkWl:mknLndqzs<ss(B")
- ("chr"        "$B<q>|?$?(?tB%B0SvV$ZKb`badHifk=m1o7qq(B")
- ("chs"        "address@hidden<WVn7(B")
- ("chd"        "$B=>=FAQAZAmAoC~DMF4G,N5N6P:PxR2WOWdX;eAeTfb(B")
- ("chl"        "$B:E:GVCYt\c^/(B")
- ("cn" 
"$B0,1/3b<h<q="=%=)=-=6=9=P?[?d?m?n?u?v?wAFC\CjDFDGDHDIDJGkOISBU7U9VdX/YXYY\6\d^Wa,address@hidden(B")
- ("cnr"        "$B1/<3<4=3=K=LC[C\C^C_C`M.\egXm&(B")
- ("cns"        "$B=UDXrV(B")
- ("cnf"        "$B=P[2sY(B")
- ("cnd"        "$B2-=<=F>WCiCnCoMCQU`>g^j5(B")
- ("cnp"        "$BX,X-X8aahDlT(B")
- ("cnl"        "$B<h<q="address@hidden(B")
- ("cmr"        "$BB&B'B,D=P<X<Z`(B")
- ("cms"        "$Bsp(B")
- ("cma"        "$Boo(B")
- ("cmd"        "$BA=A>AX(B")
- ("cl" 
"$B:7:9;u<#<&>}?"?%CMCQCTCUCVCWCZD'D>FePLRHRNSPTiV5VbVpVz[i_ua7a?awbtcPcze#e>eLfWiPjul8lemOo!p5r5rKrvrwscso(B")
- ("clr"        "$BB'B,D<R,RNVzX<ZE(B")
- ("cls"        "$B?Fk%sp(B")
- ("clf"        "$B<7<?(B")
- ("cla"        "$B5N?/?2?;address@hidden;o*o,ooqT(B")
- ("clq"        "$Bj/(B")
- ("cld"        "$B>NGicJjYqU(B")
- ("cho"        "$B2wTo`V(B")
- ("xk" "$B<XB>BBBCBDBEBFBGBHBIBJBKBLBMCSOMPIS#TXU`YYYe[4\s]}g!m>qLrx(B")
- ("xkr"        "$BBnBoBqBsBtBuBvBwBxByE'EYPkS6Y>[Q_7ner0(B")
- ("xks"        "$BBMC2C3C7C:C>CBCFF]FgW<X_Z:]QjX(B")
- ("xkf"        "$BC%C&(B")
- ("xka"        "$BC5C?b>lE(B")
- ("xkq"        "$BEcEkYr\PpaperW(B")
- ("xkd"        "$BEfErE|F"Vfb;j#(B")
- ("xo" "address@hidden@BABUBVBYB[B]BaBfBgG=KXLaQ<\(cze)ihkHq&qM(B")
- ("xor"        "$BBpBrBtZ$_7(B")
- ("xh" "$BEFEGEQEZEeF$Q=h9(B")
- ("xhs"        "$Bjt(B")
- ("xhd"        "$B23DKDLE{E}HuWxXV(B")
- ("xhl"        "$B?dBOB\B`DHDIDJFXjtpx(B")
- ("xn" "$BEJEjF)F.L{Pye5o+qmr,(B")
- ("xmr"        "$BB_FCXW(B")
- ("vk" "$B?|GCGDGEGGGHGIGJGKGLGNHmHvT3WfZ4[1`(``bncvfRg8hJh]jZllox(B")
- ("vks"        "$B:d:eH=HDHGHNR!]ra"ng(B")
- ("vkf"        "$B;+H,R\[5n\(B")
- ("vo" "$B143-GIGTGWGXG\GbH4HmI#PPUVX#Y6ZT[1]o`cp>(B")
- ("vod"        "$BC*K#K5KDW:WEZU_0b|e^(B")
- ("vir"        "$BX?(B")
- ("vus"        "$BJ?JPJRJSJTJWJXJ\Y(fIgyi~jokfqY(B")
- ("vua"        "$BlJ(B")
- ("vud"        "$BDZI>IMJ?Wh^$bogyhLr9(B")
- ("vP" "$B3AGQGYJ>address@hidden&ZIZMasi0qo(B")
- ("vh" 
"$B1:3s3wGxGzI[I]IrJ^J_J`JaJqJyJzK"K$K&K+K0K=R1R5R7RvS.T5YF[T_F_\aWb.f}gTgzj\jqmynppRq0q}r:rDsR(B")
- ("vhr"        "$BGxGzI}K=_F(B")
- ("vy" "$B<]I6I7I8I:I;I<I=I?QwUEXX]Ke]q(q)q*q_qjqurd(B")
- ("vns"        "$BJ,(B")
- ("vna"        "$BIJcHcI(B")
- ("vnd"        "$BIvIwK-afkel4q$qH(B")
- ("vb" "$BI7(B")
- ("vl" "$BH`HdHhHiHmHoHrllmdox(B")
- ("vlf"        "$B2^HfHgI$I%I+I,I-I.J'J)PGYDdJkvm+s+(B")
- ("vlq"        "$BI/I}K3^"(B")
- ("gk" "$B2<2?2F2O2Y2\2b2l3E<6ROR`V|^Q`leKf!kEl.n"o(rQ(B")
- ("gkr"        "$B2)3X5TDaT[U\U]^A`Bajkbl;s?(B")
- ("gks"        "$B4(address@hidden:(UFUGW{Y*YRZ][e_K`Cb*f'n8qSqlsm(B")
- ("gkf"        "$B323d3e3mR$bRiys\(B")
- ("gka"        "$B4O4Y4^H!MtQbRyS2S?VH]#^>eHh1n8nro|pwq2rRsD(B")
- ("gkq"        "$B389^9gH:RnR}^eb4b5b6hdonr{(B")
- ("gkd"        "$B7e9+91939:9A9R9T9_9`FzP6PDRbWqe}fjobprr*(B")
- ("go" "$B0g2r3#3$3*3/31323:3<:zPsT6TnTxUXW(Xh\4i&j7k;k_n0nOqO(B")
- ("gor"        "$B3/3Kbkk*mJ(B")
- ("god"        "$B0I8v9,9Te.jbr}(B")
- ("gid"        "$B5}6?6A6B8~9aSlq.(B")
- ("gj" "$B135u5vTR[[]A^w(B")
- ("gjs"        "$B7{8%8.YW`[(B")
- ("gjf"        "$B]<iyj8(B")
- ("gja"        "$B8183VUp*qd(B")
- ("gur"        "$B3E3R3W7CTu^)r+(B")
- ("gus"        "$B0<7|8)8+8-82898<8=8>8?9`JGPWRl^-aRbAeQidjJnkp}(B")
- ("guf"        "$B7j7l>iJGLRUSk#pv(B")
- ("gua"        "$B7y(B")
- ("guq"        "$B0A3p6"6(6.64696<KKOFTsV7XDYQ^5`Ed)d:h2nwo}p!(B")
- ("gud"        "$B3>5|7:7;7?7A7U7V7e9UTk_W_X`rfzj%mj(B")
- ("gP" "$B7E7RQBR>TxWBX*b=c4l~nQp^(B")
- ("gh" 
"address@hidden:c;)<JD[QTTdW`Y&Z_Zn\5]]]l^v^w`7`ha!b(b+hYhfiHiKizn=o.q7(B")
- ("ghr"        "$B0?9s9tOGUeZO(B")
- ("ghs"        "$B:':*:+:.:2[~\!^U^g_c`m(B")
- ("ghf"        "$B3K9z9{]Gcts3(B")
- ("ghq"        "$B3f(B")
- ("ghd"        "$B909?9H9cR|]g]wkAobr*(B")
- ("ghk"        "$B2=2P2R2S2V2Z2_2h3q3r7$CtOBOCS;V<aAdqo&(B")
- ("ghkr"       "$B3H3M3N3OZ2Z<ayb_j?p9(B")
- ("ghks"       
"$B4-45494<4?4D4T4]88OKT(TvUaUnXu]D^R^S_eb*bAbbl,l6oBqir%r](B")
- ("ghkf"       "$B1[3h3j;#`Qbwi]l/ohoi(B")
- ("ghkd"       "$B2+677;92989D9SKZQWQ`WSWrX5Zh^T^f_jd;dPfki{n#p&rS(B")
- ("gho"        "$B2h7S`VaA(B")
- ("ghl"        
"$B2q2s2u2v2y2z2{3"3%=ZI0OEPrQER;TUWKXg[X\G^Neig:h"i'i\kKkRmorf(B")
- ("ghlr"       "$B2h3D3MaA(B")
- ("ghld"       "$B2#909U9li*mDo)sT(B")
- ("gy" "$B6G8s8z9;9Z:hP{S,SeSoZCZ|[f^B_^`+qaqb(B")
- ("gn" "$B0r5`8e8t8u8|9!9"PHRcSLSR^A_h`Md<kMmp(B")
- ("gns"        "$B7.7071FkR._m_nhXnU(B")
- ("gnd"        "$Bi*(B")
- ("gnjs"       "$B3~7vCHX:address@hidden,(B")
- ("gnp"        "$BCnRCS<TL_{(B")
- ("gnl"        "$B4x5+51WCY&Zv]`ka(B")
- ("gb" "$B5Y7H7MC\Z8_^iLl<(B")
- ("gbr"        "$BC\(B")
- ("gbf"        "$BWukys;(B")
- ("gbd"        "$B6$6'6;R3Wo^((B")
- ("gmr"        "$B9un^(B")
- ("gms"        "$B6U:/WLWWYWnW(B")
- ("gmf"        "$B5%5IKxV(k?(B")
- ("gma"        "$B6V7g(B")
- ("gmq"        "address@hidden(B")
- ("gmd"        "$B6=Fz(B")
- ("gml"        "$B4n4r4u5)5:5>I1Q%RzS)S`XAXZY&Zk[']8_f_g_t`!`:c6f<nZrF(B")
- ("glf"        "$B5Merk#pvs\(B")
- ("unknown"    
"$B4#<5DNFJFdFuJ=KsL]QeRIRpS&S9SuS{T*T+T8T:T>TBTCTKTNTQTWT\T_UNU~V&V,V-V.V/V0V2V4V8VNW;WjWnWpY0YKY^Z1Zs[=[b[n\)\-\.\/\0\1\O\S\j\n\o\p\q\x]&]6]B]i^<^L^c_&_1`<a:a<a>b<bBbXbmbpbsc%c5cNcdc}d&d1d=dIdLdYdddfdhdte9eaebemenevf$g3g\h4h6hHhMhWhhiFi[ibj,jQj^jmk\lCmZmhmimzn%n}o'oZo]p#p-pXp]p`q;qIqRr;address@hidden(B"))
+ ("rk" "榎仮伽価佳加可嘉嫁家暇架歌珂稼苛茄迦駕街袈个假價呵哥枷柯珈痂笳舸葭訶謌賈跏軻")
+ ("rkr"        "各格殻覚角較閣却脚刻塙卻咯埆恪愨擱桷殼狢覺貉鬥")
+ ("rks"        "斡乾侃刊姦干幹澗看竿簡肝間墾懇艮菅奸慳揀杆柬栞桿狠癇稈繝艱諫鶫齦")
+ ("rkf"        "介喝渇葛褐掲丐曷碣竭羯蝎鞨頡")
+ ("rka"        "勘堪感憾敢柑甘監鑑欠鹸減紺凵坎坩嵌戡撼橄歉淦疳瞰緘蚶轗酣鑒龕")
+ ("rkq"        "押蓋甲合岬匣盖胛閘")
+ ("rkd"        "岡橿強彊慶康控江糠綱腔講鋼降剛虹亢僵啌姜崗慷扛杠棡疆矼絳繦羌薑襁跫鱇")
+ ("ro" "佳箇介解改皆芥開階凱咳慨概蓋鎧個丐个价剴愾懈揩楷漑疥盖觧")
+ ("ror"        "客喀")
+ ("rod"        "坑更粳羹羮鏗")
+ ("ri" "茄")
+ ("rir"        "醵")
+ ("rj" "去居巨拒拠渠距鋸車据裾俥倨墟據擧舉欅炬秬筥苣踞遽醵鉅")
+ ("rjs"        "乾巾件健建鍵愆搴腱虔謇蹇騫")
+ ("rjf"        "渇掲傑乞担桝偈杰桀气竭")
+ ("rja"        "柑倹剣検鹸儉劍劔劒剱檢瞼臉黔")
+ ("rjq"        "笈怯劫拾刧")
+ ("rp" "憩掲偈憇碣")
+ ("rur"        "仮格隔革撃激假挌檄膈茖覡闃骼鬲鴃鵙")
+ ("rus"        "樫鰹堅牽犬絹肩見遣縛繭鑓俔幵悁枅狷甄筧羂譴鵑")
+ ("ruf"        "桔契決潔結訣孟决抉拮挈缺髻")
+ ("rua"        "鎌兼謙慊拑歉箝蒹鉗")
+ ("ruq"        "恰頬慊鋏")
+ ("rud"        "京競卿境鏡驚傾径慶敬景経茎荊警軽頚鯨庚更梗硬耕頃亰竸冂冏剄勁勍哽徑憬檠煢瓊畊痙磬絅經綮耿脛莖謦輕逕竟頸黥")
+ ("rP" "戒械界階季係啓契桂渓稽系継繋計鶏堺届屆彑悸枅溪畍癸禊笄綮繼薊誡谿髻鷄")
+ ("rh" "苦古固姑孤庫故枯袴股菰鈷雇顧鼓稿考膏高拷告皐縞尻叩藁估凅刳呱攷敲杲柧桍栲槁槹沽痼皋睾瞽稾箍罟羔胯蛄蠱觚詁誥賈辜錮靠鴣鵁皷")
+ ("rhr"        "曲告穀酷鵠谷硲哭斛梏槲轂髷")
+ ("rhs"        "困坤昆梱混壼崑悃棍滾菎褌鯀鯤鶤")
+ ("rhf"        "滑骨榾汨鶻")
+ ("rhd"        "供共恐恭空公功孔工控攻貢倥廾拱椌槓箜蚣蛩蛬跫鞏")
+ ("rhk"        "瓜寡科果菓課過袴誇跨鍋堝夥夸戈胯萪蝌裹踝顆")
+ ("rhkr"       "廓郭擴攫椁槨癨矍钁霍")
+ ("rhks"       "冠官寛慣棺款潅管莞観貫関館舘串菅丱冦毋灌盥綸綰罐觀鑵關鸛")
+ ("rhkf"       "括活筈桧刮檜聒")
+ ("rhkd"       "拡匡狂光広鉱砿壙廣擴曠昿框洸礦筐筺絋絖胱誑鑛")
+ ("rho"        "掛卦罫咼戈挂枴褂")
+ ("rhl"        "会塊壊怪恢拐魁乖傀壞恠愧槐瑰詼")
+ ("rhlr"       "膕馘")
+ ("rhld"       "宏紘肱轟浤軣鍠")
+ ("ry" "撹覚較噛糾僑叫喬教橋矯蕎交佼孝巧校絞郊酵鮫招咬嬌攪敲橇澆狡皎磽窖翹膠蛟轎釖餃驕驍")
+ ("rn" 
"臼厩欧殴鴎鈎亀丘久仇救求灸球究旧拒九倶句区狗玖矩躯駆駈駒具粂勾口垢拘構溝購叩韮鳩釦傴冓劬區咎嘔媾嫗寇嶇廐廏怐惧懼扣搆柩枸歐毆毬甌疚瞿窶篝舅舊苟蒟蚯衢裘覯詬謳逑遘邱鉤韭颶馗驅鬮齲龜")
+ ("rnr"        "掬菊鞠局麹国囗國椈鬻鞫跼")
+ ("rns"        "君群軍郡桾皸皹窘羣裙")
+ ("rnf"        "屈掘窟堀倔厥崛")
+ ("rnd"        "宮弓窮穹躬")
+ ("rnjs"       "勧巻挙倦券圏拳捲権劵勸卷圈惓椦權眷綣蜷顴")
+ ("rnjf"       "掘蕨亅厥獗蹶闕")
+ ("rnp"        "机帰軌凧潰几匱椢櫃歸皈簣臾詭跪蹶餽饋")
+ ("rnl"        "帰貴鬼亀喟椢歸皈龜")
+ ("rnlr"       "掴幗")
+ ("rb" "葵窺規糾叫九圭珪頃槻奎揆摎樛癸硅竅糺繆袿赳逵閨馗鬮")
+ ("rbs"        "亀均菌箘鈞麕龜")
+ ("rbf"        "橘")
+ ("rmr"        "可革極劇戟隙克亟剋尅屐棘蕀郤")
+ ("rms"        "僅勤巾斤筋芹謹近根懃槿瑾矜菫覲釿饉")
+ ("rmf"        "契訖")
+ ("rma"        "錦琴禁禽衿襟金檎今噤擒衾黔")
+ ("rmq"        "扱及急汲笈級給岌")
+ ("rmd"        "恒肯亙亘兢恆矜")
+ ("rl" 
"磯企伎器基奇寄岐幾忌旗既期棋棄機気汽畿祈紀記起飢騎妓技欺祇居祁己碁乞崎埼碕示其肌鰭箕亟俟冀剞嗜噐圻竒嵜弃掎旡曁朞杞枳棊榿气氣沂淇畸祺稘綺羈羇耆覊覬譏豈跂饑騏驥鮨麒")
+ ("rlr"        "喫")
+ ("rls"        "緊")
+ ("rlf"        "吉桔詰佶拮")
+ ("rla"        "金")
+ ("Rlr"        "喫")
+ ("sk" "奈那難儺娜懦扨拏拿梛糯")
+ ("skr"        "諾")
+ ("sks"        "暖難攤煖赧")
+ ("skf"        "捺捏涅")
+ ("ska"        "男南楠喃娚遖")
+ ("skq"        "納衲")
+ ("skd"        "嚢娘曩")
+ ("so" "耐奈内匂乃廼能迺")
+ ("sid"        "嬢孃")
+ ("su" "女拏拿茹")
+ ("sus"        "年撚碾輾")
+ ("suf"        "捏涅")
+ ("sua"        "念恬拈棯")
+ ("suq"        "摂捻攝躡鑷")
+ ("sud"        "寧嚀濘獰聹")
+ ("sP" "禰昵")
+ ("sh" "努奴怒脳呶孥帑弩瑙碯腦臑駑")
+ ("shd"        "濃膿農儂")
+ ("shk"        "雫")
+ ("shl"        "悩脳惱腦餒")
+ ("sy" "溺尿嫋撓橈鐃閙鬧")
+ ("sn" "耨")
+ ("sns"        "嫩")
+ ("snf"        "吶肭訥")
+ ("sb" "紐忸狃鈕")
+ ("sbr"        "忸衄衂")
+ ("smd"        "能")
+ ("sl" "泥尼禰祢怩濔瀰膩")
+ ("slr"        "溺匿")
+ ("slf"        "尼怩昵")
+ ("sla"        "賃恁")
+ ("ek" "多大茶夛")
+ ("eks"        "円但丹単担旦短端箪胆蛋鍛団壇断檀段椴敦亶單團彖愽慱斷槫湍猯疸緞葮蜑袒襌褝鄲鶉")
+ ("ekf"        "達咄妲怛撻燵獺逹闥靼韃")
+ ("eka"        "担淡湛耽談曇啖啗壜憺擔毯潭澹痰眈膽蕁覃譚餤")
+ ("ekq"        "沓搭答踏剳荅")
+ ("ekd"        "党唐塘当糖堂撞儻幢档棠溏當瞠礑螳蟷襠鐺黨")
+ ("eo" "碓対岱帯待戴袋貸隊黛代大敦垈對帶擡抬玳臺薹鐓隶")
+ ("ejr"        "徳悳")
+ ("eh" "稲図挑跳堵塗屠徒渡菟賭途都鍍度倒刀島嶋悼桃梼盗淘涛祷到逃陶導萄道叨圖嶌掏掉搗擣朷檮棹櫂盜濤滔睹稻絛綢綯纛荼莵覩跿蹈迯闍韜饕")
+ ("ehr"        "竺涜督禿篤毒独読牘犢獨纛讀髑黷")
+ ("ehs"        "純噸惇敦沌豚遁頓暾燉瓲遯飩")
+ ("ehf"        "突頓咄柮")
+ ("ehd"        "諌桐冬凍東棟董働動同憧洞瞳童胴銅僮橦潼疼粡艟苳鮗鶇鼕")
+ ("en" "吋兜逗斗杜土痘豆頭読亠抖竇肚荳蚪蠹蠧讀酘鬥")
+ ("ens"        "屯遁頓鈍臀遯")
+ ("emr"        "得")
+ ("emd"        "登灯燈等藤謄鐙騰嶝橙滕疼磴籐籘縢")
+ ("fk" "刺羅螺裸喇懶瘰癩蘿邏鑼陏騾")
+ ("fkr"        "格楽洛絡落酪咯樂烙犖珞駱")
+ ("fks"        "乱卵欄蘭亂嬾欒瀾燗爛襴鑾闌鸞")
+ ("fkf"        "剌喇埒埓糲辣")
+ ("fka"        "嵐濫藍覧儖婪攬欖籃繿纜襤覽醂")
+ ("fkq"        "摺蝋拉柆臘臈鑞")
+ ("fkd"        "滝瀧廊朗榔浪狼郎朖琅瑯莨螂跟踉")
+ ("fo" "來徠")
+ ("fod"        "冷")
+ ("fir"        "掠略擽畧")
+ ("fid"        "椋掠亮両梁涼糧良諒量倆兩凉喨粱粮裲跟踉輛輌魎")
+ ("fu" "芦蛎砺麿侶慮旅励麗呂録儷勵唳廬梠櫚犂犁癘礪糲絽綟膂臚茘藜蘆蠣蠡鑢閭驢驪")
+ ("fur"        "力暦歴屶朸櫟檪櫪瀝癧礫轢轣靂鬲")
+ ("fus"        "怜零恋憐漣煉練聯蓮連錬嗹戀揀攣楝聨臠輦鏈鰊")
+ ("fuf"        "列劣烈裂冽捩洌")
+ ("fua"        "鎌廉簾匳奩斂濂瀲")
+ ("fuq"        "猟獵鬣")
+ ("fud"        "領令伶嶺怜玲苓鈴零霊齢囹櫺澪羚聆蛉靈鴒齡")
+ ("fP" "豊例礼隷禮茘醴隸鱧")
+ ("fh" "芦鷺櫨蕗虜魯櫓炉賂路露労牢老勞咾撈枦滷潦濾瀘爐癆盧艪艫舮蘆輅轤鑪鈩顱驢鱸鹵")
+ ("fhr"        "角漉鹿谷緑麓禄録梺碌祿轆")
+ ("fhs"        "論淪")
+ ("fhd"        "滝瀧竜龍弄篭聾哢垰壟朧槞瓏籠蘢隴")
+ ("fhl"        "瀬頼雷塁賂儡壘擂櫑癩磊籟罍耒蕾藾誄賚")
+ ("fy" "了僚寮料療瞭遼寥廖撩暸燎繚聊蓼醪鐐鷯")
+ ("fyd"        "竜龍蘢")
+ ("fn" "屡涙累婁楼漏僂樓犂犁瘻簍縷縲螻褸鏤陋髏")
+ ("fnl"        "涙泪")
+ ("fb" "謬柳劉流溜琉留硫瑠塁累類勠嚠壘廖旒榴泪瀏璢瘤繆縲茆鉚鏐霤餾")
+ ("fbr"        "陸六勠戮蓼")
+ ("fbs"        "倫輪論侖崙崘棆淪綸")
+ ("fbf"        "栗律率葎慄篥")
+ ("fbd"        "隆嶐窿")
+ ("fmr"        "肋仂勒")
+ ("fma"        "凛廩懍菻")
+ ("fmd"        "綾菱睦凌稜陵崚楞蔆薐")
+ ("fl" "浬鯉糎狸提哩利吏履李梨理璃痢裏裡里離厘麗俚俐悧罹漓犂犁竰籬羸莅莉蜊蠡詈貍釐驪魑鯏黐")
+ ("fls"        "燐隣鱗麟吝悋藺躙躪鄰")
+ ("fla"        "林淋琳臨痳霖")
+ ("flq"        "笠立粒苙")
+ ("ak" "罵馬摩磨魔麻嘛媽麼瑪痲碼蟇蟆")
+ ("akr"        "漠莫貌幕膜摸寞藐")
+ ("aks"        "鰻挽晩蛮娩万慢満漫蔓湾卍曼巒幔彎弯懣滿灣瞞縵萬蠻謾蹣輓鏝饅鬘")
+ ("akf"        "抹末沫眛秣茉襪靺韈")
+ ("akd"        "亡忘忙望妄網惘网罔芒茫莽蠎蟒鋩魍")
+ ("ao" "罵媒梅楳煤買売呆某埋妹昧枚毎魅寐瑁苺莓賣邁霾")
+ ("aor"        "莫麦百脈獏脉貊貘陌驀麥")
+ ("aod"        "虻萌盟猛盲儚氓甍萠黽")
+ ("aur"        "冖冪幎汨羃覓")
+ ("aus"        "勉眠免棉綿緬面麺俛冕宀湎眄瞑緜麪")
+ ("auf"        "蔑滅")
+ ("aud"        "皿冥名命明銘鳴暝榠溟瞑茗螟酩黽")
+ ("aP" "袂")
+ ("ah" "姥牡茅莫侮募墓慕暮母帽某冒謀貌鉾膜粍牟矛摸模毛耗姆旄獏瑁瓱皃眸竓糢耄冐莽謨髦鴾")
+ ("ahr"        "匹牧穆木目凩朷沐繆苜鶩")
+ ("ahf"        "没勿歿沒")
+ ("ahd"        "夢蒙冢梦曚朦檬濛矇艨")
+ ("ay" "卯畝猫廟描秒苗錨墓妙杳昴渺眇緲茆藐")
+ ("an" "畝謬撫武舞蕪戊母亡某謀貿務無牟矛霧鵡茂姆巫廡憮懋拇无楙眸繆莽袤誣")
+ ("anr"        "冒墨万黙默冐")
+ ("ans"        "蚊吻文聞娩免問紋門匁們刎悗懣捫紊")
+ ("anf"        "物勿")
+ ("al" "梶謎尾微眉美米味未迷弥媚嵋弭彌濔瀰糜縻薇躾麋靡黴")
+ ("als"        "敏民悶岷愍憫旻泯緡罠閔黽")
+ ("alf"        "密蜜樒謐")
+ ("qkr"        "狛剥博拍泊箔粕舶薄迫爆駁簿撲朴亳搏摶樸溥珀璞膊雹駮魄鰒")
+ ("qks"        "伴半反叛搬斑班畔繁般頒飯盤磐扮返弁拌攀槃潘瘢竝絆胖蟠襷蹣")
+ ("qkf"        "鉢溌発醗髪抜勃孛悖拔撥渤癶發秡跋髮魃")
+ ("qkd"        "倣放方芳訪邦傍坊妨房棒紡肪防匚厖尨幇彭彷旁枋榜滂磅竝膀舫蒡蚌謗錺髣魴")
+ ("qo" "俳拝排杯盃背輩配倍培賠陪白北坏徘憊拜湃焙琲胚裴")
+ ("qor"        "栢覇伯拍柏白舶百佰帛霸珀瓸竡粨魄")
+ ("qjs"        "幡反繁藩煩番蕃翻旛旙樊潘燔礬繙飜膰袢鐇鷭")
+ ("qjf"        "伐罰筏閥罸")
+ ("qja"        "帆氾汎犯範凡梵泛笵范")
+ ("qjq"        "法琺")
+ ("qur"        "副幅僻壁癖碧劈擘檗璧甓薜襞躄辟闢霹")
+ ("qus"        "釆変編辺便弁来辨卞扁抃變汳辮胼褊諞辯邊邉駢")
+ ("quf"        "批閉別瞥丿暼鼈")
+ ("qud"        "病浜瓶丙併兵柄並餅屏并枋榜炳秉竝絣迸餠駢")
+ ("qh" "捗鴇埠普父譜保歩甫補輔菩報宝堡寶寳葆褓鞴黼")
+ ("qhr"        "伏副復幅服福腹複覆僕卜撲匐攴攵樸殕濮箙茯蔔蝠蝮袱蹼輻輹馥鰒")
+ ("qhs"        "本夲賁")
+ ("qhd"        "逢汎封俸奉峰峯捧縫蓬蜂鋒鳳棒泛烽笂篷")
+ ("qn" 
"釜缶蔀専培否不付埠夫婦富冨府扶敷斧浮父符腐膚芙負賦赴阜附撫部伏副復複覆簿報剖仆俘俯傅咐嘸坿孚孵抔拊枹柎桴榑殕溥罘腑艀苻蜉訃賻趺輻郛釡鳧鳬麩麸黼")
+ ("qnr"        "北")
+ ("qns"        "体頒匪分噴墳憤扮焚奮粉糞紛雰奔盆吩忿枌氛汾濆犇瓰畚竕笨芬賁")
+ ("qnf"        "不弗払沸仏佛彿怫拂朏狒祓髴黻")
+ ("qnd"        "棚鮒崩朋鵬堋弸硼繃")
+ ("qmr"        "匐")
+ ("ql" "轡匪卑否妃庇悲扉批斐比泌碑秘緋肥誹費非飛備枇毘琵鼻沸箆丕俾匕嚊妣婢屁憊朏榧狒痞痺睥砒祕秕篦粃糒紕羆翡脾腓臂菲蓖蜚裨譬貔豼賁贔鄙隗霏鞁鞴髀鯡")
+ ("qls"        "鋲彬斌瀕貧賓頻牝嬪擯檳殯濱繽蘋顰鬢")
+ ("qld"        "氷冫冰凭娉憑聘馮騁")
+ ("tk" 
"卸献些唆沙砂詐鎖裟咋仕伺使司史嗣四士師思斯死獅私糸詞賜飼事似寺璽辞舎写射捨赦斜社紗謝蛇邪食笥乍覗巳蓑貰亊俟冩厶嗄奢娑寫徙柤梭槎泗洒渣瀉灑犧獻畭祀祠竢篩簑簔絲耜肆舍莎乕辭釶鉈駟駛鯊鰤麝")
+ ("tkr"        "削朔索数嗽數槊爍鑠")
+ ("tks"        "傘山撒散珊産算酸蒜刪杣汕疝繖跚閂閊")
+ ("tkf"        "殺薩撒蔡")
+ ("tka"        "三参森杉參彡滲糂纔罧芟蔘衫")
+ ("tkq"        "扱渋挿插歃澁澀霎颯")
+ ("tkd"        "桑向傷償商嘗尚床湘祥裳詳象賞上常状双喪爽想相霜像滝瀧湯峠橡箱様雙嫦孀庠廂慯樣殤牀甞翔裃觴謫鱶")
+ ("to" "塞璽洒灑腮賽顋鰓")
+ ("tor"        "塞咋索色嗇愬槭穡薔")
+ ("tod"        "甥省牲生猩笙")
+ ("tid"        "餉")
+ ("tj" "黍犀暑曙庶緒署書薯藷叙序徐恕鋤瑞棲栖西誓逝鼠挑婿舒噬墅壻嶼抒敍敘筮絮耡聟胥黎鼡")
+ ("tjr"        "潟汐射釈錫席惜昔析石碩夕淅皙蓆蜥螫裼釋鉐")
+ ("tjs"        "還蝉仙先宣扇撰洗煽旋線羨腺船選銑鮮善禅繕膳単亘僊單嬋尠愃洒燹癬禪綫譱舩蘚跣霰")
+ ("tjf"        "洩屑契折設説雪舌鱈苫囓挈楔泄渫紲絏緤薛褻齧")
+ ("tja"        "繊閃孅暹歙殲殱笘纖纎蟾譫贍銛")
+ ("tjq"        "拾渉摺摂燮囁慴懾攝聶躡鑷顳")
+ ("tjd"        "省城姓性成星盛聖声誠醒惺晟猩筬聲腥")
+ ("tp" "歳細笹世勢税説洗貰彗洒蛻")
+ ("th" "鯵繰咲篠所召哨宵小少昭梢沼消焼硝笑紹肖鞘塑疏疎素蘇訴遡掃掻巣燥騒蛸疋劭嘯嫂愬梳樔毟泝溯瀟燒甦筱簫艘蔬蕭蘓譟踈逍邵釖銷霄韶騷鮹鰺")
+ ("thr"        "粟束速俗属続屬續謖贖")
+ ("ths"        "餐孫損遜巽")
+ ("thf"        "率蟀")
+ ("thd"        "松訟宋送悚枩淞竦舂蚣誦鎹頌鬆")
+ ("thkf"       "刷")
+ ("tho"        "鎖砕刷殺晒洒灑瑣碎")
+ ("thl"        "粋衰夊")
+ ("tn" 
"守手殊狩首受寿授樹綬需囚収修愁秀繍蒐讐酬獣宿須垂帥水睡遂随瑞髄数捜痩袖竪誰嬬穂薮輸率叟售嗾嗽埀壽嫂岫戍搜收數殳泅洙溲漱燧獸祟穗籔粹綉綏繻羞脩隋膸茱莎蓚藪雖讎豎隨酥銖銹鏥陲隧髓鬚")
+ ("tnr"        "叔夙宿淑縮粛塾熟俶孰倏肅菽蓿")
+ ("tns"        "瞬舜駿循旬楯殉淳盾純巡醇順馴徇恂洵筍笋脣荀蓴蕣詢諄鐓鶉")
+ ("tnf"        "術述率恤戌朮")
+ ("tnd"        "崇嵩菘")
+ ("tnl"        "倅伜淬")
+ ("tmf"        "膝瑟虱蝨")
+ ("tmq"        "湿拾習襲濕褶隰")
+ ("tmd"        "勝升承昇丞乗剰僧縄蝿乘剩甸枡繩蠅陞")
+ ("tl" "飴柿匙殺使始屍市施視詩試侍寺時示蒔偲柴是提矢厮啻嗜嘶尸屎廝弑恃撕猜翅腮舐葹蓍諡豕豺顋")
+ ("tlr"        "喰式識埴飾拭植殖食蝕息寔熄軾餝")
+ ("tls"        "榊伸信娠慎新申神紳臣薪身辛腎訊迅辰矧噺呻哂宸愼抻晨燼蜃贐頤鰰")
+ ("tlf"        "失室悉実實榁蟋")
+ ("tla"        "参審心深芯尋甚參忱椹沁潯瀋蕈鐔")
+ ("tlq"        "拾什十渋辻卅丗澁澀瓧竍籵")
+ ("Tkd"        "双雙")
+ ("Tl" "氏")
+ ("dk" "亜唖阿俄峨我牙芽蛾雅餓涯御児亞兒哦娥婀峩椏猗痾莪衙襾訝錏鐚鴉鵝鵞")
+ ("dkr"        "亜悪握渥岳楽顎鍔鰐亞咢堊嶽幄惡愕樂萼蕚葯諤鄂鶚齷齶")
+ ("dks"        "安按案鞍岸眼贋雁顔諺偐晏殷顏鮟鴈鳫")
+ ("dkf"        "斡按謁戛戞蘗蘖歹訐軋遏閼靄")
+ ("dka"        "庵暗闇厭俺巌癌岩嵒巖菴諳頷黯黶")
+ ("dkq"        "姶圧押鴨哈壓狎")
+ ("dkd"        "央仰昂怏殃泱秧鞅鴦")
+ ("do" "哀愛挨崖涯碍喝啀嗄噫埃崕曖欸皚睚瞹磑礙艾藹阨隘靄靉饐")
+ ("dor"        "液額夜厄扼掖腋軛阨隘")
+ ("dod"        "嚶櫻罌鶯鸚")
+ ("di" "射斜邪若惹埜也冶夜爺耶野揶椰鵺")
+ ("dir"        "鰯若弱約薬躍嫋搦籥葯蒻藥鑰鶸龠")
+ ("did"        "詳壌嬢穣譲醸揚楊様洋羊陽養佯壤孃恙攘昜暘樣漾瀁煬痒瘍癢禳穰襄讓釀驤")
+ ("dj" "於漁禦魚御語唹圄圉淤飫馭鯲齬")
+ ("djr"        "億憶臆疑抑檍")
+ ("djs"        "堰言諺這彦偃嫣焉篶")
+ ("djf"        "蘗蘖")
+ ("dja"        "奄掩俺巌岩験厳儼厂嚴巖广淹罨閹驗")
+ ("djq"        "業")
+ ("dp" "恚殪")
+ ("du" "汝如予余与誉輿預豫歟洳畭絮舁與茹蕷蜍譽餘")
+ ("dur"        "易域疫駅逆射亦役訳懌繹蜴譯閠閾霓驛鯣")
+ ("dus"        "咽宴延沿演煙燕縁鉛研硯次然鳶軟燃淵吮嚥妍娟悁捐掾椽櫞衍涓涎渊烟筵臙莚蜒蠕讌")
+ ("duf"        "咽悦閲説熱吶噎齧")
+ ("dua"        "厭炎焔艶塩染稔冉檐艷苒閻髯魘鯰鹽黶")
+ ("duq"        "厭葉囁曄靨")
+ ("dud"        "営嬰影映栄永泳瑛盈穎頴英詠景迎咏營塋佞侫暎楹榮潁瀛瑩瓔珱纓蠑贏郢霙")
+ ("dP" "医叡曳洩鋭刈詣芸児蕊誉預乂豫倪兒兌囈曵泄猊睨睿穢翳艾蘂蕋藝蚋裔譽貎霓鯢麑")
+ ("dh" "悪烏迂於汚奥襖五伍午呉吾娯悟梧誤傲唔嗚嗷塢墺奧媼寤忤惡懊敖晤澳熬燠牾珸蜈螯遨鏖鰲鼇")
+ ("dhr"        "阿屋玉獄沃")
+ ("dhs"        "温穏慍瘟穩薀蘊褞鰮鰛")
+ ("dhf"        "兀榲膃")
+ ("dhd"        "翁擁壅廱瓮甕癰禺蓊雍鶲")
+ ("dhk"        "娃渦臥蛙瓦窪哇囮窩萵蝸訛譌")
+ ("dhks"       "宛完緩莞関玩翫頑椀碗腕婉浣澣蜿豌關")
+ ("dhkf"       "曰")
+ ("dhkd"       "往旺王皇尢徃枉汪")
+ ("dho"        "娃蛙倭哇矮蝸")
+ ("dhl"        "畏外隈嵬巍猥磑薈鮠")
+ ("dy" "凹楽尭腰擾銚陶約妖揺曜窯耀要謡遥僥夭姚嬲嫐嶢幺徭徼拗搖撓樂橈殀澆燿瑶窈窰繞蕘蟯謠遶邀饒鷂堯遙瑤")
+ ("dyr"        "辱谷慾欲浴峪溽縟蓐褥")
+ ("dyd"        "桶茸勇湧涌傭容庸溶熔用蓉踊俑慂慵榕甬聳舂蛹踴鎔頌")
+ ("dn" "芋右宇羽迂雨欧殴牛区愚虞偶寓遇隅枢又尤佑優友憂祐郵于傴吁吽嵎樞歐毆疣盂禹禺紆肬藕謳麌齲")
+ ("dnr"        "旭郁勗墺澳燠")
+ ("dns"        "員韻云運雲暈殞熕紜耘隕韵")
+ ("dnf"        "宛尉欝蔚鬱熨")
+ ("dnd"        "熊雄")
+ ("dnjs"       "宛員院園怨援猿苑薗遠鴛垣願元原源媛冤圓圜婉寃愿湲爰芫蜿袁諢轅鋺阮隕")
+ ("dnjf"       "越月戉曰粤鉞")
+ ("dnl"        "葦位偉囲委威尉慰為緯胃萎謂違蔚衛危偽倭僞喟囗圍幃渭爲痿縅莠蝟衞逶韋魏")
+ ("db" "惟維遺桜儒柔嬬酉楢肉乳濡鮪愉愈油癒諭輸唯宥幽悠有柚猶猷由裕誘遊幼侑兪喩囿孺帷懦揉揄攸楡渝游瑜瘉糅綏腴臾萸蕕蚰蝓蝣蠕襦覦諛蹂踰逾釉鍮鞣黝鼬")
+ ("dbr"        "育粥肉囿毓鬻")
+ ("dbs"        "允胤閏潤尹贇酳")
+ ("dbf"        "聿鴪")
+ ("dbd"        "戎融絨")
+ ("dms"        "隠恩銀听圻垠慇憖殷犹隱齦")
+ ("dmf"        "乙疑")
+ ("dma"        "飲淫蔭陰音疑吟吽婬崟飮霪")
+ ("dmq"        "泣揖邑悒")
+ ("dmd"        "応疑凝鷹蝿應膺蠅軅軈")
+ ("dml"        "依意椅衣涯毅儀宜擬疑義蟻誼議歪倚崕嶬嶷懿欹熨猗矣礒縊艤醫饐")
+ ("dl" "飴以伊夷易異移餌施爾而耳蛇食詑台弛寅二迩弍姨尓已彝彜怡洟珥甅痍肄苡詒貽貳貮轜邇隶")
+ ("dlr"        "益翌翼嶷弋杙翊謚鷁")
+ ("dls"        "印咽因姻引煙人仁刃靭寅忍認籾仞仭儿刄堙孕廴氤湮烟茵荵蚓靱")
+ ("dlf"        "一壱溢逸日弌佚壹衵釼鎰")
+ ("dla"        "荏壬賃任妊稔姙恁衽袵")
+ ("dlq"        "込廿入叺圦鳰")
+ ("dld"        "剰仍剩孕")
+ ("wk" "梓茨佐左査剤作仔刺姉姿子孜紫諮資雌字慈滋磁自煮者斉積柘髭偖劑呰咨孳恣滓炙瓷疵眥眦粢苴茲蔗藉薺觜貲齎赭鮓鷓齊")
+ ("wkr"        "作昨勺杓灼爵酌酢雀嚼妁寉斫柞炸筰綽芍醋鵲")
+ ("wks"        "桟残孱戔棧殘潺盞")
+ ("wka"        "蚕暫潜湛岑潛濳箴簪蠶賺鏨")
+ ("wkq"        "雑匝挿喋囃插箚襍雜")
+ ("wkd"        "匠奨将庄掌樟章粧蒋醤障丈場杖状壮荘葬装臓蔵帳張腸長撞仗塲墻壯奘奬妝將嶂弉橦檣淙漿爿牆獎璋瘴膓臟臧艢莊萇薔藏裝贓賍鏘鱆")
+ ("wo" "再哉宰才災斎裁載在材財柴斉存滓齋縡纔豺齎齊")
+ ("wod"        "噌槍争鎗崢幀爭瞠箏筝諍錚")
+ ("wj" "姐且杵煮渚藷諸鋤除岨狙樗瀦猪苧著貯低底抵邸屠這箸儲佇咀弖抒杼柢楮沮潴牴疽砠竚紵羝耡苴蛆觝詆豬躇雎齟")
+ ("wjr"        "荻借寂積籍績赤跡蹟賊逐嫡弔吊摘敵滴的笛適鏑躍勣廸炙狄癪磧糴芍藉覿迪迹逖")
+ ("wjs"        
"鴫竣戦栓栴煎箭詮銭前全揃樽佃典填展纏転顛伝殿澱田電縛畑槙淀傳剪甸吮囀奠專巓廛悛戔戰畋旃氈沺濺牋甎痊癜癲磚筌箋篆纒羶翦腆趁躔輾轉鈿銓錢鐫雋靦顫餞饌鷆鷏槇")
+ ("wjf"        "準切拙折窃節絶窒姪凖卩咥截晢晰浙竊耋跌軼")
+ ("wja"        "鮎占漸店点苫粘岾簟霑黏點")
+ ("wjq"        "接蝶慴椄楫楪沾渫聶鰈")
+ ("wjd"        
"井鯖晶証鉦情浄錠征政整正精静打丁町頂亭停偵貞呈定庭廷挺汀碇禎程艇訂鄭釘鼎瀞柾靖淀丼叮幀掟旌梃淨渟甼疔睛穽聢菁蟶逞遉酊酲鐺霆靜")
+ ("wp" "鵜栽済祭際剤諸除制製斉折第醍題堤帝弟悌提梯蹄俤儕劑擠晢濟眥眦睇臍薺齎躋霽齏韲齊")
+ ("wh" 
"竃繰錯惨篠助昭照詔条岨措祖租粗組阻操早曹槽漕燥糟藻遭造鯛兆凋弔彫朝潮眺調跳銚鳥蔦爪吊釣敦蚤肇佻俎嘲噪徂慘慥懆找抓晁條梍棗棹澡爼砠祚稠窕竈笊糶絛罩耡胙艚蜩詛誂譟趙躁鑿雕髞")
+ ("whr"        "足族簇蔟鏃")
+ ("whs"        "尊拵")
+ ("whf"        "拙卒枠卆猝")
+ ("whd"        "種腫宗終従縦鍾鐘綜柊从從慫棕椶樅淙粽縱螽踵蹤踪鑁")
+ ("whk"        "佐左坐座挫")
+ ("whl"        "罪")
+ ("wy" "釖")
+ ("wn" "株作主朱珠酒呪周州洲舟週住祝厨奏走足族宙昼柱注註酎鋳駐調紬肘湊丶侏做儔冑嗾廚晝疇畴稠籌籀紂綢胄蔟蛛誅赱躊輳遒鑄麈")
+ ("wnr"        "粥竹鬻")
+ ("wns"        "噂俊峻竣駿準純遵屯隼鱒儁凖墫恂悛惷浚濬皴蠢蹲逡")
+ ("wnd"        "衆重中仲")
+ ("wmr"        "即賊")
+ ("wmf"        "櫛")
+ ("wma"        "怎")
+ ("wmq"        "輯汁葺揖楫緝")
+ ("wmd"        "絵甑症証蒸噌曾曽増憎贈徴拯橙烝證")
+ ("wl" "岐祇志指支旨枝止祉紙肢脂至誌持識質芝織只知地智池蜘遅漬底抵砥之咫址塒帋弖摯枳沚痣祗耆胝舐觝貭贄趾踟躓輊遲阯鮨鷙")
+ ("wlr"        "織職直喞稙稷")
+ ("wls"        "唇振晋榛疹真秦診進震塵尽陣辰珍鎮陳津填賑侭儘嗔晉殄燼珎甄畛盡眞瞋縉臻蓁袗趁軫鎭")
+ ("wlf"        "叱嫉疾質秩窒迭蛭姪佚咥喞垤帙桎耋膣腟貭跌軼")
+ ("wla"        "朕斟酖鴆")
+ ("wlq"        "執輯集汁緝")
+ ("wld"        "澄徴懲澂")
+ ("ck" "且此叉嵯差瑳車遮借詫侘嗟岔嵳扠搓朿槎磋箚苴蹉釵")
+ ("ckr"        "搾窄錯昔捉濁着著戳縒躇鑿齣齪")
+ ("cks"        "燦纂讃賛餐撰簒攅爨竄粲纉讚贊鏨鑽鑚饌")
+ ("ckf"        "察拶擦札刹扎獺紮")
+ ("cka"        "参惨斬漸僭僣參塹嶄巉慘慙慚懺懴槧站譖譛讒讖驂")
+ ("ckd"        "唱娼廠彰昌菖椙創倉槍窓蒼暢脹畠倡剏厰悵愴搶敞昶淌滄漲猖瘡窗艙蹌鬯")
+ ("co" "差債彩採采砦祭菜柴責莱寨綵蔡豸釵靫")
+ ("cor"        "咋柵窄策冊責措册嘖拆柞磔筴簀")
+ ("cj" "妻処凄狙處悽淒絮萋")
+ ("cjr"        "刺尺隻戚斥脊捗剔呎彳擲滌瘠蜴跖蹐蹠躑陟鶺")
+ ("cjs"        "茜粁串釧蚕千川撰泉浅穿舛薦賎践遷辿天仟倩刋喘巛擅栫楾淺湶濺瓩竏荐賤踐闡阡韆")
+ ("cjf"        "綴哲徹撤轍鉄凸畷啜屮掣輟銕錣鐵鐡餮")
+ ("cja"        "鹸尖添甜僉忝恬槧檐沾瞻簷簽籤籖蟾覘諂譫")
+ ("cjq"        "妾捷畳喋帖牒諜貼疊疉疂睫褶輒輙")
+ ("cjd"        "鯖錆晴清請青庁聴廳廰聽菁蜻")
+ ("cp" "切体替滞逮綴剃締諦逓薙畷啼嚔嚏掣楴涕滯睇砌蒂蔕裼躰軆遞靆體髢")
+ ("ch" "鍬初哨抄招樵焦硝礁肖蕉鞘酢楚礎草超銚秒剿劭勦屮峭悄愀憔杪椒湫炒稍艸誚貂迢醋鈔髫鷦齠")
+ ("chr"        "趣嘱燭触数促属囑屬數矗矚簇蜀觸躅鏃髑")
+ ("chs"        "吋寸村忖邨")
+ ("chd"        "従銃叢惣総聡寵塚憧葱竜龍从偬匆從怱愡總縱聰")
+ ("chl"        "催最崔摧榱洒")
+ ("cn" "穐丑鰍取趣就愁秋臭酋醜出諏推錐錘枢趨雛粗畜抽墜椎槌追鎚萩鷲啾娵婢帚惆掫捶楸樞湫甃皺龝箒簇縋聚芻蒭鄒陬隹鞦騅驟鰌麁")
+ ("cnr"        "丑竺軸蹴祝縮築畜筑蓄逐柚槭舳蹙")
+ ("cns"        "春椿鰆")
+ ("cnf"        "出朮黜")
+ ("cnd"        "沖充銃衝忠虫衷傭冲狆艟蟲")
+ ("cnp"        "悴忰惴瘁萃贅")
+ ("cnl"        "取趣就臭吹炊翠酔脆鷲嘴娶惴揣橇毳瘁翆聚膵萃觜醉驟")
+ ("cmr"        "側則測捗仄惻昃")
+ ("cms"        "齔")
+ ("cma"        "闖")
+ ("cmd"        "曾曽層")
+ ("cl" "嵯差歯治痔埴植織値恥痴稚置致馳徴直薙侈卮厠嗤夂峙巵幟廁梔熾畄畤癡碪穉笞紕緇緻耻蚩褫豸跂輜錙雉魑鯔鴟鵄黹齒")
+ ("clr"        "則測勅飭厠廁惻敕")
+ ("cls"        "親襯齔")
+ ("clf"        "七漆")
+ ("cla"        "砧侵寝浸針湛沈枕寢忱斟椹鍼鍖闖駸")
+ ("clq"        "蟄")
+ ("cld"        "称秤稱袮騁")
+ ("cho"        "快夬獪")
+ ("xk" "蛇他詑唾堕妥惰打柁舵楕陀駄騨池詫佗咤墮它捶揣朶橢沱隋躱駝鴕")
+ ("xkr"        "卓啄托拓沢濯琢託鐸濁擢度倬啅拆柝澤鈬魄")
+ ("xks"        "騨嘆坦歎炭綻誕弾呑灘彈憚攤殫袒")
+ ("xkf"        "奪脱")
+ ("xka"        "探耽眈貪")
+ ("xkq"        "塔搭搨榻鞜鞳鰈")
+ ("xkd"        "宕湯糖蕩帑盪蝪")
+ ("xo" "税太汰怠態泰胎苔逮台大能殆戻兌棣笞紿蛻詒颱駘")
+ ("xor"        "宅択沢擇澤")
+ ("xh" "兎吐菟土套討兔莵")
+ ("xhs"        "褪")
+ ("xhd"        "桶痛通筒統樋恫慟")
+ ("xhl"        "推堆腿退槌追鎚敦褪頽")
+ ("xn" "妬投透闘愉偸綉鍮骰鬪")
+ ("xmr"        "貸特慝")
+ ("vk" "頗巴把播杷波派琶破婆芭罷簸坡怕擺霸爬玻碆笆耙膰菠葩袙跛陂")
+ ("vks"        "坂阪判板版販辧汳瓣鈑")
+ ("vkf"        "捌八叭杁釟")
+ ("vo" "唄貝派敗牌背倍狽抜罷稗佩孛悖拔旆霸沛珮霈")
+ ("vod"        "棚烹傍膨弸彭旁澎磅繃")
+ ("vir"        "愎")
+ ("vus"        "平偏片篇編遍便鞭扁翩苹蝙褊諞騙")
+ ("vua"        "貶")
+ ("vud"        "坪評浜平怦泙硼苹萍鮃")
+ ("vP" "柿廃肺幣弊蔽閉陛吠嬖幤廢敝斃癈薜髀")
+ ("vh" "浦鞄蒲曝爆布怖葡舗鋪圃捕包庖抱泡砲胞褒飽暴勹匍匏咆哺垉抛枹瀑炮疱皰脯舖苞袍襃逋鉋靤餔髱鮑鯆麭")
+ ("vhr"        "曝爆幅暴瀑")
+ ("vy" "杓俵彪標漂瓢票表豹剽嫖慓殍縹飄飃飆驃驫髟鰾")
+ ("vns"        "分")
+ ("vna"        "品稟禀")
+ ("vnd"        "楓風豊瘋諷豐颪馮")
+ ("vb" "彪")
+ ("vl" "彼披疲皮罷被避跛辟陂")
+ ("vlf"        "嘩比泌匹疋弼必畢筆払仏佛拂篳譁蹕鵯")
+ ("vlq"        "逼幅乏泛")
+ ("gk" "下何夏河荷蝦霞賀嚇雫厦呀廈渮瑕緞罅訶谺遐鍜鰕")
+ ("gkr"        "鴬学虐鶴壑學斈涸狢瘧謔貉鷽")
+ ("gks"        "寒汗漢翰閑韓限恨嫺嫻悍扞捍旱桿瀚狠皖罕邯駻骭鼾")
+ ("gkf"        "害割喝轄劼瞎蝎黠")
+ ("gka"        "艦陥含函濫凾咸啣喊嵌檻涵緘莟邯銜陷頷餡鰔鹹")
+ ("gkq"        "蓋閤合蛤呷哈溘盍盖盒葢闔鴿")
+ ("gkd"        "桁巷恒抗杭港航行降項虹亢伉吭恆缸肛閧頏鬨")
+ ("go" "亥解械海蟹劾咳害該骸鮭偕垓夥奚孩廨懈楷薤蠏觧諧邂醢駭")
+ ("gor"        "劾核硅覈輅")
+ ("god"        "杏倖幸行絎裄鵆")
+ ("gid"        "享郷響饗向香嚮餉")
+ ("gj" "嘘虚許墟栩歔滸")
+ ("gjs"        "憲献軒掀獻")
+ ("gjf"        "歇蝎蠍")
+ ("gja"        "険験嶮險驗")
+ ("gur"        "嚇赫革恵奕洫鬩")
+ ("gus"        "絢懸県見賢顕弦玄現絃舷項頁俔呟洵痃眩縣蜆衒鉉顯")
+ ("guf"        "穴血冗頁孟孑襭頡")
+ ("gua"        "嫌")
+ ("guq"        "袷叶侠協峡挟狭脅頬脇夾峽慊挾浹狹筴篋莢鋏陜陝")
+ ("gud"        "馨亨刑兄型形荊蛍桁衡夐炯烱瑩脛螢迥")
+ ("gP" "慧繋兮匸奚彗惠盻禊蹊醯鞋")
+ ("gh" "穫乎呼弧戸湖狐糊胡虎雇互吾瑚護醐好浩号壕濠豪冴皐縞壷冱壺怙戲昊晧楜毫沍滬滸犒琥瓠皋皓葫蒿虍號蝴扈鎬餬")
+ ("ghr"        "或酷鵠惑寉斛")
+ ("ghs"        "婚昏昆混魂棍棔渾溷焜琿")
+ ("ghf"        "核忽惚歿笏鶻")
+ ("ghq"        "恰")
+ ("ghd"        "弘洪紅鴻哄汞泓訌閧鬨")
+ ("ghk"        "化火禍禾花華貨画椛樺靴樗和話啝崋畫糀錵")
+ ("ghkr"       "拡獲確穫擴攫癨矍蠖霍")
+ ("ghks"       "喚患換桓歓環還丸幻亘圜奐宦寰懽歡渙湲煥皖眩矜讙豢鐶驩鬟鰥")
+ ("ghkf"       "越活滑撮猾磆蛞豁闊濶")
+ ("ghkd"       "黄況兄慌晃皇荒幌况凰徨恍惶晄湟滉煌篁簧肓蝗遑隍鰉")
+ ("gho"        "画罫獪畫")
+ ("ghl"        "会回壊廻悔恢懐晦灰准桧賄會囘匯壞徊懷檜槐淮繪膾茴薈蛔詼誨迴鱠")
+ ("ghlr"       "画劃獲畫")
+ ("ghld"       "横弘衡轟薨軣鍠黌")
+ ("gy" "暁佼効校酵肴傚哮嚆囂效曉梟淆烋爻驕驍")
+ ("gn" "芋朽後侯候厚后喉佝吼嗅嘔涸煦猴篌詬逅")
+ ("gns"        "勲薫訓馴勳熏燻葷醺")
+ ("gnd"        "薨")
+ ("gnjs"       "萱喧暖愃暄萓諠讙")
+ ("gnp"        "虫卉喙毀燬")
+ ("gnl"        "揮徽輝彙戲暉麾諱")
+ ("gb" "休携畦畜攜烋虧貅")
+ ("gbr"        "畜")
+ ("gbf"        "恤譎鷸")
+ ("gbd"        "兇凶胸匈恟洶")
+ ("gmr"        "黒釛")
+ ("gms"        "欣痕很忻掀釁")
+ ("gmf"        "汽吃迄屹訖")
+ ("gma"        "欽欠")
+ ("gmq"        "吸歙洽皀翕")
+ ("gmd"        "興虹")
+ ("gml"        "喜嬉希稀戯犠姫僖咥唏噫愾憙戲晞曦欷煕熈熹燹犧禧羲釐鯑")
+ ("glf"        "詰纈襭頡黠")
+ ("unknown"    
"苅宍栂栃凪弐塀俣杢刔夘咒哘唸囎圀圷圸垳垪埔埖埣塰堽墹墸壗壥嬶屓乢妛岫岻岶岼峅峇峺嵶彁怺恷恊抂挧掵擶暃杤桙梹椥椨椪椚椣椡槝樮櫁樌橲樶橸樢檸欟歛汢渕淕溂潸澑犲畉畆畩蘯眤瞶硴碚碵礇禝穃邃笶筅箟篏簓簗籏粐粭粫糘綛縺繧纃緕纐罎膤艝茣莇菷萢蒄蓙蘰蚫蛯蟐袞袰褄諚戝轌辷迚逧逎鍄錻閇閖陦隲靹鞆鞐饂馼駲鮖鮴鯒鯱鰄鰡鱚鵈鵤鵐"))
 
 ;;; hanja-jis.el ends here
diff --git a/lisp/leim/quail/hanja.el b/lisp/leim/quail/hanja.el
index 01843ac..9c6dfc8 100644
--- a/lisp/leim/quail/hanja.el
+++ b/lisp/leim/quail/hanja.el
@@ -1,6 +1,6 @@
 ;;; hanja.el --- Quail-package for Korean Hanja (KSC5601)  -*-coding: utf-8;-*-
 
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 ;;   2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/leim/quail/hanja3.el b/lisp/leim/quail/hanja3.el
index fe82f20..1f829df 100644
--- a/lisp/leim/quail/hanja3.el
+++ b/lisp/leim/quail/hanja3.el
@@ -1,6 +1,6 @@
 ;;; hanja3.el --- Quail-package for Korean Hanja (KSC5601)  -*-coding: 
utf-8;-*-
 
-;; Copyright (C) 1997, 1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1999, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Koaunghi Un <address@hidden>
 ;; Keywords: mule, quail, multilingual, input method, Korean, Hanja
diff --git a/lisp/leim/quail/indian.el b/lisp/leim/quail/indian.el
index 69a346b..b6c1b94 100644
--- a/lisp/leim/quail/indian.el
+++ b/lisp/leim/quail/indian.el
@@ -1,6 +1,6 @@
 ;;; indian.el --- Quail packages for inputting Indian
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: KAWABATA, Taichi <address@hidden>
 
diff --git a/lisp/leim/quail/ipa-praat.el b/lisp/leim/quail/ipa-praat.el
index 9a5c24f..74a2dcc 100644
--- a/lisp/leim/quail/ipa-praat.el
+++ b/lisp/leim/quail/ipa-praat.el
@@ -1,6 +1,6 @@
 ;;; ipa-praat.el --- Inputting IPA characters with the conventions of Praat
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Oliver Scholz <address@hidden>
 ;; Keywords: multilingual, input method, IPA
diff --git a/lisp/leim/quail/ipa.el b/lisp/leim/quail/ipa.el
index fd9a05b..3c4c914 100644
--- a/lisp/leim/quail/ipa.el
+++ b/lisp/leim/quail/ipa.el
@@ -1,6 +1,6 @@
 ;;; ipa.el --- Quail package for inputting IPA characters  -*-coding: utf-8;-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 ;;   2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/leim/quail/japanese.el b/lisp/leim/quail/japanese.el
index f8735cd..d536b5e 100644
--- a/lisp/leim/quail/japanese.el
+++ b/lisp/leim/quail/japanese.el
@@ -1,6 +1,6 @@
-;;; japanese.el --- Quail package for inputting Japanese  -*-coding: 
iso-2022-7bit;-*-
+;;; japanese.el --- Quail package for inputting Japanese
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 ;;   2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -31,7 +31,7 @@
 (require 'kkc)
 
 (defvar quail-japanese-use-double-n nil
-  "If non-nil, use type \"nn\" to insert $B$s(B.")
+  "If non-nil, use type \"nn\" to insert ん.")
 
 ;; Update Quail translation region while considering Japanese bizarre
 ;; translation rules.
@@ -47,14 +47,14 @@
                 (setq quail-current-str (aref quail-current-key 0)
                       control-flag t))
                ((= (aref quail-current-key 0) ?n)
-                (setq quail-current-str ?$B$s(B)
+                (setq quail-current-str ?ん)
                 (if (and quail-japanese-use-double-n
                          (> keylen 0)
                          (= (aref quail-current-key 1) ?n))
                     (setq control-flag t)))
                ((and (> keylen 1)
                      (= (aref quail-current-key 0) (aref quail-current-key 1)))
-                (setq quail-current-str ?$B$C(B))
+                (setq quail-current-str ?っ))
                (t
                 (setq quail-current-str (aref quail-current-key 0))))
          (if (integerp control-flag)
@@ -84,10 +84,10 @@
 (defun quail-japanese-kanji-kkc ()
   (interactive)
   (when (= (char-before (overlay-end quail-conv-overlay)) ?n)
-    ;; The last char is `n'.  We had better convert it to `$B$s(B'
+    ;; The last char is `n'.  We had better convert it to `ん'
     ;; before kana-kanji conversion.
     (goto-char (1- (overlay-end quail-conv-overlay)))
-    (insert ?$B$s(B)
+    (insert ?ん)
     (delete-char 1))
   (let* ((from (copy-marker (overlay-start quail-conv-overlay)))
         (len (- (overlay-end quail-conv-overlay) from)))
@@ -135,113 +135,113 @@
   (throw 'quail-tag nil))
 
 (defvar quail-japanese-transliteration-rules
-  '(( "a" "$B$"(B") ( "i" "$B$$(B") ( "u" "$B$&(B") ( "e" "$B$((B") ( 
"o" "$B$*(B")
-    ("ka" "$B$+(B") ("ki" "$B$-(B") ("ku" "$B$/(B") ("ke" "$B$1(B") 
("ko" "$B$3(B")
-    ("sa" "$B$5(B") ("si" "$B$7(B") ("su" "$B$9(B") ("se" "$B$;(B") 
("so" "$B$=(B")
-    ("ta" "$B$?(B") ("ti" "$B$A(B") ("tu" "$B$D(B") ("te" "$B$F(B") 
("to" "$B$H(B")
-    ("na" "$B$J(B") ("ni" "$B$K(B") ("nu" "$B$L(B") ("ne" "$B$M(B") 
("no" "$B$N(B")
-    ("ha" "$B$O(B") ("hi" "$B$R(B") ("hu" "$B$U(B") ("he" "$B$X(B") 
("ho" "$B$[(B")
-    ("ma" "$B$^(B") ("mi" "$B$_(B") ("mu" "$B$`(B") ("me" "$B$a(B") 
("mo" "$B$b(B")
-    ("ya" "$B$d(B")             ("yu" "$B$f(B")             ("yo" 
"$B$h(B")
-    ("ra" "$B$i(B") ("ri" "$B$j(B") ("ru" "$B$k(B") ("re" "$B$l(B") 
("ro" "$B$m(B")
-    ("la" "$B$i(B") ("li" "$B$j(B") ("lu" "$B$k(B") ("le" "$B$l(B") 
("lo" "$B$m(B")
-    ("wa" "$B$o(B") ("wi" "$B$p(B") ("wu" "$B$&(B") ("we" "$B$q(B") 
("wo" "$B$r(B")
-    ("n'" "$B$s(B")
-    ("ga" "$B$,(B") ("gi" "$B$.(B") ("gu" "$B$0(B") ("ge" "$B$2(B") 
("go" "$B$4(B")
-    ("za" "$B$6(B") ("zi" "$B$8(B") ("zu" "$B$:(B") ("ze" "$B$<(B") 
("zo" "$B$>(B")
-    ("da" "address@hidden(B") ("di" "$B$B(B") ("du" "$B$E(B") ("de" 
"$B$G(B") ("do" "$B$I(B")
-    ("ba" "$B$P(B") ("bi" "$B$S(B") ("bu" "$B$V(B") ("be" "$B$Y(B") 
("bo" "$B$\(B")
-    ("pa" "$B$Q(B") ("pi" "$B$T(B") ("pu" "$B$W(B") ("pe" "$B$Z(B") 
("po" "$B$](B")
-
-    ("kya" ["$B$-$c(B"]) ("kyu" ["$B$-$e(B"]) ("kye" ["$B$-$'(B"]) 
("kyo" ["$B$-$g(B"])
-    ("sya" ["$B$7$c(B"]) ("syu" ["$B$7$e(B"]) ("sye" ["$B$7$'(B"]) 
("syo" ["$B$7$g(B"])
-    ("sha" ["$B$7$c(B"]) ("shu" ["$B$7$e(B"]) ("she" ["$B$7$'(B"]) 
("sho" ["$B$7$g(B"])
-    ("cha" ["$B$A$c(B"]) ("chu" ["$B$A$e(B"]) ("che" ["$B$A$'(B"]) 
("cho" ["$B$A$g(B"])
-    ("tya" ["$B$A$c(B"]) ("tyu" ["$B$A$e(B"]) ("tye" ["$B$A$'(B"]) 
("tyo" ["$B$A$g(B"])
-    ("nya" ["$B$K$c(B"]) ("nyu" ["$B$K$e(B"]) ("nye" ["$B$K$'(B"]) 
("nyo" ["$B$K$g(B"])
-    ("hya" ["$B$R$c(B"]) ("hyu" ["$B$R$e(B"]) ("hye" ["$B$R$'(B"]) 
("hyo" ["$B$R$g(B"])
-    ("mya" ["$B$_$c(B"]) ("myu" ["$B$_$e(B"]) ("mye" ["$B$_$'(B"]) 
("myo" ["$B$_$g(B"])
-    ("rya" ["$B$j$c(B"]) ("ryu" ["$B$j$e(B"]) ("rye" ["$B$j$'(B"]) 
("ryo" ["$B$j$g(B"])
-    ("lya" ["$B$j$c(B"]) ("lyu" ["$B$j$e(B"]) ("lye" ["$B$j$'(B"]) 
("lyo" ["$B$j$g(B"])
-    ("gya" ["$B$.$c(B"]) ("gyu" ["$B$.$e(B"]) ("gye" ["$B$.$'(B"]) 
("gyo" ["$B$.$g(B"])
-    ("zya" ["$B$8$c(B"]) ("zyu" ["$B$8$e(B"]) ("zye" ["$B$8$'(B"]) 
("zyo" ["$B$8$g(B"])
-    ("jya" ["$B$8$c(B"]) ("jyu" ["$B$8$e(B"]) ("jye" ["$B$8$'(B"]) 
("jyo" ["$B$8$g(B"])
-    ( "ja" ["$B$8$c(B"]) ( "ju" ["$B$8$e(B"]) ( "je" ["$B$8$'(B"]) ( 
"jo" ["$B$8$g(B"])
-    ("bya" ["$B$S$c(B"]) ("byu" ["$B$S$e(B"]) ("bye" ["$B$S$'(B"]) 
("byo" ["$B$S$g(B"])
-    ("pya" ["$B$T$c(B"]) ("pyu" ["$B$T$e(B"]) ("pye" ["$B$T$'(B"]) 
("pyo" ["$B$T$g(B"])
-
-    ("kwa" ["$B$/$n(B"]) ("kwi" ["$B$/$#(B"]) ("kwe" ["$B$/$'(B"]) 
("kwo" ["$B$/$)(B"])
-    ("tsa" ["$B$D$!(B"]) ("tsi" ["$B$D$#(B"]) ("tse" ["$B$D$'(B"]) 
("tso" ["$B$D$)(B"])
-    ( "fa" ["$B$U$!(B"]) ( "fi" ["$B$U$#(B"]) ( "fe" ["$B$U$'(B"]) ( 
"fo" ["$B$U$)(B"])
-    ("gwa" ["$B$0$n(B"]) ("gwi" ["$B$0$#(B"]) ("gwe" ["$B$0$'(B"]) 
("gwo" ["$B$0$)(B"])
-
-    ("dyi" ["$B$G$#(B"]) ("dyu" ["$B$I$%(B"]) ("dye" ["$B$G$'(B"]) 
("dyo" ["$B$I$)(B"])
-    ("xwi" ["$B$&$#(B"])                  ("xwe" ["$B$&$'(B"]) ("xwo" 
["$B$&$)(B"])
-
-    ("shi" "$B$7(B") ("tyi" ["$B$F$#(B"]) ("chi" "$B$A(B") ("tsu" 
"$B$D(B") ("ji" "$B$8(B")
-    ("fu"  "$B$U(B")
-    ("ye" ["$B$$$'(B"])
-
-    ("va" ["$B%t$!(B"]) ("vi" ["$B%t$#(B"]) ("vu" "$B%t(B") ("ve" 
["$B%t$'(B"]) ("vo" ["$B%t$)(B"])
-
-    ("xa"  "$B$!(B") ("xi"  "$B$#(B") ("xu"  "$B$%(B") ("xe"  
"$B$'(B") ("xo"  "$B$)(B")
-    ("xtu" "$B$C(B") ("xya" "$B$c(B") ("xyu" "$B$e(B") ("xyo" 
"$B$g(B") ("xwa" "$B$n(B")
-    ("xka" "$B%u(B") ("xke" "$B%v(B")
-
-    ("1" "$B#1(B") ("2" "$B#2(B") ("3" "$B#3(B") ("4" "$B#4(B") ("5" 
"$B#5(B")
-    ("6" "$B#6(B") ("7" "$B#7(B") ("8" "$B#8(B") ("9" "$B#9(B") ("0" 
"$B#0(B")
-
-    ("!" "$B!*(B") ("@" "$B!w(B") ("#" "$B!t(B") ("$" "$B!p(B") ("%" 
"$B!s(B")
-    ("^" "$B!0(B") ("&" "$B!u(B") ("*" "$B!v(B") ("(" "$B!J(B") (")" 
"$B!K(B")
-    ("-" "$B!<(B") ("=" "$B!a(B") ("`" "$B!.(B") ("\\" "$B!o(B") ("|" 
"$B!C(B")
-    ("_" "$B!2(B") ("+" "$B!\(B") ("~" "$B!1(B") ("[" "$B!V(B") ("]" 
"$B!W(B")
-    ("{" "$B!P(B") ("}" "$B!Q(B") (":" "$B!'(B") (";" "$B!((B") ("\""  
"$B!I(B")
-    ("'" "$B!G(B") ("." "$B!#(B") ("," "$B!"(B") ("<" "$B!c(B") (">" 
"$B!d(B")
-    ("?" "$B!)(B") ("/" "$B!?(B")
-
-    ("z1" "$B!{(B") ("z!" "$B!|(B")
-    ("z2" "$B"&(B") ("z@" "$B"'(B")
-    ("z3" "$B"$(B") ("z#" "$B"%(B")
-    ("z4" "$B""(B") ("z$" "$B"#(B")
-    ("z5" "$B!~(B") ("z%" "$B"!(B")
-    ("z6" "$B!y(B") ("z^" "$B!z(B")
-    ("z7" "$B!}(B") ("z&" "$B!r(B")
-    ("z8" "$B!q(B") ("z*" "$B!_(B")
-    ("z9" "$B!i(B") ("z(" "$B!Z(B")
-    ("z0" "$B!j(B") ("z)" "$B![(B")
-    ("z-" "$B!A(B") ("z_" "$B!h(B")
-    ("z=" "$B!b(B") ("z+" "$B!^(B")
-    ("z\\" "address@hidden(B") ("z|" "$B!B(B")
-    ("z`" "$B!-(B") ("z~" "$B!/(B")
-
-    ("zq" "$B!T(B") ("zQ" "$B!R(B")
-    ("zw" "$B!U(B") ("zW" "$B!S(B")
-    ("zr" "$B!9(B") ("zR" "$B!8(B")
-    ("zt" "$B!:(B") ("zT" "$B!x(B")
-    ("zp" "$B")(B") ("zP" "$B",(B")
-    ("z[" "$B!X(B") ("z{" "$B!L(B")
-    ("z]" "$B!Y(B") ("z}" "$B!M(B")
-
-    ("zs" "$B!3(B") ("zS" "$B!4(B")
-    ("zd" "$B!5(B") ("zD" "$B!6(B")
-    ("zf" "$B!7(B") ("zF" "$B"*(B")
-    ("zg" "$B!>(B") ("zG" "$B!=(B")
-    ("zh" "$B"+(B")
-    ("zj" "$B"-(B")
-    ("zk" "$B",(B")
-    ("zl" "$B"*(B")
-    ("z;" "$B!+(B") ("z:" "$B!,(B")
-    ("z'" "$B!F(B") ("z\"" "$B!H(B")
+  '(( "a" "あ") ( "i" "い") ( "u" "う") ( "e" "え") ( "o" "お")
+    ("ka" "か") ("ki" "き") ("ku" "く") ("ke" "け") ("ko" "こ")
+    ("sa" "さ") ("si" "し") ("su" "す") ("se" "せ") ("so" "そ")
+    ("ta" "た") ("ti" "ち") ("tu" "つ") ("te" "て") ("to" "と")
+    ("na" "な") ("ni" "に") ("nu" "ぬ") ("ne" "ね") ("no" "の")
+    ("ha" "は") ("hi" "ひ") ("hu" "ふ") ("he" "へ") ("ho" "ほ")
+    ("ma" "ま") ("mi" "み") ("mu" "む") ("me" "め") ("mo" "も")
+    ("ya" "や")             ("yu" "ゆ")             ("yo" "よ")
+    ("ra" "ら") ("ri" "り") ("ru" "る") ("re" "れ") ("ro" "ろ")
+    ("la" "ら") ("li" "り") ("lu" "る") ("le" "れ") ("lo" "ろ")
+    ("wa" "わ") ("wi" "ゐ") ("wu" "う") ("we" "ゑ") ("wo" "を")
+    ("n'" "ん")
+    ("ga" "が") ("gi" "ぎ") ("gu" "ぐ") ("ge" "げ") ("go" "ご")
+    ("za" "ざ") ("zi" "じ") ("zu" "ず") ("ze" "ぜ") ("zo" "ぞ")
+    ("da" "だ") ("di" "ぢ") ("du" "づ") ("de" "で") ("do" "ど")
+    ("ba" "ば") ("bi" "び") ("bu" "ぶ") ("be" "べ") ("bo" "ぼ")
+    ("pa" "ぱ") ("pi" "ぴ") ("pu" "ぷ") ("pe" "ぺ") ("po" "ぽ")
+
+    ("kya" ["きゃ"]) ("kyu" ["きゅ"]) ("kye" ["きぇ"]) ("kyo" ["きょ"])
+    ("sya" ["しゃ"]) ("syu" ["しゅ"]) ("sye" ["しぇ"]) ("syo" ["しょ"])
+    ("sha" ["しゃ"]) ("shu" ["しゅ"]) ("she" ["しぇ"]) ("sho" ["しょ"])
+    ("cha" ["ちゃ"]) ("chu" ["ちゅ"]) ("che" ["ちぇ"]) ("cho" ["ちょ"])
+    ("tya" ["ちゃ"]) ("tyu" ["ちゅ"]) ("tye" ["ちぇ"]) ("tyo" ["ちょ"])
+    ("nya" ["にゃ"]) ("nyu" ["にゅ"]) ("nye" ["にぇ"]) ("nyo" ["にょ"])
+    ("hya" ["ひゃ"]) ("hyu" ["ひゅ"]) ("hye" ["ひぇ"]) ("hyo" ["ひょ"])
+    ("mya" ["みゃ"]) ("myu" ["みゅ"]) ("mye" ["みぇ"]) ("myo" ["みょ"])
+    ("rya" ["りゃ"]) ("ryu" ["りゅ"]) ("rye" ["りぇ"]) ("ryo" ["りょ"])
+    ("lya" ["りゃ"]) ("lyu" ["りゅ"]) ("lye" ["りぇ"]) ("lyo" ["りょ"])
+    ("gya" ["ぎゃ"]) ("gyu" ["ぎゅ"]) ("gye" ["ぎぇ"]) ("gyo" ["ぎょ"])
+    ("zya" ["じゃ"]) ("zyu" ["じゅ"]) ("zye" ["じぇ"]) ("zyo" ["じょ"])
+    ("jya" ["じゃ"]) ("jyu" ["じゅ"]) ("jye" ["じぇ"]) ("jyo" ["じょ"])
+    ( "ja" ["じゃ"]) ( "ju" ["じゅ"]) ( "je" ["じぇ"]) ( "jo" ["じょ"])
+    ("bya" ["びゃ"]) ("byu" ["びゅ"]) ("bye" ["びぇ"]) ("byo" ["びょ"])
+    ("pya" ["ぴゃ"]) ("pyu" ["ぴゅ"]) ("pye" ["ぴぇ"]) ("pyo" ["ぴょ"])
+
+    ("kwa" ["くゎ"]) ("kwi" ["くぃ"]) ("kwe" ["くぇ"]) ("kwo" ["くぉ"])
+    ("tsa" ["つぁ"]) ("tsi" ["つぃ"]) ("tse" ["つぇ"]) ("tso" ["つぉ"])
+    ( "fa" ["ふぁ"]) ( "fi" ["ふぃ"]) ( "fe" ["ふぇ"]) ( "fo" ["ふぉ"])
+    ("gwa" ["ぐゎ"]) ("gwi" ["ぐぃ"]) ("gwe" ["ぐぇ"]) ("gwo" ["ぐぉ"])
+
+    ("dyi" ["でぃ"]) ("dyu" ["どぅ"]) ("dye" ["でぇ"]) ("dyo" ["どぉ"])
+    ("xwi" ["うぃ"])                  ("xwe" ["うぇ"]) ("xwo" ["うぉ"])
+
+    ("shi" "し") ("tyi" ["てぃ"]) ("chi" "ち") ("tsu" "つ") ("ji" "じ")
+    ("fu"  "ふ")
+    ("ye" ["いぇ"])
+
+    ("va" ["ヴぁ"]) ("vi" ["ヴぃ"]) ("vu" "ヴ") ("ve" ["ヴぇ"]) ("vo" ["ヴぉ"])
+
+    ("xa"  "ぁ") ("xi"  "ぃ") ("xu"  "ぅ") ("xe"  "ぇ") ("xo"  "ぉ")
+    ("xtu" "っ") ("xya" "ゃ") ("xyu" "ゅ") ("xyo" "ょ") ("xwa" "ゎ")
+    ("xka" "ヵ") ("xke" "ヶ")
+
+    ("1" "1") ("2" "2") ("3" "3") ("4" "4") ("5" "5")
+    ("6" "6") ("7" "7") ("8" "8") ("9" "9") ("0" "0")
+
+    ("!" "!") ("@" "@") ("#" "#") ("$" "$") ("%" "%")
+    ("^" "^") ("&" "&") ("*" "*") ("(" "(") (")" ")")
+    ("-" "ー") ("=" "=") ("`" "`") ("\\" "¥") ("|" "|")
+    ("_" "_") ("+" "+") ("~" " ̄") ("[" "「") ("]" "」")
+    ("{" "{") ("}" "}") (":" ":") (";" ";") ("\""  "”")
+    ("'" "’") ("." "。") ("," "、") ("<" "<") (">" ">")
+    ("?" "?") ("/" "/")
+
+    ("z1" "○") ("z!" "●")
+    ("z2" "▽") ("z@" "▼")
+    ("z3" "△") ("z#" "▲")
+    ("z4" "□") ("z$" "■")
+    ("z5" "◇") ("z%" "◆")
+    ("z6" "☆") ("z^" "★")
+    ("z7" "◎") ("z&" "£")
+    ("z8" "¢") ("z*" "×")
+    ("z9" "♂") ("z(" "【")
+    ("z0" "♀") ("z)" "】")
+    ("z-" "〜") ("z_" "∴")
+    ("z=" "≠") ("z+" "±")
+    ("z\\" "\") ("z|" "‖")
+    ("z`" "´") ("z~" "¨")
+
+    ("zq" "《") ("zQ" "〈")
+    ("zw" "》") ("zW" "〉")
+    ("zr" "々") ("zR" "仝")
+    ("zt" "〆") ("zT" "§")
+    ("zp" "〒") ("zP" "↑")
+    ("z[" "『") ("z{" "〔")
+    ("z]" "』") ("z}" "〕")
+
+    ("zs" "ヽ") ("zS" "ヾ")
+    ("zd" "ゝ") ("zD" "ゞ")
+    ("zf" "〃") ("zF" "→")
+    ("zg" "‐") ("zG" "—")
+    ("zh" "←")
+    ("zj" "↓")
+    ("zk" "↑")
+    ("zl" "→")
+    ("z;" "゛") ("z:" "゜")
+    ("z'" "‘") ("z\"" "“")
 
     ("zx" [":-"]) ("zX" [":-)"])
-    ("zc" "$B!;(B") ("zC" "$B!n(B")
-    ("zv" "$B"((B") ("zV" "$B!`(B")
-    ("zb" "$B!k(B") ("zB" "$B"+(B")
-    ("zn" "$B!l(B") ("zN" "$B"-(B")
-    ("zm" "$B!m(B") ("zM" "$B".(B")
-    ("z," "$B!E(B") ("z<" "$B!e(B")
-    ("z." "$B!D(B") ("z>" "$B!f(B")
-    ("z/" "$B!&(B") ("z?" "$B!g(B")
+    ("zc" "〇") ("zC" "℃")
+    ("zv" "※") ("zV" "÷")
+    ("zb" "°") ("zB" "←")
+    ("zn" "′") ("zN" "↓")
+    ("zm" "″") ("zM" "〓")
+    ("z," "‥") ("z<" "≦")
+    ("z." "…") ("z>" "≧")
+    ("z/" "・") ("z?" "∞")
 
     ("\\\\" quail-japanese-self-insert-and-switch-to-alpha)
     ("{{" quail-japanese-self-insert-and-switch-to-alpha)
@@ -252,81 +252,81 @@
     ))
 
 
-;; $B%m!<%^;zF~NO5Z$S2>L>4A;zJQ49$K$h$kF|K\8lF~NO%a%=%C%I(B
+;; ローマ字入力及び仮名漢字変換による日本語入力メソッド
 ;;
-;; $B$3$NF~NO%a%=%C%I$G$NF|K\8l$NF~NO$OFs$D$N%9%F!<%8!V%m!<%^;z2>L>JQ49!W(B
-;; $B$H!V2>L>4A;zJQ49!W$+$i$J$k!#:G=i$O%m!<%^;z2>L>JQ49$N%9%F!<%8$G!"%9(B
-;; $B%Z!<%9%-!<$r2!$9$3$H$K$h$j!"<!$N%9%F!<%8!V2>L>4A;zJQ49!W$X?J$`!#(B
+;; この入力メソッドでの日本語の入力は二つのステージ「ローマ字仮名変換」
+;; と「仮名漢字変換」からなる。最初はローマ字仮名変換のステージで、ス
+;; ペースキーを押すことにより、次のステージ「仮名漢字変換」へ進む。
 ;;
-;; $B!V%m!<%^;z2>L>JQ49!W(B
+;; 「ローマ字仮名変換」
 ;;
-;; $BJ?2>L>$O>.J8;z%-!<address@hidden"3g8LN`$OBP1~(B
-;; $B$9$k1Q;z%-!<$rBG$D$3$H$K$h$jF~NO!#$=$NB>$N%7%s%\%k$O(B `z' 
$B$KB3$1$F2?(B
-;; $B$l$+$N%-!<$rBG$D$3$H$K$h$jF~NO!#2<$KA4$F$N2DG=$J%-!<%7!<%1%s%9%j%9(B
-;; $B%H%"%C%W$5$l$F$$$k!#F~NO$5$l$?J8;z$O2<@~$G<($5$l$k!#(B
+;; 平仮名は小文字キー(列)を打つことにより入力。句読点、括弧類は対応
+;; する英字キーを打つことにより入力。その他のシンボルは `z' に続けて何
+;; れかのキーを打つことにより入力。下に全ての可能なキーシーケンスリス
+;; トアップされている。入力された文字は下線で示される。
 ;;
-;; $B$5$i$K0J2<$N%-!<$GFCJL$J=hM}$r9T$&!#(B
+;; さらに以下のキーで特別な処理を行う。
 ;;
-;; K   $BJ?2>L>$rJR2>L>$K!"$"$k$$$OJR2>L>$rJ?2>L>$KJQ49(B
-;; qq  $B$3$NF~NO%a%=%C%I$H(B `japanese-ascii' address@hidden(B
-;; qz  `japanese-zenkaku' $BF~NO%a%=%C%I$K%7%U%H(B
-;;     qh $B$HBG$F$P85$KLa$k(B
-;; RET $B8=:_$NF~NOJ8;zNs$r3NDj(B
-;; SPC $B2>L>4A;zJQ49$K?J$`(B
+;; K   平仮名を片仮名に、あるいは片仮名を平仮名に変換
+;; qq  この入力メソッドと `japanese-ascii' 入力メソッドをトグル切替
+;; qz  `japanese-zenkaku' 入力メソッドにシフト
+;;     qh と打てば元に戻る
+;; RET 現在の入力文字列を確定
+;; SPC 仮名漢字変換に進む
 ;;
-;; `japanese-ascii' $BF~NO%a%=%C%I$O(B ASCII 
$BJ8;z$rF~NO$9$k$N$K;H$&!#$3$l(B
-;; $B$OF~NO%a%=%C%I$r%*%U$K$9$k$N$H$[$H$s$IF1$8$G$"$k!#0[$J$k$N$O(B qq 
$B$H(B
-;; $BBG$D$3$H$K$h$j!"(B`japanese' address@hidden"$k!#(B
+;; `japanese-ascii' 入力メソッドは ASCII 文字を入力するのに使う。これ
+;; は入力メソッドをオフにするのとほとんど同じである。異なるのは qq と
+;; 打つことにより、`japanese' 入力メソッドに戻れる点である。
 ;;
-;; `japanese-zenkaku' $BF~NO%a%=%C%I$OA43Q1Q?t;z$rF~NO$9$k$N$K;H$&!#(B
+;; `japanese-zenkaku' 入力メソッドは全角英数字を入力するのに使う。
 ;;
-;; $B!V%m!<%^;z2>L>JQ49!W%9%F!<%8$G$N%-!<%7!<%1%s%9$N%j%9%H$O:G8e$KIU$1(B
-;; $B$F$"$k!#(B
+;; 「ローマ字仮名変換」ステージでのキーシーケンスのリストは最後に付け
+;; てある。
 ;;
-;; $B!V2>L>4A;zJQ49!W(B
+;; 「仮名漢字変換」
 ;;
-;; $B$3$N%9%F!<%8$G$O!"A0%9%F!<%8$GF~NO$5$l$?J8;zNs$r2>L>4A;zJQ49$9$k!#(B
-;; $BJQ49$5$l$?J8;zNs$O!"address@hidden>I=<(!K$H;D$j$NF~NO!J2<@~I=<(!K$K(B
-;; $BJ,address@hidden<$N%3%^%s%I$,;H$($k!#(B
+;; このステージでは、前ステージで入力された文字列を仮名漢字変換する。
+;; 変換された文字列は、注目文節(反転表示)と残りの入力(下線表示)に
+;; 分けられる。注目文節に対しては以下のコマンドが使える。
 ;;
 ;; SPC, C-n    kkc-next
-;;     $B<!$NJQ498uJd$rI=<((B
-;;     kkc-show-conversion-list-count $B0J>eB3$1$FBG$F$P!"JQ498uJd%j%9(B
-;;     $B%H$r%(%3!<%(%j%"$KI=<((B
+;;     次の変換候補を表示
+;;     kkc-show-conversion-list-count 以上続けて打てば、変換候補リス
+;;     トをエコーエリアに表示
 ;; C-p         kkc-prev
-;;     $BA0$NJQ498uJd$rI=<((B
-;;     kkc-show-conversion-list-count $B0J>eB3$1$FBG$F$P!"JQ498uJd%j%9(B
-;;     $B%H$r%(%3!<%(%j%"$KI=<((B
+;;     前の変換候補を表示
+;;     kkc-show-conversion-list-count 以上続けて打てば、変換候補リス
+;;     トをエコーエリアに表示
 ;; l           kkc-show-conversion-list-or-next-group
-;;     $B:G9b#1#08D$^$G$NJQ498uJd$r%(%3!<%(%j%"$KI=<(!#(B
-;;     $BB3$1$FBG$?$l$l$P!"<!$N#1#08uJd$rI=<(!#(B
+;;     最高10個までの変換候補をエコーエリアに表示。
+;;     続けて打たれれば、次の10候補を表示。
 ;; L           kkc-show-conversion-list-or-prev-group
-;;     $B:G9b#1#08D$^$G$NJQ498uJd$r%(%3!<%(%j%"$KI=<(!#(B
-;;     $BB3$1$FBG$?$l$l$P!"A0$N#1#08uJd$rI=<(!#(B
+;;     最高10個までの変換候補をエコーエリアに表示。
+;;     続けて打たれれば、前の10候補を表示。
 ;; 0..9                kkc-select-from-list
-;;     $BBG$?$l$??t;z$NJQ498uJd$rA*Br(B
+;;     打たれた数字の変換候補を選択
 ;; H           kkc-hiragana
-;;     address@hidden>L>$KJQ49(B
+;;     注目文節を平仮名に変換
 ;; K           kkc-katakana
-;;     address@hidden>L>$KJQ49(B
+;;     注目文節を片仮名に変換
 ;; C-o         kkc-longer
-;;     address@hidden;z?-$P$9(B
+;;     注目文節を後ろに一文字伸ばす
 ;; C-i         kkc-shorter
-;;     address@hidden;z=L$a$k(B
+;;     注目文節を後ろから一文字縮める
 ;; C-f         kkc-next-phrase
-;;     
address@hidden;$k!#$b$7;D$j$NF~NO$,address@hidden"$l$P!":address@hidden(B
-;;     $BA*Br$7!"address@hidden"$=$N:G=i$NJQ498uJd$rI=<($9$k!#(B
+;;     注目文節を確定させる。もし残りの入力がまだあれば、最初の文節を
+;;     選択し、それを注目文節とし、その最初の変換候補を表示する。
 ;; DEL, C-c    kkc-cancel
-;;     $B2>L>4A;zJQ49$r%-%c%s%;%k$7!"%m!<%^;z2>L>JQ49$N%9%F!<%8$KLa$k!#(B
+;;     仮名漢字変換をキャンセルし、ローマ字仮名変換のステージに戻る。
 ;; return              kkc-terminate
-;;     address@hidden;$k!#(B
+;;     全文節を確定させる。
 ;; C-SPC, C-@  kkc-first-char-only
-;;     $B:G=i$NJ8;z$r3NDj$5$;!";D$j$O:o=|$9$k!#(B
+;;     最初の文字を確定させ、残りは削除する。
 ;; C-h         kkc-help
-;;     $B$3$l$i$N%-!<%P%$%s%I$N%j%9%H$rI=<($9$k!#$"(B
+;;     これらのキーバインドのリストを表示する。あ
 
 (quail-define-package
- "japanese" "Japanese" "A$B$"(B"
+ "japanese" "Japanese" "Aあ"
  nil
  "Japanese input method by Roman transliteration and Kana-Kanji conversion.
 
@@ -433,7 +433,7 @@ Type \"qq\" to go back to previous input method."
 (quail-define-rules ("qq" quail-japanese-switch-package))
 
 (quail-define-package
- "japanese-zenkaku" "Japanese" "$B#A(B"
+ "japanese-zenkaku" "Japanese" "A"
  nil
  "Japanese zenkaku alpha numeric character input method.
 ---- Special key bindings ----
@@ -445,30 +445,30 @@ qh:       shift to the input method `japanese',
 
 (quail-define-rules
 
-(" " "$B!!(B") ("!" "$B!*(B") ("\"" "$B!m(B") ("#" "$B!t(B")
-("$" "$B!p(B") ("%" "$B!s(B") ("&" "$B!u(B") ("'" "$B!l(B")
-("(" "$B!J(B") (")" "$B!K(B") ("*" "$B!v(B") ("+" "$B!\(B")
-("," "$B!$(B") ("-" "$B!](B") ("." "$B!%(B") ("/" "$B!?(B")
-("0" "$B#0(B") ("1" "$B#1(B") ("2" "$B#2(B") ("3" "$B#3(B")
-("4" "$B#4(B") ("5" "$B#5(B") ("6" "$B#6(B") ("7" "$B#7(B")
-("8" "$B#8(B") ("9" "$B#9(B") (":" "$B!'(B") (";" "$B!((B")
-("<" "$B!c(B") ("=" "$B!a(B") (">" "$B!d(B") ("?" "$B!)(B")
-("@" "$B!w(B") ("A" "$B#A(B") ("B" "$B#B(B") ("C" "$B#C(B")
-("D" "$B#D(B") ("E" "$B#E(B") ("F" "$B#F(B") ("G" "$B#G(B")
-("H" "$B#H(B") ("I" "$B#I(B") ("J" "$B#J(B") ("K" "$B#K(B")
-("L" "$B#L(B") ("M" "$B#M(B") ("N" "$B#N(B") ("O" "$B#O(B")
-("P" "$B#P(B") ("Q" "$B#Q(B") ("R" "$B#R(B") ("S" "$B#S(B")
-("T" "$B#T(B") ("U" "$B#U(B") ("V" "$B#V(B") ("W" "$B#W(B")
-("X" "$B#X(B") ("Y" "$B#Y(B") ("Z" "$B#Z(B") ("[" "$B!N(B")
-("\\" "$B!o(B") ("]" "$B!O(B") ("^" "$B!0(B") ("_" "$B!2(B")
-("`" "$B!F(B") ("a" "$B#a(B") ("b" "$B#b(B") ("c" "$B#c(B")
-("d" "$B#d(B") ("e" "$B#e(B") ("f" "$B#f(B") ("g" "$B#g(B")
-("h" "$B#h(B") ("i" "$B#i(B") ("j" "$B#j(B") ("k" "$B#k(B")
-("l" "$B#l(B") ("m" "$B#m(B") ("n" "$B#n(B") ("o" "$B#o(B")
-("p" "$B#p(B") ("q" "$B#q(B") ("r" "$B#r(B") ("s" "$B#s(B")
-("t" "$B#t(B") ("u" "$B#u(B") ("v" "$B#v(B") ("w" "$B#w(B")
-("x" "$B#x(B") ("y" "$B#y(B") ("z" "$B#z(B") ("{" "$B!P(B")
-("|" "$B!C(B") ("}" "$B!Q(B") ("~" "$B!A(B")
+(" " " ") ("!" "!") ("\"" "″") ("#" "#")
+("$" "$") ("%" "%") ("&" "&") ("'" "′")
+("(" "(") (")" ")") ("*" "*") ("+" "+")
+("," ",") ("-" "−") ("." ".") ("/" "/")
+("0" "0") ("1" "1") ("2" "2") ("3" "3")
+("4" "4") ("5" "5") ("6" "6") ("7" "7")
+("8" "8") ("9" "9") (":" ":") (";" ";")
+("<" "<") ("=" "=") (">" ">") ("?" "?")
+("@" "@") ("A" "A") ("B" "B") ("C" "C")
+("D" "D") ("E" "E") ("F" "F") ("G" "G")
+("H" "H") ("I" "I") ("J" "J") ("K" "K")
+("L" "L") ("M" "M") ("N" "N") ("O" "O")
+("P" "P") ("Q" "Q") ("R" "R") ("S" "S")
+("T" "T") ("U" "U") ("V" "V") ("W" "W")
+("X" "X") ("Y" "Y") ("Z" "Z") ("[" "[")
+("\\" "¥") ("]" "]") ("^" "^") ("_" "_")
+("`" "‘") ("a" "a") ("b" "b") ("c" "c")
+("d" "d") ("e" "e") ("f" "f") ("g" "g")
+("h" "h") ("i" "i") ("j" "j") ("k" "k")
+("l" "l") ("m" "m") ("n" "n") ("o" "o")
+("p" "p") ("q" "q") ("r" "r") ("s" "s")
+("t" "t") ("u" "u") ("v" "v") ("w" "w")
+("x" "x") ("y" "y") ("z" "z") ("{" "{")
+("|" "|") ("}" "}") ("~" "〜")
 
 ("qq" quail-japanese-switch-package)
 ("qh" quail-japanese-switch-package)
@@ -485,7 +485,7 @@ qh: shift to the input method `japanese',
 
 (quail-define-package
  "japanese-hankaku-kana"
- "Japanese" "(I1(B"
+ "Japanese" "ア"
  nil
  "Japanese hankaku katakana input method by Roman transliteration.
 ---- Special key bindings ----
@@ -514,7 +514,7 @@ qq: toggle between this input method and the input method 
`japanese-ascii'.
                   trans)))
 
 (quail-define-package
- "japanese-hiragana" "Japanese" "$B$"(B"
+ "japanese-hiragana" "Japanese" "あ"
  nil
  "Japanese hiragana input method by Roman transliteration."
  nil t t nil nil nil nil nil
@@ -535,7 +535,7 @@ qq: toggle between this input method and the input method 
`japanese-ascii'.
   control-flag)
 
 (quail-define-package
- "japanese-katakana" "Japanese" "$B%"(B"
+ "japanese-katakana" "Japanese" "ア"
  nil
  "Japanese katakana input method by Roman transliteration."
  nil t t nil nil nil nil nil
diff --git a/lisp/leim/quail/latin-alt.el b/lisp/leim/quail/latin-alt.el
index 5044fb2..6237636 100644
--- a/lisp/leim/quail/latin-alt.el
+++ b/lisp/leim/quail/latin-alt.el
@@ -1,6 +1,6 @@
 ;;; latin-alt.el --- Quail package for inputting various European characters 
-*-coding: utf-8;-*-
 
-;; Copyright (C) 1997-1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
 ;;   2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/leim/quail/latin-ltx.el b/lisp/leim/quail/latin-ltx.el
index cef76f6..754f662 100644
--- a/lisp/leim/quail/latin-ltx.el
+++ b/lisp/leim/quail/latin-ltx.el
@@ -1,6 +1,6 @@
 ;;; latin-ltx.el --- Quail package for TeX-style input -*-coding: utf-8;-*-
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
 ;;   2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/leim/quail/latin-post.el b/lisp/leim/quail/latin-post.el
index 8b0253f..589978f 100644
--- a/lisp/leim/quail/latin-post.el
+++ b/lisp/leim/quail/latin-post.el
@@ -1,6 +1,6 @@
 ;;; latin-post.el --- Quail packages for inputting various European characters 
 -*-coding: utf-8;-*-
 
-;; Copyright (C) 1997-1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 ;;   2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/leim/quail/latin-pre.el b/lisp/leim/quail/latin-pre.el
index 9d343e7..bcf81f4 100644
--- a/lisp/leim/quail/latin-pre.el
+++ b/lisp/leim/quail/latin-pre.el
@@ -1,6 +1,6 @@
 ;;; latin-pre.el --- Quail packages for inputting various European characters  
-*-coding: utf-8;-*-
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 ;;   2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -320,7 +320,7 @@ Key translation rules are:
 
     effect   | prefix | examples
  ------------+--------+------------------
-    tilde    |   ~    | ~a -> ă
+    breve    |   ~    | ~a -> ă
   circumflex |   ^    | ^a -> â, ^i -> î
    cedilla   |   ,    | ,s -> ş, ,t -> ţ
    ~         |   ~    | ~~ -> ~
@@ -342,11 +342,11 @@ Key translation rules are:
 
     effect   | prefix | examples
  ------------+--------+------------------
-    tilde    |   \"    | \"a -> â
-  circumflex |   \\='    | \\='a -> â, \\='i -> î
-   cedilla   |   \\='    | \\='s -> ş, \\='t -> ţ
-   \\='         |   \\='    | \\='\\=' -> \\='
-   \"         |   \"    | \"\" -> \"
+    breve    |   \\='    | \\='a -> ă
+ circumflex  |  \" \\='   | \"a -> â  \\='i -> î
+   cedilla   |   \\='    | \\='s -> ş  \\='t -> ţ
+      \\='      |   \\='    | \\='\\=' -> \\='
+      \"      |   \"    | \"\" -> \"
 " nil t nil nil nil nil nil nil nil nil t)
 
 (quail-define-rules
@@ -606,7 +606,7 @@ Key translation rules are:
   circumflex |   ^    | ^a -> â
   diaeresis  |   \"    | \"a -> ä   \"\" -> ¨
    cedilla   |   ~    | ~c -> ç   ~s -> ş   ~~ -> ¸
-  dot above  |   / .  | /g -> ġ   .o -> ġ
+  dot above  |   / .  | /g -> ġ   .g -> ġ
     misc     | \" ~ /  | \"s -> ß   ~g -> ğ   ~u -> ŭ   /h -> ħ   /i -> ı
    symbol    |   ~    | ~\\=` -> ˘   /# -> £   /$ -> ¤   // -> °
 " nil t nil nil nil nil nil nil nil nil t)
@@ -1089,15 +1089,15 @@ of characters from a single Latin-N charset.
 
     effect   | prefix | examples
  ------------+--------+----------
-    acute    |   \\='    | \\='a -> á, \\='\\=' -> ´
+    acute    |   \\='    | \\='a -> á  \\='\\=' -> ´
     grave    |   \\=`    | \\=`a -> à
   circumflex |   ^    | ^a -> â
   diaeresis  |   \"    | \"a -> ä  \"\" -> ¨
     tilde    |   ~    | ~a -> ã
-   cedilla   |   ~    | ~c -> ç
+   cedilla   |  , ~   | ,c -> ç  ~c -> ç
+    caron    |   ~    | ~c -> č  ~g -> ğ
     breve    |   ~    | ~a -> ă
-    caron    |   ~    | ~c -> č
-  dot above  | ~ / .  | ~o -> ġ   /o -> ġ   .o -> ġ
+  dot above  |   / .  | /g -> ġ   .g -> ġ
     misc     | \" ~ /  | \"s -> ß  ~d -> ð  ~t -> þ  /a -> å  /e -> æ  /o -> ø
    symbol    |   ~    | ~> -> »  ~< -> «  ~! -> ¡  ~? -> ¿  ~~ -> ¸
    symbol    |  _ /   | _o -> º  _a -> ª  // -> °  /\\ -> ×  _y -> ¥
@@ -1252,7 +1252,10 @@ of characters from a single Latin-N charset.
  ("~>" ?\»)
  ("~?" ?¿)
  ("~A" ?Ã)
+ ("~A" ?Ă)
  ("~C" ?Ç)
+ ("~C" ?Č)
+ (",C" ?Ç)
  ("~D" ?Ð)
  ("~G" ?Ğ)
  ("~N" ?Ñ)
@@ -1265,13 +1268,15 @@ of characters from a single Latin-N charset.
  ("~Z" ?Ž)
  ("~`" ?˘)
  ("~a" ?ã)
+ ("~a" ?ă)
  ("~c" ?ç)
+ ("~c" ?č)
+ (",c" ?ç)
  ("~d" ?ð)
  ("~e" ?€)
  ("~g" ?ğ)
  ("~n" ?ñ)
  ("~o" ?õ)
- ("~o" ?ġ)
  ("~p" ?¶)
  ("~s" ?§)
  ("~s" ?ş)
diff --git a/lisp/leim/quail/lrt.el b/lisp/leim/quail/lrt.el
index 69e8fd6..e8f856f 100644
--- a/lisp/leim/quail/lrt.el
+++ b/lisp/leim/quail/lrt.el
@@ -1,6 +1,6 @@
 ;;; lrt.el --- Quail package for inputting Lao characters by LRT method  
-*-coding: utf-8;-*-
 
-;; Copyright (C) 1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 ;;   2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/leim/quail/persian.el b/lisp/leim/quail/persian.el
index c2c73a7..77da3ea 100644
--- a/lisp/leim/quail/persian.el
+++ b/lisp/leim/quail/persian.el
@@ -1,6 +1,6 @@
 ;;; persian.el  --- Quail package for inputting Persian/Farsi keyboard -*- 
coding: utf-8;-*-
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Mohsen BANAN <address@hidden>
 ;; X-URL: http://mohsen.1.banan.byname.net/contact
diff --git a/lisp/leim/quail/programmer-dvorak.el 
b/lisp/leim/quail/programmer-dvorak.el
index f36b71a..a8012ca 100644
--- a/lisp/leim/quail/programmer-dvorak.el
+++ b/lisp/leim/quail/programmer-dvorak.el
@@ -1,6 +1,6 @@
 ;;; programmer-dvorak.el --- Quail package for the programmer Dvorak layout
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Joakim Jalap <address@hidden>
 
diff --git a/lisp/leim/quail/py-punct.el b/lisp/leim/quail/py-punct.el
index a53f2c0..eed70a8 100644
--- a/lisp/leim/quail/py-punct.el
+++ b/lisp/leim/quail/py-punct.el
@@ -1,6 +1,6 @@
-;;; py-punct.el --- Quail packages for Chinese (pinyin + extra symbols)  
-*-coding: iso-2022-7bit;-*-
+;;; py-punct.el --- Quail packages for Chinese (pinyin + extra symbols)
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 ;;   2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -35,16 +35,16 @@
 (load "quail/Punct")
 
 (quail-define-package
- "chinese-py-punct" "Chinese-GB" "$AF47{(B"
+ "chinese-py-punct" "Chinese-GB" "拼符"
  t
- "$A::WVJdHk(B $AF4Rt7=08(B and `v' for $A1j5c7{:EJdHk(B
+ "汉字输入 拼音方案 and `v' for 标点符号输入
 
 This is the combination of the input methods `chinese-py' and `chinese-punct'.
 You can enter normal Chinese characters by the same way as `chinese-py'.
 And, you can enter symbols by typing `v' followed by any key sequences
 defined in `chinese-punct'.
 
-For instance, typing `v' and `%' insert `$A#%(B'.
+For instance, typing `v' and `%' insert `%'.
 ")
 
 (setcar (nthcdr 2 quail-current-package)
@@ -55,9 +55,9 @@ For instance, typing `v' and `%' insert `$A#%(B'.
 (load "quail/TONEPY")
 
 (quail-define-package
- "chinese-tonepy-punct" "Chinese-GB" "$AF47{(B"
+ "chinese-tonepy-punct" "Chinese-GB" "拼符"
  t
- "$A::WVJdHk(B $A4x5wF4Rt7=08(B and `v' for $A1j5c7{:EJdHk(B
+ "汉字输入 带调拼音方案 and `v' for 标点符号输入
 
 This is the combination of the input methods `chinese-tonepy' and
 `chinese-punct'.
@@ -66,7 +66,7 @@ You can enter normal Chinese characters by the same way as
 `chinese-tonepy'.  And, you can enter symbols by typing `v' followed
 by any key sequences defined in `chinese-punct'.
 
-For instance, typing `v' and `%' insert `$A#%(B'.
+For instance, typing `v' and `%' insert `%'.
 ")
 
 (setcar (nthcdr 2 quail-current-package)
diff --git a/lisp/leim/quail/pypunct-b5.el b/lisp/leim/quail/pypunct-b5.el
index ef58631..45597a4 100644
--- a/lisp/leim/quail/pypunct-b5.el
+++ b/lisp/leim/quail/pypunct-b5.el
@@ -1,4 +1,4 @@
-;;; pypunct-b5.el --- Quail packages for Chinese (pinyin + extra symbols) 
-*-coding: iso-2022-7bit;-*-
+;;; pypunct-b5.el --- Quail packages for Chinese (pinyin + extra symbols)
 
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 ;;   2006, 2007, 2008, 2009, 2010, 2011
@@ -34,9 +34,9 @@
 (load "quail/Punct-b5")
 
 (quail-define-package
- "chinese-py-punct-b5" "Chinese-BIG5" "$(03<>K(B"
+ "chinese-py-punct-b5" "Chinese-BIG5" "拼符"
  t
- "$(0&d'GTT&,!J3<5x!K(B and `v' for $(0O:X5>KHATT&,(B
+ "中文輸入【拼音】 and `v' for 標點符號輸入
 
 This is the combination of the input method `chinese-py-b5' and
 `chinese-punct-b5'.
@@ -45,7 +45,7 @@ You can enter normal Chinese characters by the same way as 
`chinese-py-b5'.
 And, you can enter symbols by typing `v' followed by any key sequences
 defined in `chinese-punct-b5'.
 
-For instance, typing `v' and `%' insert `$(0"h(B'.
+For instance, typing `v' and `%' insert `%'.
 ")
 
 (setcar (nthcdr 2 quail-current-package)
diff --git a/lisp/leim/quail/rfc1345.el b/lisp/leim/quail/rfc1345.el
index 081180a..da1a453 100644
--- a/lisp/leim/quail/rfc1345.el
+++ b/lisp/leim/quail/rfc1345.el
@@ -1,6 +1,6 @@
 ;;; rfc1345.el --- Quail method for RFC 1345 mnemonics -*- coding: utf-8 -*-
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Love <address@hidden>
 ;; Keywords: i18n
diff --git a/lisp/leim/quail/sami.el b/lisp/leim/quail/sami.el
new file mode 100644
index 0000000..7cfd0b7
--- /dev/null
+++ b/lisp/leim/quail/sami.el
@@ -0,0 +1,755 @@
+;;; sami.el --- Quail package for inputting Sámi  -*-coding: utf-8;-*-
+
+;; Copyright (C) 2019 Free Software Foundation, Inc.
+
+;; Author: Wojciech S. Gac <address@hidden>
+;; Maintainer: Wojciech S. Gac <address@hidden>>
+;; Keywords: i18n, multilingual, input method, Sámi
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This file implements the following input methods for the Sámi
+;; language
+;; - norwegian-sami-prefix
+;; - bergsland-hasselbrink-sami-prefix
+;; - southern-sami-prefix
+;; - ume-sami-prefix
+;; - northern-sami-prefix
+;; - inari-sami-prefix
+;; - skolt-sami-prefix
+;; - kildin-sami-prefix
+
+;;; Code
+
+(require 'quail)
+
+(quail-define-package
+ "norwegian-sami-prefix" "Sámi" "/NSoS" nil
+ "Norwegian Southern Sámi input method
+
+Alphabet (parenthesized letters are used in foreign names):
+А а    B b     (C c)   D d     E e     F f     G g     H h
+I i    (Ï ï)   J j     K k     L l     M m     N n     O o
+P p    (Q q)   R r     S s     T t     U u     V v     (W w)
+(X x)  Y y     (Z z)   Æ æ     Ø ø     Å å
+"
+ nil t nil nil nil nil nil nil nil nil t)
+
+(quail-define-rules
+ ("А" ?А)
+ ("а" ?а)
+ ("B" ?B)
+ ("b" ?b)
+ ("C" ?C)
+ ("c" ?c)
+ ("D" ?D)
+ ("d" ?d)
+ ("E" ?E)
+ ("e" ?e)
+ ("F" ?F)
+ ("f" ?f)
+ ("G" ?G)
+ ("g" ?g)
+ ("H" ?H)
+ ("h" ?h)
+ ("I" ?I)
+ ("i" ?i)
+ (":I" ?Ï)
+ (":i" ?ï)
+ ("J" ?J)
+ ("j" ?j)
+ ("K" ?K)
+ ("k" ?k)
+ ("L" ?L)
+ ("l" ?l)
+ ("M" ?M)
+ ("m" ?m)
+ ("N" ?N)
+ ("n" ?n)
+ ("O" ?O)
+ ("o" ?o)
+ ("P" ?P)
+ ("p" ?p)
+ ("Q" ?Q)
+ ("q" ?q)
+ ("R" ?R)
+ ("r" ?r)
+ ("S" ?S)
+ ("s" ?s)
+ ("T" ?T)
+ ("t" ?t)
+ ("U" ?U)
+ ("u" ?u)
+ ("V" ?V)
+ ("v" ?v)
+ ("W" ?W)
+ ("w" ?w)
+ ("X" ?X)
+ ("x" ?x)
+ ("Y" ?Y)
+ ("y" ?y)
+ ("Z" ?Z)
+ ("z" ?z)
+ ("AE" ?Æ)
+ ("ae" ?æ)
+ ("/O" ?Ø)
+ ("/o" ?ø)
+ ("/A" ?Å)
+ ("/a" ?å))
+
+(quail-define-package
+ "bergsland-hasselbrink-sami-prefix" "Sámi" "/BHS" nil
+ "Bergsland-Hasselbrink Southern Sámi input method
+
+Alphabet:
+А а    Â â     Á á     B b     C c     Č č     D d     Đ đ
+E e    F f     G g     H h     I i     Î î     J j     K k
+L l    M m     N n     Ŋ ŋ     O o     P p     R r     S s
+Š š    T t     U u     V v     Y y     Z z     Ž ž     Ä ä
+Æ æ    Ö ö     Å å     '
+"
+ nil t nil nil nil nil nil nil nil nil t)
+
+(quail-define-rules
+ ("А" ?А)
+ ("а" ?а)
+ ("^A" ?Â)
+ ("^a" ?â)
+ ("'A" ?Á)
+ ("'a" ?á)
+ ("B" ?B)
+ ("b" ?b)
+ ("C" ?C)
+ ("c" ?c)
+ ("^C" ?Č)
+ ("^c" ?č)
+ ("D" ?D)
+ ("d" ?d)
+ ("-D" ?Đ)
+ ("-d" ?đ)
+ ("E" ?E)
+ ("e" ?e)
+ ("F" ?F)
+ ("f" ?f)
+ ("G" ?G)
+ ("g" ?g)
+ ("H" ?H)
+ ("h" ?h)
+ ("I" ?I)
+ ("i" ?i)
+ ("^I" ?Î)
+ ("^i" ?î)
+ ("J" ?J)
+ ("j" ?j)
+ ("K" ?K)
+ ("k" ?k)
+ ("L" ?L)
+ ("l" ?l)
+ ("M" ?M)
+ ("m" ?m)
+ ("N" ?N)
+ ("n" ?n)
+ ("/N" ?Ŋ)
+ ("/n" ?ŋ)
+ ("O" ?O)
+ ("o" ?o)
+ ("P" ?P)
+ ("p" ?p)
+ ("R" ?R)
+ ("r" ?r)
+ ("S" ?S)
+ ("s" ?s)
+ ("^S" ?Š)
+ ("^s" ?š)
+ ("T" ?T)
+ ("t" ?t)
+ ("U" ?U)
+ ("u" ?u)
+ ("V" ?V)
+ ("v" ?v)
+ ("Y" ?Y)
+ ("y" ?y)
+ ("Z" ?Z)
+ ("z" ?z)
+ ("^Z" ?Ž)
+ ("^z" ?ž)
+ (":A" ?Ä)
+ (":a" ?ä)
+ ("AE" ?Æ)
+ ("ae" ?æ)
+ (":O" ?Ö)
+ (":o" ?ö)
+ ("/A" ?Å)
+ ("/a" ?å))
+
+(quail-define-package
+ "southern-sami-prefix" "Sámi" "/SoS" nil
+ "Contemporary Southern Sámi input method
+
+Alphabet (parenthesized letters are used in foreign names):
+А а    B b     (C c)   D d     E e     F f     G g     H h
+I i    (Ï ï)   J j     K k     L l     M m     N n     O o
+P p    (Q q)   R r     S s     T t     U u     V v     (W w)
+(X x)  Y y     (Z z)   Ä ä     Ö ö     Å å
+"
+ nil t nil nil nil nil nil nil nil nil t)
+
+(quail-define-rules
+ ("А" ?А)
+ ("а" ?а)
+ ("B" ?B)
+ ("b" ?b)
+ ("C" ?C)
+ ("c" ?c)
+ ("D" ?D)
+ ("d" ?d)
+ ("E" ?E)
+ ("e" ?e)
+ ("F" ?F)
+ ("f" ?f)
+ ("G" ?G)
+ ("g" ?g)
+ ("H" ?H)
+ ("h" ?h)
+ ("I" ?I)
+ ("i" ?i)
+ (":I" ?Ï)
+ (":i" ?ï)
+ ("J" ?J)
+ ("j" ?j)
+ ("K" ?K)
+ ("k" ?k)
+ ("L" ?L)
+ ("l" ?l)
+ ("M" ?M)
+ ("m" ?m)
+ ("N" ?N)
+ ("n" ?n)
+ ("O" ?O)
+ ("o" ?o)
+ ("P" ?P)
+ ("p" ?p)
+ ("Q" ?Q)
+ ("q" ?q)
+ ("R" ?R)
+ ("r" ?r)
+ ("S" ?S)
+ ("s" ?s)
+ ("T" ?T)
+ ("t" ?t)
+ ("U" ?U)
+ ("u" ?u)
+ ("V" ?V)
+ ("v" ?v)
+ ("W" ?W)
+ ("w" ?w)
+ ("X" ?X)
+ ("x" ?x)
+ ("Y" ?Y)
+ ("y" ?y)
+ ("Z" ?Z)
+ ("z" ?z)
+ (":A" ?Ä)
+ (":a" ?ä)
+ (":O" ?Ö)
+ (":o" ?ö)
+ ("/A" ?Å)
+ ("/a" ?å))
+
+(quail-define-package
+ "ume-sami-prefix" "Sámi" "/UmS" nil
+ "Ume Sámi input method
+
+Alphabet:
+А а    Á á     B b     D d     Đ đ     E e     F f     G g
+H h    I i     Ï ï     J j     K k     L l     M m     N n
+Ŋ ŋ    O o     P p     R r     S s     T t     Ŧ ŧ     U u
+Ü ü    V v     Y y     Å å     Ä ä     Ö ö
+"
+ nil t nil nil nil nil nil nil nil nil t)
+
+(quail-define-rules
+ ("А" ?А)
+ ("а" ?а)
+ ("'A" ?Á)
+ ("'a" ?á)
+ ("B" ?B)
+ ("b" ?b)
+ ("D" ?D)
+ ("d" ?d)
+ ("-D" ?Đ)
+ ("-d" ?đ)
+ ("E" ?E)
+ ("e" ?e)
+ ("F" ?F)
+ ("f" ?f)
+ ("G" ?G)
+ ("g" ?g)
+ ("H" ?H)
+ ("h" ?h)
+ ("I" ?I)
+ ("i" ?i)
+ (":I" ?Ï)
+ (":i" ?ï)
+ ("J" ?J)
+ ("j" ?j)
+ ("K" ?K)
+ ("k" ?k)
+ ("L" ?L)
+ ("l" ?l)
+ ("M" ?M)
+ ("m" ?m)
+ ("N" ?N)
+ ("n" ?n)
+ ("/N" ?Ŋ)
+ ("/n" ?ŋ)
+ ("O" ?O)
+ ("o" ?o)
+ ("P" ?P)
+ ("p" ?p)
+ ("R" ?R)
+ ("r" ?r)
+ ("S" ?S)
+ ("s" ?s)
+ ("T" ?T)
+ ("t" ?t)
+ ("-T" ?Ŧ)
+ ("-t" ?ŧ)
+ ("U" ?U)
+ ("u" ?u)
+ (":U" ?Ü)
+ (":u" ?ü)
+ ("V" ?V)
+ ("v" ?v)
+ ("Y" ?Y)
+ ("y" ?y)
+ ("/A" ?Å)
+ ("/a" ?å)
+ (":A" ?Ä)
+ (":a" ?ä)
+ (":O" ?Ö)
+ (":o" ?ö)
+ )
+
+(quail-define-package
+ "northern-sami-prefix" "Sámi" "/NoS" nil
+ "Northern Sámi input method
+
+Alphabet:
+А а    Á á     B b     C c     Č č     D d     Đ đ     E e
+F f    G g     H h     I i     J j     K k     L l     M m
+N n    Ŋ ŋ     O o     P p     R r     S s     Š š     T t
+Ŧ ŧ    U u     V v     Z z     Ž ž
+"
+ nil t nil nil nil nil nil nil nil nil t)
+
+(quail-define-rules
+ ("А" ?А)
+ ("а" ?а)
+ ("'A" ?Á)
+ ("'a" ?á)
+ ("B" ?B)
+ ("b" ?b)
+ ("C" ?C)
+ ("c" ?c)
+ ("^C" ?Č)
+ ("^c" ?č)
+ ("D" ?D)
+ ("d" ?d)
+ ("-D" ?Đ)
+ ("-d" ?đ)
+ ("E" ?E)
+ ("e" ?e)
+ ("F" ?F)
+ ("f" ?f)
+ ("G" ?G)
+ ("g" ?g)
+ ("H" ?H)
+ ("h" ?h)
+ ("I" ?I)
+ ("i" ?i)
+ ("J" ?J)
+ ("j" ?j)
+ ("K" ?K)
+ ("k" ?k)
+ ("L" ?L)
+ ("l" ?l)
+ ("M" ?M)
+ ("m" ?m)
+ ("N" ?N)
+ ("n" ?n)
+ ("/N" ?Ŋ)
+ ("/n" ?ŋ)
+ ("O" ?O)
+ ("o" ?o)
+ ("P" ?P)
+ ("p" ?p)
+ ("R" ?R)
+ ("r" ?r)
+ ("S" ?S)
+ ("s" ?s)
+ ("^S" ?Š)
+ ("^s" ?š)
+ ("T" ?T)
+ ("t" ?t)
+ ("-T" ?Ŧ)
+ ("-t" ?ŧ)
+ ("U" ?U)
+ ("u" ?u)
+ ("V" ?V)
+ ("v" ?v)
+ ("Z" ?Z)
+ ("z" ?z)
+ ("^Z" ?Ž)
+ ("^z" ?ž)
+ )
+
+(quail-define-package
+ "inari-sami-prefix" "Sámi" "/InS" nil
+ "Inari Sámi input method
+
+Alphabet (parenthesized letters are used in foreign names only):
+А а    Â â     B b     C c     Č č     D d     Đ đ     E e
+F f    G g     H h     I i     J j     K k     L l     M m
+N n    O o     P p     (Q q)   R r     S s     Š š     T t
+U u    V v     (W w)   (X x)   Y y     Z z     Ž ž     Ä ä
+Á á    Å å     Ö ö
+"
+ nil t nil nil nil nil nil nil nil nil t)
+
+(quail-define-rules
+ ("А" ?А)
+ ("а" ?а)
+ ("^A" ?Â)
+ ("^a" ?â)
+ ("B" ?B)
+ ("b" ?b)
+ ("C" ?C)
+ ("c" ?c)
+ ("^C" ?Č)
+ ("^c" ?č)
+ ("D" ?D)
+ ("d" ?d)
+ ("-D" ?Đ)
+ ("-d" ?đ)
+ ("E" ?E)
+ ("e" ?e)
+ ("F" ?F)
+ ("f" ?f)
+ ("G" ?G)
+ ("g" ?g)
+ ("H" ?H)
+ ("h" ?h)
+ ("I" ?I)
+ ("i" ?i)
+ ("J" ?J)
+ ("j" ?j)
+ ("K" ?K)
+ ("k" ?k)
+ ("L" ?L)
+ ("l" ?l)
+ ("M" ?M)
+ ("m" ?m)
+ ("N" ?N)
+ ("n" ?n)
+ ("O" ?O)
+ ("o" ?o)
+ ("P" ?P)
+ ("p" ?p)
+ ("Q" ?Q)
+ ("q" ?q)
+ ("R" ?R)
+ ("r" ?r)
+ ("S" ?S)
+ ("s" ?s)
+ ("^S" ?Š)
+ ("^s" ?š)
+ ("T" ?T)
+ ("t" ?t)
+ ("U" ?U)
+ ("u" ?u)
+ ("V" ?V)
+ ("v" ?v)
+ ("W" ?W)
+ ("w" ?w)
+ ("X" ?X)
+ ("x" ?x)
+ ("Y" ?Y)
+ ("y" ?y)
+ ("Z" ?Z)
+ ("z" ?z)
+ ("^Z" ?Ž)
+ ("^z" ?ž)
+ (":A" ?Ä)
+ (":a" ?ä)
+ ("'A" ?Á)
+ ("'a" ?á)
+ ("/A" ?Å)
+ ("/a" ?å)
+ (":O" ?Ö)
+ (":o" ?ö))
+
+(quail-define-package
+ "skolt-sami-prefix" "Sámi" "/SkS" nil
+ "Skolt Sámi input method
+
+Alphabet (parenthesized letters are used in foreign names only):
+А а    Â â     B b     C c     Č č     Ʒ ʒ     Ǯ ǯ     D d
+Đ đ    E e     F f     G g     Ǧ ǧ     Ǥ ǥ     H h     I i
+J j    K k     Ǩ ǩ     L l     M m     N n     Ŋ ŋ     O o
+Õ õ    P p     (Q q)   R r     S s     Š š     T t     U u
+V v    (W w)   (X x)   (Y y)   Z z     Ž ž     Å å     Ä ä
+(Ö ö)  ʹ
+"
+ nil t nil nil nil nil nil nil nil nil t)
+
+(quail-define-rules
+ ("A" ?А)
+ ("a" ?а)
+ ("^A" ?Â)
+ ("^a" ?â)
+ ("B" ?B)
+ ("b" ?b)
+ ("C" ?C)
+ ("c" ?c)
+ ("^C" ?Č)
+ ("^c" ?č)
+ ("/X" ?Ʒ)
+ ("/x" ?ʒ)
+ ("^X" ?Ǯ)
+ ("^x" ?ǯ)
+ ("D" ?D)
+ ("d" ?d)
+ ("-D" ?Đ)
+ ("-d" ?đ)
+ ("E" ?E)
+ ("e" ?e)
+ ("F" ?F)
+ ("f" ?f)
+ ("G" ?G)
+ ("g" ?g)
+ ("^G" ?Ǧ)
+ ("^g" ?ǧ)
+ ("-G" ?Ǥ)
+ ("-g" ?ǥ)
+ ("H" ?H)
+ ("h" ?h)
+ ("I" ?I)
+ ("i" ?i)
+ ("J" ?J)
+ ("j" ?j)
+ ("K" ?K)
+ ("k" ?k)
+ ("^K" ?Ǩ)
+ ("^k" ?ǩ)
+ ("L" ?L)
+ ("l" ?l)
+ ("M" ?M)
+ ("m" ?m)
+ ("N" ?N)
+ ("n" ?n)
+ ("/N" ?Ŋ)
+ ("/n" ?ŋ)
+ ("O" ?O)
+ ("o" ?o)
+ ("~O" ?Õ)
+ ("~o" ?õ)
+ ("P" ?P)
+ ("p" ?p)
+ ("Q" ?Q)
+ ("q" ?q)
+ ("R" ?R)
+ ("r" ?r)
+ ("S" ?S)
+ ("s" ?s)
+ ("^S" ?Š)
+ ("^s" ?š)
+ ("T" ?T)
+ ("t" ?t)
+ ("U" ?U)
+ ("u" ?u)
+ ("V" ?V)
+ ("v" ?v)
+ ("W" ?W)
+ ("w" ?w)
+ ("X" ?X)
+ ("x" ?x)
+ ("Y" ?Y)
+ ("y" ?y)
+ ("Z" ?Z)
+ ("z" ?z)
+ ("^Z" ?Ž)
+ ("^z" ?ž)
+ ("/A" ?Å)
+ ("/a" ?å)
+ (":A" ?Ä)
+ (":a" ?ä)
+ (":O" ?Ö)
+ (":o" ?ö))
+
+(quail-define-package
+ "kildin-sami-prefix" "Sámi" "/KiS" nil
+ "Kildin Sámi input method
+
+Alphabet (parenthesized letters are used in foreign names only):
+А а    А̄ а̄   Ӓ ӓ     Б б     В в     Г г     Д д     Е е     Е̄ е̄
+Ё ё    Ё̄ ё̄   Ж ж     З з     Һ һ     (')     И и     Ӣ ӣ     Й й
+Ј ј    (Ҋ ҋ)   К к     Л л     Ӆ ӆ     М м     Ӎ ӎ     Н н     Ӊ ӊ
+Ӈ ӈ    О о     О̄ о̄   П п     Р р     Ҏ ҏ     С с     Т т     У у
+Ӯ ӯ    Ф ф     Х х     Ц ц     Ч ч     Ш ш     Щ щ     Ъ ъ     Ы ы
+Ь ь    Ҍ ҍ     Э э     Э̄ э̄   Ӭ ӭ     Ю ю     Ю̄ ю̄   Я я     Я̄ я̄
+")
+
+(quail-define-rules
+ ("1" ?1)
+ ("2" ?2)
+ ("3" ?3)
+ ("4" ?4)
+ ("5" ?5)
+ ("6" ?6)
+ ("7" ?7)
+ ("8" ?8)
+ ("9" ?9)
+ ("0" ?0)
+ ("-" ?-)
+ ("=" ?ч)
+ ("`" ?ю)
+ ("-`" ["ю̄"])
+ ("q" ?я)
+ ("-q" ["я̄"])
+ ("w" ?в)
+ ("e" ?е)
+ ("-e" ["е̄"])
+ ("-@" ["ё̄"])
+ ("r" ?р)
+ ("-r" ?ҏ)
+ ("t" ?т)
+ ("y" ?ы)
+ ("u" ?у)
+ ("-u" ?ӯ)
+ ("i" ?и)
+ ("o" ?о)
+ ("-o" ["о̄"])
+ ("p" ?п)
+ ("[" ?ш)
+ ("]" ?щ)
+ ("a" ?а)
+ ("-a" ["а̄"])
+ (":a" ?ӓ)
+ ("s" ?с)
+ ("d" ?д)
+ ("f" ?ф)
+ ("g" ?г)
+ ("h" ?х)
+ ("/h" ?һ)
+ ("j" ?й)
+ ("-j" ["ӣ"])
+ ("'j" ?ҋ)
+ ("/j" ?ј)
+ ("k" ?к)
+ ("l" ?л)
+ ("'l" ?ӆ)
+ (";" ?\;)
+ ("'" ?')
+ ("\\" ?э)
+ ("-\\" ["э̄"])
+ (":\\" ?ӭ)
+ ("z" ?з)
+ ("x" ?ь)
+ ("-x" ?ҍ)
+ ("c" ?ц)
+ ("v" ?ж)
+ ("b" ?б)
+ ("n" ?н)
+ ("'n" ?ӊ)
+ (",n" ?ӈ)
+ ("m" ?м)
+ ("'m" ?ӎ)
+ ("," ?,)
+ ("." ?.)
+ ("/" ?/)
+
+ ("!" ?!)
+ ("@" ?ё)
+ ("#" ?ъ)
+ ("$" ?Ё)
+ ("%" ?%)
+ ("^" ?^)
+ ("&" ?&)
+ ("*" ?*)
+ ("(" ?\()
+ (")" ?\))
+ ("_" ?_)
+ ("+" ?Ч)
+ ("~" ?Ю)
+ ("-~" ["Ю̄"])
+ ("Q" ?Я)
+ ("-Q" ["Я̄"])
+ ("W" ?В)
+ ("E" ?Е)
+ ("-E" ["Е̄"])
+ ("-$" ["Ё̄"])
+ ("R" ?Р)
+ ("-R" ?Ҏ)
+ ("T" ?Т)
+ ("Y" ?Ы)
+ ("U" ?У)
+ ("-U" ["Ӯ"])
+ ("I" ?И)
+ ("O" ?О)
+ ("-O" ["О̄"])
+ ("P" ?П)
+ ("{" ?Ш)
+ ("}" ?Щ)
+ ("A" ?А)
+ ("-A" ["А̄"])
+ (":A" ?Ӓ)
+ ("S" ?С)
+ ("D" ?Д)
+ ("F" ?Ф)
+ ("G" ?Г)
+ ("H" ?Х)
+ ("/H" ?Һ)
+ ("J" ?Й)
+ ("-J" ["Ӣ"])
+ ("'J" ?Ҋ)
+ ("/J" ?Ј)
+ ("K" ?К)
+ ("L" ?Л)
+ ("'L" ?Ӆ)
+ (":" ?:)
+ ("\"" ?\")
+ ("|" ?Э)
+ ("-|" ["Э̄"])
+ (":|" ?Ӭ)
+ ("Z" ?З)
+ ("X" ?Ь)
+ ("-X" ?Ҍ)
+ ("C" ?Ц)
+ ("V" ?Ж)
+ ("B" ?Б)
+ ("N" ?Н)
+ ("'N" ?Ӊ)
+ (",N" ?Ӈ)
+ ("M" ?М)
+ ("'M" ?Ӎ)
+ ("<" ?<)
+ (">" ?>)
+ ("?" ??))
+
+;;; sami.el ends here
diff --git a/lisp/leim/quail/sgml-input.el b/lisp/leim/quail/sgml-input.el
index f39ac92..f94e7ad 100644
--- a/lisp/leim/quail/sgml-input.el
+++ b/lisp/leim/quail/sgml-input.el
@@ -1,6 +1,6 @@
 ;;; sgml-input.el --- Quail method for Unicode entered as SGML entities -*- 
coding: utf-8 -*-
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Love <address@hidden>
 ;; Keywords: i18n
diff --git a/lisp/leim/quail/sisheng.el b/lisp/leim/quail/sisheng.el
index 9ed9579..571ed54 100644
--- a/lisp/leim/quail/sisheng.el
+++ b/lisp/leim/quail/sisheng.el
@@ -1,6 +1,6 @@
 ;;; sisheng.el --- sisheng input method for Chinese pinyin transliteration
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Werner LEMBERG <address@hidden>
 
diff --git a/lisp/leim/quail/slovak.el b/lisp/leim/quail/slovak.el
index 48964dc..cf07790 100644
--- a/lisp/leim/quail/slovak.el
+++ b/lisp/leim/quail/slovak.el
@@ -1,6 +1,6 @@
 ;;; slovak.el --- Quail package for inputting Slovak  -*-coding: utf-8;-*-
 
-;; Copyright (C) 1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Authors: Tibor Šimko <address@hidden>
 ;;     Milan Zamazal <address@hidden>
diff --git a/lisp/leim/quail/symbol-ksc.el b/lisp/leim/quail/symbol-ksc.el
index 0500d64..4ed5e27 100644
--- a/lisp/leim/quail/symbol-ksc.el
+++ b/lisp/leim/quail/symbol-ksc.el
@@ -1,6 +1,6 @@
 ;;; symbol-ksc.el --- Quail-package for Korean Symbol (KSC5601) -*-coding: 
utf-8;-*-
 
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 ;;   2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/leim/quail/tamil-dvorak.el b/lisp/leim/quail/tamil-dvorak.el
index 8c021b4..b7f3afa 100644
--- a/lisp/leim/quail/tamil-dvorak.el
+++ b/lisp/leim/quail/tamil-dvorak.el
@@ -1,6 +1,6 @@
 ;;; tamil-dvorak.el --- Quail package for Tamil input with Dvorak keyboard
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Shakthi Kannan <address@hidden>
 
diff --git a/lisp/leim/quail/tibetan.el b/lisp/leim/quail/tibetan.el
index 2b9c053..54f95b8 100644
--- a/lisp/leim/quail/tibetan.el
+++ b/lisp/leim/quail/tibetan.el
@@ -1,6 +1,6 @@
 ;;; tibetan.el --- Quail package for inputting Tibetan characters -*-coding: 
utf-8-emacs;-*-
 
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 ;;   2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/leim/quail/uni-input.el b/lisp/leim/quail/uni-input.el
index 4014ebc..42499d0 100644
--- a/lisp/leim/quail/uni-input.el
+++ b/lisp/leim/quail/uni-input.el
@@ -1,6 +1,6 @@
 ;;; uni-input.el --- Hex Unicode input method
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
 ;;   Registration Number H14PRO021
diff --git a/lisp/leim/quail/vntelex.el b/lisp/leim/quail/vntelex.el
index 8c73107..78b467d 100644
--- a/lisp/leim/quail/vntelex.el
+++ b/lisp/leim/quail/vntelex.el
@@ -1,6 +1,6 @@
 ;;; vntelex.el --- Quail package for Vietnamese by Telex method
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author:   Werner Lemberg <address@hidden>
 ;; Keywords: multilingual, input method, Vietnamese
diff --git a/lisp/leim/quail/vnvni.el b/lisp/leim/quail/vnvni.el
index 0e98bc1..fc44cea 100644
--- a/lisp/leim/quail/vnvni.el
+++ b/lisp/leim/quail/vnvni.el
@@ -1,6 +1,6 @@
 ;;; vnvni.el --- Quail package for Vietnamese by VNI method
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author:   Werner Lemberg <address@hidden>
 ;;           Nguyen Thai Ngoc Duy <address@hidden>
diff --git a/lisp/leim/quail/welsh.el b/lisp/leim/quail/welsh.el
index fdbfe2b..36bcbeb 100644
--- a/lisp/leim/quail/welsh.el
+++ b/lisp/leim/quail/welsh.el
@@ -1,6 +1,6 @@
 ;;; welsh.el --- Quail package for inputting Welsh characters  -*-coding: 
utf-8;-*-
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Love <address@hidden>
 ;; Keywords: i18n
diff --git a/lisp/linum.el b/lisp/linum.el
index 6e673e5..0b4b008 100644
--- a/lisp/linum.el
+++ b/lisp/linum.el
@@ -1,6 +1,6 @@
 ;;; linum.el --- display line numbers in the left margin -*- lexical-binding: 
t -*-
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Markus Triska <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/loadhist.el b/lisp/loadhist.el
index 566d51a..4e5d8e0 100644
--- a/lisp/loadhist.el
+++ b/lisp/loadhist.el
@@ -1,6 +1,6 @@
 ;;; loadhist.el --- lisp functions for working with feature groups
 
-;; Copyright (C) 1995, 1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1998, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric S. Raymond <address@hidden>
 ;; Maintainer: address@hidden
@@ -96,7 +96,8 @@ A library name is equivalent to the file name that 
`load-library' would load."
   (let ((provides (file-provides file))
        (dependents nil))
     (dolist (x load-history dependents)
-      (when (file-set-intersect provides (file-requires (car x)))
+      (when (and (stringp (car x))
+                 (file-set-intersect provides (file-requires (car x))))
        (push (car x) dependents)))))
 
 (defun read-feature (prompt &optional loaded-p)
diff --git a/lisp/loadup.el b/lisp/loadup.el
index eb66353..67e8aa7 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -1,6 +1,6 @@
 ;;; loadup.el --- load up standardly loaded Lisp files for Emacs
 
-;; Copyright (C) 1985-1986, 1992, 1994, 2001-2018 Free Software
+;; Copyright (C) 1985-1986, 1992, 1994, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
@@ -26,6 +26,9 @@
 
 ;; This is loaded into a bare Emacs to make a dumpable one.
 
+;; Emacs injects the variable `dump-mode' to tell us how to dump.
+;; We unintern it before allowing user code to run.
+
 ;; If you add a file to be loaded here, keep the following points in mind:
 
 ;; i) If the file is no-byte-compile, explicitly load the .el version.
@@ -54,33 +57,58 @@
 ;; bidi.c needs for its job.
 (setq redisplay--inhibit-bidi t)
 
+(message "dump mode: %s" dump-mode)
+
 ;; Add subdirectories to the load-path for files that might get
-;; autoloaded when bootstrapping.
+;; autoloaded when bootstrapping or running Emacs normally.
 ;; This is because PATH_DUMPLOADSEARCH is just "../lisp".
-(if (or (equal (member "bootstrap" command-line-args) '("bootstrap"))
+(if (or (member dump-mode '("bootstrap" "pbootstrap"))
        ;; FIXME this is irritatingly fragile.
-       (and (stringp (nth 4 command-line-args))
-            (string-match "^unidata-gen\\(\\.elc?\\)?$"
-                          (nth 4 command-line-args)))
-       (member (nth 7 command-line-args) '("unidata-gen-file"
-                                           "unidata-gen-charprop"))
-       (if (fboundp 'dump-emacs)
-           (string-match "src/bootstrap-emacs" (nth 0 command-line-args))
-         t))
-    (let ((dir (car load-path)))
+        (and (stringp (nth 4 command-line-args))
+             (string-match "^unidata-gen\\(\\.elc?\\)?$"
+                           (nth 4 command-line-args)))
+        (member (nth 7 command-line-args) '("unidata-gen-file"
+                                            "unidata-gen-charprop"))
+        (null dump-mode))
+    (progn
+      ;; Find the entry in load-path that contains Emacs elisp and
+      ;; splice some additional directories in there for the benefit
+      ;; of autoload and regular Emacs use.
+      (let ((subdirs '("emacs-lisp"
+                       "progmodes"
+                       "language"
+                       "international"
+                       "textmodes"
+                       "vc"))
+            (iter load-path))
+        (while iter
+          (let ((dir (car iter))
+                (subdirs subdirs)
+                esubdirs esubdir)
+            (while subdirs
+              (setq esubdir (expand-file-name (car subdirs) dir))
+              (setq subdirs (cdr subdirs))
+              (if (file-directory-p esubdir)
+                  (setq esubdirs (cons esubdir esubdirs))
+                (setq subdirs nil esubdirs nil)))
+            (if esubdirs
+                (progn
+                  (setcdr iter (nconc (nreverse esubdirs) (cdr iter)))
+                  (setq iter nil))
+              (setq iter (cdr iter))
+              (if (null iter)
+                  (signal
+                   'error (list
+                           (format-message
+                            "Could not find elisp load-path: searched %S"
+                            load-path))))))))
       ;; We'll probably overflow the pure space.
       (setq purify-flag nil)
       ;; Value of max-lisp-eval-depth when compiling initially.
-      ;; During bootstrapping the byte-compiler is run interpreted when
-      ;; compiling itself, which uses a lot more stack than usual.
-      (setq max-lisp-eval-depth 2200)
-      (setq load-path (list (expand-file-name "." dir)
-                           (expand-file-name "emacs-lisp" dir)
-                           (expand-file-name "progmodes" dir)
-                           (expand-file-name "language" dir)
-                           (expand-file-name "international" dir)
-                           (expand-file-name "textmodes" dir)
-                           (expand-file-name "vc" dir)))))
+      ;; During bootstrapping the byte-compiler is run interpreted
+      ;; when compiling itself, which uses a lot more stack
+      ;; than usual.
+      (setq max-lisp-eval-depth 2200)))
 
 (if (eq t purify-flag)
     ;; Hash consing saved around 11% of pure space in my tests.
@@ -88,10 +116,7 @@
 
 (message "Using load-path %s" load-path)
 
-;; This is a poor man's `last', since we haven't loaded subr.el yet.
-(if (and (fboundp 'dump-emacs)
-         (or (equal (member "bootstrap" command-line-args) '("bootstrap"))
-             (equal (member "dump" command-line-args) '("dump"))))
+(if dump-mode
     (progn
       ;; To reduce the size of dumped Emacs, we avoid making huge char-tables.
       (setq inhibit-load-charset-map t)
@@ -350,15 +375,16 @@ lost after dumping")))
 ;; file primitive.  So the only workable solution to support building
 ;; in non-ASCII directories is to manipulate unibyte strings in the
 ;; current locale's encoding.
-(if (and (member (car (last command-line-args)) '("dump" "bootstrap"))
-         (fboundp 'dump-emacs)
-        (multibyte-string-p default-directory))
+(if (and dump-mode (multibyte-string-p default-directory))
     (error "default-directory must be unibyte when dumping Emacs!"))
 
 ;; Determine which build number to use
 ;; based on the executables that now exist.
-(if (and (equal (last command-line-args) '("dump"))
-         (fboundp 'dump-emacs)
+(if (and (or
+          (and (equal dump-mode "dump")
+               (fboundp 'dump-emacs))
+          (and (equal dump-mode "pdump")
+               (fboundp 'dump-emacs-portable)))
         (not (eq system-type 'ms-dos)))
     (let* ((base (concat "emacs-" emacs-version "."))
           (exelen (if (eq system-type 'windows-nt) -4))
@@ -376,8 +402,10 @@ lost after dumping")))
 
 
 (message "Finding pointers to doc strings...")
-(if (and (fboundp 'dump-emacs)
-         (equal (last command-line-args) '("dump")))
+(if (and (or (and (fboundp 'dump-emacs)
+                  (equal dump-mode "dump"))
+             (and (fboundp 'dump-emacs-portable)
+                  (equal dump-mode "pdump"))))
     (Snarf-documentation "DOC")
   (condition-case nil
       (Snarf-documentation "DOC")
@@ -446,53 +474,69 @@ lost after dumping")))
 ;; Make sure we will attempt bidi reordering henceforth.
 (setq redisplay--inhibit-bidi nil)
 
-(if (and (fboundp 'dump-emacs)
-         (member (car (last command-line-args)) '("dump" "bootstrap")))
-    (progn
-      ;; Prevent build-time PATH getting stored in the binary.
-      ;; Mainly cosmetic, but helpful for Guix.  (Bug#20330)
-      ;; Do this here, rather than earlier, so that the above code
-      ;; can invoke Git commands and the like.
-      (setq exec-path nil)
-      (message "Dumping under the name emacs")
+(if dump-mode
+    (let ((output (cond ((equal dump-mode "pdump") "emacs.pdmp")
+                        ((equal dump-mode "dump") "emacs")
+                        ((equal dump-mode "bootstrap") "emacs")
+                        ((equal dump-mode "pbootstrap") "bootstrap-emacs.pdmp")
+                        (t (error "unrecognized dump mode %s" dump-mode)))))
+      (message "Dumping under the name %s" output)
       (condition-case ()
-         (delete-file "emacs")
-       (file-error nil))
-      ;; We used to dump under the name xemacs, but that occasionally
-      ;; confused people installing Emacs (they'd install the file
-      ;; under the name `xemacs'), and it's inconsistent with every
-      ;; other GNU program's build process.
-      (dump-emacs "emacs" "temacs")
-      (message "%d pure bytes used" pure-bytes-used)
+          (delete-file output)
+        (file-error nil))
+      ;; On MS-Windows, the current directory is not necessarily the
+      ;; same as invocation-directory.
+      (let (success)
+        (unwind-protect
+             (let ((tmp-dump-mode dump-mode)
+                   (dump-mode nil))
+               (if (member tmp-dump-mode '("pdump" "pbootstrap"))
+                   (dump-emacs-portable (expand-file-name output 
invocation-directory))
+                 (dump-emacs output "temacs")
+                 (message "%d pure bytes used" pure-bytes-used))
+               (setq success t))
+          (unless success
+            (ignore-errors
+              (delete-file output)))))
       ;; Recompute NAME now, so that it isn't set when we dump.
       (if (not (or (eq system-type 'ms-dos)
                    ;; Don't bother adding another name if we're just
                    ;; building bootstrap-emacs.
-                   (equal (last command-line-args) '("bootstrap"))))
-         (let ((name (format "emacs-%s.%d" emacs-version emacs-build-number))
-               (exe (if (eq system-type 'windows-nt) ".exe" "")))
-           (while (string-match "[^-+_.a-zA-Z0-9]+" name)
-             (setq name (concat (downcase (substring name 0 (match-beginning 
0)))
-                                "-"
-                                (substring name (match-end 0)))))
-           (setq name (concat name exe))
-            (message "Adding name %s" name)
-           ;; When this runs on Windows, invocation-directory is not
-           ;; necessarily the current directory.
-           (add-name-to-file (expand-file-name (concat "emacs" exe)
-                                               invocation-directory)
-                             (expand-file-name name invocation-directory)
-                             t)))
+                   (member dump-mode '("pbootstrap" "bootstrap"))))
+          (let ((name (format "emacs-%s.%d" emacs-version emacs-build-number))
+                (exe (if (eq system-type 'windows-nt) ".exe" "")))
+            (while (string-match "[^-+_.a-zA-Z0-9]+" name)
+              (setq name (concat (downcase (substring name 0 (match-beginning 
0)))
+                                 "-"
+                                 (substring name (match-end 0)))))
+            (message "Adding name %s" (concat name exe))
+            ;; When this runs on Windows, invocation-directory is not
+            ;; necessarily the current directory.
+            (add-name-to-file (expand-file-name (concat "emacs" exe)
+                                                invocation-directory)
+                              (expand-file-name (concat name exe)
+                                                invocation-directory)
+                              t)
+            (when (equal dump-mode "pdump")
+              (message "Adding name %s" (concat name ".pdmp"))
+              (add-name-to-file (expand-file-name "emacs.pdmp"
+                                                  invocation-directory)
+                                (expand-file-name (concat name ".pdmp")
+                                                  invocation-directory)
+                                t))))
       (kill-emacs)))
 
-;; For machines with CANNOT_DUMP defined in config.h,
-;; this file must be loaded each time Emacs is run.
+;; This file must be loaded each time Emacs is run from scratch, e.g., temacs.
 ;; So run the startup code now.  First, remove `-l loadup' from args.
 
 (if (and (member (nth 1 command-line-args) '("-l" "--load"))
         (equal (nth 2 command-line-args) "loadup"))
     (setcdr command-line-args (nthcdr 3 command-line-args)))
 
+;; Don't keep `load-file-name' set during the top-level session!
+;; Otherwise, it breaks a lot of code which does things like
+;; (or load-file-name byte-compile-current-file).
+(setq load-file-name nil)
 (eval top-level)
 
 
diff --git a/lisp/locate.el b/lisp/locate.el
index 81e9696..452f746 100644
--- a/lisp/locate.el
+++ b/lisp/locate.el
@@ -1,6 +1,6 @@
-;;; locate.el --- interface to the locate command
+;;; locate.el --- interface to the locate command  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1996, 1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Peter Breton <address@hidden>
 ;; Keywords: unix files
@@ -261,7 +261,7 @@ that is, with a prefix arg, you get the default behavior."
         "Run locate (like this): "
         (cons
          (concat (car locate-cmd) "  "
-                 (mapconcat 'identity (cdr locate-cmd) " "))
+                 (mapconcat #'identity (cdr locate-cmd) " "))
          (+ 2 (length (car locate-cmd))))
         nil nil 'locate-history-list))
     (let* ((default (locate-word-at-point))
@@ -313,7 +313,7 @@ then `locate-post-command-hook'."
              (and (not arg) locate-prompt-for-command))))
 
     ;; Find the Locate buffer
-    (save-window-excursion
+    (save-window-excursion              ;FIXME: What window-excursion?
       (set-buffer (get-buffer-create locate-buffer-name))
       (locate-mode)
       (let ((inhibit-read-only t)
@@ -327,7 +327,7 @@ then `locate-post-command-hook'."
 
        (if run-locate-command
            (shell-command search-string locate-buffer-name)
-         (apply 'call-process locate-cmd nil t nil locate-cmd-args))
+         (apply #'call-process locate-cmd nil t nil locate-cmd-args))
 
        (and filter
             (locate-filter-output filter))
@@ -466,8 +466,8 @@ do not work in subdirectories.
   ;; Avoid clobbering this variable
   (make-local-variable 'dired-subdir-alist)
   (setq default-directory   "/"
-       buffer-read-only    t
-       selective-display   t)
+       buffer-read-only    t)
+  (add-to-invisibility-spec '(dired . t))
   (dired-alist-add-1 default-directory (point-min-marker))
   (set (make-local-variable 'dired-directory) "/")
   (set (make-local-variable 'dired-subdir-switches) locate-ls-subdir-switches)
@@ -554,7 +554,7 @@ do not work in subdirectories.
          locate-regexp-match
          (concat locate-regexp-match ":\n"))
 
-    (insert (apply 'format locate-format-string (reverse locate-format-args)))
+    (insert (apply #'format locate-format-string (reverse locate-format-args)))
 
     (save-excursion
       (goto-char (point-min))
diff --git a/lisp/lpr.el b/lisp/lpr.el
index 33b8da8..436f9e3 100644
--- a/lisp/lpr.el
+++ b/lisp/lpr.el
@@ -1,6 +1,6 @@
 ;;; lpr.el --- print Emacs buffer on line printer
 
-;; Copyright (C) 1985, 1988, 1992, 1994, 2001-2018 Free Software
+;; Copyright (C) 1985, 1988, 1992, 1994, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
@@ -258,7 +258,7 @@ for further customization of the printer command."
 
 (defun lpr-print-region (start end switches name)
   (let ((buf (current-buffer))
-        (nswitches (lpr-flatten-list
+        (nswitches (flatten-tree
                     (mapcar #'lpr-eval-switch ; Dynamic evaluation
                             switches)))
         (switch-string (if switches
@@ -336,23 +336,7 @@ The characters tab, linefeed, space, return and formfeed 
are not affected."
        ((consp arg) (apply (car arg) (cdr arg)))
        (t nil)))
 
-;; `lpr-flatten-list' is defined here (copied from "message.el" and
-;; enhanced to handle dotted pairs as well) until we can get some
-;; sensible autoloads, or `flatten-list' gets put somewhere decent.
-
-;; (lpr-flatten-list '((a . b) c (d . e) (f g h) i . j))
-;; => (a b c d e f g h i j)
-
-(defun lpr-flatten-list (&rest list)
-  (lpr-flatten-list-1 list))
-
-(defun lpr-flatten-list-1 (list)
-  (cond
-   ((null list) nil)
-   ((consp list)
-    (append (lpr-flatten-list-1 (car list))
-           (lpr-flatten-list-1 (cdr list))))
-   (t (list list))))
+(define-obsolete-function-alias 'lpr-flatten-list #'flatten-tree "27.1")
 
 (provide 'lpr)
 
diff --git a/lisp/ls-lisp.el b/lisp/ls-lisp.el
index 95f3163..1f2c468 100644
--- a/lisp/ls-lisp.el
+++ b/lisp/ls-lisp.el
@@ -1,6 +1,6 @@
 ;;; ls-lisp.el --- emulate insert-directory completely in Emacs Lisp  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1992, 1994, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1994, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Sebastian Kremer <address@hidden>
 ;; Modified by: Francis J. Wright <address@hidden>
@@ -475,9 +475,13 @@ not contain `d', so that a full listing is expected."
                       (ls-lisp-classify-file file fattr)
                     file)
                   fattr (file-attribute-size fattr)
-                                 switches time-index))
-       (message "%s: doesn't exist or is inaccessible" file)
-       (ding) (sit-for 2)))))          ; to show user the message!
+                   switches time-index))
+        ;; Emulate what we do on Posix hosts when we call access-file
+        ;; in insert-directory.
+       (signal 'file-error
+                (list "Reading directory"
+                      "Directory doesn't exist or is inaccessible"
+                      file))))))
 
 (declare-function dired-read-dir-and-switches "dired" (str))
 (declare-function dired-goto-next-file "dired" ())
diff --git a/lisp/macros.el b/lisp/macros.el
index 4078b98..ba6a840 100644
--- a/lisp/macros.el
+++ b/lisp/macros.el
@@ -1,6 +1,6 @@
 ;;; macros.el --- non-primitive commands for keyboard macros -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1985-1987, 1992, 1994-1995, 2001-2018 Free Software
+;; Copyright (C) 1985-1987, 1992, 1994-1995, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/mail/binhex.el b/lisp/mail/binhex.el
index fa2ea3d..19fcbaa 100644
--- a/lisp/mail/binhex.el
+++ b/lisp/mail/binhex.el
@@ -1,6 +1,6 @@
 ;;; binhex.el --- decode BinHex-encoded text  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Shenghuo Zhu <address@hidden>
 ;; Keywords: binhex news
diff --git a/lisp/mail/blessmail.el b/lisp/mail/blessmail.el
index 62e9873..62094bf 100644
--- a/lisp/mail/blessmail.el
+++ b/lisp/mail/blessmail.el
@@ -1,6 +1,6 @@
 ;;; blessmail.el --- decide whether movemail needs special privileges -*- 
no-byte-compile: t -*-
 
-;; Copyright (C) 1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: internal
diff --git a/lisp/mail/emacsbug.el b/lisp/mail/emacsbug.el
index 7955167..c637e24 100644
--- a/lisp/mail/emacsbug.el
+++ b/lisp/mail/emacsbug.el
@@ -1,6 +1,6 @@
 ;;; emacsbug.el --- command to report Emacs bugs to appropriate mailing list
 
-;; Copyright (C) 1985, 1994, 1997-1998, 2000-2018 Free Software
+;; Copyright (C) 1985, 1994, 1997-1998, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: K. Shane Hartman
diff --git a/lisp/mail/feedmail.el b/lisp/mail/feedmail.el
index 2b63343..a90d9c4 100644
--- a/lisp/mail/feedmail.el
+++ b/lisp/mail/feedmail.el
@@ -561,7 +561,7 @@ but common in some proprietary systems."
 ;; maybe some distant mail system needs it.  Really, though, if you
 ;; want a sender line in your mail, just put one in there and don't
 ;; wait for feedmail to do it for you.  (Yes, I know all about
-;; RFC-822 and RFC-1123, but are you *really* one of those cases
+;; RFC-822-or-later and RFC-1123, but are you *really* one of those cases
 ;; they're talking about?  I doubt it.)
 (defcustom feedmail-sender-line nil
   "If non-nil and the email has no Sender: header, use this value.
@@ -787,7 +787,7 @@ cases the name element of the fiddle-plex is ignored and is 
hardwired
 by feedmail to either \"Date\" or \"Resent-Date\".
 
 If you decide to format your own date field, do us all a favor and know
-what you're doing.  Study the relevant parts of RFC-822 and RFC-1123.
+what you're doing.  Study the relevant parts of RFC-822-or-later and RFC-1123.
 Don't make me come up there!
 
 You should let feedmail generate a Date: for you unless you are sure
@@ -1514,7 +1514,7 @@ function, for example, to archive all of your sent 
messages someplace
 
 
 (defvar feedmail-is-a-resend nil
-  "Non-nil means the message is a Resend (in the RFC-822 sense).
+  "Non-nil means the message is a Resend (in the RFC-822-or-later sense).
 This affects the composition of certain headers.  feedmail sets this
 variable as soon as it starts prepping the message text buffer, so any
 user-supplied functions can rely on it.  Users shouldn't set or change this
@@ -2369,7 +2369,7 @@ mapped to mostly alphanumerics for safety."
 
 (defun feedmail-rfc822-date (arg-time)
   (feedmail-say-debug ">in-> feedmail-rfc822-date %s" arg-time)
-  (let ((time (if arg-time arg-time (current-time)))
+  (let ((time (or arg-time (current-time)))
        (system-time-locale "C"))
     (concat
      (format-time-string "%a, %e %b %Y %T " time)
@@ -2443,7 +2443,7 @@ mapped to mostly alphanumerics for safety."
 
          (let ((case-fold-search t) (addr-regexp))
            (goto-char (point-min))
-           ;; There are some RFC-822 combinations/cases missed here,
+           ;; There are some RFC-822-or-later combinations/cases missed here,
            ;; but probably good enough and what users expect.
            ;;
            ;; Use resent-* stuff only if there is at least one non-empty one.
diff --git a/lisp/mail/flow-fill.el b/lisp/mail/flow-fill.el
index db2a30a..06279d4 100644
--- a/lisp/mail/flow-fill.el
+++ b/lisp/mail/flow-fill.el
@@ -1,6 +1,6 @@
 ;;; flow-fill.el --- interpret RFC2646 "flowed" text  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <address@hidden>
 ;; Keywords: mail
diff --git a/lisp/mail/footnote.el b/lisp/mail/footnote.el
index f5d280a..81dc11d 100644
--- a/lisp/mail/footnote.el
+++ b/lisp/mail/footnote.el
@@ -1,6 +1,6 @@
 ;;; footnote.el --- footnote support for message mode  -*- lexical-binding:t 
-*-
 
-;; Copyright (C) 1997, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Steven L Baur <address@hidden> (1997-2011)
 ;;         Boruch Baum <address@hidden> (2017-)
@@ -363,7 +363,9 @@ Use Unicode characters for footnoting."
     ("ק" "ר" "ש" "ת" "תק" "תר" "תש" "תת" "תתק")))
 
 (defconst footnote-hebrew-numeric-regex
-  (concat "[" (apply #'concat (apply #'append footnote-hebrew-numeric)) "']+"))
+  (let ((numchars (string-to-list
+                  (apply #'concat (apply #'append footnote-hebrew-numeric)))))
+    (concat (regexp-opt-charset (cons ?' numchars)) "+")))
 ;; (defconst footnote-hebrew-numeric-regex 
"\\([אבגדהוזחט]'\\)?\\(ת\\)?\\(ת\\)?\\([קרשת]\\)?\\([טיכלמנסעפצ]\\)?\\([אבגדהוזחט]\\)?")
 
 (defun footnote--hebrew-numeric (n)
@@ -457,9 +459,19 @@ Conversion is done based upon the current selected style."
 
 (defun footnote--current-regexp ()
   "Return the regexp of the index of the current style."
-  (concat (nth 2 (or (assq footnote-style footnote-style-alist)
-                    (nth 0 footnote-style-alist)))
-         "*"))
+  (let ((regexp (nth 2 (or (assq footnote-style footnote-style-alist)
+                          (nth 0 footnote-style-alist)))))
+    (concat
+     ;; Hack to avoid repetition of repetition.
+     ;; FIXME: I'm not sure the added * makes sense at all; there is
+     ;; always a single number within the footnote-{start,end}-tag pairs.
+     ;; Worse, the code goes on and adds yet another + later on, in
+     ;; footnote-refresh-footnotes, just in case. That makes even less sense.
+     ;; Likely, both the * and the extra + should go away.
+     (if (string-match "[^\\]\\\\\\{2\\}*[*+?]\\'" regexp)
+        (substring regexp 0 -1)
+       regexp)
+     "*")))
 
 (defun footnote--refresh-footnotes (&optional index-regexp)
   "Redraw all footnotes.
diff --git a/lisp/mail/hashcash.el b/lisp/mail/hashcash.el
index 37b2d94..6068952 100644
--- a/lisp/mail/hashcash.el
+++ b/lisp/mail/hashcash.el
@@ -1,6 +1,6 @@
 ;;; hashcash.el --- Add hashcash payments to email  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2003-2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Written by: Paul Foley <address@hidden> (1997-2002)
 ;; Maintainer: address@hidden
@@ -182,8 +182,7 @@ Return immediately.  Call CALLBACK with process and result 
when ready."
        (setq hashcash-process-alist (cons
                                      (cons process (current-buffer))
                                      hashcash-process-alist))
-       (set-process-filter process `(lambda (process output)
-                                      (funcall ,callback process output))))
+       (set-process-filter process callback))
     (funcall callback nil nil)))
 
 (defun hashcash-check-payment (token str val)
@@ -244,8 +243,9 @@ Only start calculation.  Results are inserted when ready."
     (hashcash-generate-payment-async
      (hashcash-payment-to arg)
      (hashcash-payment-required arg)
-     `(lambda (process payment)
-       (hashcash-insert-payment-async-2 ,(current-buffer) process payment)))))
+     (let ((buf (current-buffer)))
+       (lambda (process payment)
+         (hashcash-insert-payment-async-2 buf process payment))))))
 
 (defun hashcash-insert-payment-async-2 (buffer process pay)
   (when (buffer-live-p buffer)
diff --git a/lisp/mail/ietf-drums.el b/lisp/mail/ietf-drums.el
index 0af3221..29752cb 100644
--- a/lisp/mail/ietf-drums.el
+++ b/lisp/mail/ietf-drums.el
@@ -1,6 +1,6 @@
-;;; ietf-drums.el --- Functions for parsing RFC822bis headers  -*- 
lexical-binding:t -*-
+;;; ietf-drums.el --- Functions for parsing RFC 2822 headers  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; This file is part of GNU Emacs.
@@ -20,10 +20,10 @@
 
 ;;; Commentary:
 
-;; DRUMS is an IETF Working Group that works (or worked) on the
-;; successor to RFC822, "Standard For The Format Of Arpa Internet Text
-;; Messages".  This library is based on
-;; draft-ietf-drums-msg-fmt-05.txt, released on 1998-08-05.
+;; DRUMS is an IETF Working Group that worked on Internet RFC 2822,
+;; the successor to RFC 822 and the predecessor of RFC 5322.  This
+;; library is based on draft-ietf-drums-msg-fmt-05.txt, released on
+;; 1998-08-05.
 
 ;; Pending a real regression self test suite, Simon Josefsson added
 ;; various self test expressions snipped from bug reports, and their
@@ -294,7 +294,7 @@ a list of address strings."
 
 (defun ietf-drums-parse-date (string)
   "Return an Emacs time spec from STRING."
-  (apply 'encode-time (parse-time-string string)))
+  (encode-time (parse-time-string string)))
 
 (defun ietf-drums-narrow-to-header ()
   "Narrow to the header section in the current buffer."
diff --git a/lisp/mail/mail-extr.el b/lisp/mail/mail-extr.el
index 7219464..c1e90c3 100644
--- a/lisp/mail/mail-extr.el
+++ b/lisp/mail/mail-extr.el
@@ -1,6 +1,6 @@
-;;; mail-extr.el --- extract full name and address from RFC 822 mail header
+;;; mail-extr.el --- extract full name and address from email header
 
-;; Copyright (C) 1991-1994, 1997, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1991-1994, 1997, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Joe Wells <address@hidden>
@@ -29,15 +29,15 @@
 ;;
 ;;    mail-extract-address-components: (address &optional all)
 ;;
-;;    Given an RFC-822 ADDRESS, extract full name and canonical address.
+;;    Given an RFC-822-or-later ADDRESS, extract name and address.
 ;;    Returns a list of the form (FULL-NAME CANONICAL-ADDRESS).
 ;;    If no name can be extracted, FULL-NAME will be nil.
 ;;    ADDRESS may be a string or a buffer.  If it is a buffer, the visible
 ;;     (narrowed) portion of the buffer will be interpreted as the address.
 ;;     (This feature exists so that the clever caller might be able to avoid
 ;;     consing a string.)
-;;    If ADDRESS contains more than one RFC-822 address, only the first is
-;;     returned.
+;;    If ADDRESS contains more than one RFC-822-or-later address, only
+;;     the first is returned.
 ;;
 ;;    If ALL is non-nil, that means return info about all the addresses
 ;;     that are found in ADDRESS.  The value is a list of elements of
@@ -149,7 +149,7 @@
 ;;     * Handle "null" addresses.  Handle = used for spacing in mailbox
 ;;       name.  Fix bug in handling of ROUTE-ADDR-type addresses that are
 ;;       missing their brackets.  Handle uppercase "JR".  Extract full
-;;       names from X.400 addresses encoded in RFC-822.  Fix bug in
+;;       names from X.400 addresses encoded in RFC-822-or-later.  Fix bug in
 ;;        handling of multiple addresses where first has trailing comment.
 ;;        Handle more kinds of telephone extension lead-ins.
 ;;
@@ -209,7 +209,7 @@
 
 
 (defgroup mail-extr nil
-  "Extract full name and address from RFC 822 mail header."
+  "Extract full name and address from RFC 822 (or later) mail header."
   :prefix "mail-extr-"
   :group 'mail)
 
@@ -288,11 +288,12 @@ by translating things like \"address@hidden" into 
\"address@hidden"."
 (defconst mail-extr-all-letters-but-separators
   (purecopy "][[:alnum:]{|}'~`"))
 
-;; Any character that can occur in a name in an RFC822 address including
-;; the separator (hyphen and possibly period) for multipart names.
+;; Any character that can occur in a name in an RFC 822 (or later)
+;; address including the separator (hyphen and possibly period) for
+;; multipart names.
 ;; #### should . be in here?
 (defconst mail-extr-all-letters
-  (purecopy (concat mail-extr-all-letters-but-separators "---")))
+  (purecopy (concat mail-extr-all-letters-but-separators "-")))
 
 ;; Any character that can start a name.
 ;; Keep this set as minimal as possible.
@@ -304,19 +305,11 @@ by translating things like \"address@hidden" into 
\"address@hidden"."
 
 (defconst mail-extr-leading-garbage "\\W+")
 
-;; (defconst mail-extr-non-name-chars
-;;   (purecopy (concat "^" mail-extr-all-letters ".")))
 ;; (defconst mail-extr-non-begin-name-chars
 ;;   (purecopy (concat "^" mail-extr-first-letters)))
 ;; (defconst mail-extr-non-end-name-chars
 ;;   (purecopy (concat "^" mail-extr-last-letters)))
 
-;; Matches an initial not followed by both a period and a space.
-;; (defconst mail-extr-bad-initials-pattern
-;;   (purecopy
-;;    (format "\\(\\([^%s]\\|\\`\\)[%s]\\)\\(\\.\\([^ ]\\)\\| \\|\\([^%s 
.]\\)\\|\\'\\)"
-;;            mail-extr-all-letters mail-extr-first-letters 
mail-extr-all-letters)))
-
 ;; Matches periods used instead of spaces.  Must not match the period
 ;; following an initial.
 (defconst mail-extr-bad-dot-pattern
@@ -390,7 +383,7 @@ by translating things like \"address@hidden" into 
\"address@hidden"."
 ;; Matches telephone extensions.
 (defconst mail-extr-telephone-extension-pattern
   (purecopy
-   "\\(\\([Ee]xt\\|\\|[Tt]ph\\|[Tt]el\\|[Xx]\\).?\\)? *\\+?[0-9][- 0-9]+"))
+   "\\(\\([Ee]xt\\|[Tt]ph\\|[Tt]el\\|[Xx]\\)\\.?\\)? *\\+?[0-9][- 0-9]+"))
 
 ;; Matches ham radio call signs.
 ;; Help from: Mat Maessen N2NJZ <address@hidden>, Mark Feit
@@ -532,7 +525,8 @@ by translating things like \"address@hidden" into 
\"address@hidden"."
     (?.  ".")
     (?\[ ".")
     (?\] ".")
-    ;; % and ! aren't RFC822 characters, but it is convenient to pretend
+    ;; % and ! aren't RFC 822 (or later) characters,
+    ;; but it is convenient to pretend.
     (?%  ".")
     (?!  ".") ;; this needs to be word-constituent when not in .UUCP mode
     )
@@ -697,7 +691,8 @@ Unless NO-REPLACE is true, at each of the positions in 
LIST-SYMBOL
 
 ;;;###autoload
 (defun mail-extract-address-components (address &optional all)
-  "Given an RFC-822 address ADDRESS, extract full name and canonical address.
+  "Extract full name and canonical address from ADDRESS.
+ADDRESS should be in RFC 822 (or later) format.
 Returns a list of the form (FULL-NAME CANONICAL-ADDRESS).  If no
 name can be extracted, FULL-NAME will be nil.  Also see
 `mail-extr-ignore-single-names' and
@@ -936,10 +931,10 @@ non-display use, you should probably use
          ;; Trim other punctuation lists of items outside < > pair to handle
          ;; stupid MTAs.
          (when <-pos                   ; don't need to check >-pos also
-           ;; handle bozo software that violates RFC 822 by sticking
-           ;; punctuation marks outside of a < > pair
+           ;; Handle bozo software that violates RFC 822 (or later)
+           ;; by sticking punctuation marks outside of a < > pair.
            (mail-extr-nuke-outside-range @-pos <-pos >-pos t)
-           ;; RFC 822 says nothing about these two outside < >, but
+           ;; RFC 822 (or later) says nothing about these two outside < >, but
            ;; remove those positions from the lists to make things
            ;; easier.
            (mail-extr-nuke-outside-range !-pos <-pos >-pos t)
@@ -1325,7 +1320,7 @@ non-display use, you should probably use
                       (narrow-to-region atom-beg atom-end)
                       (cond
 
-                       ;; Handle X.400 addresses encoded in RFC-822.
+                       ;; Handle X.400 addresses encoded in RFC 822 or later.
                        ;; *** Shit!  This has to handle the case where it is
                        ;; *** embedded in a quote too!
                        ;; *** Shit!  The input is being broken up into atoms
diff --git a/lisp/mail/mail-hist.el b/lisp/mail/mail-hist.el
index d5cd06e..9a2fb91 100644
--- a/lisp/mail/mail-hist.el
+++ b/lisp/mail/mail-hist.el
@@ -1,6 +1,6 @@
 ;;; mail-hist.el --- headers and message body history for outgoing mail
 
-;; Copyright (C) 1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Karl Fogel <address@hidden>
 ;; Created: March, 1994
diff --git a/lisp/mail/mail-parse.el b/lisp/mail/mail-parse.el
index 8883db8..d5da9d4 100644
--- a/lisp/mail/mail-parse.el
+++ b/lisp/mail/mail-parse.el
@@ -1,6 +1,6 @@
 ;;; mail-parse.el --- Interface functions for parsing mail
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; This file is part of GNU Emacs.
diff --git a/lisp/mail/mail-prsvr.el b/lisp/mail/mail-prsvr.el
index d8efef7..1240033 100644
--- a/lisp/mail/mail-prsvr.el
+++ b/lisp/mail/mail-prsvr.el
@@ -1,6 +1,6 @@
 ;;; mail-prsvr.el --- Interface variables for parsing mail
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; This file is part of GNU Emacs.
diff --git a/lisp/mail/mail-utils.el b/lisp/mail/mail-utils.el
index 463cec0..cbcbdfa 100644
--- a/lisp/mail/mail-utils.el
+++ b/lisp/mail/mail-utils.el
@@ -1,6 +1,6 @@
 ;;; mail-utils.el --- utility functions used both by rmail and rnews
 
-;; Copyright (C) 1985, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: mail, news
@@ -29,7 +29,7 @@
 
 ;;;###autoload
 (defcustom mail-use-rfc822 nil
-  "If non-nil, use a full, hairy RFC822 parser on mail addresses.
+  "If non-nil, use a full, hairy RFC 822 (or later) parser on mail addresses.
 Otherwise, (the default) use a smaller, somewhat faster, and
 often correct parser."
   :type 'boolean
@@ -384,7 +384,7 @@ The buffer should be narrowed to just the header."
         (date (mail-fetch-field "date"))
         ;; A From: header can contain multiple addresses, a "From "
         ;; line must contain only one.  (Bug#7760)
-        ;; See eg RFC 5322, 3.6.2. Originator Fields.
+        ;; See, e.g., RFC 5322, 3.6.2. Originator Fields.
         (end (string-match "[ \t]*[,\n]" from)))
     (format "From %s %s\n" (if end
                               (substring from 0 end)
diff --git a/lisp/mail/mailabbrev.el b/lisp/mail/mailabbrev.el
index e5456d9..d59df88 100644
--- a/lisp/mail/mailabbrev.el
+++ b/lisp/mail/mailabbrev.el
@@ -1,6 +1,6 @@
 ;;; mailabbrev.el --- abbrev-expansion of mail aliases
 
-;; Copyright (C) 1985-1987, 1992-1993, 1996-1997, 2000-2018 Free
+;; Copyright (C) 1985-1987, 1992-1993, 1996-1997, 2000-2019 Free
 ;; Software Foundation, Inc.
 
 ;; Author: Jamie Zawinski <address@hidden; now address@hidden>
diff --git a/lisp/mail/mailalias.el b/lisp/mail/mailalias.el
index 17b4cdf..42896c1 100644
--- a/lisp/mail/mailalias.el
+++ b/lisp/mail/mailalias.el
@@ -1,6 +1,6 @@
 ;;; mailalias.el --- expand and complete mailing address aliases -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1985, 1987, 1995-1997, 2001-2018 Free Software
+;; Copyright (C) 1985, 1987, 1995-1997, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/mail/mailclient.el b/lisp/mail/mailclient.el
index 9678a3a..4d8cda1 100644
--- a/lisp/mail/mailclient.el
+++ b/lisp/mail/mailclient.el
@@ -1,6 +1,6 @@
 ;;; mailclient.el --- mail sending via system's mail client.
 
-;; Copyright (C) 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005-2019 Free Software Foundation, Inc.
 
 ;; Author: David Reitter <address@hidden>
 ;; Keywords: mail
@@ -152,7 +152,7 @@ The mail client is taken to be the handler of mailto URLs."
                  (setq character-coding (downcase character-coding)))
                (concat
                 "mailto:";
-                ;; some of the headers according to RFC822
+                ;; Some of the headers according to RFC 822 (or later).
                 (mailclient-gather-addresses "To"
                                              'drop-first-name)
                 (mailclient-gather-addresses "cc"  )
diff --git a/lisp/mail/mailheader.el b/lisp/mail/mailheader.el
index 349e045..936f53e 100644
--- a/lisp/mail/mailheader.el
+++ b/lisp/mail/mailheader.el
@@ -1,6 +1,6 @@
 ;;; mailheader.el --- mail header parsing, merging, formatting
 
-;; Copyright (C) 1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Erik Naggum <address@hidden>
 ;; Keywords: tools, mail, news
@@ -23,7 +23,7 @@
 
 ;;; Commentary:
 
-;; This package provides an abstraction to RFC822-style messages, used in
+;; This package provides an abstraction of RFC 822 (or later) format, used in
 ;; mail, news, and some other systems.  The simple syntactic rules for such
 ;; headers, such as quoting and line folding, are routinely reimplemented
 ;; in many individual packages.  This package removes the need for this
diff --git a/lisp/mail/metamail.el b/lisp/mail/metamail.el
index 761de64..6f9f189 100644
--- a/lisp/mail/metamail.el
+++ b/lisp/mail/metamail.el
@@ -1,6 +1,6 @@
 ;;; metamail.el --- Metamail interface for GNU Emacs
 
-;; Copyright (C) 1993, 1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1996, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Masanobu UMEDA <address@hidden>
 ;; Keywords: mail, news, mime, multimedia
diff --git a/lisp/mail/mspools.el b/lisp/mail/mspools.el
index 2e8765e..9c8e72e 100644
--- a/lisp/mail/mspools.el
+++ b/lisp/mail/mspools.el
@@ -1,6 +1,6 @@
 ;;; mspools.el --- show mail spools waiting to be read
 
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Stephen Eglen <address@hidden>
 ;; Maintainer: Stephen Eglen <address@hidden>
diff --git a/lisp/mail/qp.el b/lisp/mail/qp.el
index 7353035..5b49741 100644
--- a/lisp/mail/qp.el
+++ b/lisp/mail/qp.el
@@ -1,6 +1,6 @@
 ;;; qp.el --- Quoted-Printable functions
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: mail, extensions
diff --git a/lisp/mail/reporter.el b/lisp/mail/reporter.el
index ddf8935..10db110 100644
--- a/lisp/mail/reporter.el
+++ b/lisp/mail/reporter.el
@@ -1,6 +1,6 @@
 ;;; reporter.el --- customizable bug reporting of lisp programs
 
-;; Copyright (C) 1993-1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author:          1993-1998 Barry A. Warsaw
 ;; Maintainer: address@hidden
diff --git a/lisp/mail/rfc2045.el b/lisp/mail/rfc2045.el
index fee0fb5..e677d03 100644
--- a/lisp/mail/rfc2045.el
+++ b/lisp/mail/rfc2045.el
@@ -1,6 +1,6 @@
 ;;; rfc2045.el --- Functions for decoding rfc2045 headers
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; This file is part of GNU Emacs.
diff --git a/lisp/mail/rfc2047.el b/lisp/mail/rfc2047.el
index 282fd38..118ca8a 100644
--- a/lisp/mail/rfc2047.el
+++ b/lisp/mail/rfc2047.el
@@ -1,6 +1,6 @@
 ;;; rfc2047.el --- functions for encoding and decoding rfc2047 messages  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;;     MORIOKA Tomohiko <address@hidden>
@@ -338,7 +338,7 @@ The buffer may be narrowed."
 
 ;; Use this syntax table when parsing into regions that may need
 ;; encoding.  Double quotes are string delimiters, backslash is
-;; character quoting, and all other RFC 2822 special characters are
+;; character quoting, and all other RFC 822 (or later) special characters are
 ;; treated as punctuation so we can use forward-sexp/forward-word to
 ;; skip to the end of regions appropriately.  Nb. ietf-drums does
 ;; things differently.
@@ -366,7 +366,7 @@ The buffer may be narrowed."
 
 (defun rfc2047-encode-region (b e &optional dont-fold)
   "Encode words in region B to E that need encoding.
-By default, the region is treated as containing RFC2822 addresses.
+By default, the region is treated as containing RFC 822 (or later) addresses.
 Dynamically bind `rfc2047-encoding-type' to change that."
   (save-restriction
     (narrow-to-region b e)
@@ -403,7 +403,7 @@ Dynamically bind `rfc2047-encoding-type' to change that."
        (with-syntax-table rfc2047-syntax-table
          (goto-char (point-min))
          (condition-case err           ; in case of unbalanced quotes
-             ;; Look for rfc2822-style: sequences of atoms, quoted
+             ;; Look for RFC 822 (or later) style: sequences of atoms, quoted
              ;; strings, specials, whitespace.  (Specials mustn't be
              ;; encoded.)
              (while (not (eobp))
@@ -1025,7 +1025,7 @@ other than `\"' and `\\' in quoted strings."
              (replace-match " "))
            (setq end (point-max))
            ;; Quote decoded words if there are special characters
-           ;; which might violate RFC2822.
+           ;; which might violate RFC 822 (or later).
            (when (and rfc2047-quote-decoded-words-containing-tspecials
                       (let ((regexp (car (rassq
                                           'address-mime
diff --git a/lisp/mail/rfc2231.el b/lisp/mail/rfc2231.el
index 103af55..0a0983c 100644
--- a/lisp/mail/rfc2231.el
+++ b/lisp/mail/rfc2231.el
@@ -1,6 +1,6 @@
 ;;; rfc2231.el --- Functions for decoding rfc2231 headers  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; This file is part of GNU Emacs.
diff --git a/lisp/mail/rfc2368.el b/lisp/mail/rfc2368.el
index e564755..05f27e4 100644
--- a/lisp/mail/rfc2368.el
+++ b/lisp/mail/rfc2368.el
@@ -1,6 +1,6 @@
 ;;; rfc2368.el --- support for rfc2368
 
-;; Copyright (C) 1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Sen Nagata <address@hidden>
 ;; Keywords: mail
diff --git a/lisp/mail/rfc822.el b/lisp/mail/rfc822.el
index dc12f00..a53a77e 100644
--- a/lisp/mail/rfc822.el
+++ b/lisp/mail/rfc822.el
@@ -1,6 +1,6 @@
-;;; rfc822.el --- hairy rfc822 parser for mail and news and suchlike
+;;; rfc822.el --- hairy RFC 822 (or later) parser for mail, news, etc.
 
-;; Copyright (C) 1986-1987, 1990, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1986-1987, 1990, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Richard Mlynarik <address@hidden>
@@ -24,8 +24,8 @@
 
 ;;; Commentary:
 
-;; Support functions for parsing RFC-822 headers, used by mail and news
-;; modes.
+;; Support functions for parsing headers used by mail and news modes.
+;; The header format is specified by Internet RFC 822 and its successors.
 
 ;;; Code:
 
diff --git a/lisp/mail/rmail-spam-filter.el b/lisp/mail/rmail-spam-filter.el
index 99c1a1c..86217e5 100644
--- a/lisp/mail/rmail-spam-filter.el
+++ b/lisp/mail/rmail-spam-filter.el
@@ -1,6 +1,6 @@
 ;;; rmail-spam-filter.el --- spam filter for Rmail, the Emacs mail reader
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 ;; Keywords: email, spam, filter, rmail
 ;; Author: Eli Tziperman <eli AT deas.harvard.edu>
 ;; Package: rmail
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 73a17ee..91291b8 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -1,6 +1,6 @@
 ;;; rmail.el --- main code of "RMAIL" mail reader for Emacs  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1985-1988, 1993-1998, 2000-2018 Free Software
+;; Copyright (C) 1985-1988, 1993-1998, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
@@ -779,8 +779,8 @@ The first parenthesized expression should match the 
MIME-charset name.")
     (concat
      "From "
 
-     ;; Many things can happen to an RFC 822 mailbox before it is put into
-     ;; a `From' line.  The leading phrase can be stripped, e.g.
+     ;; Many things can happen to an RFC 822 (or later) mailbox before it is
+     ;; put into a `From' line.  The leading phrase can be stripped, e.g.
      ;; `Joe <@w.x:address@hidden>' -> `<@w.x:address@hidden>'.  The <> can be 
stripped, e.g.
      ;; `<@x.y:address@hidden>' -> address@hidden:address@hidden'.  Everything 
starting with a CRLF
      ;; can be removed, e.g.
@@ -1003,8 +1003,8 @@ If `rmail-display-summary' is non-nil, make a summary for 
this RMAIL file."
   "Report that the buffer is not in the mbox file format.
 MSGNUM, if present, indicates the malformed message."
   (if msgnum
-      (error "Message %d is not a valid RFC2822 message" msgnum)
-    (error "Message is not a valid RFC2822 message")))
+      (error "Message %d is not a valid RFC 822 (or later) message" msgnum)
+    (error "Message is not a valid RFC 822 (or later) message")))
 
 (defun rmail-convert-babyl-to-mbox ()
   "Convert the mail file from Babyl version 5 to mbox.
@@ -2072,7 +2072,8 @@ Value is the size of the newly read mail after 
conversion."
                   ;; If we just read the password, most likely it is
                   ;; wrong.  Otherwise, see if there is a specific
                   ;; reason to think that the problem is a wrong passwd.
-                  (if (and (rmail-remote-proto-p proto)
+                  (if (and proto
+                            (rmail-remote-proto-p proto)
                            (or got-password
                                (re-search-forward rmail-remote-password-error
                                                   nil t)))
@@ -2147,9 +2148,9 @@ Call with point at the end of the message."
     (insert "\n")))
 
 (defun rmail-add-mbox-headers ()
-  "Validate the RFC2822 format for the new messages.
+  "Validate the RFC 822 (or later) format for the new messages.
 Point should be at the first new message.
-An error is signaled if the new messages are not RFC2822
+An error is signaled if the new messages are not RFC 822 (or later)
 compliant.
 Unless an Rmail attribute header already exists, add it to the
 new messages.  Return the number of new messages."
@@ -2574,7 +2575,7 @@ the message.  Point is at the beginning of the message."
   (save-excursion
     (setq deleted-head
          (cons (if (and (search-forward (concat rmail-attribute-header ": ") 
message-end t)
-                        (looking-at "?D"))
+                        (looking-at "\\?D"))
                    ?D
                  ?\s) deleted-head))))
 
@@ -3914,9 +3915,9 @@ which is an element of rmail-msgref-vector."
             (setq tem (copy-sequence tem))
             (set-text-properties 0 (length tem) nil tem)
             (setq tem (copy-sequence tem))
-            ;; Use prin1 to fake RFC822 quoting
+            ;; Use prin1 to fake RFC 822 (or later) quoting
             (let ((field (prin1-to-string tem)))
-              ;; Wrap it in parens to make it a comment according to RFC822
+              ;; Wrap it in parens to make it a comment.
               (if date
                   (concat "(" field "'s message of " date ")")
                 (concat "(" field ")"))))))
@@ -3945,7 +3946,7 @@ which is an element of rmail-msgref-vector."
              (if message-id
                  ;; "<address@hidden> (message from Unix Loser on 1-Apr-89)"
                  (concat message-id " (" field ")")
-              ;; Wrap in parens to make it a comment, for RFC822.
+              ;; Wrap in parens to make it a comment.
               (concat "(" field ")")))))
         (t
          ;; If we can't kludge it simply, do it correctly
@@ -4543,6 +4544,9 @@ Argument MIME is non-nil if this is a mime message."
 
     (unless armor-end
       (error "Encryption armor beginning has no matching end"))
+    (setq armor-start (move-marker (make-marker) armor-start))
+    (setq armor-end (move-marker (make-marker) armor-end))
+
     (goto-char armor-start)
 
     ;; Because epa--find-coding-system-for-mime-charset not autoloaded.
@@ -4575,15 +4579,16 @@ Argument MIME is non-nil if this is a mime message."
         (mail-unquote-printable-region armor-start
                                        (- (point-max) after-end))))
 
-    ;; Decrypt it, maybe in place, maybe making new buffer.
-    (epa-decrypt-region
-     armor-start (- (point-max) after-end)
-     ;; Call back this function to prepare the output.
-     (lambda ()
-       (let ((inhibit-read-only t))
-         (delete-region armor-start (- (point-max) after-end))
-         (goto-char armor-start)
-         (current-buffer))))
+    (condition-case nil
+       (epa-decrypt-region
+        armor-start (- (point-max) after-end)
+        ;; Call back this function to prepare the output.
+        (lambda ()
+          (let ((inhibit-read-only t))
+            (delete-region armor-start (- (point-max) after-end))
+            (goto-char armor-start)
+            (current-buffer))))
+      (error nil))
 
     (list armor-start (- (point-max) after-end) mime
           armor-end-regexp
@@ -4619,9 +4624,14 @@ Argument MIME is non-nil if this is a mime message."
       (goto-char (point-min))
       (while (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t)
        (let ((coding-system-for-read coding-system-for-read)
-             (case-fold-search t))
-
-          (push (rmail-epa-decrypt-1 mime) decrypts)))
+             (case-fold-search t)
+             (armor-start (match-beginning 0)))
+         ;; Don't decrypt an armor that was copied into
+         ;; the message from a message it is a reply to.
+         (or (equal (buffer-substring (line-beginning-position)
+                                      armor-start)
+                    "> ")
+             (push (rmail-epa-decrypt-1 mime) decrypts))))
 
       (when (and decrypts (eq major-mode 'rmail-mode))
         (rmail-add-label "decrypt"))
diff --git a/lisp/mail/rmailedit.el b/lisp/mail/rmailedit.el
index 91aeb41..01d5524 100644
--- a/lisp/mail/rmailedit.el
+++ b/lisp/mail/rmailedit.el
@@ -1,6 +1,6 @@
 ;;; rmailedit.el --- "RMAIL edit mode"  Edit the current message
 
-;; Copyright (C) 1985, 1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: mail
diff --git a/lisp/mail/rmailkwd.el b/lisp/mail/rmailkwd.el
index 2b1533c..9427796 100644
--- a/lisp/mail/rmailkwd.el
+++ b/lisp/mail/rmailkwd.el
@@ -1,6 +1,6 @@
 ;;; rmailkwd.el --- part of the "RMAIL" mail reader for Emacs
 
-;; Copyright (C) 1985, 1988, 1994, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1985, 1988, 1994, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/mail/rmailmm.el b/lisp/mail/rmailmm.el
index 71038ca..af52813 100644
--- a/lisp/mail/rmailmm.el
+++ b/lisp/mail/rmailmm.el
@@ -1,6 +1,6 @@
 ;;; rmailmm.el --- MIME decoding and display stuff for RMAIL
 
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Alexander Pohoyda
 ;;     Alex Schroeder
diff --git a/lisp/mail/rmailmsc.el b/lisp/mail/rmailmsc.el
index c204d84..ba0c2ae 100644
--- a/lisp/mail/rmailmsc.el
+++ b/lisp/mail/rmailmsc.el
@@ -1,6 +1,6 @@
 ;;; rmailmsc.el --- miscellaneous support functions for the RMAIL mail reader
 
-;; Copyright (C) 1985, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: mail
diff --git a/lisp/mail/rmailout.el b/lisp/mail/rmailout.el
index 824b1a5..12d3761 100644
--- a/lisp/mail/rmailout.el
+++ b/lisp/mail/rmailout.el
@@ -1,6 +1,6 @@
 ;;; rmailout.el --- "RMAIL" mail reader for Emacs: output message to a file
 
-;; Copyright (C) 1985, 1987, 1993-1994, 2001-2018 Free Software
+;; Copyright (C) 1985, 1987, 1993-1994, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/mail/rmailsort.el b/lisp/mail/rmailsort.el
index ecd2fd4..4a70103 100644
--- a/lisp/mail/rmailsort.el
+++ b/lisp/mail/rmailsort.el
@@ -1,6 +1,6 @@
 ;;; rmailsort.el --- Rmail: sort messages
 
-;; Copyright (C) 1990, 1993-1994, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1990, 1993-1994, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Masanobu UMEDA <address@hidden>
diff --git a/lisp/mail/rmailsum.el b/lisp/mail/rmailsum.el
index f8adf77..79a322c 100644
--- a/lisp/mail/rmailsum.el
+++ b/lisp/mail/rmailsum.el
@@ -1,6 +1,6 @@
 ;;; rmailsum.el --- make summary buffers for the mail reader  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1985, 1993-1996, 2000-2018 Free Software Foundation,
+;; Copyright (C) 1985, 1993-1996, 2000-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/mail/sendmail.el b/lisp/mail/sendmail.el
index 6fc91a3..93b6c90 100644
--- a/lisp/mail/sendmail.el
+++ b/lisp/mail/sendmail.el
@@ -1,6 +1,6 @@
 ;;; sendmail.el --- mail sending commands for Emacs  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1985-1986, 1992-1996, 1998, 2000-2018 Free Software
+;; Copyright (C) 1985-1986, 1992-1996, 1998, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
@@ -150,7 +150,7 @@ Otherwise, let mailer send back a message to report errors."
       'smtpmail-send-it 'sendmail-query-once)
   "Function to call to send the current buffer as mail.
 The headers should be delimited by a line which is
-not a valid RFC822 header or continuation line,
+not a valid RFC 822 (or later) header or continuation line,
 that matches the variable `mail-header-separator'.
 This is used by the default mail-sending commands.  See also
 `message-send-mail-function' for use with the Message package."
@@ -908,7 +908,7 @@ the user from the mailer."
            (ml (when mail-mailing-lists
                 ;; The surrounding regexp assumes the use of
                 ;; `mail-strip-quoted-names' on addresses before matching
-                ;; Cannot deal with full RFC 822 freedom, but that is
+                ;; Cannot deal with full RFC 822 (or later), but that is
                 ;; unlikely to be problematic.
                 (concat "\\(?:[[:space:];,]\\|\\`\\)"
                         (regexp-opt mail-mailing-lists t)
@@ -1044,7 +1044,7 @@ This function does not perform RFC2047 encoding."
                 (fullname-end (point-marker)))
             (goto-char fullname-start)
             ;; Look for a character that cannot appear unquoted
-            ;; according to RFC 822.
+            ;; according to RFC 822 (or later).
             (if (or (re-search-forward "[^- !#-'*+/-9=?A-Z^-~]"
                                        fullname-end 1)
                     quote-fullname)
@@ -1068,8 +1068,7 @@ This function does not perform RFC2047 encoding."
                 (insert "\""))
             (let ((fullname-end (point-marker)))
               (goto-char fullname-start)
-              ;; RFC 822 says \ and nonmatching parentheses
-              ;; must be escaped in comments.
+              ;; \ and nonmatching parentheses must be escaped in comments.
               ;; Escape every instance of ()\ ...
               (while (re-search-forward "[()\\]" fullname-end 1)
                 (replace-match "\\\\\\&" t))
diff --git a/lisp/mail/smtpmail.el b/lisp/mail/smtpmail.el
index 8a1e86b..f31e0b4 100644
--- a/lisp/mail/smtpmail.el
+++ b/lisp/mail/smtpmail.el
@@ -1,6 +1,6 @@
 ;;; smtpmail.el --- simple SMTP protocol (RFC 821) for sending mail  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1995-1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-1996, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Tomoji Kagatani <address@hidden>
 ;; Maintainer: Simon Josefsson <address@hidden>
@@ -259,7 +259,7 @@ for `smtpmail-try-auth-method'.")
                               (fullname-end (point-marker)))
                           (goto-char fullname-start)
                           ;; Look for a character that cannot appear unquoted
-                          ;; according to RFC 822.
+                          ;; according to RFC 822 or its successors.
                           (if (re-search-forward "[^- !#-'*+/-9=?A-Z^-~]"
                                                  fullname-end 1)
                               (progn
@@ -277,8 +277,9 @@ for `smtpmail-try-auth-method'.")
                           (insert fullname)
                           (let ((fullname-end (point-marker)))
                             (goto-char fullname-start)
-                            ;; RFC 822 says \ and nonmatching parentheses
-                            ;; must be escaped in comments.
+                            ;; RFC 822 and its successors say \ and
+                            ;; nonmatching parentheses must be
+                            ;; escaped in comments.
                             ;; Escape every instance of ()\ ...
                             (while (re-search-forward "[()\\]" fullname-end 1)
                               (replace-match "\\\\\\&" t))
diff --git a/lisp/mail/supercite.el b/lisp/mail/supercite.el
index ce061e2..ad69dca 100644
--- a/lisp/mail/supercite.el
+++ b/lisp/mail/supercite.el
@@ -1,6 +1,6 @@
 ;;; supercite.el --- minor mode for citing mail and news replies
 
-;; Copyright (C) 1993, 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: 1993 Barry A. Warsaw <address@hidden>
 ;; Maintainer: address@hidden
@@ -315,7 +315,7 @@ during the initial citing via `sc-cite-original'."
   :group 'supercite-hooks)
 
 (defcustom sc-mail-warn-if-non-rfc822-p t
-  "Warn if mail headers don't conform to RFC822."
+  "Warn if mail headers don't conform to RFC 822 (or later)."
   :type 'boolean
   :group 'supercite-attr)
 (defcustom sc-mumble ""
@@ -738,10 +738,10 @@ If optional ATTRIBS-P is non-nil, the key/value pair is 
placed in
   nil)
 
 (defun sc-mail-error-in-mail-field ()
-  "Issue warning that mail headers don't conform to RFC 822."
+  "Issue warning that mail headers don't conform to email RFCs."
   (let* ((len (min (length curline) 10))
         (ellipsis (if (< len (length curline)) "..." ""))
-        (msg "Mail header \"%s%s\" doesn't conform to RFC 822. skipping..."))
+        (msg "Mail header \"%s%s\" doesn't conform to RFC 822 (or later). 
skipping..."))
     (message msg (substring curline 0 len) ellipsis))
   (beep)
   (sit-for 2)
diff --git a/lisp/mail/uce.el b/lisp/mail/uce.el
index dfe5c9c..7225cda 100644
--- a/lisp/mail/uce.el
+++ b/lisp/mail/uce.el
@@ -1,6 +1,6 @@
 ;;; uce.el --- facilitate reply to unsolicited commercial email
 
-;; Copyright (C) 1996, 1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1998, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: stanislav shalunov <address@hidden>
 ;; Created: 10 Dec 1996
diff --git a/lisp/mail/undigest.el b/lisp/mail/undigest.el
index 8d46be8..bbf3c83 100644
--- a/lisp/mail/undigest.el
+++ b/lisp/mail/undigest.el
@@ -1,6 +1,6 @@
 ;;; undigest.el --- digest-cracking support for the RMAIL mail reader  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1985-1986, 1994, 1996, 2001-2018 Free Software
+;; Copyright (C) 1985-1986, 1994, 1996, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/mail/unrmail.el b/lisp/mail/unrmail.el
index a74bcf3..4d9ad67 100644
--- a/lisp/mail/unrmail.el
+++ b/lisp/mail/unrmail.el
@@ -1,6 +1,6 @@
 ;;; unrmail.el --- convert Rmail Babyl files to mbox files
 
-;; Copyright (C) 1992, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: mail
diff --git a/lisp/mail/uudecode.el b/lisp/mail/uudecode.el
index b8f74e3..32e668b 100644
--- a/lisp/mail/uudecode.el
+++ b/lisp/mail/uudecode.el
@@ -1,6 +1,6 @@
 ;;; uudecode.el -- elisp native uudecode  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Shenghuo Zhu <address@hidden>
 ;; Keywords: uudecode news
diff --git a/lisp/mail/yenc.el b/lisp/mail/yenc.el
index 25b4ebb..75b62c1 100644
--- a/lisp/mail/yenc.el
+++ b/lisp/mail/yenc.el
@@ -1,6 +1,6 @@
 ;;; yenc.el --- elisp native yenc decoder  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Jesper Harder <address@hidden>
 ;; Keywords: yenc news
diff --git a/lisp/makesum.el b/lisp/makesum.el
index a50f093..10ad78e 100644
--- a/lisp/makesum.el
+++ b/lisp/makesum.el
@@ -1,6 +1,6 @@
 ;;; makesum.el --- generate key binding summary for Emacs
 
-;; Copyright (C) 1985, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: help
diff --git a/lisp/man.el b/lisp/man.el
index defe992..b1d0fd3 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -1,6 +1,6 @@
 ;;; man.el --- browse UNIX manual pages -*- lexical-binding: t -*-
 
-;; Copyright (C) 1993-1994, 1996-1997, 2001-2018 Free Software
+;; Copyright (C) 1993-1994, 1996-1997, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Barry A. Warsaw <address@hidden>
@@ -318,7 +318,7 @@ This regular expression should start with a `^' character.")
 
 (defvar Man-reference-regexp
   (concat "\\(" Man-name-regexp
-         "\\(‐?\n[ \t]+" Man-name-regexp "\\)*\\)[ \t]*(\\("
+         "\\(\\([-‐]\n\\)?[ \t]+" Man-name-regexp "\\)*\\)[ \t]*(\\("
          Man-section-regexp "\\))")
   "Regular expression describing a reference to another manpage.")
 
@@ -664,7 +664,7 @@ and the `Man-section-translations-alist' variables)."
      ;; "chmod(2V)" case ?
      ((string-match (concat "^" Man-reference-regexp "$") ref)
       (setq name (replace-regexp-in-string "[\n\t ]" "" (match-string 1 ref))
-           section (match-string 3 ref)))
+           section (match-string 4 ref)))
      ;; "2v chmod" case ?
      ((string-match (concat "^\\(" Man-section-regexp
                            "\\) +\\(" Man-name-regexp "\\)$") ref)
@@ -783,11 +783,22 @@ POS defaults to `point'."
       ;;     see this-
       ;;     command-here(1)
       ;; Note: This code gets executed iff our entry is after POS.
-      (when (looking-at "‐?[ \t\r\n]+\\([-a-zA-Z0-9._+:]+\\)([0-9])")
-       (setq word (concat word (match-string-no-properties 1)))
+      (when (looking-at
+             (concat
+              "‐?[ \t\r\n]+\\([-a-zA-Z0-9._+:]+\\)(" Man-section-regexp ")"))
+        (let ((1st-part word))
+          (setq word (concat word (match-string-no-properties 1)))
+          ;; If they use -Tascii, we cannot know whether a hyphen at
+          ;; EOL is or isn't part of the referenced manpage name.
+          ;; Heuristics: if the part of the manpage before the hyphen
+          ;; doesn't include a hyphen, we consider the hyphen to be
+          ;; added by troff, and remove it.
+          (or (not (eq (string-to-char (substring 1st-part -1)) ?-))
+              (string-match-p "-" (substring 1st-part 0 -1))
+              (setq word (replace-regexp-in-string "-" "" word))))
        ;; Make sure the section number gets included by the code below.
        (goto-char (match-end 1)))
-      (when (string-match "[-._]+$" word)
+      (when (string-match "[-._‐]+$" word)
        (setq word (substring word 0 (match-beginning 0))))
       ;; The following was commented out since the preceding code
       ;; should not produce a leading "*" in the first place.
diff --git a/lisp/master.el b/lisp/master.el
index 7176897..a054d7f 100644
--- a/lisp/master.el
+++ b/lisp/master.el
@@ -1,6 +1,6 @@
 ;;; master.el --- make a buffer the master over another buffer
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Alex Schroeder <address@hidden>
 ;; Maintainer: Alex Schroeder <address@hidden>
diff --git a/lisp/mb-depth.el b/lisp/mb-depth.el
index 84c73ca..61673ee 100644
--- a/lisp/mb-depth.el
+++ b/lisp/mb-depth.el
@@ -1,6 +1,6 @@
 ;;; mb-depth.el --- Indicate minibuffer-depth in prompt -*- lexical-binding: t 
-*-
 ;;
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Miles Bader <address@hidden>
 ;; Keywords: convenience
diff --git a/lisp/md4.el b/lisp/md4.el
index 788846a..7091c20 100644
--- a/lisp/md4.el
+++ b/lisp/md4.el
@@ -1,6 +1,6 @@
 ;;; md4.el --- MD4 Message Digest Algorithm. -*- lexical-binding: t -*-
 
-;; Copyright (C) 2001, 2004, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2004, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Taro Kawagishi <address@hidden>
 ;; Keywords: MD4
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 1081fb4..4ff60ed 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -1,6 +1,6 @@
 ;;; menu-bar.el --- define a default menu bar
 
-;; Copyright (C) 1993-1995, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1995, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Richard M. Stallman
 ;; Maintainer: address@hidden
@@ -309,7 +309,7 @@
       menu-bar-separator)
 
     (bindings--define-key menu [tags-continue]
-      '(menu-item "Continue Tags Search" multifile-continue
+      '(menu-item "Continue Tags Search" fileloop-continue
                   :help "Continue last tags search operation"))
     (bindings--define-key menu [tags-srch]
       '(menu-item "Search Tagged Files..." tags-search
@@ -358,7 +358,7 @@
 (defvar menu-bar-replace-menu
   (let ((menu (make-sparse-keymap "Replace")))
     (bindings--define-key menu [tags-repl-continue]
-      '(menu-item "Continue Replace" multifile-continue
+      '(menu-item "Continue Replace" fileloop-continue
                   :help "Continue last tags replace operation"))
     (bindings--define-key menu [tags-repl]
       '(menu-item "Replace in Tagged Files..." tags-query-replace
diff --git a/lisp/mh-e/ChangeLog.1 b/lisp/mh-e/ChangeLog.1
index 1f08c78..c870e59 100644
--- a/lisp/mh-e/ChangeLog.1
+++ b/lisp/mh-e/ChangeLog.1
@@ -11419,7 +11419,7 @@
        (dist): Leave release in current directory.
 
 
-  Copyright (C) 2003-2018 Free Software Foundation, Inc.
+  Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/mh-e/ChangeLog.2 b/lisp/mh-e/ChangeLog.2
index 37bb34d..6d3b8e3 100644
--- a/lisp/mh-e/ChangeLog.2
+++ b/lisp/mh-e/ChangeLog.2
@@ -3673,7 +3673,7 @@
 
 See ChangeLog.1 for earlier changes.
 
-  Copyright (C) 2005-2018 Free Software Foundation, Inc.
+  Copyright (C) 2005-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/mh-e/mh-acros.el b/lisp/mh-e/mh-acros.el
index 76e4ef7..3bbf509 100644
--- a/lisp/mh-e/mh-acros.el
+++ b/lisp/mh-e/mh-acros.el
@@ -1,6 +1,6 @@
 ;;; mh-acros.el --- macros used in MH-E
 
-;; Copyright (C) 2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Satyaki Das <address@hidden>
 ;; Maintainer: Bill Wohler <address@hidden>
@@ -143,6 +143,8 @@ check if variable `transient-mark-mode' is active."
 
 ;;;###mh-autoload
 (defmacro mh-defstruct (name-spec &rest fields)
+  ;; FIXME: Use `cl-defstruct' instead: shouldn't emit warnings any
+  ;; more nor depend on run-time CL functions.
   "Replacement for `defstruct' from the \"cl\" package.
 The `defstruct' in the \"cl\" library produces compiler warnings,
 and generates code that uses functions present in \"cl\" at
@@ -160,15 +162,17 @@ more details."
          (constructor (or (and (consp name-spec)
                                (cadr (assoc :constructor (cdr name-spec))))
                           (intern (format "make-%s" struct-name))))
-         (field-names (mapcar #'(lambda (x) (if (atom x) x (car x))) fields))
-         (field-init-forms (mapcar #'(lambda (x) (and (consp x) (cadr x)))
-                                   fields))
+         (fields (mapcar (lambda (x)
+                           (if (atom x)
+                               (list x nil)
+                             (list (car x) (cadr x))))
+                         fields))
+         (field-names (mapcar #'car fields))
          (struct (gensym "S"))
          (x (gensym "X"))
          (y (gensym "Y")))
     `(progn
-       (defun* ,constructor (&key ,@(mapcar* #'(lambda (x y) (list x y))
-                                             field-names field-init-forms))
+       (defun* ,constructor (&key ,@fields)
          (list (quote ,struct-name) ,@field-names))
        (defun ,predicate (arg)
          (and (consp arg) (eq (car arg) (quote ,struct-name))))
diff --git a/lisp/mh-e/mh-alias.el b/lisp/mh-e/mh-alias.el
index 257d6b3..c6cdfc4 100644
--- a/lisp/mh-e/mh-alias.el
+++ b/lisp/mh-e/mh-alias.el
@@ -1,6 +1,6 @@
 ;;; mh-alias.el --- MH-E mail alias completion and expansion
 
-;; Copyright (C) 1994-1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Peter S. Galbraith <address@hidden>
 ;; Maintainer: Bill Wohler <address@hidden>
@@ -80,9 +80,7 @@ If ARG is non-nil, set timestamp with the current time."
                        (when (and file (file-exists-p file))
                          (setq stamp (file-attribute-modification-time
                                      (file-attributes file)))
-                         (or (> (car stamp) (car mh-alias-tstamp))
-                             (and (= (car stamp) (car mh-alias-tstamp))
-                                  (> (cadr stamp) (cadr mh-alias-tstamp)))))))
+                        (time-less-p mh-alias-tstamp stamp))))
                     (mh-alias-filenames t)))))))
 
 (defun mh-alias-filenames (arg)
@@ -340,7 +338,7 @@ NO-COMMA-SWAP is non-nil."
     ;; Two words -> first.last
     (downcase
      (format "%s.%s" (match-string 1 string) (match-string 2 string))))
-   ((string-match "^\\([-a-zA-Z0-9._]+\\)@[-a-zA-z0-9_]+\\.+[a-zA-Z0-9]+$"
+   ((string-match "^\\([-a-zA-Z0-9._]+\\)@[-a-zA-Z0-9_]+\\.+[a-zA-Z0-9]+$"
                   string)
     ;; email only -> downcase username
     (downcase (match-string 1 string)))
diff --git a/lisp/mh-e/mh-buffers.el b/lisp/mh-e/mh-buffers.el
index eeb1f7b..3c0c481 100644
--- a/lisp/mh-e/mh-buffers.el
+++ b/lisp/mh-e/mh-buffers.el
@@ -1,6 +1,6 @@
 ;;; mh-buffers.el --- MH-E buffer constants and utilities
 
-;; Copyright (C) 1993, 1995, 1997, 2000-2018 Free Software Foundation,
+;; Copyright (C) 1993, 1995, 1997, 2000-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Bill Wohler <address@hidden>
diff --git a/lisp/mh-e/mh-comp.el b/lisp/mh-e/mh-comp.el
index 5c474b4..b96ef74 100644
--- a/lisp/mh-e/mh-comp.el
+++ b/lisp/mh-e/mh-comp.el
@@ -1,6 +1,6 @@
 ;;; mh-comp.el --- MH-E functions for composing and sending messages
 
-;; Copyright (C) 1993, 1995, 1997, 2000-2018 Free Software Foundation,
+;; Copyright (C) 1993, 1995, 1997, 2000-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Bill Wohler <address@hidden>
@@ -612,7 +612,7 @@ See also `mh-compose-forward-as-mime-flag',
               (goto-char (mh-mail-header-end))
               (while
                   (re-search-forward
-                   "^#forw \\[\\([^]]+\\)\\] \\(+\\S-+\\) \\(.*\\)$"
+                   "^#forw \\[\\([^]]+\\)\\] \\(\\+\\S-+\\) \\(.*\\)$"
                    (point-max) t)
                 (let ((description (if (equal (match-string 1)
                                               "forwarded messages")
diff --git a/lisp/mh-e/mh-compat.el b/lisp/mh-e/mh-compat.el
index ffeb693..eb173df 100644
--- a/lisp/mh-e/mh-compat.el
+++ b/lisp/mh-e/mh-compat.el
@@ -1,6 +1,6 @@
 ;;; mh-compat.el --- make MH-E compatible with various versions of Emacs
 
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Bill Wohler <address@hidden>
 ;; Maintainer: Bill Wohler <address@hidden>
diff --git a/lisp/mh-e/mh-e.el b/lisp/mh-e/mh-e.el
index 54a62b8..bc09764 100644
--- a/lisp/mh-e/mh-e.el
+++ b/lisp/mh-e/mh-e.el
@@ -1,6 +1,6 @@
 ;;; mh-e.el --- GNU Emacs interface to the MH mail system
 
-;; Copyright (C) 1985-1988, 1990, 1992-1995, 1997, 1999-2018 Free
+;; Copyright (C) 1985-1988, 1990, 1992-1995, 1997, 1999-2019 Free
 ;; Software Foundation, Inc.
 
 ;; Author: Bill Wohler <address@hidden>
@@ -2420,14 +2420,14 @@ of citations entirely, choose \"None\"."
   :package-version '(MH-E . "8.0"))
 
 ;; These entries have been intentionally excluded by the developers.
-;;  "Comments:"                         ; RFC 2822 - show this one
+;;  "Comments:"                         ; RFC 822 (or later) - show this one
 ;;  "Fax:"                              ; 
http://people.dsv.su.se/~jpalme/ietf/mail-headers/
 ;;  "Mail-System-Version:"              ; 
http://people.dsv.su.se/~jpalme/ietf/mail-headers/
 ;;  "Mailer:"                           ; 
http://people.dsv.su.se/~jpalme/ietf/mail-headers/
 ;;  "Organization:"                     ;
 ;;  "Phone:"                            ; 
http://people.dsv.su.se/~jpalme/ietf/mail-headers/
 ;;  "Reply-By:"                         ; RFC 2156
-;;  "Reply-To:"                         ; RFC 2822
+;;  "Reply-To:"                         ; RFC 822 (or later)
 ;;  "Sender:"                           ;
 ;;  "User-Agent:"                       ; Similar to X-Mailer, so display it.
 ;;  "X-Mailer:"                         ;
@@ -2488,9 +2488,9 @@ of citations entirely, choose \"None\"."
     "From "                             ; sendmail
     "Generate-Delivery-Report:"         ; RFC 2156
     "Importance:"                       ; RFC 2156, 2421
-    "In-Reply-To:"                      ; RFC 2822
+    "In-Reply-To:"                      ; RFC 822 (or later)
     "Incomplete-Copy:"                  ; RFC 2156
-    "Keywords:"                         ; RFC 2822
+    "Keywords:"                         ; RFC 822 (or later)
     "Language:"                         ; RFC 2156
     "Lines:"                            ; RFC 1036
     "List-"                             ; RFC 2369, 2919
@@ -2500,7 +2500,7 @@ of citations entirely, choose \"None\"."
     "Mail-Reply-To:"                    ; 
http://people.dsv.su.se/~jpalme/ietf/mail-headers/
     "Mailing-List:"                     ; Egroups/yahoogroups mailing list 
manager
     "Message-Content:"                  ; 
http://people.dsv.su.se/~jpalme/ietf/mail-headers/
-    "Message-Id:"                       ; RFC 822
+    "Message-ID:"                       ; RFC 822 (or later)
     "Message-Type:"                     ; RFC 2156
     "Mime-Version"                      ; RFC 2045
     "Msgid:"
@@ -2531,14 +2531,14 @@ of citations entirely, choose \"None\"."
     "Priority:"                         ; RFC 2156
     "Read-Receipt-To:"                  ; 
http://people.dsv.su.se/~jpalme/ietf/mail-headers/
     "Received-SPF:"                     ; Gmail
-    "Received:"                         ; RFC 822
-    "References:"                       ; RFC 2822
+    "Received:"                         ; RFC 822 (or later)
+    "References:"                       ; RFC 822 (or later)
     "Registered-Mail-Reply-Requested-By:"       ; 
http://people.dsv.su.se/~jpalme/ietf/mail-headers/
     "Remailed-"                         ; MH
     "Replaces:"                         ; 
http://people.dsv.su.se/~jpalme/ietf/mail-headers/
     "Replied:"                          ; MH
-    "Resent-"                           ; RFC 2822
-    "Return-Path:"                      ; RFC 822
+    "Resent-"                           ; RFC 822 (or later)
+    "Return-Path:"                      ; RFC 822 (or later)
     "Return-Receipt-Requested:"         ; 
http://people.dsv.su.se/~jpalme/ietf/mail-headers/
     "Return-Receipt-To:"                ; 
http://people.dsv.su.se/~jpalme/ietf/mail-headers/
     "Seal-Send-Time:"
diff --git a/lisp/mh-e/mh-folder.el b/lisp/mh-e/mh-folder.el
index 1d4291c..caf4071 100644
--- a/lisp/mh-e/mh-folder.el
+++ b/lisp/mh-e/mh-folder.el
@@ -1,6 +1,6 @@
 ;;; mh-folder.el --- MH-Folder mode
 
-;; Copyright (C) 2002-2003, 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2003, 2005-2019 Free Software Foundation, Inc.
 
 ;; Author: Bill Wohler <address@hidden>
 ;; Maintainer: Bill Wohler <address@hidden>
diff --git a/lisp/mh-e/mh-funcs.el b/lisp/mh-e/mh-funcs.el
index 3574f8c..da7c87e 100644
--- a/lisp/mh-e/mh-funcs.el
+++ b/lisp/mh-e/mh-funcs.el
@@ -1,6 +1,6 @@
 ;;; mh-funcs.el --- MH-E functions not everyone will use right away
 
-;; Copyright (C) 1993, 1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Bill Wohler <address@hidden>
 ;; Maintainer: Bill Wohler <address@hidden>
diff --git a/lisp/mh-e/mh-gnus.el b/lisp/mh-e/mh-gnus.el
index 3d20289..61d531f 100644
--- a/lisp/mh-e/mh-gnus.el
+++ b/lisp/mh-e/mh-gnus.el
@@ -1,6 +1,6 @@
 ;;; mh-gnus.el --- make MH-E compatible with various versions of Gnus
 
-;; Copyright (C) 2003-2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Satyaki Das <address@hidden>
 ;; Maintainer: Bill Wohler <address@hidden>
diff --git a/lisp/mh-e/mh-identity.el b/lisp/mh-e/mh-identity.el
index a1eb22f..1d929e8 100644
--- a/lisp/mh-e/mh-identity.el
+++ b/lisp/mh-e/mh-identity.el
@@ -1,6 +1,6 @@
 ;;; mh-identity.el --- multiple identify support for MH-E
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Peter S. Galbraith <address@hidden>
 ;; Maintainer: Bill Wohler <address@hidden>
diff --git a/lisp/mh-e/mh-inc.el b/lisp/mh-e/mh-inc.el
index 34efe13..21034bc 100644
--- a/lisp/mh-e/mh-inc.el
+++ b/lisp/mh-e/mh-inc.el
@@ -1,6 +1,6 @@
 ;;; mh-inc.el --- MH-E "inc" and separate mail spool handling
 
-;; Copyright (C) 2003-2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Peter S. Galbraith <address@hidden>
 ;; Maintainer: Bill Wohler <address@hidden>
diff --git a/lisp/mh-e/mh-junk.el b/lisp/mh-e/mh-junk.el
index 0a50e02..db80f90 100644
--- a/lisp/mh-e/mh-junk.el
+++ b/lisp/mh-e/mh-junk.el
@@ -1,6 +1,6 @@
 ;;; mh-junk.el --- MH-E interface to anti-spam measures
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author: Satyaki Das <address@hidden>,
 ;;         Bill Wohler <address@hidden>
diff --git a/lisp/mh-e/mh-letter.el b/lisp/mh-e/mh-letter.el
index 71a4623..4fc31ed 100644
--- a/lisp/mh-e/mh-letter.el
+++ b/lisp/mh-e/mh-letter.el
@@ -1,6 +1,6 @@
 ;;; mh-letter.el --- MH-Letter mode
 
-;; Copyright (C) 1993, 1995, 1997, 2000-2018 Free Software Foundation,
+;; Copyright (C) 1993, 1995, 1997, 2000-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Bill Wohler <address@hidden>
diff --git a/lisp/mh-e/mh-limit.el b/lisp/mh-e/mh-limit.el
index a04bc90..27dda79 100644
--- a/lisp/mh-e/mh-limit.el
+++ b/lisp/mh-e/mh-limit.el
@@ -1,6 +1,6 @@
 ;;; mh-limit.el --- MH-E display limits
 
-;; Copyright (C) 2001-2003, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2003, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Peter S. Galbraith <address@hidden>
 ;; Maintainer: Bill Wohler <address@hidden>
diff --git a/lisp/mh-e/mh-mime.el b/lisp/mh-e/mh-mime.el
index 0385e5f..9901548 100644
--- a/lisp/mh-e/mh-mime.el
+++ b/lisp/mh-e/mh-mime.el
@@ -1,6 +1,6 @@
 ;;; mh-mime.el --- MH-E MIME support
 
-;; Copyright (C) 1993, 1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Bill Wohler <address@hidden>
 ;; Maintainer: Bill Wohler <address@hidden>
diff --git a/lisp/mh-e/mh-print.el b/lisp/mh-e/mh-print.el
index c6df05e..033c1cb 100644
--- a/lisp/mh-e/mh-print.el
+++ b/lisp/mh-e/mh-print.el
@@ -1,6 +1,6 @@
 ;;; mh-print.el --- MH-E printing support
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author: Jeffrey C Honig <address@hidden>
 ;; Maintainer: Bill Wohler <address@hidden>
diff --git a/lisp/mh-e/mh-scan.el b/lisp/mh-e/mh-scan.el
index f3ad7c6..cd689d6 100644
--- a/lisp/mh-e/mh-scan.el
+++ b/lisp/mh-e/mh-scan.el
@@ -1,6 +1,6 @@
 ;;; mh-scan.el --- MH-E scan line constants and utilities
 
-;; Copyright (C) 1993, 1995, 1997, 2000-2018 Free Software Foundation,
+;; Copyright (C) 1993, 1995, 1997, 2000-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Bill Wohler <address@hidden>
diff --git a/lisp/mh-e/mh-search.el b/lisp/mh-e/mh-search.el
index 8b8ba96..c017bae 100644
--- a/lisp/mh-e/mh-search.el
+++ b/lisp/mh-e/mh-search.el
@@ -1,6 +1,6 @@
 ;;; mh-search  ---  MH-Search mode
 
-;; Copyright (C) 1993, 1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Indexed search by Satyaki Das <address@hidden>
 ;; Maintainer: Bill Wohler <address@hidden>
@@ -495,16 +495,16 @@ group of results."
     (let ((point (point)))
       (forward-line (if backward-flag 0 1))
       (cond ((if backward-flag
-                 (re-search-backward "^+" (point-min) t)
-               (re-search-forward "^+" (point-max) t))
+                 (re-search-backward "^\\+" (point-min) t)
+               (re-search-forward "^\\+" (point-max) t))
              (beginning-of-line))
             ((and (if backward-flag
                       (goto-char (point-max))
                     (goto-char (point-min)))
                   nil))
             ((if backward-flag
-                 (re-search-backward "^+" (point-min) t)
-               (re-search-forward "^+" (point-max) t))
+                 (re-search-backward "^\\+" (point-min) t)
+               (re-search-forward "^\\+" (point-max) t))
              (beginning-of-line))
             (t (goto-char point))))))
 
@@ -1429,7 +1429,7 @@ being the list of messages originally from that folder."
         (setq which-func-mode t))
     (let ((alist ()))
       (goto-char (point-min))
-      (while (re-search-forward "^+" nil t)
+      (while (re-search-forward "^\\+" nil t)
         (save-excursion
           (beginning-of-line)
           (push (cons (buffer-substring-no-properties
diff --git a/lisp/mh-e/mh-seq.el b/lisp/mh-e/mh-seq.el
index eeec984..f7d7c62 100644
--- a/lisp/mh-e/mh-seq.el
+++ b/lisp/mh-e/mh-seq.el
@@ -1,6 +1,6 @@
 ;;; mh-seq.el --- MH-E sequences support
 
-;; Copyright (C) 1993, 1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Bill Wohler <address@hidden>
 ;; Maintainer: Bill Wohler <address@hidden>
diff --git a/lisp/mh-e/mh-show.el b/lisp/mh-e/mh-show.el
index 4eebd06..7dad81d 100644
--- a/lisp/mh-e/mh-show.el
+++ b/lisp/mh-e/mh-show.el
@@ -1,6 +1,6 @@
 ;;; mh-show.el --- MH-Show mode
 
-;; Copyright (C) 1993, 1995, 1997, 2000-2018 Free Software Foundation,
+;; Copyright (C) 1993, 1995, 1997, 2000-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Bill Wohler <address@hidden>
diff --git a/lisp/mh-e/mh-speed.el b/lisp/mh-e/mh-speed.el
index 539e39a..3e89d1b 100644
--- a/lisp/mh-e/mh-speed.el
+++ b/lisp/mh-e/mh-speed.el
@@ -1,6 +1,6 @@
 ;;; mh-speed.el --- MH-E speedbar support
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Satyaki Das <address@hidden>
 ;; Maintainer: Bill Wohler <address@hidden>
diff --git a/lisp/mh-e/mh-thread.el b/lisp/mh-e/mh-thread.el
index ff8e660..0fc560b 100644
--- a/lisp/mh-e/mh-thread.el
+++ b/lisp/mh-e/mh-thread.el
@@ -1,6 +1,6 @@
 ;;; mh-thread.el --- MH-E threading support
 
-;; Copyright (C) 2002-2004, 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2004, 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Satyaki Das <address@hidden>
 ;; Maintainer: Bill Wohler <address@hidden>
diff --git a/lisp/mh-e/mh-tool-bar.el b/lisp/mh-e/mh-tool-bar.el
index 3214487..41610b2 100644
--- a/lisp/mh-e/mh-tool-bar.el
+++ b/lisp/mh-e/mh-tool-bar.el
@@ -1,6 +1,6 @@
 ;;; mh-tool-bar.el --- MH-E tool bar support
 
-;; Copyright (C) 2002-2003, 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2003, 2005-2019 Free Software Foundation, Inc.
 
 ;; Author: Satyaki Das <address@hidden>
 ;; Maintainer: Bill Wohler <address@hidden>
diff --git a/lisp/mh-e/mh-utils.el b/lisp/mh-e/mh-utils.el
index 7bda0a6..cad6278 100644
--- a/lisp/mh-e/mh-utils.el
+++ b/lisp/mh-e/mh-utils.el
@@ -1,6 +1,6 @@
 ;;; mh-utils.el --- MH-E general utilities
 
-;; Copyright (C) 1993, 1995, 1997, 2000-2018 Free Software Foundation,
+;; Copyright (C) 1993, 1995, 1997, 2000-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Bill Wohler <address@hidden>
@@ -888,7 +888,7 @@ in this situation."
 ;;;###mh-autoload
 (defun mh-header-field-beginning ()
   "Move to the beginning of the current header field.
-Handles RFC 822 continuation lines."
+Handle RFC 822 (or later) continuation lines."
   (beginning-of-line)
   (while (looking-at "^[ \t]")
     (forward-line -1)))
@@ -896,7 +896,7 @@ Handles RFC 822 continuation lines."
 ;;;###mh-autoload
 (defun mh-header-field-end ()
   "Move to the end of the current header field.
-Handles RFC 822 continuation lines."
+Handle RFC 822 (or later) continuation lines."
   (forward-line 1)
   (while (looking-at "^[ \t]")
     (forward-line 1))
diff --git a/lisp/mh-e/mh-xface.el b/lisp/mh-e/mh-xface.el
index 52e453d..ddb001a 100644
--- a/lisp/mh-e/mh-xface.el
+++ b/lisp/mh-e/mh-xface.el
@@ -1,6 +1,6 @@
 ;;; mh-xface.el --- MH-E X-Face and Face header field display
 
-;; Copyright (C) 2002-2003, 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2003, 2005-2019 Free Software Foundation, Inc.
 
 ;; Author: Bill Wohler <address@hidden>
 ;; Maintainer: Bill Wohler <address@hidden>
@@ -197,7 +197,7 @@ The directories are searched for in the order they appear 
in the list.")
                         (mh-funcall-if-exists ietf-drums-parse-address
                                               from-field))))
            (host (and from
-                      (string-match "\\([^+]*\\)\\(+.*\\)address@hidden(.*\\)" 
from)
+                      (string-match 
"\\([^+]*\\)\\(\\+.*\\)address@hidden(.*\\)" from)
                       (downcase (match-string 3 from))))
            (user (and host (downcase (match-string 1 from))))
            (canonical-address (format "address@hidden" user host))
diff --git a/lisp/midnight.el b/lisp/midnight.el
index 7c4096c..86c1e21 100644
--- a/lisp/midnight.el
+++ b/lisp/midnight.el
@@ -1,6 +1,6 @@
 ;;; midnight.el --- run something every midnight, e.g., kill old buffers  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Sam Steingold <address@hidden>
 ;; Maintainer: Sam Steingold <address@hidden>
diff --git a/lisp/minibuf-eldef.el b/lisp/minibuf-eldef.el
index a81e663..7fd08ab 100644
--- a/lisp/minibuf-eldef.el
+++ b/lisp/minibuf-eldef.el
@@ -1,6 +1,6 @@
 ;;; minibuf-eldef.el --- Only show defaults in prompts when applicable  -*- 
lexical-binding: t -*-
 ;;
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Miles Bader <address@hidden>
 ;; Keywords: convenience
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index f8e328f..dbd24df 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1,6 +1,6 @@
 ;;; minibuffer.el --- Minibuffer completion functions -*- lexical-binding: t 
-*-
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Package: emacs
@@ -174,10 +174,14 @@ ACTION can be one of nil, t or `lambda'."
 
 (defun completion-table-dynamic (fun &optional switch-buffer)
   "Use function FUN as a dynamic completion table.
-FUN is called with one argument, the string for which completion is required,
-and it should return an alist containing all the intended possible completions.
-This alist may be a full list of possible completions so that FUN can ignore
-the value of its argument.
+FUN is called with one argument, the string for which completion is requested,
+and it should return a completion table containing all the intended possible
+completions.
+This table is allowed to include elements that do not actually match the
+string: they will be automatically filtered out.
+The completion table returned by FUN can use any of the usual formats of
+completion tables such as lists, alists, and hash-tables.
+
 If SWITCH-BUFFER is non-nil and completion is performed in the
 minibuffer, FUN will be called in the buffer from which the minibuffer
 was entered.
@@ -185,6 +189,8 @@ was entered.
 The result of the `completion-table-dynamic' form is a function
 that can be used as the COLLECTION argument to `try-completion' and
 `all-completions'.  See Info node `(elisp)Programmed Completion'.
+The completion table returned by `completion-table-dynamic' has empty
+metadata and trivial boundaries.
 
 See also the related function `completion-table-with-cache'."
   (lambda (string pred action)
@@ -263,7 +269,7 @@ the form (concat S2 S)."
                     (+ beg (- (length s1) (length s2))))
               . ,(and (eq (car-safe res) 'boundaries) (cddr res)))))
          ((stringp res)
-          (if (string-prefix-p s2 string completion-ignore-case)
+          (if (string-prefix-p s2 res completion-ignore-case)
               (concat s1 (substring res (length s2)))))
          ((eq action t)
           (let ((bounds (completion-boundaries str table pred "")))
@@ -676,9 +682,9 @@ for use at QPOS."
 ;; (defmacro complete-in-turn (a b) `(completion-table-in-turn ,a ,b))
 ;; (defmacro dynamic-completion-table (fun) `(completion-table-dynamic ,fun))
 (define-obsolete-function-alias
-  'complete-in-turn 'completion-table-in-turn "23.1")
+  'complete-in-turn #'completion-table-in-turn "23.1")
 (define-obsolete-function-alias
-  'dynamic-completion-table 'completion-table-dynamic "23.1")
+  'dynamic-completion-table #'completion-table-dynamic "23.1")
 
 ;;; Minibuffer completion
 
@@ -696,7 +702,7 @@ If ARGS are provided, then pass MESSAGE through 
`format-message'."
   (if (not (minibufferp (current-buffer)))
       (progn
         (if args
-            (apply 'message message args)
+            (apply #'message message args)
           (message "%s" message))
         (prog1 (sit-for (or minibuffer-message-timeout 1000000))
           (message nil)))
@@ -788,6 +794,11 @@ Additionally the user can use the char \"*\" as a glob 
pattern.")
 I.e. when completing \"foo_bar\" (where _ is the position of point),
 it will consider all completions candidates matching the glob
 pattern \"*foo*bar*\".")
+    (flex
+     completion-flex-try-completion completion-flex-all-completions
+     "Completion of an in-order subset of characters.
+When completing \"foo\" the glob \"*f*o*o*\" is used, so that
+\"foo\" can complete to \"frodo\".")
     (initials
      completion-initials-try-completion completion-initials-all-completions
      "Completion of acronyms and initialisms.
@@ -835,7 +846,7 @@ styles for specific categories, such as files, buffers, 
etc."
 (defvar completion-category-defaults
   '((buffer (styles . (basic substring)))
     (unicode-name (styles . (basic substring)))
-    (project-file (styles . (basic substring)))
+    (project-file (styles . (substring)))
     (info-menu (styles . (basic substring))))
   "Default settings for specific completion categories.
 Each entry has the shape (CATEGORY . ALIST) where ALIST is
@@ -1003,7 +1014,7 @@ completion candidates than this number."
 
 (defvar-local completion-all-sorted-completions nil)
 (defvar-local completion--all-sorted-completions-location nil)
-(defvar completion-cycling nil)
+(defvar completion-cycling nil)      ;Function that takes down the cycling map.
 
 (defvar completion-fail-discreetly nil
   "If non-nil, stay quiet when there  is no match.")
@@ -1035,7 +1046,7 @@ when the buffer's text is already an exact match."
   (let* ((string (buffer-substring beg end))
          (md (completion--field-metadata beg))
          (comp (funcall (or try-completion-function
-                            'completion-try-completion)
+                            #'completion-try-completion)
                         string
                         minibuffer-completion-table
                         minibuffer-completion-predicate
@@ -1188,7 +1199,7 @@ scroll the window of possible completions."
 
 (defun completion--cache-all-sorted-completions (beg end comps)
   (add-hook 'after-change-functions
-            'completion--flush-all-sorted-completions nil t)
+            #'completion--flush-all-sorted-completions nil t)
   (setq completion--all-sorted-completions-location
         (cons (copy-marker beg) (copy-marker end)))
   (setq completion-all-sorted-completions comps))
@@ -1198,8 +1209,10 @@ scroll the window of possible completions."
                (or (> start (cdr completion--all-sorted-completions-location))
                    (< end (car completion--all-sorted-completions-location))))
     (remove-hook 'after-change-functions
-                 'completion--flush-all-sorted-completions t)
-    (setq completion-cycling nil)
+                 #'completion--flush-all-sorted-completions t)
+    ;; Remove the transient map if applicable.
+    (when completion-cycling
+      (funcall (prog1 completion-cycling (setq completion-cycling nil))))
     (setq completion-all-sorted-completions nil)))
 
 (defun completion--metadata (string base md-at-point table pred)
@@ -1239,15 +1252,23 @@ scroll the window of possible completions."
           (setq all (delete-dups all))
           (setq last (last all))
 
-          (setq all (if sort-fun (funcall sort-fun all)
-                      ;; Prefer shorter completions, by default.
-                      (sort all (lambda (c1 c2) (< (length c1) (length c2))))))
-          ;; Prefer recently used completions.
-          (when (minibufferp)
-            (let ((hist (symbol-value minibuffer-history-variable)))
-              (setq all (sort all (lambda (c1 c2)
-                                    (> (length (member c1 hist))
-                                       (length (member c2 hist))))))))
+          (cond
+           (sort-fun
+            (setq all (funcall sort-fun all)))
+           (t
+            ;; Prefer shorter completions, by default.
+            (setq all (sort all (lambda (c1 c2) (< (length c1) (length c2)))))
+            (if (minibufferp)
+                ;; Prefer recently used completions and put the default, if
+                ;; it exists, on top.
+                (let ((hist (symbol-value minibuffer-history-variable)))
+                  (setq all
+                        (sort all
+                              (lambda (c1 c2)
+                                (cond ((equal c1 minibuffer-default) t)
+                                      ((equal c2 minibuffer-default) nil)
+                                      (t (> (length (member c1 hist))
+                                            (length (member c2 hist))))))))))))
           ;; Cache the result.  This is not just for speed, but also so that
           ;; repeated calls to minibuffer-force-complete can cycle through
           ;; all possibilities.
@@ -1257,16 +1278,23 @@ scroll the window of possible completions."
 (defun minibuffer-force-complete-and-exit ()
   "Complete the minibuffer with first of the matches and exit."
   (interactive)
-  (minibuffer-force-complete)
+  ;; If `completion-cycling' is t, then surely a
+  ;; `minibuffer-force-complete' has already executed.  This is not
+  ;; just for speed: the extra rotation caused by the second
+  ;; unnecessary call would mess up the final result value
+  ;; (bug#34116).
+  (unless completion-cycling
+    (minibuffer-force-complete nil nil 'dont-cycle))
   (completion--complete-and-exit
    (minibuffer-prompt-end) (point-max) #'exit-minibuffer
    ;; If the previous completion completed to an element which fails
    ;; test-completion, then we shouldn't exit, but that should be rare.
    (lambda () (minibuffer-message "Incomplete"))))
 
-(defun minibuffer-force-complete (&optional start end)
+(defun minibuffer-force-complete (&optional start end dont-cycle)
   "Complete the minibuffer to an exact match.
-Repeated uses step through the possible completions."
+Repeated uses step through the possible completions.
+DONT-CYCLE tells the function not to setup cycling."
   (interactive)
   (setq minibuffer-scroll-window nil)
   ;; FIXME: Need to deal with the extra-size issue here as well.
@@ -1279,7 +1307,7 @@ Repeated uses step through the possible completions."
          (base (+ start (or (cdr (last all)) 0))))
     (cond
      ((not (consp all))
-        (completion--message
+      (completion--message
        (if all "No more completions" "No completions")))
      ((not (consp (cdr all)))
       (let ((done (equal (car all) (buffer-substring-no-properties base end))))
@@ -1290,33 +1318,34 @@ Repeated uses step through the possible completions."
       (completion--replace base end (car all))
       (setq end (+ base (length (car all))))
       (completion--done (buffer-substring-no-properties start (point)) 'sole)
-      ;; Set cycling after modifying the buffer since the flush hook resets it.
-      (setq completion-cycling t)
       (setq this-command 'completion-at-point) ;For completion-in-region.
-      ;; If completing file names, (car all) may be a directory, so we'd now
-      ;; have a new set of possible completions and might want to reset
-      ;; completion-all-sorted-completions to nil, but we prefer not to,
-      ;; so that repeated calls minibuffer-force-complete still cycle
-      ;; through the previous possible completions.
-      (let ((last (last all)))
-        (setcdr last (cons (car all) (cdr last)))
-        (completion--cache-all-sorted-completions start end (cdr all)))
-      ;; Make sure repeated uses cycle, even though completion--done might
-      ;; have added a space or something that moved us outside of the field.
-      ;; (bug#12221).
-      (let* ((table minibuffer-completion-table)
-             (pred minibuffer-completion-predicate)
-             (extra-prop completion-extra-properties)
-             (cmd
-              (lambda () "Cycle through the possible completions."
-                (interactive)
-                (let ((completion-extra-properties extra-prop))
-                  (completion-in-region start (point) table pred)))))
-        (set-transient-map
-         (let ((map (make-sparse-keymap)))
-           (define-key map [remap completion-at-point] cmd)
-           (define-key map (vector last-command-event) cmd)
-           map)))))))
+      ;; Set cycling after modifying the buffer since the flush hook resets it.
+      (unless dont-cycle
+        ;; If completing file names, (car all) may be a directory, so we'd now
+        ;; have a new set of possible completions and might want to reset
+        ;; completion-all-sorted-completions to nil, but we prefer not to,
+        ;; so that repeated calls minibuffer-force-complete still cycle
+        ;; through the previous possible completions.
+        (let ((last (last all)))
+          (setcdr last (cons (car all) (cdr last)))
+          (completion--cache-all-sorted-completions start end (cdr all)))
+        ;; Make sure repeated uses cycle, even though completion--done might
+        ;; have added a space or something that moved us outside of the field.
+        ;; (bug#12221).
+        (let* ((table minibuffer-completion-table)
+               (pred minibuffer-completion-predicate)
+               (extra-prop completion-extra-properties)
+               (cmd
+                (lambda () "Cycle through the possible completions."
+                  (interactive)
+                  (let ((completion-extra-properties extra-prop))
+                    (completion-in-region start (point) table pred)))))
+          (setq completion-cycling
+                (set-transient-map
+                 (let ((map (make-sparse-keymap)))
+                   (define-key map [remap completion-at-point] cmd)
+                   (define-key map (vector last-command-event) cmd)
+                   map)))))))))
 
 (defvar minibuffer-confirm-exit-commands
   '(completion-at-point minibuffer-complete
@@ -1534,7 +1563,7 @@ horizontally in alphabetical order, rather than down the 
screen."
 Uses columns to keep the listing readable but compact.
 It also eliminates runs of equal strings."
   (when (consp strings)
-    (let* ((length (apply 'max
+    (let* ((length (apply #'max
                          (mapcar (lambda (s)
                                    (if (consp s)
                                        (+ (string-width (car s))
@@ -2268,7 +2297,7 @@ Useful to give the user default values that won't be 
substituted."
   (if (and (not (file-name-quoted-p filename))
            (file-name-absolute-p filename)
            (string-match-p (if (memq system-type '(windows-nt ms-dos))
-                               "[/\\\\]~" "/~")
+                               "[/\\]~" "/~")
                            (file-local-name filename)))
       (file-name-quote filename)
     (minibuffer--double-dollars filename)))
@@ -2282,7 +2311,7 @@ Useful to give the user default values that won't be 
substituted."
   ;; We can't reuse env--substitute-vars-regexp because we need to match only
   ;; potentially-unfinished envvars at end of string.
   (concat "\\(?:^\\|[^$]\\(?:\\$\\$\\)*\\)"
-          "$\\([[:alnum:]_]*\\|{\\([^}]*\\)\\)\\'"))
+          "\\$\\([[:alnum:]_]*\\|{\\([^}]*\\)\\)\\'"))
 
 (defun completion--embedded-envvar-table (string _pred action)
   "Completion table for envvars embedded in a string.
@@ -2323,7 +2352,7 @@ same as `substitute-in-file-name'."
                      (match-beginning 0)))))))
        (t
         (if (eq (aref string (1- beg)) ?{)
-            (setq table (apply-partially 'completion-table-with-terminator
+            (setq table (apply-partially #'completion-table-with-terminator
                                          "}" table)))
         ;; Even if file-name completion is case-insensitive, we want
         ;; envvar completion to be case-sensitive.
@@ -2457,7 +2486,7 @@ except that it passes the file name through 
`substitute-in-file-name'.")
                             #'completion--file-name-table)
   "Internal subroutine for `read-file-name'.  Do not call this.")
 
-(defvar read-file-name-function 'read-file-name-default
+(defvar read-file-name-function #'read-file-name-default
   "The function called by `read-file-name' to do its work.
 It should accept the same arguments as `read-file-name'.")
 
@@ -2732,8 +2761,8 @@ See `read-file-name' for the meaning of the arguments."
 BUFFER nil or omitted means use the current buffer.
 Like `internal-complete-buffer', but removes BUFFER from the completion list."
   (let ((except (if (stringp buffer) buffer (buffer-name buffer))))
-    (apply-partially 'completion-table-with-predicate
-                    'internal-complete-buffer
+    (apply-partially #'completion-table-with-predicate
+                    #'internal-complete-buffer
                     (lambda (name)
                       (not (equal (if (consp name) (car name) name) except)))
                     nil)))
@@ -3023,6 +3052,17 @@ PATTERN is as returned by 
`completion-pcm--string->pattern'."
            (when (string-match-p regex c) (push c poss)))
          (nreverse poss))))))
 
+(defvar flex-score-match-tightness 100
+  "Controls how the `flex' completion style scores its matches.
+
+Value is a positive number.  Values smaller than one make the
+scoring formula value matches scattered along the string, while
+values greater than one make the formula value tighter matches.
+I.e \"foo\" matches both strings \"barbazfoo\" and \"fabrobazo\",
+which are of equal length, but only a value greater than one will
+score the former (which has one \"hole\") higher than the
+latter (which has two).")
+
 (defun completion-pcm--hilit-commonality (pattern completions)
   (when completions
     (let* ((re (completion-pcm--pattern->regex pattern 'group))
@@ -3037,20 +3077,67 @@ PATTERN is as returned by 
`completion-pcm--string->pattern'."
          (let* ((pos (if point-idx (match-beginning point-idx) (match-end 0)))
                 (md (match-data))
                 (start (pop md))
-                (end (pop md)))
+                (end (pop md))
+                (len (length str))
+                ;; To understand how this works, consider these bad
+                ;; ascii(tm) diagrams showing how the pattern \"foo\"
+                ;; flex-matches \"fabrobazo" and
+                ;; \"barfoobaz\":
+
+                ;;      f abr o baz o
+                ;;      + --- + --- +
+
+                ;;      bar foo baz
+                ;;      --- +++ ---
+
+                ;; Where + indicates parts where the pattern matched,
+                ;; - where it didn't match.  The score is a number
+                ;; bound by ]0..1]: the higher the better and only a
+                ;; perfect match (pattern equals string) will have
+                ;; score 1.  The formula takes the form of a quotient.
+                ;; For the numerator, we use the number of +, i.e. the
+                ;; length of the pattern.  For the denominator, it
+                ;; sums (1+ (/ (grouplen - 1)
+                ;; flex-score-match-tightness)) across all groups of
+                ;; -, sums one to that total, and then multiples by
+                ;; the length of the string.
+                (score-numerator 0)
+                (score-denominator 0)
+                (last-b 0)
+                (update-score
+                 (lambda (a b)
+                   "Update score variables given match range (A B)."
+                   (setq
+                    score-numerator   (+ score-numerator (- b a)))
+                   (unless (= a last-b)
+                     (setq
+                      score-denominator (+ score-denominator
+                                           1
+                                           (/ (- a last-b 1)
+                                              flex-score-match-tightness
+                                              1.0))))
+                   (setq
+                    last-b              b))))
+           (funcall update-score start start)
            (while md
+             (funcall update-score start (car md))
              (put-text-property start (pop md)
                                 'font-lock-face 'completions-common-part
                                 str)
              (setq start (pop md)))
+           (funcall update-score len len)
            (put-text-property start end
                               'font-lock-face 'completions-common-part
                               str)
            (if (> (length str) pos)
                (put-text-property pos (1+ pos)
-                                 'font-lock-face 'completions-first-difference
-                                 str)))
-        str)
+                                  'font-lock-face 'completions-first-difference
+                                  str))
+           (unless (zerop (length str))
+             (put-text-property
+              0 1 'completion-score
+              (/ score-numerator (* len (1+ score-denominator)) 1.0) str)))
+         str)
        completions))))
 
 (defun completion-pcm--find-all-completions (string table pred point
@@ -3331,7 +3418,12 @@ the same set of elements."
 ;;; Substring completion
 ;; Mostly derived from the code of `basic' completion.
 
-(defun completion-substring--all-completions (string table pred point)
+(defun completion-substring--all-completions
+    (string table pred point &optional transform-pattern-fn)
+  "Match the presumed substring STRING to the entries in TABLE.
+Respect PRED and POINT.  The pattern used is a PCM-style
+substring pattern, but it be massaged by TRANSFORM-PATTERN-FN, if
+that is non-nil."
   (let* ((beforepoint (substring string 0 point))
          (afterpoint (substring string point))
          (bounds (completion-boundaries beforepoint table pred afterpoint))
@@ -3342,6 +3434,9 @@ the same set of elements."
          (pattern (if (not (stringp (car basic-pattern)))
                       basic-pattern
                     (cons 'prefix basic-pattern)))
+         (pattern (if transform-pattern-fn
+                      (funcall transform-pattern-fn pattern)
+                    pattern))
          (all (completion-pcm--all-completions prefix pattern table pred)))
     (list all pattern prefix suffix (car bounds))))
 
@@ -3361,6 +3456,52 @@ the same set of elements."
       (nconc (completion-pcm--hilit-commonality pattern all)
              (length prefix)))))
 
+;;; "flex" completion, also known as flx/fuzzy/scatter completion
+;; Completes "foo" to "frodo" and "farfromsober"
+
+(defun completion-flex--make-flex-pattern (pattern)
+  "Convert PCM-style PATTERN into PCM-style flex pattern.
+
+This turns
+    (prefix \"foo\" point)
+into
+    (prefix \"f\" any \"o\" any \"o\" any point)
+which is at the core of flex logic.  The extra
+'any' is optimized away later on."
+  (mapcan (lambda (elem)
+            (if (stringp elem)
+                (mapcan (lambda (char)
+                          (list (string char) 'any))
+                        elem)
+              (list elem)))
+          pattern))
+
+(defun completion-flex-try-completion (string table pred point)
+  "Try to flex-complete STRING in TABLE given PRED and POINT."
+  (pcase-let ((`(,all ,pattern ,prefix ,suffix ,_carbounds)
+               (completion-substring--all-completions
+                string table pred point
+                #'completion-flex--make-flex-pattern)))
+    (if minibuffer-completing-file-name
+        (setq all (completion-pcm--filename-try-filter all)))
+    ;; Try some "merging", meaning add as much as possible to the
+    ;; user's pattern without losing any possible matches in `all'.
+    ;; i.e this will augment "cfi" to "config" if all candidates
+    ;; contain the substring "config".  FIXME: this still won't
+    ;; augment "foo" to "froo" when matching "frodo" and
+    ;; "farfromsober".
+    (completion-pcm--merge-try pattern all prefix suffix)))
+
+(defun completion-flex-all-completions (string table pred point)
+  "Get flex-completions of STRING in TABLE, given PRED and POINT."
+  (pcase-let ((`(,all ,pattern ,prefix ,_suffix ,_carbounds)
+               (completion-substring--all-completions
+                string table pred point
+                #'completion-flex--make-flex-pattern)))
+    (when all
+      (nconc (completion-pcm--hilit-commonality pattern all)
+             (length prefix)))))
+
 ;; Initials completion
 ;; Complete /ums to /usr/monnier/src or lch to list-command-history.
 
@@ -3403,7 +3544,7 @@ the same set of elements."
     (when newstr
       (completion-pcm-try-completion newstr table pred (length newstr)))))
 
-(defvar completing-read-function 'completing-read-default
+(defvar completing-read-function #'completing-read-default
   "The function called by `completing-read' to do its work.
 It should accept the same arguments as `completing-read'.")
 
diff --git a/lisp/misc.el b/lisp/misc.el
index f1d5eea..4cf6cad 100644
--- a/lisp/misc.el
+++ b/lisp/misc.el
@@ -1,6 +1,6 @@
 ;;; misc.el --- some nonstandard editing and utility commands for Emacs
 
-;; Copyright (C) 1989, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1989, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: convenience
diff --git a/lisp/misearch.el b/lisp/misearch.el
index 1ad08fe..ae0ba45 100644
--- a/lisp/misearch.el
+++ b/lisp/misearch.el
@@ -1,6 +1,6 @@
 ;;; misearch.el --- isearch extensions for multi-buffer search
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Juri Linkov <address@hidden>
 ;; Keywords: matching
diff --git a/lisp/mouse-copy.el b/lisp/mouse-copy.el
index fa1cac3..c3df17b 100644
--- a/lisp/mouse-copy.el
+++ b/lisp/mouse-copy.el
@@ -1,6 +1,6 @@
 ;;; mouse-copy.el --- one-click text copy and move
 
-;; Copyright (C) 1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: John Heidemann <address@hidden>
 ;; Keywords: mouse
diff --git a/lisp/mouse-drag.el b/lisp/mouse-drag.el
index 805cfe4..55de2a4 100644
--- a/lisp/mouse-drag.el
+++ b/lisp/mouse-drag.el
@@ -1,6 +1,6 @@
 ;;; mouse-drag.el --- use mouse-2 to do a new style of scrolling
 
-;; Copyright (C) 1996-1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: John Heidemann <address@hidden>
 ;; Keywords: mouse
diff --git a/lisp/mouse.el b/lisp/mouse.el
index e25b664..835eaa3 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -1,6 +1,6 @@
 ;;; mouse.el --- window system-independent mouse support  -*- lexical-binding: 
t -*-
 
-;; Copyright (C) 1993-1995, 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1995, 1999-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: hardware, mouse
@@ -98,7 +98,7 @@ point at the click position."
 
 (defun mouse--down-1-maybe-follows-link (&optional _prompt)
   (when mouse-1-click-follows-link
-    (setq mouse--last-down (cons (car-safe last-input-event) (float-time))))
+    (setq mouse--last-down (cons (car-safe last-input-event) (current-time))))
   nil)
 
 (defun mouse--click-1-maybe-follows-link (&optional _prompt)
@@ -110,8 +110,10 @@ Expects to be bound to `(double-)mouse-1' in 
`key-translation-map'."
          ('double (eq 'double-mouse-1 (car-safe last-input-event)))
          (_ (and (eq 'mouse-1 (car-safe last-input-event))
                  (or (not (numberp mouse-1-click-follows-link))
-                     (funcall (if (< mouse-1-click-follows-link 0) #'> #'<)
-                              (- (float-time) (cdr mouse--last-down))
+                    (funcall (if (< mouse-1-click-follows-link 0)
+                                 (lambda (a b) (time-less-p b a))
+                               #'time-less-p)
+                             (time-since (cdr mouse--last-down))
                               (/ (abs mouse-1-click-follows-link) 1000.0))))))
        (eq (car mouse--last-down)
            (event-convert-list (list 'down (car-safe last-input-event))))
diff --git a/lisp/mpc.el b/lisp/mpc.el
index ebd2abb..8e557ed 100644
--- a/lisp/mpc.el
+++ b/lisp/mpc.el
@@ -1,6 +1,6 @@
 ;;; mpc.el --- A client for the Music Player Daemon   -*- lexical-binding: t 
-*-
 
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords: multimedia
@@ -2555,7 +2555,6 @@ If stopped, start playback."
 (defvar mpc--faster-toggle-forward nil)
 (defvar mpc--faster-acceleration 0.5)
 (defun mpc--faster-toggle (speedup step)
-  (setq speedup (float speedup))
   (if mpc--faster-toggle-timer
       (mpc--faster-stop)
     (mpc-status-refresh) (mpc-proc-sync)
@@ -2582,7 +2581,7 @@ If stopped, start playback."
                    (setq songtime (string-to-number
                                    (cdr (assq 'time mpc-status))))
                    (setq songduration (mpc--songduration))
-                   (setq oldtime (float-time)))
+                  (setq oldtime (current-time)))
                   ((and (>= songtime songduration) mpc--faster-toggle-forward)
                    ;; Skip to the beginning of the next song.
                    (if (not (equal (cdr (assq 'state mpc-status)) "play"))
@@ -2601,14 +2600,16 @@ If stopped, start playback."
                        (lambda ()
                          (setq songid (cdr (assq 'songid mpc-status)))
                          (setq songtime (setq songduration 
(mpc--songduration)))
-                         (setq oldtime (float-time))
+                        (setq oldtime (current-time))
                          (mpc-proc-cmd (list "seekid" songid songtime)))))))
                   (t
                    (setq speedup (+ speedup mpc--faster-acceleration))
                    (let ((newstep
-                          (truncate (* speedup (- (float-time) oldtime)))))
+                         (truncate
+                          (* speedup
+                             (float-time (time-since oldtime))))))
                      (if (<= newstep 1) (setq newstep 1))
-                     (setq oldtime (+ oldtime (/ newstep speedup)))
+                    (setq oldtime (time-add oldtime (/ newstep speedup)))
                      (if (not mpc--faster-toggle-forward)
                          (setq newstep (- newstep)))
                      (setq songtime (min songduration (+ songtime newstep)))
diff --git a/lisp/msb.el b/lisp/msb.el
index 91d83d2..7a1a338 100644
--- a/lisp/msb.el
+++ b/lisp/msb.el
@@ -1,6 +1,6 @@
 ;;; msb.el --- customizable buffer-selection with multiple menus
 
-;; Copyright (C) 1993-1995, 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1995, 1997-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Lindberg <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/mwheel.el b/lisp/mwheel.el
index 876659f..23f491d 100644
--- a/lisp/mwheel.el
+++ b/lisp/mwheel.el
@@ -1,6 +1,6 @@
 ;;; mwheel.el --- Wheel mouse support
 
-;; Copyright (C) 1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2000-2019 Free Software Foundation, Inc.
 ;; Maintainer: William M. Perry <address@hidden>
 ;; Keywords: mouse
 ;; Package: emacs
diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el
index 37df793..5af9ea7 100644
--- a/lisp/net/ange-ftp.el
+++ b/lisp/net/ange-ftp.el
@@ -1,6 +1,6 @@
 ;;; ange-ftp.el --- transparent FTP support for GNU Emacs  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1989-1996, 1998, 2000-2018 Free Software Foundation,
+;; Copyright (C) 1989-1996, 1998, 2000-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Andy Norman (address@hidden)
@@ -2728,7 +2728,7 @@ The main reason for this alist is to deal with file 
versions in VMS.")
            ;; seem to believe in the F-switch
            (if (or (and symlink (string-match "@\\'" file))
                    (and directory (string-match "/\\'" file))
-                   (and executable (string-match "*\\'" file))
+                   (and executable (string-match "\\*\\'" file))
                    (and socket (string-match "=\\'" file)))
                (setq file (substring file 0 -1)))))
       (puthash file (or symlink directory) tbl)
@@ -4277,7 +4277,7 @@ NEWNAME should be the name to give the new compressed or 
uncompressed file.")
                               nil
                               t
                               nil
-                              "-c"
+                              shell-command-switch
                               (format "compress -f -c < %s > %s" tmp1 tmp2))
          (and ange-ftp-process-verbose
               (ange-ftp-message "Compressing %s...done" abbr))
@@ -4313,7 +4313,7 @@ NEWNAME should be the name to give the new compressed or 
uncompressed file.")
                               nil
                               t
                               nil
-                              "-c"
+                              shell-command-switch
                               (format "uncompress -c < %s > %s" tmp1 tmp2))
          (and ange-ftp-process-verbose
               (ange-ftp-message "Uncompressing %s...done" abbr))
@@ -4441,10 +4441,11 @@ NEWNAME should be the name to give the new compressed 
or uncompressed file.")
 
 ;; We can handle process-file in a restricted way (just for chown).
 ;; Nothing possible for `start-file-process'.
+(put 'exec-path 'ange-ftp 'ignore)
+(put 'make-process 'ange-ftp 'ignore)
 (put 'process-file 'ange-ftp 'ange-ftp-process-file)
 (put 'start-file-process 'ange-ftp 'ignore)
 (put 'shell-command 'ange-ftp 'ange-ftp-shell-command)
-(put 'exec-path 'ange-ftp 'ignore)
 
 ;;; Define ways of getting at unmodified Emacs primitives,
 ;;; turning off our handler.
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index bf179c8..aa31e25 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -1,6 +1,6 @@
 ;;; browse-url.el --- pass a URL to a WWW browser
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Author: Denis Howe <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/net/dbus.el b/lisp/net/dbus.el
index 4397817..3820cd4 100644
--- a/lisp/net/dbus.el
+++ b/lisp/net/dbus.el
@@ -1,6 +1,6 @@
 ;;; dbus.el --- Elisp bindings for D-Bus. -*- lexical-binding: t -*-
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 ;; Keywords: comm, hardware
diff --git a/lisp/net/dig.el b/lisp/net/dig.el
index 1cd79ce..ad47982 100644
--- a/lisp/net/dig.el
+++ b/lisp/net/dig.el
@@ -1,6 +1,6 @@
 ;;; dig.el --- Domain Name System dig interface
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <address@hidden>
 ;; Keywords: DNS BIND dig comm
diff --git a/lisp/net/dns.el b/lisp/net/dns.el
index b3b430d..4fa8705 100644
--- a/lisp/net/dns.el
+++ b/lisp/net/dns.el
@@ -1,6 +1,6 @@
 ;;; dns.el --- Domain Name Service lookups
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: network comm
@@ -432,8 +432,9 @@ If REVERSEP, look up an IP address."
                       tcp-p))
           (while (and (zerop (buffer-size))
                       (> times 0))
-            (sit-for (/ step 1000.0))
-            (accept-process-output process 0 step)
+           (let ((step-sec (/ step 1000.0)))
+             (sit-for step-sec)
+             (accept-process-output process step-sec))
             (setq times (- times step)))
           (condition-case nil
               (delete-process process)
diff --git a/lisp/net/eudc-bob.el b/lisp/net/eudc-bob.el
index f63e807..59a4637 100644
--- a/lisp/net/eudc-bob.el
+++ b/lisp/net/eudc-bob.el
@@ -1,6 +1,6 @@
 ;;; eudc-bob.el --- Binary Objects Support for EUDC
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Oscar Figueiredo <address@hidden>
 ;;         Pavel Janík <address@hidden>
diff --git a/lisp/net/eudc-export.el b/lisp/net/eudc-export.el
index f97fd7e..a520eca 100644
--- a/lisp/net/eudc-export.el
+++ b/lisp/net/eudc-export.el
@@ -1,6 +1,6 @@
 ;;; eudc-export.el --- functions to export EUDC query results
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Oscar Figueiredo <address@hidden>
 ;;         Pavel Janík <address@hidden>
diff --git a/lisp/net/eudc-hotlist.el b/lisp/net/eudc-hotlist.el
index 0762445..19788ba 100644
--- a/lisp/net/eudc-hotlist.el
+++ b/lisp/net/eudc-hotlist.el
@@ -1,6 +1,6 @@
 ;;; eudc-hotlist.el --- hotlist management for EUDC
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Oscar Figueiredo <address@hidden>
 ;;         Pavel Janík <address@hidden>
diff --git a/lisp/net/eudc-vars.el b/lisp/net/eudc-vars.el
index e947146..8111629 100644
--- a/lisp/net/eudc-vars.el
+++ b/lisp/net/eudc-vars.el
@@ -1,6 +1,6 @@
 ;;; eudc-vars.el --- Emacs Unified Directory Client
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Oscar Figueiredo <address@hidden>
 ;;         Pavel Janík <address@hidden>
diff --git a/lisp/net/eudc.el b/lisp/net/eudc.el
index a28fa6a..3c9c01d 100644
--- a/lisp/net/eudc.el
+++ b/lisp/net/eudc.el
@@ -1,6 +1,6 @@
 ;;; eudc.el --- Emacs Unified Directory Client  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Oscar Figueiredo <address@hidden>
 ;;         Pavel Janík <address@hidden>
diff --git a/lisp/net/eudcb-bbdb.el b/lisp/net/eudcb-bbdb.el
index ac4814a..f91d0af 100644
--- a/lisp/net/eudcb-bbdb.el
+++ b/lisp/net/eudcb-bbdb.el
@@ -1,6 +1,6 @@
 ;;; eudcb-bbdb.el --- Emacs Unified Directory Client - BBDB Backend
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Oscar Figueiredo <address@hidden>
 ;;         Pavel Janík <address@hidden>
diff --git a/lisp/net/eudcb-ldap.el b/lisp/net/eudcb-ldap.el
index f339f9e..7514d1a 100644
--- a/lisp/net/eudcb-ldap.el
+++ b/lisp/net/eudcb-ldap.el
@@ -1,6 +1,6 @@
 ;;; eudcb-ldap.el --- Emacs Unified Directory Client - LDAP Backend
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Oscar Figueiredo <address@hidden>
 ;;         Pavel Janík <address@hidden>
diff --git a/lisp/net/eudcb-mab.el b/lisp/net/eudcb-mab.el
index 4d517c1..0202b17 100644
--- a/lisp/net/eudcb-mab.el
+++ b/lisp/net/eudcb-mab.el
@@ -1,6 +1,6 @@
 ;;; eudcb-mab.el --- Emacs Unified Directory Client - AddressBook backend
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 ;; Maintainer: Thomas Fitzsimmons <address@hidden>
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 64cc1a5..3e93345 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -1,6 +1,6 @@
 ;;; eww.el --- Emacs Web Wowser  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: html
@@ -247,21 +247,29 @@ This list can be customized via `eww-suggest-uris'."
     (nreverse uris)))
 
 ;;;###autoload
-(defun eww (url)
+(defun eww (url &optional arg)
   "Fetch URL and render the page.
 If the input doesn't look like an URL or a domain name, the
-word(s) will be searched for via `eww-search-prefix'."
+word(s) will be searched for via `eww-search-prefix'.
+
+If called with a prefix ARG, use a new buffer instead of reusing
+the default EWW buffer."
   (interactive
    (let* ((uris (eww-suggested-uris))
          (prompt (concat "Enter URL or keywords"
                          (if uris (format " (default %s)" (car uris)) "")
                          ": ")))
-     (list (read-string prompt nil 'eww-prompt-history uris))))
+     (list (read-string prompt nil 'eww-prompt-history uris)
+           (prefix-numeric-value current-prefix-arg))))
   (setq url (eww--dwim-expand-url url))
   (pop-to-buffer-same-window
-   (if (eq major-mode 'eww-mode)
-       (current-buffer)
-     (get-buffer-create "*eww*")))
+   (cond
+    ((eq arg 4)
+     (generate-new-buffer "*eww*"))
+    ((eq major-mode 'eww-mode)
+     (current-buffer))
+    (t
+     (get-buffer-create "*eww*"))))
   (eww-setup-buffer)
   ;; Check whether the domain only uses "Highly Restricted" Unicode
   ;; IDNA characters.  If not, transform to punycode to indicate that
@@ -462,10 +470,10 @@ Currently this means either text/html or 
application/xhtml+xml."
                (condition-case nil
                    (decode-coding-region (point) (point-max) encode)
                  (coding-system-error nil))
-                (save-excursion
-                  ;; Remove CRLF before parsing.
-                  (while (re-search-forward "\r$" nil t)
-                    (replace-match "" t t)))
+               (save-excursion
+                 ;; Remove CRLF and replace NUL with &#0; before parsing.
+                 (while (re-search-forward "\\(\r$\\)\\|\0" nil t)
+                   (replace-match (if (match-beginning 1) "" "&#0;") t t)))
                (libxml-parse-html-region (point) (point-max))))))
        (source (and (null document)
                     (buffer-substring (point) (point-max)))))
@@ -1531,10 +1539,12 @@ Differences in #targets are ignored."
   (kill-new (plist-get eww-data :url)))
 
 (defun eww-download ()
-  "Download URL under point to `eww-download-directory'."
+  "Download URL to `eww-download-directory'.
+Use link at point if there is one, else the current page's URL."
   (interactive)
   (access-file eww-download-directory "Download failed")
-  (let ((url (get-text-property (point) 'shr-url)))
+  (let ((url (or (get-text-property (point) 'shr-url)
+                 (eww-current-url))))
     (if (not url)
         (message "No URL under point")
       (url-retrieve url 'eww-download-callback (list url)))))
@@ -1542,7 +1552,7 @@ Differences in #targets are ignored."
 (defun eww-download-callback (status url)
   (unless (plist-get status :error)
     (let* ((obj (url-generic-parse-url url))
-           (path (car (url-path-and-query obj)))
+           (path (directory-file-name (car (url-path-and-query obj))))
            (file (eww-make-unique-file-name
                   (eww-decode-url-file-name (file-name-nondirectory path))
                   eww-download-directory)))
diff --git a/lisp/net/gnutls.el b/lisp/net/gnutls.el
index 315932b..61480f3 100644
--- a/lisp/net/gnutls.el
+++ b/lisp/net/gnutls.el
@@ -1,6 +1,6 @@
 ;;; gnutls.el --- Support SSL/TLS connections through GnuTLS
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Ted Zlatanov <address@hidden>
 ;; Keywords: comm, tls, ssl, encryption
@@ -38,6 +38,9 @@
 (require 'cl-lib)
 (require 'puny)
 
+(declare-function network-stream-certificate "network-stream"
+                  (host service parameters))
+
 (defgroup gnutls nil
   "Emacs interface to the GnuTLS library."
   :version "24.1"
@@ -138,7 +141,7 @@ node `(emacs) Network Security'."
                  (integer :tag "Number of bits" 512))
   :group 'gnutls)
 
-(defun open-gnutls-stream (name buffer host service &optional nowait)
+(defun open-gnutls-stream (name buffer host service &optional parameters)
   "Open a SSL/TLS connection for a service to a host.
 Returns a subprocess-object to represent the connection.
 Input and output work as for subprocesses; `delete-process' closes it.
@@ -149,12 +152,15 @@ BUFFER is the buffer (or `buffer-name') to associate with 
the process.
  a filter function to handle the output.
  BUFFER may be also nil, meaning that this process is not associated
  with any buffer
-Third arg is name of the host to connect to, or its IP address.
-Fourth arg SERVICE is name of the service desired, or an integer
+Third arg HOST is the name of the host to connect to, or its IP address.
+Fourth arg SERVICE is the name of the service desired, or an integer
 specifying a port number to connect to.
-Fifth arg NOWAIT (which is optional) means that the socket should
-be opened asynchronously.  The connection process will be
-returned to the caller before TLS negotiation has happened.
+Fifth arg PARAMETERS is an optional list of keyword/value pairs.
+Only :client-certificate and :nowait keywords are recognized, and
+have the same meaning as for `open-network-stream'.
+For historical reasons PARAMETERS can also be a symbol, which is
+interpreted the same as passing a list containing :nowait and the
+value of that symbol.
 
 Usage example:
 
@@ -168,19 +174,33 @@ This is a very simple wrapper around `gnutls-negotiate'.  
See its
 documentation for the specific parameters you can use to open a
 GnuTLS connection, including specifying the credential type,
 trust and key files, and priority string."
-  (let ((process (open-network-stream
-                  name buffer host service
-                  :nowait nowait
-                  :tls-parameters
-                  (and nowait
-                       (cons 'gnutls-x509pki
-                             (gnutls-boot-parameters
-                              :type 'gnutls-x509pki
-                              :hostname (puny-encode-domain host)))))))
+  (let* ((parameters
+          (cond ((symbolp parameters)
+                 (list :nowait parameters))
+                ((not (cl-evenp (length parameters)))
+                 (error "Malformed keyword list"))
+                ((consp parameters)
+                 parameters)
+                (t
+                 (error "Unknown parameter type"))))
+         (cert (network-stream-certificate host service parameters))
+         (keylist (and cert (list cert)))
+         (nowait (plist-get parameters :nowait))
+         (process (open-network-stream
+                   name buffer host service
+                   :nowait nowait
+                   :tls-parameters
+                   (and nowait
+                        (cons 'gnutls-x509pki
+                              (gnutls-boot-parameters
+                               :type 'gnutls-x509pki
+                               :keylist keylist
+                               :hostname (puny-encode-domain host)))))))
     (if nowait
         process
       (gnutls-negotiate :process process
                         :type 'gnutls-x509pki
+                        :keylist keylist
                         :hostname (puny-encode-domain host)))))
 
 (define-error 'gnutls-error "GnuTLS error")
diff --git a/lisp/net/goto-addr.el b/lisp/net/goto-addr.el
index db59df3..c25d787 100644
--- a/lisp/net/goto-addr.el
+++ b/lisp/net/goto-addr.el
@@ -1,6 +1,6 @@
 ;;; goto-addr.el --- click to browse URL or to send to e-mail address
 
-;; Copyright (C) 1995, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Ding <address@hidden>
 ;; Maintainer: address@hidden
@@ -98,7 +98,7 @@ A value of t means there is no limit--fontify regardless of 
the size."
 
 (defvar goto-address-mail-regexp
   ;; Actually pretty much any char could appear in the username part.  -stef
-  "address@hidden([-a-zA-z0-9_]+\\.\\)+[a-zA-Z0-9]+"
+  "address@hidden([-a-zA-Z0-9_]+\\.\\)+[a-zA-Z0-9]+"
   "A regular expression probably matching an e-mail address.")
 
 (defvar goto-address-url-regexp
@@ -246,7 +246,7 @@ there, then load the URL at or before point."
   "Find e-mail address around or before point.
 Then search backwards to beginning of line for the start of an e-mail
 address.  If no e-mail address found, return nil."
-  (re-search-backward "address@hidden" (line-beginning-position) 'lim)
+  (re-search-backward "address@hidden" (line-beginning-position) 'lim)
   (if (or (looking-at goto-address-mail-regexp)        ; already at start
          (and (re-search-forward goto-address-mail-regexp
                                  (line-end-position) 'lim)
diff --git a/lisp/net/hmac-def.el b/lisp/net/hmac-def.el
index d087d55..44db0bb 100644
--- a/lisp/net/hmac-def.el
+++ b/lisp/net/hmac-def.el
@@ -1,6 +1,6 @@
 ;;; hmac-def.el --- A macro for defining HMAC functions.
 
-;; Copyright (C) 1999, 2001, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2001, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Shuhei KOBAYASHI <address@hidden>
 ;; Keywords: HMAC, RFC2104
diff --git a/lisp/net/hmac-md5.el b/lisp/net/hmac-md5.el
index f5d12be..647139f 100644
--- a/lisp/net/hmac-md5.el
+++ b/lisp/net/hmac-md5.el
@@ -1,6 +1,6 @@
 ;;; hmac-md5.el --- Compute HMAC-MD5.
 
-;; Copyright (C) 1999, 2001, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2001, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Shuhei KOBAYASHI <address@hidden>
 ;; Keywords: HMAC, RFC2104, HMAC-MD5, MD5, KEYED-MD5, CRAM-MD5
diff --git a/lisp/net/imap.el b/lisp/net/imap.el
index 042b0f9..9f43c57 100644
--- a/lisp/net/imap.el
+++ b/lisp/net/imap.el
@@ -1,6 +1,6 @@
 ;;; imap.el --- imap library  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <address@hidden>
 ;; Keywords: mail
@@ -1918,18 +1918,14 @@ on failure."
          (unless (< len 10)
            (setq imap-have-messaged t)
            (message "imap read: %dk" len))
-         (accept-process-output imap-process
-                                (truncate imap-read-timeout)
-                                (truncate (* (- imap-read-timeout
-                                                (truncate imap-read-timeout))
-                                             1000)))))
+         (accept-process-output imap-process imap-read-timeout)))
       ;; A process can die _before_ we have processed everything it
       ;; has to say.  Moreover, this can happen in between the call to
       ;; accept-process-output and the call to process-status in an
       ;; iteration of the loop above.
       (when (and (null imap-continuation)
                 (< imap-reached-tag tag))
-       (accept-process-output imap-process 0 0))
+       (accept-process-output imap-process 0))
       (when imap-have-messaged
        (message ""))
       (and (memq (process-status imap-process) '(open run))
@@ -2076,23 +2072,23 @@ Return nil if no complete line has arrived."
 ;;                      addr-host ")"
 ;;
 ;;   addr-adl        = nstring
-;;                       ; Holds route from [RFC-822] route-addr if
+;;                       ; Holds route from [RFC-822 (or later)] route-addr if
 ;;                       ; non-nil
 ;;
 ;;   addr-host       = nstring
-;;                       ; nil indicates [RFC-822] group syntax.
-;;                       ; Otherwise, holds [RFC-822] domain name
+;;                       ; nil indicates [RFC-822 (or later)] group syntax.
+;;                       ; Otherwise, holds [RFC-822 (or later)] domain name
 ;;
 ;;   addr-mailbox    = nstring
-;;                       ; nil indicates end of [RFC-822] group; if
+;;                       ; nil indicates end of [RFC-822 (or later)] group; if
 ;;                       ; non-nil and addr-host is nil, holds
-;;                       ; [RFC-822] group name.
-;;                       ; Otherwise, holds [RFC-822] local-part
-;;                       ; after removing [RFC-822] quoting
+;;                       ; [RFC-822 (or later)] group name.
+;;                       ; Otherwise, holds [RFC-822 (or later)] local-part
+;;                       ; after removing [RFC-822 (or later)] quoting
 ;;
 ;;   addr-name       = nstring
-;;                       ; If non-nil, holds phrase from [RFC-822]
-;;                       ; mailbox after removing [RFC-822] quoting
+;;                       ; If non-nil, holds phrase from [RFC-822 (or later)]
+;;                       ; mailbox after removing [RFC-822 (or later)] quoting
 ;;
 
 (defsubst imap-parse-address ()
diff --git a/lisp/net/ldap.el b/lisp/net/ldap.el
index 720c9c1..75fc7d6 100644
--- a/lisp/net/ldap.el
+++ b/lisp/net/ldap.el
@@ -1,6 +1,6 @@
 ;;; ldap.el --- client interface to LDAP for Emacs
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Oscar Figueiredo <address@hidden>
 ;; Maintainer: address@hidden
@@ -646,8 +646,9 @@ an alist of attribute/value pairs."
               (not (equal "" sizelimit)))
          (setq arglist (nconc arglist (list (format "-z%s" sizelimit)))))
       (if passwd
-         (let* ((process-connection-type t)
-                (proc-args (append arglist ldap-ldapsearch-args
+         ;; Leave process-connection-type at its default value.  See
+         ;; discussion in Bug#33050.
+         (let* ((proc-args (append arglist ldap-ldapsearch-args
                                    filter))
                 (proc (apply #'start-process "ldapsearch" buf
                              ldap-ldapsearch-prog
diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el
index a8ade01..eb4312e 100644
--- a/lisp/net/mailcap.el
+++ b/lisp/net/mailcap.el
@@ -1,6 +1,6 @@
 ;;; mailcap.el --- MIME media types configuration -*- lexical-binding: t -*-
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: William M. Perry <address@hidden>
 ;;     Lars Magne Ingebrigtsen <address@hidden>
diff --git a/lisp/net/mairix.el b/lisp/net/mairix.el
index ade263a..0741566 100644
--- a/lisp/net/mairix.el
+++ b/lisp/net/mairix.el
@@ -1,6 +1,6 @@
 ;;; mairix.el --- Mairix interface for Emacs
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: David Engster <address@hidden>
 ;; Keywords: mail searching
diff --git a/lisp/net/net-utils.el b/lisp/net/net-utils.el
index c9e8080..e61d889 100644
--- a/lisp/net/net-utils.el
+++ b/lisp/net/net-utils.el
@@ -1,6 +1,6 @@
 ;;; net-utils.el --- network functions
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author:  Peter Breton <address@hidden>
 ;; Created: Sun Mar 16 1997
diff --git a/lisp/net/netrc.el b/lisp/net/netrc.el
index 7b974eb..93152f4 100644
--- a/lisp/net/netrc.el
+++ b/lisp/net/netrc.el
@@ -1,5 +1,5 @@
 ;;; netrc.el --- .netrc parsing functionality
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: news
diff --git a/lisp/net/network-stream.el b/lisp/net/network-stream.el
index a0589e2..2b3292b 100644
--- a/lisp/net/network-stream.el
+++ b/lisp/net/network-stream.el
@@ -1,6 +1,6 @@
 ;;; network-stream.el --- open network processes, possibly with encryption -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: network
@@ -48,6 +48,7 @@
 
 (declare-function starttls-available-p "starttls" ())
 (declare-function starttls-negotiate "starttls" (process))
+(declare-function starttls-open-stream "starttls" (name buffer host port))
 
 (autoload 'gnutls-negotiate "gnutls")
 (autoload 'open-gnutls-stream "gnutls")
@@ -196,7 +197,7 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
          (car result))))))
 
 (defun network-stream-certificate (host service parameters)
-  (let ((spec (plist-get :client-certificate parameters)))
+  (let ((spec (plist-get parameters :client-certificate)))
     (cond
      ((listp spec)
       ;; Either nil or a list with a key/certificate pair.
@@ -375,7 +376,7 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
        (goto-char start)
        (while (and (memq (process-status stream) '(open run))
                    (not (re-search-forward end-of-command nil t)))
-         (accept-process-output stream 0 50)
+         (accept-process-output stream 0.05)
          (goto-char start))
        ;; Return the data we got back, or nil if the process died.
        (unless (= start (point))
@@ -389,7 +390,7 @@ gnutls-boot (as returned by `gnutls-boot-parameters')."
           (stream
             (if (gnutls-available-p)
                 (open-gnutls-stream name buffer host service
-                                    (plist-get parameters :nowait))
+                                    parameters)
               (require 'tls)
               (open-tls-stream name buffer host service)))
           (eoc (plist-get parameters :end-of-command)))
diff --git a/lisp/net/newst-backend.el b/lisp/net/newst-backend.el
index 40096ca..9925a04 100644
--- a/lisp/net/newst-backend.el
+++ b/lisp/net/newst-backend.el
@@ -1,6 +1,6 @@
 ;;; newst-backend.el --- Retrieval backend for newsticker  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author:      Ulf Jasper <address@hidden>
 ;; Filename:    newst-backend.el
@@ -1691,8 +1691,8 @@ Examples:
     nil))
 
 (defun newsticker--decode-rfc822-date (rfc822-string)
-  "Return RFC822-STRING in format like `decode-time'.
-Converts from RFC822 to Emacs representation.
+  "Convert RFC822-STRING to a Lisp timestamp.
+RFC822-STRING should use RFC 822 (or later) format.
 Examples:
 Sat, 07 September 2002 00:00:01 +0100
 Sat, 07 September 2002 00:00:01 MET
@@ -1802,7 +1802,7 @@ download it from URL first."
              (time-less-p nil
                           (time-add (file-attribute-modification-time
                                     (file-attributes image-name))
-                                    (seconds-to-time 86400))))
+                                   86400)))
         (newsticker--debug-msg "%s: Getting image for %s skipped"
                                (format-time-string "%A, %H:%M")
                                feed-name)
@@ -1995,8 +1995,7 @@ older than TIME."
          (mapc
           (lambda (item)
             (when (eq (newsticker--age item) old-age)
-              (let ((exp-time (time-add (newsticker--time item)
-                                        (seconds-to-time time))))
+             (let ((exp-time (time-add (newsticker--time item) time)))
                 (when (time-less-p exp-time nil)
                   (newsticker--debug-msg
                    "Item `%s' from %s has expired on %s"
@@ -2171,22 +2170,8 @@ well."
                  (throw 'result nil))
                 ((eq age2 'obsolete)
                  (throw 'result t)))))
-    (let* ((time1 (newsticker--time item1))
-           (time2 (newsticker--time item2)))
-      (cond ((< (nth 0 time1) (nth 0 time2))
-             nil)
-            ((> (nth 0 time1) (nth 0 time2))
-             t)
-            ((< (nth 1 time1) (nth 1 time2))
-             nil)
-            ((> (nth 1 time1) (nth 1 time2))
-             t)
-            ((< (or (nth 2 time1) 0) (or (nth 2 time2) 0))
-             nil)
-            ((> (or (nth 2 time1) 0) (or (nth 2 time2) 0))
-             t)
-            (t
-             nil)))))
+    (time-less-p (newsticker--time item2)
+                (newsticker--time item1))))
 
 (defun newsticker--cache-item-compare-by-title (item1 item2)
   "Compare ITEM1 and ITEM2 by comparing their titles."
diff --git a/lisp/net/newst-plainview.el b/lisp/net/newst-plainview.el
index 889404e..4f5c729 100644
--- a/lisp/net/newst-plainview.el
+++ b/lisp/net/newst-plainview.el
@@ -1,6 +1,6 @@
 ;;; newst-plainview.el --- Single buffer frontend for newsticker.
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author:      Ulf Jasper <address@hidden>
 ;; Filename:    newst-plainview.el
diff --git a/lisp/net/newst-reader.el b/lisp/net/newst-reader.el
index 98d9262..4b1d68a 100644
--- a/lisp/net/newst-reader.el
+++ b/lisp/net/newst-reader.el
@@ -1,6 +1,6 @@
 ;;; newst-reader.el --- Generic RSS reader functions.
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author:      Ulf Jasper <address@hidden>
 ;; Filename:    newst-reader.el
diff --git a/lisp/net/newst-ticker.el b/lisp/net/newst-ticker.el
index 16318ec..fab0b73 100644
--- a/lisp/net/newst-ticker.el
+++ b/lisp/net/newst-ticker.el
@@ -1,6 +1,6 @@
 ;; newst-ticker.el --- mode line ticker for newsticker.
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author:      Ulf Jasper <address@hidden>
 ;; Filename:    newst-ticker.el
diff --git a/lisp/net/newst-treeview.el b/lisp/net/newst-treeview.el
index 59a5729..ece728a 100644
--- a/lisp/net/newst-treeview.el
+++ b/lisp/net/newst-treeview.el
@@ -1,6 +1,6 @@
 ;;; newst-treeview.el --- Treeview frontend for newsticker.  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author:      Ulf Jasper <address@hidden>
 ;; Filename:    newst-treeview.el
diff --git a/lisp/net/newsticker.el b/lisp/net/newsticker.el
index b5c0b0e..e1f4c8f 100644
--- a/lisp/net/newsticker.el
+++ b/lisp/net/newsticker.el
@@ -1,6 +1,6 @@
 ;;; newsticker.el --- A Newsticker for Emacs. -*- lexical-binding: t -*-
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author:      Ulf Jasper <address@hidden>
 ;; Filename:    newsticker.el
diff --git a/lisp/net/nsm.el b/lisp/net/nsm.el
index e857e64..6a312e2 100644
--- a/lisp/net/nsm.el
+++ b/lisp/net/nsm.el
@@ -1,6 +1,6 @@
 ;;; nsm.el --- Network Security Manager
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: encryption, security, network
diff --git a/lisp/net/ntlm.el b/lisp/net/ntlm.el
index 142c375..88c5619 100644
--- a/lisp/net/ntlm.el
+++ b/lisp/net/ntlm.el
@@ -1,6 +1,6 @@
 ;;; ntlm.el --- NTLM (NT LanManager) authentication support  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2001, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Taro Kawagishi <address@hidden>
 ;; Maintainer: Thomas Fitzsimmons <address@hidden>
diff --git a/lisp/net/pop3.el b/lisp/net/pop3.el
index 2a6807e..599e230 100644
--- a/lisp/net/pop3.el
+++ b/lisp/net/pop3.el
@@ -1,6 +1,6 @@
 ;;; pop3.el --- Post Office Protocol (RFC 1460) interface  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Richard L. Pieri <address@hidden>
 ;; Maintainer: address@hidden
@@ -165,12 +165,7 @@ Used for APOP authentication.")
       "How long pop3 should wait between checking for the end of output.
 Shorter values mean quicker response, but are more CPU intensive.")
     (defun pop3-accept-process-output (process)
-      (accept-process-output
-       process
-       (truncate pop3-read-timeout)
-       (truncate (* (- pop3-read-timeout
-                      (truncate pop3-read-timeout))
-                   1000))))))
+      (accept-process-output process pop3-read-timeout))))
 
 (defvar pop3-uidl)
 ;; List of UIDLs of existing messages at present in the server:
@@ -185,8 +180,8 @@ Shorter values mean quicker response, but are more CPU 
intensive.")
 ;;  ("SERVER_B" ("USER_B1" "UIDL1" TIMESTAMP1 "UIDL2" TIMESTAMP2...)
 ;;              ("USER_B2" "UIDL1" TIMESTAMP1 "UIDL2" TIMESTAMP2...)
 ;;              ...))
-;; Where TIMESTAMP is the most significant two digits of an Emacs time,
-;; i.e. the return value of `current-time'.
+;; Where TIMESTAMP is an Emacs time value (HI LO) representing the
+;; number of seconds (+ (ash HI 16) LO).
 
 ;;;###autoload
 (defun pop3-movemail (file)
@@ -385,7 +380,9 @@ Use streaming commands."
 (defun pop3-uidl-dele (process)
   "Delete messages according to `pop3-leave-mail-on-server'.
 Return non-nil if it is necessary to update the local UIDL file."
-  (let* ((ctime (current-time))
+  (let* ((ctime (encode-time nil 'list))
+        (age-limit (and (numberp pop3-leave-mail-on-server)
+                        (* 86400 pop3-leave-mail-on-server)))
         (srvr (assoc pop3-mailhost pop3-uidl-saved))
         (saved (assoc pop3-maildrop (cdr srvr)))
         i uidl mod new tstamp dele)
@@ -402,17 +399,13 @@ Return non-nil if it is necessary to update the local 
UIDL file."
           (setq new (mapcan (lambda (elt) (list elt ctime)) pop3-uidl))))
     (when new (setq mod t))
     ;; List expirable messages and delete them from the data to be saved.
-    (setq ctime (when (numberp pop3-leave-mail-on-server)
-                 (/ (+ (* (car ctime) 65536.0) (cadr ctime)) 86400))
-         i (1- (length saved)))
+    (setq i (1- (length saved)))
     (while (> i 0)
       (if (member (setq uidl (nth (1- i) saved)) pop3-uidl)
          (progn
            (setq tstamp (nth i saved))
-           (if (and ctime
-                    (> (- ctime (/ (+ (* (car tstamp) 65536.0) (cadr tstamp))
-                                   86400))
-                       pop3-leave-mail-on-server))
+           (if (and age-limit
+                    (time-less-p age-limit (time-subtract ctime tstamp)))
                ;; Mails to delete.
                (progn
                  (setq mod t)
@@ -592,7 +585,7 @@ Return the response string if optional second argument is 
non-nil."
       (goto-char pop3-read-point)
       (if (looking-at "-ERR")
          (error "%s" (buffer-substring (point) (- match-end 2)))
-       (if (not (looking-at "+OK"))
+       (if (not (looking-at "\\+OK"))
            (progn (setq pop3-read-point match-end) nil)
          (setq pop3-read-point match-end)
          (if return
@@ -691,14 +684,14 @@ If NOW, use that time instead."
   "Send USER information to POP3 server."
   (pop3-send-command process (format "USER %s" user))
   (let ((response (pop3-read-response process t)))
-    (if (not (and response (string-match "+OK" response)))
+    (if (not (and response (string-match "\\+OK" response)))
        (error "USER %s not valid" user))))
 
 (defun pop3-pass (process)
   "Send authentication information to the server."
   (pop3-send-command process (format "PASS %s" pop3-password))
   (let ((response (pop3-read-response process t)))
-    (if (not (and response (string-match "+OK" response)))
+    (if (not (and response (string-match "\\+OK" response)))
        (pop3-quit process))))
 
 (defun pop3-apop (process user)
@@ -711,7 +704,7 @@ If NOW, use that time instead."
        (let ((hash (md5 (concat pop3-timestamp pass) nil nil 'binary)))
          (pop3-send-command process (format "APOP %s %s" user hash))
          (let ((response (pop3-read-response process t)))
-           (if (not (and response (string-match "+OK" response)))
+           (if (not (and response (string-match "\\+OK" response)))
                (pop3-quit process)))))
     ))
 
diff --git a/lisp/net/puny.el b/lisp/net/puny.el
index efa11cf..23c7af8 100644
--- a/lisp/net/puny.el
+++ b/lisp/net/puny.el
@@ -1,6 +1,6 @@
 ;;; puny.el --- translate non-ASCII domain names to ASCII
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: mail, net
diff --git a/lisp/net/quickurl.el b/lisp/net/quickurl.el
index ff14d20..3f7e9d1 100644
--- a/lisp/net/quickurl.el
+++ b/lisp/net/quickurl.el
@@ -1,6 +1,6 @@
 ;;; quickurl.el --- insert a URL based on text at point in buffer
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Pearson <address@hidden>
 ;; Maintainer: Dave Pearson <address@hidden>
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el
index 0c72e47..b1a6c1c 100644
--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -1,6 +1,6 @@
 ;;; rcirc.el --- default, simple IRC client          -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005-2019 Free Software Foundation, Inc.
 
 ;; Author: Ryan Yeske <address@hidden>
 ;; Maintainers: Ryan Yeske <address@hidden>,
@@ -670,8 +670,9 @@ last ping."
 
 (defun rcirc-handler-ctcp-KEEPALIVE (process _target _sender message)
   (with-rcirc-process-buffer process
-    (setq header-line-format (format "%f" (- (float-time)
-                                            (string-to-number message))))))
+    (setq header-line-format
+         (format "%f" (float-time
+                       (time-since (string-to-number message)))))))
 
 (defvar rcirc-debug-buffer "*rcirc debug*")
 (defvar rcirc-debug-flag nil
@@ -723,8 +724,8 @@ When 0, do not auto-reconnect."
                  (< 0 rcirc-reconnect-delay))
         (let ((now (current-time)))
           (when (or (null rcirc-last-connect-time)
-                    (< rcirc-reconnect-delay
-                       (float-time (time-subtract now 
rcirc-last-connect-time))))
+                   (time-less-p rcirc-reconnect-delay
+                                (time-subtract now rcirc-last-connect-time)))
             (setq rcirc-last-connect-time now)
             (rcirc-cmd-reconnect nil))))
       (run-hook-with-args 'rcirc-sentinel-functions process sentinel))))
@@ -2064,9 +2065,7 @@ activity.  Only run if the buffer is not visible and
 (defvar rcirc-visible-buffers nil)
 (defun rcirc-window-configuration-change ()
   (unless (minibuffer-window-active-p (minibuffer-window))
-    ;; delay this until command has finished to make sure window is
-    ;; actually visible before clearing activity
-    (add-hook 'post-command-hook 'rcirc-window-configuration-change-1)))
+    (rcirc-window-configuration-change-1)))
 
 (defun rcirc-window-configuration-change-1 ()
   ;; clear activity and overlay arrows
@@ -2090,9 +2089,7 @@ activity.  Only run if the buffer is not visible and
                            rcirc-activity)))
     ;; update the mode-line string
     (unless (equal old-activity rcirc-activity)
-      (rcirc-update-activity-string)))
-
-  (remove-hook 'post-command-hook 'rcirc-window-configuration-change-1))
+      (rcirc-update-activity-string))))
 
 
 ;;; buffer name abbreviation
@@ -2798,7 +2795,7 @@ the only argument."
   (let* ((nick (nth 1 args))
          (idle-secs (string-to-number (nth 2 args)))
          (idle-string (format-seconds "%yy %dd %hh %mm %z%ss" idle-secs))
-         (signon-time (seconds-to-time (string-to-number (nth 3 args))))
+        (signon-time (string-to-number (nth 3 args)))
          (signon-string (format-time-string "%c" signon-time))
          (message (format "%s idle for %s, signed on %s"
                           nick idle-string signon-string)))
@@ -2819,8 +2816,7 @@ Not in rfc1459.txt"
     (with-current-buffer buffer
       (let ((setter (nth 2 args))
            (time (current-time-string
-                  (seconds-to-time
-                   (string-to-number (cl-cadddr args))))))
+                  (string-to-number (cl-cadddr args)))))
        (rcirc-print process sender "TOPIC" (cadr args)
                     (format "%s (%s on %s)" rcirc-topic setter time))))))
 
diff --git a/lisp/net/rfc2104.el b/lisp/net/rfc2104.el
index 57bca2e..68c35aa 100644
--- a/lisp/net/rfc2104.el
+++ b/lisp/net/rfc2104.el
@@ -1,6 +1,6 @@
 ;;; rfc2104.el --- RFC2104 Hashed Message Authentication Codes  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <address@hidden>
 ;; Keywords: mail
diff --git a/lisp/net/rlogin.el b/lisp/net/rlogin.el
index 015e04f..bf6f535 100644
--- a/lisp/net/rlogin.el
+++ b/lisp/net/rlogin.el
@@ -1,6 +1,6 @@
 ;;; rlogin.el --- remote login interface  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1992-1995, 1997-1998, 2001-2018 Free Software
+;; Copyright (C) 1992-1995, 1997-1998, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Noah Friedman
diff --git a/lisp/net/sasl-cram.el b/lisp/net/sasl-cram.el
index d5d8ddf..a4d80c9 100644
--- a/lisp/net/sasl-cram.el
+++ b/lisp/net/sasl-cram.el
@@ -1,6 +1,6 @@
 ;;; sasl-cram.el --- CRAM-MD5 module for the SASL client framework
 
-;; Copyright (C) 2000, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <address@hidden>
 ;;     Kenichi OKADA <address@hidden>
diff --git a/lisp/net/sasl-digest.el b/lisp/net/sasl-digest.el
index e127ee5..28b5886 100644
--- a/lisp/net/sasl-digest.el
+++ b/lisp/net/sasl-digest.el
@@ -1,6 +1,6 @@
 ;;; sasl-digest.el --- DIGEST-MD5 module for the SASL client framework
 
-;; Copyright (C) 2000, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <address@hidden>
 ;;     Kenichi OKADA <address@hidden>
diff --git a/lisp/net/sasl-ntlm.el b/lisp/net/sasl-ntlm.el
index c9e5eed..4a142af 100644
--- a/lisp/net/sasl-ntlm.el
+++ b/lisp/net/sasl-ntlm.el
@@ -1,6 +1,6 @@
 ;;; sasl-ntlm.el --- NTLM (NT Lan Manager) module for the SASL client framework
 
-;; Copyright (C) 2000, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Taro Kawagishi <address@hidden>
 ;; Keywords: SASL, NTLM
diff --git a/lisp/net/sasl-scram-rfc.el b/lisp/net/sasl-scram-rfc.el
index e524b59..f4d33a6 100644
--- a/lisp/net/sasl-scram-rfc.el
+++ b/lisp/net/sasl-scram-rfc.el
@@ -1,6 +1,6 @@
 ;;; sasl-scram-rfc.el --- SCRAM-SHA-1 module for the SASL client framework  
-*- lexical-binding: t; -*-
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Magnus Henoch <address@hidden>
 ;; Package: sasl
diff --git a/lisp/net/sasl.el b/lisp/net/sasl.el
index ca0b66b..492f657 100644
--- a/lisp/net/sasl.el
+++ b/lisp/net/sasl.el
@@ -1,6 +1,6 @@
 ;;; sasl.el --- SASL client framework
 
-;; Copyright (C) 2000, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <address@hidden>
 ;; Keywords: SASL
diff --git a/lisp/net/secrets.el b/lisp/net/secrets.el
index ca75d95..5d294ce 100644
--- a/lisp/net/secrets.el
+++ b/lisp/net/secrets.el
@@ -1,6 +1,6 @@
 ;;; secrets.el --- Client interface to gnome-keyring and kwallet. -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 ;; Keywords: comm password passphrase
diff --git a/lisp/net/shr-color.el b/lisp/net/shr-color.el
index 6303141..2d6cf68 100644
--- a/lisp/net/shr-color.el
+++ b/lisp/net/shr-color.el
@@ -1,6 +1,6 @@
 ;;; shr-color.el --- Simple HTML Renderer color management  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Julien Danjou <address@hidden>
 ;; Keywords: html
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 7ef1e18..2f628e1 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -1,6 +1,6 @@
 ;;; shr.el --- Simple HTML Renderer -*- lexical-binding: t -*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: html
@@ -1755,7 +1755,14 @@ The preference is a float determined from 
`shr-prefer-media-type'."
 
 (defun shr-tag-ol (dom)
   (shr-ensure-paragraph)
-  (let ((shr-list-mode 1))
+  (let* ((attrs (dom-attributes dom))
+         (start-attr (alist-get 'start attrs))
+         ;; Start at 1 if there is no start attribute
+         ;; or if start can't be parsed as an integer.
+         (start-index (condition-case _
+                          (cl-parse-integer start-attr)
+                        (t 1)))
+         (shr-list-mode start-index))
     (shr-generic dom))
   (shr-ensure-paragraph))
 
diff --git a/lisp/net/sieve-manage.el b/lisp/net/sieve-manage.el
index 8c70ae0..72731b8 100644
--- a/lisp/net/sieve-manage.el
+++ b/lisp/net/sieve-manage.el
@@ -1,6 +1,6 @@
 ;;; sieve-manage.el --- Implementation of the managesieve protocol in elisp  
-*- lexical-binding:t -*-
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <address@hidden>
 ;;         Albert Krewinkel <address@hidden>
diff --git a/lisp/net/sieve-mode.el b/lisp/net/sieve-mode.el
index b9f424f..adab010 100644
--- a/lisp/net/sieve-mode.el
+++ b/lisp/net/sieve-mode.el
@@ -1,6 +1,6 @@
 ;;; sieve-mode.el --- Sieve code editing commands for Emacs
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <address@hidden>
 
diff --git a/lisp/net/sieve.el b/lisp/net/sieve.el
index ef7bb5c..d237c1e 100644
--- a/lisp/net/sieve.el
+++ b/lisp/net/sieve.el
@@ -1,6 +1,6 @@
 ;;; sieve.el --- Utilities to manage sieve scripts
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <address@hidden>
 
diff --git a/lisp/net/snmp-mode.el b/lisp/net/snmp-mode.el
index cb3b176..45b8b70 100644
--- a/lisp/net/snmp-mode.el
+++ b/lisp/net/snmp-mode.el
@@ -1,6 +1,6 @@
 ;;; snmp-mode.el --- SNMP & SNMPv2 MIB major mode
 
-;; Copyright (C) 1995, 1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Paul D. Smith <address@hidden>
 ;; Keywords: data
diff --git a/lisp/net/soap-client.el b/lisp/net/soap-client.el
index 7c40966..1632ee1 100644
--- a/lisp/net/soap-client.el
+++ b/lisp/net/soap-client.el
@@ -1,6 +1,6 @@
 ;;; soap-client.el --- Access SOAP web services       -*- lexical-binding: t 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Alexandru Harsanyi <address@hidden>
 ;; Author: Thomas Fitzsimmons <address@hidden>
@@ -629,7 +629,7 @@ disallows them."
              (<= time-zone-minute 59))
       (error "Invalid or unsupported time: %s" date-time-string))
     ;; Return a value in a format similar to that returned by decode-time, and
-    ;; suitable for (apply 'encode-time ...).
+    ;; suitable for (apply #'encode-time ...).
     (list second minute hour day month year second-fraction datatype
           (if has-time-zone
               (* (rng-xsd-time-to-seconds
diff --git a/lisp/net/soap-inspect.el b/lisp/net/soap-inspect.el
index 252b1f3..17b6675 100644
--- a/lisp/net/soap-inspect.el
+++ b/lisp/net/soap-inspect.el
@@ -1,6 +1,6 @@
 ;;; soap-inspect.el --- Interactive WSDL inspector    -*- lexical-binding: t 
-*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Alexandru Harsanyi <address@hidden>
 ;; Created: October 2010
diff --git a/lisp/net/socks.el b/lisp/net/socks.el
index 5ee6eea..6356707 100644
--- a/lisp/net/socks.el
+++ b/lisp/net/socks.el
@@ -1,6 +1,6 @@
 ;;; socks.el --- A Socks v5 Client for Emacs  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1996-2000, 2002, 2007-2018 Free Software Foundation,
+;; Copyright (C) 1996-2000, 2002, 2007-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: William M. Perry <address@hidden>
diff --git a/lisp/net/telnet.el b/lisp/net/telnet.el
index 93a4e7e..cf3634f 100644
--- a/lisp/net/telnet.el
+++ b/lisp/net/telnet.el
@@ -1,6 +1,6 @@
 ;;; telnet.el --- run a telnet session from within an Emacs buffer
 
-;; Copyright (C) 1985, 1988, 1992, 1994, 2001-2018 Free Software
+;; Copyright (C) 1985, 1988, 1992, 1994, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: William F. Schelter
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 7906ec9..bd66ab4 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -1,6 +1,6 @@
 ;;; tramp-adb.el --- Functions for calling Android Debug Bridge from Tramp  
-*- lexical-binding:t -*-
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Jürgen Hötzel <address@hidden>
 ;; Keywords: comm, processes
@@ -35,14 +35,12 @@
 
 (require 'tramp)
 
-;;;###tramp-autoload
 (defcustom tramp-adb-program "adb"
   "Name of the Android Debug Bridge program."
   :group 'tramp
   :version "24.4"
   :type 'string)
 
-;;;###tramp-autoload
 (defcustom tramp-adb-connect-if-not-connected nil
   "Try to run `adb connect' if provided device is not connected currently.
 It is used for TCP/IP devices."
@@ -54,9 +52,8 @@ It is used for TCP/IP devices."
 (defconst tramp-adb-method "adb"
   "When this method name is used, forward all calls to Android Debug Bridge.")
 
-;;;###tramp-autoload
 (defcustom tramp-adb-prompt
-  
"^\\(?:[[:digit:]]*|?\\)?\\(?:[[:alnum:]\e;address@hidden:alnum:]]*[^#\\$]*\\)?[#\\$][[:space:]]"
+  
"^[[:digit:]]*|?[[:alnum:]\e;address@hidden:alnum:]]*[^#\\$]*[#\\$][[:space:]]"
   "Regexp used as prompt in almquist shell."
   :type 'string
   :version "24.4"
@@ -78,22 +75,20 @@ It is used for TCP/IP devices."
   "Regexp for ls output.")
 
 ;;;###tramp-autoload
-(add-to-list 'tramp-methods
-            `(,tramp-adb-method
-              (tramp-tmpdir "/data/local/tmp")
-               (tramp-default-port 5555)))
+(tramp--with-startup
+ (add-to-list 'tramp-methods
+             `(,tramp-adb-method
+               (tramp-tmpdir            "/data/local/tmp")
+                (tramp-default-port      5555)))
 
-;;;###tramp-autoload
-(add-to-list 'tramp-default-host-alist `(,tramp-adb-method nil ""))
+ (add-to-list 'tramp-default-host-alist `(,tramp-adb-method nil ""))
 
-;;;###tramp-autoload
-(eval-after-load 'tramp
-  '(tramp-set-completion-function
-    tramp-adb-method '((tramp-adb-parse-device-names ""))))
+ (tramp-set-completion-function
+  tramp-adb-method '((tramp-adb-parse-device-names ""))))
 
 ;;;###tramp-autoload
 (defconst tramp-adb-file-name-handler-alist
-  '((access-file . ignore)
+  '((access-file . tramp-handle-access-file)
     (add-name-to-file . tramp-handle-add-name-to-file)
     ;; `byte-compiler-base-file-name' performed by default handler.
     ;; `copy-directory' performed by default handler.
@@ -149,6 +144,7 @@ It is used for TCP/IP devices."
     (make-directory . tramp-adb-handle-make-directory)
     (make-directory-internal . ignore)
     (make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
+    (make-process . tramp-adb-handle-make-process)
     (make-symbolic-link . tramp-handle-make-symbolic-link)
     (process-file . tramp-adb-handle-process-file)
     (rename-file . tramp-adb-handle-rename-file)
@@ -157,10 +153,11 @@ It is used for TCP/IP devices."
     (set-file-selinux-context . ignore)
     (set-file-times . tramp-adb-handle-set-file-times)
     (set-visited-file-modtime . tramp-handle-set-visited-file-modtime)
-    (shell-command . tramp-adb-handle-shell-command)
-    (start-file-process . tramp-adb-handle-start-file-process)
+    (shell-command . tramp-handle-shell-command)
+    (start-file-process . tramp-handle-start-file-process)
     (substitute-in-file-name . tramp-handle-substitute-in-file-name)
     (temporary-file-directory . tramp-handle-temporary-file-directory)
+    (tramp-set-file-uid-gid . ignore)
     (unhandled-file-name-directory . ignore)
     (vc-registered . ignore)
     (verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)
@@ -187,44 +184,21 @@ pass to the OPERATION."
       (tramp-run-real-handler operation args))))
 
 ;;;###tramp-autoload
-(tramp-register-foreign-file-name-handler
- 'tramp-adb-file-name-p 'tramp-adb-file-name-handler)
+(tramp--with-startup
+ (tramp-register-foreign-file-name-handler
+  #'tramp-adb-file-name-p #'tramp-adb-file-name-handler))
 
 ;;;###tramp-autoload
 (defun tramp-adb-parse-device-names (_ignore)
   "Return a list of (nil host) tuples allowed to access."
-  (with-timeout (10)
-    (with-temp-buffer
-      ;; `call-process' does not react on timer under MS Windows.
-      ;; That's why we use `start-process'.
-      ;; We don't know yet whether we need a user or host name for the
-      ;; connection vector.  We assume we don't, it will be OK in most
-      ;; of the cases.  Otherwise, there might be an additional trace
-      ;; buffer, which doesn't hurt.
-      (let ((p (start-process
-               tramp-adb-program (current-buffer) tramp-adb-program "devices"))
-           (v (make-tramp-file-name :method tramp-adb-method))
-           result)
-       (tramp-message v 6 "%s" (mapconcat 'identity (process-command p) " "))
-       (process-put p 'adjust-window-size-function 'ignore)
-       (set-process-query-on-exit-flag p nil)
-       (while (process-live-p p)
-         (accept-process-output p 0.1))
-       (accept-process-output p 0.1)
-       (tramp-message v 6 "\n%s" (buffer-string))
-       (goto-char (point-min))
-       (while (search-forward-regexp "^\\(\\S-+\\)[[:space:]]+device$" nil t)
-         (push (list nil (match-string 1)) result))
-
-       ;; Replace ":" by "#".
-       (mapc
-        (lambda (elt)
-          (setcar
-           (cdr elt)
-           (replace-regexp-in-string
-            ":" tramp-prefix-port-format (car (cdr elt)))))
-        result)
-       result))))
+  (delq nil
+       (mapcar
+        (lambda (line)
+          (when (string-match "^\\(\\S-+\\)[[:space:]]+device$" line)
+            ;; Replace ":" by "#".
+            `(nil ,(replace-regexp-in-string
+                    ":" tramp-prefix-port-format (match-string 1 line)))))
+        (tramp-process-lines nil tramp-adb-program "devices"))))
 
 (defun tramp-adb-handle-file-system-info (filename)
   "Like `file-system-info' for Tramp files."
@@ -258,7 +232,7 @@ pass to the OPERATION."
    ;; Preserve trailing "/".
   (funcall
    (if (string-equal (file-name-nondirectory filename) "")
-       'file-name-as-directory 'identity)
+       #'file-name-as-directory #'identity)
    (with-parsed-tramp-file-name (expand-file-name filename) nil
      (tramp-make-tramp-file-name
       v
@@ -283,14 +257,14 @@ pass to the OPERATION."
              (setq thisstep (pop steps))
              (tramp-message
               v 5 "Check %s"
-              (mapconcat 'identity
+              (mapconcat #'identity
                          (append '("") (reverse result) (list thisstep))
                          "/"))
              (setq symlink-target
                    (tramp-compat-file-attribute-type
                     (file-attributes
                      (tramp-make-tramp-file-name
-                      v (mapconcat 'identity
+                      v (mapconcat #'identity
                                    (append
                                     '("") (reverse result) (list thisstep))
                                    "/")))))
@@ -328,7 +302,7 @@ pass to the OPERATION."
            ;; Combine list to form string.
            (setq result
                  (if result
-                     (mapconcat 'identity (cons "" result) "/")
+                     (mapconcat #'identity (cons "" result) "/")
                    "/"))
            (when (and is-dir (or (string= "" result)
                                  (not (string= (substring result -1) "/"))))
@@ -470,10 +444,10 @@ pass to the OPERATION."
   "Almquist shell can't handle multiple arguments.
 Convert (\"-al\") to (\"-a\" \"-l\").  Remove arguments like \"--dired\"."
   (split-string
-   (apply 'concat
+   (apply #'concat
          (mapcar (lambda (s)
                    (replace-regexp-in-string
-                    "\\(.\\)"  " -\\1" (replace-regexp-in-string "^-" "" s)))
+                    "\\(.\\)" " -\\1" (replace-regexp-in-string "^-" "" s)))
                  ;; FIXME: Warning about removed switches (long and non-dash).
                  (delq nil
                        (mapcar
@@ -502,10 +476,10 @@ Emacs dired can't find files."
            (sort
             lines
             (if sort-by-time
-                'tramp-adb-ls-output-time-less-p
-              'tramp-adb-ls-output-name-less-p))))
+                #'tramp-adb-ls-output-time-less-p
+              #'tramp-adb-ls-output-name-less-p))))
       (delete-region (point-min) (point-max))
-      (insert "  " (mapconcat 'identity sorted-lines "\n  ")))
+      (insert "  " (mapconcat #'identity sorted-lines "\n  ")))
     ;; Add final newline.
     (goto-char (point-max))
     (unless (bolp) (insert "\n"))))
@@ -514,9 +488,9 @@ Emacs dired can't find files."
   "Sort \"ls\" output by time, descending."
   (let (time-a time-b)
     (string-match tramp-adb-ls-date-regexp a)
-    (setq time-a (apply 'encode-time (parse-time-string (match-string 0 a))))
+    (setq time-a (apply #'encode-time (parse-time-string (match-string 0 a))))
     (string-match tramp-adb-ls-date-regexp b)
-    (setq time-b (apply 'encode-time (parse-time-string (match-string 0 b))))
+    (setq time-b (apply #'encode-time (parse-time-string (match-string 0 b))))
     (time-less-p time-b time-a)))
 
 (defun tramp-adb-ls-output-name-less-p (a b)
@@ -592,7 +566,7 @@ Emacs dired can't find files."
            (delq
             nil
             (mapcar
-             (lambda (l) (and (not (string-match-p  "^[[:space:]]*$" l)) l))
+             (lambda (l) (and (not (string-match-p "^[[:space:]]*$" l)) l))
              (split-string (buffer-string) "\n")))))))))))
 
 (defun tramp-adb-handle-file-local-copy (filename)
@@ -612,9 +586,7 @@ Emacs dired can't find files."
          (ignore-errors (delete-file tmpfile))
          (tramp-error
           v 'file-error "Cannot make local copy of file `%s'" filename))
-       (set-file-modes
-        tmpfile
-        (logior (or (file-modes filename) 0) (string-to-number "0400" 8))))
+       (set-file-modes tmpfile (logior (or (file-modes filename) 0) #o0400)))
       tmpfile)))
 
 (defun tramp-adb-handle-file-writable-p (filename)
@@ -660,11 +632,9 @@ But handle the case, if the \"test\" command is not 
available."
           (tmpfile (tramp-compat-make-temp-file filename)))
       (when (and append (file-exists-p filename))
        (copy-file filename tmpfile 'ok)
-       (set-file-modes
-        tmpfile
-        (logior (or (file-modes tmpfile) 0) (string-to-number "0600" 8))))
+       (set-file-modes tmpfile (logior (or (file-modes tmpfile) 0) #o0600)))
       (tramp-run-real-handler
-       'write-region (list start end tmpfile append 'no-message lockname))
+       #'write-region (list start end tmpfile append 'no-message lockname))
       (with-tramp-progress-reporter
         v 3 (format-message
              "Moving tmp file `%s' to `%s'" tmpfile filename)
@@ -707,12 +677,22 @@ But handle the case, if the \"test\" command is not 
available."
                        (tramp-compat-time-equal-p time tramp-time-doesnt-exist)
                        (tramp-compat-time-equal-p time tramp-time-dont-know))
                    (current-time)
-                 time)))
+                 time))
+         (quoted-name (tramp-shell-quote-argument localname)))
+      ;; Older versions of toybox 'touch' mishandle nanoseconds and/or
+      ;; trailing "Z", so fall back on plain seconds if nanoseconds+Z
+      ;; fails.  Also, fall back on old POSIX 'touch -t' if 'touch -d'
+      ;; (introduced in POSIX.1-2008) fails.
       (tramp-adb-send-command-and-check
-       ;; Use shell arithmetic because of Emacs integer size limit.
-       v (format "touch -t $(( %d * 65536 + %d )) %s"
-                (car time) (cadr time)
-                (tramp-shell-quote-argument localname))))))
+       v (format (concat "touch -d %s %s 2>/dev/null || "
+                        "touch -d %s %s 2>/dev/null || "
+                        "touch -t %s %s")
+                (format-time-string "%Y-%m-%dT%H:%M:%S.%NZ" time t)
+                quoted-name
+                (format-time-string "%Y-%m-%dT%H:%M:%S" time t)
+                quoted-name
+                (format-time-string "%Y%m%d%H%M.%S" time t)
+                quoted-name)))))
 
 (defun tramp-adb-handle-copy-file
   (filename newname &optional ok-if-already-exists keep-date
@@ -847,7 +827,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
   (with-parsed-tramp-file-name default-directory nil
     (let (command input tmpinput stderr tmpstderr outbuf ret)
       ;; Compute command.
-      (setq command (mapconcat 'tramp-shell-quote-argument
+      (setq command (mapconcat #'tramp-shell-quote-argument
                               (cons program args) " "))
       ;; Determine input.
       (if (null infile)
@@ -942,160 +922,123 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
          (keyboard-quit)
        ret))))
 
-(defun tramp-adb-handle-shell-command
-  (command &optional output-buffer error-buffer)
-  "Like `shell-command' for Tramp files."
-  (let* ((asynchronous (string-match-p "[ \t]*&[ \t]*\\'" command))
-        ;; We cannot use `shell-file-name' and `shell-command-switch',
-        ;; they are variables of the local host.
-        (args (list "sh" "-c" (substring command 0 asynchronous)))
-        current-buffer-p
-        (output-buffer
-         (cond
-          ((bufferp output-buffer) output-buffer)
-          ((stringp output-buffer) (get-buffer-create output-buffer))
-          (output-buffer
-           (setq current-buffer-p t)
-           (current-buffer))
-          (t (get-buffer-create
-              (if asynchronous
-                  "*Async Shell Command*"
-                "*Shell Command Output*")))))
-        (error-buffer
-         (cond
-          ((bufferp error-buffer) error-buffer)
-          ((stringp error-buffer) (get-buffer-create error-buffer))))
-        (buffer
-         (if (and (not asynchronous) error-buffer)
-             (with-parsed-tramp-file-name default-directory nil
-               (list output-buffer (tramp-make-tramp-temp-file v)))
-           output-buffer))
-        (p (get-buffer-process output-buffer)))
-
-    ;; Check whether there is another process running.  Tramp does not
-    ;; support 2 (asynchronous) processes in parallel.
-    (when p
-      (if (yes-or-no-p "A command is running.  Kill it? ")
-         (ignore-errors (kill-process p))
-       (tramp-user-error p "Shell command in progress")))
-
-    (if current-buffer-p
-       (progn
-         (barf-if-buffer-read-only)
-         (push-mark nil t))
-      (with-current-buffer output-buffer
-       (setq buffer-read-only nil)
-       (erase-buffer)))
-
-    (if (and (not current-buffer-p) (integerp asynchronous))
-       (prog1
-           ;; Run the process.
-           (apply 'start-file-process "*Async Shell*" buffer args)
-         ;; Display output.
-         (pop-to-buffer output-buffer)
-         (setq mode-line-process '(":%s"))
-         (shell-mode))
-
-      (prog1
-         ;; Run the process.
-         (apply 'process-file (car args) nil buffer nil (cdr args))
-       ;; Insert error messages if they were separated.
-       (when (listp buffer)
-         (with-current-buffer error-buffer
-           (insert-file-contents (cadr buffer)))
-         (delete-file (cadr buffer)))
-       (if current-buffer-p
-           ;; This is like exchange-point-and-mark, but doesn't
-           ;; activate the mark.  It is cleaner to avoid activation,
-           ;; even though the command loop would deactivate the mark
-           ;; because we inserted text.
-           (goto-char (prog1 (mark t)
-                        (set-marker (mark-marker) (point)
-                                    (current-buffer))))
-         ;; There's some output, display it.
-         (when (with-current-buffer output-buffer (> (point-max) (point-min)))
-           (display-message-or-buffer output-buffer)))))))
-
 ;; We use BUFFER also as connection buffer during setup.  Because of
 ;; this, its original contents must be saved, and restored once
 ;; connection has been setup.
-(defun tramp-adb-handle-start-file-process (name buffer program &rest args)
-  "Like `start-file-process' for Tramp files."
-  (with-parsed-tramp-file-name default-directory nil
-    ;; When PROGRAM is nil, we should provide a tty.  This is not
-    ;; possible here.
-    (unless (stringp program)
-      (tramp-error v 'file-error "PROGRAM must be a string"))
-
-    (let* ((buffer
-           (if buffer
-               (get-buffer-create buffer)
-             ;; BUFFER can be nil.  We use a temporary buffer.
-             (generate-new-buffer tramp-temp-buffer-name)))
-          (command
-           (format "cd %s; %s"
-                   (tramp-shell-quote-argument localname)
-                   (mapconcat 'tramp-shell-quote-argument
-                              (cons program args) " ")))
-          (tramp-process-connection-type
-           (or (null program) tramp-process-connection-type))
-          (bmp (and (buffer-live-p buffer) (buffer-modified-p buffer)))
-          (name1 name)
-          (i 0)
-          ;; We do not want to run timers.
-          timer-list timer-idle-list)
-
-      (while (get-process name1)
-       ;; NAME must be unique as process name.
-       (setq i (1+ i)
-             name1 (format "%s<%d>" name i)))
-      (setq name name1)
-      ;; Set the new process properties.
-      (tramp-set-connection-property v "process-name" name)
-      (tramp-set-connection-property v "process-buffer" buffer)
-
-      (with-current-buffer (tramp-get-connection-buffer v)
-       (unwind-protect
-           ;; We catch this event.  Otherwise, `start-process' could
-           ;; be called on the local host.
-           (save-excursion
-             (save-restriction
-               ;; Activate narrowing in order to save BUFFER
-               ;; contents.  Clear also the modification time;
-               ;; otherwise we might be interrupted by
-               ;; `verify-visited-file-modtime'.
-               (let ((buffer-undo-list t)
-                     (buffer-read-only nil)
-                     (mark (point)))
-                 (clear-visited-file-modtime)
-                 (narrow-to-region (point-max) (point-max))
-                 ;; We call `tramp-adb-maybe-open-connection', in
-                 ;; order to cleanup the prompt afterwards.
-                 (tramp-adb-maybe-open-connection v)
-                 (widen)
-                 (delete-region mark (point))
-                 (narrow-to-region (point-max) (point-max))
-                 ;; Send the command.
-                 (let ((tramp-adb-prompt (regexp-quote command)))
-                   (tramp-adb-send-command v command))
-                 (let ((p (tramp-get-connection-process v)))
-                   ;; Set query flag and process marker for this
-                   ;; process.  We ignore errors, because the process
-                   ;; could have finished already.
-                   (ignore-errors
-                     (set-process-query-on-exit-flag p t)
-                     (set-marker (process-mark p) (point)))
-                   ;; Return process.
-                   p))))
-
-         ;; Save exit.
-         (if (string-match-p tramp-temp-buffer-name (buffer-name))
-             (ignore-errors
-               (set-process-buffer (tramp-get-connection-process v) nil)
-               (kill-buffer (current-buffer)))
-           (set-buffer-modified-p bmp))
-         (tramp-flush-connection-property v "process-name")
-         (tramp-flush-connection-property v "process-buffer"))))))
+(defun tramp-adb-handle-make-process (&rest args)
+  "Like `make-process' for Tramp files."
+  (when args
+    (with-parsed-tramp-file-name (expand-file-name default-directory) nil
+      (let ((name (plist-get args :name))
+           (buffer (plist-get args :buffer))
+           (command (plist-get args :command))
+           (coding (plist-get args :coding))
+           (noquery (plist-get args :noquery))
+           (connection-type (plist-get args :connection-type))
+           (filter (plist-get args :filter))
+           (sentinel (plist-get args :sentinel))
+           (stderr (plist-get args :stderr)))
+       (unless (stringp name)
+         (signal 'wrong-type-argument (list #'stringp name)))
+       (unless (or (null buffer) (bufferp buffer) (stringp buffer))
+         (signal 'wrong-type-argument (list #'stringp buffer)))
+       (unless (consp command)
+         (signal 'wrong-type-argument (list #'consp command)))
+       (unless (or (null coding)
+                   (and (symbolp coding) (memq coding coding-system-list))
+                   (and (consp coding)
+                        (memq (car coding) coding-system-list)
+                        (memq (cdr coding) coding-system-list)))
+         (signal 'wrong-type-argument (list #'symbolp coding)))
+       (unless (or (null connection-type) (memq connection-type '(pipe pty)))
+         (signal 'wrong-type-argument (list #'symbolp connection-type)))
+       (unless (or (null filter) (functionp filter))
+         (signal 'wrong-type-argument (list #'functionp filter)))
+       (unless (or (null sentinel) (functionp sentinel))
+         (signal 'wrong-type-argument (list #'functionp sentinel)))
+       (unless (or (null stderr) (bufferp stderr) (stringp stderr))
+         (signal 'wrong-type-argument (list #'stringp stderr)))
+
+       (let* ((buffer
+               (if buffer
+                   (get-buffer-create buffer)
+                 ;; BUFFER can be nil.  We use a temporary buffer.
+                 (generate-new-buffer tramp-temp-buffer-name)))
+              (program (car command))
+              (args (cdr command))
+              (command
+               (format "cd %s && exec %s"
+                       (tramp-shell-quote-argument localname)
+                       (mapconcat #'tramp-shell-quote-argument
+                                  (cons program args) " ")))
+              (tramp-process-connection-type
+               (or (null program) tramp-process-connection-type))
+              (bmp (and (buffer-live-p buffer) (buffer-modified-p buffer)))
+              (name1 name)
+              (i 0)
+              ;; We do not want to run timers.
+              timer-list timer-idle-list)
+
+         (while (get-process name1)
+           ;; NAME must be unique as process name.
+           (setq i (1+ i)
+                 name1 (format "%s<%d>" name i)))
+         (setq name name1)
+         ;; Set the new process properties.
+         (tramp-set-connection-property v "process-name" name)
+         (tramp-set-connection-property v "process-buffer" buffer)
+
+         (with-current-buffer (tramp-get-connection-buffer v)
+           (unwind-protect
+               ;; We catch this event.  Otherwise, `make-process'
+               ;; could be called on the local host.
+               (save-excursion
+                 (save-restriction
+                   ;; Activate narrowing in order to save BUFFER
+                   ;; contents.  Clear also the modification time;
+                   ;; otherwise we might be interrupted by
+                   ;; `verify-visited-file-modtime'.
+                   (let ((buffer-undo-list t)
+                         (inhibit-read-only t))
+                     (clear-visited-file-modtime)
+                     (narrow-to-region (point-max) (point-max))
+                     ;; We call `tramp-adb-maybe-open-connection', in
+                     ;; order to cleanup the prompt afterwards.
+                     (tramp-adb-maybe-open-connection v)
+                     (delete-region (point-min) (point-max))
+                     ;; Send the command.
+                     (let* ((p (tramp-get-connection-process v)))
+                        (tramp-adb-send-command v command nil t) ; nooutput
+                       ;; Set sentinel and filter.
+                       (when sentinel
+                         (set-process-sentinel p sentinel))
+                       (when filter
+                         (set-process-filter p filter))
+                       ;; Set query flag and process marker for this
+                       ;; process.  We ignore errors, because the
+                       ;; process could have finished already.
+                       (ignore-errors
+                         (set-process-query-on-exit-flag p (null noquery))
+                         (set-marker (process-mark p) (point)))
+                       ;; Read initial output.  Remove the first line,
+                       ;; which is the command echo.
+                       (while
+                           (progn
+                             (goto-char (point-min))
+                             (not (re-search-forward "[\n]" nil t)))
+                         (tramp-accept-process-output p 0))
+                       (delete-region (point-min) (point))
+                       ;; Return process.
+                       p))))
+
+             ;; Save exit.
+             (if (string-match-p tramp-temp-buffer-name (buffer-name))
+                 (ignore-errors
+                   (set-process-buffer (tramp-get-connection-process v) nil)
+                   (kill-buffer (current-buffer)))
+               (set-buffer-modified-p bmp))
+             (tramp-flush-connection-property v "process-name")
+             (tramp-flush-connection-property v "process-buffer"))))))))
 
 (defun tramp-adb-handle-exec-path ()
   "Like `exec-path' for Tramp files."
@@ -1123,7 +1066,7 @@ E.g. a host name \"192.168.1.1#5555\" returns 
\"192.168.1.1:5555\"
   (with-tramp-connection-property (tramp-get-connection-process vec) "device"
     (let* ((host (tramp-file-name-host vec))
           (port (tramp-file-name-port-or-default vec))
-          (devices (mapcar 'cadr (tramp-adb-parse-device-names nil))))
+          (devices (mapcar #'cadr (tramp-adb-parse-device-names nil))))
       (replace-regexp-in-string
        tramp-prefix-port-format ":"
        (cond ((member host devices) host)
@@ -1160,7 +1103,7 @@ E.g. a host name \"192.168.1.1#5555\" returns 
\"192.168.1.1:5555\"
     (prog1
        (unless
            (zerop
-            (apply 'tramp-call-process vec tramp-adb-program nil t nil args))
+            (apply #'tramp-call-process vec tramp-adb-program nil t nil args))
          (buffer-string))
       (tramp-message vec 6 "%s" (buffer-string)))))
 
@@ -1172,24 +1115,27 @@ This happens for Android >= 4.0."
 
 ;; Connection functions
 
-(defun tramp-adb-send-command (vec command)
+(defun tramp-adb-send-command (vec command &optional neveropen nooutput)
   "Send the COMMAND to connection VEC."
-  (tramp-adb-maybe-open-connection vec)
+  (unless neveropen (tramp-adb-maybe-open-connection vec))
   (tramp-message vec 6 "%s" command)
   (tramp-send-string vec command)
-  ;; fixme: Race condition
-  (tramp-adb-wait-for-output (tramp-get-connection-process vec))
-  (with-current-buffer (tramp-get-connection-buffer vec)
-    (save-excursion
-      (goto-char (point-min))
-      ;; We can't use stty to disable echo of command.
-      (delete-matching-lines (regexp-quote command))
-      ;; When the local machine is W32, there are still trailing ^M.
-      ;; There must be a better solution by setting the correct coding
-      ;; system, but this requires changes in core Tramp.
-      (goto-char (point-min))
-      (while (re-search-forward "\r+$" nil t)
-       (replace-match "" nil nil)))))
+  (unless nooutput
+    ;; FIXME: Race condition.
+    (tramp-adb-wait-for-output (tramp-get-connection-process vec))
+    (with-current-buffer (tramp-get-connection-buffer vec)
+      (save-excursion
+       (goto-char (point-min))
+       ;; We can't use stty to disable echo of command.  stty is said
+       ;; to be added to toybox 0.7.6.  busybox shall have it, but this
+       ;; isn't used any longer for Android.
+       (delete-matching-lines (regexp-quote command))
+       ;; When the local machine is W32, there are still trailing ^M.
+       ;; There must be a better solution by setting the correct coding
+       ;; system, but this requires changes in core Tramp.
+       (goto-char (point-min))
+       (while (re-search-forward "\r+$" nil t)
+         (replace-match "" nil nil))))))
 
 (defun tramp-adb-send-command-and-check (vec command)
   "Run COMMAND and check its exit status.
@@ -1208,51 +1154,43 @@ the exit status is not equal 0, and t otherwise."
     (skip-chars-forward "^ ")
     (prog1
        (zerop (read (current-buffer)))
-      (let (buffer-read-only)
+      (let ((inhibit-read-only t))
        (delete-region (match-beginning 0) (point-max))))))
 
 (defun tramp-adb-barf-unless-okay (vec command fmt &rest args)
   "Run COMMAND, check exit status, throw error if exit status not okay.
 FMT and ARGS are passed to `error'."
   (unless (tramp-adb-send-command-and-check vec command)
-    (apply 'tramp-error vec 'file-error fmt args)))
+    (apply #'tramp-error vec 'file-error fmt args)))
 
 (defun tramp-adb-wait-for-output (proc &optional timeout)
   "Wait for output from remote command."
   (unless (buffer-live-p (process-buffer proc))
     (delete-process proc)
     (tramp-error proc 'file-error "Process `%s' not available, try again" 
proc))
-  (with-current-buffer (process-buffer proc)
-    (if (tramp-wait-for-regexp
-        proc timeout
-        (tramp-get-connection-property proc "prompt" tramp-adb-prompt))
-       (let (buffer-read-only)
-         (goto-char (point-min))
-         ;; ADB terminal sends "^H" sequences.
-         (when (re-search-forward "<\b+" (point-at-eol) t)
-           (forward-line 1)
-           (delete-region (point-min) (point)))
-         ;; Delete the prompt.
-         (goto-char (point-min))
-         (when (re-search-forward
-               (tramp-get-connection-property proc "prompt" tramp-adb-prompt)
-               (point-at-eol) t)
-           (forward-line 1)
-           (delete-region (point-min) (point)))
-         (goto-char (point-max))
-         (re-search-backward
-          (tramp-get-connection-property proc "prompt" tramp-adb-prompt) nil t)
-         (delete-region (point) (point-max)))
-      (if timeout
+  (let ((prompt (tramp-get-connection-property proc "prompt" 
tramp-adb-prompt)))
+    (with-current-buffer (process-buffer proc)
+      (if (tramp-wait-for-regexp proc timeout prompt)
+         (let ((inhibit-read-only t))
+           (goto-char (point-min))
+           ;; ADB terminal sends "^H" sequences.
+           (when (re-search-forward "<\b+" (point-at-eol) t)
+             (forward-line 1)
+             (delete-region (point-min) (point)))
+           ;; Delete the prompt.
+            (goto-char (point-min))
+            (when (re-search-forward prompt (point-at-eol) t)
+              (forward-line 1)
+              (delete-region (point-min) (point)))
+           (goto-char (point-max))
+           (re-search-backward prompt nil t)
+           (delete-region (point) (point-max)))
+       (if timeout
+           (tramp-error
+            proc 'file-error
+            "[[Remote prompt `%s' not found in %d secs]]" prompt timeout)
          (tramp-error
-          proc 'file-error
-          "[[Remote adb prompt `%s' not found in %d secs]]"
-          (tramp-get-connection-property proc "prompt" tramp-adb-prompt)
-          timeout)
-       (tramp-error
-        proc 'file-error
-        "[[Remote prompt `%s' not found]]"
-        (tramp-get-connection-property proc "prompt" tramp-adb-prompt))))))
+          proc 'file-error "[[Remote prompt `%s' not found]]" prompt))))))
 
 (defun tramp-adb-maybe-open-connection (vec)
   "Maybe open a connection VEC.
@@ -1271,6 +1209,14 @@ connection if a previous connection has died for some 
reason."
       (tramp-error vec 'file-error "Cannot switch to user `%s'" user))
 
     (unless (process-live-p p)
+      ;; During completion, don't reopen a new connection.  We check
+      ;; this for the process related to `tramp-buffer-name';
+      ;; otherwise `start-file-process' wouldn't run ever when
+      ;; `non-essential' is non-nil.
+      (when (and (tramp-completion-mode-p)
+                (null (get-process (tramp-buffer-name vec))))
+       (throw 'non-essential 'non-essential))
+
       (save-match-data
        (when (and p (processp p)) (delete-process p))
        (if (zerop (length device))
@@ -1283,18 +1229,24 @@ connection if a previous connection has died for some 
reason."
                         (list "shell")))
                 (p (let ((default-directory
                            (tramp-compat-temporary-file-directory)))
-                     (apply 'start-process (tramp-get-connection-name vec) buf
+                     (apply #'start-process (tramp-get-connection-name vec) buf
                             tramp-adb-program args)))
                 (prompt (md5 (concat (prin1-to-string process-environment)
                                      (current-time-string)))))
            (tramp-message
-            vec 6 "%s" (mapconcat 'identity (process-command p) " "))
-           ;; Wait for initial prompt.
+            vec 6 "%s" (mapconcat #'identity (process-command p) " "))
+           ;; Wait for initial prompt.  On some devices, it needs an
+           ;; initial RET, in order to get it.
+            (sleep-for 0.1)
+           (tramp-send-string vec tramp-rsh-end-of-line)
            (tramp-adb-wait-for-output p 30)
            (unless (process-live-p p)
-             (tramp-error  vec 'file-error "Terminated!"))
+             (tramp-error vec 'file-error "Terminated!"))
+
+           ;; Set sentinel and query flag.  Initialize variables.
+           (set-process-sentinel p #'tramp-process-sentinel)
            (process-put p 'vector vec)
-           (process-put p 'adjust-window-size-function 'ignore)
+           (process-put p 'adjust-window-size-function #'ignore)
            (set-process-query-on-exit-flag p nil)
 
            ;; Change prompt.
@@ -1342,6 +1294,25 @@ connection if a previous connection has died for some 
reason."
            ;; Mark it as connected.
            (tramp-set-connection-property p "connected" t)))))))
 
+;; Default settings for connection-local variables.
+(defconst tramp-adb-connection-local-default-profile
+  '((shell-file-name . "/system/bin/sh")
+    (shell-command-switch . "-c"))
+  "Default connection-local variables for remote adb connections.")
+
+;; `connection-local-set-profile-variables' and
+;; `connection-local-set-profiles' exists since Emacs 26.1.
+(eval-after-load "shell"
+  '(progn
+     (tramp-compat-funcall
+      'connection-local-set-profile-variables
+      'tramp-adb-connection-local-default-profile
+      tramp-adb-connection-local-default-profile)
+     (tramp-compat-funcall
+      'connection-local-set-profiles
+      `(:application tramp :protocol ,tramp-adb-method)
+      'tramp-adb-connection-local-default-profile)))
+
 (add-hook 'tramp-unload-hook
          (lambda ()
            (unload-feature 'tramp-adb 'force)))
diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el
index cb072ac..b096edc 100644
--- a/lisp/net/tramp-archive.el
+++ b/lisp/net/tramp-archive.el
@@ -1,6 +1,6 @@
 ;;; tramp-archive.el --- Tramp archive manager  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 ;; Keywords: comm, processes
@@ -108,7 +108,10 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl-lib))
-(require 'tramp-gvfs)
+;; Sometimes, compilation fails with "Variable binding depth exceeds
+;; max-specpdl-size".
+(eval-and-compile
+  (let ((max-specpdl-size (* 2 max-specpdl-size))) (require 'tramp-gvfs)))
 
 (autoload 'dired-uncache "dired")
 (autoload 'url-tramp-convert-url-to-tramp "url-tramp")
@@ -198,15 +201,15 @@ It must be supported by libarchive(3).")
 (defconst tramp-archive-all-gvfs-methods
   (cons tramp-archive-method
        (let ((values (cdr (cadr (get 'tramp-gvfs-methods 'custom-type)))))
-         (setq values (mapcar 'last values)
-               values (mapcar 'car values))))
+         (setq values (mapcar #'last values)
+               values (mapcar #'car values))))
   "List of all methods `tramp-gvfs-methods' offers.")
 
 
 ;; New handlers should be added here.
 ;;;###tramp-autoload
 (defconst tramp-archive-file-name-handler-alist
-  '((access-file . ignore)
+  '((access-file . tramp-archive-handle-access-file)
     (add-name-to-file . tramp-archive-handle-not-implemented)
     ;; `byte-compiler-base-file-name' performed by default handler.
     ;; `copy-directory' performed by default handler.
@@ -261,6 +264,7 @@ It must be supported by libarchive(3).")
     (make-directory . tramp-archive-handle-not-implemented)
     (make-directory-internal . tramp-archive-handle-not-implemented)
     (make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
+    (make-process . ignore)
     (make-symbolic-link . tramp-archive-handle-not-implemented)
     (process-file . ignore)
     (rename-file . tramp-archive-handle-not-implemented)
@@ -273,6 +277,7 @@ It must be supported by libarchive(3).")
     (start-file-process . tramp-archive-handle-not-implemented)
     ;; `substitute-in-file-name' performed by default handler.
     (temporary-file-directory . tramp-archive-handle-temporary-file-directory)
+    ;; `tramp-set-file-uid-gid' performed by default handler.
     (unhandled-file-name-directory . ignore)
     (vc-registered . ignore)
     (verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)
@@ -282,8 +287,9 @@ Operations not mentioned here will be handled by the 
default Emacs primitives.")
 
 (defsubst tramp-archive-file-name-for-operation (operation &rest args)
   "Like `tramp-file-name-for-operation', but for archive file name syntax."
-  (cl-letf (((symbol-function 'tramp-tramp-file-p) 'tramp-archive-file-name-p))
-    (apply 'tramp-file-name-for-operation operation args)))
+  (cl-letf (((symbol-function #'tramp-tramp-file-p)
+            #'tramp-archive-file-name-p))
+    (apply #'tramp-file-name-for-operation operation args)))
 
 (defun tramp-archive-run-real-handler (operation args)
   "Invoke normal file name handler for OPERATION.
@@ -308,14 +314,15 @@ pass to the OPERATION."
           (tramp-register-file-name-handlers)
           (tramp-archive-run-real-handler operation args))
 
-      (let* ((filename (apply 'tramp-archive-file-name-for-operation
+      (let* ((filename (apply #'tramp-archive-file-name-for-operation
                              operation args))
             (archive (tramp-archive-file-name-archive filename)))
 
-        ;; The file archive could be a directory, see Bug#30293.
-        (if (and archive
-                (tramp-archive-run-real-handler
-                  'file-directory-p (list archive)))
+        ;; `filename' could be a quoted file name.  Or the file
+        ;; archive could be a directory, see Bug#30293.
+        (if (or (null archive)
+               (tramp-archive-run-real-handler
+                 #'file-directory-p (list archive)))
             (tramp-archive-run-real-handler operation args)
           ;; Now run the handler.
           (let ((tramp-methods (cons `(,tramp-archive-method) tramp-methods))
@@ -324,7 +331,7 @@ pass to the OPERATION."
                (tramp-unknown-id-integer (user-uid))
                (tramp-unknown-id-string (user-login-name))
                (fn (assoc operation tramp-archive-file-name-handler-alist)))
-           (when (eq (cdr fn) 'tramp-archive-handle-not-implemented)
+           (when (eq (cdr fn) #'tramp-archive-handle-not-implemented)
              (setq args (cons operation args)))
            (if fn
                (save-match-data (apply (cdr fn) args))
@@ -332,7 +339,7 @@ pass to the OPERATION."
 
 ;;;###autoload
 (defalias
-  'tramp-archive-autoload-file-name-handler 'tramp-autoload-file-name-handler)
+  'tramp-archive-autoload-file-name-handler #'tramp-autoload-file-name-handler)
 
 ;;;###autoload
 (progn (defun tramp-register-archive-file-name-handler ()
@@ -340,17 +347,17 @@ pass to the OPERATION."
   (when tramp-archive-enabled
     (add-to-list 'file-name-handler-alist
                 (cons (tramp-archive-autoload-file-name-regexp)
-                      'tramp-archive-autoload-file-name-handler))
+                      #'tramp-archive-autoload-file-name-handler))
     (put 'tramp-archive-autoload-file-name-handler 'safe-magic t))))
 
 ;;;###autoload
 (progn
-  (add-hook 'after-init-hook 'tramp-register-archive-file-name-handler)
+  (add-hook 'after-init-hook #'tramp-register-archive-file-name-handler)
   (add-hook
    'tramp-archive-unload-hook
    (lambda ()
      (remove-hook
-      'after-init-hook 'tramp-register-archive-file-name-handler))))
+      'after-init-hook #'tramp-register-archive-file-name-handler))))
 
 ;; In older Emacsen (prior 27.1), the autoload above does not exist.
 ;; So we call it again; it doesn't hurt.
@@ -358,19 +365,19 @@ pass to the OPERATION."
 
 ;; Mark `operations' the handler is responsible for.
 (put 'tramp-archive-file-name-handler 'operations
-     (mapcar 'car tramp-archive-file-name-handler-alist))
+     (mapcar #'car tramp-archive-file-name-handler-alist))
 
 ;; `tramp-archive-file-name-handler' must be placed before `url-file-handler'.
 (when url-handler-mode (tramp-register-file-name-handlers))
 
 (eval-after-load 'url-handler
-  (progn
-    (add-hook 'url-handler-mode-hook 'tramp-register-file-name-handlers)
-    (add-hook
-     'tramp-archive-unload-hook
-     (lambda ()
-       (remove-hook
-       'url-handler-mode-hook 'tramp-register-file-name-handlers)))))
+  '(progn
+     (add-hook 'url-handler-mode-hook #'tramp-register-file-name-handlers)
+     (add-hook
+      'tramp-archive-unload-hook
+      (lambda ()
+       (remove-hook
+        'url-handler-mode-hook #'tramp-register-file-name-handlers)))))
 
 
 ;; File name conversions.
@@ -378,6 +385,8 @@ pass to the OPERATION."
 (defun tramp-archive-file-name-p (name)
   "Return t if NAME is a string with archive file name syntax."
   (and (stringp name)
+       ;; `tramp-archive-file-name-regexp' does not suppress quoted file names.
+       (not (tramp-compat-file-name-quoted-p name t))
        ;; We cannot use `string-match-p', the matches are used.
        (string-match tramp-archive-file-name-regexp name)
        t))
@@ -450,9 +459,9 @@ name is kept in slot `hop'"
 
        ;; Anything else.  Here we call `file-local-copy', which we
        ;; have avoided so far.
-       (t (let* ((inhibit-file-name-operation 'file-local-copy)
+       (t (let* ((inhibit-file-name-operation #'file-local-copy)
                 (inhibit-file-name-handlers
-                 (cons 'jka-compr-handler inhibit-file-name-handlers))
+                 (cons #'jka-compr-handler inhibit-file-name-handlers))
                 (copy (file-local-copy archive)))
            (setf (tramp-file-name-host vec) (tramp-archive-gvfs-host copy))
            (puthash archive (cons vec copy) tramp-archive-hash))))
@@ -462,7 +471,6 @@ name is kept in slot `hop'"
       (setf (tramp-file-name-localname vec) localname)
       vec)))
 
-;;;###tramp-autoload
 (defun tramp-archive-cleanup-hash ()
   "Remove local copies of archives, used by GVFS."
   (maphash
@@ -477,11 +485,14 @@ name is kept in slot `hop'"
    tramp-archive-hash)
   (clrhash tramp-archive-hash))
 
-(add-hook 'kill-emacs-hook 'tramp-archive-cleanup-hash)
+(add-hook 'tramp-cleanup-all-connections-hook #'tramp-archive-cleanup-hash)
+(add-hook 'kill-emacs-hook #'tramp-archive-cleanup-hash)
 (add-hook 'tramp-archive-unload-hook
          (lambda ()
+           (remove-hook 'tramp-cleanup-all-connections-hook
+                        #'tramp-archive-cleanup-hash)
            (remove-hook 'kill-emacs-hook
-                        'tramp-archive-cleanup-hash)))
+                        #'tramp-archive-cleanup-hash)))
 
 (defsubst tramp-file-name-archive (vec)
   "Extract the archive file name from VEC.
@@ -526,6 +537,10 @@ offered."
 
 ;; File name primitives.
 
+(defun tramp-archive-handle-access-file (filename string)
+  "Like `access-file' for Tramp files."
+  (access-file (tramp-archive-gvfs-file-name filename) string))
+
 (defun tramp-archive-handle-copy-file
   (filename newname &optional ok-if-already-exists keep-date
    preserve-uid-gid preserve-extended-attributes)
@@ -572,9 +587,7 @@ offered."
 
 (defun tramp-archive-handle-file-readable-p (filename)
   "Like `file-readable-p' for file archives."
-  (with-parsed-tramp-file-name
-      (tramp-archive-gvfs-file-name filename) nil
-    (tramp-check-cached-permissions v ?r)))
+  (file-readable-p (tramp-archive-gvfs-file-name filename)))
 
 (defun tramp-archive-handle-file-system-info (filename)
   "Like `file-system-info' for file archives."
@@ -627,7 +640,7 @@ offered."
   "Generic handler for operations not implemented for file archives."
   (let ((v (ignore-errors
             (tramp-archive-dissect-file-name
-             (apply 'tramp-archive-file-name-for-operation operation args)))))
+             (apply #'tramp-archive-file-name-for-operation operation args)))))
     (tramp-message v 10 "%s" (cons operation args))
     (tramp-error
      v 'file-error
diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el
index 0a799d7..3d3b14e 100644
--- a/lisp/net/tramp-cache.el
+++ b/lisp/net/tramp-cache.el
@@ -1,6 +1,6 @@
 ;;; tramp-cache.el --- file information caching for Tramp  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2000, 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2005-2019 Free Software Foundation, Inc.
 
 ;; Author: Daniel Pittman <address@hidden>
 ;;         Michael Albinus <address@hidden>
@@ -50,10 +50,11 @@
 ;;   definitions already sent to the remote shell, "last-cmd-time" is
 ;;   the time stamp a command has been sent to the remote process.
 ;;
-;; - The key is `nil'.  This are temporary properties related to the
+;; - The key is nil.  This are temporary properties related to the
 ;;   local machine.  Examples: "parse-passwd" and "parse-group" keep
-;;   the results of parsing "/etc/passwd" and "/etc/group", "locale"
-;;   is the used shell locale.
+;;   the results of parsing "/etc/passwd" and "/etc/group",
+;;   "{uid,gid}-{integer,string}" are the local uid and gid, and
+;;   "locale" is the used shell locale.
 
 ;; Some properties are handled special:
 ;;
@@ -68,7 +69,7 @@
 ;;; -- Cache --
 
 ;;;###tramp-autoload
-(defvar tramp-cache-data (make-hash-table :test 'equal)
+(defvar tramp-cache-data (make-hash-table :test #'equal)
   "Hash table for remote files properties.")
 
 ;;;###tramp-autoload
@@ -85,7 +86,6 @@ details see the info pages."
                       (choice :tag "        Property" string)
                       (choice :tag "           Value" sexp))))
 
-;;;###tramp-autoload
 (defcustom tramp-persistency-file-name
   (expand-file-name (locate-user-emacs-file "tramp"))
   "File which keeps connection history for Tramp connections."
@@ -101,7 +101,7 @@ If it doesn't exist yet, it is created and initialized with
 matching entries of `tramp-connection-properties'."
   (or (gethash key tramp-cache-data)
       (let ((hash
-            (puthash key (make-hash-table :test 'equal) tramp-cache-data)))
+            (puthash key (make-hash-table :test #'equal) tramp-cache-data)))
        (when (tramp-file-name-p key)
          (dolist (elt tramp-connection-properties)
            (when (string-match-p
@@ -118,7 +118,7 @@ Returns DEFAULT if not set."
   (setq file (tramp-compat-file-name-unquote file)
        key (copy-tramp-file-name key))
   (setf (tramp-file-name-localname key)
-       (tramp-run-real-handler 'directory-file-name (list file))
+       (tramp-run-real-handler #'directory-file-name (list file))
        (tramp-file-name-hop key) nil)
   (let* ((hash (tramp-get-hash-table key))
         (value (when (hash-table-p hash) (gethash property hash))))
@@ -128,8 +128,14 @@ Returns DEFAULT if not set."
        (and (consp value)
             (or (null remote-file-name-inhibit-cache)
                 (and (integerp remote-file-name-inhibit-cache)
-                     (<= (tramp-time-diff (current-time) (car value))
-                         remote-file-name-inhibit-cache))
+                     (time-less-p
+                      ;; `current-time' can be nil once we get rid of Emacs 24.
+                      (current-time)
+                      (time-add
+                       (car value)
+                      ;; `seconds-to-time' can be removed once we get
+                      ;; rid of Emacs 24.
+                       (seconds-to-time remote-file-name-inhibit-cache))))
                 (and (consp remote-file-name-inhibit-cache)
                      (time-less-p
                       remote-file-name-inhibit-cache (car value)))))
@@ -155,7 +161,7 @@ Returns VALUE."
   (setq file (tramp-compat-file-name-unquote file)
        key (copy-tramp-file-name key))
   (setf (tramp-file-name-localname key)
-       (tramp-run-real-handler 'directory-file-name (list file))
+       (tramp-run-real-handler #'directory-file-name (list file))
        (tramp-file-name-hop key) nil)
   (let ((hash (tramp-get-hash-table key)))
     ;; We put the timestamp there.
@@ -178,7 +184,7 @@ Returns VALUE."
   (setq file (tramp-compat-file-name-unquote file)
        key (copy-tramp-file-name key))
   (setf (tramp-file-name-localname key)
-       (tramp-run-real-handler 'directory-file-name (list file))
+       (tramp-run-real-handler #'directory-file-name (list file))
        (tramp-file-name-hop key) nil)
   (remhash property (tramp-get-hash-table key))
   (tramp-message key 8 "%s %s" file property)
@@ -190,7 +196,7 @@ Returns VALUE."
 (defun tramp-flush-file-properties (key file)
   "Remove all properties of FILE in the cache context of KEY."
   (let* ((file (tramp-run-real-handler
-               'directory-file-name (list file)))
+               #'directory-file-name (list file)))
         (truename (tramp-get-file-property key file "file-truename" nil)))
     ;; Unify localname.  Remove hop from `tramp-file-name' structure.
     (setq file (tramp-compat-file-name-unquote file)
@@ -210,7 +216,7 @@ Returns VALUE."
 Remove also properties of all files in subdirectories."
   (setq directory (tramp-compat-file-name-unquote directory))
   (let* ((directory (tramp-run-real-handler
-                   'directory-file-name (list directory)))
+                   #'directory-file-name (list directory)))
         (truename (tramp-get-file-property key directory "file-truename" nil)))
     (tramp-message key 8 "%s" directory)
     (maphash
@@ -245,17 +251,17 @@ This is suppressed for temporary buffers."
          (with-parsed-tramp-file-name bfn nil
            (tramp-flush-file-properties v localname)))))))
 
-(add-hook 'before-revert-hook 'tramp-flush-file-function)
-(add-hook 'eshell-pre-command-hook 'tramp-flush-file-function)
-(add-hook 'kill-buffer-hook 'tramp-flush-file-function)
+(add-hook 'before-revert-hook #'tramp-flush-file-function)
+(add-hook 'eshell-pre-command-hook #'tramp-flush-file-function)
+(add-hook 'kill-buffer-hook #'tramp-flush-file-function)
 (add-hook 'tramp-cache-unload-hook
          (lambda ()
            (remove-hook 'before-revert-hook
-                        'tramp-flush-file-function)
+                        #'tramp-flush-file-function)
            (remove-hook 'eshell-pre-command-hook
-                        'tramp-flush-file-function)
+                        #'tramp-flush-file-function)
            (remove-hook 'kill-buffer-hook
-                        'tramp-flush-file-function)))
+                        #'tramp-flush-file-function)))
 
 ;;; -- Properties --
 
@@ -363,7 +369,7 @@ used to cache connection properties of the local machine."
         (when (tramp-file-name-p key)
           ;; (dolist
           ;;     (slot
-          ;;   (mapcar 'car (cdr (cl-struct-slot-info 'tramp-file-name))))
+          ;;   (mapcar #'car (cdr (cl-struct-slot-info 'tramp-file-name))))
           ;;   (when (stringp (cl-struct-slot-value 'tramp-file-name slot key))
           ;;     (setf (cl-struct-slot-value 'tramp-file-name slot key)
           ;;        (substring-no-properties
@@ -451,11 +457,11 @@ used to cache connection properties of the local machine."
             (pp (read (format "(%s)" (tramp-cache-print cache)))))))))))
 
 (unless noninteractive
-  (add-hook 'kill-emacs-hook 'tramp-dump-connection-properties))
+  (add-hook 'kill-emacs-hook #'tramp-dump-connection-properties))
 (add-hook 'tramp-cache-unload-hook
          (lambda ()
            (remove-hook 'kill-emacs-hook
-                        'tramp-dump-connection-properties)))
+                        #'tramp-dump-connection-properties)))
 
 ;;;###tramp-autoload
 (defun tramp-parse-connection-properties (method)
diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el
index b886223..f1e1d82 100644
--- a/lisp/net/tramp-cmds.el
+++ b/lisp/net/tramp-cmds.el
@@ -1,6 +1,6 @@
 ;;; tramp-cmds.el --- Interactive commands for Tramp  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 ;; Keywords: comm, processes
@@ -55,9 +55,9 @@ SYNTAX can be one of the symbols `default' (default),
   "Return a list of all Tramp connection buffers."
   (append
    (all-completions
-    "*tramp" (mapcar 'list (mapcar 'buffer-name (buffer-list))))
+    "*tramp" (mapcar #'list (mapcar #'buffer-name (buffer-list))))
    (all-completions
-    "*debug tramp" (mapcar 'list (mapcar 'buffer-name (buffer-list))))))
+    "*debug tramp" (mapcar #'list (mapcar #'buffer-name (buffer-list))))))
 
 (defun tramp-list-remote-buffers ()
   "Return a list of all buffers with remote default-directory."
@@ -69,6 +69,11 @@ SYNTAX can be one of the symbols `default' (default),
     (buffer-list))))
 
 ;;;###tramp-autoload
+(defvar tramp-cleanup-connection-hook nil
+  "List of functions to be called after Tramp connection is cleaned up.
+Each function is called with the current vector as argument.")
+
+;;;###tramp-autoload
 (defun tramp-cleanup-connection (vec &optional keep-debug keep-password)
   "Flush all connection related objects.
 This includes password cache, file cache, connection cache,
@@ -80,7 +85,7 @@ When called interactively, a Tramp connection has to be 
selected."
    ;; Return nil when there is no Tramp connection.
    (list
     (let ((connections
-          (mapcar 'tramp-make-tramp-file-name (tramp-list-connections)))
+          (mapcar #'tramp-make-tramp-file-name (tramp-list-connections)))
          name)
 
       (when connections
@@ -99,9 +104,8 @@ When called interactively, a Tramp connection has to be 
selected."
     (unless keep-password (tramp-clear-passwd vec))
 
     ;; Cleanup `tramp-current-connection'.  Otherwise, we would be
-    ;; suppressed in the test suite.  We use `keep-password' as
-    ;; indicator; it is not worth to add a new argument.
-    (when keep-password (setq tramp-current-connection nil))
+    ;; suppressed.
+    (setq tramp-current-connection nil)
 
     ;; Flush file cache.
     (tramp-flush-directory-properties vec "")
@@ -118,7 +122,10 @@ When called interactively, a Tramp connection has to be 
selected."
                   (unless keep-debug
                     (get-buffer (tramp-debug-buffer-name vec)))
                   (tramp-get-connection-property vec "process-buffer" nil)))
-      (when (bufferp buf) (kill-buffer buf)))))
+      (when (bufferp buf) (kill-buffer buf)))
+
+    ;; The end.
+    (run-hook-with-args 'tramp-cleanup-connection-hook vec)))
 
 ;;;###tramp-autoload
 (defun tramp-cleanup-this-connection ()
@@ -129,6 +136,10 @@ When called interactively, a Tramp connection has to be 
selected."
        (tramp-dissect-file-name default-directory 'noexpand))))
 
 ;;;###tramp-autoload
+(defvar tramp-cleanup-all-connections-hook nil
+  "List of functions to be called after all Tramp connections are cleaned up.")
+
+;;;###tramp-autoload
 (defun tramp-cleanup-all-connections ()
   "Flush all Tramp internal objects.
 This includes password cache, file cache, connection cache, buffers."
@@ -143,10 +154,6 @@ This includes password cache, file cache, connection 
cache, buffers."
   ;; Flush file and connection cache.
   (clrhash tramp-cache-data)
 
-  ;; Cleanup local copies of archives.
-  (when (bound-and-true-p tramp-archive-enabled)
-    (tramp-archive-cleanup-hash))
-
   ;; Remove ad-hoc proxies.
   (let ((proxies tramp-default-proxies-alist))
     (while proxies
@@ -162,7 +169,10 @@ This includes password cache, file cache, connection 
cache, buffers."
 
   ;; Remove buffers.
   (dolist (name (tramp-list-tramp-buffers))
-    (when (bufferp (get-buffer name)) (kill-buffer name))))
+    (when (bufferp (get-buffer name)) (kill-buffer name)))
+
+  ;; The end.
+  (run-hooks 'tramp-cleanup-all-connections-hook))
 
 ;;;###tramp-autoload
 (defun tramp-cleanup-all-buffers ()
@@ -206,7 +216,7 @@ This includes password cache, file cache, connection cache, 
buffers."
          (lambda (x)
            (and x (boundp x) (cons x 'tramp-reporter-dump-variable)))
          (append
-          (mapcar 'intern (all-completions "tramp-" obarray 'boundp))
+          (mapcar #'intern (all-completions "tramp-" obarray #'boundp))
           ;; Non-tramp variables of interest.
           '(shell-prompt-pattern
             backup-by-copying
@@ -320,11 +330,11 @@ buffer in your bug report.
             (sort
              (append
               (mapcar
-               'intern
+               #'intern
                (all-completions "tramp-" (buffer-local-variables buffer)))
               ;; Non-tramp variables of interest.
               '(connection-local-variables-alist default-directory))
-             'string<))
+             #'string<))
            (reporter-dump-variable varsym elbuf))
        (lisp-indent-line)
        (insert ")\n"))
@@ -402,7 +412,7 @@ please ensure that the buffers are attached to your 
email.\n\n"))
          (kill-buffer nil)
          (throw 'dont-send nil))))))
 
-(defalias 'tramp-submit-bug 'tramp-bug)
+(defalias 'tramp-submit-bug #'tramp-bug)
 
 (add-hook 'tramp-unload-hook
          (lambda () (unload-feature 'tramp-cmds 'force)))
diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el
index 0137724..ae743b2 100644
--- a/lisp/net/tramp-compat.el
+++ b/lisp/net/tramp-compat.el
@@ -1,6 +1,6 @@
 ;;; tramp-compat.el --- Tramp compatibility functions  -*- lexical-binding:t 
-*-
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 ;; Keywords: comm, processes
@@ -45,8 +45,6 @@
 (require 'timer)
 (require 'ucs-normalize)
 
-(require 'tramp-loaddefs)
-
 ;; For not existing functions, obsolete functions, or functions with a
 ;; changed argument list, there are compiler warnings.  We want to
 ;; avoid them in cases we know what we do.
@@ -75,7 +73,7 @@ Add the extension of F, if existing."
 ;; `temporary-file-directory' as function is introduced with Emacs 26.1.
 (defalias 'tramp-compat-temporary-file-directory-function
   (if (fboundp 'temporary-file-directory)
-      'temporary-file-directory
+      #'temporary-file-directory
     'tramp-handle-temporary-file-directory))
 
 (defun tramp-compat-process-running-p (process-name)
@@ -104,12 +102,12 @@ Add the extension of F, if existing."
 
 ;; `default-toplevel-value' has been declared in Emacs 24.4.
 (unless (fboundp 'default-toplevel-value)
-  (defalias 'default-toplevel-value 'symbol-value))
+  (defalias 'default-toplevel-value #'symbol-value))
 
 ;; `file-attribute-*' are introduced in Emacs 25.1.
 
 (if (fboundp 'file-attribute-type)
-    (defalias 'tramp-compat-file-attribute-type 'file-attribute-type)
+    (defalias 'tramp-compat-file-attribute-type #'file-attribute-type)
   (defsubst tramp-compat-file-attribute-type (attributes)
     "The type field in ATTRIBUTES returned by `file-attributes'.
 The value is either t for directory, string (name linked to) for
@@ -118,13 +116,13 @@ symbolic link, or nil."
 
 (if (fboundp 'file-attribute-link-number)
     (defalias 'tramp-compat-file-attribute-link-number
-      'file-attribute-link-number)
+      #'file-attribute-link-number)
   (defsubst tramp-compat-file-attribute-link-number (attributes)
     "Return the number of links in ATTRIBUTES returned by `file-attributes'."
     (nth 1 attributes)))
 
 (if (fboundp 'file-attribute-user-id)
-    (defalias 'tramp-compat-file-attribute-user-id 'file-attribute-user-id)
+    (defalias 'tramp-compat-file-attribute-user-id #'file-attribute-user-id)
   (defsubst tramp-compat-file-attribute-user-id (attributes)
     "The UID field in ATTRIBUTES returned by `file-attributes'.
 This is either a string or a number.  If a string value cannot be
@@ -133,7 +131,7 @@ returned."
     (nth 2 attributes)))
 
 (if (fboundp 'file-attribute-group-id)
-    (defalias 'tramp-compat-file-attribute-group-id 'file-attribute-group-id)
+    (defalias 'tramp-compat-file-attribute-group-id #'file-attribute-group-id)
   (defsubst tramp-compat-file-attribute-group-id (attributes)
     "The GID field in ATTRIBUTES returned by `file-attributes'.
 This is either a string or a number.  If a string value cannot be
@@ -143,7 +141,7 @@ returned."
 
 (if (fboundp 'file-attribute-modification-time)
     (defalias 'tramp-compat-file-attribute-modification-time
-      'file-attribute-modification-time)
+      #'file-attribute-modification-time)
   (defsubst tramp-compat-file-attribute-modification-time (attributes)
     "The modification time in ATTRIBUTES returned by `file-attributes'.
 This is the time of the last change to the file's contents, and
@@ -151,7 +149,7 @@ is a Lisp timestamp in the style of `current-time'."
     (nth 5 attributes)))
 
 (if (fboundp 'file-attribute-size)
-    (defalias 'tramp-compat-file-attribute-size 'file-attribute-size)
+    (defalias 'tramp-compat-file-attribute-size #'file-attribute-size)
   (defsubst tramp-compat-file-attribute-size (attributes)
     "The size (in bytes) in ATTRIBUTES returned by `file-attributes'.
 If the size is too large for a fixnum, this is a bignum in Emacs 27
@@ -159,7 +157,7 @@ and later, and is a float in Emacs 26 and earlier."
     (nth 7 attributes)))
 
 (if (fboundp 'file-attribute-modes)
-    (defalias 'tramp-compat-file-attribute-modes 'file-attribute-modes)
+    (defalias 'tramp-compat-file-attribute-modes #'file-attribute-modes)
   (defsubst tramp-compat-file-attribute-modes (attributes)
     "The file modes in ATTRIBUTES returned by `file-attributes'.
 This is a string of ten letters or dashes as in ls -l."
@@ -167,11 +165,11 @@ This is a string of ten letters or dashes as in ls -l."
 
 ;; `format-message' is new in Emacs 25.1.
 (unless (fboundp 'format-message)
-  (defalias 'format-message 'format))
+  (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)
+    (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))
@@ -191,7 +189,7 @@ This is a string of ten letters or dashes as in ls -l."
 ;; `file-name-unquote' are introduced in Emacs 26.
 (eval-and-compile
   (if (fboundp 'file-local-name)
-      (defalias 'tramp-compat-file-local-name 'file-local-name)
+      (defalias 'tramp-compat-file-local-name #'file-local-name)
     (defsubst tramp-compat-file-local-name (name)
       "Return the local name component of NAME.
 It returns a file name which can be used directly as argument of
@@ -199,14 +197,15 @@ It returns a file name which can be used directly as 
argument of
       (or (file-remote-p name 'localname) name)))
 
   (if (fboundp 'file-name-quoted-p)
-      (defalias 'tramp-compat-file-name-quoted-p 'file-name-quoted-p)
-    (defsubst tramp-compat-file-name-quoted-p (name)
+      (defalias 'tramp-compat-file-name-quoted-p #'file-name-quoted-p)
+    (defsubst tramp-compat-file-name-quoted-p (name &optional top)
       "Whether NAME is quoted with prefix \"/:\".
-If NAME is a remote file name, check the local part of NAME."
-      (string-prefix-p "/:" (tramp-compat-file-local-name name))))
+If NAME is a remote file name and TOP is nil, check the local part of NAME."
+      (let ((file-name-handler-alist (unless top file-name-handler-alist)))
+       (string-prefix-p "/:" (tramp-compat-file-local-name name)))))
 
   (if (fboundp 'file-name-quote)
-      (defalias 'tramp-compat-file-name-quote 'file-name-quote)
+      (defalias 'tramp-compat-file-name-quote #'file-name-quote)
     (defsubst tramp-compat-file-name-quote (name)
       "Add the quotation prefix \"/:\" to file NAME.
 If NAME is a remote file name, the local part of NAME is quoted."
@@ -216,7 +215,7 @@ If NAME is a remote file name, the local part of NAME is 
quoted."
         (file-remote-p name) "/:" (tramp-compat-file-local-name name)))))
 
   (if (fboundp 'file-name-unquote)
-      (defalias 'tramp-compat-file-name-unquote 'file-name-unquote)
+      (defalias 'tramp-compat-file-name-unquote #'file-name-unquote)
     (defsubst tramp-compat-file-name-unquote (name)
       "Remove quotation prefix \"/:\" from file NAME.
 If NAME is a remote file name, the local part of NAME is unquoted."
@@ -230,6 +229,7 @@ If NAME is a remote file name, the local part of NAME is 
unquoted."
 ;; support old settings.
 (defsubst tramp-compat-tramp-syntax ()
   "Return proper value of `tramp-syntax'."
+  (defvar tramp-syntax)
   (cond ((eq tramp-syntax 'ftp) 'default)
        ((eq tramp-syntax 'sep) 'separate)
        (t tramp-syntax)))
@@ -237,8 +237,8 @@ If NAME is a remote file name, the local part of NAME is 
unquoted."
 ;; `cl-struct-slot-info' has been introduced with Emacs 25.
 (defmacro tramp-compat-tramp-file-name-slots ()
   (if (fboundp 'cl-struct-slot-info)
-      '(cdr (mapcar 'car (cl-struct-slot-info 'tramp-file-name)))
-    '(cdr (mapcar 'car (get 'tramp-file-name 'cl-struct-slots)))))
+      '(cdr (mapcar #'car (cl-struct-slot-info 'tramp-file-name)))
+    '(cdr (mapcar #'car (get 'tramp-file-name 'cl-struct-slots)))))
 
 ;; The signature of `tramp-make-tramp-file-name' has been changed.
 ;; Therefore, we cannot us `url-tramp-convert-url-to-tramp' prior
@@ -249,7 +249,7 @@ If NAME is a remote file name, the local part of NAME is 
unquoted."
 ;; `exec-path' is new in Emacs 27.1.
 (eval-and-compile
   (if (fboundp 'exec-path)
-      (defalias 'tramp-compat-exec-path 'exec-path)
+      (defalias 'tramp-compat-exec-path #'exec-path)
     (defun tramp-compat-exec-path ()
       "List of directories to search programs to run in remote subprocesses."
       (let ((handler (find-file-name-handler default-directory 'exec-path)))
@@ -259,12 +259,27 @@ If NAME is a remote file name, the local part of NAME is 
unquoted."
 
 ;; `time-equal-p' has appeared in Emacs 27.1.
 (if (fboundp 'time-equal-p)
-    (defalias 'tramp-compat-time-equal-p 'time-equal-p)
+    (defalias 'tramp-compat-time-equal-p #'time-equal-p)
   (defsubst tramp-compat-time-equal-p (t1 t2)
     "Return non-nil if time value T1 is equal to time value T2.
 A nil value for either argument stands for the current time."
     (equal (or t1 (current-time)) (or t2 (current-time)))))
 
+;; `flatten-tree' has appeared in Emacs 27.1.
+(if (fboundp 'flatten-tree)
+    (defalias 'tramp-compat-flatten-tree #'flatten-tree)
+  (defun tramp-compat-flatten-tree (tree)
+    "Take TREE and \"flatten\" it."
+    (let (elems)
+      (setq tree (list tree))
+      (while (let ((elem (pop tree)))
+               (cond ((consp elem)
+                      (setq tree (cons (car elem) (cons (cdr elem) tree))))
+                     (elem
+                      (push elem elems)))
+               tree))
+      (nreverse elems))))
+
 (add-hook 'tramp-unload-hook
          (lambda ()
            (unload-feature 'tramp-loaddefs 'force)
@@ -274,7 +289,7 @@ A nil value for either argument stands for the current 
time."
 
 ;;; TODO:
 
-;; * When we get rid of Emacs 24, replace "(mapconcat 'identity" by
+;; * When we get rid of Emacs 24, replace "(mapconcat #'identity" by
 ;;   "(string-join".
 
 ;;; tramp-compat.el ends here
diff --git a/lisp/net/tramp-ftp.el b/lisp/net/tramp-ftp.el
index 5d8b56e..d1aae22 100644
--- a/lisp/net/tramp-ftp.el
+++ b/lisp/net/tramp-ftp.el
@@ -1,6 +1,6 @@
 ;;; tramp-ftp.el --- Tramp convenience functions for Ange-FTP  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 ;; Keywords: comm, processes
@@ -54,10 +54,9 @@ present for backward compatibility."
          (delete a1 (delete a2 file-name-handler-alist)))))
 
 (eval-after-load "ange-ftp"
-  '(when (functionp 'tramp-disable-ange-ftp)
-     (tramp-disable-ange-ftp)))
+  '(tramp-disable-ange-ftp))
 
-;;;###autoload
+;;;###tramp-autoload
 (defun tramp-ftp-enable-ange-ftp ()
   "Reenable Ange-FTP, when Tramp is unloaded."
   ;; The following code is commented out in Ange-FTP.
@@ -86,7 +85,7 @@ present for backward compatibility."
                         ange-ftp-completion-hook-function)
                       file-name-handler-alist)))))
 
-(add-hook 'tramp-ftp-unload-hook 'tramp-ftp-enable-ange-ftp)
+(add-hook 'tramp-ftp-unload-hook #'tramp-ftp-enable-ange-ftp)
 
 ;; Define FTP method ...
 ;;;###tramp-autoload
@@ -95,22 +94,19 @@ present for backward compatibility."
 
 ;; ... and add it to the method list.
 ;;;###tramp-autoload
-(add-to-list 'tramp-methods (cons tramp-ftp-method nil))
+(tramp--with-startup
+ (add-to-list 'tramp-methods (cons tramp-ftp-method nil))
 
-;; Add some defaults for `tramp-default-method-alist'.
-;;;###tramp-autoload
-(add-to-list 'tramp-default-method-alist
-            (list "\\`ftp\\." nil tramp-ftp-method))
-;;;###tramp-autoload
-(add-to-list 'tramp-default-method-alist
-            (list nil "\\`\\(anonymous\\|ftp\\)\\'" tramp-ftp-method))
+ ;; Add some defaults for `tramp-default-method-alist'.
+ (add-to-list 'tramp-default-method-alist
+             (list "\\`ftp\\." nil tramp-ftp-method))
+ (add-to-list 'tramp-default-method-alist
+             (list nil "\\`\\(anonymous\\|ftp\\)\\'" tramp-ftp-method))
 
-;; Add completion function for FTP method.
-;;;###tramp-autoload
-(eval-after-load 'tramp
-  '(tramp-set-completion-function
-     tramp-ftp-method
-     '((tramp-parse-netrc "~/.netrc"))))
+ ;; Add completion function for FTP method.
+ (tramp-set-completion-function
+  tramp-ftp-method
+  '((tramp-parse-netrc "~/.netrc"))))
 
 ;;;###tramp-autoload
 (defun tramp-ftp-file-name-handler (operation &rest args)
@@ -142,7 +138,7 @@ pass to the OPERATION."
        ;; because this returns another user but the one declared in
        ;; "~/.netrc".
        ((memq operation '(file-directory-p file-exists-p))
-       (if (apply 'ange-ftp-hook-function operation args)
+       (if (apply #'ange-ftp-hook-function operation args)
            (let ((v (tramp-dissect-file-name (car args) t)))
              (setf (tramp-file-name-method v) tramp-ftp-method)
              (tramp-set-connection-property v "started" t))
@@ -176,7 +172,7 @@ pass to the OPERATION."
                        (and (eq inhibit-file-name-operation operation)
                             inhibit-file-name-handlers)))
                 (inhibit-file-name-operation operation))
-           (apply 'ange-ftp-hook-function operation args)))))))
+           (apply #'ange-ftp-hook-function operation args)))))))
 
 ;; It must be a `defsubst' in order to push the whole code into
 ;; tramp-loaddefs.el.  Otherwise, there would be recursive autoloading.
@@ -188,8 +184,9 @@ pass to the OPERATION."
                tramp-ftp-method)))
 
 ;;;###tramp-autoload
-(add-to-list 'tramp-foreign-file-name-handler-alist
-            (cons 'tramp-ftp-file-name-p 'tramp-ftp-file-name-handler))
+(tramp--with-startup
+ (add-to-list 'tramp-foreign-file-name-handler-alist
+             (cons #'tramp-ftp-file-name-p #'tramp-ftp-file-name-handler)))
 
 (add-hook 'tramp-unload-hook
          (lambda ()
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index e034f7b..8fea82d 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -1,6 +1,6 @@
 ;;; tramp-gvfs.el --- Tramp access functions for GVFS daemon  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 ;; Keywords: comm, processes
@@ -68,7 +68,7 @@
 ;; (message
 ;;  "%s"
 ;;  (mapcar
-;;   'car
+;;   #'car
 ;;   (dbus-call-method
 ;;    :session tramp-gvfs-service-daemon tramp-gvfs-path-mounttracker
 ;;    tramp-gvfs-interface-mounttracker "ListMountableInfo")))
@@ -147,14 +147,14 @@
 
 ;; Add defaults for `tramp-default-user-alist' and `tramp-default-host-alist'.
 ;;;###tramp-autoload
-(when (string-match "\\(.+\\)@\\(\\(?:gmail\\|googlemail\\)\\.com\\)"
-                   user-mail-address)
-  (add-to-list 'tramp-default-user-alist
-              `("\\`gdrive\\'" nil ,(match-string 1 user-mail-address)))
-  (add-to-list 'tramp-default-host-alist
-              '("\\`gdrive\\'" nil ,(match-string 2 user-mail-address))))
+(tramp--with-startup
+ (when (string-match "\\(.+\\)@\\(\\(?:gmail\\|googlemail\\)\\.com\\)"
+                    user-mail-address)
+   (add-to-list 'tramp-default-user-alist
+               `("\\`gdrive\\'" nil ,(match-string 1 user-mail-address)))
+   (add-to-list 'tramp-default-host-alist
+               '("\\`gdrive\\'" nil ,(match-string 2 user-mail-address)))))
 
-;;;###tramp-autoload
 (defcustom tramp-gvfs-zeroconf-domain "local"
   "Zeroconf domain to be used for discovering services, like host names."
   :group 'tramp
@@ -165,9 +165,10 @@
 ;; completion.
 ;;;###tramp-autoload
 (when (featurep 'dbusbind)
-  (dolist (elt tramp-gvfs-methods)
-    (unless (assoc elt tramp-methods)
-      (add-to-list 'tramp-methods (cons elt nil)))))
+  (tramp--with-startup
+   (dolist (elt tramp-gvfs-methods)
+     (unless (assoc elt tramp-methods)
+       (add-to-list 'tramp-methods (cons elt nil))))))
 
 (defconst tramp-gvfs-path-tramp (concat dbus-path-emacs "/Tramp")
   "The preceding object path for own objects.")
@@ -522,7 +523,7 @@ It has been changed in GVFS 1.14.")
 ;; New handlers should be added here.
 ;;;###tramp-autoload
 (defconst tramp-gvfs-file-name-handler-alist
-  '((access-file . ignore)
+  '((access-file . tramp-handle-access-file)
     (add-name-to-file . tramp-handle-add-name-to-file)
     ;; `byte-compiler-base-file-name' performed by default handler.
     ;; `copy-directory' performed by default handler.
@@ -577,6 +578,7 @@ It has been changed in GVFS 1.14.")
     (make-directory . tramp-gvfs-handle-make-directory)
     (make-directory-internal . ignore)
     (make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
+    (make-process . ignore)
     (make-symbolic-link . tramp-handle-make-symbolic-link)
     (process-file . ignore)
     (rename-file . tramp-gvfs-handle-rename-file)
@@ -589,6 +591,7 @@ It has been changed in GVFS 1.14.")
     (start-file-process . ignore)
     (substitute-in-file-name . tramp-handle-substitute-in-file-name)
     (temporary-file-directory . tramp-handle-temporary-file-directory)
+    (tramp-set-file-uid-gid . ignore)
     (unhandled-file-name-directory . ignore)
     (vc-registered . ignore)
     (verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)
@@ -620,8 +623,9 @@ pass to the OPERATION."
 
 ;;;###tramp-autoload
 (when (featurep 'dbusbind)
-  (tramp-register-foreign-file-name-handler
-   'tramp-gvfs-file-name-p 'tramp-gvfs-file-name-handler))
+  (tramp--with-startup
+   (tramp-register-foreign-file-name-handler
+    #'tramp-gvfs-file-name-p #'tramp-gvfs-file-name-handler)))
 
 
 ;; D-Bus helper function.
@@ -653,7 +657,7 @@ Return nil for null BYTE-ARRAY."
     (cons (tramp-gvfs-stringify-dbus-message (car message))
          (tramp-gvfs-stringify-dbus-message (cdr message))))
    ((consp message)
-    (mapcar 'tramp-gvfs-stringify-dbus-message message))
+    (mapcar #'tramp-gvfs-stringify-dbus-message message))
    ((stringp message)
     (format "%S" message))
    (t message)))
@@ -677,7 +681,7 @@ it is an asynchronous call, with `ignore' as callback 
function.
 The other arguments have the same meaning as with `dbus-call-method'
 or `dbus-call-method-asynchronously'."
   `(let ((func (if ,synchronous
-                  'dbus-call-method 'dbus-call-method-asynchronously))
+                  #'dbus-call-method #'dbus-call-method-asynchronously))
         (args (append (list ,bus ,service ,path ,interface ,method)
                       (if ,synchronous (list ,@args) (list 'ignore ,@args)))))
      (tramp-dbus-function ,vec func args)))
@@ -694,10 +698,10 @@ The call will be traced by Tramp with trace level 6."
   `(when (member
          ,interface
          (tramp-dbus-function
-          ,vec 'dbus-introspect-get-interface-names
+          ,vec #'dbus-introspect-get-interface-names
           (list ,bus ,service ,path)))
      (tramp-dbus-function
-      ,vec 'dbus-get-all-properties (list ,bus ,service ,path ,interface))))
+      ,vec #'dbus-get-all-properties (list ,bus ,service ,path ,interface))))
 
 (put 'with-tramp-dbus-get-all-properties 'lisp-indent-function 1)
 (put 'with-tramp-dbus-get-all-properties 'edebug-form-spec '(form symbolp 
body))
@@ -719,7 +723,7 @@ is no information where to trace the message.")
 (add-hook
  (if (boundp 'dbus-event-error-functions)
      'dbus-event-error-functions 'dbus-event-error-hooks)
- 'tramp-gvfs-dbus-event-error)
+ #'tramp-gvfs-dbus-event-error)
 
 
 ;; File name primitives.
@@ -779,7 +783,7 @@ file names."
              v 0 (format "%s %s to %s" msg-operation filename newname)
            (unless
                (apply
-                'tramp-gvfs-send-command v gvfs-operation
+                #'tramp-gvfs-send-command v gvfs-operation
                 (append
                  (and (eq op 'copy) (or keep-date preserve-uid-gid)
                       '("--preserve"))
@@ -879,12 +883,14 @@ file names."
   "Like `expand-file-name' for Tramp files."
   ;; If DIR is not given, use DEFAULT-DIRECTORY or "/".
   (setq dir (or dir default-directory "/"))
+  ;; Handle empty NAME.
+  (when (zerop (length name)) (setq name "."))
   ;; Unless NAME is absolute, concat DIR and NAME.
   (unless (file-name-absolute-p name)
     (setq name (concat (file-name-as-directory dir) name)))
   ;; If NAME is not a Tramp file, run the real handler.
   (if (not (tramp-tramp-file-p name))
-      (tramp-run-real-handler 'expand-file-name (list name nil))
+      (tramp-run-real-handler #'expand-file-name (list name nil))
     ;; Dissect NAME.
     (with-parsed-tramp-file-name name nil
       ;; If there is a default location, expand tilde.
@@ -903,7 +909,7 @@ file names."
        (tramp-error
         v 'file-error
         "Cannot expand tilde in file `%s'" name))
-      (unless (tramp-run-real-handler 'file-name-absolute-p (list localname))
+      (unless (tramp-run-real-handler #'file-name-absolute-p (list localname))
        (setq localname (concat "/" localname)))
       ;; We do not pass "/..".
       (if (string-match-p "^\\(afp\\|davs?\\|smb\\)$" method)
@@ -917,7 +923,7 @@ file names."
       ;; No tilde characters in file name, do normal
       ;; `expand-file-name' (this does "/./" and "/../").
       (tramp-make-tramp-file-name
-       v (tramp-run-real-handler 'expand-file-name (list localname))))))
+       v (tramp-run-real-handler #'expand-file-name (list localname))))))
 
 (defun tramp-gvfs-get-directory-attributes (directory)
   "Return GVFS attributes association list of all files in DIRECTORY."
@@ -931,7 +937,7 @@ file names."
          ;; Send command.
          (tramp-gvfs-send-command
           v "gvfs-ls" "-h" "-n" "-a"
-          (mapconcat 'identity tramp-gvfs-file-attributes ",")
+          (mapconcat #'identity tramp-gvfs-file-attributes ",")
           (tramp-gvfs-url-file-name directory))
          ;; Parse output.
          (with-current-buffer (tramp-get-connection-buffer v)
@@ -1130,7 +1136,8 @@ If FILE-SYSTEM is non-nil, return file system attributes."
   "Like `file-executable-p' for Tramp files."
   (with-parsed-tramp-file-name filename nil
     (with-tramp-file-property v localname "file-executable-p"
-      (tramp-check-cached-permissions v ?x))))
+      (and (file-exists-p filename)
+          (tramp-check-cached-permissions v ?x)))))
 
 (defun tramp-gvfs-handle-file-name-all-completions (filename directory)
   "Like `file-name-all-completions' for Tramp files."
@@ -1166,23 +1173,23 @@ If FILE-SYSTEM is non-nil, return file system 
attributes."
              '(created changed changes-done-hint moved deleted))
             ((memq 'attribute-change flags) '(attribute-changed))))
           (p (apply
-              'start-process
+              #'start-process
               "gvfs-monitor" (generate-new-buffer " *gvfs-monitor*")
               `("gio" "monitor" ,(tramp-gvfs-url-file-name file-name)))))
       (if (not (processp p))
          (tramp-error
           v 'file-notify-error "Monitoring not supported for `%s'" file-name)
        (tramp-message
-        v 6 "Run `%s', %S" (mapconcat 'identity (process-command p) " ") p)
+        v 6 "Run `%s', %S" (mapconcat #'identity (process-command p) " ") p)
        (process-put p 'vector v)
        (process-put p 'events events)
        (process-put p 'watch-name localname)
-       (process-put p 'adjust-window-size-function 'ignore)
+       (process-put p 'adjust-window-size-function #'ignore)
        (set-process-query-on-exit-flag p nil)
-       (set-process-filter p 'tramp-gvfs-monitor-process-filter)
+       (set-process-filter p #'tramp-gvfs-monitor-process-filter)
        ;; There might be an error if the monitor is not supported.
        ;; Give the filter a chance to read the output.
-       (tramp-accept-process-output p 1)
+       (while (tramp-accept-process-output p 0))
        (unless (process-live-p p)
          (tramp-error
           p 'file-notify-error "Monitoring not supported for `%s'" file-name))
@@ -1252,7 +1259,20 @@ file-notify events."
   "Like `file-readable-p' for Tramp files."
   (with-parsed-tramp-file-name filename nil
     (with-tramp-file-property v localname "file-readable-p"
-      (tramp-check-cached-permissions v ?r))))
+      (and (file-exists-p filename)
+          (or (tramp-check-cached-permissions v ?r)
+              ;; If the user is different from what we guess to be
+              ;; the user, we don't know.  Let's check, whether
+              ;; access is restricted explicitly.
+              (and (/= (tramp-gvfs-get-remote-uid v 'integer)
+                       (tramp-compat-file-attribute-user-id
+                        (file-attributes filename 'integer)))
+                   (not
+                    (string-equal
+                     "FALSE"
+                     (cdr (assoc
+                           "access::can-read"
+                           (tramp-gvfs-get-file-attributes filename)))))))))))
 
 (defun tramp-gvfs-handle-file-system-info (filename)
   "Like `file-system-info' for Tramp files."
@@ -1301,7 +1321,7 @@ file-notify events."
        'rename filename newname ok-if-already-exists
        'keep-date 'preserve-uid-gid)
     (tramp-run-real-handler
-     'rename-file (list filename newname ok-if-already-exists))))
+     #'rename-file (list filename newname ok-if-already-exists))))
 
 
 ;; File name conversions.
@@ -1510,20 +1530,20 @@ file-notify events."
   (dbus-register-signal
    :session nil tramp-gvfs-path-mounttracker
    tramp-gvfs-interface-mounttracker "mounted"
-   'tramp-gvfs-handler-mounted-unmounted)
+   #'tramp-gvfs-handler-mounted-unmounted)
   (dbus-register-signal
    :session nil tramp-gvfs-path-mounttracker
    tramp-gvfs-interface-mounttracker "Mounted"
-   'tramp-gvfs-handler-mounted-unmounted)
+   #'tramp-gvfs-handler-mounted-unmounted)
 
   (dbus-register-signal
    :session nil tramp-gvfs-path-mounttracker
    tramp-gvfs-interface-mounttracker "unmounted"
-   'tramp-gvfs-handler-mounted-unmounted)
+   #'tramp-gvfs-handler-mounted-unmounted)
   (dbus-register-signal
    :session nil tramp-gvfs-path-mounttracker
    tramp-gvfs-interface-mounttracker "Unmounted"
-   'tramp-gvfs-handler-mounted-unmounted))
+   #'tramp-gvfs-handler-mounted-unmounted))
 
 (defun tramp-gvfs-connection-mounted-p (vec)
   "Check, whether the location is already mounted."
@@ -1778,22 +1798,22 @@ connection if a previous connection has died for some 
reason."
        (dbus-register-method
         :session dbus-service-emacs object-path
         tramp-gvfs-interface-mountoperation "askPassword"
-        'tramp-gvfs-handler-askpassword)
+        #'tramp-gvfs-handler-askpassword)
        (dbus-register-method
         :session dbus-service-emacs object-path
         tramp-gvfs-interface-mountoperation "AskPassword"
-        'tramp-gvfs-handler-askpassword)
+        #'tramp-gvfs-handler-askpassword)
 
        ;; There could be a callback of "askQuestion" when adding
        ;; fingerprints or checking certificates.
        (dbus-register-method
         :session dbus-service-emacs object-path
         tramp-gvfs-interface-mountoperation "askQuestion"
-        'tramp-gvfs-handler-askquestion)
+        #'tramp-gvfs-handler-askquestion)
        (dbus-register-method
         :session dbus-service-emacs object-path
         tramp-gvfs-interface-mountoperation "AskQuestion"
-        'tramp-gvfs-handler-askquestion)
+        #'tramp-gvfs-handler-askquestion)
 
        ;; The call must be asynchronously, because of the "askPassword"
        ;; or "askQuestion" callbacks.
@@ -1843,7 +1863,7 @@ connection if a previous connection has died for some 
reason."
         (tramp-get-connection-process vec) "connected" t))))
 
   ;; In `tramp-check-cached-permissions', the connection properties
-  ;; {uig,gid}-{integer,string} are used.  We set them to proper values.
+  ;; "{uid,gid}-{integer,string}" are used.  We set them to proper values.
   (unless tramp-gvfs-get-remote-uid-gid-in-progress
     (let ((tramp-gvfs-get-remote-uid-gid-in-progress t))
       (tramp-gvfs-get-remote-uid vec 'integer)
@@ -1876,7 +1896,7 @@ is applied, and it returns t if the return code is zero."
     (with-current-buffer (tramp-get-connection-buffer vec)
       (tramp-gvfs-maybe-open-connection vec)
       (erase-buffer)
-      (or (zerop (apply 'tramp-call-process vec command nil t nil args))
+      (or (zerop (apply #'tramp-call-process vec command nil t nil args))
          ;; Remove information about mounted connection.
          (and (tramp-flush-file-properties vec "/") nil)))))
 
@@ -1893,9 +1913,9 @@ VEC is used only for traces."
   (dolist
       (object-path
        (mapcar
-       'car
+       #'car
        (tramp-dbus-function
-        vec 'dbus-get-all-managed-objects
+        vec #'dbus-get-all-managed-objects
         `(:session ,tramp-goa-service ,tramp-goa-path))))
     (let* ((account-properties
            (with-tramp-dbus-get-all-properties vec
diff --git a/lisp/net/tramp-integration.el b/lisp/net/tramp-integration.el
new file mode 100644
index 0000000..da168ad
--- /dev/null
+++ b/lisp/net/tramp-integration.el
@@ -0,0 +1,199 @@
+;;; tramp-integration.el --- Tramp integration into other packages  -*- 
lexical-binding:t -*-
+
+;; Copyright (C) 2019 Free Software Foundation, Inc.
+
+;; Author: Michael Albinus <address@hidden>
+;; Keywords: comm, processes
+;; Package: tramp
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This assembles all integration of Tramp with other packages.
+
+;;; Code:
+
+(require 'tramp-compat)
+
+;; Pacify byte-compiler.
+(require 'cl-lib)
+(declare-function tramp-dissect-file-name "tramp")
+(declare-function tramp-file-name-equal-p "tramp")
+(declare-function tramp-tramp-file-p "tramp")
+(declare-function recentf-cleanup "recentf")
+(defvar eshell-path-env)
+(defvar recentf-exclude)
+(defvar tramp-current-connection)
+(defvar tramp-postfix-host-format)
+
+;;; Fontification of `read-file-name':
+
+(defvar tramp-rfn-eshadow-overlay)
+(make-variable-buffer-local 'tramp-rfn-eshadow-overlay)
+
+(defun tramp-rfn-eshadow-setup-minibuffer ()
+  "Set up a minibuffer for `file-name-shadow-mode'.
+Adds another overlay hiding filename parts according to Tramp's
+special handling of `substitute-in-file-name'."
+  (when minibuffer-completing-file-name
+    (setq tramp-rfn-eshadow-overlay
+         (make-overlay (minibuffer-prompt-end) (minibuffer-prompt-end)))
+    ;; Copy rfn-eshadow-overlay properties.
+    (let ((props (overlay-properties rfn-eshadow-overlay)))
+      (while props
+        ;; The `field' property prevents correct minibuffer
+        ;; completion; we exclude it.
+        (if (not (eq (car props) 'field))
+            (overlay-put tramp-rfn-eshadow-overlay (pop props) (pop props))
+          (pop props) (pop props))))))
+
+(add-hook 'rfn-eshadow-setup-minibuffer-hook
+         #'tramp-rfn-eshadow-setup-minibuffer)
+(add-hook 'tramp-unload-hook
+         (lambda ()
+           (remove-hook 'rfn-eshadow-setup-minibuffer-hook
+                        #'tramp-rfn-eshadow-setup-minibuffer)))
+
+(defun tramp-rfn-eshadow-update-overlay-regexp ()
+  (format "[^%s/~]*\\(/\\|~\\)" tramp-postfix-host-format))
+
+;; Package rfn-eshadow is preloaded in Emacs, but for some reason,
+;; it only did (defvar rfn-eshadow-overlay) without giving it a global
+;; value, so it was only declared as dynamically-scoped within the
+;; rfn-eshadow.el file.  This is now fixed in Emacs>26.1 but we still need
+;; this defvar here for older releases.
+(defvar rfn-eshadow-overlay)
+
+(defun tramp-rfn-eshadow-update-overlay ()
+  "Update `rfn-eshadow-overlay' to cover shadowed part of minibuffer input.
+This is intended to be used as a minibuffer `post-command-hook' for
+`file-name-shadow-mode'; the minibuffer should have already
+been set up by `rfn-eshadow-setup-minibuffer'."
+  ;; In remote files name, there is a shadowing just for the local part.
+  (ignore-errors
+    (let ((end (or (overlay-end rfn-eshadow-overlay)
+                  (minibuffer-prompt-end)))
+         ;; We do not want to send any remote command.
+         (non-essential t))
+      (when (tramp-tramp-file-p (buffer-substring end (point-max)))
+       (save-excursion
+         (save-restriction
+           (narrow-to-region
+            (1+ (or (string-match-p
+                     (tramp-rfn-eshadow-update-overlay-regexp)
+                     (buffer-string) end)
+                    end))
+            (point-max))
+           (let ((rfn-eshadow-overlay tramp-rfn-eshadow-overlay)
+                 (rfn-eshadow-update-overlay-hook nil)
+                 file-name-handler-alist)
+             (move-overlay rfn-eshadow-overlay (point-max) (point-max))
+             (rfn-eshadow-update-overlay))))))))
+
+(add-hook 'rfn-eshadow-update-overlay-hook
+         #'tramp-rfn-eshadow-update-overlay)
+(add-hook 'tramp-unload-hook
+         (lambda ()
+           (remove-hook 'rfn-eshadow-update-overlay-hook
+                        #'tramp-rfn-eshadow-update-overlay)))
+
+;;; Integration of eshell.el:
+
+;; eshell.el keeps the path in `eshell-path-env'.  We must change it
+;; when `default-directory' points to another host.
+(defun tramp-eshell-directory-change ()
+  "Set `eshell-path-env' to $PATH of the host related to `default-directory'."
+  ;; Remove last element of `(exec-path)', which is `exec-directory'.
+  ;; Use `path-separator' as it does eshell.
+  (setq eshell-path-env
+       (mapconcat
+        #'identity (butlast (tramp-compat-exec-path)) path-separator)))
+
+(eval-after-load "esh-util"
+  '(progn
+     (add-hook 'eshell-mode-hook
+              #'tramp-eshell-directory-change)
+     (add-hook 'eshell-directory-change-hook
+              #'tramp-eshell-directory-change)
+     (add-hook 'tramp-integration-unload-hook
+              (lambda ()
+                (remove-hook 'eshell-mode-hook
+                             #'tramp-eshell-directory-change)
+                (remove-hook 'eshell-directory-change-hook
+                             #'tramp-eshell-directory-change)))))
+
+;;; Integration of recentf.el:
+
+(defun tramp-recentf-exclude-predicate (name)
+  "Predicate to exclude a remote file name from recentf.
+NAME must be equal to `tramp-current-connection'."
+  (when (file-remote-p name)
+    (tramp-file-name-equal-p
+     (tramp-dissect-file-name name) (car tramp-current-connection))))
+
+(defun tramp-recentf-cleanup (vec)
+  "Remove all file names related to VEC from recentf."
+  (when (bound-and-true-p recentf-list)
+    (let ((tramp-current-connection `(,vec))
+         (recentf-exclude '(tramp-recentf-exclude-predicate)))
+      (recentf-cleanup))))
+
+(defun tramp-recentf-cleanup-all ()
+  "Remove all remote file names from recentf."
+  (when (bound-and-true-p recentf-list)
+    (let ((recentf-exclude '(file-remote-p)))
+      (recentf-cleanup))))
+
+(eval-after-load "recentf"
+  '(progn
+     (add-hook 'tramp-cleanup-connection-hook
+              #'tramp-recentf-cleanup)
+     (add-hook 'tramp-cleanup-all-connections-hook
+              #'tramp-recentf-cleanup-all)
+     (add-hook 'tramp-integration-unload-hook
+              (lambda ()
+                (remove-hook 'tramp-cleanup-connection-hook
+                             #'tramp-recentf-cleanup)
+                (remove-hook 'tramp-cleanup-all-connections-hook
+                             #'tramp-recentf-cleanup-all)))))
+
+;;; Default connection-local variables for Tramp:
+
+(defconst tramp-connection-local-default-profile
+  '((shell-file-name . "/bin/sh")
+    (shell-command-switch . "-c"))
+  "Default connection-local variables for remote connections.")
+
+;; `connection-local-set-profile-variables' and
+;; `connection-local-set-profiles' exists since Emacs 26.1.
+(eval-after-load "shell"
+  '(progn
+     (tramp-compat-funcall
+      'connection-local-set-profile-variables
+      'tramp-connection-local-default-profile
+      tramp-connection-local-default-profile)
+     (tramp-compat-funcall
+      'connection-local-set-profiles
+      `(:application tramp)
+      'tramp-connection-local-default-profile)))
+
+(add-hook 'tramp-unload-hook
+         (lambda () (unload-feature 'tramp-integration 'force)))
+
+(provide 'tramp-integration)
+
+;;; tramp-integration.el ends here
diff --git a/lisp/net/tramp-rclone.el b/lisp/net/tramp-rclone.el
index 5ea42c0..0148116 100644
--- a/lisp/net/tramp-rclone.el
+++ b/lisp/net/tramp-rclone.el
@@ -1,6 +1,6 @@
 ;;; tramp-rclone.el --- Tramp access functions to cloud storages  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 ;; Keywords: comm, processes
@@ -42,7 +42,6 @@
 (defconst tramp-rclone-method "rclone"
   "When this method name is used, forward all calls to rclone mounts.")
 
-;;;###tramp-autoload
 (defcustom tramp-rclone-program "rclone"
   "Name of the rclone program."
   :group 'tramp
@@ -50,24 +49,24 @@
   :type 'string)
 
 ;;;###tramp-autoload
-(add-to-list
- 'tramp-methods
- `(,tramp-rclone-method
-   (tramp-mount-args nil)
-   (tramp-copyto-args nil)
-   (tramp-moveto-args nil)
-   (tramp-about-args ("--full"))))
+(tramp--with-startup
+ (add-to-list 'tramp-methods
+             `(,tramp-rclone-method
+               (tramp-mount-args nil)
+               (tramp-copyto-args nil)
+               (tramp-moveto-args nil)
+               (tramp-about-args ("--full"))))
 
-;;;###tramp-autoload
-(eval-after-load 'tramp
-  '(tramp-set-completion-function
-    tramp-rclone-method '((tramp-rclone-parse-device-names ""))))
+ (add-to-list 'tramp-default-host-alist `(,tramp-rclone-method nil ""))
+
+ (tramp-set-completion-function
+  tramp-rclone-method '((tramp-rclone-parse-device-names ""))))
 
 
 ;; New handlers should be added here.
 ;;;###tramp-autoload
 (defconst tramp-rclone-file-name-handler-alist
-  '((access-file . ignore)
+  '((access-file . tramp-handle-access-file)
     (add-name-to-file . tramp-handle-add-name-to-file)
     ;; `byte-compiler-base-file-name' performed by default handler.
     ;; `copy-directory' performed by default handler.
@@ -122,6 +121,7 @@
     (make-directory . tramp-rclone-handle-make-directory)
     (make-directory-internal . ignore)
     (make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
+    (make-process . ignore)
     (make-symbolic-link . tramp-handle-make-symbolic-link)
     (process-file . ignore)
     (rename-file . tramp-rclone-handle-rename-file)
@@ -134,6 +134,7 @@
     (start-file-process . ignore)
     (substitute-in-file-name . tramp-handle-substitute-in-file-name)
     (temporary-file-directory . tramp-handle-temporary-file-directory)
+    (tramp-set-file-uid-gid . ignore)
     (unhandled-file-name-directory . ignore)
     (vc-registered . ignore)
     (verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)
@@ -161,33 +162,20 @@ pass to the OPERATION."
       (tramp-run-real-handler operation args))))
 
 ;;;###tramp-autoload
-(tramp-register-foreign-file-name-handler
- 'tramp-rclone-file-name-p 'tramp-rclone-file-name-handler)
+(tramp--with-startup
+ (tramp-register-foreign-file-name-handler
+  #'tramp-rclone-file-name-p #'tramp-rclone-file-name-handler))
 
 ;;;###tramp-autoload
 (defun tramp-rclone-parse-device-names (_ignore)
   "Return a list of (nil host) tuples allowed to access."
   (with-tramp-connection-property nil "rclone-device-names"
-    (with-timeout (10)
-      (with-temp-buffer
-       ;; `call-process' does not react on timer under MS Windows.
-       ;; That's why we use `start-process'.
-       (let ((p (start-process
-                 tramp-rclone-program (current-buffer)
-                 tramp-rclone-program "listremotes"))
-             (v (make-tramp-file-name :method tramp-rclone-method))
-             result)
-         (tramp-message v 6 "%s" (mapconcat 'identity (process-command p) " "))
-         (process-put p 'adjust-window-size-function 'ignore)
-         (set-process-query-on-exit-flag p nil)
-         (while (process-live-p p)
-           (accept-process-output p 0.1))
-         (accept-process-output p 0.1)
-         (tramp-message v 6 "\n%s" (buffer-string))
-         (goto-char (point-min))
-         (while (search-forward-regexp "^\\(\\S-+\\):$" nil t)
-           (push (list nil (match-string 1)) result))
-         result)))))
+    (delq nil
+         (mapcar
+          (lambda (line)
+            (when (string-match "^\\(\\S-+\\):$" line)
+              `(nil ,(match-string 1 line))))
+          (tramp-process-lines nil tramp-rclone-program "listremotes")))))
 
 
 ;; File name primitives.
@@ -292,7 +280,7 @@ file names."
        'copy filename newname ok-if-already-exists keep-date
        preserve-uid-gid preserve-extended-attributes)
     (tramp-run-real-handler
-     'copy-file
+     #'copy-file
      (list filename newname ok-if-already-exists keep-date
           preserve-uid-gid preserve-extended-attributes))))
 
@@ -326,7 +314,7 @@ file names."
        (when full
          (let ((local (concat "^" (regexp-quote (tramp-rclone-mount-point v))))
                (remote (funcall (if (tramp-compat-file-name-quoted-p directory)
-                                    'tramp-compat-file-name-quote 'identity)
+                                    #'tramp-compat-file-name-quote #'identity)
                                 (file-remote-p directory))))
            (setq result
                  (mapcar
@@ -340,7 +328,7 @@ file names."
                              result)))
            (setq result (cons item result))))
        ;; Return result.
-       (if nosort result (sort result 'string<))))))
+       (if nosort result (sort result #'string<))))))
 
 (defun tramp-rclone-handle-file-attributes (filename &optional id-format)
   "Like `file-attributes' for Tramp files."
@@ -448,7 +436,7 @@ file names."
        'rename filename newname ok-if-already-exists
        'keep-date 'preserve-uid-gid)
     (tramp-run-real-handler
-     'rename-file (list filename newname ok-if-already-exists))))
+     #'rename-file (list filename newname ok-if-already-exists))))
 
 
 ;; File name conversions.
@@ -458,7 +446,7 @@ file names."
   (expand-file-name
    (concat
     tramp-temp-name-prefix (tramp-file-name-method vec)
-    "."  (tramp-file-name-host vec))
+    "." (tramp-file-name-host vec))
    (tramp-compat-temporary-file-directory)))
 
 (defun tramp-rclone-mounted-p (vec)
@@ -468,12 +456,12 @@ file names."
     ;; to cache a nil result.
     (or (tramp-get-connection-property
         (tramp-get-connection-process vec) "mounted" nil)
-       (tramp-set-connection-property
-        (tramp-get-connection-process vec) "mounted"
-        (let* ((default-directory temporary-file-directory)
-               (mount (shell-command-to-string "mount -t fuse.rclone")))
-          (tramp-message vec 6 "%s" "mount -t fuse.rclone")
-          (tramp-message vec 6 "\n%s" mount)
+       (let* ((default-directory temporary-file-directory)
+              (mount (shell-command-to-string "mount -t fuse.rclone")))
+         (tramp-message vec 6 "%s" "mount -t fuse.rclone")
+         (tramp-message vec 6 "\n%s" mount)
+         (tramp-set-connection-property
+          (tramp-get-connection-process vec) "mounted"
           (when (string-match
                  (format
                   "^\\(%s:\\S-*\\)" (regexp-quote (tramp-file-name-host vec)))
@@ -512,7 +500,7 @@ file names."
       (let ((quoted (tramp-compat-file-name-quoted-p localname))
            (localname (tramp-compat-file-name-unquote localname)))
        (funcall
-        (if quoted 'tramp-compat-file-name-quote 'identity)
+        (if quoted #'tramp-compat-file-name-quote #'identity)
         (expand-file-name
          (if (file-name-absolute-p localname)
              (substring localname 1) localname)
@@ -543,6 +531,14 @@ connection if a previous connection has died for some 
reason."
       (if (zerop (length host))
          (tramp-error vec 'file-error "Storage %s not connected" host))
 
+      ;; During completion, don't reopen a new connection.  We check
+      ;; this for the process related to `tramp-buffer-name';
+      ;; otherwise `start-file-process' wouldn't run ever when
+      ;; `non-essential' is non-nil.
+      (when (and (tramp-completion-mode-p)
+                (null (get-process (tramp-buffer-name vec))))
+       (throw 'non-essential 'non-essential))
+
       ;; We need a process bound to the connection buffer.  Therefore,
       ;; we create a dummy process.  Maybe there is a better solution?
       (unless (get-buffer-process (tramp-get-connection-buffer vec))
@@ -564,7 +560,7 @@ connection if a previous connection has died for some 
reason."
       ;; DESTINATION of `tramp-call-process'.
       (unless (tramp-rclone-mounted-p vec)
        (apply
-        'tramp-call-process
+        #'tramp-call-process
         vec tramp-rclone-program nil 0 nil
         (delq nil
               `("mount" ,(concat host ":/")
@@ -572,10 +568,14 @@ connection if a previous connection has died for some 
reason."
                 ;; This could be nil.
                 ,(tramp-get-method-parameter vec 'tramp-mount-args))))
        (while (not (file-exists-p (tramp-make-tramp-file-name vec 'localname)))
-         (tramp-cleanup-connection vec 'keep-debug 'keep-password)))))
+         (tramp-cleanup-connection vec 'keep-debug 'keep-password))
+
+       ;; Mark it as connected.
+       (tramp-set-connection-property
+        (tramp-get-connection-process vec) "connected" t))))
 
   ;; In `tramp-check-cached-permissions', the connection properties
-  ;; {uig,gid}-{integer,string} are used.  We set them to proper values.
+  ;; "{uid,gid}-{integer,string}" are used.  We set them to proper values.
   (with-tramp-connection-property
       vec "uid-integer" (tramp-get-local-uid 'integer))
   (with-tramp-connection-property
@@ -591,7 +591,7 @@ connection if a previous connection has died for some 
reason."
     (erase-buffer)
     (let ((flags (tramp-get-method-parameter
                  vec (intern (format "tramp-%s-args" (car args))))))
-      (apply 'tramp-call-process
+      (apply #'tramp-call-process
             vec tramp-rclone-program nil t nil (append args flags)))))
 
 (add-hook 'tramp-unload-hook
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index a6e9d29..dc64726 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -1,6 +1,6 @@
 ;;; tramp-sh.el --- Tramp access functions for (s)sh-like connections  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; (copyright statements below in code to be updated with the above notice)
 
@@ -41,7 +41,6 @@
 (defvar vc-git-program)
 (defvar vc-hg-program)
 
-;;;###tramp-autoload
 (defcustom tramp-inline-compress-start-size 4096
   "The minimum size of compressing where inline transfer.
 When inline transfer, compress transferred data of file
@@ -50,7 +49,6 @@ If it is nil, no compression at all will be applied."
   :group 'tramp
   :type '(choice (const nil) integer))
 
-;;;###tramp-autoload
 (defcustom tramp-copy-size-limit 10240
   "The maximum file size where inline copying is preferred over an \
 out-of-the-band copy.
@@ -67,7 +65,6 @@ files conditionalize this setup based on the TERM environment 
variable."
   :group 'tramp
   :type 'string)
 
-;;;###tramp-autoload
 (defcustom tramp-histfile-override "~/.tramp_history"
   "When invoking a shell, override the HISTFILE with this value.
 When setting to a string, it redirects the shell history to that
@@ -88,7 +85,6 @@ the default storage location, e.g. \"$HOME/.sh_history\"."
 (defconst tramp-display-escape-sequence-regexp "\e[[;0-9]+m"
   "Terminal control escape sequences for display attributes.")
 
-;;;###tramp-autoload
 (defconst tramp-device-escape-sequence-regexp "\e[[0-9]+n"
   "Terminal control escape sequences for device status.")
 
@@ -111,7 +107,6 @@ detected as prompt when being sent on echoing hosts, 
therefore.")
 (defconst tramp-end-of-heredoc (md5 tramp-end-of-output)
   "String used to recognize end of heredoc strings.")
 
-;;;###tramp-autoload
 (defcustom tramp-use-ssh-controlmaster-options t
   "Whether to use `tramp-ssh-controlmaster-options'."
   :group 'tramp
@@ -134,285 +129,262 @@ The string is used in `tramp-methods'.")
 
 ;; Initialize `tramp-methods' with the supported methods.
 ;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  '("rcp"
-    (tramp-login-program        "rsh")
-    (tramp-login-args           (("%h") ("-l" "%u")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-login   ("-l"))
-    (tramp-remote-shell-args    ("-c"))
-    (tramp-copy-program         "rcp")
-    (tramp-copy-args            (("-p" "%k") ("-r")))
-    (tramp-copy-keep-date       t)
-    (tramp-copy-recursive       t)))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  '("remcp"
-    (tramp-login-program        "remsh")
-    (tramp-login-args           (("%h") ("-l" "%u")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-login   ("-l"))
-    (tramp-remote-shell-args    ("-c"))
-    (tramp-copy-program         "rcp")
-    (tramp-copy-args            (("-p" "%k")))
-    (tramp-copy-keep-date       t)))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  '("scp"
-    (tramp-login-program        "ssh")
-    (tramp-login-args           (("-l" "%u") ("-p" "%p") ("%c")
-                                ("-e" "none") ("%h")))
-    (tramp-async-args           (("-q")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-login   ("-l"))
-    (tramp-remote-shell-args    ("-c"))
-    (tramp-copy-program         "scp")
-    (tramp-copy-args            (("-P" "%p") ("-p" "%k") ("-q") ("-r") ("%c")))
-    (tramp-copy-keep-date       t)
-    (tramp-copy-recursive       t)))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  '("scpx"
-    (tramp-login-program        "ssh")
-    (tramp-login-args           (("-l" "%u") ("-p" "%p") ("%c")
-                                ("-e" "none") ("-t" "-t") ("%h") ("/bin/sh")))
-    (tramp-async-args           (("-q")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-login   ("-l"))
-    (tramp-remote-shell-args    ("-c"))
-    (tramp-copy-program         "scp")
-    (tramp-copy-args            (("-P" "%p") ("-p" "%k")
-                                ("-q") ("-r") ("%c")))
-    (tramp-copy-keep-date       t)
-    (tramp-copy-recursive       t)))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  '("rsync"
-    (tramp-login-program        "ssh")
-    (tramp-login-args           (("-l" "%u") ("-p" "%p") ("%c")
-                                ("-e" "none") ("%h")))
-    (tramp-async-args           (("-q")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-login   ("-l"))
-    (tramp-remote-shell-args    ("-c"))
-    (tramp-copy-program         "rsync")
-    (tramp-copy-args            (("-t" "%k") ("-p") ("-r") ("-s") ("-c")))
-    (tramp-copy-env             (("RSYNC_RSH") ("ssh" "%c")))
-    (tramp-copy-keep-date       t)
-    (tramp-copy-keep-tmpfile    t)
-    (tramp-copy-recursive       t)))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  '("rsh"
-    (tramp-login-program        "rsh")
-    (tramp-login-args           (("%h") ("-l" "%u")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-login   ("-l"))
-    (tramp-remote-shell-args    ("-c"))))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  '("remsh"
-    (tramp-login-program        "remsh")
-    (tramp-login-args           (("%h") ("-l" "%u")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-login   ("-l"))
-    (tramp-remote-shell-args    ("-c"))))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  '("ssh"
-    (tramp-login-program        "ssh")
-    (tramp-login-args           (("-l" "%u") ("-p" "%p") ("%c")
-                                ("-e" "none") ("%h")))
-    (tramp-async-args           (("-q")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-login   ("-l"))
-    (tramp-remote-shell-args    ("-c"))))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  '("sshx"
-    (tramp-login-program        "ssh")
-    (tramp-login-args           (("-l" "%u") ("-p" "%p") ("%c")
-                                ("-e" "none") ("-t" "-t") ("%h") ("/bin/sh")))
-    (tramp-async-args           (("-q")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-login   ("-l"))
-    (tramp-remote-shell-args    ("-c"))))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  '("telnet"
-    (tramp-login-program        "telnet")
-    (tramp-login-args           (("%h") ("%p") ("2>/dev/null")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-login   ("-l"))
-    (tramp-remote-shell-args    ("-c"))))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  '("nc"
-    (tramp-login-program        "telnet")
-    (tramp-login-args           (("%h") ("%p") ("2>/dev/null")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-login   ("-l"))
-    (tramp-remote-shell-args    ("-c"))
-    (tramp-copy-program         "nc")
-    ;; We use "-v" for better error tracking.
-    (tramp-copy-args            (("-w" "1") ("-v") ("%h") ("%r")))
-    (tramp-remote-copy-program  "nc")
-    ;; We use "-p" as required for newer busyboxes.  For older
-    ;; busybox/nc versions, the value must be (("-l") ("%r")).  This
-    ;; can be achieved by tweaking `tramp-connection-properties'.
-    (tramp-remote-copy-args     (("-l") ("-p" "%r") ("2>/dev/null")))))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  '("su"
-    (tramp-login-program        "su")
-    (tramp-login-args           (("-") ("%u")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-login   ("-l"))
-    (tramp-remote-shell-args    ("-c"))
-    (tramp-connection-timeout   10)))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  '("sg"
-    (tramp-login-program        "sg")
-    (tramp-login-args           (("-") ("%u")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-args    ("-c"))
-    (tramp-connection-timeout   10)))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  '("sudo"
-    (tramp-login-program        "sudo")
-    ;; The password template must be masked.  Otherwise, it could be
-    ;; interpreted as password prompt if the remote host echoes the command.
-    (tramp-login-args           (("-u" "%u") ("-s") ("-H")
-                                ("-p" 
"P\"\"a\"\"s\"\"s\"\"w\"\"o\"\"r\"\"d\"\":")))
-    ;; Local $SHELL could be a nasty one, like zsh or fish.  Let's override it.
-    (tramp-login-env            (("SHELL") ("/bin/sh")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-login   ("-l"))
-    (tramp-remote-shell-args    ("-c"))
-    (tramp-connection-timeout   10)
-    (tramp-session-timeout      300)))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  '("doas"
-    (tramp-login-program        "doas")
-    (tramp-login-args           (("-u" "%u") ("-s")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-args    ("-c"))
-    (tramp-connection-timeout   10)
-    (tramp-session-timeout      300)))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  '("ksu"
-    (tramp-login-program        "ksu")
-    (tramp-login-args           (("%u") ("-q")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-login   ("-l"))
-    (tramp-remote-shell-args    ("-c"))
-    (tramp-connection-timeout   10)))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  '("krlogin"
-    (tramp-login-program        "krlogin")
-    (tramp-login-args           (("%h") ("-l" "%u") ("-x")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-login   ("-l"))
-    (tramp-remote-shell-args    ("-c"))))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  `("plink"
-    (tramp-login-program        "plink")
-    (tramp-login-args           (("-l" "%u") ("-P" "%p") ("-ssh") ("-t")
-                                ("%h") ("\"")
-                                (,(format
-                                   "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=%s'"
-                                   tramp-terminal-type
-                                   tramp-initial-end-of-output))
-                                ("/bin/sh") ("\"")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-login   ("-l"))
-    (tramp-remote-shell-args    ("-c"))))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  `("plinkx"
-    (tramp-login-program        "plink")
-    (tramp-login-args           (("-load") ("%h") ("-t") ("\"")
-                                (,(format
-                                   "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=%s'"
-                                   tramp-terminal-type
-                                   tramp-initial-end-of-output))
-                                ("/bin/sh") ("\"")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-login   ("-l"))
-    (tramp-remote-shell-args    ("-c"))))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  `("pscp"
-    (tramp-login-program        "plink")
-    (tramp-login-args           (("-l" "%u") ("-P" "%p") ("-ssh") ("-t")
-                                ("%h") ("\"")
-                                (,(format
-                                   "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=%s'"
-                                   tramp-terminal-type
-                                   tramp-initial-end-of-output))
-                                ("/bin/sh") ("\"")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-login   ("-l"))
-    (tramp-remote-shell-args    ("-c"))
-    (tramp-copy-program         "pscp")
-    (tramp-copy-args            (("-l" "%u") ("-P" "%p") ("-scp") ("-p" "%k")
-                                ("-q") ("-r")))
-    (tramp-copy-keep-date       t)
-    (tramp-copy-recursive       t)))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  `("psftp"
-    (tramp-login-program        "plink")
-    (tramp-login-args           (("-l" "%u") ("-P" "%p") ("-ssh") ("-t")
-                                ("%h") ("\"")
-                                (,(format
-                                   "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=%s'"
-                                   tramp-terminal-type
-                                   tramp-initial-end-of-output))
-                                ("/bin/sh") ("\"")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-login   ("-l"))
-    (tramp-remote-shell-args    ("-c"))
-    (tramp-copy-program         "pscp")
-    (tramp-copy-args            (("-l" "%u") ("-P" "%p") ("-sftp") ("-p" "%k")
-                                ("-q")))
-    (tramp-copy-keep-date       t)))
-;;;###tramp-autoload
-(add-to-list 'tramp-methods
-  '("fcp"
-    (tramp-login-program        "fsh")
-    (tramp-login-args           (("%h") ("-l" "%u") ("sh" "-i")))
-    (tramp-remote-shell         "/bin/sh")
-    (tramp-remote-shell-login   ("-l"))
-    (tramp-remote-shell-args    ("-i") ("-c"))
-    (tramp-copy-program         "fcp")
-    (tramp-copy-args            (("-p" "%k")))
-    (tramp-copy-keep-date       t)))
-
-;;;###tramp-autoload
-(add-to-list 'tramp-default-method-alist
-            `(,tramp-local-host-regexp "\\`root\\'" "su"))
-
-;;;###tramp-autoload
-(add-to-list 'tramp-default-user-alist
-            `(,(concat "\\`" (regexp-opt '("su" "sudo" "doas" "ksu")) "\\'")
-              nil "root"))
-;; Do not add "ssh" based methods, otherwise ~/.ssh/config would be ignored.
-;; Do not add "plink" based methods, they ask interactively for the user.
-;;;###tramp-autoload
-(add-to-list 'tramp-default-user-alist
-            `(,(concat
-                "\\`"
-                (regexp-opt
-                 '("rcp" "remcp" "rsh" "telnet" "nc" "krlogin" "fcp"))
-                "\\'")
-              nil ,(user-login-name)))
+(tramp--with-startup
+ (add-to-list 'tramp-methods
+              '("rcp"
+                (tramp-login-program        "rsh")
+                (tramp-login-args           (("%h") ("-l" "%u")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-login   ("-l"))
+                (tramp-remote-shell-args    ("-c"))
+                (tramp-copy-program         "rcp")
+                (tramp-copy-args            (("-p" "%k") ("-r")))
+                (tramp-copy-keep-date       t)
+                (tramp-copy-recursive       t)))
+ (add-to-list 'tramp-methods
+              '("remcp"
+                (tramp-login-program        "remsh")
+                (tramp-login-args           (("%h") ("-l" "%u")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-login   ("-l"))
+                (tramp-remote-shell-args    ("-c"))
+                (tramp-copy-program         "rcp")
+                (tramp-copy-args            (("-p" "%k")))
+                (tramp-copy-keep-date       t)))
+ (add-to-list 'tramp-methods
+              '("scp"
+                (tramp-login-program        "ssh")
+                (tramp-login-args           (("-l" "%u") ("-p" "%p") ("%c")
+                                            ("-e" "none") ("%h")))
+                (tramp-async-args           (("-q")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-login   ("-l"))
+                (tramp-remote-shell-args    ("-c"))
+                (tramp-copy-program         "scp")
+                (tramp-copy-args            (("-P" "%p") ("-p" "%k") ("-q") 
("-r") ("%c")))
+                (tramp-copy-keep-date       t)
+                (tramp-copy-recursive       t)))
+ (add-to-list 'tramp-methods
+              '("scpx"
+                (tramp-login-program        "ssh")
+                (tramp-login-args           (("-l" "%u") ("-p" "%p") ("%c")
+                                            ("-e" "none") ("-t" "-t") ("%h") 
("/bin/sh")))
+                (tramp-async-args           (("-q")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-login   ("-l"))
+                (tramp-remote-shell-args    ("-c"))
+                (tramp-copy-program         "scp")
+                (tramp-copy-args            (("-P" "%p") ("-p" "%k")
+                                            ("-q") ("-r") ("%c")))
+                (tramp-copy-keep-date       t)
+                (tramp-copy-recursive       t)))
+ (add-to-list 'tramp-methods
+              '("rsync"
+                (tramp-login-program        "ssh")
+                (tramp-login-args           (("-l" "%u") ("-p" "%p") ("%c")
+                                            ("-e" "none") ("%h")))
+                (tramp-async-args           (("-q")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-login   ("-l"))
+                (tramp-remote-shell-args    ("-c"))
+                (tramp-copy-program         "rsync")
+                (tramp-copy-args            (("-t" "%k") ("-p") ("-r") ("-s") 
("-c")))
+                (tramp-copy-env             (("RSYNC_RSH") ("ssh" "%c")))
+                (tramp-copy-keep-date       t)
+                (tramp-copy-keep-tmpfile    t)
+                (tramp-copy-recursive       t)))
+ (add-to-list 'tramp-methods
+              '("rsh"
+                (tramp-login-program        "rsh")
+                (tramp-login-args           (("%h") ("-l" "%u")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-login   ("-l"))
+                (tramp-remote-shell-args    ("-c"))))
+ (add-to-list 'tramp-methods
+              '("remsh"
+                (tramp-login-program        "remsh")
+                (tramp-login-args           (("%h") ("-l" "%u")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-login   ("-l"))
+                (tramp-remote-shell-args    ("-c"))))
+ (add-to-list 'tramp-methods
+              '("ssh"
+                (tramp-login-program        "ssh")
+                (tramp-login-args           (("-l" "%u") ("-p" "%p") ("%c")
+                                            ("-e" "none") ("%h")))
+                (tramp-async-args           (("-q")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-login   ("-l"))
+                (tramp-remote-shell-args    ("-c"))))
+ (add-to-list 'tramp-methods
+              '("sshx"
+                (tramp-login-program        "ssh")
+                (tramp-login-args           (("-l" "%u") ("-p" "%p") ("%c")
+                                            ("-e" "none") ("-t" "-t") ("%h") 
("/bin/sh")))
+                (tramp-async-args           (("-q")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-login   ("-l"))
+                (tramp-remote-shell-args    ("-c"))))
+ (add-to-list 'tramp-methods
+              '("telnet"
+                (tramp-login-program        "telnet")
+                (tramp-login-args           (("%h") ("%p") ("2>/dev/null")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-login   ("-l"))
+                (tramp-remote-shell-args    ("-c"))))
+ (add-to-list 'tramp-methods
+              '("nc"
+                (tramp-login-program        "telnet")
+                (tramp-login-args           (("%h") ("%p") ("2>/dev/null")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-login   ("-l"))
+                (tramp-remote-shell-args    ("-c"))
+                (tramp-copy-program         "nc")
+                ;; We use "-v" for better error tracking.
+                (tramp-copy-args            (("-w" "1") ("-v") ("%h") ("%r")))
+                (tramp-remote-copy-program  "nc")
+                ;; We use "-p" as required for newer busyboxes.  For older
+                ;; busybox/nc versions, the value must be (("-l") ("%r")).  
This
+                ;; can be achieved by tweaking `tramp-connection-properties'.
+                (tramp-remote-copy-args     (("-l") ("-p" "%r") 
("2>/dev/null")))))
+ (add-to-list 'tramp-methods
+              '("su"
+                (tramp-login-program        "su")
+                (tramp-login-args           (("-") ("%u")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-login   ("-l"))
+                (tramp-remote-shell-args    ("-c"))
+                (tramp-connection-timeout   10)))
+ (add-to-list 'tramp-methods
+              '("sg"
+                (tramp-login-program        "sg")
+                (tramp-login-args           (("-") ("%u")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-args    ("-c"))
+                (tramp-connection-timeout   10)))
+ (add-to-list 'tramp-methods
+              '("sudo"
+                (tramp-login-program        "sudo")
+                ;; The password template must be masked.  Otherwise, it could 
be
+                ;; interpreted as password prompt if the remote host echoes 
the command.
+                (tramp-login-args           (("-u" "%u") ("-s") ("-H")
+                                            ("-p" 
"P\"\"a\"\"s\"\"s\"\"w\"\"o\"\"r\"\"d\"\":")))
+                ;; Local $SHELL could be a nasty one, like zsh or fish.  Let's 
override it.
+                (tramp-login-env            (("SHELL") ("/bin/sh")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-login   ("-l"))
+                (tramp-remote-shell-args    ("-c"))
+                (tramp-connection-timeout   10)
+                (tramp-session-timeout      300)))
+ (add-to-list 'tramp-methods
+              '("doas"
+                (tramp-login-program        "doas")
+                (tramp-login-args           (("-u" "%u") ("-s")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-args    ("-c"))
+                (tramp-connection-timeout   10)
+                (tramp-session-timeout      300)))
+ (add-to-list 'tramp-methods
+              '("ksu"
+                (tramp-login-program        "ksu")
+                (tramp-login-args           (("%u") ("-q")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-login   ("-l"))
+                (tramp-remote-shell-args    ("-c"))
+                (tramp-connection-timeout   10)))
+ (add-to-list 'tramp-methods
+              '("krlogin"
+                (tramp-login-program        "krlogin")
+                (tramp-login-args           (("%h") ("-l" "%u") ("-x")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-login   ("-l"))
+                (tramp-remote-shell-args    ("-c"))))
+ (add-to-list 'tramp-methods
+              `("plink"
+                (tramp-login-program        "plink")
+                (tramp-login-args           (("-l" "%u") ("-P" "%p") ("-ssh") 
("-t")
+                                            ("%h") ("\"")
+                                            (,(format
+                                               "env 'TERM=%s' 
'PROMPT_COMMAND=' 'PS1=%s'"
+                                               tramp-terminal-type
+                                               tramp-initial-end-of-output))
+                                            ("/bin/sh") ("\"")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-login   ("-l"))
+                (tramp-remote-shell-args    ("-c"))))
+ (add-to-list 'tramp-methods
+              `("plinkx"
+                (tramp-login-program        "plink")
+                (tramp-login-args           (("-load") ("%h") ("-t") ("\"")
+                                            (,(format
+                                               "env 'TERM=%s' 
'PROMPT_COMMAND=' 'PS1=%s'"
+                                               tramp-terminal-type
+                                               tramp-initial-end-of-output))
+                                            ("/bin/sh") ("\"")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-login   ("-l"))
+                (tramp-remote-shell-args    ("-c"))))
+ (add-to-list 'tramp-methods
+              `("pscp"
+                (tramp-login-program        "plink")
+                (tramp-login-args           (("-l" "%u") ("-P" "%p") ("-ssh") 
("-t")
+                                            ("%h") ("\"")
+                                            (,(format
+                                               "env 'TERM=%s' 
'PROMPT_COMMAND=' 'PS1=%s'"
+                                               tramp-terminal-type
+                                               tramp-initial-end-of-output))
+                                            ("/bin/sh") ("\"")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-login   ("-l"))
+                (tramp-remote-shell-args    ("-c"))
+                (tramp-copy-program         "pscp")
+                (tramp-copy-args            (("-l" "%u") ("-P" "%p") ("-scp") 
("-p" "%k")
+                                            ("-q") ("-r")))
+                (tramp-copy-keep-date       t)
+                (tramp-copy-recursive       t)))
+ (add-to-list 'tramp-methods
+              `("psftp"
+                (tramp-login-program        "plink")
+                (tramp-login-args           (("-l" "%u") ("-P" "%p") ("-ssh") 
("-t")
+                                            ("%h") ("\"")
+                                            (,(format
+                                               "env 'TERM=%s' 
'PROMPT_COMMAND=' 'PS1=%s'"
+                                               tramp-terminal-type
+                                               tramp-initial-end-of-output))
+                                            ("/bin/sh") ("\"")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-login   ("-l"))
+                (tramp-remote-shell-args    ("-c"))
+                (tramp-copy-program         "pscp")
+                (tramp-copy-args            (("-l" "%u") ("-P" "%p") ("-sftp") 
("-p" "%k")
+                                            ("-q")))
+                (tramp-copy-keep-date       t)))
+ (add-to-list 'tramp-methods
+              '("fcp"
+                (tramp-login-program        "fsh")
+                (tramp-login-args           (("%h") ("-l" "%u") ("sh" "-i")))
+                (tramp-remote-shell         "/bin/sh")
+                (tramp-remote-shell-login   ("-l"))
+                (tramp-remote-shell-args    ("-i") ("-c"))
+                (tramp-copy-program         "fcp")
+                (tramp-copy-args            (("-p" "%k")))
+                (tramp-copy-keep-date       t)))
+
+ (add-to-list 'tramp-default-method-alist
+             `(,tramp-local-host-regexp "\\`root\\'" "su"))
+
+ (add-to-list 'tramp-default-user-alist
+             `(,(concat "\\`" (regexp-opt '("su" "sudo" "doas" "ksu")) "\\'")
+               nil "root"))
+ ;; Do not add "ssh" based methods, otherwise ~/.ssh/config would be ignored.
+ ;; Do not add "plink" based methods, they ask interactively for the user.
+ (add-to-list 'tramp-default-user-alist
+             `(,(concat
+                 "\\`"
+                 (regexp-opt
+                  '("rcp" "remcp" "rsh" "telnet" "nc" "krlogin" "fcp"))
+                 "\\'")
+               nil ,(user-login-name))))
 
 ;;;###tramp-autoload
 (defconst tramp-completion-function-alist-rsh
@@ -460,33 +432,32 @@ The string is used in `tramp-methods'.")
  "Default list of (FUNCTION REGISTRY) pairs to be examined for putty 
sessions.")
 
 ;;;###tramp-autoload
-(eval-after-load 'tramp
-  '(progn
-     (tramp-set-completion-function "rcp" tramp-completion-function-alist-rsh)
-     (tramp-set-completion-function "remcp" 
tramp-completion-function-alist-rsh)
-     (tramp-set-completion-function "scp" tramp-completion-function-alist-ssh)
-     (tramp-set-completion-function "scpx" tramp-completion-function-alist-ssh)
-     (tramp-set-completion-function "rsync" 
tramp-completion-function-alist-ssh)
-     (tramp-set-completion-function "rsh" tramp-completion-function-alist-rsh)
-     (tramp-set-completion-function "remsh" 
tramp-completion-function-alist-rsh)
-     (tramp-set-completion-function "ssh" tramp-completion-function-alist-ssh)
-     (tramp-set-completion-function "sshx" tramp-completion-function-alist-ssh)
-     (tramp-set-completion-function
-      "telnet" tramp-completion-function-alist-telnet)
-     (tramp-set-completion-function "nc" 
tramp-completion-function-alist-telnet)
-     (tramp-set-completion-function "su" tramp-completion-function-alist-su)
-     (tramp-set-completion-function "sudo" tramp-completion-function-alist-su)
-     (tramp-set-completion-function "doas" tramp-completion-function-alist-su)
-     (tramp-set-completion-function "ksu" tramp-completion-function-alist-su)
-     (tramp-set-completion-function "sg" tramp-completion-function-alist-sg)
-     (tramp-set-completion-function
-      "krlogin" tramp-completion-function-alist-rsh)
-     (tramp-set-completion-function "plink" 
tramp-completion-function-alist-ssh)
-     (tramp-set-completion-function
-      "plinkx" tramp-completion-function-alist-putty)
-     (tramp-set-completion-function "pscp" tramp-completion-function-alist-ssh)
-     (tramp-set-completion-function "psftp" 
tramp-completion-function-alist-ssh)
-     (tramp-set-completion-function "fcp" 
tramp-completion-function-alist-ssh)))
+(tramp--with-startup
+ (tramp-set-completion-function "rcp" tramp-completion-function-alist-rsh)
+ (tramp-set-completion-function "remcp" tramp-completion-function-alist-rsh)
+ (tramp-set-completion-function "scp" tramp-completion-function-alist-ssh)
+ (tramp-set-completion-function "scpx" tramp-completion-function-alist-ssh)
+ (tramp-set-completion-function "rsync" tramp-completion-function-alist-ssh)
+ (tramp-set-completion-function "rsh" tramp-completion-function-alist-rsh)
+ (tramp-set-completion-function "remsh" tramp-completion-function-alist-rsh)
+ (tramp-set-completion-function "ssh" tramp-completion-function-alist-ssh)
+ (tramp-set-completion-function "sshx" tramp-completion-function-alist-ssh)
+ (tramp-set-completion-function
+  "telnet" tramp-completion-function-alist-telnet)
+ (tramp-set-completion-function "nc" tramp-completion-function-alist-telnet)
+ (tramp-set-completion-function "su" tramp-completion-function-alist-su)
+ (tramp-set-completion-function "sudo" tramp-completion-function-alist-su)
+ (tramp-set-completion-function "doas" tramp-completion-function-alist-su)
+ (tramp-set-completion-function "ksu" tramp-completion-function-alist-su)
+ (tramp-set-completion-function "sg" tramp-completion-function-alist-sg)
+ (tramp-set-completion-function
+  "krlogin" tramp-completion-function-alist-rsh)
+ (tramp-set-completion-function "plink" tramp-completion-function-alist-ssh)
+ (tramp-set-completion-function
+  "plinkx" tramp-completion-function-alist-putty)
+ (tramp-set-completion-function "pscp" tramp-completion-function-alist-ssh)
+ (tramp-set-completion-function "psftp" tramp-completion-function-alist-ssh)
+ (tramp-set-completion-function "fcp" tramp-completion-function-alist-ssh))
 
 ;; "getconf PATH" yields:
 ;; HP-UX: 
/usr/bin:/usr/ccs/bin:/opt/ansic/bin:/opt/langtools/bin:/opt/fortran/bin
@@ -790,7 +761,7 @@ on the remote host.")
 (defconst tramp-perl-encode
   "%s -e '
 # This script contributed by Juanma Barranquero <address@hidden>.
-# Copyright (C) 2002-2018 Free Software Foundation, Inc.
+# Copyright (C) 2002-2019 Free Software Foundation, Inc.
 use strict;
 
 my %%trans = do {
@@ -828,7 +799,7 @@ This string is passed to `format', so percent characters 
need to be doubled.")
 (defconst tramp-perl-decode
   "%s -e '
 # This script contributed by Juanma Barranquero <address@hidden>.
-# Copyright (C) 2002-2018 Free Software Foundation, Inc.
+# Copyright (C) 2002-2019 Free Software Foundation, Inc.
 use strict;
 
 my %%trans = do {
@@ -945,13 +916,6 @@ od -v -t x1 -A n </dev/null && \
 busybox awk '{}' </dev/null"
   "Test command for checking `tramp-awk-encode' and `tramp-awk-decode'.")
 
-;;;###tramp-autoload
-(defconst tramp-stat-marker "/////"
-  "Marker in stat commands for file attributes.")
-
-(defconst tramp-stat-quoted-marker "\\/\\/\\/\\/\\/"
-  "Quoted marker in stat commands for file attributes.")
-
 (defconst tramp-vc-registered-read-file-names
   "echo \"(\"
 while read file; do
@@ -977,7 +941,7 @@ of command line.")
 ;; New handlers should be added here.
 ;;;###tramp-autoload
 (defconst tramp-sh-file-name-handler-alist
-  '(;; `access-file' performed by default handler.
+  '((access-file . tramp-handle-access-file)
     (add-name-to-file . tramp-sh-handle-add-name-to-file)
     ;; `byte-compiler-base-file-name' performed by default handler.
     (copy-directory . tramp-sh-handle-copy-directory)
@@ -1032,6 +996,7 @@ of command line.")
     (make-directory . tramp-sh-handle-make-directory)
     ;; `make-directory-internal' performed by default handler.
     (make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
+    (make-process . tramp-sh-handle-make-process)
     (make-symbolic-link . tramp-sh-handle-make-symbolic-link)
     (process-file . tramp-sh-handle-process-file)
     (rename-file . tramp-sh-handle-rename-file)
@@ -1041,9 +1006,10 @@ of command line.")
     (set-file-times . tramp-sh-handle-set-file-times)
     (set-visited-file-modtime . tramp-sh-handle-set-visited-file-modtime)
     (shell-command . tramp-handle-shell-command)
-    (start-file-process . tramp-sh-handle-start-file-process)
+    (start-file-process . tramp-handle-start-file-process)
     (substitute-in-file-name . tramp-handle-substitute-in-file-name)
     (temporary-file-directory . tramp-handle-temporary-file-directory)
+    (tramp-set-file-uid-gid . tramp-sh-handle-set-file-uid-gid)
     (unhandled-file-name-directory . ignore)
     (vc-registered . tramp-sh-handle-vc-registered)
     (verify-visited-file-modtime . tramp-sh-handle-verify-visited-file-modtime)
@@ -1061,7 +1027,7 @@ of the symlink.  If TARGET is a Tramp file, only the 
localname
 component is used as the target of the symlink."
   (if (not (tramp-tramp-file-p (expand-file-name linkname)))
       (tramp-run-real-handler
-       'make-symbolic-link (list target linkname ok-if-already-exists))
+       #'make-symbolic-link (list target linkname ok-if-already-exists))
 
     (with-parsed-tramp-file-name linkname nil
       ;; If TARGET is a Tramp name, use just the localname component.
@@ -1079,7 +1045,7 @@ component is used as the target of the symlink."
 
        (let ((ln (tramp-get-remote-ln v))
              (cwd (tramp-run-real-handler
-                   'file-name-directory (list localname))))
+                   #'file-name-directory (list localname))))
          (unless ln
            (tramp-error
             v 'file-error
@@ -1123,7 +1089,7 @@ component is used as the target of the symlink."
    ;; Preserve trailing "/".
   (funcall
    (if (string-equal (file-name-nondirectory filename) "")
-       'file-name-as-directory 'identity)
+       #'file-name-as-directory #'identity)
    (with-parsed-tramp-file-name (expand-file-name filename) nil
      (tramp-make-tramp-file-name
       v
@@ -1171,7 +1137,7 @@ component is used as the target of the symlink."
                  (setq thisstep (pop steps))
                  (tramp-message
                   v 5 "Check %s"
-                  (mapconcat 'identity
+                  (mapconcat #'identity
                              (append '("") (reverse result) (list thisstep))
                              "/"))
                  (setq symlink-target
@@ -1179,7 +1145,7 @@ component is used as the target of the symlink."
                         (file-attributes
                          (tramp-make-tramp-file-name
                           v
-                          (mapconcat 'identity
+                          (mapconcat #'identity
                                      (append '("")
                                              (reverse result)
                                              (list thisstep))
@@ -1211,7 +1177,7 @@ component is used as the target of the symlink."
                ;; Combine list to form string.
                (setq result
                      (if result
-                         (mapconcat 'identity (cons "" result) "/")
+                         (mapconcat #'identity (cons "" result) "/")
                        "/"))
                (when (string= "" result)
                  (setq result "/")))))
@@ -1414,7 +1380,7 @@ component is used as the target of the symlink."
     (error "Can't set-visited-file-modtime: buffer `%s' not visiting a file"
           (buffer-name)))
   (if time-list
-      (tramp-run-real-handler 'set-visited-file-modtime (list time-list))
+      (tramp-run-real-handler #'set-visited-file-modtime (list time-list))
     (let ((f (buffer-file-name))
          coding-system-used)
       (with-parsed-tramp-file-name f nil
@@ -1424,7 +1390,7 @@ component is used as the target of the symlink."
                            tramp-time-doesnt-exist)))
          (setq coding-system-used last-coding-system-used)
          (if (not (tramp-compat-time-equal-p modtime tramp-time-dont-know))
-             (tramp-run-real-handler 'set-visited-file-modtime (list modtime))
+             (tramp-run-real-handler #'set-visited-file-modtime (list modtime))
            (progn
              (tramp-send-command
               v
@@ -1516,39 +1482,26 @@ of."
              "")
            (tramp-shell-quote-argument localname)))))))
 
-(defun tramp-set-file-uid-gid (filename &optional uid gid)
-  "Set the ownership for FILENAME.
-If UID and GID are provided, these values are used; otherwise uid
-and gid of the corresponding user is taken.  Both parameters must
-be non-negative integers."
+(defun tramp-sh-handle-set-file-uid-gid (filename &optional uid gid)
+  "Like `tramp-set-file-uid-gid' for Tramp files."
   ;; Modern Unices allow chown only for root.  So we might need
   ;; another implementation, see `dired-do-chown'.  OTOH, it is mostly
   ;; working with su(do)? when it is needed, so it shall succeed in
   ;; the majority of cases.
   ;; Don't modify `last-coding-system-used' by accident.
   (let ((last-coding-system-used last-coding-system-used))
-    (if (tramp-tramp-file-p filename)
-       (with-parsed-tramp-file-name filename nil
-         (if (and (zerop (user-uid)) (tramp-local-host-p v))
-             ;; If we are root on the local host, we can do it directly.
-             (tramp-set-file-uid-gid localname uid gid)
-           (let ((uid (or (and (natnump uid) uid)
-                          (tramp-get-remote-uid v 'integer)))
-                 (gid (or (and (natnump gid) gid)
-                          (tramp-get-remote-gid v 'integer))))
-             (tramp-send-command
-              v (format
-                 "chown %d:%d %s" uid gid
-                 (tramp-shell-quote-argument localname))))))
-
-      ;; We handle also the local part, because there doesn't exist
-      ;; `set-file-uid-gid'.  On W32 "chown" does not work.
-      (unless (memq system-type '(ms-dos windows-nt))
-       (let ((uid (or (and (natnump uid) uid) (tramp-get-local-uid 'integer)))
-             (gid (or (and (natnump gid) gid) (tramp-get-local-gid 'integer))))
-         (tramp-call-process
-          nil "chown" nil nil nil
-          (format "%d:%d" uid gid) (shell-quote-argument filename)))))))
+    (with-parsed-tramp-file-name filename nil
+      (if (and (zerop (user-uid)) (tramp-local-host-p v))
+         ;; If we are root on the local host, we can do it directly.
+         (tramp-set-file-uid-gid localname uid gid)
+       (let ((uid (or (and (natnump uid) uid)
+                      (tramp-get-remote-uid v 'integer)))
+             (gid (or (and (natnump gid) gid)
+                      (tramp-get-remote-gid v 'integer))))
+         (tramp-send-command
+          v (format
+             "chown %d:%d %s" uid gid
+             (tramp-shell-quote-argument localname))))))))
 
 (defun tramp-remote-selinux-p (vec)
   "Check, whether SELINUX is enabled on the remote host."
@@ -1683,9 +1636,9 @@ be non-negative integers."
                   (tramp-compat-time-equal-p
                    (tramp-compat-file-attribute-modification-time fa2)
                    tramp-time-dont-know)))
-                (> 0 (tramp-time-diff
-                      (tramp-compat-file-attribute-modification-time fa2)
-                      (tramp-compat-file-attribute-modification-time fa1)))
+                (time-less-p
+                 (tramp-compat-file-attribute-modification-time fa2)
+                 (tramp-compat-file-attribute-modification-time fa1))
               ;; If one of them is the dont-know value, then we can
               ;; still try to run a shell command on the remote host.
               ;; However, this only works if both files are Tramp
@@ -1979,7 +1932,7 @@ tramp-sh-handle-file-name-all-completions: internal error 
accessing `%s': `%s'"
              (setq newname
                    (expand-file-name
                     (file-name-nondirectory dirname) newname)))
-           (when (not (file-directory-p (file-name-directory newname)))
+           (unless (file-directory-p (file-name-directory newname))
                (make-directory (file-name-directory newname) parents))
            (tramp-do-copy-or-rename-file-out-of-band
             'copy dirname newname keep-date))
@@ -2009,7 +1962,7 @@ tramp-sh-handle-file-name-all-completions: internal error 
accessing `%s': `%s'"
        'rename filename newname ok-if-already-exists
        'keep-time 'preserve-uid-gid)
     (tramp-run-real-handler
-     'rename-file (list filename newname ok-if-already-exists))))
+     #'rename-file (list filename newname ok-if-already-exists))))
 
 (defun tramp-do-copy-or-rename-file
   (op filename newname &optional ok-if-already-exists keep-date
@@ -2044,7 +1997,7 @@ file names."
                   (file-attributes (file-truename filename))))
          ;; `file-extended-attributes' exists since Emacs 24.4.
          (attributes (and preserve-extended-attributes
-                          (apply 'file-extended-attributes (list filename)))))
+                          (apply #'file-extended-attributes (list filename)))))
 
       (with-parsed-tramp-file-name (if t1 filename newname) nil
        (when (and (not ok-if-already-exists) (file-exists-p newname))
@@ -2114,9 +2067,10 @@ file names."
 
          ;; Handle `preserve-extended-attributes'.  We ignore possible
          ;; errors, because ACL strings could be incompatible.
+         ;; `set-file-extended-attributes' exists since Emacs 24.4.
          (when attributes
            (ignore-errors
-             (apply 'set-file-extended-attributes (list newname attributes))))
+             (apply #'set-file-extended-attributes (list newname attributes))))
 
          ;; In case of `rename', we must flush the cache of the source file.
          (when (and t1 (eq op 'rename))
@@ -2231,8 +2185,7 @@ the uid and gid from FILENAME."
                   (or (eq op 'copy)
                       (zerop
                        (logand
-                        (file-modes (file-name-directory localname1))
-                        (string-to-number "1000" 8))))
+                        (file-modes (file-name-directory localname1)) #o1000)))
                   (file-writable-p (file-name-directory localname2))
                   (or (file-directory-p localname2)
                       (file-writable-p localname2))))
@@ -2241,7 +2194,8 @@ the uid and gid from FILENAME."
                 localname1 localname2 ok-if-already-exists
                 keep-date preserve-uid-gid)
              (tramp-run-real-handler
-              'rename-file (list localname1 localname2 ok-if-already-exists))))
+              #'rename-file
+              (list localname1 localname2 ok-if-already-exists))))
 
           ;; We can do it directly with `tramp-send-command'
           ((and (file-readable-p (concat prefix localname1))
@@ -2276,8 +2230,7 @@ the uid and gid from FILENAME."
                      ;; We must change the ownership as remote user.
                      ;; Since this does not work reliable, we also
                      ;; give read permissions.
-                     (set-file-modes
-                      (concat prefix tmpfile) (string-to-number "0777" 8))
+                     (set-file-modes (concat prefix tmpfile) #o0777)
                      (tramp-set-file-uid-gid
                       (concat prefix tmpfile)
                       (tramp-get-local-uid 'integer)
@@ -2287,11 +2240,11 @@ the uid and gid from FILENAME."
                          (copy-file
                           localname1 tmpfile t keep-date preserve-uid-gid)
                        (tramp-run-real-handler
-                        'rename-file (list localname1 tmpfile t)))
+                        #'rename-file (list localname1 tmpfile t)))
                      ;; We must change the ownership as local user.
                      ;; Since this does not work reliable, we also
                      ;; give read permissions.
-                     (set-file-modes tmpfile (string-to-number "0777" 8))
+                     (set-file-modes tmpfile #o0777)
                      (tramp-set-file-uid-gid
                       tmpfile
                       (tramp-get-remote-uid v 'integer)
@@ -2309,7 +2262,7 @@ the uid and gid from FILENAME."
                       (tramp-get-buffer v)))
                     (t1
                      (tramp-run-real-handler
-                      'rename-file
+                      #'rename-file
                       (list tmpfile localname2 ok-if-already-exists)))))
 
                ;; Save exit.
@@ -2358,8 +2311,8 @@ The method used must be an out-of-band method."
        (setq source (funcall
                      (if (and (file-directory-p filename)
                               (not (file-exists-p newname)))
-                         'file-name-as-directory
-                       'identity)
+                         #'file-name-as-directory
+                       #'identity)
                      (if t1
                          (tramp-make-copy-program-file-name v)
                        (tramp-unquote-shell-quote-argument filename)))
@@ -2413,7 +2366,7 @@ The method used must be an out-of-band method."
               (mapcar
                (lambda (x)
                  (setq x (mapcar (lambda (y) (format-spec y spec)) x))
-                 (unless (member "" x) (mapconcat 'identity x " ")))
+                 (unless (member "" x) (mapconcat #'identity x " ")))
                (tramp-get-method-parameter v 'tramp-copy-env)))
 
              remote-copy-program
@@ -2443,7 +2396,7 @@ The method used must be an out-of-band method."
             "Cannot find remote listener: %s" remote-copy-program))
          (setq remote-copy-program
                (mapconcat
-                'identity
+                #'identity
                 (append
                  (list remote-copy-program) remote-copy-args
                  (list (if t1 (concat "<" source) (concat ">" target)) "&"))
@@ -2489,7 +2442,7 @@ The method used must be an out-of-band method."
                ;; copying of large files can last longer than 60 secs.
                (let* ((command
                        (mapconcat
-                        'identity (append (list copy-program) copy-args)
+                        #'identity (append (list copy-program) copy-args)
                         " "))
                       (p (let ((default-directory
                                  (tramp-compat-temporary-file-directory)))
@@ -2499,7 +2452,7 @@ The method used must be an out-of-band method."
                             command))))
                  (tramp-message orig-vec 6 "%s" command)
                  (process-put p 'vector orig-vec)
-                 (process-put p 'adjust-window-size-function 'ignore)
+                 (process-put p 'adjust-window-size-function #'ignore)
                  (set-process-query-on-exit-flag p nil)
 
                  ;; We must adapt `tramp-local-end-of-line' for
@@ -2623,6 +2576,9 @@ The method used must be an out-of-band method."
   "Like `insert-directory' for Tramp files."
   (setq filename (expand-file-name filename))
   (unless switches (setq switches ""))
+  ;; Check, whether directory is accessible.
+  (unless wildcard
+    (access-file filename "Reading directory"))
   (with-parsed-tramp-file-name filename nil
     (if (and (featurep 'ls-lisp)
             (not (symbol-value 'ls-lisp-use-insert-directory-program)))
@@ -2639,12 +2595,12 @@ The method used must be an out-of-band method."
        (setq switches (delete "--dired" switches)))
       (when wildcard
         (setq wildcard (tramp-run-real-handler
-                       'file-name-nondirectory (list localname)))
+                       #'file-name-nondirectory (list localname)))
         (setq localname (tramp-run-real-handler
-                        'file-name-directory (list localname))))
+                        #'file-name-directory (list localname))))
       (unless (or full-directory-p (member "-d" switches))
         (setq switches (append switches '("-d"))))
-      (setq switches (mapconcat 'tramp-shell-quote-argument switches " "))
+      (setq switches (mapconcat #'tramp-shell-quote-argument switches " "))
       (when wildcard
        (setq switches (concat switches " " wildcard)))
       (tramp-message
@@ -2666,10 +2622,10 @@ The method used must be an out-of-band method."
         v
         (format "cd %s" (tramp-shell-quote-argument
                          (tramp-run-real-handler
-                          'file-name-directory (list localname))))
+                          #'file-name-directory (list localname))))
         "Couldn't `cd %s'"
         (tramp-shell-quote-argument
-         (tramp-run-real-handler 'file-name-directory (list localname))))
+         (tramp-run-real-handler #'file-name-directory (list localname))))
        (tramp-send-command
         v
         (format "%s %s %s 2>/dev/null"
@@ -2678,11 +2634,11 @@ The method used must be an out-of-band method."
                 (if (or wildcard
                         (zerop (length
                                 (tramp-run-real-handler
-                                 'file-name-nondirectory (list localname)))))
+                                 #'file-name-nondirectory (list localname)))))
                     ""
                   (tramp-shell-quote-argument
                    (tramp-run-real-handler
-                    'file-name-nondirectory (list localname)))))))
+                    #'file-name-nondirectory (list localname)))))))
 
       (save-restriction
        (let ((beg (point)))
@@ -2761,15 +2717,17 @@ If the localname part of the given file name starts 
with \"/../\" then
 the result will be a local, non-Tramp, file name."
   ;; If DIR is not given, use `default-directory' or "/".
   (setq dir (or dir default-directory "/"))
+  ;; Handle empty NAME.
+  (when (zerop (length name)) (setq name "."))
   ;; Unless NAME is absolute, concat DIR and NAME.
   (unless (file-name-absolute-p name)
     (setq name (concat (file-name-as-directory dir) name)))
   ;; If connection is not established yet, run the real handler.
   (if (not (tramp-connectable-p name))
-      (tramp-run-real-handler 'expand-file-name (list name nil))
+      (tramp-run-real-handler #'expand-file-name (list name nil))
     ;; Dissect NAME.
     (with-parsed-tramp-file-name name nil
-      (unless (tramp-run-real-handler 'file-name-absolute-p (list localname))
+      (unless (tramp-run-real-handler #'file-name-absolute-p (list localname))
        (setq localname (concat "~/" localname)))
       ;; Tilde expansion if necessary.  This needs a shell which
       ;; groks tilde expansion!  The function `tramp-find-shell' is
@@ -2807,155 +2765,210 @@ the result will be a local, non-Tramp, file name."
        (tramp-make-tramp-file-name
         v (tramp-drop-volume-letter
            (tramp-run-real-handler
-            'expand-file-name (list localname))))))))
+            #'expand-file-name (list localname))))))))
 
 ;;; Remote commands:
 
-(defun tramp-process-sentinel (proc event)
-  "Flush file caches."
-  (unless (process-live-p proc)
-    (let ((vec (process-get proc 'vector)))
-      (when vec
-       (tramp-message vec 5 "Sentinel called: `%S' `%s'" proc event)
-        (tramp-flush-connection-properties proc)
-        (tramp-flush-directory-properties vec "")))))
-
 ;; We use BUFFER also as connection buffer during setup. Because of
 ;; this, its original contents must be saved, and restored once
 ;; connection has been setup.
-(defun tramp-sh-handle-start-file-process (name buffer program &rest args)
-  "Like `start-file-process' for Tramp files."
-  (with-parsed-tramp-file-name (expand-file-name default-directory) nil
-    (let* ((buffer
-           (if buffer
-               (get-buffer-create buffer)
-             ;; BUFFER can be nil.  We use a temporary buffer.
-             (generate-new-buffer tramp-temp-buffer-name)))
-          ;; When PROGRAM matches "*sh", and the first arg is "-c",
-          ;; it might be that the arguments exceed the command line
-          ;; length.  Therefore, we modify the command.
-          (heredoc (and (stringp program)
-                        (string-match-p "sh$" program)
-                        (string-equal "-c" (car args))
-                        (= (length args) 2)))
-          ;; When PROGRAM is nil, we just provide a tty.
-          (args (if (not heredoc) args
-                  (let ((i 250))
-                    (while (and (< i (length (cadr args)))
-                                (string-match " " (cadr args) i))
-                      (setcdr
-                       args
-                       (list (replace-match " \\\\\n" nil nil (cadr args))))
-                      (setq i (+ i 250))))
-                  (cdr args)))
-          ;; Use a human-friendly prompt, for example for `shell'.
-          ;; We discard hops, if existing, that's why we cannot use
-          ;; `file-remote-p'.
-          (prompt (format "PS1=%s %s"
-                          (tramp-make-tramp-file-name v nil 'nohop)
-                          tramp-initial-end-of-output))
-          ;; We use as environment the difference to toplevel
-          ;; `process-environment'.
-          env uenv
-          (env (dolist (elt (cons prompt process-environment) env)
-                  (or (member elt (default-toplevel-value 
'process-environment))
-                      (if (string-match-p "=" elt)
-                          (setq env (append env `(,elt)))
-                        (if (tramp-get-env-with-u-option v)
-                            (setq env (append `("-u" ,elt) env))
-                          (setq uenv (cons elt uenv)))))))
-          (command
-           (when (stringp program)
-             (format "cd %s && %s exec %s env %s %s"
-                     (tramp-shell-quote-argument localname)
-                      (if uenv
-                          (format
-                           "unset %s &&"
-                           (mapconcat 'tramp-shell-quote-argument uenv " "))
-                        "")
-                     (if heredoc (format "<<'%s'" tramp-end-of-heredoc) "")
-                     (mapconcat 'tramp-shell-quote-argument env " ")
-                     (if heredoc
-                         (format "%s\n(\n%s\n) </dev/tty\n%s"
-                                 program (car args) tramp-end-of-heredoc)
-                       (mapconcat 'tramp-shell-quote-argument
-                                  (cons program args) " ")))))
-          (tramp-process-connection-type
-           (or (null program) tramp-process-connection-type))
-          (bmp (and (buffer-live-p buffer) (buffer-modified-p buffer)))
-          (name1 name)
-          (i 0)
-          ;; We do not want to raise an error when
-          ;; `start-file-process' has been started several times in
-          ;; `eshell' and friends.
-          tramp-current-connection
-          ;; We do not want to run timers.
-          timer-list timer-idle-list
-          p)
-
-      (while (get-process name1)
-       ;; NAME must be unique as process name.
-       (setq i (1+ i)
-             name1 (format "%s<%d>" name i)))
-      (setq name name1)
-      ;; Set the new process properties.
-      (tramp-set-connection-property v "process-name" name)
-      (tramp-set-connection-property v "process-buffer" buffer)
-
-      (with-current-buffer (tramp-get-connection-buffer v)
-       (unwind-protect
-           ;; We catch this event.  Otherwise, `start-process' could
-           ;; be called on the local host.
-           (save-excursion
-             (save-restriction
-               ;; Activate narrowing in order to save BUFFER
-               ;; contents.  Clear also the modification time;
-               ;; otherwise we might be interrupted by
-               ;; `verify-visited-file-modtime'.
-               (let ((buffer-undo-list t)
-                     (buffer-read-only nil)
-                     (mark (point-max)))
-                 (clear-visited-file-modtime)
-                 (narrow-to-region (point-max) (point-max))
-                 ;; We call `tramp-maybe-open-connection', in order
-                 ;; to cleanup the prompt afterwards.
-                 (catch 'suppress
-                   (tramp-maybe-open-connection v)
-                   (setq p (tramp-get-connection-process v))
-                   ;; Set the pid of the remote shell.  This is
-                   ;; needed when sending signals remotely.
-                   (let ((pid (tramp-send-command-and-read v "echo $$")))
-                     (process-put p 'remote-pid pid)
-                     (tramp-set-connection-property p "remote-pid" pid))
-                   (widen)
-                   (delete-region mark (point-max))
-                   (narrow-to-region (point-max) (point-max))
-                   ;; Now do it.
-                   (if command
-                       ;; Send the command.
-                       (tramp-send-command v command nil t) ; nooutput
-                     ;; Check, whether a pty is associated.
-                     (unless (process-get p 'remote-tty)
-                       (tramp-error
-                        v 'file-error
-                        "pty association is not supported for `%s'" name))))
-                 ;; Set query flag and process marker for this
-                 ;; process.  We ignore errors, because the process
-                 ;; could have finished already.
-                 (ignore-errors
-                   (set-process-query-on-exit-flag p t)
-                   (set-marker (process-mark p) (point)))
-                 ;; Return process.
-                 p)))
+(defun tramp-sh-handle-make-process (&rest args)
+  "Like `make-process' for Tramp files."
+  (when args
+    (with-parsed-tramp-file-name (expand-file-name default-directory) nil
+      (let ((name (plist-get args :name))
+           (buffer (plist-get args :buffer))
+           (command (plist-get args :command))
+           (coding (plist-get args :coding))
+           (noquery (plist-get args :noquery))
+           (connection-type (plist-get args :connection-type))
+           (filter (plist-get args :filter))
+           (sentinel (plist-get args :sentinel))
+           (stderr (plist-get args :stderr)))
+       (unless (stringp name)
+         (signal 'wrong-type-argument (list #'stringp name)))
+       (unless (or (null buffer) (bufferp buffer) (stringp buffer))
+         (signal 'wrong-type-argument (list #'stringp buffer)))
+       (unless (consp command)
+         (signal 'wrong-type-argument (list #'consp command)))
+       (unless (or (null coding)
+                   (and (symbolp coding) (memq coding coding-system-list))
+                   (and (consp coding)
+                        (memq (car coding) coding-system-list)
+                        (memq (cdr coding) coding-system-list)))
+         (signal 'wrong-type-argument (list #'symbolp coding)))
+       (unless (or (null connection-type) (memq connection-type '(pipe pty)))
+         (signal 'wrong-type-argument (list #'symbolp connection-type)))
+       (unless (or (null filter) (functionp filter))
+         (signal 'wrong-type-argument (list #'functionp filter)))
+       (unless (or (null sentinel) (functionp sentinel))
+         (signal 'wrong-type-argument (list #'functionp sentinel)))
+       (unless (or (null stderr) (bufferp stderr) (stringp stderr))
+         (signal 'wrong-type-argument (list #'stringp stderr)))
+
+       (let* ((buffer
+               (if buffer
+                   (get-buffer-create buffer)
+                 ;; BUFFER can be nil.  We use a temporary buffer.
+                 (generate-new-buffer tramp-temp-buffer-name)))
+              (stderr (and stderr (get-buffer-create stderr)))
+              (tmpstderr (and stderr (tramp-make-tramp-temp-file v)))
+              (program (car command))
+              (args (cdr command))
+              ;; When PROGRAM matches "*sh", and the first arg is
+              ;; "-c", it might be that the arguments exceed the
+              ;; command line length.  Therefore, we modify the
+              ;; command.
+              (heredoc (and (stringp program)
+                            (string-match-p "sh$" program)
+                            (string-equal "-c" (car args))
+                            (= (length args) 2)))
+              ;; When PROGRAM is nil, we just provide a tty.
+              (args (if (not heredoc) args
+                      (let ((i 250))
+                        (while (and (< i (length (cadr args)))
+                                    (string-match " " (cadr args) i))
+                          (setcdr
+                           args
+                           (list
+                            (replace-match " \\\\\n" nil nil (cadr args))))
+                          (setq i (+ i 250))))
+                      (cdr args)))
+              ;; Use a human-friendly prompt, for example for
+              ;; `shell'.  We discard hops, if existing, that's why
+              ;; we cannot use `file-remote-p'.
+              (prompt (format "PS1=%s %s"
+                              (tramp-make-tramp-file-name v nil 'nohop)
+                              tramp-initial-end-of-output))
+              ;; We use as environment the difference to toplevel
+              ;; `process-environment'.
+              env uenv
+              (env (dolist (elt (cons prompt process-environment) env)
+                      (or (member
+                          elt (default-toplevel-value 'process-environment))
+                         (if (string-match-p "=" elt)
+                              (setq env (append env `(,elt)))
+                           (if (tramp-get-env-with-u-option v)
+                               (setq env (append `("-u" ,elt) env))
+                              (setq uenv (cons elt uenv)))))))
+              (command
+               (when (stringp program)
+                 (format "cd %s && %s exec %s %s env %s %s"
+                         (tramp-shell-quote-argument localname)
+                         (if uenv
+                              (format
+                               "unset %s &&"
+                               (mapconcat
+                               #'tramp-shell-quote-argument uenv " "))
+                           "")
+                         (if heredoc (format "<<'%s'" tramp-end-of-heredoc) "")
+                         (if tmpstderr (format "2>'%s'" tmpstderr) "")
+                         (mapconcat #'tramp-shell-quote-argument env " ")
+                         (if heredoc
+                             (format "%s\n(\n%s\n) </dev/tty\n%s"
+                                     program (car args) tramp-end-of-heredoc)
+                           (mapconcat #'tramp-shell-quote-argument
+                                      (cons program args) " ")))))
+              (tramp-process-connection-type
+               (or (null program) tramp-process-connection-type))
+              (bmp (and (buffer-live-p buffer) (buffer-modified-p buffer)))
+              (name1 name)
+              (i 0)
+              ;; We do not want to raise an error when `make-process'
+              ;; has been started several times in `eshell' and
+              ;; friends.
+              tramp-current-connection
+              ;; We do not want to run timers.
+              timer-list timer-idle-list
+              p)
+
+         (while (get-process name1)
+           ;; NAME must be unique as process name.
+           (setq i (1+ i)
+                 name1 (format "%s<%d>" name i)))
+         (setq name name1)
+         ;; Set the new process properties.
+         (tramp-set-connection-property v "process-name" name)
+         (tramp-set-connection-property v "process-buffer" buffer)
 
-         ;; Save exit.
-         (if (string-match-p tramp-temp-buffer-name (buffer-name))
-             (ignore-errors
-               (set-process-buffer p nil)
-               (kill-buffer (current-buffer)))
-           (set-buffer-modified-p bmp))
-         (tramp-flush-connection-property v "process-name")
-         (tramp-flush-connection-property v "process-buffer"))))))
+         (with-current-buffer (tramp-get-connection-buffer v)
+           (unwind-protect
+               ;; We catch this event.  Otherwise, `make-process' could
+               ;; be called on the local host.
+               (save-excursion
+                 (save-restriction
+                   ;; Activate narrowing in order to save BUFFER
+                   ;; contents.  Clear also the modification time;
+                   ;; otherwise we might be interrupted by
+                   ;; `verify-visited-file-modtime'.
+                   (let ((buffer-undo-list t)
+                         (inhibit-read-only t)
+                         (mark (point-max)))
+                     (clear-visited-file-modtime)
+                     (narrow-to-region (point-max) (point-max))
+                     ;; We call `tramp-maybe-open-connection', in
+                     ;; order to cleanup the prompt afterwards.
+                     (catch 'suppress
+                       (tramp-maybe-open-connection v)
+                       (setq p (tramp-get-connection-process v))
+                       ;; Set the pid of the remote shell.  This is
+                       ;; needed when sending signals remotely.
+                       (let ((pid (tramp-send-command-and-read v "echo $$")))
+                         (process-put p 'remote-pid pid)
+                         (tramp-set-connection-property p "remote-pid" pid))
+                       ;; `tramp-maybe-open-connection' and
+                       ;; `tramp-send-command-and-read' could have
+                       ;; trashed the connection buffer.  Remove this.
+                       (widen)
+                       (delete-region mark (point-max))
+                       (narrow-to-region (point-max) (point-max))
+                       ;; Now do it.
+                       (if command
+                           ;; Send the command.
+                           (tramp-send-command v command nil t) ; nooutput
+                         ;; Check, whether a pty is associated.
+                         (unless (process-get p 'remote-tty)
+                           (tramp-error
+                            v 'file-error
+                            "pty association is not supported for `%s'"
+                            name))))
+                     ;; Set sentinel and filter.
+                     (when sentinel
+                       (set-process-sentinel p sentinel))
+                     (when filter
+                       (set-process-filter p filter))
+                     ;; Set query flag and process marker for this
+                     ;; process.  We ignore errors, because the
+                     ;; process could have finished already.
+                     (ignore-errors
+                       (set-process-query-on-exit-flag p (null noquery))
+                       (set-marker (process-mark p) (point)))
+                     ;; Provide error buffer.  This shows only
+                     ;; initial error messages; messages arriving
+                     ;; later on shall be inserted by `auto-revert'.
+                     ;; The temporary file will still be existing.
+                     ;; TODO: Write a sentinel, which deletes the
+                     ;; temporary file.
+                     (when tmpstderr
+                       ;; We must flush them here already; otherwise
+                       ;; `insert-file-contents' will fail.
+                       (tramp-flush-connection-property v "process-name")
+                       (tramp-flush-connection-property v "process-buffer")
+                       (with-current-buffer stderr
+                         (insert-file-contents
+                          (tramp-make-tramp-file-name v tmpstderr) 'visit)
+                         (auto-revert-mode)))
+                     ;; Return process.
+                     p)))
+
+             ;; Save exit.
+             (if (string-match-p tramp-temp-buffer-name (buffer-name))
+                 (ignore-errors
+                   (set-process-buffer p nil)
+                   (kill-buffer (current-buffer)))
+               (set-buffer-modified-p bmp))
+             (tramp-flush-connection-property v "process-name")
+             (tramp-flush-connection-property v "process-buffer"))))))))
 
 (defun tramp-sh-handle-process-file
   (program &optional infile destination display &rest args)
@@ -2967,7 +2980,7 @@ the result will be a local, non-Tramp, file name."
   (with-parsed-tramp-file-name default-directory nil
     (let (command env uenv input tmpinput stderr tmpstderr outbuf ret)
       ;; Compute command.
-      (setq command (mapconcat 'tramp-shell-quote-argument
+      (setq command (mapconcat #'tramp-shell-quote-argument
                               (cons program args) " "))
       ;; We use as environment the difference to toplevel 
`process-environment'.
       (dolist (elt process-environment)
@@ -2981,12 +2994,12 @@ the result will be a local, non-Tramp, file name."
        (setq command
              (format
               "env %s %s"
-              (mapconcat 'tramp-shell-quote-argument env " ") command)))
+              (mapconcat #'tramp-shell-quote-argument env " ") command)))
       (when uenv
         (setq command
               (format
                "unset %s && %s"
-               (mapconcat 'tramp-shell-quote-argument uenv " ") command)))
+               (mapconcat #'tramp-shell-quote-argument uenv " ") command)))
       ;; Determine input.
       (if (null infile)
          (setq input "/dev/null")
@@ -3198,7 +3211,8 @@ the result will be a local, non-Tramp, file name."
                      (file-writable-p localname)))))
          ;; Short track: if we are on the local host, we can run directly.
          (tramp-run-real-handler
-          'write-region (list start end localname append 'no-message lockname))
+          #'write-region
+          (list start end localname append 'no-message lockname))
 
        (let* ((modes (save-excursion (tramp-default-file-modes filename)))
               ;; We use this to save the value of
@@ -3234,7 +3248,7 @@ the result will be a local, non-Tramp, file name."
                 (tramp-find-file-name-coding-system-alist filename tmpfile)))
            (condition-case err
                (tramp-run-real-handler
-                'write-region
+                #'write-region
                 (list start end tmpfile append 'no-message lockname))
              ((error quit)
               (setq tramp-temp-buffer-file-name nil)
@@ -3250,9 +3264,7 @@ the result will be a local, non-Tramp, file name."
          ;; handles permissions.
          ;; Ensure that it is still readable.
          (when modes
-           (set-file-modes
-            tmpfile
-            (logior (or modes 0) (string-to-number "0400" 8))))
+           (set-file-modes tmpfile (logior (or modes 0) #o0400)))
 
          ;; This is a bit lengthy due to the different methods
          ;; possible for file transfer.  First, we check whether the
@@ -3450,7 +3462,7 @@ the result will be a local, non-Tramp, file name."
          ;; Here we collect only file names, which need an operation.
          (tramp-with-demoted-errors
              v "Error in 1st pass of `vc-registered': %s"
-           (tramp-run-real-handler 'vc-registered (list file)))
+           (tramp-run-real-handler #'vc-registered (list file)))
          (tramp-message v 10 "\n%s" tramp-vc-registered-file-names)
 
          ;; Send just one command, in order to fill the cache.
@@ -3473,7 +3485,7 @@ the result will be a local, non-Tramp, file name."
                    (format
                     "tramp_vc_registered_read_file_names <<'%s'\n%s\n%s\n"
                     tramp-end-of-heredoc
-                    (mapconcat 'tramp-shell-quote-argument
+                    (mapconcat #'tramp-shell-quote-argument
                                tramp-vc-registered-file-names
                                "\n")
                     tramp-end-of-heredoc))
@@ -3513,7 +3525,7 @@ the result will be a local, non-Tramp, file name."
          ;; Run.
          (tramp-with-demoted-errors
              v "Error in 2nd pass of `vc-registered': %s"
-           (tramp-run-real-handler 'vc-registered (list file))))))))
+           (tramp-run-real-handler #'vc-registered (list file))))))))
 
 ;;;###tramp-autoload
 (defun tramp-sh-file-name-handler (operation &rest args)
@@ -3526,15 +3538,16 @@ Fall back to normal file name handler if no Tramp 
handler exists."
 
 ;; This must be the last entry, because `identity' always matches.
 ;;;###tramp-autoload
-(tramp-register-foreign-file-name-handler
- 'identity 'tramp-sh-file-name-handler 'append)
+(tramp--with-startup
+ (tramp-register-foreign-file-name-handler
+  #'identity #'tramp-sh-file-name-handler 'append))
 
 (defun tramp-vc-file-name-handler (operation &rest args)
   "Invoke special file name handler, which collects files to be handled."
   (save-match-data
     (let ((filename
           (tramp-replace-environment-variables
-           (apply 'tramp-file-name-for-operation operation args)))
+           (apply #'tramp-file-name-for-operation operation args)))
          (fn (assoc operation tramp-sh-file-name-handler-alist)))
       (with-parsed-tramp-file-name filename nil
        (cond
@@ -3564,7 +3577,7 @@ Fall back to normal file name handler if no Tramp handler 
exists."
       (cond
        ;; "inotifywait".
        ((setq command (tramp-get-remote-inotifywait v))
-       (setq filter 'tramp-sh-inotifywait-process-filter
+       (setq filter #'tramp-sh-inotifywait-process-filter
              events
              (cond
               ((and (memq 'change flags) (memq 'attribute-change flags))
@@ -3584,7 +3597,7 @@ Fall back to normal file name handler if no Tramp handler 
exists."
               (split-string events "," 'omit))))
        ;; "gio monitor".
        ((setq command (tramp-get-remote-gio-monitor v))
-       (setq filter 'tramp-sh-gio-monitor-process-filter
+       (setq filter #'tramp-sh-gio-monitor-process-filter
              events
              (cond
               ((and (memq 'change flags) (memq 'attribute-change flags))
@@ -3596,7 +3609,7 @@ Fall back to normal file name handler if no Tramp handler 
exists."
              sequence `(,command "monitor" ,localname)))
        ;; "gvfs-monitor-dir".
        ((setq command (tramp-get-remote-gvfs-monitor-dir v))
-       (setq filter 'tramp-sh-gvfs-monitor-dir-process-filter
+       (setq filter #'tramp-sh-gvfs-monitor-dir-process-filter
              events
              (cond
               ((and (memq 'change flags) (memq 'attribute-change flags))
@@ -3613,7 +3626,7 @@ Fall back to normal file name handler if no Tramp handler 
exists."
           (file-remote-p file-name))))
       ;; Start process.
       (setq p (apply
-              'start-file-process
+              #'start-file-process
               (file-name-nondirectory command)
               (generate-new-buffer
                (format " *%s*" (file-name-nondirectory command)))
@@ -3623,8 +3636,8 @@ Fall back to normal file name handler if no Tramp handler 
exists."
          (tramp-error
           v 'file-notify-error
           "`%s' failed to start on remote host"
-          (mapconcat 'identity sequence " "))
-       (tramp-message v 6 "Run `%s', %S" (mapconcat 'identity sequence " ") p)
+          (mapconcat #'identity sequence " "))
+       (tramp-message v 6 "Run `%s', %S" (mapconcat #'identity sequence " ") p)
        (process-put p 'vector v)
        ;; Needed for process filter.
        (process-put p 'events events)
@@ -3633,7 +3646,7 @@ Fall back to normal file name handler if no Tramp handler 
exists."
        (set-process-filter p filter)
        ;; There might be an error if the monitor is not supported.
        ;; Give the filter a chance to read the output.
-       (tramp-accept-process-output p 1)
+       (while (tramp-accept-process-output p 0))
        (unless (process-live-p p)
          (tramp-error
           p 'file-notify-error "Monitoring not supported for `%s'" file-name))
@@ -3662,11 +3675,14 @@ Fall back to normal file name handler if no Tramp 
handler exists."
        (string-match-p "Monitoring not supported\\|No locations given" string)
       (delete-process proc))
 
+    ;; Delete empty lines.
+    (setq string (replace-regexp-in-string "\n\n" "\n" string))
+
     (while (string-match
            (eval-when-compile
              (concat "^[^:]+:"
                      "[[:space:]]\\([^:]+\\):"
-                     "[[:space:]]"  (regexp-opt tramp-gio-events t)
+                     "[[:space:]]" (regexp-opt tramp-gio-events t)
                      "\\([[:space:]]\\([^:]+\\)\\)?$"))
            string)
 
@@ -3760,7 +3776,7 @@ file-notify events."
     (tramp-message proc 6 "%S\n%s" proc string)
     (dolist (line (split-string string "[\n\r]+" 'omit))
       ;; Check, whether there is a problem.
-      (unless (string-match-p
+      (unless (string-match
               (eval-when-compile
                 (concat "^[^[:blank:]]+"
                         "[[:blank:]]+\\([^[:blank:]]+\\)+"
@@ -3796,22 +3812,26 @@ file-notify events."
        (tramp-message v 5 "file system info: %s" localname)
        (tramp-send-command
         v (format
-           "%s --block-size=1 --output=size,used,avail %s"
+           "%s %s"
            (tramp-get-remote-df v) (tramp-shell-quote-argument localname)))
        (with-current-buffer (tramp-get-connection-buffer v)
          (goto-char (point-min))
          (forward-line)
          (when (looking-at
                 (eval-when-compile
-                  (concat "[[:space:]]*\\([[:digit:]]+\\)"
+                  (concat "\\(?:^/[^[:space:]]*[[:space:]]\\)?"
+                          "[[:space:]]*\\([[:digit:]]+\\)"
                           "[[:space:]]+\\([[:digit:]]+\\)"
                           "[[:space:]]+\\([[:digit:]]+\\)")))
-           (list (string-to-number (match-string 1))
-                 ;; The second value is the used size.  We need the
-                 ;; free size.
-                 (- (string-to-number (match-string 1))
-                    (string-to-number (match-string 2)))
-                 (string-to-number (match-string 3)))))))))
+           (mapcar
+            (lambda (d)
+              (* d (tramp-get-connection-property v "df-blocksize" 0)))
+            (list (string-to-number (match-string 1))
+                  ;; The second value is the used size.  We need the
+                  ;; free size.
+                  (- (string-to-number (match-string 1))
+                     (string-to-number (match-string 2)))
+                  (string-to-number (match-string 3))))))))))
 
 ;;; Internal Functions:
 
@@ -3918,7 +3938,7 @@ This function expects to be in the right *tramp* buffer."
                           "%s\n%s"))
                 progname progname progname
                 tramp-end-of-heredoc
-                (mapconcat 'identity dirlist "\n")
+                (mapconcat #'identity dirlist "\n")
                 tramp-end-of-heredoc))
        (goto-char (point-max))
        (when (search-backward "tramp_executable " nil t)
@@ -3927,15 +3947,33 @@ This function expects to be in the right *tramp* 
buffer."
          (setq result (buffer-substring (point) (point-at-eol)))))
     result)))
 
+;; On hydra.nixos.org, the $PATH environment variable is too long to
+;; send it.  This is likely not due to PATH_MAX, but PIPE_BUF.  We
+;; check it, and use a temporary file in case of.  See Bug#33781.
 (defun tramp-set-remote-path (vec)
   "Sets the remote environment PATH to existing directories.
 I.e., for each directory in `tramp-remote-path', it is tested
 whether it exists and if so, it is added to the environment
 variable PATH."
-  (tramp-message vec 5 "Setting $PATH environment variable")
-  (tramp-send-command
-   vec (format "PATH=%s; export PATH"
-              (mapconcat 'identity (tramp-get-remote-path vec) ":"))))
+  (let ((command
+        (format "PATH=%s; export PATH"
+                (mapconcat #'identity (tramp-get-remote-path vec) ":")))
+       (pipe-buf
+        (or (with-tramp-connection-property vec "pipe-buf"
+              (tramp-send-command-and-read
+               vec "getconf PIPE_BUF / 2>/dev/null || echo nil" 'noerror))
+            4096))
+       tmpfile)
+    (tramp-message vec 5 "Setting $PATH environment variable")
+    (if (< (length command) pipe-buf)
+       (tramp-send-command vec command)
+      ;; Use a temporary file.
+      (setq tmpfile
+           (tramp-make-tramp-file-name vec (tramp-make-tramp-temp-file vec)))
+      (write-region command nil tmpfile)
+      (tramp-send-command
+       vec (format ". %s" (tramp-compat-file-local-name tmpfile)))
+      (delete-file tmpfile))))
 
 ;; ------------------------------------------------------------
 ;; -- Communication with external shell --
@@ -4112,7 +4150,7 @@ seconds.  If not, it produces an error message with the 
given ERROR-ARGS."
          "\\(%s\\|%s\\)\\'" shell-prompt-pattern tramp-shell-prompt-pattern))
       (error
        (delete-process proc)
-       (apply 'tramp-error-with-buffer
+       (apply #'tramp-error-with-buffer
              (tramp-get-connection-buffer vec) vec 'file-error error-args)))))
 
 (defun tramp-open-connection-setup-interactive-shell (proc vec)
@@ -4262,7 +4300,7 @@ process to set up.  VEC specifies the connection."
                     (append `(,(tramp-get-remote-locale vec))
                             (copy-sequence tramp-remote-process-environment))))
        (setq item (split-string item "=" 'omit))
-       (setcdr item (mapconcat 'identity (cdr item) "="))
+       (setcdr item (mapconcat #'identity (cdr item) "="))
        (if (and (stringp (cdr item)) (not (string-equal (cdr item) "")))
            (push (format "%s %s" (car item) (cdr item)) vars)
          (push (car item) unset)))
@@ -4272,12 +4310,12 @@ process to set up.  VEC specifies the connection."
         (format
          "while read var val; do export $var=\"$val\"; done <<'%s'\n%s\n%s"
          tramp-end-of-heredoc
-         (mapconcat 'identity vars "\n")
+         (mapconcat #'identity vars "\n")
          tramp-end-of-heredoc)
         t))
       (when unset
        (tramp-send-command
-        vec (format "unset %s" (mapconcat 'identity unset " ")) t)))))
+        vec (format "unset %s" (mapconcat #'identity unset " ")) t)))))
 
 ;; Old text from documentation of tramp-methods:
 ;; Using a uuencode/uudecode inline method is discouraged, please use one
@@ -4303,7 +4341,7 @@ Each item is a list that looks like this:
 
 \(FORMAT ENCODING DECODING)
 
-FORMAT is  symbol describing the encoding/decoding format.  It can be
+FORMAT is a symbol describing the encoding/decoding format.  It can be
 `b64' for base64 encoding, `uu' for uu encoding, or `pack' for simple packing.
 
 ENCODING and DECODING can be strings, giving commands, or symbols,
@@ -4419,7 +4457,7 @@ Goes through the list `tramp-local-coding-commands' and
                  ;; actually check the output it gives.  And also, when
                  ;; redirecting "mimencode" output to /dev/null, then as root
                  ;; it might change the permissions of /dev/null!
-                 (when (not (stringp rem-enc))
+                 (unless (stringp rem-enc)
                    (let ((name (symbol-name rem-enc)))
                      (while (string-match "-" name)
                        (setq name (replace-match "_" nil t name)))
@@ -4432,7 +4470,7 @@ Goes through the list `tramp-local-coding-commands' and
                           vec (format "%s </dev/null" rem-enc) t)
                    (throw 'wont-work-remote nil))
 
-                 (when (not (stringp rem-dec))
+                 (unless (stringp rem-dec)
                    (let ((name (symbol-name rem-dec))
                          (value (symbol-value rem-dec))
                          tmpfile)
@@ -4460,7 +4498,7 @@ Goes through the list `tramp-local-coding-commands' and
                           t)
                    (throw 'wont-work-remote nil))
 
-                 (with-current-buffer (tramp-get-buffer vec)
+                 (with-current-buffer (tramp-get-connection-buffer vec)
                    (goto-char (point-min))
                    (unless (looking-at-p (regexp-quote magic))
                      (throw 'wont-work-remote nil)))
@@ -4539,9 +4577,9 @@ Goes through the list `tramp-inline-compress-commands'."
                 ;; the pipe symbol be quoted if they use forward
                 ;; slashes as directory separators.
                 (mapconcat
-                 'shell-quote-argument (split-string compress) " ")
+                 #'shell-quote-argument (split-string compress) " ")
                 (mapconcat
-                 'shell-quote-argument (split-string decompress) " "))
+                 #'shell-quote-argument (split-string decompress) " "))
                nil nil))
            (throw 'next nil))
          (tramp-message
@@ -4573,7 +4611,8 @@ Goes through the list `tramp-inline-compress-commands'."
 
 (defun tramp-compute-multi-hops (vec)
   "Expands VEC according to `tramp-default-proxies-alist'."
-  (let ((target-alist `(,vec))
+  (let ((saved-tdpa tramp-default-proxies-alist)
+       (target-alist `(,vec))
        (hops (or (tramp-file-name-hop vec) ""))
        (item vec)
        choices proxy)
@@ -4639,9 +4678,9 @@ Goes through the list `tramp-inline-compress-commands'."
       (while (setq item (pop choices))
        (when (or (not (tramp-get-method-parameter item 'tramp-login-program))
                  (tramp-get-method-parameter item 'tramp-copy-program))
-         (tramp-error
-          vec 'file-error
-          "Method `%s' is not supported for multi-hops."
+         (setq tramp-default-proxies-alist saved-tdpa)
+         (tramp-user-error
+          vec "Method `%s' is not supported for multi-hops."
           (tramp-file-name-method item)))))
 
     ;; Some methods ("su", "sg", "sudo", "doas", "ksu") do not use the
@@ -4659,8 +4698,9 @@ Goes through the list `tramp-inline-compress-commands'."
                '("%h") (tramp-get-method-parameter item 'tramp-login-args))
               ;; The host name must match previous hop.
               (string-match-p previous-host host))
+           (setq tramp-default-proxies-alist saved-tdpa)
            (tramp-user-error
-            item "Host name `%s' does not match `%s'" host previous-host))
+            vec "Host name `%s' does not match `%s'" host previous-host))
          (setq previous-host (concat "^" (regexp-quote host) "$")))))
 
     ;; Result.
@@ -4683,7 +4723,7 @@ Goes through the list `tramp-inline-compress-commands'."
        (ignore-errors
          (when (executable-find "ssh")
            (with-tramp-progress-reporter
-               vec 4  "Computing ControlMaster options"
+               vec 4 "Computing ControlMaster options"
              (with-temp-buffer
                (tramp-call-process vec "ssh" nil t nil "-o" "ControlMaster")
                (goto-char (point-min))
@@ -4740,9 +4780,12 @@ connection if a previous connection has died for some 
reason."
     (unless (or (process-live-p p)
                (not (tramp-file-name-equal-p
                      vec (car tramp-current-connection)))
-               (> (tramp-time-diff
-                   (current-time) (cdr tramp-current-connection))
-                  (or tramp-connection-min-time-diff 0)))
+               (time-less-p
+                ;; `current-time' can be removed once we get rid of Emacs 24.
+                (time-since (or (cdr tramp-current-connection) (current-time)))
+                ;; `seconds-to-time' can be removed once we get rid
+                ;; of Emacs 24.
+                (seconds-to-time (or tramp-connection-min-time-diff 0))))
       (throw 'suppress 'suppress))
 
     ;; If too much time has passed since last command was sent, look
@@ -4753,11 +4796,11 @@ connection if a previous connection has died for some 
reason."
     ;; try to send a command from time to time, then look again
     ;; whether the process is really alive.
     (condition-case nil
-       (when (and (> (tramp-time-diff
-                      (current-time)
-                      (tramp-get-connection-property
-                       p "last-cmd-time" '(0 0 0)))
-                     60)
+       ;; `seconds-to-time' can be removed once we get rid of Emacs 24.
+       (when (and (time-less-p (seconds-to-time 60)
+                               (time-since
+                                (tramp-get-connection-property
+                                 p "last-cmd-time" (seconds-to-time 0))))
                   (process-live-p p))
          (tramp-send-command vec "echo are you awake" t t)
          (unless (and (process-live-p p)
@@ -4824,7 +4867,7 @@ connection if a previous connection has died for some 
reason."
                     (p (let ((default-directory
                                (tramp-compat-temporary-file-directory)))
                          (apply
-                          'start-process
+                          #'start-process
                           (tramp-get-connection-name vec)
                           (tramp-get-connection-buffer vec)
                           (if tramp-encoding-command-interactive
@@ -4833,14 +4876,14 @@ connection if a previous connection has died for some 
reason."
                             (list tramp-encoding-shell))))))
 
                ;; Set sentinel and query flag.  Initialize variables.
-               (set-process-sentinel p 'tramp-process-sentinel)
+               (set-process-sentinel p #'tramp-process-sentinel)
                (process-put p 'vector vec)
-               (process-put p 'adjust-window-size-function 'ignore)
+               (process-put p 'adjust-window-size-function #'ignore)
                (set-process-query-on-exit-flag p nil)
                (setq tramp-current-connection (cons vec (current-time)))
 
                (tramp-message
-                vec 6 "%s" (mapconcat 'identity (process-command p) " "))
+                vec 6 "%s" (mapconcat #'identity (process-command p) " "))
 
                ;; Check whether process is alive.
                (tramp-barf-if-no-shell-prompt
@@ -4917,7 +4960,7 @@ connection if a previous connection has died for some 
reason."
                       (mapcar
                        (lambda (x)
                          (setq x (mapcar (lambda (y) (format-spec y spec)) x))
-                         (unless (member "" x) (mapconcat 'identity x " ")))
+                         (unless (member "" x) (mapconcat #'identity x " ")))
                        login-env))
                      (while login-env
                        (setq command
@@ -4946,7 +4989,7 @@ connection if a previous connection has died for some 
reason."
                      (mapconcat
                       (lambda (x)
                         (setq x (mapcar (lambda (y) (format-spec y spec)) x))
-                        (unless (member "" x) (mapconcat 'identity x " ")))
+                        (unless (member "" x) (mapconcat #'identity x " ")))
                       login-args " ")
                      ;; Local shell could be a Windows COMSPEC.  It
                      ;; doesn't know the ";" syntax, but we must exit
@@ -5038,7 +5081,7 @@ function waits for output unless NOOUTPUT is set."
           (regexp1 (format "\\(^\\|\000\\)%s" regexp))
           (found (tramp-wait-for-regexp proc timeout regexp1)))
       (if found
-         (let (buffer-read-only)
+         (let ((inhibit-read-only t))
            ;; A simple-minded busybox has sent " ^H" sequences.
            ;; Delete them.
            (goto-char (point-min))
@@ -5085,7 +5128,7 @@ DONT-SUPPRESS-ERR is non-nil, stderr won't be sent to 
/dev/null."
     (skip-chars-forward "^ ")
     (prog1
        (zerop (read (current-buffer)))
-      (let (buffer-read-only)
+      (let ((inhibit-read-only t))
        (delete-region (match-beginning 0) (point-max))))))
 
 (defun tramp-barf-unless-okay (vec command fmt &rest args)
@@ -5093,7 +5136,7 @@ DONT-SUPPRESS-ERR is non-nil, stderr won't be sent to 
/dev/null."
 Similar to `tramp-send-command-and-check' but accepts two more arguments
 FMT and ARGS which are passed to `error'."
   (or (tramp-send-command-and-check vec command)
-      (apply 'tramp-error vec 'file-error fmt args)))
+      (apply #'tramp-error vec 'file-error fmt args)))
 
 (defun tramp-send-command-and-read (vec command &optional noerror marker)
   "Run COMMAND and return the output, which must be a Lisp expression.
@@ -5101,7 +5144,7 @@ If MARKER is a regexp, read the output after that string.
 In case there is no valid Lisp expression and NOERROR is nil, it
 raises an error."
   (when (if noerror
-           (tramp-send-command-and-check vec command)
+           (ignore-errors (tramp-send-command-and-check vec command))
          (tramp-barf-unless-okay
           vec command "`%s' returns with error" command))
     (with-current-buffer (tramp-get-connection-buffer vec)
@@ -5127,6 +5170,7 @@ raises an error."
                  "`%s' does not return a valid Lisp expression: `%s'"
                  command (buffer-string))))))))
 
+;; FIXME: Move to tramp.el?
 ;;;###tramp-autoload
 (defun tramp-convert-file-attributes (vec attr)
   "Convert `file-attributes' ATTR generated by perl script, stat or ls.
@@ -5260,87 +5304,90 @@ Return ATTR."
 (defun tramp-get-remote-path (vec)
   "Compile list of remote directories for $PATH.
 Nonexistent directories are removed from spec."
-  (with-tramp-connection-property
-      ;; When `tramp-own-remote-path' is in `tramp-remote-path', we
-      ;; cache the result for the session only.  Otherwise, the result
-      ;; is cached persistently.
-      (if (memq 'tramp-own-remote-path tramp-remote-path)
-         (tramp-get-connection-process vec)
-       vec)
-      "remote-path"
-    (let* ((remote-path (copy-tree tramp-remote-path))
-          (elt1 (memq 'tramp-default-remote-path remote-path))
-          (elt2 (memq 'tramp-own-remote-path remote-path))
-          (default-remote-path
-            (when elt1
-              (or
-               (tramp-send-command-and-read
-                vec "echo \\\"`getconf PATH 2>/dev/null`\\\"" 'noerror)
-               ;; Default if "getconf" is not available.
-               (progn
-                 (tramp-message
-                  vec 3
-                  "`getconf PATH' not successful, using default value \"%s\"."
-                  "/bin:/usr/bin")
-                 "/bin:/usr/bin"))))
-          (own-remote-path
-           ;; The login shell could return more than just the $PATH
-           ;; string.  So we use `tramp-end-of-heredoc' as marker.
-           (when elt2
-             (or
-              (tramp-send-command-and-read
-               vec
-               (format
-                "%s %s %s 'echo %s \\\"$PATH\\\"'"
-                (tramp-get-method-parameter vec 'tramp-remote-shell)
-                (mapconcat
-                 'identity
-                 (tramp-get-method-parameter vec 'tramp-remote-shell-login)
-                 " ")
-                (mapconcat
-                 'identity
-                 (tramp-get-method-parameter vec 'tramp-remote-shell-args)
-                 " ")
-                (tramp-shell-quote-argument tramp-end-of-heredoc))
-               'noerror (regexp-quote tramp-end-of-heredoc))
-              (progn
-                (tramp-message
-                 vec 2 "Could not retrieve `tramp-own-remote-path'")
-                nil)))))
-
-      ;; Replace place holder `tramp-default-remote-path'.
-      (when elt1
-       (setcdr elt1
-               (append
-                 (split-string (or default-remote-path "") ":" 'omit)
-                (cdr elt1)))
-       (setq remote-path (delq 'tramp-default-remote-path remote-path)))
-
-      ;; Replace place holder `tramp-own-remote-path'.
-      (when elt2
-       (setcdr elt2
-               (append
-                 (split-string (or own-remote-path "") ":" 'omit)
-                (cdr elt2)))
-       (setq remote-path (delq 'tramp-own-remote-path remote-path)))
-
-      ;; Remove double entries.
-      (setq elt1 remote-path)
-      (while (consp elt1)
-       (while (and (car elt1) (setq elt2 (member (car elt1) (cdr elt1))))
-         (setcar elt2 nil))
-       (setq elt1 (cdr elt1)))
-
-      ;; Remove non-existing directories.
-      (delq
-       nil
-       (mapcar
-       (lambda (x)
-         (and
-          (stringp x)
-          (file-directory-p (tramp-make-tramp-file-name vec x 'nohop))
-          x))
-       remote-path)))))
+  (with-current-buffer (tramp-get-connection-buffer vec)
+    ;; Expand connection-local variables.
+    (tramp-set-connection-local-variables vec)
+    (with-tramp-connection-property
+       ;; When `tramp-own-remote-path' is in `tramp-remote-path', we
+       ;; cache the result for the session only.  Otherwise, the
+       ;; result is cached persistently.
+       (if (memq 'tramp-own-remote-path tramp-remote-path)
+           (tramp-get-connection-process vec)
+         vec)
+       "remote-path"
+      (let* ((remote-path (copy-tree tramp-remote-path))
+            (elt1 (memq 'tramp-default-remote-path remote-path))
+            (elt2 (memq 'tramp-own-remote-path remote-path))
+            (default-remote-path
+              (when elt1
+                (or
+                 (tramp-send-command-and-read
+                  vec "echo \\\"`getconf PATH 2>/dev/null`\\\"" 'noerror)
+                 ;; Default if "getconf" is not available.
+                 (progn
+                   (tramp-message
+                    vec 3
+                    "`getconf PATH' not successful, using default value 
\"%s\"."
+                    "/bin:/usr/bin")
+                   "/bin:/usr/bin"))))
+            (own-remote-path
+             ;; The login shell could return more than just the $PATH
+             ;; string.  So we use `tramp-end-of-heredoc' as marker.
+             (when elt2
+               (or
+                (tramp-send-command-and-read
+                 vec
+                 (format
+                  "%s %s %s 'echo %s \\\"$PATH\\\"'"
+                  (tramp-get-method-parameter vec 'tramp-remote-shell)
+                  (mapconcat
+                   #'identity
+                   (tramp-get-method-parameter vec 'tramp-remote-shell-login)
+                   " ")
+                  (mapconcat
+                   #'identity
+                   (tramp-get-method-parameter vec 'tramp-remote-shell-args)
+                   " ")
+                  (tramp-shell-quote-argument tramp-end-of-heredoc))
+                 'noerror (regexp-quote tramp-end-of-heredoc))
+                (progn
+                  (tramp-message
+                   vec 2 "Could not retrieve `tramp-own-remote-path'")
+                  nil)))))
+
+       ;; Replace place holder `tramp-default-remote-path'.
+       (when elt1
+         (setcdr elt1
+                 (append
+                   (split-string (or default-remote-path "") ":" 'omit)
+                  (cdr elt1)))
+         (setq remote-path (delq 'tramp-default-remote-path remote-path)))
+
+       ;; Replace place holder `tramp-own-remote-path'.
+       (when elt2
+         (setcdr elt2
+                 (append
+                   (split-string (or own-remote-path "") ":" 'omit)
+                  (cdr elt2)))
+         (setq remote-path (delq 'tramp-own-remote-path remote-path)))
+
+       ;; Remove double entries.
+       (setq elt1 remote-path)
+       (while (consp elt1)
+         (while (and (car elt1) (setq elt2 (member (car elt1) (cdr elt1))))
+           (setcar elt2 nil))
+         (setq elt1 (cdr elt1)))
+
+       ;; Remove non-existing directories.
+       (delq
+        nil
+        (mapcar
+         (lambda (x)
+           (and
+            (stringp x)
+            (file-directory-p (tramp-make-tramp-file-name vec x 'nohop))
+            x))
+         remote-path))))))
 
 (defun tramp-get-remote-locale (vec)
   "Determine remote locale, supporting UTF8 if possible."
@@ -5538,12 +5585,24 @@ This command is returned only if 
`delete-by-moving-to-trash' is non-nil."
   "Determine remote `df' command."
   (with-tramp-connection-property vec "df"
     (tramp-message vec 5 "Finding a suitable `df' command")
-    (let ((result (tramp-find-executable vec "df" (tramp-get-remote-path 
vec))))
-      (and
-       result
-       (tramp-send-command-and-check
-       vec (format "%s --block-size=1 --output=size,used,avail /" result))
-       result))))
+    (let ((df (tramp-find-executable vec "df" (tramp-get-remote-path vec)))
+         result)
+      (when df
+       (cond
+        ;; coreutils.
+        ((tramp-send-command-and-check
+          vec
+          (format
+           "%s /"
+           (setq result
+                 (format "%s --block-size=1 --output=size,used,avail" df))))
+         (tramp-set-connection-property vec "df-blocksize" 1)
+         result)
+        ;; POSIX.1
+        ((tramp-send-command-and-check
+          vec (format "%s /" (setq result (format "%s -k" df))))
+         (tramp-set-connection-property vec "df-blocksize" 1024)
+         result))))))
 
 (defun tramp-get-remote-gio-monitor (vec)
   "Determine remote `gio-monitor' command."
@@ -5619,7 +5678,7 @@ This command is returned only if 
`delete-by-moving-to-trash' is non-nil."
           (tramp-get-remote-python vec)
           (if (equal id-format 'integer)
               "import os; print (os.getuid())"
-            "import os, pwd; print ('\\\"' + pwd.getpwuid(os.getuid())[0] + 
'\\\"')"))))
+    "import os, pwd; print ('\\\"' + pwd.getpwuid(os.getuid())[0] + 
'\\\"')"))))
 
 (defun tramp-get-remote-uid (vec id-format)
   "The uid of the remote connection VEC, in ID-FORMAT.
@@ -5670,7 +5729,7 @@ ID-FORMAT valid values are `string' and `integer'."
           (tramp-get-remote-python vec)
           (if (equal id-format 'integer)
               "import os; print (os.getgid())"
-            "import os, grp; print ('\\\"' + grp.getgrgid(os.getgid())[0] + 
'\\\"')"))))
+    "import os, grp; print ('\\\"' + grp.getgrgid(os.getgid())[0] + 
'\\\"')"))))
 
 (defun tramp-get-remote-gid (vec id-format)
   "The gid of the remote connection VEC, in ID-FORMAT.
@@ -5759,14 +5818,14 @@ function cell is returned to be applied on a buffer."
                 (let ((coding-system-for-write 'binary)
                       (coding-system-for-read 'binary))
                   (apply
-                   'tramp-call-process-region ',vec (point-min) (point-max)
+                   #'tramp-call-process-region ',vec (point-min) (point-max)
                    (car (split-string ,compress)) t t nil
                    (cdr (split-string ,compress)))))
            `(lambda (beg end)
               (let ((coding-system-for-write 'binary)
                     (coding-system-for-read 'binary))
                 (apply
-                 'tramp-call-process-region ',vec beg end
+                 #'tramp-call-process-region ',vec beg end
                  (car (split-string ,compress)) t t nil
                  (cdr (split-string ,compress))))
               (,coding (point-min) (point-max)))))
@@ -5820,10 +5879,6 @@ function cell is returned to be applied on a buffer."
 ;;   gets confused about the file locking status.  Try to find out why
 ;;   the workaround doesn't work.
 ;;
-;; * Allow out-of-band methods as _last_ multi-hop.  Open a connection
-;;   until the last but one hop via `start-file-process'.  Apply it
-;;   also for ftp and smb.
-;;
 ;; * WIBNI if we had a command "trampclient"?  If I was editing in
 ;;   some shell with root privileges, it would be nice if I could
 ;;   just call
@@ -5897,5 +5952,9 @@ function cell is returned to be applied on a buffer."
 ;;   which could immediately be passed on to the remote side, and
 ;;   later on checks the return value of those calls as and when
 ;;   needed.  (Stefan Monnier)
+;;
+;; * Implement detaching/re-attaching remote sessions.  By this, a
+;;   session could be reused after a connection loss.  Use dtach, or
+;;   screen, or tmux, or mosh.
 
 ;;; tramp-sh.el ends here
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index 5b7998a..6647630 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -1,6 +1,6 @@
 ;;; tramp-smb.el --- Tramp access functions for SMB servers  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 ;; Keywords: comm, processes
@@ -38,45 +38,39 @@
 ;; ... and add it to the method list.
 ;;;###tramp-autoload
 (unless (memq system-type '(cygwin windows-nt))
-  (add-to-list 'tramp-methods
-    `(,tramp-smb-method
-      ;; We define an empty command, because `tramp-smb-call-winexe'
-      ;; opens already the powershell.  Used in `tramp-handle-shell-command'.
-      (tramp-remote-shell "")
-      ;; This is just a guess.  We don't know whether the share "C$"
-      ;; is available for public use, and whether the user has write
-      ;; access.
-      (tramp-tmpdir "/C$/Temp")
-      ;; Another guess.  We might implement a better check later on.
-      (tramp-case-insensitive t))))
+  (tramp--with-startup
+   (add-to-list 'tramp-methods
+                `(,tramp-smb-method
+                  ;; This is just a guess.  We don't know whether the share 
"C$"
+                  ;; is available for public use, and whether the user has 
write
+                  ;; access.
+                  (tramp-tmpdir "/C$/Temp")
+                  ;; Another guess.  We might implement a better check later 
on.
+                  (tramp-case-insensitive t)))))
 
 ;; Add a default for `tramp-default-user-alist'. Rule: For the SMB method,
 ;; the anonymous user is chosen.
 ;;;###tramp-autoload
-(add-to-list 'tramp-default-user-alist
-            `(,(concat "\\`" tramp-smb-method "\\'") nil nil))
+(tramp--with-startup
+ (add-to-list 'tramp-default-user-alist
+             `(,(concat "\\`" tramp-smb-method "\\'") nil nil))
 
-;; Add completion function for SMB method.
-;;;###tramp-autoload
-(eval-after-load 'tramp
-  '(tramp-set-completion-function
-    tramp-smb-method
-    '((tramp-parse-netrc "~/.netrc"))))
+ ;; Add completion function for SMB method.
+ (tramp-set-completion-function
+  tramp-smb-method
+  '((tramp-parse-netrc "~/.netrc"))))
 
-;;;###tramp-autoload
 (defcustom tramp-smb-program "smbclient"
   "Name of SMB client to run."
   :group 'tramp
   :type 'string)
 
-;;;###tramp-autoload
 (defcustom tramp-smb-acl-program "smbcacls"
   "Name of SMB acls to run."
   :group 'tramp
   :type 'string
   :version "24.4")
 
-;;;###tramp-autoload
 (defcustom tramp-smb-conf "/dev/null"
   "Path of the smb.conf file.
 If it is nil, no smb.conf will be added to the `tramp-smb-program'
@@ -102,7 +96,7 @@ call, letting the SMB client use the default one."
 
 (defconst tramp-smb-errors
   (mapconcat
-   'identity
+   #'identity
    `(;; Connection error / timeout / unknown command.
      "Connection\\( to \\S-+\\)? failed"
      "Read from server failed, maybe it closed the connection"
@@ -146,6 +140,7 @@ call, letting the SMB client use the default one."
         "NT_STATUS_NO_LOGON_SERVERS"
         "NT_STATUS_NO_SUCH_FILE"
         "NT_STATUS_NO_SUCH_USER"
+        "NT_STATUS_NOT_A_DIRECTORY"
         "NT_STATUS_OBJECT_NAME_COLLISION"
         "NT_STATUS_OBJECT_NAME_INVALID"
         "NT_STATUS_OBJECT_NAME_NOT_FOUND"
@@ -215,7 +210,7 @@ See `tramp-actions-before-shell' for more info.")
 ;; New handlers should be added here.
 ;;;###tramp-autoload
 (defconst tramp-smb-file-name-handler-alist
-  '(;; `access-file' performed by default handler.
+  '((access-file . tramp-handle-access-file)
     (add-name-to-file . tramp-smb-handle-add-name-to-file)
     ;; `byte-compiler-base-file-name' performed by default handler.
     (copy-directory . tramp-smb-handle-copy-directory)
@@ -270,6 +265,7 @@ See `tramp-actions-before-shell' for more info.")
     (make-directory . tramp-smb-handle-make-directory)
     (make-directory-internal . tramp-smb-handle-make-directory-internal)
     (make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
+    (make-process . ignore)
     (make-symbolic-link . tramp-smb-handle-make-symbolic-link)
     (process-file . tramp-smb-handle-process-file)
     (rename-file . tramp-smb-handle-rename-file)
@@ -282,6 +278,7 @@ See `tramp-actions-before-shell' for more info.")
     (start-file-process . tramp-smb-handle-start-file-process)
     (substitute-in-file-name . tramp-smb-handle-substitute-in-file-name)
     (temporary-file-directory . tramp-handle-temporary-file-directory)
+    (tramp-set-file-uid-gid . ignore)
     (unhandled-file-name-directory . ignore)
     (vc-registered . ignore)
     (verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)
@@ -290,7 +287,6 @@ See `tramp-actions-before-shell' for more info.")
 Operations not mentioned here will be handled by the default Emacs 
primitives.")
 
 ;; Options for remote processes via winexe.
-;;;###tramp-autoload
 (defcustom tramp-smb-winexe-program "winexe"
   "Name of winexe client to run.
 If it isn't found in the local $PATH, the absolute path of winexe
@@ -299,7 +295,6 @@ shall be given.  This is needed for remote processes."
   :type 'string
   :version "24.3")
 
-;;;###tramp-autoload
 (defcustom tramp-smb-winexe-shell-command "powershell.exe"
   "Shell to be used for processes on remote machines.
 This must be Powershell V2 compatible."
@@ -307,7 +302,6 @@ This must be Powershell V2 compatible."
   :type 'string
   :version "24.3")
 
-;;;###tramp-autoload
 (defcustom tramp-smb-winexe-shell-command-switch "-file -"
   "Command switch used together with `tramp-smb-winexe-shell-command'.
 This can be used to disable echo etc."
@@ -336,8 +330,9 @@ pass to the OPERATION."
 
 ;;;###tramp-autoload
 (unless (memq system-type '(cygwin windows-nt))
-  (tramp-register-foreign-file-name-handler
-   'tramp-smb-file-name-p 'tramp-smb-file-name-handler))
+  (tramp--with-startup
+   (tramp-register-foreign-file-name-handler
+    #'tramp-smb-file-name-p #'tramp-smb-file-name-handler)))
 
 ;; File name primitives.
 
@@ -406,7 +401,7 @@ pass to the OPERATION."
   (if copy-contents
       ;; We must do it file-wise.
       (tramp-run-real-handler
-       'copy-directory (list dirname newname keep-date parents copy-contents))
+       #'copy-directory (list dirname newname keep-date parents copy-contents))
 
     (setq dirname (expand-file-name dirname)
          newname (expand-file-name newname))
@@ -512,15 +507,15 @@ pass to the OPERATION."
                    ;; password can be handled.
                    (let* ((default-directory tmpdir)
                           (p (apply
-                              'start-process
+                              #'start-process
                               (tramp-get-connection-name v)
                               (tramp-get-connection-buffer v)
                               tramp-smb-program args)))
 
                      (tramp-message
-                      v 6 "%s" (mapconcat 'identity (process-command p) " "))
+                      v 6 "%s" (mapconcat #'identity (process-command p) " "))
                      (process-put p 'vector v)
-                     (process-put p 'adjust-window-size-function 'ignore)
+                     (process-put p 'adjust-window-size-function #'ignore)
                      (set-process-query-on-exit-flag p nil)
                      (tramp-process-actions p v nil tramp-smb-actions-with-tar)
 
@@ -553,7 +548,7 @@ pass to the OPERATION."
           ;; We must do it file-wise.
           (t
            (tramp-run-real-handler
-            'copy-directory (list dirname newname keep-date parents)))))))))
+            #'copy-directory (list dirname newname keep-date parents)))))))))
 
 (defun tramp-smb-handle-copy-file
   (filename newname &optional ok-if-already-exists keep-date
@@ -671,7 +666,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
 (defun tramp-smb-handle-directory-files
   (directory &optional full match nosort)
   "Like `directory-files' for Tramp files."
-  (let ((result (mapcar 'directory-file-name
+  (let ((result (mapcar #'directory-file-name
                        (file-name-all-completions "" directory))))
     ;; Discriminate with regexp.
     (when match
@@ -686,19 +681,21 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
             (lambda (x) (format "%s/%s" directory x))
             result)))
     ;; Sort them if necessary.
-    (unless nosort (setq result (sort result 'string-lessp)))
+    (unless nosort (setq result (sort result #'string-lessp)))
     result))
 
 (defun tramp-smb-handle-expand-file-name (name &optional dir)
   "Like `expand-file-name' for Tramp files."
   ;; If DIR is not given, use DEFAULT-DIRECTORY or "/".
   (setq dir (or dir default-directory "/"))
+  ;; Handle empty NAME.
+  (when (zerop (length name)) (setq name "."))
   ;; Unless NAME is absolute, concat DIR and NAME.
   (unless (file-name-absolute-p name)
     (setq name (concat (file-name-as-directory dir) name)))
   ;; If NAME is not a Tramp file, run the real handler.
   (if (not (tramp-tramp-file-p name))
-      (tramp-run-real-handler 'expand-file-name (list name nil))
+      (tramp-run-real-handler #'expand-file-name (list name nil))
     ;; Dissect NAME.
     (with-parsed-tramp-file-name name nil
       ;; Tilde expansion if necessary.  We use the user name as share,
@@ -711,18 +708,18 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
                 (match-string 1 localname))
               nil nil localname)))
       ;; Make the file name absolute.
-      (unless (tramp-run-real-handler 'file-name-absolute-p (list localname))
+      (unless (tramp-run-real-handler #'file-name-absolute-p (list localname))
        (setq localname (concat "/" localname)))
       ;; No tilde characters in file name, do normal
       ;; `expand-file-name' (this does "/./" and "/../").
       (tramp-make-tramp-file-name
-       v (tramp-run-real-handler 'expand-file-name (list localname))))))
+       v (tramp-run-real-handler #'expand-file-name (list localname))))))
 
 (defun tramp-smb-action-get-acl (proc vec)
   "Read ACL data from connection buffer."
   (unless (process-live-p proc)
     ;; Accept pending output.
-    (while (tramp-accept-process-output proc 0.1))
+    (while (tramp-accept-process-output proc))
     (with-current-buffer (tramp-get-connection-buffer vec)
       ;; There might be a hidden password prompt.
       (widen)
@@ -773,15 +770,15 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
                  ;; Use an asynchronous process.  By this, password can
                  ;; be handled.
                  (let ((p (apply
-                           'start-process
+                           #'start-process
                            (tramp-get-connection-name v)
                            (tramp-get-connection-buffer v)
                            tramp-smb-acl-program args)))
 
                    (tramp-message
-                    v 6 "%s" (mapconcat 'identity (process-command p) " "))
+                    v 6 "%s" (mapconcat #'identity (process-command p) " "))
                    (process-put p 'vector v)
-                   (process-put p 'adjust-window-size-function 'ignore)
+                   (process-put p 'adjust-window-size-function #'ignore)
                    (set-process-query-on-exit-flag p nil)
                    (tramp-process-actions p v nil tramp-smb-actions-get-acl)
                    (when (> (point-max) (point-min))
@@ -995,6 +992,9 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
       ;; Called from `dired-add-entry'.
       (setq filename (file-name-as-directory filename))
     (setq filename (directory-file-name filename)))
+  ;; Check, whether directory is accessible.
+  (unless wildcard
+    (access-file filename "Reading directory"))
   (with-parsed-tramp-file-name filename nil
     (with-tramp-progress-reporter v 0 (format "Opening directory %s" filename)
       (save-match-data
@@ -1049,7 +1049,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
          (when (string-match-p "F" switches)
            (mapc
             (lambda (x)
-              (when (not (zerop (length (car x))))
+              (unless (zerop (length (car x)))
                 (cond
                  ((char-equal ?d (string-to-char (nth 1 x)))
                   (setcar x (concat (car x) "/")))
@@ -1067,7 +1067,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
          ;; Print entries.
          (mapc
           (lambda (x)
-            (when (not (zerop (length (nth 0 x))))
+            (unless (zerop (length (nth 0 x)))
               (let ((attr
                      (when (tramp-smb-get-stat-capability v)
                        (ignore-errors
@@ -1089,7 +1089,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
                           ;; Half a year.
                           (time-since (nth 3 x)) (days-to-time 183))
                          "%b %e %R"
-                       "%b %e  %Y")
+                       "%b %e %Y")
                      (nth 3 x))))) ; date
 
                 ;; We mark the file name.  The inserted name could be
@@ -1161,7 +1161,7 @@ of the symlink.  If TARGET is a Tramp file, only the 
localname
 component is used as the target of the symlink."
   (if (not (tramp-tramp-file-p (expand-file-name linkname)))
       (tramp-run-real-handler
-       'make-symbolic-link (list target linkname ok-if-already-exists))
+       #'make-symbolic-link (list target linkname ok-if-already-exists))
 
     (with-parsed-tramp-file-name linkname nil
       ;; If TARGET is a Tramp name, use just the localname component.
@@ -1260,7 +1260,7 @@ component is used as the target of the symlink."
        (setq outbuf (current-buffer))))
 
       ;; Construct command.
-      (setq command (mapconcat 'identity (cons program args) " ")
+      (setq command (mapconcat #'identity (cons program args) " ")
            command (if input
                        (format
                         "get-content %s | & %s"
@@ -1375,10 +1375,10 @@ component is used as the target of the symlink."
        (delete-file filename)))))
 
 (defun tramp-smb-action-set-acl (proc vec)
-  "Read ACL data from connection buffer."
+  "Set ACL data."
   (unless (process-live-p proc)
     ;; Accept pending output.
-    (while (tramp-accept-process-output proc 0.1))
+    (while (tramp-accept-process-output proc))
     (with-current-buffer (tramp-get-connection-buffer vec)
       (tramp-message vec 10 "\n%s" (buffer-string))
       (throw 'tramp-action 'ok))))
@@ -1424,15 +1424,15 @@ component is used as the target of the symlink."
                ;; Use an asynchronous process.  By this, password can
                ;; be handled.
                (let ((p (apply
-                         'start-process
+                         #'start-process
                          (tramp-get-connection-name v)
                          (tramp-get-connection-buffer v)
                          tramp-smb-acl-program args)))
 
                  (tramp-message
-                  v 6 "%s" (mapconcat 'identity (process-command p) " "))
+                  v 6 "%s" (mapconcat #'identity (process-command p) " "))
                  (process-put p 'vector v)
-                 (process-put p 'adjust-window-size-function 'ignore)
+                 (process-put p 'adjust-window-size-function #'ignore)
                  (set-process-query-on-exit-flag p nil)
                  (tramp-process-actions p v nil tramp-smb-actions-set-acl)
                  (goto-char (point-max))
@@ -1474,7 +1474,7 @@ component is used as the target of the symlink."
                (get-buffer-create buffer)
              ;; BUFFER can be nil.  We use a temporary buffer.
              (generate-new-buffer tramp-temp-buffer-name)))
-          (command (mapconcat 'identity (cons program args) " "))
+          (command (mapconcat #'identity (cons program args) " "))
           (bmp (and (buffer-live-p buffer) (buffer-modified-p buffer)))
           (name1 name)
           (i 0)
@@ -1529,7 +1529,7 @@ errors for shares like \"C$/\", which are common in 
Microsoft Windows."
              (concat (file-remote-p filename)
                      (replace-match "\\1" nil nil localname)))))
     (condition-case nil
-       (tramp-run-real-handler 'substitute-in-file-name (list filename))
+       (tramp-run-real-handler #'substitute-in-file-name (list filename))
       (error filename))))
 
 (defun tramp-smb-handle-write-region
@@ -1556,7 +1556,7 @@ errors for shares like \"C$/\", which are common in 
Microsoft Windows."
       ;; modtime data to be clobbered from the temp file.  We call
       ;; `set-visited-file-modtime' ourselves later on.
       (tramp-run-real-handler
-       'write-region (list start end tmpfile append 'no-message lockname))
+       #'write-region (list start end tmpfile append 'no-message lockname))
 
       (with-tramp-progress-reporter
          v 3 (format "Moving tmp file %s to %s" tmpfile filename)
@@ -1898,11 +1898,11 @@ If ARGUMENT is non-nil, use it as argument for
     ;; connection timeout.
     (with-current-buffer buf
       (goto-char (point-min))
-      (when (and (> (tramp-time-diff
-                    (current-time)
-                    (tramp-get-connection-property
-                     p "last-cmd-time" '(0 0 0)))
-                   60)
+      ;; `seconds-to-time' can be removed once we get rid of Emacs 24.
+      (when (and (time-less-p (seconds-to-time 60)
+                             (time-since
+                              (tramp-get-connection-property
+                               p "last-cmd-time" (seconds-to-time 0))))
                 (process-live-p p)
                 (re-search-forward tramp-smb-errors nil t))
        (delete-process p)
@@ -1915,6 +1915,14 @@ If ARGUMENT is non-nil, use it as argument for
                      share
                      (tramp-get-connection-property p "smb-share" ""))))
 
+      ;; During completion, don't reopen a new connection.  We
+      ;; check this for the process related to
+      ;; `tramp-buffer-name'; otherwise `start-file-process'
+      ;; wouldn't run ever when `non-essential' is non-nil.
+      (when (and (tramp-completion-mode-p)
+                (null (get-process (tramp-buffer-name vec))))
+       (throw 'non-essential 'non-essential))
+
       (save-match-data
        ;; There might be unread output from checking for share names.
        (when buf (with-current-buffer buf (erase-buffer)))
@@ -1964,9 +1972,9 @@ If ARGUMENT is non-nil, use it as argument for
                               args))))
 
              (tramp-message
-              vec 6 "%s" (mapconcat 'identity (process-command p) " "))
+              vec 6 "%s" (mapconcat #'identity (process-command p) " "))
              (process-put p 'vector vec)
-             (process-put p 'adjust-window-size-function 'ignore)
+             (process-put p 'adjust-window-size-function #'ignore)
              (set-process-query-on-exit-flag p nil)
 
              (condition-case err
@@ -1979,20 +1987,22 @@ If ARGUMENT is non-nil, use it as argument for
                       tramp-smb-actions-without-share))
 
                    ;; Check server version.
-                   (unless argument
-                     (with-current-buffer (tramp-get-connection-buffer vec)
-                       (goto-char (point-min))
-                       (search-forward-regexp tramp-smb-server-version nil t)
-                       (let ((smbserver-version (match-string 0)))
-                         (unless
-                             (string-equal
-                              smbserver-version
-                              (tramp-get-connection-property
-                               vec "smbserver-version" smbserver-version))
-                           (tramp-flush-directory-properties vec "")
-                           (tramp-flush-connection-properties vec))
-                         (tramp-set-connection-property
-                          vec "smbserver-version" smbserver-version))))
+                   ;; FIXME: With recent smbclient versions, this
+                   ;; information isn't printed anymore.
+                   ;; (unless argument
+                   ;;   (with-current-buffer (tramp-get-connection-buffer vec)
+                   ;;  (goto-char (point-min))
+                   ;;  (search-forward-regexp tramp-smb-server-version nil t)
+                   ;;  (let ((smbserver-version (match-string 0)))
+                   ;;    (unless
+                   ;;        (string-equal
+                   ;;         smbserver-version
+                   ;;         (tramp-get-connection-property
+                   ;;          vec "smbserver-version" smbserver-version))
+                   ;;      (tramp-flush-directory-properties vec "")
+                   ;;      (tramp-flush-connection-properties vec))
+                   ;;    (tramp-set-connection-property
+                   ;;     vec "smbserver-version" smbserver-version))))
 
                    ;; Set chunksize to 1.  smbclient reads its input
                    ;; character by character; if we send the string
@@ -2028,51 +2038,27 @@ If ARGUMENT is non-nil, use it as argument for
 ;; We don't use timeouts.  If needed, the caller shall wrap around.
 (defun tramp-smb-wait-for-output (vec)
   "Wait for output from smbclient command.
-Returns nil if an error message has appeared."
+Removes smb prompt.  Returns nil if an error message has appeared."
   (with-current-buffer (tramp-get-connection-buffer vec)
     (let ((p (get-buffer-process (current-buffer)))
-         (found (progn (goto-char (point-min))
-                       (re-search-forward tramp-smb-prompt nil t)))
-         (err   (progn (goto-char (point-min))
-                       (re-search-forward tramp-smb-errors nil t)))
-         buffer-read-only)
-
-      ;; Algorithm: get waiting output.  See if last line contains
-      ;; `tramp-smb-prompt' sentinel or `tramp-smb-errors' strings.
-      ;; If not, wait a bit and again get waiting output.
-      (while (and (not found) (not err) (process-live-p p))
-
-       ;; Accept pending output.
-       (tramp-accept-process-output p 0.1)
-
-       ;; Search for prompt.
-       (goto-char (point-min))
-       (setq found (re-search-forward tramp-smb-prompt nil t))
-
-       ;; Search for errors.
-       (goto-char (point-min))
-       (setq err (re-search-forward tramp-smb-errors nil t)))
-
-      ;; When the process is still alive, read pending output.
-      (while (and (not found) (process-live-p p))
-
-       ;; Accept pending output.
-       (tramp-accept-process-output p 0.1)
-
-       ;; Search for prompt.
-       (goto-char (point-min))
-       (setq found (re-search-forward tramp-smb-prompt nil t)))
+         (inhibit-read-only t))
 
+      ;; Read pending output.
+      (while (not (re-search-forward tramp-smb-prompt nil t))
+       (while (tramp-accept-process-output p 0)
+         (goto-char (point-min))))
       (tramp-message vec 6 "\n%s" (buffer-string))
 
       ;; Remove prompt.
-      (when found
+      (goto-char (point-min))
+      (when (re-search-forward tramp-smb-prompt nil t)
        (goto-char (point-max))
        (re-search-backward tramp-smb-prompt nil t)
        (delete-region (point) (point-max)))
 
       ;; Return value is whether no error message has appeared.
-      (not err))))
+      (goto-char (point-min))
+      (not (re-search-forward tramp-smb-errors nil t)))))
 
 (defun tramp-smb-kill-winexe-function ()
   "Send SIGKILL to the winexe process."
diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el
new file mode 100644
index 0000000..0d9e04d
--- /dev/null
+++ b/lisp/net/tramp-sudoedit.el
@@ -0,0 +1,893 @@
+;;; tramp-sudoedit.el --- Functions for accessing under root permissions  -*- 
lexical-binding:t -*-
+
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
+
+;; Author: Michael Albinus <address@hidden>
+;; Keywords: comm, processes
+;; Package: tramp
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; The "sudoedit" Tramp method allows to edit a file as a different
+;; user on the local host.  Contrary to the "sudo" method, all magic
+;; file name functions are implemented by single "sudo ..."  commands.
+;; The purpose is to make editing such a file as secure as possible;
+;; there must be no session running in the Emacs background which
+;; could be attacked from inside Emacs.
+
+;; Consequently, external processes are not implemented.
+
+;;; Code:
+
+(require 'tramp)
+
+;;;###tramp-autoload
+(defconst tramp-sudoedit-method "sudoedit"
+  "When this method name is used, call sudoedit for editing a file.")
+
+;;;###tramp-autoload
+(tramp--with-startup
+ (add-to-list 'tramp-methods
+              `(,tramp-sudoedit-method
+                (tramp-sudo-login (("sudo") ("-u" "%u") ("-S") ("-H")
+                                  ("-p" "Password:") ("--")))))
+
+ (add-to-list 'tramp-default-user-alist '("\\`sudoedit\\'" nil "root"))
+
+ (tramp-set-completion-function
+  tramp-sudoedit-method tramp-completion-function-alist-su))
+
+(defconst tramp-sudoedit-sudo-actions
+  '((tramp-password-prompt-regexp tramp-action-password)
+    (tramp-wrong-passwd-regexp tramp-action-permission-denied)
+    (tramp-process-alive-regexp tramp-sudoedit-action-sudo))
+  "List of pattern/action pairs.
+This list is used for sudo calls.
+
+See `tramp-actions-before-shell' for more info.")
+
+;;;###tramp-autoload
+(defconst tramp-sudoedit-file-name-handler-alist
+  '((access-file . tramp-handle-access-file)
+    (add-name-to-file . tramp-sudoedit-handle-add-name-to-file)
+    (byte-compiler-base-file-name . ignore)
+    ;; `copy-directory' performed by default handler.
+    (copy-file . tramp-sudoedit-handle-copy-file)
+    (delete-directory . tramp-sudoedit-handle-delete-directory)
+    (delete-file . tramp-sudoedit-handle-delete-file)
+    (diff-latest-backup-file . ignore)
+    ;; `directory-file-name' performed by default handler.
+    (directory-files . tramp-handle-directory-files)
+    (directory-files-and-attributes
+     . tramp-handle-directory-files-and-attributes)
+    (dired-compress-file . ignore)
+    (dired-uncache . tramp-handle-dired-uncache)
+    (exec-path . ignore)
+    (expand-file-name . tramp-sudoedit-handle-expand-file-name)
+    (file-accessible-directory-p . tramp-handle-file-accessible-directory-p)
+    (file-acl . tramp-sudoedit-handle-file-acl)
+    (file-attributes . tramp-sudoedit-handle-file-attributes)
+    (file-directory-p . tramp-handle-file-directory-p)
+    (file-equal-p . tramp-handle-file-equal-p)
+    (file-executable-p . tramp-sudoedit-handle-file-executable-p)
+    (file-exists-p . tramp-sudoedit-handle-file-exists-p)
+    (file-in-directory-p . tramp-handle-file-in-directory-p)
+    (file-local-copy . tramp-handle-file-local-copy)
+    (file-modes . tramp-handle-file-modes)
+    (file-name-all-completions
+     . tramp-sudoedit-handle-file-name-all-completions)
+    (file-name-as-directory . tramp-handle-file-name-as-directory)
+    (file-name-case-insensitive-p . tramp-handle-file-name-case-insensitive-p)
+    (file-name-completion . tramp-handle-file-name-completion)
+    (file-name-directory . tramp-handle-file-name-directory)
+    (file-name-nondirectory . tramp-handle-file-name-nondirectory)
+    ;; `file-name-sans-versions' performed by default handler.
+    (file-newer-than-file-p . tramp-handle-file-newer-than-file-p)
+    (file-notify-add-watch . ignore)
+    (file-notify-rm-watch . ignore)
+    (file-notify-valid-p . ignore)
+    (file-ownership-preserved-p . ignore)
+    (file-readable-p . tramp-sudoedit-handle-file-readable-p)
+    (file-regular-p . tramp-handle-file-regular-p)
+    (file-remote-p . tramp-handle-file-remote-p)
+    (file-selinux-context . tramp-sudoedit-handle-file-selinux-context)
+    (file-symlink-p . tramp-handle-file-symlink-p)
+    (file-system-info . tramp-sudoedit-handle-file-system-info)
+    (file-truename . tramp-sudoedit-handle-file-truename)
+    (file-writable-p . tramp-sudoedit-handle-file-writable-p)
+    (find-backup-file-name . tramp-handle-find-backup-file-name)
+    ;; `get-file-buffer' performed by default handler.
+    (insert-directory . tramp-handle-insert-directory)
+    (insert-file-contents . tramp-handle-insert-file-contents)
+    (load . tramp-handle-load)
+    (make-auto-save-file-name . tramp-handle-make-auto-save-file-name)
+    (make-directory . tramp-sudoedit-handle-make-directory)
+    (make-directory-internal . ignore)
+    (make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
+    (make-process . ignore)
+    (make-symbolic-link . tramp-sudoedit-handle-make-symbolic-link)
+    (process-file . ignore)
+    (rename-file . tramp-sudoedit-handle-rename-file)
+    (set-file-acl . tramp-sudoedit-handle-set-file-acl)
+    (set-file-modes . tramp-sudoedit-handle-set-file-modes)
+    (set-file-selinux-context . tramp-sudoedit-handle-set-file-selinux-context)
+    (set-file-times . tramp-sudoedit-handle-set-file-times)
+    (set-visited-file-modtime . tramp-handle-set-visited-file-modtime)
+    (shell-command . ignore)
+    (start-file-process . ignore)
+    (substitute-in-file-name . tramp-handle-substitute-in-file-name)
+    (temporary-file-directory . tramp-handle-temporary-file-directory)
+    (tramp-set-file-uid-gid . tramp-sudoedit-handle-set-file-uid-gid)
+    (unhandled-file-name-directory . ignore)
+    (vc-registered . ignore)
+    (verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)
+    (write-region . tramp-sudoedit-handle-write-region))
+  "Alist of handler functions for Tramp SUDOEDIT method.")
+
+;; It must be a `defsubst' in order to push the whole code into
+;; tramp-loaddefs.el.  Otherwise, there would be recursive autoloading.
+;;;###tramp-autoload
+(defsubst tramp-sudoedit-file-name-p (filename)
+  "Check if it's a filename for SUDOEDIT."
+  (and (tramp-tramp-file-p filename)
+       (string= (tramp-file-name-method (tramp-dissect-file-name filename))
+               tramp-sudoedit-method)))
+
+;;;###tramp-autoload
+(defun tramp-sudoedit-file-name-handler (operation &rest args)
+  "Invoke the SUDOEDIT handler for OPERATION.
+First arg specifies the OPERATION, second arg is a list of arguments to
+pass to the OPERATION."
+  (let ((fn (assoc operation tramp-sudoedit-file-name-handler-alist)))
+    (if fn
+       (save-match-data (apply (cdr fn) args))
+      (tramp-run-real-handler operation args))))
+
+;;;###tramp-autoload
+(tramp--with-startup
+ (tramp-register-foreign-file-name-handler
+  #'tramp-sudoedit-file-name-p #'tramp-sudoedit-file-name-handler))
+
+
+;; File name primitives.
+
+(defun tramp-sudoedit-handle-add-name-to-file
+  (filename newname &optional ok-if-already-exists)
+  "Like `add-name-to-file' for Tramp files."
+  (unless (tramp-equal-remote filename newname)
+    (with-parsed-tramp-file-name
+       (if (tramp-tramp-file-p filename) filename newname) nil
+      (tramp-error
+       v 'file-error
+       "add-name-to-file: %s"
+       "only implemented for same method, same user, same host")))
+  (with-parsed-tramp-file-name filename v1
+    (with-parsed-tramp-file-name newname v2
+       ;; Do the 'confirm if exists' thing.
+       (when (file-exists-p newname)
+         ;; What to do?
+         (if (or (null ok-if-already-exists) ; not allowed to exist
+                 (and (numberp ok-if-already-exists)
+                      (not (yes-or-no-p
+                            (format
+                             "File %s already exists; make it a link anyway? "
+                             v2-localname)))))
+             (tramp-error v2 'file-already-exists newname)
+           (delete-file newname)))
+       (tramp-flush-file-properties v2 (file-name-directory v2-localname))
+       (tramp-flush-file-properties v2 v2-localname)
+       (unless
+           (tramp-sudoedit-send-command
+            v1 "ln"
+            (tramp-compat-file-name-unquote v1-localname)
+            (tramp-compat-file-name-unquote v2-localname))
+         (tramp-error
+          v1 'file-error
+          "error with add-name-to-file, see buffer `%s' for details"
+          (buffer-name))))))
+
+(defun tramp-sudoedit-do-copy-or-rename-file
+  (op filename newname &optional ok-if-already-exists keep-date
+   preserve-uid-gid preserve-extended-attributes)
+  "Copy or rename a remote file.
+OP must be `copy' or `rename' and indicates the operation to perform.
+FILENAME specifies the file to copy or rename, NEWNAME is the name of
+the new file (for copy) or the new name of the file (for rename).
+OK-IF-ALREADY-EXISTS means don't barf if NEWNAME exists already.
+KEEP-DATE means to make sure that NEWNAME has the same timestamp
+as FILENAME.  PRESERVE-UID-GID, when non-nil, instructs to keep
+the uid and gid if both files are on the same host.
+PRESERVE-EXTENDED-ATTRIBUTES activates selinux and acl commands.
+
+This function is invoked by `tramp-sudoedit-handle-copy-file' and
+`tramp-sudoedit-handle-rename-file'.  It is an error if OP is
+neither of `copy' and `rename'.  FILENAME and NEWNAME must be
+absolute file names."
+  (unless (memq op '(copy rename))
+    (error "Unknown operation `%s', must be `copy' or `rename'" op))
+
+  (setq filename (file-truename filename))
+  (if (file-directory-p filename)
+      (progn
+       (copy-directory filename newname keep-date t)
+       (when (eq op 'rename) (delete-directory filename 'recursive)))
+
+    (let ((t1 (tramp-sudoedit-file-name-p filename))
+         (t2 (tramp-sudoedit-file-name-p newname))
+         (file-times (tramp-compat-file-attribute-modification-time
+                      (file-attributes filename)))
+         (file-modes (tramp-default-file-modes filename))
+         ;; `file-extended-attributes' exists since Emacs 24.4.
+         (attributes (and preserve-extended-attributes
+                          (apply #'file-extended-attributes (list filename))))
+         (sudoedit-operation
+          (cond
+           ((and (eq op 'copy) preserve-uid-gid) '("cp" "-f" "-p"))
+           ((eq op 'copy) '("cp" "-f"))
+           ((eq op 'rename) '("mv" "-f"))))
+         (msg-operation (if (eq op 'copy) "Copying" "Renaming")))
+
+      (with-parsed-tramp-file-name (if t1 filename newname) nil
+       (when (and (not ok-if-already-exists) (file-exists-p newname))
+         (tramp-error v 'file-already-exists newname))
+
+       (if (or (and (file-remote-p filename) (not t1))
+               (and (file-remote-p newname)  (not t2)))
+           ;; We cannot copy or rename directly.
+           (let ((tmpfile (tramp-compat-make-temp-file filename)))
+             (if (eq op 'copy)
+                 (copy-file filename tmpfile t)
+               (rename-file filename tmpfile t))
+             (rename-file tmpfile newname ok-if-already-exists))
+
+         ;; Direct action.
+         (with-tramp-progress-reporter
+             v 0 (format "%s %s to %s" msg-operation filename newname)
+           (unless (tramp-sudoedit-send-command
+                    v sudoedit-operation
+                    (tramp-compat-file-name-unquote
+                     (tramp-compat-file-local-name filename))
+                    (tramp-compat-file-name-unquote
+                     (tramp-compat-file-local-name newname)))
+             (tramp-error
+              v 'file-error
+              "Error %s `%s' `%s'" msg-operation filename newname))))
+
+       ;; When `newname' is local, we must change the ownership to
+       ;; the local user.
+       (unless (file-remote-p newname)
+         (tramp-set-file-uid-gid
+          (concat (file-remote-p filename) newname)
+          (tramp-get-local-uid 'integer)
+          (tramp-get-local-gid 'integer)))
+
+       ;; Set the time and mode. Mask possible errors.
+       (when keep-date
+         (ignore-errors
+           (set-file-times newname file-times)
+           (set-file-modes newname file-modes)))
+
+       ;; Handle `preserve-extended-attributes'.  We ignore possible
+       ;; errors, because ACL strings could be incompatible.
+       ;; `set-file-extended-attributes' exists since Emacs 24.4.
+       (when attributes
+         (ignore-errors
+           (apply #'set-file-extended-attributes (list newname attributes))))
+
+       (when (and t1 (eq op 'rename))
+         (with-parsed-tramp-file-name filename v1
+           (tramp-flush-file-properties
+            v1 (file-name-directory v1-localname))
+           (tramp-flush-file-properties v1 v1-localname)))
+
+       (when t2
+         (with-parsed-tramp-file-name newname v2
+           (tramp-flush-file-properties
+            v2 (file-name-directory v2-localname))
+           (tramp-flush-file-properties v2 v2-localname)))))))
+
+(defun tramp-sudoedit-handle-copy-file
+  (filename newname &optional ok-if-already-exists keep-date
+   preserve-uid-gid preserve-extended-attributes)
+  "Like `copy-file' for Tramp files."
+  (setq filename (expand-file-name filename))
+  (setq newname (expand-file-name newname))
+  ;; At least one file a Tramp file?
+  (if (or (tramp-tramp-file-p filename)
+         (tramp-tramp-file-p newname))
+      (tramp-sudoedit-do-copy-or-rename-file
+       'copy filename newname ok-if-already-exists keep-date
+       preserve-uid-gid preserve-extended-attributes)
+    (tramp-run-real-handler
+     #'copy-file
+     (list filename newname ok-if-already-exists keep-date
+          preserve-uid-gid preserve-extended-attributes))))
+
+(defun tramp-sudoedit-handle-delete-directory
+    (directory &optional recursive trash)
+  "Like `delete-directory' for Tramp files."
+  (setq directory (expand-file-name directory))
+  (with-parsed-tramp-file-name directory nil
+    (tramp-flush-file-properties v (file-name-directory localname))
+    (tramp-flush-directory-properties v localname)
+    (unless
+       (tramp-sudoedit-send-command
+        v (or (and trash "trash")
+              (if recursive '("rm" "-rf") "rmdir"))
+        (tramp-compat-file-name-unquote localname))
+      (tramp-error v 'file-error "Couldn't delete %s" directory))))
+
+(defun tramp-sudoedit-handle-delete-file (filename &optional trash)
+  "Like `delete-file' for Tramp files."
+  (with-parsed-tramp-file-name filename nil
+    (tramp-flush-file-properties v (file-name-directory localname))
+    (tramp-flush-file-properties v localname)
+    (unless
+       (tramp-sudoedit-send-command
+        v (if (and trash delete-by-moving-to-trash) "trash" "rm")
+        (tramp-compat-file-name-unquote localname))
+      ;; Propagate the error.
+      (with-current-buffer (tramp-get-connection-buffer v)
+       (goto-char (point-min))
+       (tramp-error-with-buffer
+        nil v 'file-error "Couldn't delete %s" filename)))))
+
+(defun tramp-sudoedit-handle-expand-file-name (name &optional dir)
+  "Like `expand-file-name' for Tramp files.
+If the localname part of the given file name starts with \"/../\" then
+the result will be a local, non-Tramp, file name."
+  ;; If DIR is not given, use `default-directory' or "/".
+  (setq dir (or dir default-directory "/"))
+  ;; Handle empty NAME.
+  (when (zerop (length name)) (setq name "."))
+  ;; Unless NAME is absolute, concat DIR and NAME.
+  (unless (file-name-absolute-p name)
+    (setq name (concat (file-name-as-directory dir) name)))
+  (with-parsed-tramp-file-name name nil
+    ;; Tilde expansion if necessary.  We cannot accept "~/", because
+    ;; under sudo "~/" is expanded to the local user home directory
+    ;; but to the root home directory.
+    (when (zerop (length localname))
+      (setq localname "~"))
+    (unless (file-name-absolute-p localname)
+      (setq localname (format "~%s/%s" user localname)))
+    (when (string-match "\\`\\(~[^/]*\\)\\(.*\\)\\'" localname)
+      (let ((uname (match-string 1 localname))
+           (fname (match-string 2 localname)))
+       (when (string-equal uname "~")
+         (setq uname (concat uname user)))
+       (setq localname (concat uname fname))))
+    ;; Do normal `expand-file-name' (this does "~user/", "/./" and "/../").
+    (tramp-make-tramp-file-name v (expand-file-name localname))))
+
+(defun tramp-sudoedit-remote-acl-p (vec)
+  "Check, whether ACL is enabled on the remote host."
+  (with-tramp-connection-property (tramp-get-connection-process vec) "acl-p"
+    (zerop (tramp-call-process vec "getfacl" nil nil nil "/"))))
+
+(defun tramp-sudoedit-handle-file-acl (filename)
+  "Like `file-acl' for Tramp files."
+  (with-parsed-tramp-file-name filename nil
+    (with-tramp-file-property v localname "file-acl"
+      (let ((result (and (tramp-sudoedit-remote-acl-p v)
+                        (tramp-sudoedit-send-command-string
+                         v "getfacl" "-acp"
+                         (tramp-compat-file-name-unquote localname)))))
+       ;; The acl string must have a trailing \n, which is not
+       ;; provided by `tramp-sudoedit-send-command-string'.  Add it.
+       (and (stringp result) (concat result "\n"))))))
+
+(defun tramp-sudoedit-handle-file-attributes (filename &optional id-format)
+  "Like `file-attributes' for Tramp files."
+  (unless id-format (setq id-format 'integer))
+  (with-parsed-tramp-file-name (expand-file-name filename) nil
+    (with-tramp-file-property
+       v localname (format "file-attributes-%s" id-format)
+      (tramp-message v 5 "file attributes: %s" localname)
+      (ignore-errors
+       (tramp-convert-file-attributes
+        v
+        (tramp-sudoedit-send-command-and-read
+         v "env" "QUOTING_STYLE=locale" "stat" "-c"
+         (format
+          ;; Apostrophes in the stat output are masked as
+          ;; `tramp-stat-marker', in order to make a proper shell
+          ;; escape of them in file names.
+          "((%s%%N%s) %%h %s %s %%X %%Y %%Z %%s %s%%A%s t %%i -1)"
+          tramp-stat-marker tramp-stat-marker
+          (if (eq id-format 'integer)
+              "%u"
+            (eval-when-compile
+              (concat tramp-stat-marker "%U" tramp-stat-marker)))
+          (if (eq id-format 'integer)
+              "%g"
+            (eval-when-compile
+              (concat tramp-stat-marker "%G" tramp-stat-marker)))
+          tramp-stat-marker tramp-stat-marker)
+         (tramp-compat-file-name-unquote localname)))))))
+
+(defun tramp-sudoedit-handle-file-executable-p (filename)
+  "Like `file-executable-p' for Tramp files."
+  (with-parsed-tramp-file-name filename nil
+    (with-tramp-file-property v localname "file-executable-p"
+      (tramp-sudoedit-send-command
+       v "test" "-x" (tramp-compat-file-name-unquote localname)))))
+
+(defun tramp-sudoedit-handle-file-exists-p (filename)
+  "Like `file-exists-p' for Tramp files."
+  (with-parsed-tramp-file-name filename nil
+    (with-tramp-file-property v localname "file-exists-p"
+      (tramp-sudoedit-send-command
+       v "test" "-e" (tramp-compat-file-name-unquote localname)))))
+
+(defun tramp-sudoedit-handle-file-name-all-completions (filename directory)
+  "Like `file-name-all-completions' for Tramp files."
+  (all-completions
+   filename
+   (with-parsed-tramp-file-name (expand-file-name directory) nil
+     (with-tramp-file-property v localname "file-name-all-completions"
+       (tramp-sudoedit-send-command
+       v "ls" "-a1" "--quoting-style=literal" "--show-control-chars"
+       (if (zerop (length localname))
+           "" (tramp-compat-file-name-unquote localname)))
+       (mapcar
+       (lambda (f)
+         (if (file-directory-p (expand-file-name f directory))
+             (file-name-as-directory f)
+           f))
+       (with-current-buffer (tramp-get-connection-buffer v)
+         (delq
+          nil
+          (mapcar
+           (lambda (l) (and (not (string-match-p "^[[:space:]]*$" l)) l))
+           (split-string (buffer-string) "\n" 'omit)))))))))
+
+(defun tramp-sudoedit-handle-file-readable-p (filename)
+  "Like `file-readable-p' for Tramp files."
+  (with-parsed-tramp-file-name filename nil
+    (with-tramp-file-property v localname "file-readable-p"
+      (tramp-sudoedit-send-command
+       v "test" "-r" (tramp-compat-file-name-unquote localname)))))
+
+(defun tramp-sudoedit-handle-set-file-modes (filename mode)
+  "Like `set-file-modes' for Tramp files."
+  (with-parsed-tramp-file-name filename nil
+    (tramp-flush-file-properties v (file-name-directory localname))
+    (tramp-flush-file-properties v localname)
+    (unless (tramp-sudoedit-send-command
+            v "chmod" (format "%o" mode)
+            (tramp-compat-file-name-unquote localname))
+      (tramp-error
+       v 'file-error "Error while changing file's mode %s" filename))))
+
+(defun tramp-sudoedit-remote-selinux-p (vec)
+  "Check, whether SELINUX is enabled on the remote host."
+  (with-tramp-connection-property (tramp-get-connection-process vec) 
"selinux-p"
+    (zerop (tramp-call-process vec "selinuxenabled"))))
+
+(defun tramp-sudoedit-handle-file-selinux-context (filename)
+  "Like `file-selinux-context' for Tramp files."
+  (with-parsed-tramp-file-name filename nil
+    (with-tramp-file-property v localname "file-selinux-context"
+      (let ((context '(nil nil nil nil))
+           (regexp (eval-when-compile
+                     (concat "\\([a-z0-9_]+\\):" "\\([a-z0-9_]+\\):"
+                             "\\([a-z0-9_]+\\):" "\\([a-z0-9_]+\\)"))))
+       (when (and (tramp-sudoedit-remote-selinux-p v)
+                  (tramp-sudoedit-send-command
+                   v "ls" "-d" "-Z"
+                   (tramp-compat-file-name-unquote localname)))
+         (with-current-buffer (tramp-get-connection-buffer v)
+           (goto-char (point-min))
+           (when (re-search-forward regexp (point-at-eol) t)
+             (setq context (list (match-string 1) (match-string 2)
+                                 (match-string 3) (match-string 4))))))
+       ;; Return the context.
+       context))))
+
+(defun tramp-sudoedit-handle-file-system-info (filename)
+  "Like `file-system-info' for Tramp files."
+  (ignore-errors
+    (with-parsed-tramp-file-name (expand-file-name filename) nil
+      (tramp-message v 5 "file system info: %s" localname)
+      (when (tramp-sudoedit-send-command
+            v "df" "--block-size=1" "--output=size,used,avail"
+            (tramp-compat-file-name-unquote localname)))
+      (with-current-buffer (tramp-get-connection-buffer v)
+       (goto-char (point-min))
+       (forward-line)
+       (when (looking-at
+              (eval-when-compile
+                (concat "[[:space:]]*\\([[:digit:]]+\\)"
+                        "[[:space:]]+\\([[:digit:]]+\\)"
+                        "[[:space:]]+\\([[:digit:]]+\\)")))
+         (list (string-to-number (match-string 1))
+               ;; The second value is the used size.  We need the
+               ;; free size.
+               (- (string-to-number (match-string 1))
+                  (string-to-number (match-string 2)))
+               (string-to-number (match-string 3))))))))
+
+(defun tramp-sudoedit-handle-set-file-times (filename &optional time)
+  "Like `set-file-times' for Tramp files."
+  (with-parsed-tramp-file-name filename nil
+    (tramp-flush-file-properties v (file-name-directory localname))
+    (tramp-flush-file-properties v localname)
+    (let ((time
+          (if (or (null time)
+                  (tramp-compat-time-equal-p time tramp-time-doesnt-exist)
+                  (tramp-compat-time-equal-p time tramp-time-dont-know))
+              (current-time)
+            time)))
+      (tramp-sudoedit-send-command
+       v "env" "TZ=UTC" "touch" "-t"
+       (format-time-string "%Y%m%d%H%M.%S" time t)
+       (tramp-compat-file-name-unquote localname)))))
+
+(defun tramp-sudoedit-handle-file-truename (filename)
+  "Like `file-truename' for Tramp files."
+   ;; Preserve trailing "/".
+  (funcall
+   (if (string-equal (file-name-nondirectory filename) "")
+       #'file-name-as-directory #'identity)
+   (with-parsed-tramp-file-name (expand-file-name filename) nil
+     (tramp-make-tramp-file-name
+      v
+      (with-tramp-file-property v localname "file-truename"
+       (let ((quoted (tramp-compat-file-name-quoted-p localname))
+             (localname (tramp-compat-file-name-unquote localname))
+             result)
+         (tramp-message v 4 "Finding true name for `%s'" filename)
+         (setq result (tramp-sudoedit-send-command-string
+                       v "readlink" "--canonicalize-missing" localname))
+         ;; 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))
+           (let (file-name-handler-alist)
+             (setq result (tramp-compat-file-name-quote result))))
+         (tramp-message v 4 "True name of `%s' is `%s'" localname result)
+         result))
+      'nohop))))
+
+(defun tramp-sudoedit-handle-file-writable-p (filename)
+  "Like `file-writable-p' for Tramp files."
+  (with-parsed-tramp-file-name filename nil
+    (with-tramp-file-property v localname "file-writable-p"
+      (if (file-exists-p filename)
+         (tramp-sudoedit-send-command
+          v "test" "-w" (tramp-compat-file-name-unquote localname))
+       (let ((dir (file-name-directory filename)))
+         (and (file-exists-p dir)
+              (file-writable-p dir)))))))
+
+(defun tramp-sudoedit-handle-make-directory (dir &optional parents)
+  "Like `make-directory' for Tramp files."
+  (setq dir (expand-file-name dir))
+  (with-parsed-tramp-file-name dir nil
+    ;; When PARENTS is non-nil, DIR could be a chain of non-existent
+    ;; directories a/b/c/...  Instead of checking, we simply flush the
+    ;; whole cache.
+    (tramp-flush-directory-properties
+     v (if parents "/" (file-name-directory localname)))
+    (unless (tramp-sudoedit-send-command
+            v (if parents '("mkdir" "-p") "mkdir")
+            (tramp-compat-file-name-unquote localname))
+      (tramp-error v 'file-error "Couldn't make directory %s" dir))))
+
+(defun tramp-sudoedit-handle-make-symbolic-link
+    (target linkname &optional ok-if-already-exists)
+  "Like `make-symbolic-link' for Tramp files.
+If TARGET is a non-Tramp file, it is used verbatim as the target
+of the symlink.  If TARGET is a Tramp file, only the localname
+component is used as the target of the symlink."
+  (if (not (tramp-tramp-file-p (expand-file-name linkname)))
+      (tramp-run-real-handler
+       #'make-symbolic-link (list target linkname ok-if-already-exists))
+
+    (with-parsed-tramp-file-name linkname nil
+      ;; If TARGET is a Tramp name, use just the localname component.
+      (when (and (tramp-tramp-file-p target)
+                (tramp-file-name-equal-p v (tramp-dissect-file-name target)))
+       (setq target
+             (tramp-file-name-localname
+              (tramp-dissect-file-name (expand-file-name target)))))
+
+      ;; If TARGET is still remote, quote it.
+      (if (tramp-tramp-file-p target)
+         (make-symbolic-link
+          (let (file-name-handler-alist) (tramp-compat-file-name-quote target))
+          linkname ok-if-already-exists)
+
+       ;; Do the 'confirm if exists' thing.
+       (when (file-exists-p linkname)
+         ;; What to do?
+         (if (or (null ok-if-already-exists) ; not allowed to exist
+                 (and (numberp ok-if-already-exists)
+                      (not
+                       (yes-or-no-p
+                        (format
+                         "File %s already exists; make it a link anyway? "
+                         localname)))))
+             (tramp-error v 'file-already-exists localname)
+           (delete-file linkname)))
+
+       (tramp-flush-file-properties v (file-name-directory localname))
+       (tramp-flush-file-properties v localname)
+        (tramp-sudoedit-send-command
+        v "ln" "-sf"
+        (tramp-compat-file-name-unquote target)
+        (tramp-compat-file-name-unquote localname))))))
+
+(defun tramp-sudoedit-handle-rename-file
+  (filename newname &optional ok-if-already-exists)
+  "Like `rename-file' for Tramp files."
+  (setq filename (expand-file-name filename))
+  (setq newname (expand-file-name newname))
+  ;; At least one file a Tramp file?
+  (if (or (tramp-tramp-file-p filename)
+          (tramp-tramp-file-p newname))
+      (tramp-sudoedit-do-copy-or-rename-file
+       'rename filename newname ok-if-already-exists
+       'keep-date 'preserve-uid-gid)
+    (tramp-run-real-handler
+     'rename-file (list filename newname ok-if-already-exists))))
+
+(defun tramp-sudoedit-handle-set-file-acl (filename acl-string)
+  "Like `set-file-acl' for Tramp files."
+  (with-parsed-tramp-file-name (expand-file-name filename) nil
+    (when (and (stringp acl-string) (tramp-sudoedit-remote-acl-p v))
+      ;; Massage `acl-string'.
+      (setq acl-string
+           (mapconcat #'identity (split-string acl-string "\n" 'omit) ","))
+      (prog1
+         (tramp-sudoedit-send-command
+          v "setfacl" "-m"
+          acl-string (tramp-compat-file-name-unquote localname))
+       (tramp-flush-file-property v localname "file-acl")))))
+
+(defun tramp-sudoedit-handle-set-file-selinux-context (filename context)
+  "Like `set-file-selinux-context' for Tramp files."
+  (with-parsed-tramp-file-name filename nil
+    (when (and (consp context)
+              (tramp-sudoedit-remote-selinux-p v))
+      (let ((user (and (stringp (nth 0 context)) (nth 0 context)))
+           (role (and (stringp (nth 1 context)) (nth 1 context)))
+           (type (and (stringp (nth 2 context)) (nth 2 context)))
+           (range (and (stringp (nth 3 context)) (nth 3 context))))
+       (when (tramp-sudoedit-send-command
+              v "chcon"
+              (when user (format "--user=%s" user))
+              (when role (format "--role=%s" role))
+              (when type (format "--type=%s" type))
+              (when range (format "--range=%s" range))
+              (tramp-compat-file-name-unquote localname))
+         (if (and user role type range)
+             (tramp-set-file-property
+              v localname "file-selinux-context" context)
+           (tramp-flush-file-property v localname "file-selinux-context"))
+         t)))))
+
+(defun tramp-sudoedit-get-remote-uid (vec id-format)
+  "The uid of the remote connection VEC, in ID-FORMAT.
+ID-FORMAT valid values are `string' and `integer'."
+  (with-tramp-connection-property vec (format "uid-%s" id-format)
+    (if (equal id-format 'integer)
+       (tramp-sudoedit-send-command-and-read vec "id" "-u")
+      (tramp-sudoedit-send-command-string vec "id" "-un"))))
+
+(defun tramp-sudoedit-get-remote-gid (vec id-format)
+  "The gid of the remote connection VEC, in ID-FORMAT.
+ID-FORMAT valid values are `string' and `integer'."
+  (with-tramp-connection-property vec (format "gid-%s" id-format)
+    (if (equal id-format 'integer)
+       (tramp-sudoedit-send-command-and-read vec "id" "-g")
+      (tramp-sudoedit-send-command-string vec "id" "-gn"))))
+
+(defun tramp-sudoedit-handle-set-file-uid-gid (filename &optional uid gid)
+  "Like `tramp-set-file-uid-gid' for Tramp files."
+    (with-parsed-tramp-file-name filename nil
+      (tramp-sudoedit-send-command
+       v "chown"
+       (format "%d:%d"
+              (or uid (tramp-sudoedit-get-remote-uid v 'integer))
+              (or gid (tramp-sudoedit-get-remote-gid v 'integer)))
+       (tramp-compat-file-name-unquote
+       (tramp-compat-file-local-name filename)))))
+
+(defun tramp-sudoedit-handle-write-region
+  (start end filename &optional append visit lockname mustbenew)
+  "Like `write-region' for Tramp files."
+  (with-parsed-tramp-file-name filename nil
+    (let ((uid (or (tramp-compat-file-attribute-user-id
+                   (file-attributes filename 'integer))
+                  (tramp-sudoedit-get-remote-uid v 'integer)))
+         (gid (or (tramp-compat-file-attribute-group-id
+                   (file-attributes filename 'integer))
+                  (tramp-sudoedit-get-remote-gid v 'integer)))
+         (modes (tramp-default-file-modes filename)))
+      (prog1
+         (tramp-handle-write-region
+          start end filename append visit lockname mustbenew)
+
+       ;; Set the ownership and modes.  This is not performed in
+       ;; `tramp-handle-write-region'.
+       (unless (and (= (tramp-compat-file-attribute-user-id
+                        (file-attributes filename 'integer))
+                       uid)
+                     (= (tramp-compat-file-attribute-group-id
+                        (file-attributes filename 'integer))
+                       gid))
+          (tramp-set-file-uid-gid filename uid gid))
+       (set-file-modes filename modes)))))
+
+
+;; Internal functions.
+
+;; Used in `tramp-sudoedit-sudo-actions'.
+(defun tramp-sudoedit-action-sudo (proc vec)
+  "Check, whether a sudo process has finished.
+Remove unneeded output."
+  ;; There might be pending output for the exit status.
+  (unless (process-live-p proc)
+    (while (tramp-accept-process-output proc 0))
+    ;; Delete narrowed region, it would be in the way reading a Lisp form.
+    (goto-char (point-min))
+    (widen)
+    (delete-region (point-min) (point))
+    ;; Delete empty lines.
+    (goto-char (point-min))
+    (while (and (not (eobp)) (= (point) (point-at-eol)))
+      (forward-line))
+    (delete-region (point-min) (point))
+    (tramp-message vec 3 "Process has finished.")
+    (throw 'tramp-action 'ok)))
+
+(defun tramp-sudoedit-maybe-open-connection (vec)
+  "Maybe open a connection VEC.
+Does not do anything if a connection is already open, but re-opens the
+connection if a previous connection has died for some reason."
+  ;; We need a process bound to the connection buffer.  Therefore, we
+  ;; create a dummy process.  Maybe there is a better solution?
+  (unless (tramp-get-connection-process vec)
+
+    ;; During completion, don't reopen a new connection.  We check
+    ;; this for the process related to `tramp-buffer-name'; otherwise
+    ;; `start-file-process' wouldn't run ever when `non-essential' is
+    ;; non-nil.
+    (when (and (tramp-completion-mode-p)
+              (null (get-process (tramp-buffer-name vec))))
+      (throw 'non-essential 'non-essential))
+
+    (let ((p (make-network-process
+             :name (tramp-buffer-name vec)
+             :buffer (tramp-get-connection-buffer vec)
+             :server t :host 'local :service t :noquery t)))
+      (process-put p 'vector vec)
+      (set-process-query-on-exit-flag p nil)
+
+      ;; Set connection-local variables.
+      (tramp-set-connection-local-variables vec)
+
+      ;; Mark it as connected.
+      (tramp-set-connection-property p "connected" t))
+
+    ;; In `tramp-check-cached-permissions', the connection properties
+    ;; "{uid,gid}-{integer,string}" are used.  We set them to proper values.
+    (tramp-sudoedit-get-remote-uid vec 'integer)
+    (tramp-sudoedit-get-remote-gid vec 'integer)
+    (tramp-sudoedit-get-remote-uid vec 'string)
+    (tramp-sudoedit-get-remote-gid vec 'string)))
+
+(defun tramp-sudoedit-send-command (vec &rest args)
+  "Send commands ARGS to connection VEC.
+If an element of ARGS is a list, it will be flattened.  If an
+element of ARGS is nil, it will be deleted.
+Erases temporary buffer before sending the command.  Returns nil
+in case of error, t otherwise."
+  (tramp-sudoedit-maybe-open-connection vec)
+  (with-current-buffer (tramp-get-connection-buffer vec)
+    (erase-buffer)
+    (let* ((login (tramp-get-method-parameter vec 'tramp-sudo-login))
+          (host (or (tramp-file-name-host vec) ""))
+          (user (or (tramp-file-name-user vec) ""))
+          (spec (format-spec-make ?h host ?u user))
+          (args (append
+                 (tramp-compat-flatten-tree
+                  (mapcar
+                   (lambda (x)
+                     (setq x (mapcar (lambda (y) (format-spec y spec)) x))
+                     (unless (member "" x) x))
+                   login))
+                 (tramp-compat-flatten-tree (delq nil args))))
+          (delete-exited-processes t)
+          (process-connection-type tramp-process-connection-type)
+          (p (apply #'start-process
+                    (tramp-get-connection-name vec) (current-buffer) args))
+          ;; We suppress the messages `Waiting for prompts from remote shell'.
+          (tramp-verbose (if (= tramp-verbose 3) 2 tramp-verbose))
+          ;; We do not want to save the password.
+          auth-source-save-behavior)
+      (tramp-message vec 6 "%s" (mapconcat #'identity (process-command p) " "))
+      ;; Avoid process status message in output buffer.
+      (set-process-sentinel p #'ignore)
+      (process-put p 'vector vec)
+      (process-put p 'adjust-window-size-function #'ignore)
+      (set-process-query-on-exit-flag p nil)
+      (tramp-process-actions p vec nil tramp-sudoedit-sudo-actions)
+      (tramp-message vec 6 "%s\n%s" (process-exit-status p) (buffer-string))
+      (prog1
+         (zerop (process-exit-status p))
+       (delete-process p)))))
+
+(defun tramp-sudoedit-send-command-and-read (vec &rest args)
+  "Run command ARGS and return the output, which must be a Lisp expression.
+In case there is no valid Lisp expression, it raises an error."
+  (when (apply #'tramp-sudoedit-send-command vec args)
+    (with-current-buffer (tramp-get-connection-buffer vec)
+      ;; Replace stat marker.
+      (goto-char (point-min))
+      (when (search-forward tramp-stat-marker nil t)
+       (goto-char (point-min))
+       (while (search-forward "\"" nil t)
+         (replace-match "\\\"" nil 'literal))
+       (goto-char (point-min))
+       (while (search-forward tramp-stat-marker nil t)
+         (replace-match "\"")))
+      ;; Read the expression.
+      (tramp-message vec 6 "\n%s" (buffer-string))
+      (goto-char (point-min))
+      (condition-case nil
+         (prog1 (read (current-buffer))
+           ;; Error handling.
+           (when (re-search-forward "\\S-" (point-at-eol) t)
+             (error nil)))
+       (error (tramp-error
+               vec 'file-error
+               "`%s' does not return a valid Lisp expression: `%s'"
+               (car args) (buffer-string)))))))
+
+(defun tramp-sudoedit-send-command-string (vec &rest args)
+  "Run command ARGS and return the output as astring."
+  (when (apply #'tramp-sudoedit-send-command vec args)
+    (with-current-buffer (tramp-get-connection-buffer vec)
+      (tramp-message vec 6 "\n%s" (buffer-string))
+      (goto-char (point-max))
+      ;(delete-blank-lines)
+      (while (looking-back "[ \t\n]+" nil 'greedy)
+       (delete-region (match-beginning 0) (point)))
+      (when (> (point-max) (point-min))
+       (substring-no-properties (buffer-string))))))
+
+(add-hook 'tramp-unload-hook
+         (lambda ()
+           (unload-feature 'tramp-sudoedit 'force)))
+
+(provide 'tramp-sudoedit)
+
+;;; TODO:
+
+;; * Fix *-selinux functions.  Likely, this is due to wrong file
+;;   ownership after `write-region' and/or `copy-file'.
+
+;;; tramp-sudoedit.el ends here
diff --git a/lisp/net/tramp-uu.el b/lisp/net/tramp-uu.el
index 3e08b94..c12a4eb 100644
--- a/lisp/net/tramp-uu.el
+++ b/lisp/net/tramp-uu.el
@@ -1,6 +1,6 @@
 ;;; tramp-uu.el --- uuencode in Lisp  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Kai Großjohann <address@hidden>
 ;; Maintainer: Michael Albinus <address@hidden>
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index a44abfd..2e1a096 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -1,13 +1,13 @@
 ;;; tramp.el --- Transparent Remote Access, Multiple Protocol  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Kai Großjohann <address@hidden>
 ;;         Michael Albinus <address@hidden>
 ;; Maintainer: Michael Albinus <address@hidden>
 ;; Keywords: comm, processes
 ;; Package: tramp
-;; Version: 2.4.1-pre
+;; Version: 2.4.2-pre
 ;; Package-Requires: ((emacs "24.1"))
 
 ;; This file is part of GNU Emacs.
@@ -56,13 +56,13 @@
 ;;; Code:
 
 (require 'tramp-compat)
+(require 'tramp-integration)
 (require 'trampver)
 
 ;; Pacify byte-compiler.
 (require 'cl-lib)
 (declare-function netrc-parse "netrc")
 (defvar auto-save-file-name-transforms)
-(defvar eshell-path-env)
 (defvar ls-lisp-use-insert-directory-program)
 (defvar outline-regexp)
 
@@ -75,6 +75,16 @@
   :link '(custom-manual "(tramp)Top")
   :version "22.1")
 
+(eval-and-compile ;; So it's also available in tramp-loaddefs.el!
+  (defvar tramp--startup-hook nil
+    "Forms to be executed at the end of tramp.el.")
+
+  (defmacro tramp--with-startup (&rest body)
+    "Schedule BODY to be executed at the end of tramp.el."
+    `(add-hook 'tramp--startup-hook (lambda () ,@body))))
+
+(require 'tramp-loaddefs)
+
 ;; Maybe we need once a real Tramp mode, with key bindings etc.
 ;;;###autoload
 (defcustom tramp-mode t
@@ -163,7 +173,6 @@ See the variable `tramp-encoding-shell' for more 
information."
   :group 'tramp
   :type '(choice (const nil) string))
 
-;;;###tramp-autoload
 (defvar tramp-methods nil
   "Alist of methods for remote files.
 This is a list of entries of the form (NAME PARAM1 PARAM2 ...).
@@ -344,7 +353,6 @@ Also see `tramp-default-method-alist'."
   :group 'tramp
   :type 'string)
 
-;;;###tramp-autoload
 (defcustom tramp-default-method-alist nil
   "Default method to use for specific host/user pairs.
 This is an alist of items (HOST USER METHOD).  The first matching item
@@ -374,7 +382,6 @@ This variable is regarded as obsolete, and will be removed 
soon."
   :group 'tramp
   :type '(choice (const nil) string))
 
-;;;###tramp-autoload
 (defcustom tramp-default-user-alist nil
   "Default user to use for specific method/host pairs.
 This is an alist of items (METHOD HOST USER).  The first matching item
@@ -396,7 +403,6 @@ Useful for su and sudo methods mostly."
   :group 'tramp
   :type 'string)
 
-;;;###tramp-autoload
 (defcustom tramp-default-host-alist nil
   "Default host to use for specific method/user pairs.
 This is an alist of items (METHOD USER HOST).  The first matching item
@@ -456,7 +462,6 @@ host runs a registered shell, it shall be added to this 
list, too."
   :group 'tramp
   :type '(repeat (regexp :tag "Host regexp")))
 
-;;;###tramp-autoload
 (defcustom tramp-local-host-regexp
   (concat
    "\\`"
@@ -683,7 +688,6 @@ Useful for \"rsync\" like methods.")
 (make-variable-buffer-local 'tramp-temp-buffer-file-name)
 (put 'tramp-temp-buffer-file-name 'permanent-local t)
 
-;;;###tramp-autoload
 (defcustom tramp-syntax 'default
   "Tramp filename syntax to be used.
 
@@ -702,8 +706,8 @@ Customize.  See also `tramp-change-syntax'."
                 (const :tag "Ange-FTP" simplified)
                 (const :tag "XEmacs" separate))
   :require 'tramp
-  :initialize 'custom-initialize-set
-  :set 'tramp-set-syntax)
+  :initialize #'custom-initialize-default
+  :set #'tramp-set-syntax)
 
 (defun tramp-set-syntax (symbol value)
   "Set SYMBOL to value VALUE.
@@ -711,7 +715,7 @@ Used in user option `tramp-syntax'.  There are further 
variables
 to be set, depending on VALUE."
   ;; Check allowed values.
   (unless (memq value (tramp-syntax-values))
-    (tramp-user-error "Wrong `tramp-syntax' %s" tramp-syntax))
+    (tramp-user-error "Wrong `tramp-syntax' %s" value))
   ;; Cleanup existing buffers.
   (unless (eq (symbol-value symbol) value)
     (tramp-cleanup-all-buffers))
@@ -743,14 +747,15 @@ to be set, depending on VALUE."
 ;; value of `tramp-file-name-regexp'.  Other Tramp syntax variables
 ;; must be initialized as well to proper values.  We do not call
 ;; `custom-set-variable', this would load Tramp via custom.el.
-(eval-after-load 'tramp
-  '(tramp-set-syntax 'tramp-syntax (tramp-compat-tramp-syntax)))
+(tramp--with-startup
+  (tramp-set-syntax 'tramp-syntax (tramp-compat-tramp-syntax)))
 
 (defun tramp-syntax-values ()
   "Return possible values of `tramp-syntax', a list"
   (let ((values (cdr (get 'tramp-syntax 'custom-type))))
-    (setq values (mapcar 'last values)
-         values (mapcar 'car values))))
+    (setq values (mapcar #'last values)
+         values (mapcar #'car values))
+    values))
 
 (defun tramp-lookup-syntax (alist)
   "Look up a syntax string in ALIST according to `tramp-compat-tramp-syntax.'
@@ -767,14 +772,14 @@ Raise an error if `tramp-syntax' is invalid."
 (defun tramp-build-prefix-format ()
   (tramp-lookup-syntax tramp-prefix-format-alist))
 
-(defvar tramp-prefix-format (tramp-build-prefix-format)
+(defvar tramp-prefix-format nil ;Initialized when defining `tramp-syntax'!
   "String matching the very beginning of Tramp file names.
 Used in `tramp-make-tramp-file-name'.")
 
 (defun tramp-build-prefix-regexp ()
   (concat "^" (regexp-quote tramp-prefix-format)))
 
-(defvar tramp-prefix-regexp (tramp-build-prefix-regexp)
+(defvar tramp-prefix-regexp nil ;Initialized when defining `tramp-syntax'!
   "Regexp matching the very beginning of Tramp file names.
 Should always start with \"^\". Derived from `tramp-prefix-format'.")
 
@@ -787,7 +792,7 @@ Should always start with \"^\". Derived from 
`tramp-prefix-format'.")
 (defun tramp-build-method-regexp ()
   (tramp-lookup-syntax tramp-method-regexp-alist))
 
-(defvar tramp-method-regexp (tramp-build-method-regexp)
+(defvar tramp-method-regexp nil ;Initialized when defining `tramp-syntax'!
   "Regexp matching methods identifiers.
 The `ftp' syntax does not support methods.")
 
@@ -800,7 +805,7 @@ The `ftp' syntax does not support methods.")
 (defun tramp-build-postfix-method-format ()
   (tramp-lookup-syntax tramp-postfix-method-format-alist))
 
-(defvar tramp-postfix-method-format (tramp-build-postfix-method-format)
+(defvar tramp-postfix-method-format nil ;Init'd when defining `tramp-syntax'!
   "String matching delimiter between method and user or host names.
 The `ftp' syntax does not support methods.
 Used in `tramp-make-tramp-file-name'.")
@@ -808,18 +813,16 @@ Used in `tramp-make-tramp-file-name'.")
 (defun tramp-build-postfix-method-regexp ()
   (regexp-quote tramp-postfix-method-format))
 
-(defvar tramp-postfix-method-regexp (tramp-build-postfix-method-regexp)
+(defvar tramp-postfix-method-regexp nil ;Init'd when defining `tramp-syntax'!
   "Regexp matching delimiter between method and user or host names.
 Derived from `tramp-postfix-method-format'.")
 
 (defconst tramp-user-regexp "[^/|: \t]+"
   "Regexp matching user names.")
 
-;;;###tramp-autoload
 (defconst tramp-prefix-domain-format "%"
   "String matching delimiter between user and domain names.")
 
-;;;###tramp-autoload
 (defconst tramp-prefix-domain-regexp (regexp-quote tramp-prefix-domain-format)
   "Regexp matching delimiter between user and domain names.
 Derived from `tramp-prefix-domain-format'.")
@@ -853,21 +856,21 @@ Derived from `tramp-postfix-user-format'.")
 (defun tramp-build-prefix-ipv6-format ()
   (tramp-lookup-syntax tramp-prefix-ipv6-format-alist))
 
-(defvar tramp-prefix-ipv6-format (tramp-build-prefix-ipv6-format)
+(defvar tramp-prefix-ipv6-format nil ;Initialized when defining `tramp-syntax'!
   "String matching left hand side of IPv6 addresses.
 Used in `tramp-make-tramp-file-name'.")
 
 (defun tramp-build-prefix-ipv6-regexp ()
   (regexp-quote tramp-prefix-ipv6-format))
 
-(defvar tramp-prefix-ipv6-regexp (tramp-build-prefix-ipv6-regexp)
+(defvar tramp-prefix-ipv6-regexp nil ;Initialized when defining `tramp-syntax'!
   "Regexp matching left hand side of IPv6 addresses.
 Derived from `tramp-prefix-ipv6-format'.")
 
 ;; The following regexp is a bit sloppy.  But it shall serve our
 ;; purposes.  It covers also IPv4 mapped IPv6 addresses, like in
 ;; "::ffff:192.168.0.1".
-(defconst tramp-ipv6-regexp "\\(?:\\(?:[a-zA-Z0-9]+\\)?:\\)+[a-zA-Z0-9.]+"
+(defconst tramp-ipv6-regexp "\\(?:[a-zA-Z0-9]*:\\)+[a-zA-Z0-9.]+"
   "Regexp matching IPv6 addresses.")
 
 (defconst tramp-postfix-ipv6-format-alist
@@ -879,14 +882,14 @@ Derived from `tramp-prefix-ipv6-format'.")
 (defun tramp-build-postfix-ipv6-format ()
   (tramp-lookup-syntax tramp-postfix-ipv6-format-alist))
 
-(defvar tramp-postfix-ipv6-format (tramp-build-postfix-ipv6-format)
+(defvar tramp-postfix-ipv6-format nil ;Initialized when defining 
`tramp-syntax'!
   "String matching right hand side of IPv6 addresses.
 Used in `tramp-make-tramp-file-name'.")
 
 (defun tramp-build-postfix-ipv6-regexp ()
   (regexp-quote tramp-postfix-ipv6-format))
 
-(defvar tramp-postfix-ipv6-regexp (tramp-build-postfix-ipv6-regexp)
+(defvar tramp-postfix-ipv6-regexp nil ;Initialized when defining 
`tramp-syntax'!
   "Regexp matching right hand side of IPv6 addresses.
 Derived from `tramp-postfix-ipv6-format'.")
 
@@ -922,14 +925,14 @@ Derived from `tramp-postfix-hop-format'.")
 (defun tramp-build-postfix-host-format ()
   (tramp-lookup-syntax tramp-postfix-host-format-alist))
 
-(defvar tramp-postfix-host-format (tramp-build-postfix-host-format)
+(defvar tramp-postfix-host-format nil ;Initialized when defining 
`tramp-syntax'!
   "String matching delimiter between host names and localnames.
 Used in `tramp-make-tramp-file-name'.")
 
 (defun tramp-build-postfix-host-regexp ()
   (regexp-quote tramp-postfix-host-format))
 
-(defvar tramp-postfix-host-regexp (tramp-build-postfix-host-regexp)
+(defvar tramp-postfix-host-regexp nil ;Initialized when defining 
`tramp-syntax'!
   "Regexp matching delimiter between host names and localnames.
 Derived from `tramp-postfix-host-format'.")
 
@@ -956,7 +959,7 @@ It is expected, that `tramp-syntax' has the proper value."
           "\\(?:" tramp-prefix-port-regexp  tramp-port-regexp "\\)?" "\\)?"))
 
 (defvar tramp-remote-file-name-spec-regexp
-  (tramp-build-remote-file-name-spec-regexp)
+   nil ;Initialized when defining `tramp-syntax'!
   "Regular expression matching a Tramp file name between prefix and postfix.")
 
 (defun tramp-build-file-name-structure ()
@@ -972,7 +975,7 @@ See `tramp-file-name-structure'."
     "\\(" tramp-localname-regexp "\\)")
    5 6 7 8 1))
 
-(defvar tramp-file-name-structure (tramp-build-file-name-structure)
+(defvar tramp-file-name-structure nil ;Initialized when defining 
`tramp-syntax'!
   "List of six elements (REGEXP METHOD USER HOST FILE HOP), detailing \
 the Tramp file name structure.
 
@@ -1065,7 +1068,7 @@ See `tramp-file-name-structure' for more explanations.")
   (tramp-lookup-syntax tramp-completion-file-name-regexp-alist))
 
 (defvar tramp-completion-file-name-regexp
-  (tramp-build-completion-file-name-regexp)
+   nil ;Initialized when defining `tramp-syntax'!
   "Regular expression matching file names handled by Tramp completion.
 This regexp should match partial Tramp file names only.
 
@@ -1225,7 +1228,6 @@ Operations not mentioned here will be handled by Tramp's 
file
 name handler functions, or the normal Emacs functions.")
 
 ;; Handlers for foreign methods, like FTP or SMB, shall be plugged here.
-;;;###tramp-autoload
 (defvar tramp-foreign-file-name-handler-alist nil
   "Alist of elements (FUNCTION . HANDLER) for foreign methods handled 
specially.
 If (FUNCTION FILENAME) returns non-nil, then all I/O on that file is done by
@@ -1295,7 +1297,6 @@ entry does not exist, return nil."
   "Return unquoted localname component of VEC."
   (tramp-compat-file-name-unquote (tramp-file-name-localname vec)))
 
-;;;###tramp-autoload
 (defun tramp-tramp-file-p (name)
   "Return t if NAME is a string with Tramp file name syntax."
   (and tramp-mode (stringp name)
@@ -1505,7 +1506,7 @@ the form (METHOD USER DOMAIN HOST PORT LOCALNAME 
&optional HOP)."
     ;; Unless `tramp-syntax' is `simplified', we need a method.
     (when (and (not (zerop (length tramp-postfix-method-format)))
               (zerop (length method)))
-      (signal 'wrong-type-argument (list 'stringp method)))
+      (signal 'wrong-type-argument (list #'stringp method)))
     (concat tramp-prefix-format hop
            (unless (zerop (length tramp-postfix-method-format))
              (concat method tramp-postfix-method-format))
@@ -1745,7 +1746,7 @@ applicable)."
     (when (<= level tramp-verbose)
       ;; Display only when there is a minimum level.
       (when (and tramp-message-show-message (<= level 3))
-       (apply 'message
+       (apply #'message
               (concat
                (cond
                 ((= level 0) "")
@@ -1770,7 +1771,7 @@ applicable)."
            (setq vec-or-proc (process-get vec-or-proc 'vector))))
        ;; Do it.
        (when (tramp-file-name-p vec-or-proc)
-         (apply 'tramp-debug-message
+         (apply #'tramp-debug-message
                 vec-or-proc
                 (concat (format "(%d) # " level) fmt-string)
                 arguments))))))
@@ -1821,7 +1822,7 @@ an input event arrives.  The other arguments are passed 
to `tramp-error'."
                    (and buf (with-current-buffer buf
                               (tramp-dissect-file-name default-directory))))))
       (unwind-protect
-         (apply 'tramp-error vec-or-proc signal fmt-string arguments)
+         (apply #'tramp-error vec-or-proc signal fmt-string arguments)
        ;; Save exit.
        (when (and buf
                   tramp-message-show-message
@@ -1833,7 +1834,7 @@ an input event arrives.  The other arguments are passed 
to `tramp-error'."
          (let ((enable-recursive-minibuffers t))
            ;; `tramp-error' does not show messages.  So we must do it
            ;; ourselves.
-           (apply 'message fmt-string arguments)
+           (apply #'message fmt-string arguments)
            ;; Show buffer.
            (pop-to-buffer buf)
            (discard-input)
@@ -1847,7 +1848,7 @@ an input event arrives.  The other arguments are passed 
to `tramp-error'."
   "Signal a pilot error."
   (unwind-protect
       (apply
-       'tramp-error vec-or-proc
+       #'tramp-error vec-or-proc
        ;; `user-error' has appeared in Emacs 24.3.
        (if (fboundp 'user-error) 'user-error 'error) fmt-string arguments)
     ;; Save exit.
@@ -1859,7 +1860,7 @@ an input event arrives.  The other arguments are passed 
to `tramp-error'."
               (current-message))
       (let ((enable-recursive-minibuffers t))
        ;; `tramp-error' does not show messages.  So we must do it ourselves.
-       (apply 'message fmt-string arguments)
+       (apply #'message fmt-string arguments)
        (discard-input)
        (sit-for 30)
        ;; Reset timestamp.  It would be wrong after waiting for a while.
@@ -1990,7 +1991,7 @@ letter into the file name.  This function removes it."
   (save-match-data
     (funcall
      (if (tramp-compat-file-name-quoted-p name)
-        'tramp-compat-file-name-quote 'identity)
+        #'tramp-compat-file-name-quote #'identity)
      (let ((name (tramp-compat-file-name-unquote name)))
        (if (string-match "\\`[a-zA-Z]:/" name)
           (replace-match "/" nil t name)
@@ -1998,7 +1999,6 @@ letter into the file name.  This function removes it."
 
 ;;; Config Manipulation Functions:
 
-;;;###tramp-autoload
 (defun tramp-set-completion-function (method function-list)
   "Sets the list of completion functions for METHOD.
 FUNCTION-LIST is a list of entries of the form (FUNCTION FILE).
@@ -2056,77 +2056,6 @@ For definition of that list see 
`tramp-set-completion-function'."
    ;; The method related defaults.
    (cdr (assoc method tramp-completion-function-alist))))
 
-;;; Fontification of `read-file-name':
-
-(defvar tramp-rfn-eshadow-overlay)
-(make-variable-buffer-local 'tramp-rfn-eshadow-overlay)
-
-(defun tramp-rfn-eshadow-setup-minibuffer ()
-  "Set up a minibuffer for `file-name-shadow-mode'.
-Adds another overlay hiding filename parts according to Tramp's
-special handling of `substitute-in-file-name'."
-  (when minibuffer-completing-file-name
-    (setq tramp-rfn-eshadow-overlay
-         (make-overlay (minibuffer-prompt-end) (minibuffer-prompt-end)))
-    ;; Copy rfn-eshadow-overlay properties.
-    (let ((props (overlay-properties rfn-eshadow-overlay)))
-      (while props
-       ;; The `field' property prevents correct minibuffer
-       ;; completion; we exclude it.
-       (if (not (eq (car props) 'field))
-            (overlay-put tramp-rfn-eshadow-overlay (pop props) (pop props))
-         (pop props) (pop props))))))
-
-(add-hook 'rfn-eshadow-setup-minibuffer-hook
-         'tramp-rfn-eshadow-setup-minibuffer)
-(add-hook 'tramp-unload-hook
-         (lambda ()
-           (remove-hook 'rfn-eshadow-setup-minibuffer-hook
-                        'tramp-rfn-eshadow-setup-minibuffer)))
-
-(defun tramp-rfn-eshadow-update-overlay-regexp ()
-  (format "[^%s/~]*\\(/\\|~\\)" tramp-postfix-host-format))
-
-;; Package rfn-eshadow is preloaded in Emacs, but for some reason,
-;; it only did (defvar rfn-eshadow-overlay) without giving it a global
-;; value, so it was only declared as dynamically-scoped within the
-;; rfn-eshadow.el file.  This is now fixed in Emacs>26.1 but we still need
-;; this defvar here for older releases.
-(defvar rfn-eshadow-overlay)
-
-(defun tramp-rfn-eshadow-update-overlay ()
-  "Update `rfn-eshadow-overlay' to cover shadowed part of minibuffer input.
-This is intended to be used as a minibuffer `post-command-hook' for
-`file-name-shadow-mode'; the minibuffer should have already
-been set up by `rfn-eshadow-setup-minibuffer'."
-  ;; In remote files name, there is a shadowing just for the local part.
-  (ignore-errors
-    (let ((end (or (overlay-end rfn-eshadow-overlay)
-                  (minibuffer-prompt-end)))
-         ;; We do not want to send any remote command.
-         (non-essential t))
-      (when (tramp-tramp-file-p (buffer-substring end (point-max)))
-       (save-excursion
-         (save-restriction
-           (narrow-to-region
-            (1+ (or (string-match-p
-                     (tramp-rfn-eshadow-update-overlay-regexp)
-                     (buffer-string) end)
-                    end))
-            (point-max))
-           (let ((rfn-eshadow-overlay tramp-rfn-eshadow-overlay)
-                 (rfn-eshadow-update-overlay-hook nil)
-                 file-name-handler-alist)
-             (move-overlay rfn-eshadow-overlay (point-max) (point-max))
-             (rfn-eshadow-update-overlay))))))))
-
-(add-hook 'rfn-eshadow-update-overlay-hook
-         'tramp-rfn-eshadow-update-overlay)
-(add-hook 'tramp-unload-hook
-         (lambda ()
-           (remove-hook 'rfn-eshadow-update-overlay-hook
-                        'tramp-rfn-eshadow-update-overlay)))
-
 ;; Inodes don't exist for some file systems.  Therefore we must
 ;; generate virtual ones.  Used in `find-buffer-visiting'.  The method
 ;; applied might be not so efficient (Ange-FTP uses hashes). But
@@ -2148,7 +2077,7 @@ been set up by `rfn-eshadow-setup-minibuffer'."
 If the file modes of FILENAME cannot be determined, return the
 value of `default-file-modes', without execute permissions."
   (or (file-modes filename)
-      (logand (default-file-modes) (string-to-number "0666" 8))))
+      (logand (default-file-modes) #o0666)))
 
 (defun tramp-replace-environment-variables (filename)
  "Replace environment variables in FILENAME.
@@ -2158,7 +2087,7 @@ Return the string with the replaced variables."
        (tramp-compat-funcall 'substitute-env-vars filename 'only-defined))
      ;; We need an own implementation.
      (save-match-data
-       (let ((idx (string-match "$\\(\\w+\\)" filename)))
+       (let ((idx (string-match "\\$\\(\\w+\\)" filename)))
         ;; `$' is coded as `$$'.
         (when (and idx
                    (or (zerop idx) (not (eq ?$ (aref filename (1- idx)))))
@@ -2234,7 +2163,9 @@ ARGS are the arguments OPERATION has been called with."
              ;; Emacs 26+ only.
              file-name-case-insensitive-p
              ;; Emacs 27+ only.
-             file-system-info))
+             file-system-info
+             ;; Tramp internal magic file name function.
+             tramp-set-file-uid-gid))
     (if (file-name-absolute-p (nth 0 args))
        (nth 0 args)
       default-directory))
@@ -2276,7 +2207,7 @@ ARGS are the arguments OPERATION has been called with."
              ;; Emacs 26+ only.
              make-nearby-temp-file temporary-file-directory
              ;; Emacs 27+ only.
-             exec-path))
+             exec-path make-process))
     default-directory)
    ;; PROC.
    ((member operation
@@ -2308,6 +2239,7 @@ ARGS are the arguments OPERATION has been called with."
 (defmacro tramp-condition-case-unless-debug
   (var bodyform &rest handlers)
   "Like `condition-case-unless-debug' but `tramp-debug-on-error'."
+  (declare (debug condition-case) (indent 2))
   `(let ((debug-on-error tramp-debug-on-error))
      (condition-case-unless-debug ,var ,bodyform ,@handlers)))
 
@@ -2342,7 +2274,7 @@ preventing reentrant calls of Tramp.")
 (defun tramp-file-name-handler (operation &rest args)
   "Invoke Tramp file name handler.
 Falls back to normal file name handler if no Tramp file name handler exists."
-  (let ((filename (apply 'tramp-file-name-for-operation operation args)))
+  (let ((filename (apply #'tramp-file-name-for-operation operation args)))
     (if (tramp-tramp-file-p filename)
        (save-match-data
           (setq filename (tramp-replace-environment-variables filename))
@@ -2487,7 +2419,7 @@ remote file names."
           "^%s$"
           (regexp-opt
            (mapcar
-            'file-name-sans-extension
+            #'file-name-sans-extension
             (directory-files dir nil "^tramp.+\\.elc?$"))
            'paren))))
     (mapatoms
@@ -2499,7 +2431,7 @@ remote file names."
           (setf (cadr (symbol-function atom))
                 (expand-file-name (cadr (symbol-function atom)) dir))))))))
 
-(eval-after-load 'tramp (tramp-use-absolute-autoload-file-names))
+(tramp--with-startup (tramp-use-absolute-autoload-file-names))
 
 (defun tramp-register-file-name-handlers ()
   "Add Tramp file name handlers to `file-name-handler-alist'."
@@ -2512,21 +2444,21 @@ remote file names."
   ;; `tramp-archive-file-name-handler', this shall be done by the
   ;; respective foreign handlers.
   (add-to-list 'file-name-handler-alist
-              (cons tramp-file-name-regexp 'tramp-file-name-handler))
+              (cons tramp-file-name-regexp #'tramp-file-name-handler))
   (put 'tramp-file-name-handler 'safe-magic t)
 
   (add-to-list 'file-name-handler-alist
               (cons tramp-completion-file-name-regexp
-                    'tramp-completion-file-name-handler))
+                    #'tramp-completion-file-name-handler))
   (put 'tramp-completion-file-name-handler 'safe-magic t)
   ;; Mark `operations' the handler is responsible for.
   (put 'tramp-completion-file-name-handler 'operations
-       (mapcar 'car tramp-completion-file-name-handler-alist))
+       (mapcar #'car tramp-completion-file-name-handler-alist))
 
   (when (bound-and-true-p tramp-archive-enabled)
     (add-to-list 'file-name-handler-alist
                 (cons tramp-archive-file-name-regexp
-                      'tramp-archive-file-name-handler))
+                      #'tramp-archive-file-name-handler))
     (put 'tramp-archive-file-name-handler 'safe-magic t))
 
   ;; If jka-compr or epa-file are already loaded, move them to the
@@ -2537,10 +2469,9 @@ remote file names."
        (setq file-name-handler-alist
              (cons entry (delete entry file-name-handler-alist)))))))
 
-(eval-after-load 'tramp (tramp-register-file-name-handlers))
+(tramp--with-startup (tramp-register-file-name-handlers))
 
-;;;###tramp-autoload
-(progn (defun tramp-register-foreign-file-name-handler
+(defun tramp-register-foreign-file-name-handler
     (func handler &optional append)
   "Register (FUNC . HANDLER) in `tramp-foreign-file-name-handler-alist'.
 FUNC is the function, which determines whether HANDLER is to be called.
@@ -2554,8 +2485,8 @@ Add operations defined in `HANDLER-alist' to 
`tramp-file-name-handler'."
         (append
          (get 'tramp-file-name-handler 'operations)
          (mapcar
-          'car
-          (symbol-value (intern (concat (symbol-name handler) "-alist")))))))))
+          #'car
+          (symbol-value (intern (concat (symbol-name handler) "-alist"))))))))
 
 (defun tramp-exists-file-name-handler (operation &rest args)
   "Check, whether OPERATION runs a file name handler."
@@ -2585,7 +2516,7 @@ Add operations defined in `HANDLER-alist' to 
`tramp-file-name-handler'."
               (string-prefix-p "tramp-" (symbol-name (cdr fnh))))
       (setq file-name-handler-alist (delq fnh file-name-handler-alist))))))
 
-(add-hook 'tramp-unload-hook 'tramp-unload-file-name-handlers)
+(add-hook 'tramp-unload-hook #'tramp-unload-file-name-handlers)
 
 ;;; File name handler functions for completion mode:
 
@@ -2690,7 +2621,7 @@ not in completion mode."
   "Like `file-name-completion' for Tramp files."
   (try-completion
    filename
-   (mapcar 'list (file-name-all-completions filename directory))
+   (mapcar #'list (file-name-all-completions filename directory))
    (when (and predicate
              (tramp-connectable-p (expand-file-name filename directory)))
      (lambda (x) (funcall predicate (expand-file-name (car x) directory))))))
@@ -2808,7 +2739,7 @@ remote host and localname (filename on remote host)."
      (and method
          (string-match-p (concat "^" (regexp-quote partial-method)) method)
          (tramp-completion-make-tramp-file-name method nil nil nil)))
-   (mapcar 'car tramp-methods)))
+   (mapcar #'car tramp-methods)))
 
 ;; Compares partial user and host names with possible completions.
 (defun tramp-get-completion-user-host
@@ -2866,17 +2797,18 @@ for all methods.  Resulting data are derived from 
default settings."
   (and tramp-completion-use-auth-sources
        (mapcar
        (lambda (x) `(,(plist-get x :user) ,(plist-get x :host)))
-       (auth-source-search :port method :max most-positive-fixnum))))
+       (auth-source-search
+        :port method :require '(:port) :max most-positive-fixnum))))
 
 ;; Generic function.
-(defun tramp-parse-group (regexp match-level skip-regexp)
+(defun tramp-parse-group (regexp match-level skip-chars)
    "Return a (user host) tuple allowed to access.
 User is always nil."
    (let (result)
      (when (re-search-forward regexp (point-at-eol) t)
        (setq result (list nil (match-string match-level))))
      (or
-      (> (skip-chars-forward skip-regexp) 0)
+      (> (skip-chars-forward skip-chars) 0)
       (forward-line 1))
      result))
 
@@ -2893,11 +2825,10 @@ User is always nil."
        (goto-char (point-min))
         (cl-loop while (not (eobp)) collect (funcall function))))))
 
-;;;###tramp-autoload
 (defun tramp-parse-rhosts (filename)
   "Return a list of (user host) tuples allowed to access.
 Either user or host may be nil."
-  (tramp-parse-file filename 'tramp-parse-rhosts-group))
+  (tramp-parse-file filename #'tramp-parse-rhosts-group))
 
 (defun tramp-parse-rhosts-group ()
    "Return a (user host) tuple allowed to access.
@@ -2912,22 +2843,20 @@ Either user or host may be nil."
      (forward-line 1)
      result))
 
-;;;###tramp-autoload
 (defun tramp-parse-shosts (filename)
   "Return a list of (user host) tuples allowed to access.
 User is always nil."
-  (tramp-parse-file filename 'tramp-parse-shosts-group))
+  (tramp-parse-file filename #'tramp-parse-shosts-group))
 
 (defun tramp-parse-shosts-group ()
    "Return a (user host) tuple allowed to access.
 User is always nil."
    (tramp-parse-group (concat "^\\(" tramp-host-regexp "\\)") 1 ","))
 
-;;;###tramp-autoload
 (defun tramp-parse-sconfig (filename)
   "Return a list of (user host) tuples allowed to access.
 User is always nil."
-  (tramp-parse-file filename 'tramp-parse-sconfig-group))
+  (tramp-parse-file filename #'tramp-parse-sconfig-group))
 
 (defun tramp-parse-sconfig-group ()
    "Return a (user host) tuple allowed to access.
@@ -2935,7 +2864,7 @@ User is always nil."
    (tramp-parse-group
     (concat "\\(?:^[ \t]*Host\\)" "\\|" "\\(?:^.+\\)"
            "\\|" "\\(" tramp-host-regexp "\\)")
-    1 "[ \t]+"))
+    1 " \t"))
 
 ;; Generic function.
 (defun tramp-parse-shostkeys-sknownhosts (dirname regexp)
@@ -2950,14 +2879,12 @@ User is always nil."
      when (and (not (string-match "^\\.\\.?$" f)) (string-match regexp f))
      collect (list nil (match-string 1 f)))))
 
-;;;###tramp-autoload
 (defun tramp-parse-shostkeys (dirname)
   "Return a list of (user host) tuples allowed to access.
 User is always nil."
   (tramp-parse-shostkeys-sknownhosts
    dirname (concat "^key_[0-9]+_\\(" tramp-host-regexp "\\)\\.pub$")))
 
-;;;###tramp-autoload
 (defun tramp-parse-sknownhosts (dirname)
   "Return a list of (user host) tuples allowed to access.
 User is always nil."
@@ -2965,11 +2892,10 @@ User is always nil."
    dirname
    (concat "^\\(" tramp-host-regexp "\\)\\.ssh-\\(dss\\|rsa\\)\\.pub$")))
 
-;;;###tramp-autoload
 (defun tramp-parse-hosts (filename)
   "Return a list of (user host) tuples allowed to access.
 User is always nil."
-  (tramp-parse-file filename 'tramp-parse-hosts-group))
+  (tramp-parse-file filename #'tramp-parse-hosts-group))
 
 (defun tramp-parse-hosts-group ()
    "Return a (user host) tuple allowed to access.
@@ -2977,7 +2903,6 @@ User is always nil."
    (tramp-parse-group
     (concat "^\\(" tramp-ipv6-regexp "\\|" tramp-host-regexp "\\)") 1 " \t"))
 
-;;;###tramp-autoload
 (defun tramp-parse-passwd (filename)
   "Return a list of (user host) tuples allowed to access.
 Host is always \"localhost\"."
@@ -2988,7 +2913,7 @@ Host is always \"localhost\"."
            (goto-char (point-min))
            (cl-loop while (not (eobp)) collect
                     (tramp-parse-etc-group-group))))
-      (tramp-parse-file filename 'tramp-parse-passwd-group))))
+      (tramp-parse-file filename #'tramp-parse-passwd-group))))
 
 (defun tramp-parse-passwd-group ()
    "Return a (user host) tuple allowed to access.
@@ -3000,7 +2925,6 @@ Host is always \"localhost\"."
      (forward-line 1)
      result))
 
-;;;###tramp-autoload
 (defun tramp-parse-etc-group (filename)
   "Return a list of (group host) tuples allowed to access.
 Host is always \"localhost\"."
@@ -3011,7 +2935,7 @@ Host is always \"localhost\"."
            (goto-char (point-min))
            (cl-loop while (not (eobp)) collect
                     (tramp-parse-etc-group-group))))
-      (tramp-parse-file filename 'tramp-parse-etc-group-group))))
+      (tramp-parse-file filename #'tramp-parse-etc-group-group))))
 
 (defun tramp-parse-etc-group-group ()
    "Return a (group host) tuple allowed to access.
@@ -3023,7 +2947,6 @@ Host is always \"localhost\"."
      (forward-line 1)
      result))
 
-;;;###tramp-autoload
 (defun tramp-parse-netrc (filename)
   "Return a list of (user host) tuples allowed to access.
 User may be nil."
@@ -3034,7 +2957,6 @@ User may be nil."
          `(,(cdr (assoc "login" item)) ,(cdr (assoc "machine" item)))))
    (netrc-parse filename)))
 
-;;;###tramp-autoload
 (defun tramp-parse-putty (registry-or-dirname)
   "Return a list of (user host) tuples allowed to access.
 User is always nil."
@@ -3068,6 +2990,13 @@ User is always nil."
 (defvar tramp-handle-write-region-hook nil
   "Normal hook to be run at the end of `tramp-*-handle-write-region'.")
 
+(defun tramp-handle-access-file (filename string)
+  "Like `access-file' for Tramp files."
+  (unless (file-readable-p filename)
+    (tramp-error
+     (tramp-dissect-file-name filename) tramp-file-missing
+     "%s: No such file or directory %s" string filename)))
+
 (defun tramp-handle-add-name-to-file
   (filename newname &optional ok-if-already-exists)
   "Like `add-name-to-file' for Tramp files."
@@ -3119,7 +3048,7 @@ User is always nil."
        (when (or (null match) (string-match-p match item))
          (push (if full (concat directory item) item)
                result)))
-      (if nosort result (sort result 'string<)))))
+      (if nosort result (sort result #'string<)))))
 
 (defun tramp-handle-directory-files-and-attributes
   (directory &optional full match nosort id-format)
@@ -3140,15 +3069,17 @@ User is always nil."
   "Like `expand-file-name' for Tramp files."
   ;; If DIR is not given, use DEFAULT-DIRECTORY or "/".
   (setq dir (or dir default-directory "/"))
+  ;; Handle empty NAME.
+  (when (zerop (length name)) (setq name "."))
   ;; Unless NAME is absolute, concat DIR and NAME.
   (unless (file-name-absolute-p name)
     (setq name (concat (file-name-as-directory dir) name)))
   ;; If NAME is not a Tramp file, run the real handler.
   (if (not (tramp-tramp-file-p name))
-      (tramp-run-real-handler 'expand-file-name (list name nil))
+      (tramp-run-real-handler #'expand-file-name (list name nil))
     ;; Dissect NAME.
     (with-parsed-tramp-file-name name nil
-      (unless (tramp-run-real-handler 'file-name-absolute-p (list localname))
+      (unless (tramp-run-real-handler #'file-name-absolute-p (list localname))
        (setq localname (concat "/" localname)))
       ;; Do normal `expand-file-name' (this does "/./" and "/../").
       ;; `default-directory' is bound, because on Windows there would
@@ -3156,7 +3087,7 @@ User is always nil."
       (let ((default-directory (tramp-compat-temporary-file-directory)))
        (tramp-make-tramp-file-name
         v (tramp-drop-volume-letter
-           (tramp-run-real-handler 'expand-file-name (list localname))))))))
+           (tramp-run-real-handler #'expand-file-name (list localname))))))))
 
 (defun tramp-handle-file-accessible-directory-p (filename)
   "Like `file-accessible-directory-p' for Tramp files."
@@ -3177,7 +3108,7 @@ User is always nil."
   (when (string-equal
         (file-remote-p (expand-file-name filename1))
         (file-remote-p (expand-file-name filename2)))
-    (tramp-run-real-handler 'file-equal-p (list filename1 filename2))))
+    (tramp-run-real-handler #'file-equal-p (list filename1 filename2))))
 
 (defun tramp-handle-file-exists-p (filename)
   "Like `file-exists-p' for Tramp files."
@@ -3191,7 +3122,7 @@ User is always nil."
   (when (string-equal
         (file-remote-p (expand-file-name filename))
         (file-remote-p (expand-file-name directory)))
-    (tramp-run-real-handler 'file-in-directory-p (list filename directory))))
+    (tramp-run-real-handler #'file-in-directory-p (list filename directory))))
 
 (defun tramp-handle-file-local-copy (filename)
   "Like `file-local-copy' for Tramp files."
@@ -3223,7 +3154,7 @@ User is always nil."
      v (or (and (zerop (length (tramp-file-name-localname v)))
                (not (tramp-connectable-p file)))
           (tramp-run-real-handler
-           'file-name-as-directory
+           #'file-name-as-directory
            (list (tramp-file-name-localname v)))))))
 
 (defun tramp-handle-file-name-case-insensitive-p (filename)
@@ -3288,7 +3219,7 @@ User is always nil."
      (try-completion
       filename (file-name-all-completions filename directory)
       (lambda (x)
-       (when (funcall (or predicate 'identity) (expand-file-name x directory))
+       (when (funcall (or predicate #'identity) (expand-file-name x directory))
          (not
           (and
            completion-ignored-extensions
@@ -3309,13 +3240,13 @@ User is always nil."
     ;; nil, mark also the localname part of `v' as nil.
     (tramp-make-tramp-file-name
      v (or (tramp-run-real-handler
-           'file-name-directory (list (tramp-file-name-localname v)))
+           #'file-name-directory (list (tramp-file-name-localname v)))
           'noloc))))
 
 (defun tramp-handle-file-name-nondirectory (file)
   "Like `file-name-nondirectory' but aware of Tramp files."
   (with-parsed-tramp-file-name file nil
-    (tramp-run-real-handler 'file-name-nondirectory (list localname))))
+    (tramp-run-real-handler #'file-name-nondirectory (list localname))))
 
 (defun tramp-handle-file-newer-than-file-p (file1 file2)
   "Like `file-newer-than-file-p' for Tramp files."
@@ -3372,7 +3303,7 @@ User is always nil."
   ;; Preserve trailing "/".
   (funcall
    (if (string-equal (file-name-nondirectory filename) "")
-       'file-name-as-directory 'identity)
+       #'file-name-as-directory #'identity)
    (let ((result (expand-file-name filename))
         (numchase 0)
         ;; Don't make the following value larger than necessary.
@@ -3395,7 +3326,7 @@ User is always nil."
                     v2
                     (funcall
                      (if (tramp-compat-file-name-quoted-p v2-localname)
-                         'tramp-compat-file-name-quote 'identity)
+                         #'tramp-compat-file-name-quote #'identity)
 
                      (if (stringp symlink-target)
                          (if (file-remote-p symlink-target)
@@ -3437,7 +3368,7 @@ User is always nil."
                     (cdr x))))
                tramp-backup-directory-alist)
             backup-directory-alist)))
-      (tramp-run-real-handler 'find-backup-file-name (list filename)))))
+      (tramp-run-real-handler #'find-backup-file-name (list filename)))))
 
 (defun tramp-handle-insert-directory
   (filename switches &optional wildcard full-directory-p)
@@ -3447,12 +3378,15 @@ User is always nil."
   (when (and (zerop (length (file-name-nondirectory filename)))
             (not full-directory-p))
     (setq switches (concat switches "F")))
+  ;; Check, whether directory is accessible.
+  (unless wildcard
+    (access-file filename "Reading directory"))
   (with-parsed-tramp-file-name (expand-file-name filename) nil
     (with-tramp-progress-reporter v 0 (format "Opening directory %s" filename)
       (require 'ls-lisp)
       (let (ls-lisp-use-insert-directory-program start)
        (tramp-run-real-handler
-        'insert-directory
+        #'insert-directory
         (list filename switches wildcard full-directory-p))
        ;; `ls-lisp' always returns full listings.  We must remove
        ;; superfluous parts.
@@ -3466,7 +3400,7 @@ User is always nil."
               start
               (or (text-property-any start (point-at-eol) 'dired-filename t)
                   (point-at-eol)))
-             (if (=  (point-at-bol) (point-at-eol))
+             (if (= (point-at-bol) (point-at-eol))
                  ;; Empty line.
                  (delete-region (point) (progn (forward-line) (point)))
                (forward-line)))))))))
@@ -3494,7 +3428,7 @@ User is always nil."
                      ;; run directly.
                      (setq result
                            (tramp-run-real-handler
-                            'insert-file-contents
+                            #'insert-file-contents
                             (list localname visit beg end replace)))
 
                    ;; When we shall insert only a part of the file, we
@@ -3548,7 +3482,7 @@ User is always nil."
                    ;; When the file is not readable for the owner, it
                    ;; cannot be inserted, even if it is readable for the
                    ;; group or for everybody.
-                   (set-file-modes local-copy (string-to-number "0600" 8))
+                   (set-file-modes local-copy #o0600)
 
                    (when (and (null remote-copy)
                               (tramp-get-method-parameter
@@ -3604,10 +3538,9 @@ User is always nil."
        (tramp-error
         v 'file-error
         "File `%s' does not include a `.el' or `.elc' suffix" file)))
-    (unless noerror
-      (when (not (file-exists-p file))
-       (tramp-error
-        v tramp-file-missing "Cannot load nonexistent file `%s'" file)))
+    (unless (or noerror (file-exists-p file))
+      (tramp-error
+       v tramp-file-missing "Cannot load nonexistent file `%s'" file))
     (if (not (file-exists-p file))
        nil
       (let ((tramp-message-show-message (not nomessage)))
@@ -3630,23 +3563,13 @@ support symbolic links."
     ;; This is needed prior Emacs 26.1, where TARGET has also be
     ;; checked for a file name handler.
     (tramp-run-real-handler
-     'make-symbolic-link (list target linkname ok-if-already-exists))))
+     #'make-symbolic-link (list target linkname ok-if-already-exists))))
 
 (defun tramp-handle-shell-command
   (command &optional output-buffer error-buffer)
   "Like `shell-command' for Tramp files."
   (let* ((asynchronous (string-match-p "[ \t]*&[ \t]*\\'" command))
-        ;; We cannot use `shell-file-name' and `shell-command-switch',
-        ;; they are variables of the local host.
-        (args (append
-               (cons
-                (tramp-get-method-parameter
-                 (tramp-dissect-file-name default-directory)
-                 'tramp-remote-shell)
-                (tramp-get-method-parameter
-                 (tramp-dissect-file-name default-directory)
-                 'tramp-remote-shell-args))
-               (list (substring command 0 asynchronous))))
+        (command (substring command 0 asynchronous))
         current-buffer-p
         (output-buffer
          (cond
@@ -3663,19 +3586,48 @@ support symbolic links."
          (cond
           ((bufferp error-buffer) error-buffer)
           ((stringp error-buffer) (get-buffer-create error-buffer))))
-        (buffer
-         (if (and (not asynchronous) error-buffer)
-             (with-parsed-tramp-file-name default-directory nil
-               (list output-buffer (tramp-make-tramp-temp-file v)))
-           output-buffer))
-        (p (get-buffer-process output-buffer)))
-
-    ;; Check whether there is another process running.  Tramp does not
-    ;; support 2 (asynchronous) processes in parallel.
+        (bname (buffer-name output-buffer))
+        (p (get-buffer-process output-buffer))
+        buffer)
+
+    ;; The following code is taken from `shell-command', slightly
+    ;; adapted.  Shouldn't it be factored out?
     (when p
-      (if (yes-or-no-p "A command is running.  Kill it? ")
-         (ignore-errors (kill-process p))
-       (tramp-user-error p "Shell command in progress")))
+      (cond
+       ((eq async-shell-command-buffer 'confirm-kill-process)
+       ;; If will kill a process, query first.
+       (if (yes-or-no-p
+            "A command is running in the default buffer.  Kill it? ")
+           (kill-process p)
+         (tramp-user-error p "Shell command in progress")))
+       ((eq async-shell-command-buffer 'confirm-new-buffer)
+       ;; If will create a new buffer, query first.
+       (if (yes-or-no-p
+            "A command is running in the default buffer.  Use a new buffer? ")
+            (setq output-buffer (generate-new-buffer bname))
+         (tramp-user-error p "Shell command in progress")))
+       ((eq async-shell-command-buffer 'new-buffer)
+       ;; It will create a new buffer.
+        (setq output-buffer (generate-new-buffer bname)))
+       ((eq async-shell-command-buffer 'confirm-rename-buffer)
+       ;; If will rename the buffer, query first.
+       (if (yes-or-no-p
+            "A command is running in the default buffer.  Rename it? ")
+           (progn
+             (with-current-buffer output-buffer
+               (rename-uniquely))
+              (setq output-buffer (get-buffer-create bname)))
+         (tramp-user-error p "Shell command in progress")))
+       ((eq async-shell-command-buffer 'rename-buffer)
+       ;; It will rename the buffer.
+       (with-current-buffer output-buffer
+         (rename-uniquely))
+        (setq output-buffer (get-buffer-create bname)))))
+
+    (setq buffer (if (and (not asynchronous) error-buffer)
+                    (with-parsed-tramp-file-name default-directory nil
+                      (list output-buffer (tramp-make-tramp-temp-file v)))
+                  output-buffer))
 
     (if current-buffer-p
        (progn
@@ -3686,20 +3638,28 @@ support symbolic links."
        (erase-buffer)))
 
     (if (and (not current-buffer-p) (integerp asynchronous))
-       (prog1
-           ;; Run the process.
-           (setq p (apply 'start-file-process "*Async Shell*" buffer args))
-         ;; Display output.
-         (with-current-buffer output-buffer
-           (display-buffer output-buffer '(nil (allow-no-window . t)))
-           (setq mode-line-process '(":%s"))
-           (shell-mode)
-           (set-process-sentinel p 'shell-command-sentinel)
-           (set-process-filter p 'comint-output-filter)))
+       (let ((tramp-remote-process-environment
+              ;; `shell-command-width' has been introduced with Emacs 27.1.
+              (if (natnump (bound-and-true-p shell-command-width))
+                  (cons (format "COLUMNS=%d"
+                                (bound-and-true-p shell-command-width))
+                        tramp-remote-process-environment)
+                tramp-remote-process-environment)))
+         (prog1
+             ;; Run the process.
+             (setq p (start-file-process-shell-command
+                      (buffer-name output-buffer) buffer command))
+           ;; Display output.
+           (with-current-buffer output-buffer
+             (display-buffer output-buffer '(nil (allow-no-window . t)))
+             (setq mode-line-process '(":%s"))
+             (shell-mode)
+             (set-process-sentinel p #'shell-command-sentinel)
+             (set-process-filter p #'comint-output-filter))))
 
       (prog1
          ;; Run the process.
-         (apply 'process-file (car args) nil buffer nil (cdr args))
+         (process-file-shell-command command nil buffer nil)
        ;; Insert error messages if they were separated.
        (when (listp buffer)
          (with-current-buffer error-buffer
@@ -3717,6 +3677,17 @@ support symbolic links."
          (when (with-current-buffer output-buffer (> (point-max) (point-min)))
            (display-message-or-buffer output-buffer)))))))
 
+(defun tramp-handle-start-file-process (name buffer program &rest args)
+  "Like `start-file-process' for Tramp files."
+  ;; `make-process' knows the `:file-error' argument since Emacs 27.1.
+  (tramp-file-name-handler
+   'make-process
+   :name name
+   :buffer buffer
+   :command (and program (cons program args))
+   :noquery nil
+   :file-handler t))
+
 (defun tramp-handle-substitute-in-file-name (filename)
   "Like `substitute-in-file-name' for Tramp files.
 \"//\" and \"/~\" substitute only in the local filename part."
@@ -3743,12 +3714,18 @@ support symbolic links."
                           ;; We must disable cygwin-mount file name
                           ;; handlers and alike.
                           (tramp-run-real-handler
-                           'substitute-in-file-name (list localname))))))))
+                           #'substitute-in-file-name (list localname))))))))
       ;; "/m:h:~" does not work for completion.  We use "/m:h:~/".
       (if (and (stringp localname) (string-equal "~" localname))
          (concat filename "/")
        filename))))
 
+(defconst tramp-time-dont-know '(0 0 0 1000)
+  "An invalid time value, used as \"Don’t know\" value.")
+
+(defconst tramp-time-doesnt-exist '(-1 65535)
+  "An invalid time value, used as \"Doesn’t exist\" value.")
+
 (defun tramp-handle-set-visited-file-modtime (&optional time-list)
   "Like `set-visited-file-modtime' for Tramp files."
   (unless (buffer-file-name)
@@ -3761,7 +3738,7 @@ support symbolic links."
                 (file-attributes (buffer-file-name)))
                tramp-time-doesnt-exist))))
   (unless (tramp-compat-time-equal-p time-list tramp-time-dont-know)
-    (tramp-run-real-handler 'set-visited-file-modtime (list time-list))))
+    (tramp-run-real-handler #'set-visited-file-modtime (list time-list))))
 
 (defun tramp-handle-verify-visited-file-modtime (&optional buf)
   "Like `verify-visited-file-modtime' for Tramp files.
@@ -3814,7 +3791,7 @@ of."
       ;; modtime data to be clobbered from the temp file.  We call
       ;; `set-visited-file-modtime' ourselves later on.
       (tramp-run-real-handler
-       'write-region (list start end tmpfile append 'no-message lockname))
+       #'write-region (list start end tmpfile append 'no-message lockname))
       (condition-case nil
          (rename-file tmpfile filename 'ok-if-already-exists)
        (error
@@ -3837,6 +3814,13 @@ of."
       (tramp-message v 0 "Wrote %s" filename))
     (run-hooks 'tramp-handle-write-region-hook)))
 
+;; This is used in tramp-sh.el and tramp-sudoedit.el.
+(defconst tramp-stat-marker "/////"
+  "Marker in stat commands for file attributes.")
+
+(defconst tramp-stat-quoted-marker "\\/\\/\\/\\/\\/"
+  "Quoted marker in stat commands for file attributes.")
+
 ;; This is used in tramp-gvfs.el and tramp-sh.el.
 (defconst tramp-gio-events
   '("attribute-changed" "changed" "changes-done-hint"
@@ -3887,7 +3871,8 @@ of."
     (with-current-buffer (tramp-get-connection-buffer vec)
       (tramp-message vec 6 "\n%s" (buffer-string)))
     (tramp-message vec 3 "Sending login name `%s'" user)
-    (tramp-send-string vec (concat user tramp-local-end-of-line))))
+    (tramp-send-string vec (concat user tramp-local-end-of-line)))
+  t)
 
 (defun tramp-action-password (proc vec)
   "Query the user for a password."
@@ -3903,11 +3888,12 @@ of."
       (tramp-check-for-regexp proc tramp-password-prompt-regexp)
       (tramp-message vec 3 "Sending %s" (match-string 1))
       ;; We don't call `tramp-send-string' in order to hide the
-      ;; password from the debug buffer.
+      ;; password from the debug buffer and the traces.
       (process-send-string
        proc (concat (tramp-read-passwd proc) tramp-local-end-of-line))
       ;; Hide password prompt.
-      (narrow-to-region (point-max) (point-max)))))
+      (narrow-to-region (point-max) (point-max))))
+  t)
 
 (defun tramp-action-succeed (_proc _vec)
   "Signal success in finding shell prompt."
@@ -3930,7 +3916,8 @@ See also `tramp-action-yn'."
        (throw 'tramp-action 'permission-denied))
       (with-current-buffer (tramp-get-connection-buffer vec)
        (tramp-message vec 6 "\n%s" (buffer-string)))
-      (tramp-send-string vec (concat "yes" tramp-local-end-of-line)))))
+      (tramp-send-string vec (concat "yes" tramp-local-end-of-line))))
+  t)
 
 (defun tramp-action-yn (proc vec)
   "Ask the user for confirmation using `y-or-n-p'.
@@ -3944,7 +3931,8 @@ See also `tramp-action-yesno'."
        (throw 'tramp-action 'permission-denied))
       (with-current-buffer (tramp-get-connection-buffer vec)
        (tramp-message vec 6 "\n%s" (buffer-string)))
-      (tramp-send-string vec (concat "y" tramp-local-end-of-line)))))
+      (tramp-send-string vec (concat "y" tramp-local-end-of-line))))
+  t)
 
 (defun tramp-action-terminal (_proc vec)
   "Tell the remote host which terminal type to use.
@@ -3952,7 +3940,8 @@ The terminal type can be configured with 
`tramp-terminal-type'."
   (tramp-message vec 5 "Setting `%s' as terminal type." tramp-terminal-type)
   (with-current-buffer (tramp-get-connection-buffer vec)
     (tramp-message vec 6 "\n%s" (buffer-string)))
-  (tramp-send-string vec (concat tramp-terminal-type tramp-local-end-of-line)))
+  (tramp-send-string vec (concat tramp-terminal-type tramp-local-end-of-line))
+  t)
 
 (defun tramp-action-process-alive (proc _vec)
   "Check, whether a process has finished."
@@ -3962,14 +3951,14 @@ The terminal type can be configured with 
`tramp-terminal-type'."
 (defun tramp-action-out-of-band (proc vec)
   "Check, whether an out-of-band copy has finished."
   ;; There might be pending output for the exit status.
-  (tramp-accept-process-output proc 0.1)
+  (while (tramp-accept-process-output proc 0))
   (cond ((and (not (process-live-p proc))
              (zerop (process-exit-status proc)))
         (tramp-message vec 3 "Process has finished.")
         (throw 'tramp-action 'ok))
        ((or (and (memq (process-status proc) '(stop exit))
                  (not (zerop (process-exit-status proc))))
-            (memq (process-status proc) '(signal)))
+            (eq (process-status proc) 'signal))
         ;; `scp' could have copied correctly, but set modes could have failed.
         ;; This can be ignored.
         (with-current-buffer (process-buffer proc)
@@ -3986,13 +3975,14 @@ The terminal type can be configured with 
`tramp-terminal-type'."
 ;;; Functions for processing the actions:
 
 (defun tramp-process-one-action (proc vec actions)
-  "Wait for output from the shell and perform one action."
+  "Wait for output from the shell and perform one action.
+See `tramp-process-actions' for the format of ACTIONS."
   (let ((case-fold-search t)
        found todo item pattern action)
     (while (not found)
       ;; Reread output once all actions have been performed.
       ;; Obviously, the output was not complete.
-      (tramp-accept-process-output proc 1)
+      (while (tramp-accept-process-output proc 0))
       (setq todo actions)
       (while todo
        (setq item (pop todo))
@@ -4009,7 +3999,27 @@ The terminal type can be configured with 
`tramp-terminal-type'."
   "Perform ACTIONS until success or TIMEOUT.
 PROC and VEC indicate the remote connection to be used.  POS, if
 set, is the starting point of the region to be deleted in the
-connection buffer."
+connection buffer.
+
+ACTIONS is a list of (PATTERN ACTION).  The PATTERN should be a
+symbol, a variable.  The value of this variable gives the regular
+expression to search for.  Note that the regexp must match at the
+end of the buffer, \"\\'\" is implicitly appended to it.
+
+The ACTION should also be a symbol, but a function.  When the
+corresponding PATTERN matches, the ACTION function is called.
+
+An ACTION function has two arguments (PROC VEC).  If it returns
+nil, nothing has been done, and the next action shall be called.
+A non-nil return value indicates that the process output has been
+consumed, and new output shall be retrieved, before starting to
+process all ACTIONs, again.  The same happens after calling the
+last ACTION.
+
+If an action determines, that all processing has been done (e.g.,
+because the shell prompt has been detected), it shall throw a
+result.  The symbol `ok' means that all ACTIONs have been
+performed successfully.  Any other value means an error."
   ;; Enable `auth-source', unless "emacs -Q" has been called.  We must
   ;; use the "password-vector" property in case we have several hops.
   (tramp-set-connection-property
@@ -4059,28 +4069,36 @@ connection buffer."
            (t "Login failed")))))
       (when (numberp pos)
        (with-current-buffer (tramp-get-connection-buffer vec)
-         (let (buffer-read-only) (delete-region pos (point))))))))
+         (let ((inhibit-read-only t)) (delete-region pos (point))))))))
 
 ;;; Utility functions:
 
-(defun tramp-accept-process-output (proc timeout)
+(defun tramp-accept-process-output (proc &optional timeout)
   "Like `accept-process-output' for Tramp processes.
 This is needed in order to hide `last-coding-system-used', which is set
 for process communication also."
   (with-current-buffer (process-buffer proc)
-    (let (buffer-read-only last-coding-system-used
+    (let ((inhibit-read-only t)
+         last-coding-system-used
          ;; We do not want to run timers.
-         timer-list timer-idle-list)
-      ;; Under Windows XP, `accept-process-output' doesn't return
-      ;; sometimes.  So we add an additional timeout.  JUST-THIS-ONE
-      ;; is set due to Bug#12145.  It is an integer, in order to avoid
-      ;; running timers as well.
+         (tl timer-list)
+          (stimers (with-timeout-suspend))
+         timer-list timer-idle-list
+         result)
+      ;; Enable our progress reporter.
+      (dolist (timer tl)
+       (if (eq (timer--function timer) #'tramp-progress-reporter-update)
+            (push timer timer-list)))
+      ;; JUST-THIS-ONE is set due to Bug#12145.
       (tramp-message
-       proc 10 "%s %s %s\n%s"
-       proc (process-status proc)
-       (with-timeout (timeout)
-        (accept-process-output proc timeout nil 0))
-       (buffer-string)))))
+       proc 10 "%s %s %s %s\n%s"
+       proc timeout (process-status proc)
+       (with-local-quit
+        (setq result (accept-process-output proc timeout nil t)))
+       (buffer-string))
+      ;; Reenable the timers.
+      (with-timeout-unsuspend stimers)
+      result)))
 
 (defun tramp-check-for-regexp (proc regexp)
   "Check, whether REGEXP is contained in process buffer of PROC.
@@ -4128,20 +4146,20 @@ nil."
       (cond (timeout
             (with-timeout (timeout)
               (while (not found)
-                (tramp-accept-process-output proc 1)
+                (tramp-accept-process-output proc)
                 (unless (process-live-p proc)
                   (tramp-error-with-buffer
                    nil proc 'file-error "Process has died"))
                 (setq found (tramp-check-for-regexp proc regexp)))))
            (t
             (while (not found)
-              (tramp-accept-process-output proc 1)
+              (tramp-accept-process-output proc)
               (unless (process-live-p proc)
                 (tramp-error-with-buffer
                  nil proc 'file-error "Process has died"))
               (setq found (tramp-check-for-regexp proc regexp)))))
       (tramp-message proc 6 "\n%s" (buffer-string))
-      (when (not found)
+      (unless found
        (if timeout
            (tramp-error
             proc 'file-error "[[Regexp `%s' not found in %d secs]]"
@@ -4160,35 +4178,59 @@ The STRING is expected to use Unix line-endings, but 
the lines sent to
 the remote host use line-endings as defined in the variable
 `tramp-rsh-end-of-line'.  The communication buffer is erased before sending."
   (let* ((p (tramp-get-connection-process vec))
-        (chunksize (tramp-get-connection-property p "chunksize" nil)))
+        (chunksize (tramp-get-connection-property p "chunksize" nil))
+        ;; We do not want to run timers.
+        (tl timer-list)
+         (stimers (with-timeout-suspend))
+        timer-list timer-idle-list)
     (unless p
       (tramp-error
        vec 'file-error "Can't send string to remote host -- not logged in"))
     (tramp-set-connection-property p "last-cmd-time" (current-time))
     (tramp-message vec 10 "%s" string)
+    ;; Enable our progress reporter.
+    (dolist (timer tl)
+      (if (eq (timer--function timer) #'tramp-progress-reporter-update)
+          (push timer timer-list)))
     (with-current-buffer (tramp-get-connection-buffer vec)
       ;; Clean up the buffer.  We cannot call `erase-buffer' because
       ;; narrowing might be in effect.
-      (let (buffer-read-only) (delete-region (point-min) (point-max)))
+      (let ((inhibit-read-only t)) (delete-region (point-min) (point-max)))
       ;; Replace "\n" by `tramp-rsh-end-of-line'.
       (setq string
            (mapconcat
-            'identity (split-string string "\n") tramp-rsh-end-of-line))
+            #'identity (split-string string "\n") tramp-rsh-end-of-line))
       (unless (or (string= string "")
                  (string-equal (substring string -1) tramp-rsh-end-of-line))
        (setq string (concat string tramp-rsh-end-of-line)))
       ;; Send the string.
-      (if (and chunksize (not (zerop chunksize)))
-         (let ((pos 0)
-               (end (length string)))
-           (while (< pos end)
-             (tramp-message
-              vec 10 "Sending chunk from %s to %s"
-              pos (min (+ pos chunksize) end))
-             (process-send-string
-              p (substring string pos (min (+ pos chunksize) end)))
-             (setq pos (+ pos chunksize))))
-       (process-send-string p string)))))
+      (with-local-quit
+       (if (and chunksize (not (zerop chunksize)))
+           (let ((pos 0)
+                 (end (length string)))
+             (while (< pos end)
+               (tramp-message
+                vec 10 "Sending chunk from %s to %s"
+                pos (min (+ pos chunksize) end))
+               (process-send-string
+                p (substring string pos (min (+ pos chunksize) end)))
+               (setq pos (+ pos chunksize))))
+         (process-send-string p string)))
+      ;; Reenable the timers.
+      (with-timeout-unsuspend stimers))))
+
+(defun tramp-process-sentinel (proc event)
+  "Flush file caches and remove shell prompt."
+  (unless (process-live-p proc)
+    (let ((vec (process-get proc 'vector))
+         (prompt (tramp-get-connection-property proc "prompt" nil)))
+      (when vec
+       (tramp-message vec 5 "Sentinel called: `%S' `%s'" proc event)
+        (tramp-flush-connection-properties proc)
+        (tramp-flush-directory-properties vec ""))
+      (goto-char (point-max))
+      (when (and prompt (re-search-backward (regexp-quote prompt) nil t))
+       (delete-region (point) (point-max))))))
 
 (defun tramp-get-inode (vec)
   "Returns the virtual inode number.
@@ -4221,7 +4263,6 @@ would yield t.  On the other hand, the following check 
results in nil:
        (tramp-tramp-file-p file2)
        (string-equal (file-remote-p file1) (file-remote-p file2))))
 
-;;;###tramp-autoload
 (defun tramp-mode-string-to-int (mode-string)
   "Converts a ten-letter `drwxrwxrwx'-style mode string into mode bits."
   (let* (case-fold-search
@@ -4237,47 +4278,47 @@ would yield t.  On the other hand, the following check 
results in nil:
          (other-execute-or-sticky (aref mode-chars 9)))
     (logior
      (cond
-      ((char-equal owner-read ?r) (string-to-number "00400" 8))
+      ((char-equal owner-read ?r) #o0400)
       ((char-equal owner-read ?-) 0)
       (t (error "Second char `%c' must be one of `r-'" owner-read)))
      (cond
-      ((char-equal owner-write ?w) (string-to-number "00200" 8))
+      ((char-equal owner-write ?w) #o0200)
       ((char-equal owner-write ?-) 0)
       (t (error "Third char `%c' must be one of `w-'" owner-write)))
      (cond
-      ((char-equal owner-execute-or-setid ?x) (string-to-number "00100" 8))
-      ((char-equal owner-execute-or-setid ?S) (string-to-number "04000" 8))
-      ((char-equal owner-execute-or-setid ?s) (string-to-number "04100" 8))
+      ((char-equal owner-execute-or-setid ?x) #o0100)
+      ((char-equal owner-execute-or-setid ?S) #o4000)
+      ((char-equal owner-execute-or-setid ?s) #o4100)
       ((char-equal owner-execute-or-setid ?-) 0)
       (t (error "Fourth char `%c' must be one of `xsS-'"
                owner-execute-or-setid)))
      (cond
-      ((char-equal group-read ?r) (string-to-number "00040" 8))
+      ((char-equal group-read ?r) #o0040)
       ((char-equal group-read ?-) 0)
       (t (error "Fifth char `%c' must be one of `r-'" group-read)))
      (cond
-      ((char-equal group-write ?w) (string-to-number "00020" 8))
+      ((char-equal group-write ?w) #o0020)
       ((char-equal group-write ?-) 0)
       (t (error "Sixth char `%c' must be one of `w-'" group-write)))
      (cond
-      ((char-equal group-execute-or-setid ?x) (string-to-number "00010" 8))
-      ((char-equal group-execute-or-setid ?S) (string-to-number "02000" 8))
-      ((char-equal group-execute-or-setid ?s) (string-to-number "02010" 8))
+      ((char-equal group-execute-or-setid ?x) #o0010)
+      ((char-equal group-execute-or-setid ?S) #o2000)
+      ((char-equal group-execute-or-setid ?s) #o2010)
       ((char-equal group-execute-or-setid ?-) 0)
       (t (error "Seventh char `%c' must be one of `xsS-'"
                group-execute-or-setid)))
      (cond
-      ((char-equal other-read ?r) (string-to-number "00004" 8))
+      ((char-equal other-read ?r) #o0004)
       ((char-equal other-read ?-) 0)
       (t (error "Eighth char `%c' must be one of `r-'" other-read)))
      (cond
-      ((char-equal other-write ?w) (string-to-number "00002" 8))
+      ((char-equal other-write ?w) #o0002)
       ((char-equal other-write ?-) 0)
       (t (error "Ninth char `%c' must be one of `w-'" other-write)))
      (cond
-      ((char-equal other-execute-or-sticky ?x) (string-to-number "00001" 8))
-      ((char-equal other-execute-or-sticky ?T) (string-to-number "01000" 8))
-      ((char-equal other-execute-or-sticky ?t) (string-to-number "01001" 8))
+      ((char-equal other-execute-or-sticky ?x) #o0001)
+      ((char-equal other-execute-or-sticky ?T) #o1000)
+      ((char-equal other-execute-or-sticky ?t) #o1001)
       ((char-equal other-execute-or-sticky ?-) 0)
       (t (error "Tenth char `%c' must be one of `xtT-'"
                other-execute-or-sticky))))))
@@ -4301,7 +4342,6 @@ would yield t.  On the other hand, the following check 
results in nil:
   "A list of file types returned from the `stat' system call.
 This is used to map a mode number to a permission string.")
 
-;;;###tramp-autoload
 (defun tramp-file-mode-from-int (mode)
   "Turn an integer representing a file mode into an ls(1)-like string."
   (let ((type  (cdr
@@ -4329,24 +4369,53 @@ This is used internally by `tramp-file-mode-from-int'."
                (and suid (upcase suid-text)) ; suid, !execute
                (and x "x") "-"))))     ; !suid
 
-;;;###tramp-autoload
+;; This is a Tramp internal function.  A general `set-file-uid-gid'
+;; outside Tramp is not needed, I believe.
+(defun tramp-set-file-uid-gid (filename &optional uid gid)
+  "Set the ownership for FILENAME.
+If UID and GID are provided, these values are used; otherwise uid
+and gid of the corresponding remote or local user is taken,
+depending whether FILENAME is remote or local.  Both parameters
+must be non-negative integers.
+The setgid bit of the upper directory is respected.
+If FILENAME is remote, a file name handler is called."
+  (let* ((dir (file-name-directory filename))
+        (modes (file-modes dir)))
+    (when (and modes (not (zerop (logand modes #o2000))))
+      (setq gid (tramp-compat-file-attribute-group-id (file-attributes dir)))))
+
+  (let ((handler (find-file-name-handler filename 'tramp-set-file-uid-gid)))
+    (if handler
+       (funcall handler #'tramp-set-file-uid-gid filename uid gid)
+      ;; On W32 "chown" does not work.
+      (unless (memq system-type '(ms-dos windows-nt))
+       (let ((uid (or (and (natnump uid) uid) (tramp-get-local-uid 'integer)))
+             (gid (or (and (natnump gid) gid) (tramp-get-local-gid 'integer))))
+         (tramp-call-process
+          nil "chown" nil nil nil
+          (format "%d:%d" uid gid) (shell-quote-argument filename)))))))
+
 (defun tramp-get-local-uid (id-format)
   "The uid of the local user, in ID-FORMAT.
 ID-FORMAT valid values are `string' and `integer'."
-  (if (equal id-format 'integer) (user-uid) (user-login-name)))
+  ;; We use key nil for local connection properties.
+  (with-tramp-connection-property nil (format "uid-%s" id-format)
+    (if (equal id-format 'integer) (user-uid) (user-login-name))))
 
-;;;###tramp-autoload
 (defun tramp-get-local-gid (id-format)
   "The gid of the local user, in ID-FORMAT.
 ID-FORMAT valid values are `string' and `integer'."
-  (cond
-   ;; `group-gid' has been introduced with Emacs 24.4.
-   ((and (fboundp 'group-gid) (equal id-format 'integer))
-    (tramp-compat-funcall 'group-gid))
-   ;; `group-name' has been introduced with Emacs 27.1.
-   ((and (fboundp 'group-name) (equal id-format 'string))
-    (tramp-compat-funcall 'group-name (tramp-compat-funcall 'group-gid)))
-   ((tramp-compat-file-attribute-group-id (file-attributes "~/" id-format)))))
+  ;; We use key nil for local connection properties.
+  (with-tramp-connection-property nil (format "gid-%s" id-format)
+    (cond
+     ;; `group-gid' has been introduced with Emacs 24.4.
+     ((and (fboundp 'group-gid) (equal id-format 'integer))
+      (tramp-compat-funcall 'group-gid))
+     ;; `group-name' has been introduced with Emacs 27.1.
+     ((and (fboundp 'group-name) (equal id-format 'string))
+      (tramp-compat-funcall 'group-name (tramp-compat-funcall 'group-gid)))
+     ((tramp-compat-file-attribute-group-id
+       (file-attributes "~/" id-format))))))
 
 (defun tramp-get-local-locale (&optional vec)
   "Determine locale, supporting UTF8 if possible.
@@ -4371,7 +4440,6 @@ VEC is used for tracing."
       (when vec (tramp-message vec 7 "locale %s" (or locale "C")))
       (or locale "C"))))
 
-;;;###tramp-autoload
 (defun tramp-check-cached-permissions (vec access)
   "Check `file-attributes' caches for VEC.
 Return t if according to the cache access type ACCESS is known to
@@ -4432,7 +4500,6 @@ be granted."
                        (tramp-compat-file-attribute-group-id
                         file-attr))))))))))))
 
-;;;###tramp-autoload
 (defun tramp-local-host-p (vec)
   "Return t if this points to the local host, nil otherwise.
 This handles also chrooted environments, which are not regarded as local."
@@ -4468,7 +4535,6 @@ This handles also chrooted environments, which are not 
regarded as local."
          (tramp-error vec 'file-error "Directory %s not accessible" dir))
       dir)))
 
-;;;###tramp-autoload
 (defun tramp-make-tramp-temp-file (vec)
   "Create a temporary file on the remote host identified by VEC.
 Return the local name of the temporary file."
@@ -4485,7 +4551,7 @@ Return the local name of the temporary file."
          (setq result nil)
        ;; This creates the file by side effect.
        (set-file-times result)
-       (set-file-modes result (string-to-number "0700" 8))))
+       (set-file-modes result #o0700)))
 
     ;; Return the local part.
     (with-parsed-tramp-file-name result nil localname)))
@@ -4495,11 +4561,11 @@ Return the local name of the temporary file."
   (when (stringp tramp-temp-buffer-file-name)
     (ignore-errors (delete-file tramp-temp-buffer-file-name))))
 
-(add-hook 'kill-buffer-hook 'tramp-delete-temp-file-function)
+(add-hook 'kill-buffer-hook #'tramp-delete-temp-file-function)
 (add-hook 'tramp-unload-hook
          (lambda ()
            (remove-hook 'kill-buffer-hook
-                        'tramp-delete-temp-file-function)))
+                        #'tramp-delete-temp-file-function)))
 
 (defun tramp-handle-make-auto-save-file-name ()
   "Like `make-auto-save-file-name' for Tramp files.
@@ -4535,7 +4601,7 @@ this file, if that variable is non-nil."
             (tramp-compat-file-name-unquote (buffer-file-name)))
            tramp-auto-save-directory))))
     ;; Run plain `make-auto-save-file-name'.
-    (tramp-run-real-handler 'make-auto-save-file-name nil)))
+    (tramp-run-real-handler #'make-auto-save-file-name nil)))
 
 (defun tramp-subst-strs-in-string (alist string)
   "Replace all occurrences of the string FROM with TO in STRING.
@@ -4576,15 +4642,16 @@ PROGRAM is nil is trapped also, returning 1.  
Furthermore, traces
 are written with verbosity of 6."
   (let ((default-directory (tramp-compat-temporary-file-directory))
        (destination (if (eq destination t) (current-buffer) destination))
+       (vec (or vec (car tramp-current-connection)))
        output error result)
     (tramp-message
      vec 6 "`%s %s' %s %s"
-     program (mapconcat 'identity args " ") infile destination)
+     program (mapconcat #'identity args " ") infile destination)
     (condition-case err
        (with-temp-buffer
          (setq result
                (apply
-                'call-process program infile (or destination t) display args))
+                #'call-process program infile (or destination t) display args))
          ;; `result' could also be an error string.
          (when (stringp result)
            (setq error result
@@ -4606,17 +4673,17 @@ are written with verbosity of 6."
 It always returns a return code.  The Lisp error raised when
 PROGRAM is nil is trapped also, returning 1.  Furthermore, traces
 are written with verbosity of 6."
-  (let ((default-directory  (tramp-compat-temporary-file-directory))
+  (let ((default-directory (tramp-compat-temporary-file-directory))
        (buffer (if (eq buffer t) (current-buffer) buffer))
        result)
     (tramp-message
      vec 6 "`%s %s' %s %s %s %s"
-     program (mapconcat 'identity args " ") start end delete buffer)
+     program (mapconcat #'identity args " ") start end delete buffer)
     (condition-case err
        (progn
          (setq result
                (apply
-                'call-process-region
+                #'call-process-region
                 start end program delete buffer display args))
          ;; `result' could also be an error string.
          (when (stringp result)
@@ -4630,7 +4697,25 @@ are written with verbosity of 6."
        (tramp-message vec 6 "%d\n%s" result (error-message-string err))))
     result))
 
-;;;###tramp-autoload
+(defun tramp-process-lines
+  (vec program &rest args)
+  "Calls `process-lines' on the local host.
+If an error occurs, it returns nil.  Traces are written with
+verbosity of 6."
+  (let ((default-directory (tramp-compat-temporary-file-directory))
+       (vec (or vec (car tramp-current-connection)))
+       result)
+    (if args
+       (tramp-message vec 6 "%s %s" program (mapconcat #'identity args " "))
+      (tramp-message vec 6 "%s" program))
+    (setq result
+         (condition-case err
+             (apply #'process-lines program args)
+           (error
+            (tramp-error vec (car err) (cdr err)))))
+    (tramp-message vec 6 "%s" result)
+    result))
+
 (defun tramp-read-passwd (proc &optional prompt)
   "Read a password from user (compat function).
 Consults the auth-source package.
@@ -4703,7 +4788,6 @@ Invokes `password-read' if available, `read-passwd' else."
       ;; Reenable the timers.
       (with-timeout-unsuspend stimers))))
 
-;;;###tramp-autoload
 (defun tramp-clear-passwd (vec)
   "Clear password cache for connection related to VEC."
   (let ((method (tramp-file-name-method vec))
@@ -4718,15 +4802,6 @@ Invokes `password-read' if available, `read-passwd' 
else."
        :host ,host-port :port ,method))
     (password-cache-remove (tramp-make-tramp-file-name vec 'noloc 'nohop))))
 
-;;;###tramp-autoload
-(defconst tramp-time-dont-know '(0 0 0 1000)
-  "An invalid time value, used as \"Don’t know\" value.")
-
-;;;###tramp-autoload
-(defconst tramp-time-doesnt-exist '(-1 65535)
-  "An invalid time value, used as \"Doesn’t exist\" value.")
-
-;;;###tramp-autoload
 (defun tramp-time-diff (t1 t2)
   "Return the difference between the two times, in seconds.
 T1 and T2 are time values (as returned by `current-time' for example)."
@@ -4757,7 +4832,6 @@ T1 and T2 are time values (as returned by `current-time' 
for example)."
 ;;
 ;; Thanks to Mario DeWeerd for the hint that it is sufficient for this
 ;; function to work with Bourne-like shells.
-;;;###tramp-autoload
 (defun tramp-shell-quote-argument (s)
   "Similar to `shell-quote-argument', but groks newlines.
 Only works for Bourne-like shells."
@@ -4789,7 +4863,7 @@ Only works for Bourne-like shells."
        pid)
     ;; If it's a Tramp process, send the INT signal remotely.
     (when (and (processp proc) (setq pid (process-get proc 'remote-pid)))
-      (if (not  (process-live-p proc))
+      (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).
@@ -4800,44 +4874,17 @@ Only works for Bourne-like shells."
        ;; Wait, until the process has disappeared.  If it doesn't,
        ;; fall back to the default implementation.
        (with-timeout (1 (ignore))
-         (while (process-live-p proc)
-           ;; We cannot run `tramp-accept-process-output', it blocks timers.
-           (accept-process-output proc 0.1))
+         (while (tramp-accept-process-output proc))
          ;; Report success.
          proc)))))
 
 ;; `interrupt-process-functions' exists since Emacs 26.1.
 (when (boundp 'interrupt-process-functions)
-  (add-hook 'interrupt-process-functions 'tramp-interrupt-process)
+  (add-hook 'interrupt-process-functions #'tramp-interrupt-process)
   (add-hook
    'tramp-unload-hook
    (lambda ()
-     (remove-hook 'interrupt-process-functions 'tramp-interrupt-process))))
-
-;;; Integration of eshell.el:
-
-;; eshell.el keeps the path in `eshell-path-env'.  We must change it
-;; when `default-directory' points to another host.
-(defun tramp-eshell-directory-change ()
-  "Set `eshell-path-env' to $PATH of the host related to `default-directory'."
-  ;; Remove last element of `(exec-path)', which is `exec-directory'.
-  ;; Use `path-separator' as it does eshell.
-  (setq eshell-path-env
-       (mapconcat
-        'identity (butlast (tramp-compat-exec-path)) path-separator)))
-
-(eval-after-load "esh-util"
-  '(progn
-     (add-hook 'eshell-mode-hook
-              'tramp-eshell-directory-change)
-     (add-hook 'eshell-directory-change-hook
-              'tramp-eshell-directory-change)
-     (add-hook 'tramp-unload-hook
-              (lambda ()
-                (remove-hook 'eshell-mode-hook
-                             'tramp-eshell-directory-change)
-                (remove-hook 'eshell-directory-change-hook
-                             'tramp-eshell-directory-change)))))
+     (remove-hook 'interrupt-process-functions #'tramp-interrupt-process))))
 
 ;; Checklist for `tramp-unload-hook'
 ;; - Unload all `tramp-*' packages
@@ -4849,13 +4896,16 @@ Only works for Bourne-like shells."
 (defun tramp-unload-tramp ()
   "Discard Tramp from loading remote files."
   (interactive)
-  ;; ange-ftp settings must be enabled.
+  ;; ange-ftp settings must be re-enabled.
   (tramp-compat-funcall 'tramp-ftp-enable-ange-ftp)
   ;; Maybe it's not loaded yet.
   (ignore-errors (unload-feature 'tramp 'force)))
 
 (provide 'tramp)
 
+(run-hooks 'tramp--startup-hook)
+(setq tramp--startup-hook nil)
+
 ;;; TODO:
 ;;
 ;; * Avoid screen blanking when hitting `g' in dired.  (Eli Tziperman)
@@ -4878,6 +4928,12 @@ Only works for Bourne-like shells."
 ;;   and friends, for most of the handlers this is the major
 ;;   difference between the different backends.  Other handlers but
 ;;   *-process-file would profit from this as well.
+;;
+;; * Get rid of `shell-command'.  In its primary implementation, it
+;;   uses `process-file-shell-command' and
+;;   `start-file-process-shell-command', which is sufficient due to
+;;   connection-local `shell-file-name'.
+
 
 ;;; tramp.el ends here
 
diff --git a/lisp/net/trampver.el b/lisp/net/trampver.el
index b8684da..83d34c0 100644
--- a/lisp/net/trampver.el
+++ b/lisp/net/trampver.el
@@ -1,7 +1,7 @@
 ;;; trampver.el --- Transparent Remote Access, Multiple Protocol  -*- 
lexical-binding:t -*-
 ;;; lisp/trampver.el.  Generated from trampver.el.in by configure.
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author: Kai Großjohann <address@hidden>
 ;; Maintainer: Michael Albinus <address@hidden>
@@ -31,7 +31,7 @@
 ;; aclocal.m4; should be changed only there.
 
 ;;;###tramp-autoload
-(defconst tramp-version "2.4.1-pre"
+(defconst tramp-version "2.4.2-pre"
   "This version of Tramp.")
 
 ;;;###tramp-autoload
@@ -65,7 +65,7 @@
 ;; Check for Emacs version.
 (let ((x   (if (not (string-lessp emacs-version "24.1"))
       "ok"
-    (format "Tramp 2.4.1-pre is not fit for %s"
+    (format "Tramp 2.4.2-pre is not fit for %s"
             (replace-regexp-in-string "\n" "" (emacs-version))))))
   (unless (string-equal "ok" x) (error "%s" x)))
 
diff --git a/lisp/net/webjump.el b/lisp/net/webjump.el
index da6e597..e297b9d 100644
--- a/lisp/net/webjump.el
+++ b/lisp/net/webjump.el
@@ -1,6 +1,6 @@
 ;;; webjump.el --- programmable Web hotlist
 
-;; Copyright (C) 1996-1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author:    Neil W. Van Dyke <address@hidden>
 ;; Created:   09-Aug-1996
@@ -342,7 +342,7 @@ Please submit bug reports and other feedback to the author, 
Neil W. Van Dyke
   (mapconcat (lambda (c)
                (let ((s (char-to-string c)))
                  (cond ((string= s " ") "+")
-                       ((string-match "[a-zA-Z_.-/]" s) s)
+                      ((string-match "[a-zA-Z_./~-]" s) s)
                        (t (upcase (format "%%%02x" c))))))
              (encode-coding-string str 'utf-8)
              ""))
diff --git a/lisp/net/zeroconf.el b/lisp/net/zeroconf.el
index 25a8dea..36643a8 100644
--- a/lisp/net/zeroconf.el
+++ b/lisp/net/zeroconf.el
@@ -1,6 +1,6 @@
 ;;; zeroconf.el --- Service browser using Avahi.  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 ;; Keywords: comm, hardware
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index cd72266..9d919cc 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -1,6 +1,6 @@
 ;;; newcomment.el --- (un)comment regions of buffers -*- lexical-binding: t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: code extracted from Emacs-20's simple.el
 ;; Maintainer: Stefan Monnier <address@hidden>
@@ -327,11 +327,11 @@ behavior for explicit filling, you might as well use 
\\[newline-and-indent]."
 (defcustom comment-empty-lines nil
   "If nil, `comment-region' does not comment out empty lines.
 If t, it always comments out empty lines.
-If `eol' it only comments out empty lines if comments are
-terminated by the end of line (i.e. `comment-end' is empty)."
+If `eol', it only comments out empty lines if comments are
+terminated by the end of line (i.e., `comment-end' is empty)."
   :type '(choice (const :tag "Never" nil)
-         (const :tag "Always" t)
-         (const :tag "EOl-terminated" eol))
+                 (const :tag "Always" t)
+                 (const :tag "EOL-terminated" eol))
   :group 'comment)
 
 ;;;;
diff --git a/lisp/notifications.el b/lisp/notifications.el
index 2358b52..1d250e2 100644
--- a/lisp/notifications.el
+++ b/lisp/notifications.el
@@ -1,6 +1,6 @@
 ;;; notifications.el --- Client interface to desktop notifications.
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Julien Danjou <address@hidden>
 ;; Keywords: comm desktop notifications
diff --git a/lisp/novice.el b/lisp/novice.el
index aaad4fa..3da4e25 100644
--- a/lisp/novice.el
+++ b/lisp/novice.el
@@ -1,6 +1,6 @@
 ;;; novice.el --- handling of disabled commands ("novice mode") for Emacs
 
-;; Copyright (C) 1985-1987, 1994, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1985-1987, 1994, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/nxml/nxml-enc.el b/lisp/nxml/nxml-enc.el
index 596dbe7..cf8bacc 100644
--- a/lisp/nxml/nxml-enc.el
+++ b/lisp/nxml/nxml-enc.el
@@ -1,6 +1,6 @@
 ;;; nxml-enc.el --- XML encoding auto-detection  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML
diff --git a/lisp/nxml/nxml-maint.el b/lisp/nxml/nxml-maint.el
index daa7fd5..2956efb 100644
--- a/lisp/nxml/nxml-maint.el
+++ b/lisp/nxml/nxml-maint.el
@@ -1,6 +1,6 @@
 ;;; nxml-maint.el --- commands for maintainers of nxml-*.el  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML
@@ -34,10 +34,10 @@
   (let (lst head)
     (with-current-buffer (find-file-noselect file)
       (goto-char (point-min))
-      (while (re-search-forward "^ *\\([a-FA-F0-9]\\{2\\}\\)[ \t]+" nil t)
+      (while (re-search-forward "^ *\\([a-fA-F0-9]\\{2\\}\\)[ \t]+" nil t)
        (let ((row (match-string 1))
              (eol (line-end-position)))
-         (while (re-search-forward 
"\\([a-FA-F0-9]\\{2\\}\\)-\\([a-FA-F0-9]\\{2\\}\\)\\|\\([a-FA-F0-9]\\{2\\}\\)" 
eol t)
+         (while (re-search-forward 
"\\([a-fA-F0-9]\\{2\\}\\)-\\([a-fA-F0-9]\\{2\\}\\)\\|\\([a-fA-F0-9]\\{2\\}\\)" 
eol t)
            (setq lst
                  (cons (if (match-beginning 3)
                            (concat "#x" row (match-string 3))
diff --git a/lisp/nxml/nxml-mode.el b/lisp/nxml/nxml-mode.el
index e2b51bc..6f80912 100644
--- a/lisp/nxml/nxml-mode.el
+++ b/lisp/nxml/nxml-mode.el
@@ -1,6 +1,6 @@
 ;;; nxml-mode.el --- a new XML mode  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2003-2004, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2004, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML
diff --git a/lisp/nxml/nxml-ns.el b/lisp/nxml/nxml-ns.el
index 141ce12..c07ae7f 100644
--- a/lisp/nxml/nxml-ns.el
+++ b/lisp/nxml/nxml-ns.el
@@ -1,6 +1,6 @@
 ;;; nxml-ns.el --- XML namespace processing  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML
diff --git a/lisp/nxml/nxml-outln.el b/lisp/nxml/nxml-outln.el
index 5bb930f..f62535c 100644
--- a/lisp/nxml/nxml-outln.el
+++ b/lisp/nxml/nxml-outln.el
@@ -1,6 +1,6 @@
 ;;; nxml-outln.el --- outline support for nXML mode  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2004, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML
diff --git a/lisp/nxml/nxml-parse.el b/lisp/nxml/nxml-parse.el
index 7b8c691..507b6bd 100644
--- a/lisp/nxml/nxml-parse.el
+++ b/lisp/nxml/nxml-parse.el
@@ -1,6 +1,6 @@
 ;;; nxml-parse.el --- XML parser, sharing infrastructure with nxml-mode  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML
diff --git a/lisp/nxml/nxml-rap.el b/lisp/nxml/nxml-rap.el
index 2578492..2bd758b 100644
--- a/lisp/nxml/nxml-rap.el
+++ b/lisp/nxml/nxml-rap.el
@@ -1,6 +1,6 @@
 ;;; nxml-rap.el --- low-level support for random access parsing for nXML mode  
-*- lexical-binding:t -*-
 
-;; Copyright (C) 2003-2004, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2004, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML
diff --git a/lisp/nxml/nxml-util.el b/lisp/nxml/nxml-util.el
index 03e0f47..988945d 100644
--- a/lisp/nxml/nxml-util.el
+++ b/lisp/nxml/nxml-util.el
@@ -1,6 +1,6 @@
 ;;; nxml-util.el --- utility functions for nxml-*.el  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML
diff --git a/lisp/nxml/rng-cmpct.el b/lisp/nxml/rng-cmpct.el
index a433dbb..d36f9d9 100644
--- a/lisp/nxml/rng-cmpct.el
+++ b/lisp/nxml/rng-cmpct.el
@@ -1,6 +1,6 @@
 ;;; rng-cmpct.el --- parsing of RELAX NG Compact Syntax schemas  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML, RelaxNG
diff --git a/lisp/nxml/rng-dt.el b/lisp/nxml/rng-dt.el
index 10aad72..414ed95 100644
--- a/lisp/nxml/rng-dt.el
+++ b/lisp/nxml/rng-dt.el
@@ -1,6 +1,6 @@
 ;;; rng-dt.el --- datatype library interface for RELAX NG  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML, RelaxNG
diff --git a/lisp/nxml/rng-loc.el b/lisp/nxml/rng-loc.el
index 75d9831..db4f6e4 100644
--- a/lisp/nxml/rng-loc.el
+++ b/lisp/nxml/rng-loc.el
@@ -1,6 +1,6 @@
 ;;; rng-loc.el --- Locate the schema to use for validation  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML, RelaxNG
diff --git a/lisp/nxml/rng-maint.el b/lisp/nxml/rng-maint.el
index 2b7d9cc..56fbf12 100644
--- a/lisp/nxml/rng-maint.el
+++ b/lisp/nxml/rng-maint.el
@@ -1,6 +1,6 @@
 ;;; rng-maint.el --- commands for RELAX NG maintainers  -*- lexical-binding:t 
-*-
 
-;; Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML, RelaxNG
@@ -228,8 +228,7 @@
   (let* ((start (current-time))
         (val (apply function args)))
     (message "%s ran in %g seconds"
-            function
-            (float-time (time-subtract nil start)))
+            function (float-time (time-since start)))
     val))
 
 (defun rng-time-tokenize-buffer ()
diff --git a/lisp/nxml/rng-match.el b/lisp/nxml/rng-match.el
index d427af9..dcddb53 100644
--- a/lisp/nxml/rng-match.el
+++ b/lisp/nxml/rng-match.el
@@ -1,6 +1,6 @@
 ;;; rng-match.el --- matching of RELAX NG patterns against XML events  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML, RelaxNG
diff --git a/lisp/nxml/rng-nxml.el b/lisp/nxml/rng-nxml.el
index 1b3a5bb..05b5931 100644
--- a/lisp/nxml/rng-nxml.el
+++ b/lisp/nxml/rng-nxml.el
@@ -1,6 +1,6 @@
 ;;; rng-nxml.el --- make nxml-mode take advantage of rng-validate-mode  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML, RelaxNG
@@ -160,7 +160,7 @@ Validation will be enabled if `rng-nxml-auto-validate-flag' 
is non-nil."
       (and rng-collecting-text (rng-flush-text))
       (let ((target-names (rng-match-possible-start-tag-names)))
         `(,(1+ lt-pos)
-          ,(save-excursion (skip-chars-forward "[[:alnum:]_.-:]") (point))
+          ,(save-excursion (skip-chars-forward "-[:alnum:]_.:") (point))
           ,(apply-partially #'rng-complete-qname-function
                             target-names nil extra-strings)
           :exit-function
@@ -207,7 +207,7 @@ Validation will be enabled if `rng-nxml-auto-validate-flag' 
is non-nil."
                              (cdar rng-open-elements))
                    (cdar rng-open-elements))))
              `(,(+ (match-beginning 0) 2)
-               ,(save-excursion (skip-chars-forward "[[:alnum:]_.-:]") (point))
+               ,(save-excursion (skip-chars-forward "-[:alnum:]_.:") (point))
                ,(list start-tag-name)   ;Sole completion candidate.
                :exit-function
                ,(lambda (_completion status)
@@ -247,7 +247,7 @@ Validation will be enabled if `rng-nxml-auto-validate-flag' 
is non-nil."
                              "xmlns"))
                          rng-undeclared-prefixes)))
              `(,attribute-start
-               ,(save-excursion (skip-chars-forward "[[:alnum:]_.-:]") (point))
+               ,(save-excursion (skip-chars-forward "-[:alnum:]_.:") (point))
                ,(apply-partially #'rng-complete-qname-function
                                  target-names t extra-strings)
                :exit-function
diff --git a/lisp/nxml/rng-parse.el b/lisp/nxml/rng-parse.el
index 060af60..7a720bc 100644
--- a/lisp/nxml/rng-parse.el
+++ b/lisp/nxml/rng-parse.el
@@ -1,6 +1,6 @@
 ;;; rng-parse.el --- parse an XML file and validate it against a schema  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML, RelaxNG
diff --git a/lisp/nxml/rng-pttrn.el b/lisp/nxml/rng-pttrn.el
index fea8584..1b28f5c 100644
--- a/lisp/nxml/rng-pttrn.el
+++ b/lisp/nxml/rng-pttrn.el
@@ -1,6 +1,6 @@
 ;;; rng-pttrn.el --- RELAX NG patterns  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML, RelaxNG
diff --git a/lisp/nxml/rng-uri.el b/lisp/nxml/rng-uri.el
index ae7902e..798475b 100644
--- a/lisp/nxml/rng-uri.el
+++ b/lisp/nxml/rng-uri.el
@@ -1,6 +1,6 @@
 ;;; rng-uri.el --- URI parsing and manipulation  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML
@@ -30,9 +30,10 @@ Multibyte characters are left as is.  Use 
`rng-uri-escape-multibyte' to
 escape them using %HH."
   (setq f (expand-file-name f))
   (let ((url
-        (replace-regexp-in-string "[\000-\032\177<>#%\"{}|\\^[]`%?;]"
-                                  'rng-percent-encode
-                                  f)))
+        ;; FIXME. Explain why the pattern doesn't also have "!$&'()*+,/:@=".
+        ;; See Internet RFC 3986 section 2.2.
+        (replace-regexp-in-string "[]\0-\s\"#%;<>?[\\^`{|}\177]"
+                                  'rng-percent-encode f)))
     (concat "file:"
            (if (and (> (length url) 0)
                     (= (aref url 0) ?/))
@@ -42,7 +43,7 @@ escape them using %HH."
 
 (defun rng-uri-escape-multibyte (uri)
   "Escape multibyte characters in URI."
-  (replace-regexp-in-string "[:nonascii:]"
+  (replace-regexp-in-string "[[:nonascii:]]"
                            'rng-percent-encode
                            (encode-coding-string uri 'utf-8)))
 
diff --git a/lisp/nxml/rng-util.el b/lisp/nxml/rng-util.el
index d8a939c..36399f6 100644
--- a/lisp/nxml/rng-util.el
+++ b/lisp/nxml/rng-util.el
@@ -1,6 +1,6 @@
 ;;; rng-util.el --- utility functions for RELAX NG library
 
-;; Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML, RelaxNG
diff --git a/lisp/nxml/rng-valid.el b/lisp/nxml/rng-valid.el
index 92998c0..6c1ca51 100644
--- a/lisp/nxml/rng-valid.el
+++ b/lisp/nxml/rng-valid.el
@@ -1,6 +1,6 @@
 ;;; rng-valid.el --- real-time validation of XML using RELAX NG  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML, RelaxNG
diff --git a/lisp/nxml/rng-xsd.el b/lisp/nxml/rng-xsd.el
index ea4f54c..f308b04 100644
--- a/lisp/nxml/rng-xsd.el
+++ b/lisp/nxml/rng-xsd.el
@@ -1,6 +1,6 @@
 ;;; rng-xsd.el --- W3C XML Schema datatypes library for RELAX NG  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML, RelaxNG
@@ -360,7 +360,7 @@ trailing digits.  For example, -0021.0430 would be 
represented by [-1
       n)))
 
 (defun rng-xsd-convert-any-uri (string)
-  (and (string-match "\\`\\(?:[^%]\\|%[0-9a-fA-F][0-9a-fA-F]\\)?*\\'" string)
+  (and (string-match "\\`\\(?:[^%]\\|%[0-9a-fA-F][0-9a-fA-F]\\)*\\'" string)
        (string-match "\\`[^#]*\\(?:#[^#]*\\)?\\'" string)
        (string-match 
"\\`\\(?:[a-zA-Z][-+.A-Za-z0-9]*:.+\\|[^:]*\\(?:[#/?].*\\)?\\)\\'" string)
        string))
diff --git a/lisp/nxml/xmltok.el b/lisp/nxml/xmltok.el
index c4559e3..afa33e0 100644
--- a/lisp/nxml/xmltok.el
+++ b/lisp/nxml/xmltok.el
@@ -1,6 +1,6 @@
 ;;; xmltok.el --- XML tokenization  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML
diff --git a/lisp/nxml/xsd-regexp.el b/lisp/nxml/xsd-regexp.el
index 54f56dd..7ae169c 100644
--- a/lisp/nxml/xsd-regexp.el
+++ b/lisp/nxml/xsd-regexp.el
@@ -1,6 +1,6 @@
 ;;; xsd-regexp.el --- translate W3C XML Schema regexps to Emacs regexps  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2003, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: James Clark
 ;; Keywords: wp, hypermedia, languages, XML, regexp
diff --git a/lisp/obarray.el b/lisp/obarray.el
index 90a7965..c83d5d4 100644
--- a/lisp/obarray.el
+++ b/lisp/obarray.el
@@ -1,6 +1,6 @@
 ;;; obarray.el --- obarray functions -*- lexical-binding: t -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: obarray functions
diff --git a/lisp/obsolete/abbrevlist.el b/lisp/obsolete/abbrevlist.el
index 0455346..e2bf14f 100644
--- a/lisp/obsolete/abbrevlist.el
+++ b/lisp/obsolete/abbrevlist.el
@@ -1,6 +1,6 @@
 ;;; abbrevlist.el --- list one abbrev table alphabetically ordered
 
-;; Copyright (C) 1986, 1992, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1986, 1992, 2001-2019 Free Software Foundation, Inc.
 ;; Suggested by a previous version by Gildea.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/obsolete/assoc.el b/lisp/obsolete/assoc.el
index 66cf677..926e605 100644
--- a/lisp/obsolete/assoc.el
+++ b/lisp/obsolete/assoc.el
@@ -1,6 +1,6 @@
 ;;; assoc.el --- insert/delete functions on association lists  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Barry A. Warsaw <address@hidden>
 ;; Keywords: extensions
diff --git a/lisp/obsolete/bruce.el b/lisp/obsolete/bruce.el
index 0102031..fba54c1 100644
--- a/lisp/obsolete/bruce.el
+++ b/lisp/obsolete/bruce.el
@@ -1,7 +1,7 @@
 ;;; bruce.el --- bruce phrase utility for overloading the Communications
 ;;; Decency Act snoops, if any.
 
-;; Copyright (C) 1988, 1993, 1997, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1988, 1993, 1997, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/obsolete/cc-compat.el b/lisp/obsolete/cc-compat.el
index dc6e769..bbacd12 100644
--- a/lisp/obsolete/cc-compat.el
+++ b/lisp/obsolete/cc-compat.el
@@ -1,6 +1,6 @@
 ;;; cc-compat.el --- cc-mode compatibility with c-mode.el confusion
 
-;; Copyright (C) 1985, 1987, 1992-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1992-2019 Free Software Foundation, Inc.
 
 ;; Authors:    1998- Martin Stjernholm
 ;;            1994-1999 Barry A. Warsaw
diff --git a/lisp/obsolete/cl-compat.el b/lisp/obsolete/cl-compat.el
index 0bb08ff..b273582 100644
--- a/lisp/obsolete/cl-compat.el
+++ b/lisp/obsolete/cl-compat.el
@@ -1,6 +1,6 @@
 ;;; cl-compat.el --- Common Lisp extensions for GNU Emacs Lisp (compatibility)
 
-;; Copyright (C) 1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Gillespie <address@hidden>
 ;; Version: 2.02
diff --git a/lisp/obsolete/complete.el b/lisp/obsolete/complete.el
index f5e4328..8021b22 100644
--- a/lisp/obsolete/complete.el
+++ b/lisp/obsolete/complete.el
@@ -1,6 +1,6 @@
 ;;; complete.el --- partial completion mechanism plus other goodies
 
-;; Copyright (C) 1990-1993, 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1993, 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Gillespie <address@hidden>
 ;; Keywords: abbrev convenience
diff --git a/lisp/obsolete/crisp.el b/lisp/obsolete/crisp.el
index 944c6c0..832820b 100644
--- a/lisp/obsolete/crisp.el
+++ b/lisp/obsolete/crisp.el
@@ -1,6 +1,6 @@
 ;;; crisp.el --- CRiSP/Brief Emacs emulator
 
-;; Copyright (C) 1997-1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1999, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Gary D. Foster <address@hidden>
 ;; Keywords: emulations brief crisp
diff --git a/lisp/obsolete/cust-print.el b/lisp/obsolete/cust-print.el
index 354c2f4..849d665 100644
--- a/lisp/obsolete/cust-print.el
+++ b/lisp/obsolete/cust-print.el
@@ -1,6 +1,6 @@
 ;;; cust-print.el --- handles print-level and print-circle
 
-;; Copyright (C) 1992, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Daniel LaLiberte <address@hidden>
 ;; Adapted-By: ESR
diff --git a/lisp/obsolete/erc-hecomplete.el b/lisp/obsolete/erc-hecomplete.el
index 0714ecc..43df67d 100644
--- a/lisp/obsolete/erc-hecomplete.el
+++ b/lisp/obsolete/erc-hecomplete.el
@@ -1,6 +1,6 @@
 ;;; erc-hecomplete.el --- Provides Nick name completion for ERC
 
-;; Copyright (C) 2001-2002, 2004, 2006-2018 Free Software Foundation,
+;; Copyright (C) 2001-2002, 2004, 2006-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Alex Schroeder <address@hidden>
diff --git a/lisp/obsolete/eudcb-ph.el b/lisp/obsolete/eudcb-ph.el
index c1dc8ca..20f8f4a 100644
--- a/lisp/obsolete/eudcb-ph.el
+++ b/lisp/obsolete/eudcb-ph.el
@@ -1,6 +1,6 @@
 ;;; eudcb-ph.el --- Emacs Unified Directory Client - CCSO PH/QI Backend
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Oscar Figueiredo <address@hidden>
 ;;         Pavel Janík <address@hidden>
diff --git a/lisp/obsolete/fast-lock.el b/lisp/obsolete/fast-lock.el
index 21db321..5180d45 100644
--- a/lisp/obsolete/fast-lock.el
+++ b/lisp/obsolete/fast-lock.el
@@ -1,6 +1,6 @@
 ;;; fast-lock.el --- automagic text properties caching for fast Font Lock mode
 
-;; Copyright (C) 1994-1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Marshall <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/obsolete/gs.el b/lisp/obsolete/gs.el
index 236ef88..cfdc9dc 100644
--- a/lisp/obsolete/gs.el
+++ b/lisp/obsolete/gs.el
@@ -1,6 +1,6 @@
 ;;; gs.el --- interface to Ghostscript
 
-;; Copyright (C) 1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: internal
diff --git a/lisp/obsolete/gulp.el b/lisp/obsolete/gulp.el
index 81bdac6..bdb3406 100644
--- a/lisp/obsolete/gulp.el
+++ b/lisp/obsolete/gulp.el
@@ -1,6 +1,6 @@
 ;;; gulp.el --- ask for updates for Lisp packages
 
-;; Copyright (C) 1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Sam Shteingold <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/obsolete/html2text.el b/lisp/obsolete/html2text.el
index 3d97c90..efc69e8 100644
--- a/lisp/obsolete/html2text.el
+++ b/lisp/obsolete/html2text.el
@@ -1,6 +1,6 @@
 ;;; html2text.el --- a simple html to plain text converter -*- coding: utf-8 
-*-
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Joakim Hove <address@hidden>
 ;; Obsolete-since: 26.1
diff --git a/lisp/obsolete/iswitchb.el b/lisp/obsolete/iswitchb.el
index 6192368..5b0df1e 100644
--- a/lisp/obsolete/iswitchb.el
+++ b/lisp/obsolete/iswitchb.el
@@ -1,6 +1,6 @@
 ;;; iswitchb.el --- switch between buffers using substrings
 
-;; Copyright (C) 1996-1997, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1997, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Stephen Eglen <address@hidden>
 ;; Maintainer: Stephen Eglen <address@hidden>
diff --git a/lisp/obsolete/landmark.el b/lisp/obsolete/landmark.el
index effea95..c4af4c3 100644
--- a/lisp/obsolete/landmark.el
+++ b/lisp/obsolete/landmark.el
@@ -1,8 +1,8 @@
 ;;; landmark.el --- Neural-network robot that learns landmarks  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1996-1997, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1997, 2000-2019 Free Software Foundation, Inc.
 
-;; Author: Terrence Brannon (was: <address@hidden>)
+;; Author: Terrence Brannon <address@hidden>
 ;; Created: December 16, 1996 - first release to usenet
 ;; Keywords: games, neural network, adaptive search, chemotaxis
 ;; Version: 1.0
@@ -36,7 +36,7 @@
 ;; the smell of the tree increases, then the weights in the robot's
 ;; brain are adjusted to encourage this odor-driven behavior in the
 ;; future. If the smell of the tree decreases, the robots weights are
-;; adjusted to discourage a correct move.
+;; adjusted to discourage that odor-driven behavior.
 
 ;; In laymen's terms, the search space is initially flat. The point
 ;; of training is to "turn up the edges of the search space" so that
@@ -53,6 +53,13 @@
 ;; a single move, one moves east,west and south, then both east and
 ;; west will be improved when they shouldn't
 
+;; The source code was developed as part of a course on Brain Theory
+;; and Neural Networks at the University of Southern California. The
+;; original problem description and solution appeared in 1981 in the
+;; paper "Landmark Learning: An Illustration of Associative
+;; Search" authored by Andrew G. Barto and Richard S. Sutton and
+;; published to Biological Cybernetics.
+
 ;; Many thanks to Yuri Pryadkin <address@hidden> for this
 ;; concise problem description.
 
diff --git a/lisp/obsolete/lazy-lock.el b/lisp/obsolete/lazy-lock.el
index 54dc799..44f8528 100644
--- a/lisp/obsolete/lazy-lock.el
+++ b/lisp/obsolete/lazy-lock.el
@@ -1,6 +1,6 @@
 ;;; lazy-lock.el --- lazy demand-driven fontification for fast Font Lock mode
 
-;; Copyright (C) 1994-1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Marshall <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/obsolete/ledit.el b/lisp/obsolete/ledit.el
index e09c1c3..6383a42 100644
--- a/lisp/obsolete/ledit.el
+++ b/lisp/obsolete/ledit.el
@@ -1,6 +1,6 @@
 ;;; ledit.el --- Emacs side of ledit interface
 
-;; Copyright (C) 1985, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: languages
diff --git a/lisp/obsolete/levents.el b/lisp/obsolete/levents.el
index 48afe75..714b3fb 100644
--- a/lisp/obsolete/levents.el
+++ b/lisp/obsolete/levents.el
@@ -1,6 +1,6 @@
 ;;; levents.el --- emulate the Lucid event data type and associated functions
 
-;; Copyright (C) 1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: emulations
diff --git a/lisp/obsolete/lmenu.el b/lisp/obsolete/lmenu.el
index 25a9837..31fcc18 100644
--- a/lisp/obsolete/lmenu.el
+++ b/lisp/obsolete/lmenu.el
@@ -1,6 +1,6 @@
 ;;; lmenu.el --- emulate Lucid's menubar support
 
-;; Copyright (C) 1992-1994, 1997, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1992-1994, 1997, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Keywords: emulations obsolete
diff --git a/lisp/obsolete/longlines.el b/lisp/obsolete/longlines.el
index d07f7bf..2ef5324 100644
--- a/lisp/obsolete/longlines.el
+++ b/lisp/obsolete/longlines.el
@@ -1,6 +1,6 @@
 ;;; longlines.el --- automatically wrap long lines   -*- coding:utf-8 -*-
 
-;; Copyright (C) 2000-2001, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2001, 2004-2019 Free Software Foundation, Inc.
 
 ;; Authors:    Kai Grossjohann <address@hidden>
 ;;             Alex Schroeder <address@hidden>
diff --git a/lisp/obsolete/lucid.el b/lisp/obsolete/lucid.el
index c248cd6..d1b702e 100644
--- a/lisp/obsolete/lucid.el
+++ b/lisp/obsolete/lucid.el
@@ -1,6 +1,6 @@
 ;;; lucid.el --- emulate some Lucid Emacs functions
 
-;; Copyright (C) 1993, 1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: emulations
diff --git a/lisp/obsolete/messcompat.el b/lisp/obsolete/messcompat.el
index 67dd2da..28e37a6 100644
--- a/lisp/obsolete/messcompat.el
+++ b/lisp/obsolete/messcompat.el
@@ -1,6 +1,6 @@
 ;;; messcompat.el --- making message mode compatible with mail mode
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: mail, news
diff --git a/lisp/obsolete/mouse-sel.el b/lisp/obsolete/mouse-sel.el
index f54bcf0..b8dd9e6 100644
--- a/lisp/obsolete/mouse-sel.el
+++ b/lisp/obsolete/mouse-sel.el
@@ -1,6 +1,6 @@
 ;;; mouse-sel.el --- multi-click selection support
 
-;; Copyright (C) 1993-1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Mike Williams <address@hidden>
 ;; Keywords: mouse
diff --git a/lisp/obsolete/old-emacs-lock.el b/lisp/obsolete/old-emacs-lock.el
index a747c54..d940f1b 100644
--- a/lisp/obsolete/old-emacs-lock.el
+++ b/lisp/obsolete/old-emacs-lock.el
@@ -1,6 +1,6 @@
 ;;; emacs-lock.el --- prevents you from exiting Emacs if a buffer is locked
 
-;; Copyright (C) 1994, 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Tom Wurgler <address@hidden>
 ;; Created: 12/8/94
diff --git a/lisp/obsolete/old-whitespace.el b/lisp/obsolete/old-whitespace.el
index 0c9fc32..c8daa57 100644
--- a/lisp/obsolete/old-whitespace.el
+++ b/lisp/obsolete/old-whitespace.el
@@ -1,6 +1,6 @@
 ;;; whitespace.el --- warn about and clean bogus whitespaces in the file
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Rajesh Vaidheeswarran <address@hidden>
 ;; Keywords: convenience
diff --git a/lisp/obsolete/otodo-mode.el b/lisp/obsolete/otodo-mode.el
index 90334e1..7e9cc23 100644
--- a/lisp/obsolete/otodo-mode.el
+++ b/lisp/obsolete/otodo-mode.el
@@ -1,6 +1,6 @@
 ;;; todo-mode.el --- major mode for editing TODO list files
 
-;; Copyright (C) 1997, 1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1999, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Oliver Seidel <address@hidden>
 ;; Maintainer: Stephen Berman <address@hidden>
diff --git a/lisp/obsolete/pc-mode.el b/lisp/obsolete/pc-mode.el
index 3fdf9c3..6d1a456 100644
--- a/lisp/obsolete/pc-mode.el
+++ b/lisp/obsolete/pc-mode.el
@@ -1,6 +1,6 @@
 ;;; pc-mode.el --- emulate certain key bindings used on PCs
 
-;; Copyright (C) 1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: emulations
diff --git a/lisp/obsolete/pc-select.el b/lisp/obsolete/pc-select.el
index 0d41b88..e636862 100644
--- a/lisp/obsolete/pc-select.el
+++ b/lisp/obsolete/pc-select.el
@@ -2,7 +2,7 @@
 ;;;                 (or MAC GUI or MS-windoze (bah)) look-and-feel
 ;;;                 including key bindings.
 
-;; Copyright (C) 1995-1997, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-1997, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Staats <address@hidden>
 ;; Keywords: convenience emulations
diff --git a/lisp/obsolete/pgg-def.el b/lisp/obsolete/pgg-def.el
index a128a8a..853045d 100644
--- a/lisp/obsolete/pgg-def.el
+++ b/lisp/obsolete/pgg-def.el
@@ -1,6 +1,6 @@
 ;;; pgg-def.el --- functions/macros for defining PGG functions
 
-;; Copyright (C) 1999, 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <address@hidden>
 ;; Created: 1999/11/02
diff --git a/lisp/obsolete/pgg-gpg.el b/lisp/obsolete/pgg-gpg.el
index 3b89072..6a901fb 100644
--- a/lisp/obsolete/pgg-gpg.el
+++ b/lisp/obsolete/pgg-gpg.el
@@ -1,6 +1,6 @@
 ;;; pgg-gpg.el --- GnuPG support for PGG.
 
-;; Copyright (C) 1999-2000, 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2000, 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <address@hidden>
 ;; Symmetric encryption and gpg-agent support added by:
diff --git a/lisp/obsolete/pgg-parse.el b/lisp/obsolete/pgg-parse.el
index 7ae2e67..cdff9ac 100644
--- a/lisp/obsolete/pgg-parse.el
+++ b/lisp/obsolete/pgg-parse.el
@@ -1,6 +1,6 @@
 ;;; pgg-parse.el --- OpenPGP packet parsing
 
-;; Copyright (C) 1999, 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <address@hidden>
 ;; Created: 1999/10/28
diff --git a/lisp/obsolete/pgg-pgp.el b/lisp/obsolete/pgg-pgp.el
index ae75377..9e9a38d 100644
--- a/lisp/obsolete/pgg-pgp.el
+++ b/lisp/obsolete/pgg-pgp.el
@@ -1,6 +1,6 @@
 ;;; pgg-pgp.el --- PGP 2.* and 6.* support for PGG.
 
-;; Copyright (C) 1999-2000, 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2000, 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <address@hidden>
 ;; Created: 1999/11/02
diff --git a/lisp/obsolete/pgg-pgp5.el b/lisp/obsolete/pgg-pgp5.el
index af82055..8119943 100644
--- a/lisp/obsolete/pgg-pgp5.el
+++ b/lisp/obsolete/pgg-pgp5.el
@@ -1,6 +1,6 @@
 ;;; pgg-pgp5.el --- PGP 5.* support for PGG.
 
-;; Copyright (C) 1999-2000, 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2000, 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <address@hidden>
 ;; Created: 1999/11/02
diff --git a/lisp/obsolete/pgg.el b/lisp/obsolete/pgg.el
index fd35f7d..18b63fc 100644
--- a/lisp/obsolete/pgg.el
+++ b/lisp/obsolete/pgg.el
@@ -1,6 +1,6 @@
 ;;; pgg.el --- glue for the various PGP implementations.
 
-;; Copyright (C) 1999-2000, 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2000, 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <address@hidden>
 ;; Symmetric encryption added by: Sascha Wilde <address@hidden>
@@ -572,7 +572,7 @@ within the region."
   (with-current-buffer (get-buffer-create pgg-output-buffer)
     (buffer-disable-undo)
     (erase-buffer)
-    (let ((proto (if (string-match "^[a-zA-Z\\+\\.\\\\-]+:" keyserver)
+    (let ((proto (if (string-match "^[a-zA-Z\\+.-]+:" keyserver)
                     (substring keyserver 0 (1- (match-end 0))))))
       (save-excursion
        (funcall pgg-insert-url-function
diff --git a/lisp/obsolete/rcompile.el b/lisp/obsolete/rcompile.el
index 6e7e37f..dfa8009 100644
--- a/lisp/obsolete/rcompile.el
+++ b/lisp/obsolete/rcompile.el
@@ -1,6 +1,6 @@
 ;;; rcompile.el --- run a compilation on a remote machine
 
-;; Copyright (C) 1993-1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Alon Albert <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/obsolete/s-region.el b/lisp/obsolete/s-region.el
index 8487920..d86b7d7 100644
--- a/lisp/obsolete/s-region.el
+++ b/lisp/obsolete/s-region.el
@@ -1,6 +1,6 @@
 ;;; s-region.el --- set region using shift key
 
-;; Copyright (C) 1994-1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Morten Welinder <address@hidden>
 ;; Keywords: terminals
diff --git a/lisp/obsolete/sregex.el b/lisp/obsolete/sregex.el
index 1099b87..884cd3e 100644
--- a/lisp/obsolete/sregex.el
+++ b/lisp/obsolete/sregex.el
@@ -1,6 +1,6 @@
 ;;; sregex.el --- symbolic regular expressions
 
-;; Copyright (C) 1997-1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Bob Glickstein <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/obsolete/starttls.el b/lisp/obsolete/starttls.el
index 0dc2663..e0a0968 100644
--- a/lisp/obsolete/starttls.el
+++ b/lisp/obsolete/starttls.el
@@ -1,6 +1,6 @@
 ;;; starttls.el --- STARTTLS functions
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <address@hidden>
 ;; Author: Simon Josefsson <address@hidden>
@@ -217,7 +217,7 @@ handshake, or nil on failure."
                                                starttls-success nil t))
                                 (setq done-bad (re-search-forward
                                                 starttls-failure nil t))))))
-           (accept-process-output process 1 100)
+           (accept-process-output process 1.1)
            (sit-for 0.1))
          (setq info (buffer-substring-no-properties old-max (point-max)))
          (delete-region old-max (point-max))
@@ -251,7 +251,7 @@ handshake, or nil on failure."
                  (goto-char old-max)
                  (not (setq done (re-search-forward
                                   starttls-connect nil t)))))
-      (accept-process-output process 0 100)
+      (accept-process-output process 0.1)
       (sit-for 0.1))
     (if done
        (with-current-buffer buffer
diff --git a/lisp/obsolete/sup-mouse.el b/lisp/obsolete/sup-mouse.el
index 5c10c02..6bd4278 100644
--- a/lisp/obsolete/sup-mouse.el
+++ b/lisp/obsolete/sup-mouse.el
@@ -1,6 +1,6 @@
 ;;; sup-mouse.el --- supdup mouse support for lisp machines
 
-;; Copyright (C) 1985-1986, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1986, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Wolfgang Rupprecht
 ;; Maintainer: address@hidden
diff --git a/lisp/obsolete/terminal.el b/lisp/obsolete/terminal.el
index 1c4f134..ce6f230 100644
--- a/lisp/obsolete/terminal.el
+++ b/lisp/obsolete/terminal.el
@@ -1,6 +1,6 @@
 ;;; terminal.el --- terminal emulator for GNU Emacs
 
-;; Copyright (C) 1986-1989, 1993-1994, 2001-2018 Free Software
+;; Copyright (C) 1986-1989, 1993-1994, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Richard Mlynarik <address@hidden>
diff --git a/lisp/obsolete/tls.el b/lisp/obsolete/tls.el
index fb7c20c..d17ddad 100644
--- a/lisp/obsolete/tls.el
+++ b/lisp/obsolete/tls.el
@@ -1,6 +1,6 @@
 ;;; tls.el --- TLS/SSL support via wrapper around GnuTLS
 
-;; Copyright (C) 1996-1999, 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <address@hidden>
 ;; Keywords: comm, tls, gnutls, ssl
diff --git a/lisp/obsolete/tpu-edt.el b/lisp/obsolete/tpu-edt.el
index c047381..8db1c4f 100644
--- a/lisp/obsolete/tpu-edt.el
+++ b/lisp/obsolete/tpu-edt.el
@@ -1,6 +1,6 @@
 ;;; tpu-edt.el --- Emacs emulating TPU emulating EDT
 
-;; Copyright (C) 1993-1995, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1995, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Rob Riepel <address@hidden>
 ;; Maintainer: Rob Riepel <address@hidden>
diff --git a/lisp/obsolete/tpu-extras.el b/lisp/obsolete/tpu-extras.el
index 21006ff..f19a67d 100644
--- a/lisp/obsolete/tpu-extras.el
+++ b/lisp/obsolete/tpu-extras.el
@@ -1,6 +1,6 @@
 ;;; tpu-extras.el --- scroll margins and free cursor mode for TPU-edt
 
-;; Copyright (C) 1993-1995, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1995, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Rob Riepel <address@hidden>
 ;; Maintainer: Rob Riepel <address@hidden>
diff --git a/lisp/obsolete/tpu-mapper.el b/lisp/obsolete/tpu-mapper.el
index 4cc2404..60e0e49 100644
--- a/lisp/obsolete/tpu-mapper.el
+++ b/lisp/obsolete/tpu-mapper.el
@@ -1,6 +1,6 @@
 ;;; tpu-mapper.el --- create a TPU-edt X-windows keymap file
 
-;; Copyright (C) 1993-1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Rob Riepel <address@hidden>
 ;; Maintainer: Rob Riepel <address@hidden>
diff --git a/lisp/obsolete/vc-arch.el b/lisp/obsolete/vc-arch.el
index 056c270..9252891 100644
--- a/lisp/obsolete/vc-arch.el
+++ b/lisp/obsolete/vc-arch.el
@@ -1,6 +1,6 @@
 ;;; vc-arch.el --- VC backend for the Arch version-control system  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author:      FSF (see vc.el for full credits)
 ;; Maintainer:  Stefan Monnier <address@hidden>
diff --git a/lisp/obsolete/vi.el b/lisp/obsolete/vi.el
index 7d44f56..df5ddfd 100644
--- a/lisp/obsolete/vi.el
+++ b/lisp/obsolete/vi.el
@@ -132,7 +132,7 @@ command extensions.")
   (define-key vi-com-map "\C-e" 'vi-expose-line-below)
   (define-key vi-com-map "\C-f" 'vi-forward-windowful)
   (define-key vi-com-map "\C-g" 'keyboard-quit)
-  (define-key vi-com-map "\C-i" 'indent-relative-maybe) ; TAB
+  (define-key vi-com-map "\C-i" 'indent-relative-first-indent-point) ; TAB
   (define-key vi-com-map "\C-j" 'vi-next-line) ; LFD
   (define-key vi-com-map "\C-k" 'vi-kill-line) ; extension
   (define-key vi-com-map "\C-l" 'recenter)
diff --git a/lisp/obsolete/vip.el b/lisp/obsolete/vip.el
index 1d1eccb..bc4b900 100644
--- a/lisp/obsolete/vip.el
+++ b/lisp/obsolete/vip.el
@@ -1,6 +1,6 @@
 ;;; vip.el --- a VI Package for GNU Emacs
 
-;; Copyright (C) 1986-1988, 1992-1993, 1998, 2001-2018 Free Software
+;; Copyright (C) 1986-1988, 1992-1993, 1998, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Masahiko Sato <address@hidden>
@@ -2187,19 +2187,19 @@ a token has type \(command, address, end-mark\) and 
value."
          ((looking-at "%")
           (forward-char 1)
           (setq ex-token-type "whole"))
-         ((looking-at "+")
-          (cond ((or (looking-at "+[-+]") (looking-at "+[\n|]"))
+         ((looking-at "\\+")
+          (cond ((looking-at "\\+[-+\n|]")
                  (forward-char 1)
                  (insert "1")
                  (backward-char 1)
                  (setq ex-token-type "plus"))
-                ((looking-at "+[0-9]")
+                ((looking-at "\\+[0-9]")
                  (forward-char 1)
                  (setq ex-token-type "plus"))
                 (t
                  (error "Badly formed address"))))
          ((looking-at "-")
-          (cond ((or (looking-at "-[-+]") (looking-at "-[\n|]"))
+          (cond ((looking-at "-[-+\n|]")
                  (forward-char 1)
                  (insert "1")
                  (backward-char 1)
@@ -2216,7 +2216,7 @@ a token has type \(command, address, end-mark\) and 
value."
             (while (and (not (eolp)) cont)
               ;;(re-search-forward "[^/]*/")
               (re-search-forward "[^/]*\\(/\\|\n\\)")
-              (if (not (vip-looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\/"))
+              (if (not (vip-looking-back "[^\\]\\(\\\\\\\\\\)*\\\\/"))
                   (setq cont nil))))
           (backward-char 1)
           (setq ex-token (buffer-substring (point) (mark)))
@@ -2229,7 +2229,7 @@ a token has type \(command, address, end-mark\) and 
value."
             (while (and (not (eolp)) cont)
               ;;(re-search-forward "[^\\?]*\\?")
               (re-search-forward "[^\\?]*\\(\\?\\|\n\\)")
-              (if (not (vip-looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\\\?"))
+              (if (not (vip-looking-back "[^\\]\\(\\\\\\\\\\)*\\\\\\?"))
                   (setq cont nil))
               (backward-char 1)
               (if (not (looking-at "\n")) (forward-char 1))))
@@ -2325,7 +2325,7 @@ a token has type \(command, address, end-mark\) and 
value."
            (while (and (not (eolp)) cont)
              (re-search-forward "[^/]*\\(/\\|\n\\)")
              ;;(re-search-forward "[^/]*/")
-             (if (not (vip-looking-back "[^\\\\]\\(\\\\\\\\\\)*\\\\/"))
+             (if (not (vip-looking-back "[^\\]\\(\\\\\\\\\\)*\\\\/"))
                  (setq cont nil))))
          (setq ex-token
                (if (= (mark) (point)) ""
@@ -2520,7 +2520,7 @@ a token has type \(command, address, end-mark\) and 
value."
                ex-variant t)
          (forward-char 2)
          (skip-chars-forward " \t")))
-    (if (looking-at "+")
+    (if (looking-at "\\+")
        (progn
          (forward-char 1)
          (set-mark (point))
diff --git a/lisp/obsolete/ws-mode.el b/lisp/obsolete/ws-mode.el
index 9c09692..3d2e968 100644
--- a/lisp/obsolete/ws-mode.el
+++ b/lisp/obsolete/ws-mode.el
@@ -1,6 +1,6 @@
-;;; ws-mode.el --- WordStar emulation mode for GNU Emacs
+;;; ws-mode.el --- WordStar emulation mode for GNU Emacs -*- lexical-binding: 
t -*-
 
-;; Copyright (C) 1991, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1991, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Juergen Nickelsen <address@hidden>
 ;; Version: 0.7
@@ -24,9 +24,20 @@
 
 ;;; Commentary:
 
-;; This emulates WordStar, with a major mode.
+;; This provides emulation of WordStar with a minor mode.
 
 ;;; Code:
+
+(defgroup wordstar nil
+  "WordStar emulation within Emacs."
+  :prefix "wordstar-"
+  :prefix "ws-"
+  :group 'emulations)
+
+(defcustom wordstar-mode-lighter " WordStar"
+  "Lighter shown in the modeline for `wordstar' mode."
+  :type 'string)
+
 (defvar wordstar-C-k-map
   (let ((map (make-keymap)))
     (define-key map " " ())
@@ -98,8 +109,7 @@
     (define-key map "wh" 'split-window-right)
     (define-key map "wo" 'other-window)
     (define-key map "wv" 'split-window-below)
-    map)
-  "")
+    map))
 
 (defvar wordstar-C-q-map
   (let ((map (make-keymap)))
@@ -174,12 +184,9 @@
 ;; wordstar-C-j-map not yet implemented
 (defvar wordstar-C-j-map nil)
 
-
-(put 'wordstar-mode 'mode-class 'special)
-
 ;;;###autoload
-(define-derived-mode wordstar-mode fundamental-mode "WordStar"
-  "Major mode with WordStar-like key bindings.
+(define-minor-mode wordstar-mode
+  "Minor mode with WordStar-like key bindings.
 
 BUGS:
  - Help menus with WordStar commands (C-j just calls help-for-help)
@@ -189,8 +196,18 @@ BUGS:
  - Search and replace (C-q a) is only available in forward direction
 
 No key bindings beginning with ESC are installed, they will work
-Emacs-like.")
+Emacs-like."
+  :group 'wordstar
+  :lighter wordstar-mode-lighter
+  :keymap wordstar-mode-map)
 
+(defun turn-on-wordstar-mode ()
+  (when (and (not (minibufferp))
+             (not wordstar-mode))
+    (wordstar-mode 1)))
+
+(define-globalized-minor-mode global-wordstar-mode wordstar-mode
+  turn-on-wordstar-mode)
 
 (defun wordstar-center-paragraph ()
   "Center each line in the paragraph at or after point.
@@ -254,7 +271,7 @@ the distance between the end of the text and `fill-column'."
 
 (defvar ws-search-string nil "String of last search in WordStar mode.")
 (defvar ws-search-direction t
-  "Direction of last search in WordStar mode. t if forward, nil if backward.")
+  "Direction of last search in WordStar mode.  t if forward, nil if backward.")
 
 (defvar ws-last-cursorposition nil
   "Position before last search etc. in WordStar mode.")
@@ -266,8 +283,9 @@ the distance between the end of the text and `fill-column'."
 ;; wordstar special functions:
 
 (defun ws-error (string)
-  "Report error of a WordStar special function. Error message is saved
-in ws-last-errormessage for recovery with C-q w."
+  "Report error of a WordStar special function.
+Error message is saved in `ws-last-errormessage' for recovery
+with C-q w."
   (setq ws-last-errormessage string)
   (error string))
 
@@ -358,7 +376,6 @@ in ws-last-errormessage for recovery with C-q w."
        (message ""))
     (message "Block markers not set")))
 
-
 (defun ws-indent-block ()
   "In WordStar mode: Indent block (not yet implemented)."
   (interactive)
@@ -373,7 +390,7 @@ in ws-last-errormessage for recovery with C-q w."
 (defun ws-print-block ()
   "In WordStar mode: Print block."
   (interactive)
-  (message "Don't do this. Write block to a file (C-k w) and print this 
file."))
+  (message "Don't do this. Write block to a file (C-k w) and print this file"))
 
 (defun ws-mark-word ()
   "In WordStar mode: Mark current word as block."
@@ -389,7 +406,7 @@ in ws-last-errormessage for recovery with C-q w."
 (defun ws-exdent-block ()
   "I don't know what this (C-k u) should do."
   (interactive)
-  (ws-error "This won't be done -- not yet implemented."))
+  (ws-error "This won't be done -- not yet implemented"))
 
 (defun ws-move-block ()
   "In WordStar mode: Move block to current cursor position."
@@ -560,16 +577,16 @@ in ws-last-errormessage for recovery with C-q w."
   "In WordStar mode: Undo and give message about undoing more changes."
   (interactive)
   (undo)
-  (message "Repeat C-q l to undo more changes."))
+  (message "Repeat C-q l to undo more changes"))
 
 (defun ws-goto-last-cursorposition ()
-  "In WordStar mode: "
+  "In WordStar mode: Go to position before last search."
   (interactive)
   (if ws-last-cursorposition
       (progn
        (setq ws-last-cursorposition (point-marker))
        (goto-char ws-last-cursorposition))
-    (ws-error "No last cursor position available.")))
+    (ws-error "No last cursor position available")))
 
 (defun ws-last-error ()
   "In WordStar mode: repeat last error message.
@@ -577,7 +594,7 @@ This will only work for errors raised by WordStar mode 
functions."
   (interactive)
   (if ws-last-errormessage
       (message "%s" ws-last-errormessage)
-    (message "No WordStar error yet.")))
+    (message "No WordStar error yet")))
 
 (defun ws-kill-eol ()
   "In WordStar mode: Kill to end of line (like WordStar, not like Emacs)."
@@ -587,8 +604,7 @@ This will only work for errors raised by WordStar mode 
functions."
     (kill-region p (point))))
 
 (defun ws-kill-bol ()
-  "In WordStar mode: Kill to beginning of line
-\(like WordStar, not like Emacs)."
+  "In WordStar mode: Kill to beginning of line (like WordStar, not like 
Emacs)."
   (interactive)
   (let ((p (point)))
     (beginning-of-line)
diff --git a/lisp/obsolete/xesam.el b/lisp/obsolete/xesam.el
index c5c7fa7..16da6d9 100644
--- a/lisp/obsolete/xesam.el
+++ b/lisp/obsolete/xesam.el
@@ -1,6 +1,6 @@
 ;;; xesam.el --- Xesam interface to search engines.
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 ;; Keywords: tools, hypermedia
@@ -622,8 +622,7 @@ Return propertized STRING."
        (or (widget-get widget :tag) "")
        (format-time-string
         "%d %B %Y, %T"
-        (seconds-to-time
-         (string-to-number (widget-get widget :xesam:sourceModified)))))))
+        (string-to-number (widget-get widget :xesam:sourceModified))))))
 
     ;; Second line: :value.
     (widget-put widget :value (widget-get widget :xesam:url))
diff --git a/lisp/obsolete/yow.el b/lisp/obsolete/yow.el
index 70d2c5d..5cbb2ef 100644
--- a/lisp/obsolete/yow.el
+++ b/lisp/obsolete/yow.el
@@ -1,6 +1,6 @@
 ;;; yow.el --- quote random zippyisms
 
-;; Copyright (C) 1993-1995, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1995, 2000-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Author: Richard Mlynarik
diff --git a/lisp/org/ChangeLog.1 b/lisp/org/ChangeLog.1
index ee1c6f6..2bb1586 100644
--- a/lisp/org/ChangeLog.1
+++ b/lisp/org/ChangeLog.1
@@ -32833,7 +32833,7 @@
 ;; add-log-time-zone-rule: t
 ;; End:
 
-       Copyright (C) 2008-2018 Free Software Foundation, Inc.
+       Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lisp/org/ob-C.el b/lisp/org/ob-C.el
index ff5be34..36d7998 100644
--- a/lisp/org/ob-C.el
+++ b/lisp/org/ob-C.el
@@ -1,6 +1,6 @@
 ;;; ob-C.el --- Babel Functions for C and Similar Languages -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;;      Thierry Banel
diff --git a/lisp/org/ob-J.el b/lisp/org/ob-J.el
index 8781221..b9125df 100644
--- a/lisp/org/ob-J.el
+++ b/lisp/org/ob-J.el
@@ -1,6 +1,6 @@
 ;;; ob-J.el --- Babel Functions for J                -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Oleh Krehel
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-R.el b/lisp/org/ob-R.el
index d7e936e..9e738a8 100644
--- a/lisp/org/ob-R.el
+++ b/lisp/org/ob-R.el
@@ -1,6 +1,6 @@
 ;;; ob-R.el --- Babel Functions for R                -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;;     Dan Davison
diff --git a/lisp/org/ob-abc.el b/lisp/org/ob-abc.el
index 75881cc..43ee1d9 100644
--- a/lisp/org/ob-abc.el
+++ b/lisp/org/ob-abc.el
@@ -1,6 +1,6 @@
 ;;; ob-abc.el --- Org Babel Functions for ABC -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: William Waites
 ;; Keywords: literate programming, music
@@ -47,7 +47,7 @@
             (value (cdr pair)))
         (setq body
               (replace-regexp-in-string
-               (concat "\$" (regexp-quote name))
+               (concat "\\$" (regexp-quote name))
                (if (stringp value) value (format "%S" value))
                body))))
      vars)
@@ -59,7 +59,7 @@
   (message "executing Abc source code block")
   (let* ((cmdline (cdr (assq :cmdline params)))
         (out-file (let ((file (cdr (assq :file params))))
-                    (if file (replace-regexp-in-string "\.pdf$" ".ps" file)
+                    (if file (replace-regexp-in-string "\\.pdf$" ".ps" file)
                       (error "abc code block requires :file header 
argument"))))
         (in-file (org-babel-temp-file "abc-"))
         (render (concat "abcm2ps" " " cmdline
diff --git a/lisp/org/ob-asymptote.el b/lisp/org/ob-asymptote.el
index 84e2364..667d3e1 100644
--- a/lisp/org/ob-asymptote.el
+++ b/lisp/org/ob-asymptote.el
@@ -1,6 +1,6 @@
 ;;; ob-asymptote.el --- Babel Functions for Asymptote -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-awk.el b/lisp/org/ob-awk.el
index 1ee4552..4c0dbbc 100644
--- a/lisp/org/ob-awk.el
+++ b/lisp/org/ob-awk.el
@@ -1,6 +1,6 @@
 ;;; ob-awk.el --- Babel Functions for Awk            -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-calc.el b/lisp/org/ob-calc.el
index 387cba2..6ee93cd 100644
--- a/lisp/org/ob-calc.el
+++ b/lisp/org/ob-calc.el
@@ -1,6 +1,6 @@
 ;;; ob-calc.el --- Babel Functions for Calc          -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-clojure.el b/lisp/org/ob-clojure.el
index 890f60a..14c014a 100644
--- a/lisp/org/ob-clojure.el
+++ b/lisp/org/ob-clojure.el
@@ -1,6 +1,6 @@
 ;;; ob-clojure.el --- Babel Functions for Clojure    -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Joel Boehland, Eric Schulte, Oleh Krehel, Frederick Giasson
 ;;
diff --git a/lisp/org/ob-comint.el b/lisp/org/ob-comint.el
index e9c6f93..e27c1f8 100644
--- a/lisp/org/ob-comint.el
+++ b/lisp/org/ob-comint.el
@@ -1,6 +1,6 @@
 ;;; ob-comint.el --- Babel Functions for Interaction with Comint Buffers -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research, comint
diff --git a/lisp/org/ob-coq.el b/lisp/org/ob-coq.el
index 875c794..26682c1 100644
--- a/lisp/org/ob-coq.el
+++ b/lisp/org/ob-coq.el
@@ -1,6 +1,6 @@
 ;;; ob-coq.el --- Babel Functions for Coq            -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-core.el b/lisp/org/ob-core.el
index a5449fe..b6c54a9 100644
--- a/lisp/org/ob-core.el
+++ b/lisp/org/ob-core.el
@@ -1,6 +1,6 @@
 ;;; ob-core.el --- Working with Code Blocks          -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Authors: Eric Schulte
 ;;     Dan Davison
@@ -2955,7 +2955,7 @@ If the table is trivial, then return it as a scalar."
 (defun org-babel-string-read (cell)
   "Strip nested \"s from around strings."
   (org-babel-read (or (and (stringp cell)
-                           (string-match "\\\"\\(.+\\)\\\"" cell)
+                           (string-match "\"\\(.+\\)\"" cell)
                            (match-string 1 cell))
                       cell) t))
 
diff --git a/lisp/org/ob-css.el b/lisp/org/ob-css.el
index 8cabf2b..ce663b2 100644
--- a/lisp/org/ob-css.el
+++ b/lisp/org/ob-css.el
@@ -1,6 +1,6 @@
 ;;; ob-css.el --- Babel Functions for CSS            -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-ditaa.el b/lisp/org/ob-ditaa.el
index 9507630..c8a5e01 100644
--- a/lisp/org/ob-ditaa.el
+++ b/lisp/org/ob-ditaa.el
@@ -1,6 +1,6 @@
 ;;; ob-ditaa.el --- Babel Functions for ditaa        -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-dot.el b/lisp/org/ob-dot.el
index 31e0a4f..35bc893 100644
--- a/lisp/org/ob-dot.el
+++ b/lisp/org/ob-dot.el
@@ -1,6 +1,6 @@
 ;;; ob-dot.el --- Babel Functions for dot            -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-ebnf.el b/lisp/org/ob-ebnf.el
index 8c7c541..5ed9319 100644
--- a/lisp/org/ob-ebnf.el
+++ b/lisp/org/ob-ebnf.el
@@ -1,6 +1,6 @@
 ;;; ob-ebnf.el --- Babel Functions for EBNF          -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Gauland
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-emacs-lisp.el b/lisp/org/ob-emacs-lisp.el
index 8ea2ec1..c9f6c49 100644
--- a/lisp/org/ob-emacs-lisp.el
+++ b/lisp/org/ob-emacs-lisp.el
@@ -1,6 +1,6 @@
 ;;; ob-emacs-lisp.el --- Babel Functions for Emacs-lisp Code -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-eval.el b/lisp/org/ob-eval.el
index f8cb285..8d5b7ed 100644
--- a/lisp/org/ob-eval.el
+++ b/lisp/org/ob-eval.el
@@ -1,6 +1,6 @@
 ;;; ob-eval.el --- Babel Functions for External Code Evaluation -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research, comint
diff --git a/lisp/org/ob-exp.el b/lisp/org/ob-exp.el
index 264dc0e..bf57964 100644
--- a/lisp/org/ob-exp.el
+++ b/lisp/org/ob-exp.el
@@ -1,6 +1,6 @@
 ;;; ob-exp.el --- Exportation of Babel Source Blocks -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Authors: Eric Schulte
 ;;     Dan Davison
diff --git a/lisp/org/ob-forth.el b/lisp/org/ob-forth.el
index efd5759..88ed964 100644
--- a/lisp/org/ob-forth.el
+++ b/lisp/org/ob-forth.el
@@ -1,6 +1,6 @@
 ;;; ob-forth.el --- Babel Functions for Forth        -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research, forth
@@ -53,7 +53,7 @@ This function is called by `org-babel-execute-src-block'"
 (defun org-babel-forth-session-execute (body params)
   (require 'forth-mode)
   (let ((proc (forth-proc))
-       (rx " \\(\n:\\|compiled\n\\\|ok\n\\)")
+       (rx " \\(\n:\\|compiled\n\\|ok\n\\)")
        (result-start))
     (with-current-buffer (process-buffer (forth-proc))
       (mapcar (lambda (line)
diff --git a/lisp/org/ob-fortran.el b/lisp/org/ob-fortran.el
index 49e960f..579fb31 100644
--- a/lisp/org/ob-fortran.el
+++ b/lisp/org/ob-fortran.el
@@ -1,6 +1,6 @@
 ;;; ob-fortran.el --- Babel Functions for Fortran    -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Authors: Sergey Litvinov
 ;;       Eric Schulte
diff --git a/lisp/org/ob-gnuplot.el b/lisp/org/ob-gnuplot.el
index b2f4913..5ff6756 100644
--- a/lisp/org/ob-gnuplot.el
+++ b/lisp/org/ob-gnuplot.el
@@ -1,6 +1,6 @@
 ;;; ob-gnuplot.el --- Babel Functions for Gnuplot    -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-groovy.el b/lisp/org/ob-groovy.el
index 565b097..fe3a072 100644
--- a/lisp/org/ob-groovy.el
+++ b/lisp/org/ob-groovy.el
@@ -1,6 +1,6 @@
 ;;; ob-groovy.el --- Babel Functions for Groovy      -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Miro Bezjak
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-haskell.el b/lisp/org/ob-haskell.el
index e607ee0..3c0a102 100644
--- a/lisp/org/ob-haskell.el
+++ b/lisp/org/ob-haskell.el
@@ -1,6 +1,6 @@
 ;;; ob-haskell.el --- Babel Functions for Haskell    -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-hledger.el b/lisp/org/ob-hledger.el
index 727fb1f..4fb1f69 100644
--- a/lisp/org/ob-hledger.el
+++ b/lisp/org/ob-hledger.el
@@ -1,6 +1,6 @@
 ;;  ob-hledger.el --- Babel Functions for hledger      -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Michael
 ;; Keywords: literate programming, reproducible research, plain text accounting
diff --git a/lisp/org/ob-io.el b/lisp/org/ob-io.el
index 4f407cc..b0d5b51 100644
--- a/lisp/org/ob-io.el
+++ b/lisp/org/ob-io.el
@@ -1,6 +1,6 @@
 ;;; ob-io.el --- Babel Functions for Io              -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Andrzej Lichnerowicz
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-java.el b/lisp/org/ob-java.el
index d6301bf..b055f85 100644
--- a/lisp/org/ob-java.el
+++ b/lisp/org/ob-java.el
@@ -1,6 +1,6 @@
 ;;; ob-java.el --- Babel Functions for Java          -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-js.el b/lisp/org/ob-js.el
index 38c8c39..233aa58 100644
--- a/lisp/org/ob-js.el
+++ b/lisp/org/ob-js.el
@@ -1,6 +1,6 @@
 ;;; ob-js.el --- Babel Functions for Javascript      -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research, js
diff --git a/lisp/org/ob-keys.el b/lisp/org/ob-keys.el
index fc96df4..627648d 100644
--- a/lisp/org/ob-keys.el
+++ b/lisp/org/ob-keys.el
@@ -1,6 +1,6 @@
 ;;; ob-keys.el --- Key Bindings for Babel            -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-latex.el b/lisp/org/ob-latex.el
index 6a963e5..219b11c 100644
--- a/lisp/org/ob-latex.el
+++ b/lisp/org/ob-latex.el
@@ -1,6 +1,6 @@
 ;;; ob-latex.el --- Babel Functions for LaTeX        -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-ledger.el b/lisp/org/ob-ledger.el
index 2a13314..5659929 100644
--- a/lisp/org/ob-ledger.el
+++ b/lisp/org/ob-ledger.el
@@ -1,6 +1,6 @@
 ;;; ob-ledger.el --- Babel Functions for Ledger      -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric S Fraga
 ;; Keywords: literate programming, reproducible research, accounting
diff --git a/lisp/org/ob-lilypond.el b/lisp/org/ob-lilypond.el
index 3d3cc07..25e5dbc 100644
--- a/lisp/org/ob-lilypond.el
+++ b/lisp/org/ob-lilypond.el
@@ -1,6 +1,6 @@
 ;;; ob-lilypond.el --- Babel Functions for Lilypond  -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Martyn Jago
 ;; Keywords: babel language, literate programming
diff --git a/lisp/org/ob-lisp.el b/lisp/org/ob-lisp.el
index b846138..6fef0da 100644
--- a/lisp/org/ob-lisp.el
+++ b/lisp/org/ob-lisp.el
@@ -1,6 +1,6 @@
 ;;; ob-lisp.el --- Babel Functions for Common Lisp   -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Authors: Joel Boehland
 ;;      Eric Schulte
diff --git a/lisp/org/ob-lob.el b/lisp/org/ob-lob.el
index 6af6bf0..4197f2d 100644
--- a/lisp/org/ob-lob.el
+++ b/lisp/org/ob-lob.el
@@ -1,6 +1,6 @@
 ;;; ob-lob.el --- Functions Supporting the Library of Babel -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Authors: Eric Schulte
 ;;      Dan Davison
diff --git a/lisp/org/ob-lua.el b/lisp/org/ob-lua.el
index 6ae72c7..6f77941 100644
--- a/lisp/org/ob-lua.el
+++ b/lisp/org/ob-lua.el
@@ -1,6 +1,6 @@
 ;;; ob-lua.el --- Org Babel functions for Lua evaluation -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2014, 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014, 2016-2019 Free Software Foundation, Inc.
 
 ;; Authors: Dieter Schoen
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-makefile.el b/lisp/org/ob-makefile.el
index 4687037..938d17b 100644
--- a/lisp/org/ob-makefile.el
+++ b/lisp/org/ob-makefile.el
@@ -1,6 +1,6 @@
 ;;; ob-makefile.el --- Babel Functions for Makefile  -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;;        Thomas S. Dye
diff --git a/lisp/org/ob-matlab.el b/lisp/org/ob-matlab.el
index 5baac77..4ad188a 100644
--- a/lisp/org/ob-matlab.el
+++ b/lisp/org/ob-matlab.el
@@ -1,6 +1,6 @@
 ;;; ob-matlab.el --- Babel support for Matlab        -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Dan Davison
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-maxima.el b/lisp/org/ob-maxima.el
index b42a4b8..c8f3a61 100644
--- a/lisp/org/ob-maxima.el
+++ b/lisp/org/ob-maxima.el
@@ -1,6 +1,6 @@
 ;;; ob-maxima.el --- Babel Functions for Maxima      -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric S Fraga
 ;;     Eric Schulte
diff --git a/lisp/org/ob-mscgen.el b/lisp/org/ob-mscgen.el
index b2c2443..86fcc28 100644
--- a/lisp/org/ob-mscgen.el
+++ b/lisp/org/ob-mscgen.el
@@ -1,6 +1,6 @@
 ;;; ob-msc.el --- Babel Functions for Mscgen         -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Juan Pechiar
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-ocaml.el b/lisp/org/ob-ocaml.el
index 90926b5..e8f801b 100644
--- a/lisp/org/ob-ocaml.el
+++ b/lisp/org/ob-ocaml.el
@@ -1,6 +1,6 @@
 ;;; ob-ocaml.el --- Babel Functions for Ocaml        -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-octave.el b/lisp/org/ob-octave.el
index c7339cf..28c7ad2 100644
--- a/lisp/org/ob-octave.el
+++ b/lisp/org/ob-octave.el
@@ -1,6 +1,6 @@
 ;;; ob-octave.el --- Babel Functions for Octave and Matlab -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Dan Davison
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-org.el b/lisp/org/ob-org.el
index 7a495fa..def2509 100644
--- a/lisp/org/ob-org.el
+++ b/lisp/org/ob-org.el
@@ -1,6 +1,6 @@
 ;;; ob-org.el --- Babel Functions for Org Code Blocks -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-perl.el b/lisp/org/ob-perl.el
index 85806fd..810271f 100644
--- a/lisp/org/ob-perl.el
+++ b/lisp/org/ob-perl.el
@@ -1,6 +1,6 @@
 ;;; ob-perl.el --- Babel Functions for Perl          -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Authors: Dan Davison
 ;;      Eric Schulte
diff --git a/lisp/org/ob-picolisp.el b/lisp/org/ob-picolisp.el
index cc2c8a8..c0f0125 100644
--- a/lisp/org/ob-picolisp.el
+++ b/lisp/org/ob-picolisp.el
@@ -1,6 +1,6 @@
 ;;; ob-picolisp.el --- Babel Functions for Picolisp  -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Authors: Thorsten Jolitz
 ;;      Eric Schulte
diff --git a/lisp/org/ob-plantuml.el b/lisp/org/ob-plantuml.el
index 9a9313e..91229a2 100644
--- a/lisp/org/ob-plantuml.el
+++ b/lisp/org/ob-plantuml.el
@@ -1,6 +1,6 @@
 ;;; ob-plantuml.el --- Babel Functions for Plantuml  -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Zhang Weize
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-processing.el b/lisp/org/ob-processing.el
index 1a88930..97ab88c 100644
--- a/lisp/org/ob-processing.el
+++ b/lisp/org/ob-processing.el
@@ -1,6 +1,6 @@
 ;;; ob-processing.el --- Babel functions for processing -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Jarmo Hurri (adapted from ob-asymptote.el written by Eric Schulte)
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-python.el b/lisp/org/ob-python.el
index 9f1234b..546e35a 100644
--- a/lisp/org/ob-python.el
+++ b/lisp/org/ob-python.el
@@ -1,6 +1,6 @@
 ;;; ob-python.el --- Babel Functions for Python      -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Authors: Eric Schulte
 ;;      Dan Davison
diff --git a/lisp/org/ob-ref.el b/lisp/org/ob-ref.el
index 3efa17f..2198a84 100644
--- a/lisp/org/ob-ref.el
+++ b/lisp/org/ob-ref.el
@@ -1,6 +1,6 @@
 ;;; ob-ref.el --- Babel Functions for Referencing External Data -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Authors: Eric Schulte
 ;;      Dan Davison
diff --git a/lisp/org/ob-ruby.el b/lisp/org/ob-ruby.el
index 7686ac4..e0e1765 100644
--- a/lisp/org/ob-ruby.el
+++ b/lisp/org/ob-ruby.el
@@ -1,6 +1,6 @@
 ;;; ob-ruby.el --- Babel Functions for Ruby          -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-sass.el b/lisp/org/ob-sass.el
index af55d76..b19314c 100644
--- a/lisp/org/ob-sass.el
+++ b/lisp/org/ob-sass.el
@@ -1,6 +1,6 @@
 ;;; ob-sass.el --- Babel Functions for the Sass CSS generation language -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-scheme.el b/lisp/org/ob-scheme.el
index 0efe5f3..798cf4e 100644
--- a/lisp/org/ob-scheme.el
+++ b/lisp/org/ob-scheme.el
@@ -1,6 +1,6 @@
 ;;; ob-scheme.el --- Babel Functions for Scheme      -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Authors: Eric Schulte
 ;;         Michael Gauland
diff --git a/lisp/org/ob-screen.el b/lisp/org/ob-screen.el
index fb7c8e2..a3d7984 100644
--- a/lisp/org/ob-screen.el
+++ b/lisp/org/ob-screen.el
@@ -1,6 +1,6 @@
 ;;; ob-screen.el --- Babel Support for Interactive Terminal -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Benjamin Andresen
 ;; Keywords: literate programming, interactive shell
diff --git a/lisp/org/ob-sed.el b/lisp/org/ob-sed.el
index b2c80f8..33751b8 100644
--- a/lisp/org/ob-sed.el
+++ b/lisp/org/ob-sed.el
@@ -1,6 +1,6 @@
 ;;; ob-sed.el --- Babel Functions for Sed Scripts    -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Bjarte Johansen
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-shell.el b/lisp/org/ob-shell.el
index 362dfd5..8e080c6 100644
--- a/lisp/org/ob-shell.el
+++ b/lisp/org/ob-shell.el
@@ -1,6 +1,6 @@
 ;;; ob-shell.el --- Babel Functions for Shell Evaluation -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-shen.el b/lisp/org/ob-shen.el
index d81e7d6..af3bd2b 100644
--- a/lisp/org/ob-shen.el
+++ b/lisp/org/ob-shen.el
@@ -1,6 +1,6 @@
 ;;; ob-shen.el --- Babel Functions for Shen          -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research, shen
diff --git a/lisp/org/ob-sql.el b/lisp/org/ob-sql.el
index 959ede3..17447b4 100644
--- a/lisp/org/ob-sql.el
+++ b/lisp/org/ob-sql.el
@@ -1,6 +1,6 @@
 ;;; ob-sql.el --- Babel Functions for SQL            -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-sqlite.el b/lisp/org/ob-sqlite.el
index 42528a3..04bf4fe 100644
--- a/lisp/org/ob-sqlite.el
+++ b/lisp/org/ob-sqlite.el
@@ -1,6 +1,6 @@
 ;;; ob-sqlite.el --- Babel Functions for SQLite Databases -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-stan.el b/lisp/org/ob-stan.el
index ffc2681..47b871d 100644
--- a/lisp/org/ob-stan.el
+++ b/lisp/org/ob-stan.el
@@ -1,6 +1,6 @@
 ;;; ob-stan.el --- Babel Functions for Stan          -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Kyle Meyer
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-table.el b/lisp/org/ob-table.el
index f6a5c88..93a8165 100644
--- a/lisp/org/ob-table.el
+++ b/lisp/org/ob-table.el
@@ -1,6 +1,6 @@
 ;;; ob-table.el --- Support for Calling Babel Functions from Tables -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-tangle.el b/lisp/org/ob-tangle.el
index 48eddb7..3c16200 100644
--- a/lisp/org/ob-tangle.el
+++ b/lisp/org/ob-tangle.el
@@ -1,6 +1,6 @@
 ;;; ob-tangle.el --- Extract Source Code From Org Files -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob-vala.el b/lisp/org/ob-vala.el
index 96c37e3..5d14002 100644
--- a/lisp/org/ob-vala.el
+++ b/lisp/org/ob-vala.el
@@ -1,6 +1,6 @@
 ;;; ob-vala.el --- Babel functions for Vala evaluation -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Christian Garbs <address@hidden>
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/ob.el b/lisp/org/ob.el
index 35f65ff..86d6928 100644
--- a/lisp/org/ob.el
+++ b/lisp/org/ob.el
@@ -1,6 +1,6 @@
 ;;; ob.el --- Working with Code Blocks in Org        -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Authors: Eric Schulte
 ;; Keywords: literate programming, reproducible research
diff --git a/lisp/org/org-agenda.el b/lisp/org/org-agenda.el
index 98e89eb..23ee8d7 100644
--- a/lisp/org/org-agenda.el
+++ b/lisp/org/org-agenda.el
@@ -1,6 +1,6 @@
 ;;; org-agenda.el --- Dynamic task and appointment lists for Org
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -2882,13 +2882,12 @@ Pressing `<' twice means to restrict to the current 
subtree or region
             (let* ((m (org-agenda-get-any-marker))
                    (note (and m (org-entry-get m "THEFLAGGINGNOTE"))))
               (when note
-                (message (concat
-                          "FLAGGING-NOTE ([?] for more info): "
-                          (org-add-props
-                              (replace-regexp-in-string
-                               "\\\\n" "//"
-                               (copy-sequence note))
-                              nil 'face 'org-warning)))))))
+                (message "FLAGGING-NOTE ([?] for more info): %s"
+                         (org-add-props
+                          (replace-regexp-in-string
+                           "\\\\n" "//"
+                           (copy-sequence note))
+                          nil 'face 'org-warning))))))
         t t))
        ((equal org-keys "#") (call-interactively 
'org-agenda-list-stuck-projects))
        ((equal org-keys "/") (call-interactively 'org-occur-in-agenda-files))
@@ -5491,8 +5490,8 @@ displayed in agenda view."
            (substring
             (format-time-string
              (car org-time-stamp-formats)
-             (apply #'encode-time      ; DATE bound by calendar
-                    (list 0 0 0 (nth 1 date) (car date) (nth 2 date))))
+             (encode-time      ; DATE bound by calendar
+              0 0 0 (nth 1 date) (car date) (nth 2 date)))
             1 11))
           "\\|\\(<[0-9]+-[0-9]+-[0-9]+[^>\n]+?\\+[0-9]+[hdwmy]>\\)"
           "\\|\\(<%%\\(([^>\n]+)\\)>\\)"))
@@ -5742,8 +5741,8 @@ then those holidays will be skipped."
                   (substring
                    (format-time-string
                     (car org-time-stamp-formats)
-                    (apply 'encode-time  ; DATE bound by calendar
-                           (list 0 0 0 (nth 1 date) (car date) (nth 2 date))))
+                    (encode-time  ; DATE bound by calendar
+                     0 0 0 (nth 1 date) (car date) (nth 2 date)))
                    1 11))))
         (org-agenda-search-headline-for-time nil)
         marker hdmarker priority category level tags closedp
@@ -5860,21 +5859,19 @@ See also the user option 
`org-agenda-clock-consistency-checks'."
              (throw 'next t))
            (setq ts (match-string 1)
                  te (match-string 3)
-                 ts (float-time
-                     (apply #'encode-time (org-parse-time-string ts)))
-                 te (float-time
-                     (apply #'encode-time (org-parse-time-string te)))
+                 ts (float-time (org-time-string-to-time ts))
+                 te (float-time (org-time-string-to-time te))
                  dt (- te ts))))
        (cond
         ((> dt (* 60 maxtime))
          ;; a very long clocking chunk
          (setq issue (format "Clocking interval is very long: %s"
-                             (org-duration-from-minutes (floor (/ dt 60.))))
+                             (org-duration-from-minutes (floor dt 60)))
                face (or (plist-get pl :long-face) face)))
         ((< dt (* 60 mintime))
          ;; a very short clocking chunk
          (setq issue (format "Clocking interval is very short: %s"
-                             (org-duration-from-minutes (floor (/ dt 60.))))
+                             (org-duration-from-minutes (floor dt 60)))
                face (or (plist-get pl :short-face) face)))
         ((and (> tlend 0) (< ts tlend))
          ;; Two clock entries are overlapping
@@ -5914,8 +5911,8 @@ See also the user option 
`org-agenda-clock-consistency-checks'."
        (throw 'exit t))
     ;; We have a shorter gap.
     ;; Now we have to get the minute of the day when these times are
-    (let* ((t1dec (decode-time (seconds-to-time t1)))
-          (t2dec (decode-time (seconds-to-time t2)))
+    (let* ((t1dec (decode-time t1))
+          (t2dec (decode-time t2))
           ;; compute the minute on the day
           (min1 (+ (nth 1 t1dec) (* 60 (nth 2 t1dec))))
           (min2 (+ (nth 1 t2dec) (* 60 (nth 2 t2dec)))))
@@ -9448,7 +9445,7 @@ the resulting entry will not be shown.  When TEXT is 
empty, switch to
     (goto-char (point-min))
     (cond
      ((eq type 'anniversary)
-      (or (re-search-forward "^*[ \t]+Anniversaries" nil t)
+      (or (re-search-forward "^\\*[ \t]+Anniversaries" nil t)
          (progn
            (or (org-at-heading-p t)
                (progn
@@ -10159,8 +10156,7 @@ to override `appt-message-warning-time'."
          ;; Do not use `org-today' here because appt only takes
          ;; time and without date as argument, so it may pass wrong
          ;; information otherwise
-         (today (org-date-to-gregorian
-                 (time-to-days (current-time))))
+        (today (org-date-to-gregorian (time-to-days nil)))
          (org-agenda-restrict nil)
          (files (org-agenda-files 'unrestricted)) entries file
          (org-agenda-buffer nil))
diff --git a/lisp/org/org-archive.el b/lisp/org/org-archive.el
index e020ec2..dc0dfa4 100644
--- a/lisp/org/org-archive.el
+++ b/lisp/org/org-archive.el
@@ -1,6 +1,6 @@
 ;;; org-archive.el --- Archiving for Org             -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
diff --git a/lisp/org/org-attach.el b/lisp/org/org-attach.el
index 203e71e..f430cd5 100644
--- a/lisp/org/org-attach.el
+++ b/lisp/org/org-attach.el
@@ -1,6 +1,6 @@
 ;;; org-attach.el --- Manage file attachments to Org tasks -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 ;; Keywords: org data task
diff --git a/lisp/org/org-bbdb.el b/lisp/org/org-bbdb.el
index 5d36379..2c4f126 100644
--- a/lisp/org/org-bbdb.el
+++ b/lisp/org/org-bbdb.el
@@ -1,6 +1,6 @@
 ;;; org-bbdb.el --- Support for links to BBDB entries -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Authors: Carsten Dominik <carsten at orgmode dot org>
 ;;       Thomas Baumann <thomas dot baumann at ch dot tum dot de>
diff --git a/lisp/org/org-bibtex.el b/lisp/org/org-bibtex.el
index 9dab0b4..218112c 100644
--- a/lisp/org/org-bibtex.el
+++ b/lisp/org/org-bibtex.el
@@ -1,6 +1,6 @@
 ;;; org-bibtex.el --- Org links to BibTeX entries    -*- lexical-binding: t; 
-*-
 ;;
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 ;;
 ;; Authors: Bastien Guerry <address@hidden>
 ;;       Carsten Dominik <carsten dot dominik at gmail dot com>
diff --git a/lisp/org/org-capture.el b/lisp/org/org-capture.el
index 3de386c..dbba33b 100644
--- a/lisp/org/org-capture.el
+++ b/lisp/org/org-capture.el
@@ -1,6 +1,6 @@
 ;;; org-capture.el --- Fast note taking in Org       -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -1000,8 +1000,7 @@ Store them in the capture property list."
                   (equal current-prefix-arg 1))
               ;; Prompt for date.
               (let ((prompt-time (org-read-date
-                                  nil t nil "Date for tree entry:"
-                                  (current-time))))
+                                  nil t nil "Date for tree entry:" nil)))
                 (org-capture-put
                  :default-time
                  (cond ((and (or (not (boundp 'org-time-was-given))
@@ -1009,9 +1008,8 @@ Store them in the capture property list."
                              (not (= (time-to-days prompt-time) (org-today))))
                         ;; Use 00:00 when no time is given for another
                         ;; date than today?
-                        (apply #'encode-time
-                               (append '(0 0 0)
-                                       (cl-cdddr (decode-time prompt-time)))))
+                        (apply #'encode-time 0 0 0
+                               (cl-cdddr (decode-time prompt-time))))
                        ((string-match "\\([^ ]+\\)--?[^ ]+[ ]+\\(.*\\)"
                                       org-read-date-final-answer)
                         ;; Replace any time range by its start.
diff --git a/lisp/org/org-clock.el b/lisp/org/org-clock.el
index 9be0d5b..62c7cd9 100644
--- a/lisp/org/org-clock.el
+++ b/lisp/org/org-clock.el
@@ -1,6 +1,6 @@
 ;;; org-clock.el --- The time clocking code for Org mode -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -723,8 +723,8 @@ menu\nmouse-2 will jump to task"))
 The time returned includes the time spent on this task in
 previous clocking intervals."
   (let ((currently-clocked-time
-        (floor (- (float-time)
-                  (float-time org-clock-start-time)) 60)))
+        (floor (encode-time (time-since org-clock-start-time) 'integer)
+               60)))
     (+ currently-clocked-time (or org-clock-total-time 0))))
 
 (defun org-clock-modify-effort-estimate (&optional value)
@@ -932,7 +932,7 @@ If necessary, clock-out of the currently active clock."
        (unless (org-is-active-clock clock)
          (org-clock-clock-in clock t))))
 
-     ((not (time-less-p resolve-to (current-time)))
+     ((not (time-less-p resolve-to nil))
       (error "RESOLVE-TO must refer to a time in the past"))
 
      (t
@@ -1033,8 +1033,8 @@ to be CLOCKED OUT."))))
                                   nil 45)))
                (and (not (memq char-pressed '(?i ?q))) char-pressed)))))
         (default
-          (floor (/ (float-time
-                     (time-subtract (current-time) last-valid)) 60)))
+          (floor (encode-time (time-since last-valid) 'integer)
+                 60))
         (keep
          (and (memq ch '(?k ?K))
               (read-number "Keep how many minutes? " default)))
@@ -1042,8 +1042,9 @@ to be CLOCKED OUT."))))
          (and (memq ch '(?g ?G))
               (read-number "Got back how many minutes ago? " default)))
         (subtractp (memq ch '(?s ?S)))
-        (barely-started-p (< (- (float-time last-valid)
-                                (float-time (cdr clock))) 45))
+        (barely-started-p (time-less-p
+                           (time-subtract last-valid (cdr clock))
+                           45))
         (start-over (and subtractp barely-started-p)))
     (cond
      ((memq ch '(?j ?J))
@@ -1069,10 +1070,9 @@ to be CLOCKED OUT."))))
                   (and gotback (= gotback default)))
               'now)
              (keep
-              (time-add last-valid (seconds-to-time (* 60 keep))))
+              (time-add last-valid (* 60 keep)))
              (gotback
-              (time-subtract (current-time)
-                             (seconds-to-time (* 60 gotback))))
+              (time-since (* 60 gotback)))
              (t
               (error "Unexpected, please report this as a bug")))
        (and gotback last-valid)
@@ -1102,8 +1102,8 @@ If `only-dangling-p' is non-nil, only ask to resolve 
dangling
                        (lambda (clock)
                          (format
                           "Dangling clock started %d mins ago"
-                          (floor (- (float-time)
-                                    (float-time (cdr clock)))
+                          (floor (encode-time (time-since (cdr clock))
+                                              'integer)
                                  60)))))
                   (or last-valid
                       (cdr clock)))))))))))
@@ -1154,8 +1154,7 @@ so long."
             org-clock-marker (marker-buffer org-clock-marker))
     (let* ((org-clock-user-idle-seconds (org-user-idle-seconds))
           (org-clock-user-idle-start
-           (time-subtract (current-time)
-                          (seconds-to-time org-clock-user-idle-seconds)))
+           (time-since org-clock-user-idle-seconds))
           (org-clock-resolving-clocks-due-to-idleness t))
       (if (> org-clock-user-idle-seconds (* 60 org-clock-idle-time))
          (org-clock-resolve
@@ -1164,9 +1163,8 @@ so long."
           (lambda (_)
             (format "Clocked in & idle for %.1f mins"
                     (/ (float-time
-                        (time-subtract (current-time)
-                                       org-clock-user-idle-start))
-                       60.0)))
+                        (time-since org-clock-user-idle-start))
+                       60)))
           org-clock-user-idle-start)))))
 
 (defvar org-clock-current-task nil "Task currently clocked in.")
@@ -1293,8 +1291,7 @@ the default behavior."
           (setq ts (concat "[" (match-string 1) "]"))
           (goto-char (match-end 1))
           (setq org-clock-start-time
-                (apply 'encode-time
-                       (org-parse-time-string (match-string 1))))
+                (org-time-string-to-time (match-string 1)))
           (setq org-clock-effort (org-entry-get (point) org-effort-property))
           (setq org-clock-total-time (org-clock-sum-current-item
                                       (org-clock-get-sum-start))))
@@ -1324,9 +1321,11 @@ the default behavior."
                          (y-or-n-p
                           (format
                            "You stopped another clock %d mins ago; start this 
one from then? "
-                           (/ (- (float-time
-                                  (org-current-time org-clock-rounding-minutes 
t))
-                                 (float-time leftover))
+                           (/ (encode-time
+                               (time-subtract
+                                (org-current-time org-clock-rounding-minutes t)
+                                leftover)
+                               'integer)
                               60)))
                          leftover)
                     start-time
@@ -1431,7 +1430,7 @@ The time is always returned as UTC."
             (day (nth 3 dt)))
        (if (< hour org-extend-today-until) (setf (nth 3 dt) (1- day)))
        (setf (nth 2 dt) org-extend-today-until)
-       (apply #'encode-time (append (list 0 0) (nthcdr 2 dt)))))
+       (apply #'encode-time 0 0 (nthcdr 2 dt))))
      ((or (equal cmt "all")
          (and (or (not cmt) (equal cmt "auto"))
               (not lr)))
@@ -1577,21 +1576,19 @@ to, overriding the existing value of 
`org-clock-out-switch-to-state'."
          (delete-region (point) (point-at-eol))
          (insert "--")
          (setq te (org-insert-time-stamp (or at-time now) 'with-hm 'inactive))
-         (setq s (- (float-time
-                     (apply #'encode-time (org-parse-time-string te)))
-                    (float-time
-                     (apply #'encode-time (org-parse-time-string ts))))
-               h (floor (/ s 3600))
-               s (- s (* 3600 h))
-               m (floor (/ s 60))
-               s (- s (* 60 s)))
+         (setq s (encode-time (time-subtract
+                               (org-time-string-to-time te)
+                               (org-time-string-to-time ts))
+                              'integer)
+               h (floor s 3600)
+               m (floor (mod s 3600) 60))
          (insert " => " (format "%2d:%02d" h m))
          (move-marker org-clock-marker nil)
          (move-marker org-clock-hd-marker nil)
          ;; Possibly remove zero time clocks.  However, do not add
          ;; a note associated to the CLOCK line in this case.
          (cond ((and org-clock-out-remove-zero-time-clocks
-                     (= (+ h m) 0))
+                     (= 0 h m))
                 (setq remove t)
                 (delete-region (line-beginning-position)
                                (line-beginning-position 2)))
@@ -1625,9 +1622,10 @@ to, overriding the existing value of 
`org-clock-out-switch-to-state'."
                                                "\\>"))))
                  (org-todo org-clock-out-switch-to-state))))))
          (force-mode-line-update)
-         (message (concat "Clock stopped at %s after "
-                          (org-duration-from-minutes (+ (* 60 h) m)) "%s")
-                  te (if remove " => LINE REMOVED" ""))
+         (message (if remove
+                      "Clock stopped at %s after %s => LINE REMOVED"
+                    "Clock stopped at %s after %s")
+                  te (org-duration-from-minutes (+ (* 60 h) m)))
          (run-hooks 'org-clock-out-hook)
          (unless (org-clocking-p)
            (setq org-clock-current-task nil)))))))
@@ -1813,15 +1811,15 @@ PROPNAME lets you set a custom text property instead of 
:org-clock-minutes."
          ((match-end 2)
           ;; Two time stamps.
           (let* ((ts (float-time
-                      (apply #'encode-time
-                             (save-match-data
-                               (org-parse-time-string (match-string 2))))))
+                      (encode-time
+                       (save-match-data
+                         (org-parse-time-string (match-string 2))))))
                  (te (float-time
-                      (apply #'encode-time
-                             (org-parse-time-string (match-string 3)))))
+                      (encode-time
+                       (org-parse-time-string (match-string 3)))))
                  (dt (- (if tend (min te tend) te)
                         (if tstart (max ts tstart) ts))))
-            (when (> dt 0) (cl-incf t1 (floor (/ dt 60))))))
+            (when (> dt 0) (cl-incf t1 (floor dt 60)))))
          ((match-end 4)
           ;; A naked time.
           (setq t1 (+ t1 (string-to-number (match-string 5))
@@ -1835,8 +1833,9 @@ PROPNAME lets you set a custom text property instead of 
:org-clock-minutes."
                      tend
                      (>= (float-time org-clock-start-time) tstart)
                      (<= (float-time org-clock-start-time) tend))
-            (let ((time (floor (- (float-time)
-                                  (float-time org-clock-start-time))
+            (let ((time (floor (encode-time
+                                (time-since org-clock-start-time)
+                                'integer)
                                60)))
               (setq t1 (+ t1 time))))
           (let* ((headline-forced
@@ -1927,13 +1926,14 @@ Use `\\[org-clock-remove-overlays]' to remove the 
subtree times."
                    nil 'local))))
     (let* ((h (/ org-clock-file-total-minutes 60))
           (m (- org-clock-file-total-minutes (* 60 h))))
-      (message (concat (format "Total file time%s: "
-                              (cond (todayp " for today")
-                                    (customp " (custom)")
-                                    (t "")))
-                      (org-duration-from-minutes
-                       org-clock-file-total-minutes)
-                      " (%d hours and %d minutes)")
+      (message (cond
+               (todayp
+                "Total file time for today: %s (%d hours and %d minutes)")
+               (customp
+                "Total file time (custom): %s (%d hours and %d minutes)")
+               (t
+                "Total file time: %s (%d hours and %d minutes)"))
+              (org-duration-from-minutes org-clock-file-total-minutes)
               h m))))
 
 (defvar-local org-clock-overlays nil)
@@ -2704,24 +2704,24 @@ LEVEL is an integer.  Indent by two spaces per level 
above 1."
       (pcase-let ((`(,month ,day ,year) (calendar-gregorian-from-absolute ts)))
        (setq ts (float-time (encode-time 0 0 0 day month year)))))
      (ts
-      (setq ts (float-time (apply #'encode-time (org-parse-time-string ts))))))
+      (setq ts (float-time (org-time-string-to-time ts)))))
     (cond
      ((numberp te)
       ;; Likewise for te.
       (pcase-let ((`(,month ,day ,year) (calendar-gregorian-from-absolute te)))
        (setq te (float-time (encode-time 0 0 0 day month year)))))
      (te
-      (setq te (float-time (apply #'encode-time (org-parse-time-string te))))))
+      (setq te (float-time (org-time-string-to-time te)))))
     (setq tsb
          (if (eq step0 'week)
-             (let ((dow (nth 6 (decode-time (seconds-to-time ts)))))
+             (let ((dow (nth 6 (decode-time ts))))
                (if (<= dow ws) ts
                  (- ts (* 86400 (- dow ws)))))
            ts))
     (while (< tsb te)
       (unless (bolp) (insert "\n"))
-      (let ((start-time (seconds-to-time (max tsb ts))))
-       (cl-incf tsb (let ((dow (nth 6 (decode-time (seconds-to-time tsb)))))
+      (let ((start-time (max tsb ts)))
+       (cl-incf tsb (let ((dow (nth 6 (decode-time tsb))))
                       (if (or (eq step0 'day)
                               (= dow ws))
                           step
@@ -2741,7 +2741,7 @@ LEVEL is an integer.  Indent by two spaces per level 
above 1."
                  :tstart (format-time-string (org-time-stamp-format t t)
                                              start-time)
                  :tend (format-time-string (org-time-stamp-format t t)
-                                           (seconds-to-time (min te tsb))))))))
+                                           (min te tsb)))))))
          (re-search-forward "^[ \t]*#\\+END:")
          (when (and stepskip0 (equal step-time 0))
            ;; Remove the empty table
@@ -2882,18 +2882,16 @@ Otherwise, return nil."
                     (<= org-clock-marker (point-at-eol)))
            ;; The clock is running here
            (setq org-clock-start-time
-                 (apply 'encode-time
-                        (org-parse-time-string (match-string 1))))
+                 (org-time-string-to-time (match-string 1)))
            (org-clock-update-mode-line)))
         (t
          (and (match-end 4) (delete-region (match-beginning 4) (match-end 4)))
          (end-of-line 1)
          (setq ts (match-string 1)
                te (match-string 3))
-         (setq s (- (float-time
-                     (apply #'encode-time (org-parse-time-string te)))
-                    (float-time
-                     (apply #'encode-time (org-parse-time-string ts))))
+         (setq s (float-time
+                  (time-subtract (org-time-string-to-time te)
+                                 (org-time-string-to-time ts)))
                neg (< s 0)
                s (abs s)
                h (floor (/ s 3600))
diff --git a/lisp/org/org-colview.el b/lisp/org/org-colview.el
index cb5c091..799cc60 100644
--- a/lisp/org/org-colview.el
+++ b/lisp/org/org-colview.el
@@ -1,6 +1,6 @@
 ;;; org-colview.el --- Column View in Org            -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -540,7 +540,7 @@ Where possible, use the standard interface for changing 
this line."
         (eol (line-end-position))
         (pom (or (get-text-property bol 'org-hd-marker) (point)))
         (key (or key (get-char-property (point) 'org-columns-key)))
-        (org-columns--time (float-time (current-time)))
+        (org-columns--time (float-time))
         (action
          (pcase key
            ("CLOCKSUM"
@@ -719,7 +719,7 @@ around it."
       (setq time-after (copy-sequence time))
       (setf (nth 3 time-before) (1- (nth 3 time)))
       (setf (nth 3 time-after) (1+ (nth 3 time)))
-      (mapcar (lambda (x) (format-time-string fmt (apply 'encode-time x)))
+      (mapcar (lambda (x) (format-time-string fmt (encode-time x)))
              (list time-before time time-after)))))
 
 (defun org-columns-open-link (&optional arg)
@@ -790,7 +790,7 @@ When COLUMNS-FMT-STRING is non-nil, use it as the column 
format."
   (org-columns-goto-top-level)
   ;; Initialize `org-columns-current-fmt' and
   ;; `org-columns-current-fmt-compiled'.
-  (let ((org-columns--time (float-time (current-time))))
+  (let ((org-columns--time (float-time)))
     (org-columns-get-format columns-fmt-string)
     (unless org-columns-inhibit-recalculation (org-columns-compute-all))
     (save-excursion
@@ -1070,7 +1070,7 @@ as a canonical duration, i.e., using units defined in
   (cond
    ((string-match-p org-ts-regexp s)
     (/ (- org-columns--time
-         (float-time (apply #'encode-time (org-parse-time-string s))))
+         (float-time (org-time-string-to-time s)))
        60))
    ((org-duration-p s) (org-duration-to-minutes s t)) ;skip user units
    (t (user-error "Invalid age: %S" s))))
@@ -1494,7 +1494,7 @@ PARAMS is a property list of parameters:
   (if (markerp org-columns-begin-marker)
       (move-marker org-columns-begin-marker (point))
     (setq org-columns-begin-marker (point-marker)))
-  (let* ((org-columns--time (float-time (current-time)))
+  (let* ((org-columns--time (float-time))
         (fmt
          (cond
           ((bound-and-true-p org-agenda-overriding-columns-format))
diff --git a/lisp/org/org-compat.el b/lisp/org/org-compat.el
index 1fd408d..062bb4c 100644
--- a/lisp/org/org-compat.el
+++ b/lisp/org/org-compat.el
@@ -1,6 +1,6 @@
 ;;; org-compat.el --- Compatibility Code for Older Emacsen -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
diff --git a/lisp/org/org-crypt.el b/lisp/org/org-crypt.el
index 31850a4..9cd76c9 100644
--- a/lisp/org/org-crypt.el
+++ b/lisp/org/org-crypt.el
@@ -1,5 +1,5 @@
 ;;; org-crypt.el --- Public Key Encryption for Org Entries -*- 
lexical-binding: t; -*-
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Emacs Lisp Archive Entry
 ;; Filename: org-crypt.el
diff --git a/lisp/org/org-ctags.el b/lisp/org/org-ctags.el
index 4898174..111be37 100644
--- a/lisp/org/org-ctags.el
+++ b/lisp/org/org-ctags.el
@@ -1,6 +1,6 @@
 ;;; org-ctags.el - Integrate Emacs "tags" Facility with Org -*- 
lexical-binding: t; -*-
 ;;
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Paul Sexton <address@hidden>
 
diff --git a/lisp/org/org-datetree.el b/lisp/org/org-datetree.el
index d00bad2..b4797de 100644
--- a/lisp/org/org-datetree.el
+++ b/lisp/org/org-datetree.el
@@ -1,6 +1,6 @@
 ;;; org-datetree.el --- Create date entries in a tree -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -138,15 +138,16 @@ will be built under the headline at point."
        "^\\*+[ \t]+%d-%02d-\\([0123][0-9]\\) \\w+$"
        year month day))))
 
-(defun org-datetree--find-create (regex year &optional month day insert)
-  "Find the datetree matched by REGEX for YEAR, MONTH, or DAY.
-REGEX is passed to `format' with YEAR, MONTH, and DAY as
+(defun org-datetree--find-create
+    (regex-template year &optional month day insert)
+  "Find the datetree matched by REGEX-TEMPLATE for YEAR, MONTH, or DAY.
+REGEX-TEMPLATE is passed to `format' with YEAR, MONTH, and DAY as
 arguments.  Match group 1 is compared against the specified date
 component.  If INSERT is non-nil and there is no match then it is
 inserted into the buffer."
   (when (or month day)
     (org-narrow-to-subtree))
-  (let ((re (format regex year month day))
+  (let ((re (format regex-template year month day))
        match)
     (goto-char (point-min))
     (while (and (setq match (re-search-forward re nil t))
diff --git a/lisp/org/org-docview.el b/lisp/org/org-docview.el
index a467212..7e1287f 100644
--- a/lisp/org/org-docview.el
+++ b/lisp/org/org-docview.el
@@ -1,6 +1,6 @@
 ;;; org-docview.el --- Support for links to doc-view-mode buffers -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Jan Böcker <jan.boecker at jboecker dot de>
 ;; Keywords: outlines, hypermedia, calendar, wp
diff --git a/lisp/org/org-duration.el b/lisp/org/org-duration.el
index 1c962ba..770c72f 100644
--- a/lisp/org/org-duration.el
+++ b/lisp/org/org-duration.el
@@ -1,6 +1,6 @@
 ;;; org-duration.el --- Library handling durations   -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Nicolas Goaziou <address@hidden>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -317,11 +317,10 @@ When optional argument CANONICAL is non-nil, ignore
 Raise an error if expected format is unknown."
   (pcase (or fmt org-duration-format)
     (`h:mm
-     (let ((minutes (floor minutes)))
-       (format "%d:%02d" (/ minutes 60) (mod minutes 60))))
+     (format "%d:%02d" (/ minutes 60) (mod minutes 60)))
     (`h:mm:ss
      (let* ((whole-minutes (floor minutes))
-           (seconds (floor (* 60 (- minutes whole-minutes)))))
+           (seconds (mod (* 60 minutes) 60)))
        (format "%s:%02d"
               (org-duration-from-minutes whole-minutes 'h:mm)
               seconds)))
@@ -402,9 +401,7 @@ Raise an error if expected format is unknown."
              (pcase-let* ((`(,unit . ,required?) units)
                           (modifier (org-duration--modifier unit canonical)))
                (cond ((<= modifier minutes)
-                      (let ((value (if (integerp modifier)
-                                       (/ (floor minutes) modifier)
-                                     (floor (/ minutes modifier)))))
+                      (let ((value (floor minutes modifier)))
                         (cl-decf minutes (* value modifier))
                         (format " %d%s" value unit)))
                      (required? (concat " 0" unit))
diff --git a/lisp/org/org-element.el b/lisp/org/org-element.el
index b8f1467..04e2fda 100644
--- a/lisp/org/org-element.el
+++ b/lisp/org/org-element.el
@@ -1,6 +1,6 @@
 ;;; org-element.el --- Parser for Org Syntax         -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -2119,7 +2119,7 @@ containing `:key', `:value', `:begin', `:end', 
`:post-blank' and
     ;; this corner case.
     (let ((begin (or (car affiliated) (point)))
          (post-affiliated (point))
-         (key (progn (looking-at "[ \t]*#\\+\\(\\S-+*\\):")
+         (key (progn (looking-at "[ \t]*#\\+\\(\\S-*\\):")
                      (upcase (match-string-no-properties 1))))
          (value (org-trim (buffer-substring-no-properties
                            (match-end 0) (point-at-eol))))
@@ -4765,13 +4765,13 @@ you want to help debugging the issue.")
 (defvar org-element-cache-sync-idle-time 0.6
   "Length, in seconds, of idle time before syncing cache.")
 
-(defvar org-element-cache-sync-duration (seconds-to-time 0.04)
+(defvar org-element-cache-sync-duration 0.04
   "Maximum duration, as a time value, for a cache synchronization.
 If the synchronization is not over after this delay, the process
 pauses and resumes after `org-element-cache-sync-break'
 seconds.")
 
-(defvar org-element-cache-sync-break (seconds-to-time 0.3)
+(defvar org-element-cache-sync-break 0.3
   "Duration, as a time value, of the pause between synchronizations.
 See `org-element-cache-sync-duration' for more information.")
 
@@ -5066,7 +5066,7 @@ Assume ELEMENT belongs to cache and that a cache is 
active."
 TIME-LIMIT is a time value or nil."
   (and time-limit
        (or (input-pending-p)
-          (time-less-p time-limit (current-time)))))
+          (time-less-p time-limit nil))))
 
 (defsubst org-element--cache-shift-positions (element offset &optional props)
   "Shift ELEMENT properties relative to buffer positions by OFFSET.
@@ -5120,8 +5120,7 @@ updated before current modification are actually 
submitted."
             (and next (aref next 0))
             threshold
             (and (not threshold)
-                 (time-add (current-time)
-                           org-element-cache-sync-duration))
+                 (time-add nil org-element-cache-sync-duration))
             future-change)
            ;; Request processed.  Merge current and next offsets and
            ;; transfer ending position.
diff --git a/lisp/org/org-entities.el b/lisp/org/org-entities.el
index e291b52..66837f3 100644
--- a/lisp/org/org-entities.el
+++ b/lisp/org/org-entities.el
@@ -1,6 +1,6 @@
 ;;; org-entities.el --- Support for Special Entities -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>,
 ;;         Ulf Stegemann <ulf at zeitform dot de>
diff --git a/lisp/org/org-eshell.el b/lisp/org/org-eshell.el
index 8a2e8af..2251a1b 100644
--- a/lisp/org/org-eshell.el
+++ b/lisp/org/org-eshell.el
@@ -1,6 +1,6 @@
 ;;; org-eshell.el - Support for Links to Working Directories in Eshell -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Konrad Hinsen <konrad.hinsen AT fastmail.net>
 
@@ -37,7 +37,7 @@
    eshell buffer) or a command line prefixed by a buffer name
    followed by a colon."
   (let* ((buffer-and-command
-          (if (string-match "\\([A-Za-z0-9-+*]+\\):\\(.*\\)" link)
+          (if (string-match "\\([A-Za-z0-9+*-]+\\):\\(.*\\)" link)
              (list (match-string 1 link)
                    (match-string 2 link))
             (list eshell-buffer-name link)))
diff --git a/lisp/org/org-eww.el b/lisp/org/org-eww.el
index 1b6112a..4988237 100644
--- a/lisp/org/org-eww.el
+++ b/lisp/org/org-eww.el
@@ -1,6 +1,6 @@
 ;;; org-eww.el --- Store url and kill from Eww mode for Org  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Marco Wahl <marcowahlsoft>a<gmailcom>
 ;; Keywords: link, eww
diff --git a/lisp/org/org-faces.el b/lisp/org/org-faces.el
index 750ada1..7ab5736 100644
--- a/lisp/org/org-faces.el
+++ b/lisp/org/org-faces.el
@@ -1,6 +1,6 @@
 ;;; org-faces.el --- Face definitions -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
diff --git a/lisp/org/org-feed.el b/lisp/org/org-feed.el
index fde19e6..b2dc4f3 100644
--- a/lisp/org/org-feed.el
+++ b/lisp/org/org-feed.el
@@ -1,6 +1,6 @@
 ;;; org-feed.el --- Add RSS feed items to Org files  -*- lexical-binding: t; 
-*-
 ;;
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
diff --git a/lisp/org/org-footnote.el b/lisp/org/org-footnote.el
index 5d472bd..f896318 100644
--- a/lisp/org/org-footnote.el
+++ b/lisp/org/org-footnote.el
@@ -1,6 +1,6 @@
 ;;; org-footnote.el --- Footnote support in Org      -*- lexical-binding: t; 
-*-
 ;;
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
diff --git a/lisp/org/org-gnus.el b/lisp/org/org-gnus.el
index a53b343..2cb2766 100644
--- a/lisp/org/org-gnus.el
+++ b/lisp/org/org-gnus.el
@@ -1,6 +1,6 @@
 ;;; org-gnus.el --- Support for Links to Gnus Groups and Messages -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;;         Tassilo Horn <tassilo at member dot fsf dot org>
diff --git a/lisp/org/org-habit.el b/lisp/org/org-habit.el
index 375714e..6234d02 100644
--- a/lisp/org/org-habit.el
+++ b/lisp/org/org-habit.el
@@ -1,6 +1,6 @@
 ;;; org-habit.el --- The habit tracking code for Org -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw at gnu dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -288,7 +288,7 @@ Habits are assigned colors on the following basis:
         (deadline (if scheduled-days
                       (+ scheduled-days (- d-repeat s-repeat))
                     (org-habit-deadline habit)))
-        (m-days (or now-days (time-to-days (current-time)))))
+        (m-days (or now-days (time-to-days nil))))
     (cond
      ((< m-days scheduled)
       '(org-habit-clear-face . org-habit-clear-future-face))
@@ -406,8 +406,7 @@ current time."
   "Insert consistency graph for any habitual tasks."
   (let ((inhibit-read-only t)
        (buffer-invisibility-spec '(org-link))
-       (moment (time-subtract (current-time)
-                              (list 0 (* 3600 org-extend-today-until) 0))))
+       (moment (time-since (* 3600 org-extend-today-until))))
     (save-excursion
       (goto-char (if line (point-at-bol) (point-min)))
       (while (not (eobp))
diff --git a/lisp/org/org-id.el b/lisp/org/org-id.el
index ad9b7d1..6a9d729 100644
--- a/lisp/org/org-id.el
+++ b/lisp/org/org-id.el
@@ -1,6 +1,6 @@
 ;;; org-id.el --- Global identifiers for Org entries -*- lexical-binding: t; 
-*-
 ;;
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -160,9 +160,9 @@ to have no space characters in them."
 (defcustom org-id-include-domain nil
   "Non-nil means add the domain name to new IDs.
 This ensures global uniqueness of IDs, and is also suggested by
-RFC 2445 in combination with RFC 822.  This is only relevant if
-`org-id-method' is `org'.  When uuidgen is used, the domain will never
-be added.
+the relevant RFCs.  This is relevant only if `org-id-method' is
+`org'.  When uuidgen is used, the domain will never be added.
+
 The default is to not use this because we have no really good way to get
 the true domain, and Org entries will normally not be shared with enough
 people to make this necessary."
diff --git a/lisp/org/org-indent.el b/lisp/org/org-indent.el
index bf4e998..97cf878 100644
--- a/lisp/org/org-indent.el
+++ b/lisp/org/org-indent.el
@@ -1,6 +1,6 @@
 ;;; org-indent.el --- Dynamic indentation for Org    -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -332,7 +332,7 @@ stopped."
      (let* ((case-fold-search t)
            (limited-re (org-get-limited-outline-regexp))
            (level (or (org-current-level) 0))
-           (time-limit (and delay (time-add (current-time) delay))))
+           (time-limit (and delay (time-add nil delay))))
        ;; For each line, set `line-prefix' and `wrap-prefix'
        ;; properties depending on the type of line (headline, inline
        ;; task, item or other).
@@ -345,7 +345,7 @@ stopped."
           ;; In asynchronous mode, take a break of
           ;; `org-indent-agent-resume-delay' every DELAY to avoid
           ;; blocking any other idle timer or process output.
-          ((and delay (time-less-p time-limit (current-time)))
+          ((and delay (time-less-p time-limit nil))
            (setq org-indent-agent-resume-timer
                  (run-with-idle-timer
                   (time-add (current-idle-time) org-indent-agent-resume-delay)
diff --git a/lisp/org/org-info.el b/lisp/org/org-info.el
index 6dde36c..bfbe42c 100644
--- a/lisp/org/org-info.el
+++ b/lisp/org/org-info.el
@@ -1,6 +1,6 @@
 ;;; org-info.el --- Support for Links to Info Nodes -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
diff --git a/lisp/org/org-inlinetask.el b/lisp/org/org-inlinetask.el
index 08fc268..82372e5 100644
--- a/lisp/org/org-inlinetask.el
+++ b/lisp/org/org-inlinetask.el
@@ -1,6 +1,6 @@
 ;;; org-inlinetask.el --- Tasks Independent of Outline Hierarchy -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
diff --git a/lisp/org/org-irc.el b/lisp/org/org-irc.el
index 8901956..97f093e 100644
--- a/lisp/org/org-irc.el
+++ b/lisp/org/org-irc.el
@@ -1,6 +1,6 @@
 ;;; org-irc.el --- Store Links to IRC Sessions -*- lexical-binding: t; -*-
 ;;
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Philip Jackson <address@hidden>
 ;; Keywords: erc, irc, link, org
diff --git a/lisp/org/org-lint.el b/lisp/org/org-lint.el
index 9fcb17a..f915335 100644
--- a/lisp/org/org-lint.el
+++ b/lisp/org/org-lint.el
@@ -1,6 +1,6 @@
 ;;; org-lint.el --- Linting for Org documents        -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Nicolas Goaziou <address@hidden>
 ;; Keywords: outlines, hypermedia, calendar, wp
diff --git a/lisp/org/org-list.el b/lisp/org/org-list.el
index 1f51809..22692d2 100644
--- a/lisp/org/org-list.el
+++ b/lisp/org/org-list.el
@@ -1,6 +1,6 @@
 ;;; org-list.el --- Plain lists for Org              -*- lexical-binding: t; 
-*-
 ;;
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;;        Bastien Guerry <address@hidden>
@@ -236,7 +236,7 @@ into
 
 (defcustom org-plain-list-ordered-item-terminator t
   "The character that makes a line with leading number an ordered list item.
-Valid values are ?. and ?\).  To get both terminators, use t.
+Valid values are ?. and ?\\).  To get both terminators, use t.
 
 This variable needs to be set before org.el is loaded.  If you
 need to make a change while Emacs is running, use the customize
@@ -2678,7 +2678,7 @@ Return t if successful."
                (error "Cannot outdent beyond margin")
              ;; Change bullet if necessary.
              (when (and (= (+ top-ind offset) 0)
-                        (string-match "*"
+                        (string-match "\\*"
                                       (org-list-get-bullet beg struct)))
                (org-list-set-bullet beg struct
                                     (org-list-bullet-string "-")))
diff --git a/lisp/org/org-macro.el b/lisp/org/org-macro.el
index e50b2f9..a151e1e 100644
--- a/lisp/org/org-macro.el
+++ b/lisp/org/org-macro.el
@@ -1,6 +1,6 @@
 ;;; org-macro.el --- Macro Replacement Code for Org  -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Nicolas Goaziou <address@hidden>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -313,7 +313,7 @@ Return a list of arguments, as strings.  This is the 
opposite of
                                  (buffer-substring
                                   (point) (line-end-position)))))
                       (when (cl-some #'identity time)
-                        (setq date (apply #'encode-time time))))))))
+                        (setq date (encode-time time))))))))
              (let ((proc (get-buffer-process buf)))
                (while (and proc (accept-process-output proc .5 nil t)))))
          (kill-buffer buf))
diff --git a/lisp/org/org-macs.el b/lisp/org/org-macs.el
index 5836336..3c76824 100644
--- a/lisp/org/org-macs.el
+++ b/lisp/org/org-macs.el
@@ -1,6 +1,6 @@
 ;;; org-macs.el --- Top-level Definitions for Org -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
diff --git a/lisp/org/org-mhe.el b/lisp/org/org-mhe.el
index e74a9ee..a37c41a 100644
--- a/lisp/org/org-mhe.el
+++ b/lisp/org/org-mhe.el
@@ -1,6 +1,6 @@
 ;;; org-mhe.el --- Support for Links to MH-E Messages -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Thomas Baumann <thomas dot baumann at ch dot tum dot de>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -142,7 +142,7 @@ So if you use sequences, it will now work."
   "Return the name of the message folder in an index folder buffer."
   (save-excursion
     (mh-index-previous-folder)
-    (if (re-search-forward "^\\(+.*\\)$" nil t)
+    (if (re-search-forward "^\\(\\+.*\\)$" nil t)
        (message "%s" (match-string 1)))))
 
 (defun org-mhe-get-message-folder ()
diff --git a/lisp/org/org-mobile.el b/lisp/org/org-mobile.el
index cbf169f..8b4e895 100644
--- a/lisp/org/org-mobile.el
+++ b/lisp/org/org-mobile.el
@@ -1,5 +1,5 @@
 ;;; org-mobile.el --- Code for Asymmetric Sync With a Mobile Device -*- 
lexical-binding: t; -*-
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -845,11 +845,11 @@ If BEG and END are given, only do this in that region."
            (cl-incf cnt-error)
            (throw 'next t))
          (move-marker bos-marker (point))
-         (if (re-search-forward "^** Old value[ \t]*$" eos t)
+         (if (re-search-forward "^\\** Old value[ \t]*$" eos t)
              (setq old (buffer-substring
                         (1+ (match-end 0))
                         (progn (outline-next-heading) (point)))))
-         (if (re-search-forward "^** New value[ \t]*$" eos t)
+         (if (re-search-forward "^\\** New value[ \t]*$" eos t)
              (setq new (buffer-substring
                         (1+ (match-end 0))
                         (progn (outline-next-heading)
diff --git a/lisp/org/org-mouse.el b/lisp/org/org-mouse.el
index 5a10b59..a3dcb77 100644
--- a/lisp/org/org-mouse.el
+++ b/lisp/org/org-mouse.el
@@ -1,6 +1,6 @@
 ;;; org-mouse.el --- Better mouse support for Org -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Piotr Zielinski <piotr dot zielinski at gmail dot com>
 ;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
@@ -643,7 +643,7 @@ This means, between the beginning of line and the point."
         ,@(org-mouse-list-options-menu (mapcar 'car org-startup-options)
                                        'org-mode-restart))))
      ((or (eolp)
-         (and (looking-at "\\(  \\|\t\\)\\(+:[0-9a-zA-Z_:]+\\)?\\(  
\\|\t\\)+$")
+         (and (looking-at "\\(  \\|\t\\)\\(\\+:[0-9a-zA-Z_:]+\\)?\\(  
\\|\t\\)+$")
               (looking-back "  \\|\t" (- (point) 2)
                             (line-beginning-position))))
       (org-mouse-popup-global-menu))
diff --git a/lisp/org/org-pcomplete.el b/lisp/org/org-pcomplete.el
index a9b909d..cf272de 100644
--- a/lisp/org/org-pcomplete.el
+++ b/lisp/org/org-pcomplete.el
@@ -1,6 +1,6 @@
 ;;; org-pcomplete.el --- In-buffer Completion Code -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;;         John Wiegley <johnw at gnu dot org>
@@ -49,10 +49,10 @@
   "Examine the thing at point and let the caller know what it is.
 The return value is a string naming the thing at point."
   (let ((beg1 (save-excursion
-               (skip-chars-backward "[:alnum:]-_@")
+               (skip-chars-backward "-[:alnum:]_@")
                (point)))
        (beg (save-excursion
-              (skip-chars-backward "a-zA-Z0-9-_:$")
+              (skip-chars-backward "-a-zA-Z0-9_:$")
               (point)))
        (line-to-here (buffer-substring (point-at-bol) (point))))
     (cond
@@ -82,7 +82,7 @@ The return value is a string naming the thing at point."
           (not (equal (char-after (point-at-bol)) ?*))
           (save-excursion
             (move-beginning-of-line 1)
-            (skip-chars-backward "[ \t\n]")
+            (skip-chars-backward " \t\n")
             ;; org-drawer-regexp matches a whole line but while
             ;; looking-back, we just ignore trailing whitespaces
             (or (looking-back (substring org-drawer-regexp 0 -1)
diff --git a/lisp/org/org-plot.el b/lisp/org/org-plot.el
index ebd7af4..a5635e3 100644
--- a/lisp/org/org-plot.el
+++ b/lisp/org/org-plot.el
@@ -1,6 +1,6 @@
 ;;; org-plot.el --- Support for Plotting from Org -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Eric Schulte <schulte dot eric at gmail dot com>
 ;; Keywords: tables, plotting
@@ -336,7 +336,7 @@ line directly before or after the table."
                    (insert "\n")
                    (insert-file-contents (plist-get params :script))
                    (goto-char (point-min))
-                   (while (re-search-forward "$datafile" nil t)
+                   (while (re-search-forward "\\$datafile" nil t)
                      (replace-match data-file nil nil)))
          (insert (org-plot/gnuplot-script data-file num-cols params)))
        ;; Graph table.
diff --git a/lisp/org/org-protocol.el b/lisp/org/org-protocol.el
index 33957ee..016105e 100644
--- a/lisp/org/org-protocol.el
+++ b/lisp/org/org-protocol.el
@@ -1,6 +1,6 @@
 ;;; org-protocol.el --- Intercept Calls from Emacsclient to Trigger Custom 
Actions -*- lexical-binding: t; -*-
 ;;
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 ;;
 ;; Authors: Bastien Guerry <address@hidden>
 ;;       Daniel M German <dmg AT uvic DOT org>
@@ -331,7 +331,7 @@ returned list."
         (len 0)
         dir
         ret)
-    (when (string-match 
"^\\(.*\\)\\(org-protocol:/+[a-zA-z0-9][-_a-zA-z0-9]*:/+\\)\\(.*\\)" trigger)
+    (when (string-match 
"^\\(.*\\)\\(org-protocol:/+[a-zA-Z0-9][-_a-zA-Z0-9]*:/+\\)\\(.*\\)" trigger)
       (setq dir (match-string 1 trigger))
       (setq len (length dir))
       (setcar l (concat dir (match-string 3 trigger))))
@@ -349,17 +349,20 @@ returned list."
          ret)
       l)))
 
-(defun org-protocol-flatten (list)
-  "Transform LIST into a flat list.
+(defalias 'org-protocol-flatten
+  (if (fboundp 'flatten-tree) 'flatten-tree
+    (lambda (list)
+      "Transform LIST into a flat list.
 
 Greedy handlers might receive a list like this from emacsclient:
 \((\"/dir/org-protocol:/greedy:/~/path1\" (23 . 12)) (\"/dir/param\"))
 where \"/dir/\" is the absolute path to emacsclients working directory.
 This function transforms it into a flat list."
-  (if (null list) ()
-    (if (listp list)
-       (append (org-protocol-flatten (car list)) (org-protocol-flatten (cdr 
list)))
-      (list list))))
+      (if list
+         (if (consp list)
+             (append (org-protocol-flatten (car list))
+                     (org-protocol-flatten (cdr list)))
+           (list list))))))
 
 (defun org-protocol-parse-parameters (info &optional new-style default-order)
   "Return a property list of parameters from INFO.
diff --git a/lisp/org/org-rmail.el b/lisp/org/org-rmail.el
index d50fd64..c3d941e 100644
--- a/lisp/org/org-rmail.el
+++ b/lisp/org/org-rmail.el
@@ -1,6 +1,6 @@
 ;;; org-rmail.el --- Support for Links to Rmail Messages -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
diff --git a/lisp/org/org-src.el b/lisp/org/org-src.el
index 829354c..d8f2cef 100644
--- a/lisp/org/org-src.el
+++ b/lisp/org/org-src.el
@@ -1,6 +1,6 @@
 ;;; org-src.el --- Source code examples in Org       -*- lexical-binding: t; 
-*-
 ;;
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;;        Bastien Guerry <address@hidden>
diff --git a/lisp/org/org-table.el b/lisp/org/org-table.el
index dcf7430..147527d 100644
--- a/lisp/org/org-table.el
+++ b/lisp/org/org-table.el
@@ -1,6 +1,6 @@
 ;;; org-table.el --- The Table Editor for Org        -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -484,8 +484,8 @@ Line numbers are counted from the beginning of the table.  
This
 variable is initialized with `org-table-analyze'.")
 
 (defconst org-table-range-regexp
-  
"@\\([-+]?I*[-+]?[0-9]*\\)?\\(\\$[-+]?[0-9]+\\)?\\(address@hidden([-+]?I*[-+]?[0-9]*\\)?\\(\\$[-+]?[0-9]+\\)?\\)?"
-  ;;   1                        2                    3          4              
          5
+  
"@\\([-+]?I*[-+]?[0-9]*\\)\\(\\$[-+]?[0-9]+\\)?\\(address@hidden([-+]?I*[-+]?[0-9]*\\)\\(\\$[-+]?[0-9]+\\)?\\)?"
+  ;;   1                       2                    3          4               
        5
   "Regular expression for matching ranges in formulas.")
 
 (defconst org-table-range-regexp2
@@ -1182,7 +1182,7 @@ to a number.  In the case of a timestamp, increment by 
days."
                              (- (org-time-string-to-absolute txt)
                                 (org-time-string-to-absolute txt-up)))
                             ((string-match org-ts-regexp3 txt) 1)
-                            ((string-match 
"\\([-+]\\)?\\(?:[0-9]+\\)?\\(?:\.[0-9]+\\)?" txt-up)
+                            ((string-match 
"\\([-+]\\)?[0-9]*\\(?:\\.[0-9]+\\)?" txt-up)
                              (- (string-to-number txt)
                                 (string-to-number (match-string 0 txt-up))))
                             (t 1)))
@@ -2175,8 +2175,8 @@ If NLAST is a number, only the NLAST fields will actually 
be summed."
             (sres (if (= org-timecnt 0)
                       (number-to-string res)
                     (setq diff (* 3600 res)
-                          h (floor (/ diff 3600)) diff (mod diff 3600)
-                          m (floor (/ diff 60)) diff (mod diff 60)
+                          h (floor diff 3600) diff (mod diff 3600)
+                          m (floor diff 60) diff (mod diff 60)
                           s diff)
                     (format "%.0f:%02.0f:%02.0f" h m s))))
        (kill-new sres)
@@ -2307,7 +2307,7 @@ LOCATION instead."
              "\n"))))
 
 (defsubst org-table-formula-make-cmp-string (a)
-  (when (string-match "\\`$[<>]" a)
+  (when (string-match "\\`\\$[<>]" a)
     (let ((arrow (string-to-char (substring a 1))))
       ;; Fake a high number to make sure this is sorted at the end.
       (setq a (org-table-formula-handle-first/last-rc a))
@@ -2355,7 +2355,7 @@ LOCATION is a buffer position, consider the formulas 
there."
                       (cond
                        ((not (match-end 2)) m)
                        ;; Is it a column reference?
-                       ((string-match-p "\\`$\\([0-9]+\\|[<>]+\\)\\'" m) m)
+                       ((string-match-p "\\`\\$\\([0-9]+\\|[<>]+\\)\\'" m) m)
                        ;; Since named columns are not possible in
                        ;; LHS, assume this is a named field.
                        (t (match-string 2 string)))))
@@ -2909,8 +2909,8 @@ location of point."
                     (format-time-string
                      (org-time-stamp-format
                       (string-match-p "[0-9]\\{1,2\\}:[0-9]\\{2\\}" ts))
-                     (apply #'encode-time
-                            (save-match-data (org-parse-time-string ts))))))
+                     (encode-time
+                      (save-match-data (org-parse-time-string ts))))))
                 form t t))
 
          (setq ev (if (and duration (string-match 
"^[0-9]+:[0-9]+\\(?::[0-9]+\\)?$" form))
@@ -3216,7 +3216,7 @@ known that the table will be realigned a little later 
anyway."
                    (cond
                     ((string-match "address@hidden" old-lhs)
                      (user-error "Can't assign to hline relative reference"))
-                    ((string-match "\\`$[<>]" old-lhs)
+                    ((string-match "\\`\\$[<>]" old-lhs)
                      (let ((new (org-table-formula-handle-first/last-rc
                                  old-lhs)))
                        (when (assoc new eqlist)
@@ -3639,7 +3639,8 @@ Parameters get priority."
       (setq startline (org-current-line))
       (dolist (entry eql)
        (let* ((type (cond
-                     ((string-match "\\`$\\([0-9]+\\|[<>]+\\)\\'" (car entry))
+                     ((string-match "\\`\\$\\([0-9]+\\|[<>]+\\)\\'"
+                                    (car entry))
                       'column)
                      ((equal (string-to-char (car entry)) ?@) 'field)
                      (t 'named)))
diff --git a/lisp/org/org-timer.el b/lisp/org/org-timer.el
index d840944..6529a8b0 100644
--- a/lisp/org/org-timer.el
+++ b/lisp/org/org-timer.el
@@ -1,6 +1,6 @@
 ;;; org-timer.el --- Timer code for Org mode         -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -139,12 +139,7 @@ the region 0:00:00."
                   (format "Restart timer with offset [%s]: " def)))
          (unless (string-match "\\S-" s) (setq s def))
          (setq delta (org-timer-hms-to-secs (org-timer-fix-incomplete s)))))
-       (setq org-timer-start-time
-             (seconds-to-time
-              ;; Pass `current-time' result to `float-time' (instead
-              ;; of calling without arguments) so that only
-              ;; `current-time' has to be overridden in tests.
-              (- (float-time (current-time)) delta))))
+       (setq org-timer-start-time (time-since delta)))
       (setq org-timer-pause-time nil)
       (org-timer-set-mode-line 'on)
       (message "Timer start time set to %s, current value is %s"
@@ -167,14 +162,9 @@ With prefix arg STOP, stop it entirely."
            (setq org-timer-countdown-timer
                  (org-timer--run-countdown-timer
                   new-secs org-timer-countdown-timer-title))
-           (setq org-timer-start-time
-                 (time-add (current-time) (seconds-to-time new-secs))))
+           (setq org-timer-start-time (time-add nil new-secs)))
        (setq org-timer-start-time
-             ;; Pass `current-time' result to `float-time' (instead
-             ;; of calling without arguments) so that only
-             ;; `current-time' has to be overridden in tests.
-             (seconds-to-time (- (float-time (current-time))
-                                 (- pause-secs start-secs)))))
+             (time-since (- pause-secs start-secs))))
       (setq org-timer-pause-time nil)
       (org-timer-set-mode-line 'on)
       (run-hooks 'org-timer-continue-hook)
@@ -233,14 +223,9 @@ it in the buffer."
           (abs (floor (org-timer-seconds))))))
 
 (defun org-timer-seconds ()
-  ;; Pass `current-time' result to `float-time' (instead of calling
-  ;; without arguments) so that only `current-time' has to be
-  ;; overridden in tests.
-  (if org-timer-countdown-timer
-      (- (float-time org-timer-start-time)
-        (float-time (or org-timer-pause-time (current-time))))
-    (- (float-time (or org-timer-pause-time (current-time)))
-       (float-time org-timer-start-time))))
+  (let ((s (float-time (time-subtract org-timer-pause-time
+                                     org-timer-start-time))))
+    (if org-timer-countdown-timer (- s) s)))
 
 ;;;###autoload
 (defun org-timer-change-times-in-region (beg end delta)
@@ -400,7 +385,7 @@ VALUE can be `on', `off', or `paused'."
       (message "No timer set")
     (let* ((rtime (decode-time
                   (time-subtract (timer--time org-timer-countdown-timer)
-                                 (current-time))))
+                                 nil)))
           (rsecs (nth 0 rtime))
           (rmins (nth 1 rtime)))
       (message "%d minute(s) %d seconds left before next time out"
@@ -463,8 +448,7 @@ using three `C-u' prefix arguments."
                (org-timer--run-countdown-timer
                 secs org-timer-countdown-timer-title))
          (run-hooks 'org-timer-set-hook)
-         (setq org-timer-start-time
-               (time-add (current-time) (seconds-to-time secs)))
+         (setq org-timer-start-time (time-add nil secs))
          (setq org-timer-pause-time nil)
          (org-timer-set-mode-line 'on))))))
 
diff --git a/lisp/org/org-w3m.el b/lisp/org/org-w3m.el
index 9690c8e..23fd0f8 100644
--- a/lisp/org/org-w3m.el
+++ b/lisp/org/org-w3m.el
@@ -1,6 +1,6 @@
 ;;; org-w3m.el --- Support from Copy and Paste From w3m -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Andy Stewart <lazycat dot manatee at gmail dot com>
 ;; Keywords: outlines, hypermedia, calendar, wp
diff --git a/lisp/org/org.el b/lisp/org/org.el
index 873ae6b..ce6dd24 100644
--- a/lisp/org/org.el
+++ b/lisp/org/org.el
@@ -1,7 +1,7 @@
 ;;; org.el --- Outline-based notes management and organizer -*- 
lexical-binding: t; -*-
 
 ;; Carstens outline-mode for keeping track of everything.
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
@@ -229,10 +229,10 @@ file to byte-code before it is loaded."
   (interactive "fFile to load: \nP")
   (let* ((age (lambda (file)
                (float-time
-                (time-subtract (current-time)
-                               (file-attribute-modification-time
-                                (or (file-attributes (file-truename file))
-                                    (file-attributes file)))))))
+                (time-since
+                 (file-attribute-modification-time
+                  (or (file-attributes (file-truename file))
+                      (file-attributes file)))))))
         (base-name (file-name-sans-extension file))
         (exported-file (concat base-name ".el")))
     ;; tangle if the Org file is newer than the elisp file
@@ -430,7 +430,7 @@ Matched keyword is in group 1.")
 
 (defconst org-deadline-time-hour-regexp
   (concat "\\<" org-deadline-string
-         " *<\\([^>]+[0-9]\\{1,2\\}:[0-9]\\{2\\}[0-9-+:hdwmy \t.]*\\)>")
+         " *<\\([^>]+[0-9]\\{1,2\\}:[0-9]\\{2\\}[0-9+:hdwmy \t.-]*\\)>")
   "Matches the DEADLINE keyword together with a time-and-hour stamp.")
 
 (defconst org-deadline-line-regexp
@@ -446,7 +446,7 @@ Matched keyword is in group 1.")
 
 (defconst org-scheduled-time-hour-regexp
   (concat "\\<" org-scheduled-string
-         " *<\\([^>]+[0-9]\\{1,2\\}:[0-9]\\{2\\}[0-9-+:hdwmy \t.]*\\)>")
+         " *<\\([^>]+[0-9]\\{1,2\\}:[0-9]\\{2\\}[0-9+:hdwmy \t.-]*\\)>")
   "Matches the SCHEDULED keyword together with a time-and-hour stamp.")
 
 (defconst org-closed-time-regexp
@@ -5613,22 +5613,20 @@ When ROUNDING-MINUTES is not an integer, fall back on 
the car of
 the rounding returns a past time."
   (let ((r (or (and (integerp rounding-minutes) rounding-minutes)
               (car org-time-stamp-rounding-minutes)))
-       (time (decode-time)) res)
+       (now (current-time)))
     (if (< r 1)
-       (current-time)
-      (setq res
-           (apply 'encode-time
-                  (append (list 0 (* r (floor (+ .5 (/ (float (nth 1 time)) 
r)))))
-                          (nthcdr 2 time))))
-      (if (and past (< (float-time (time-subtract (current-time) res)) 0))
-         (seconds-to-time (- (float-time res) (* r 60)))
-       res))))
+       now
+      (let* ((time (decode-time now))
+            (res (apply #'encode-time 0 (* r (round (nth 1 time) r))
+                        (nthcdr 2 time))))
+       (if (or (not past) (time-less-p res now))
+           res
+         (time-subtract res (* r 60)))))))
 
 (defun org-today ()
   "Return today date, considering `org-extend-today-until'."
   (time-to-days
-   (time-subtract (current-time)
-                 (list 0 (* 3600 org-extend-today-until) 0))))
+   (time-since (* 3600 org-extend-today-until))))
 
 ;;;; Font-Lock stuff, including the activators
 
@@ -9743,9 +9741,7 @@ active region."
          (setq link
                (format-time-string
                 (car org-time-stamp-formats)
-                (apply 'encode-time
-                       (list 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd)
-                             nil nil nil))))
+                (encode-time 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd))))
          (org-store-link-props :type "calendar" :date cd)))
 
        ((eq major-mode 'help-mode)
@@ -10471,7 +10467,7 @@ This is still an experimental function, your mileage 
may vary."
    ((and (equal type "lisp") (string-match "^/" path))
     ;; Planner has a slash, we do not.
     (setq type "elisp" path (substring path 1)))
-   ((string-match "^//\\(.?*\\)/\\(<.*>\\)$" path)
+   ((string-match "^//\\(.*\\)/\\(<.*>\\)$" path)
     ;; A typical message link.  Planner has the id after the final slash,
     ;; we separate it with a hash mark
     (setq path (concat (match-string 1 path) "#"
@@ -11882,7 +11878,8 @@ prefix argument (`C-u C-u C-u C-c C-w')."
            (when (featurep 'org-inlinetask)
              (org-inlinetask-remove-END-maybe))
            (setq org-markers-to-move nil)
-           (message (concat actionmsg " to \"%s\" in file %s: done") (car it) 
file)))))))
+           (message "%s to \"%s\" in file %s: done" actionmsg
+                    (car it) file)))))))
 
 (defun org-refile-goto-last-stored ()
   "Go to the location where the last refile was stored."
@@ -13113,8 +13110,7 @@ This function is run automatically after each state 
change to a DONE state."
                        (while (re-search-forward org-clock-line-re end t)
                          (when (org-at-clock-log-p) (throw :clock t))))))
            (org-entry-put nil "LAST_REPEAT" (format-time-string
-                                             (org-time-stamp-format t t)
-                                             (current-time))))
+                                             (org-time-stamp-format t t))))
          (when org-log-repeat
            (if (or (memq 'org-add-log-note (default-value 'post-command-hook))
                    (memq 'org-add-log-note post-command-hook))
@@ -13173,7 +13169,7 @@ has been set"
                          (let ((nshiftmax 10)
                                (nshift 0))
                            (while (or (= nshift 0)
-                                      (not (time-less-p (current-time) time)))
+                                      (not (time-less-p nil time)))
                              (when (= (cl-incf nshift) nshiftmax)
                                (or (y-or-n-p
                                     (format "%d repeater intervals were not \
@@ -13344,7 +13340,7 @@ for calling org-schedule with, or if there is no 
scheduling,
 returns nil."
   (let ((time (org-entry-get pom "SCHEDULED" inherit)))
     (when time
-      (apply 'encode-time (org-parse-time-string time)))))
+      (org-time-string-to-time time))))
 
 (defun org-get-deadline-time (pom &optional inherit)
   "Get the deadline as a time tuple, of a format suitable for
@@ -13352,7 +13348,7 @@ calling org-deadline with, or if there is no 
scheduling, returns
 nil."
   (let ((time (org-entry-get pom "DEADLINE" inherit)))
     (when time
-      (apply 'encode-time (org-parse-time-string time)))))
+      (org-time-string-to-time time))))
 
 (defun org-remove-timestamp-with-keyword (keyword)
   "Remove all time stamps with KEYWORD in the current entry."
@@ -13411,7 +13407,7 @@ WHAT entry will also be removed."
                                       org-deadline-time-regexp)
                                     end t)
              (setq ts (match-string 1)
-                   default-time (apply 'encode-time (org-parse-time-string ts))
+                   default-time (org-time-string-to-time ts)
                    default-input (and ts (org-get-compact-tod ts)))))))
       (when what
        (setq time
@@ -14668,16 +14664,15 @@ it as a time string and apply `float-time' to it.  If 
S is nil, just return 0."
    ((numberp s) s)
    ((stringp s)
     (condition-case nil
-       (float-time (apply #'encode-time (org-parse-time-string s)))
-      (error 0.)))
-   (t 0.)))
+       (float-time (org-time-string-to-time s))
+      (error 0)))
+   (t 0)))
 
 (defun org-time-today ()
   "Time in seconds today at 0:00.
 Returns the float number of seconds since the beginning of the
 epoch to the beginning of today (00:00)."
-  (float-time (apply 'encode-time
-                    (append '(0 0 0) (nthcdr 3 (decode-time))))))
+  (float-time (apply #'encode-time 0 0 0 (nthcdr 3 (decode-time)))))
 
 (defun org-matcher-time (s)
   "Interpret a time comparison value."
@@ -14958,7 +14953,7 @@ When JUST-ALIGN is non-nil, only align tags."
          (unless (equal tags "")
            (let* ((level (save-excursion
                            (beginning-of-line)
-                           (skip-chars-forward "\\*")))
+                           (skip-chars-forward "*")))
                   (offset (if (bound-and-true-p org-indent-mode)
                               (* (1- org-indent-indentation-per-level)
                                  (1- level))
@@ -16572,22 +16567,20 @@ non-nil."
              ((org-at-timestamp-p 'lax) (match-string 0))))
         ;; Default time is either the timestamp at point or today.
         ;; When entering a range, only the range start is considered.
-         (default-time (if (not ts) (current-time)
-                        (apply #'encode-time (org-parse-time-string ts))))
+        (default-time (and ts (org-time-string-to-time ts)))
          (default-input (and ts (org-get-compact-tod ts)))
          (repeater (and ts
                        (string-match "\\([.+-]+[0-9]+[hdwmy] ?\\)+" ts)
                        (match-string 0 ts)))
         org-time-was-given
         org-end-time-was-given
-        (time
-         (and (if (equal arg '(16)) (current-time)
+        (time (if (equal arg '(16)) (current-time)
                 ;; Preserve `this-command' and `last-command'.
                 (let ((this-command this-command)
                       (last-command last-command))
                   (org-read-date
                    arg 'totime nil nil default-time default-input
-                   inactive))))))
+                   inactive)))))
     (cond
      ((and ts
            (memq last-command '(org-time-stamp org-time-stamp-inactive))
@@ -16820,7 +16813,7 @@ user."
     (when (< (nth 2 org-defdecode) org-extend-today-until)
       (setf (nth 2 org-defdecode) -1)
       (setf (nth 1 org-defdecode) 59)
-      (setq org-def (apply #'encode-time org-defdecode))
+      (setq org-def (encode-time org-defdecode))
       (setq org-defdecode (decode-time org-def)))
     (let* ((timestr (format-time-string
                     (if org-with-time "%Y-%m-%d %H:%M" "%Y-%m-%d")
@@ -16893,13 +16886,14 @@ user."
                 "range representable on this machine"))
       (ding))
 
-    ;; One round trip to get rid of 34th of August and stuff like that....
-    (setq final (decode-time (apply 'encode-time final)))
+    (setq final (apply #'encode-time final))
 
     (setq org-read-date-final-answer ans)
 
     (if to-time
-       (apply 'encode-time final)
+       final
+      ;; This round-trip gets rid of 34th of August and stuff like that....
+      (setq final (decode-time final))
       (if (and (boundp 'org-time-was-given) org-time-was-given)
          (format "%04d-%02d-%02d %02d:%02d"
                  (nth 5 final) (nth 4 final) (nth 3 final)
@@ -16929,7 +16923,7 @@ user."
                          (and (boundp 'org-time-was-given) org-time-was-given))
                      (cdr fmts)
                    (car fmts)))
-            (txt (format-time-string fmt (apply 'encode-time f)))
+            (txt (format-time-string fmt (apply #'encode-time f)))
             (txt (if org-read-date-inactive (concat "[" (substring txt 1 -1) 
"]") txt))
             (txt (concat "=> " txt)))
        (when (and org-end-time-was-given
@@ -16960,7 +16954,7 @@ user."
     (when (string-match "\\`[ \t]*\\.[ \t]*\\'" ans)
       (setq ans "+0"))
 
-    (when (setq delta (org-read-date-get-relative ans (current-time) org-def))
+    (when (setq delta (org-read-date-get-relative ans nil org-def))
       (setq ans (replace-match "" t t ans)
            deltan (car delta)
            deltaw (nth 1 delta)
@@ -17117,7 +17111,7 @@ user."
                                        ;      (when (and 
org-read-date-prefer-future
                                        ;                (not iso-year)
                                        ;                (< 
(calendar-absolute-from-gregorian iso-date)
-                                       ;                   (time-to-days 
(current-time))))
+                                       ;                   (time-to-days nil)))
                                        ;       (setq year (1+ year)
                                        ;             iso-date 
(calendar-gregorian-from-absolute
                                        ;                       
(calendar-iso-to-absolute
@@ -17296,7 +17290,7 @@ The command returns the inserted time stamp."
          time (org-fix-decoded-time t1)
          str (org-add-props
                  (format-time-string
-                  (substring tf 1 -1) (apply 'encode-time time))
+                  (substring tf 1 -1) (encode-time time))
                  nil 'mouse-face 'highlight))
     (put-text-property beg end 'display str)))
 
@@ -17311,7 +17305,7 @@ Don't touch the rest."
 If SECONDS is non-nil, return the difference in seconds."
   (let ((fdiff (if seconds #'float-time #'time-to-days)))
     (- (funcall fdiff (org-time-string-to-time timestamp-string))
-       (funcall fdiff (current-time)))))
+       (funcall fdiff nil))))
 
 (defun org-deadline-close-p (timestamp-string &optional ndays)
   "Is the time in TIMESTAMP-STRING close to the current date?"
@@ -17493,10 +17487,8 @@ days in order to avoid rounding problems."
          (match-end (match-end 0))
          (time1 (org-time-string-to-time ts1))
          (time2 (org-time-string-to-time ts2))
-         (t1 (float-time time1))
-         (t2 (float-time time2))
-         (diff (abs (- t2 t1)))
-         (negative (< (- t2 t1) 0))
+         (diff (abs (float-time (time-subtract time2 time1))))
+         (negative (time-less-p time2 time1))
          ;; (ys (floor (* 365 24 60 60)))
          (ds (* 24 60 60))
          (hs (* 60 60))
@@ -17507,14 +17499,14 @@ days in order to avoid rounding problems."
          (fh "%02d:%02d")
          y d h m align)
      (if havetime
-        (setq ; y (floor (/ diff ys))  diff (mod diff ys)
+        (setq ; y (floor diff ys)  diff (mod diff ys)
          y 0
-         d (floor (/ diff ds))  diff (mod diff ds)
-         h (floor (/ diff hs))  diff (mod diff hs)
-         m (floor (/ diff 60)))
-       (setq ; y (floor (/ diff ys))  diff (mod diff ys)
+         d (floor diff ds)  diff (mod diff ds)
+         h (floor diff hs)  diff (mod diff hs)
+         m (floor diff 60))
+       (setq ; y (floor diff ys)  diff (mod diff ys)
        y 0
-       d (floor (+ (/ diff ds) 0.5))
+       d (round diff ds)
        h 0 m 0))
      (if (not to-buffer)
         (message "%s" (org-make-tdiff-string y d h m))
@@ -17553,7 +17545,7 @@ days in order to avoid rounding problems."
 
 (defun org-time-string-to-time (s)
   "Convert timestamp string S into internal time."
-  (apply #'encode-time (org-parse-time-string s)))
+  (encode-time (org-parse-time-string s)))
 
 (defun org-time-string-to-seconds (s)
   "Convert a timestamp string S into a number of seconds."
@@ -17588,7 +17580,7 @@ signaled."
    (daynr (org-closest-date s daynr prefer))
    (t (time-to-days
        (condition-case errdata
-          (apply #'encode-time (org-parse-time-string s))
+          (org-time-string-to-time s)
         (error (error "Bad timestamp `%s'%s\nError was: %s"
                       s
                       (if (not (and buffer pos)) ""
@@ -17605,7 +17597,7 @@ signaled."
 YEAR is expanded into one of the 30 next years, if possible, or
 into a past one.  Any year larger than 99 is returned unchanged."
   (if (>= year 100) year
-    (let* ((current (string-to-number (format-time-string "%Y" 
(current-time))))
+    (let* ((current (string-to-number (format-time-string "%Y")))
           (century (/ current 100))
           (offset (- year (% current 100))))
       (cond ((> offset 30) (+ (* (1- century) 100) year))
@@ -17686,12 +17678,12 @@ stamp stay unchanged.  In any case, return value is 
an absolute
 day number."
   (if (not (string-match "\\+\\([0-9]+\\)\\([hdwmy]\\)" start))
       ;; No repeater.  Do not shift time stamp.
-      (time-to-days (apply #'encode-time (org-parse-time-string start)))
+      (time-to-days (org-time-string-to-time start))
     (let ((value (string-to-number (match-string 1 start)))
          (type (match-string 2 start)))
       (if (= 0 value)
          ;; Repeater with a 0-value is considered as void.
-         (time-to-days (apply #'encode-time (org-parse-time-string start)))
+         (time-to-days (org-time-string-to-time start))
        (let* ((base (org-date-to-gregorian start))
               (target (org-date-to-gregorian current))
               (sday (calendar-absolute-from-gregorian base))
@@ -17796,7 +17788,7 @@ NODEFAULT, hour and minute fields will be nil if not 
given."
         ;; second argument.  However, this requires at least Emacs
         ;; 25.1.  We can do it when we switch to this version as our
         ;; minimal requirement.
-        (decode-time (seconds-to-time (org-matcher-time s))))
+        (decode-time (encode-time (org-matcher-time s))))
        (t (error "Not a standard Org time string: %s" s))))
 
 (defun org-timestamp-up (&optional arg)
@@ -18000,7 +17992,7 @@ When SUPPRESS-TMP-DELAY is non-nil, suppress delays 
like \"--2d\"."
          (setcar time0 (or (car time0) 0))
          (setcar (nthcdr 1 time0) (or (nth 1 time0) 0))
          (setcar (nthcdr 2 time0) (or (nth 2 time0) 0))
-         (setq time (apply 'encode-time time0))))
+         (setq time (encode-time time0))))
       ;; Insert the new time-stamp, and ensure point stays in the same
       ;; category as before (i.e. not after the last position in that
       ;; category).
@@ -18125,7 +18117,7 @@ A prefix ARG can be used to force the current date."
        diff)
     (when (or (org-at-timestamp-p 'lax)
              (org-match-line (concat ".*" org-ts-regexp)))
-      (let ((d1 (time-to-days (current-time)))
+      (let ((d1 (time-to-days nil))
            (d2 (time-to-days (org-time-string-to-time (match-string 1)))))
        (setq diff (- d2 d1))))
     (calendar)
@@ -20623,7 +20615,7 @@ this numeric value."
     (unless inc (setq inc 1))
     (let ((pos (point))
          (beg (skip-chars-backward "-+^/*0-9eE."))
-         (end (skip-chars-forward "-+^/*0-9eE^.")) nap)
+         (end (skip-chars-forward "-+^/*0-9eE.")) nap)
       (setq nap (buffer-substring-no-properties
                 (+ pos beg) (+ pos beg end)))
       (delete-region (+ pos beg) (+ pos beg end))
@@ -22845,9 +22837,9 @@ assumed to be significant there."
 (defun org-fill-line-break-nobreak-p ()
   "Non-nil when a new line at point would create an Org line break."
   (save-excursion
-    (skip-chars-backward "[ \t]")
+    (skip-chars-backward " \t")
     (skip-chars-backward "\\\\")
-    (looking-at "\\\\\\\\\\($\\|[^\\\\]\\)")))
+    (looking-at "\\\\\\\\\\($\\|[^\\]\\)")))
 
 (defun org-fill-paragraph-with-timestamp-nobreak-p ()
   "Non-nil when a new line at point would split a timestamp."
@@ -23389,13 +23381,12 @@ strictly within a source block, use appropriate 
comment syntax."
 (defun org-timestamp--to-internal-time (timestamp &optional end)
   "Encode TIMESTAMP object into Emacs internal time.
 Use end of date range or time range when END is non-nil."
-  (apply #'encode-time
-        (cons 0
-              (mapcar
-               (lambda (prop) (or (org-element-property prop timestamp) 0))
-               (if end '(:minute-end :hour-end :day-end :month-end :year-end)
-                 '(:minute-start :hour-start :day-start :month-start
-                                 :year-start))))))
+  (apply #'encode-time 0
+        (mapcar
+         (lambda (prop) (or (org-element-property prop timestamp) 0))
+         (if end '(:minute-end :hour-end :day-end :month-end :year-end)
+           '(:minute-start :hour-start :day-start :month-start
+                           :year-start)))))
 
 (defun org-timestamp-has-time-p (timestamp)
   "Non-nil when TIMESTAMP has a time specified."
diff --git a/lisp/org/ox-ascii.el b/lisp/org/ox-ascii.el
index c3ccb59..7c9920f 100644
--- a/lisp/org/ox-ascii.el
+++ b/lisp/org/ox-ascii.el
@@ -1,6 +1,6 @@
 ;;; ox-ascii.el --- ASCII Back-End for Org Export Engine -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -1474,8 +1474,8 @@ contextual information."
                   (replace-regexp-in-string
                    "-" "•"
                    (replace-regexp-in-string
-                    "+" "⁃"
-                    (replace-regexp-in-string "*" "‣" bul))))))))
+                    "\\+" "⁃"
+                    (replace-regexp-in-string "\\*" "‣" bul))))))))
         (indentation (if (eq list-type 'descriptive) org-ascii-quote-margin
                        (string-width bullet))))
     (concat
diff --git a/lisp/org/ox-beamer.el b/lisp/org/ox-beamer.el
index 15b78dc..11574a9 100644
--- a/lisp/org/ox-beamer.el
+++ b/lisp/org/ox-beamer.el
@@ -1,6 +1,6 @@
 ;;; ox-beamer.el --- Beamer Back-End for Org Export Engine -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten.dominik AT gmail DOT com>
 ;;         Nicolas Goaziou <n.goaziou AT gmail DOT com>
diff --git a/lisp/org/ox-html.el b/lisp/org/ox-html.el
index 6166a4a..1f98fcd 100644
--- a/lisp/org/ox-html.el
+++ b/lisp/org/ox-html.el
@@ -1,6 +1,6 @@
 ;;; ox-html.el --- HTML Back-End for Org Export Engine -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;;      Jambunathan K <kjambunathan at gmail dot com>
@@ -234,7 +234,7 @@ property on the headline itself.")
 @licstart  The following is the entire license notice for the
 JavaScript code in this tag.
 
-Copyright (C) 2012-2018 Free Software Foundation, Inc.
+Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 The JavaScript code in this tag is free software: you can
 redistribute it and/or modify it under the terms of the GNU
@@ -524,7 +524,7 @@ means to use the maximum value consistent with other 
options."
  * @licstart  The following is the entire license notice for the
  *  JavaScript code in %SCRIPT_PATH.
  *
- * Copyright (C) 2012-2018 Free Software Foundation, Inc.
+ * Copyright (C) 2012-2019 Free Software Foundation, Inc.
  *
  *
  * The JavaScript code in this tag is free software: you can
@@ -553,7 +553,7 @@ means to use the maximum value consistent with other 
options."
 @licstart  The following is the entire license notice for the
 JavaScript code in this tag.
 
-Copyright (C) 2012-2018 Free Software Foundation, Inc.
+Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 The JavaScript code in this tag is free software: you can
 redistribute it and/or modify it under the terms of the GNU
diff --git a/lisp/org/ox-icalendar.el b/lisp/org/ox-icalendar.el
index 7d7c850..f66e100 100644
--- a/lisp/org/ox-icalendar.el
+++ b/lisp/org/ox-icalendar.el
@@ -1,6 +1,6 @@
 ;;; ox-icalendar.el --- iCalendar Back-End for Org Export Engine -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <carsten at orgmode dot org>
 ;;      Nicolas Goaziou <n dot goaziou at gmail dot com>
diff --git a/lisp/org/ox-latex.el b/lisp/org/ox-latex.el
index 5aaaf99..d711530 100644
--- a/lisp/org/ox-latex.el
+++ b/lisp/org/ox-latex.el
@@ -1,6 +1,6 @@
 ;;; ox-latex.el --- LaTeX Back-End for Org Export Engine -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -1613,7 +1613,7 @@ INFO is a plist used as a communication channel."
 
 (defun org-latex-clean-invalid-line-breaks (data _backend _info)
   (replace-regexp-in-string
-   "\\(\\end{[A-Za-z0-9*]+}\\|^\\)[ \t]*\\\\\\\\[ \t]*$" "\\1"
+   "\\(\\\\end{[A-Za-z0-9*]+}\\|^\\)[ \t]*\\\\\\\\[ \t]*$" "\\1"
    data))
 
 
diff --git a/lisp/org/ox-man.el b/lisp/org/ox-man.el
index 2bc6392..816cc36 100644
--- a/lisp/org/ox-man.el
+++ b/lisp/org/ox-man.el
@@ -1,6 +1,6 @@
 ;; ox-man.el --- Man Back-End for Org Export Engine -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
 ;;      Luis R Anaya <papoanaya aroba hot mail punto com>
diff --git a/lisp/org/ox-md.el b/lisp/org/ox-md.el
index c4da8fc..fa663db 100644
--- a/lisp/org/ox-md.el
+++ b/lisp/org/ox-md.el
@@ -1,6 +1,6 @@
 ;;; ox-md.el --- Markdown Back-End for Org Export Engine -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Nicolas Goaziou <address@hidden>
 ;; Keywords: org, wp, markdown
diff --git a/lisp/org/ox-odt.el b/lisp/org/ox-odt.el
index b878171..8deb6bd 100644
--- a/lisp/org/ox-odt.el
+++ b/lisp/org/ox-odt.el
@@ -1,6 +1,6 @@
 ;;; ox-odt.el --- OpenDocument Text Exporter for Org Mode -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Jambunathan K <kjambunathan at gmail dot com>
 ;; Keywords: outlines, hypermedia, calendar, wp
diff --git a/lisp/org/ox-org.el b/lisp/org/ox-org.el
index 1b5a7cc..ca10287 100644
--- a/lisp/org/ox-org.el
+++ b/lisp/org/ox-org.el
@@ -1,6 +1,6 @@
 ;;; ox-org.el --- Org Back-End for Org Export Engine -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Nicolas Goaziou <address@hidden>
 ;; Keywords: org, wp
diff --git a/lisp/org/ox-publish.el b/lisp/org/ox-publish.el
index 80ef239..74312bc 100644
--- a/lisp/org/ox-publish.el
+++ b/lisp/org/ox-publish.el
@@ -1,5 +1,5 @@
 ;;; ox-publish.el --- Publish Related Org Mode Files as a Website -*- 
lexical-binding: t; -*-
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: David O'Toole <address@hidden>
 ;; Maintainer: Carsten Dominik <carsten DOT dominik AT gmail DOT com>
@@ -793,13 +793,11 @@ Default for SITEMAP-FILENAME is `sitemap.org'."
                           (not (string-lessp B A))))))
                ((or `anti-chronologically `chronologically)
                 (let* ((adate (org-publish-find-date a project))
-                       (bdate (org-publish-find-date b project))
-                       (A (+ (ash (car adate) 16) (cadr adate)))
-                       (B (+ (ash (car bdate) 16) (cadr bdate))))
+                       (bdate (org-publish-find-date b project)))
                   (setq retval
-                        (if (eq sort-files 'chronologically)
-                            (<= A B)
-                          (>= A B)))))
+                        (not (if (eq sort-files 'chronologically)
+                                 (time-less-p bdate adate)
+                               (time-less-p adate bdate))))))
                (`nil nil)
                (_ (user-error "Invalid sort value %s" sort-files)))
              ;; Directory-wise wins:
@@ -1350,7 +1348,7 @@ does not exist."
               (expand-file-name (or (file-symlink-p file) file)
                                 (file-name-directory file)))))
     (if (not attr) (error "No such file: \"%s\"" file)
-      (floor (float-time (file-attribute-modification-time attr))))))
+      (encode-time (file-attribute-modification-time attr) 'integer))))
 
 
 (provide 'ox-publish)
diff --git a/lisp/org/ox-texinfo.el b/lisp/org/ox-texinfo.el
index d877c9c..468fc58 100644
--- a/lisp/org/ox-texinfo.el
+++ b/lisp/org/ox-texinfo.el
@@ -1,6 +1,6 @@
 ;;; ox-texinfo.el --- Texinfo Back-End for Org Export Engine -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 ;; Author: Jonathan Leech-Pepin <jonathan.leechpepin at gmail dot com>
 ;; Keywords: outlines, hypermedia, calendar, wp
 
diff --git a/lisp/org/ox.el b/lisp/org/ox.el
index ea7d1dc..58bc9b0 100644
--- a/lisp/org/ox.el
+++ b/lisp/org/ox.el
@@ -1,6 +1,6 @@
 ;;; ox.el --- Export Framework for Org Mode          -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
 ;; Keywords: outlines, hypermedia, calendar, wp
@@ -3252,7 +3252,7 @@ locally for the subtree through node properties."
       (let ((val (cond ((equal (car key) "DATE")
                        (or (cdr key)
                            (with-temp-buffer
-                             (org-insert-time-stamp (current-time)))))
+                             (org-insert-time-stamp nil))))
                       ((equal (car key) "TITLE")
                        (or (let ((visited-file
                                   (buffer-file-name (buffer-base-buffer))))
@@ -3322,7 +3322,7 @@ storing and resolving footnotes.  It is created 
automatically."
                           (setq value (replace-match "" nil nil value)))))
                   (lines
                    (and (string-match
-                         ":lines +\"\\(\\(?:[0-9]+\\)?-\\(?:[0-9]+\\)?\\)\""
+                         ":lines +\"\\([0-9]*-[0-9]*\\)\""
                          value)
                         (prog1 (match-string 1 value)
                           (setq value (replace-match "" nil nil value)))))
diff --git a/lisp/outline.el b/lisp/outline.el
index 59169e4..74df77b 100644
--- a/lisp/outline.el
+++ b/lisp/outline.el
@@ -1,6 +1,6 @@
 ;;; outline.el --- outline mode commands for Emacs
 
-;; Copyright (C) 1986, 1993-1995, 1997, 2000-2018 Free Software
+;; Copyright (C) 1986, 1993-1995, 1997, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/paren.el b/lisp/paren.el
index 1cab6eb..13908d4 100644
--- a/lisp/paren.el
+++ b/lisp/paren.el
@@ -1,6 +1,6 @@
 ;;; paren.el --- highlight matching paren
 
-;; Copyright (C) 1993, 1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1996, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: address@hidden
 ;; Maintainer: address@hidden
diff --git a/lisp/password-cache.el b/lisp/password-cache.el
index f775389..b868b72 100644
--- a/lisp/password-cache.el
+++ b/lisp/password-cache.el
@@ -1,6 +1,6 @@
 ;;; password-cache.el --- Read passwords, possibly using a password cache.
 
-;; Copyright (C) 1999-2000, 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2000, 2003-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <address@hidden>
 ;; Created: 2003-12-21
diff --git a/lisp/pcmpl-cvs.el b/lisp/pcmpl-cvs.el
index dedc007..c90e00f 100644
--- a/lisp/pcmpl-cvs.el
+++ b/lisp/pcmpl-cvs.el
@@ -1,6 +1,6 @@
 ;;; pcmpl-cvs.el --- functions for dealing with cvs completions
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 ;; Package: pcomplete
diff --git a/lisp/pcmpl-gnu.el b/lisp/pcmpl-gnu.el
index c4e5a67..d9caf35 100644
--- a/lisp/pcmpl-gnu.el
+++ b/lisp/pcmpl-gnu.el
@@ -1,6 +1,6 @@
 ;;; pcmpl-gnu.el --- completions for GNU project tools -*- lexical-binding: t 
-*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Package: pcomplete
 
diff --git a/lisp/pcmpl-linux.el b/lisp/pcmpl-linux.el
index 18cc647..9121e78 100644
--- a/lisp/pcmpl-linux.el
+++ b/lisp/pcmpl-linux.el
@@ -1,6 +1,6 @@
 ;;; pcmpl-linux.el --- functions for dealing with GNU/Linux completions
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Package: pcomplete
 
diff --git a/lisp/pcmpl-rpm.el b/lisp/pcmpl-rpm.el
index 7f164c9..213eac7 100644
--- a/lisp/pcmpl-rpm.el
+++ b/lisp/pcmpl-rpm.el
@@ -1,6 +1,6 @@
 ;;; pcmpl-rpm.el --- functions for dealing with rpm completions
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Package: pcomplete
 
diff --git a/lisp/pcmpl-unix.el b/lisp/pcmpl-unix.el
index 1b11afd..fa42809 100644
--- a/lisp/pcmpl-unix.el
+++ b/lisp/pcmpl-unix.el
@@ -1,6 +1,6 @@
 ;;; pcmpl-unix.el --- standard UNIX completions
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Package: pcomplete
 
diff --git a/lisp/pcmpl-x.el b/lisp/pcmpl-x.el
index 766ac2e..96dc6b2 100644
--- a/lisp/pcmpl-x.el
+++ b/lisp/pcmpl-x.el
@@ -1,6 +1,6 @@
 ;;; pcmpl-x.el --- completion for miscellaneous tools  -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Leo Liu <address@hidden>
 ;; Keywords: processes, tools, convenience
diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el
index 6bdea68..e080074 100644
--- a/lisp/pcomplete.el
+++ b/lisp/pcomplete.el
@@ -1,6 +1,6 @@
 ;;; pcomplete.el --- programmable completion -*- lexical-binding: t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 ;; Keywords: processes abbrev
@@ -444,10 +444,28 @@ Same as `pcomplete' but using the standard completion UI."
            ;; table which expects strings using a prefix from the
            ;; buffer's text but internally uses the corresponding
            ;; prefix from pcomplete-stub.
+           ;;
+           (argbeg (pcomplete-begin))
+           ;; When completing an envvar within an argument in Eshell
+           ;; (e.g. "cd /home/$US TAB"), `pcomplete-stub' will just be
+           ;; "US" whereas `argbeg' will point to the first "/".
+           ;; We could rely on c-t-subvert to handle the difference,
+           ;; but we try here to guess the "real" beginning so as to
+           ;; rely less on c-t-subvert.
            (beg (max (- (point) (length pcomplete-stub))
-                     (pcomplete-begin)))
-           (buftext (pcomplete-unquote-argument
-                     (buffer-substring beg (point)))))
+                     argbeg))
+           buftext)
+      ;; Try and improve our guess of `beg' in case the difference
+      ;; between pcomplete-stub and the buffer's text is simply due to
+      ;; some chars removed by unquoting.  Again, this is not
+      ;; indispensable but reduces the reliance on c-t-subvert and
+      ;; improves corner case behaviors.
+      (while (progn (setq buftext (pcomplete-unquote-argument
+                                   (buffer-substring beg (point))))
+                    (and (> beg argbeg)
+                         (> (length pcomplete-stub) (length buftext))))
+        (setq beg (max argbeg (- beg (- (length pcomplete-stub)
+                                        (length buftext))))))
       (when completions
         (let ((table
                (completion-table-with-quoting
@@ -768,7 +786,7 @@ this is `comint-dynamic-complete-functions'."
        (push (point) begins)
         (while
             (progn
-              (skip-chars-forward "^ \t\n\\")
+              (skip-chars-forward "^ \t\n\\\\")
               (when (eq (char-after) ?\\)
                 (forward-char 1)
                 (unless (eolp)
diff --git a/lisp/pixel-scroll.el b/lisp/pixel-scroll.el
index 227580f..dfd9a5a 100644
--- a/lisp/pixel-scroll.el
+++ b/lisp/pixel-scroll.el
@@ -1,6 +1,6 @@
 ;;; pixel-scroll.el --- Scroll a line smoothly
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 ;; Author: Tak Kunihiro <address@hidden>
 ;; Keywords: mouse
 ;; Package: emacs
@@ -97,10 +97,11 @@ When scrolling request is delivered soon after the previous 
one,
 user is in hurry.  When the time since last scroll is larger than
 `pixel-dead-time', we are ready for another smooth scroll, and this
 function returns nil."
-  (let* ((current-time (float-time))
-         (scroll-in-rush-p (< (- current-time pixel-last-scroll-time)
-                              pixel-dead-time)))
-    (setq pixel-last-scroll-time current-time)
+  (let* ((now (current-time))
+        (scroll-in-rush-p (time-less-p
+                           (time-subtract now pixel-last-scroll-time)
+                           pixel-dead-time)))
+    (setq pixel-last-scroll-time (float-time now))
     scroll-in-rush-p))
 
 ;;;###autoload
diff --git a/lisp/play/5x5.el b/lisp/play/5x5.el
index 9ac394c..e13a3c9 100644
--- a/lisp/play/5x5.el
+++ b/lisp/play/5x5.el
@@ -1,6 +1,6 @@
 ;;; 5x5.el --- simple little puzzle game
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Pearson <address@hidden>
 ;; Maintainer: Dave Pearson <address@hidden>
diff --git a/lisp/play/animate.el b/lisp/play/animate.el
index 0ed67bd..6b0b33b 100644
--- a/lisp/play/animate.el
+++ b/lisp/play/animate.el
@@ -1,6 +1,6 @@
 ;;; animate.el --- make text dance
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: Richard Stallman <address@hidden>
 ;; Keywords: games
diff --git a/lisp/play/blackbox.el b/lisp/play/blackbox.el
index d4814ba..53a0b0b 100644
--- a/lisp/play/blackbox.el
+++ b/lisp/play/blackbox.el
@@ -1,6 +1,6 @@
 ;;; blackbox.el --- blackbox game in Emacs Lisp
 
-;; Copyright (C) 1985-1987, 1992, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1985-1987, 1992, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: F. Thomas May <address@hidden>
diff --git a/lisp/play/bubbles.el b/lisp/play/bubbles.el
index 6379c70..239fbe4 100644
--- a/lisp/play/bubbles.el
+++ b/lisp/play/bubbles.el
@@ -1,6 +1,6 @@
 ;;; bubbles.el --- Puzzle game for Emacs  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author:      Ulf Jasper <address@hidden>
 ;; URL:         http://ulf.epplejasper.de/
diff --git a/lisp/play/cookie1.el b/lisp/play/cookie1.el
index 7a6a56b..e461b37 100644
--- a/lisp/play/cookie1.el
+++ b/lisp/play/cookie1.el
@@ -1,6 +1,6 @@
 ;;; cookie1.el --- retrieve random phrases from fortune cookie files
 
-;; Copyright (C) 1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric S. Raymond <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/play/decipher.el b/lisp/play/decipher.el
index 0e57278..cb0f075 100644
--- a/lisp/play/decipher.el
+++ b/lisp/play/decipher.el
@@ -1,6 +1,6 @@
 ;;; decipher.el --- cryptanalyze monoalphabetic substitution ciphers
 ;;
-;; Copyright (C) 1995-1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-1996, 2001-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Christopher J. Madsen <address@hidden>
 ;; Keywords: games
diff --git a/lisp/play/dissociate.el b/lisp/play/dissociate.el
index 43a117c..a5880c0 100644
--- a/lisp/play/dissociate.el
+++ b/lisp/play/dissociate.el
@@ -1,6 +1,6 @@
 ;;; dissociate.el --- scramble text amusingly for Emacs
 
-;; Copyright (C) 1985, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: games
diff --git a/lisp/play/doctor.el b/lisp/play/doctor.el
index 1bdb9df..b1ab670 100644
--- a/lisp/play/doctor.el
+++ b/lisp/play/doctor.el
@@ -1,6 +1,6 @@
 ;;; doctor.el --- psychological help for frustrated users
 
-;; Copyright (C) 1985, 1987, 1994, 1996, 2000-2018 Free Software
+;; Copyright (C) 1985, 1987, 1994, 1996, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/play/dunnet.el b/lisp/play/dunnet.el
index 2b8bd9d..0a9ab37 100644
--- a/lisp/play/dunnet.el
+++ b/lisp/play/dunnet.el
@@ -1,6 +1,6 @@
 ;;; dunnet.el --- text adventure for Emacs -*- lexical-binding: t -*-
 
-;; Copyright (C) 1992-1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992-1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Ron Schnell <address@hidden>
 ;; Created: 25 Jul 1992
diff --git a/lisp/play/fortune.el b/lisp/play/fortune.el
index 740f436..3c057f4 100644
--- a/lisp/play/fortune.el
+++ b/lisp/play/fortune.el
@@ -1,6 +1,6 @@
 ;;; fortune.el --- use fortune to create signatures
 
-;; Copyright (C) 1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Holger Schauer <address@hidden>
 ;; Keywords: games utils mail
diff --git a/lisp/play/gamegrid.el b/lisp/play/gamegrid.el
index 79825c4..4a9dac7 100644
--- a/lisp/play/gamegrid.el
+++ b/lisp/play/gamegrid.el
@@ -1,6 +1,6 @@
 ;;; gamegrid.el --- library for implementing grid-based games on Emacs  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1997-1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Glynn Clements <address@hidden>
 ;; Version: 1.02
@@ -565,8 +565,8 @@ FILE is created there."
 
 ;; On POSIX systems there are four cases to distinguish:
 
-;;     1. FILE is an absolute filename.  Then it should be a file in
-;;        temporary file directory.  This is the way,
+;;     1. FILE is an absolute filename or "update-game-score" does not exist.
+;;       Then FILE should be a file in a temporary file directory.  This is how
 ;;        `gamegrid-add-score' was supposed to be used in the past and
 ;;        is covered here for backward-compatibility.
 ;;
@@ -583,21 +583,18 @@ FILE is created there."
 ;;        update FILE.  This is for the case that a user has installed
 ;;        a game on her own.
 ;;
-;;     4. "update-game-score" does not exist or is not setgid/setuid.
-;;        Create/update FILE in the user's home directory, without
-;;        using "update-game-score".  There is presumably no shared
-;;        game directory.
+;;     4. "update-game-score" is not setgid/setuid.  Use it to
+;;        create/update FILE in the user's home directory.  There is
+;;        presumably no shared game directory.
 
 (defvar gamegrid-shared-game-dir)
 
 (defun gamegrid-add-score-with-update-game-score (file score)
-  (let ((gamegrid-shared-game-dir
-        (not (zerop (logand (or (file-modes
-                                 (expand-file-name "update-game-score"
-                                                   exec-directory))
-                                 0)
-                            #o6000)))))
-    (cond ((file-name-absolute-p file)
+  (let* ((update-game-score-modes
+         (file-modes (expand-file-name "update-game-score" exec-directory)))
+        (gamegrid-shared-game-dir
+         (not (zerop (logand #o6000 (or update-game-score-modes 0))))))
+    (cond ((or (not update-game-score-modes) (file-name-absolute-p file))
           (gamegrid-add-score-insecure file score))
          ((and gamegrid-shared-game-dir
                (file-exists-p (expand-file-name file 
shared-game-score-directory)))
@@ -607,12 +604,23 @@ FILE is created there."
            (expand-file-name file shared-game-score-directory) score))
          ;; Else: Add the score to a score file in the user's home
          ;; directory.
-         (t
+         (gamegrid-shared-game-dir
+          ;; If gamegrid-shared-game-dir is non-nil the
+          ;; "update-gamescore" program is setuid, so don't use it.
           (unless (file-exists-p
                    (directory-file-name gamegrid-user-score-file-directory))
             (make-directory gamegrid-user-score-file-directory t))
           (gamegrid-add-score-insecure file score
-                                       gamegrid-user-score-file-directory)))))
+                                       gamegrid-user-score-file-directory))
+         (t
+          (unless (file-exists-p
+                   (directory-file-name gamegrid-user-score-file-directory))
+            (make-directory gamegrid-user-score-file-directory t))
+          (let ((f (expand-file-name file
+                                     gamegrid-user-score-file-directory)))
+            (unless (file-exists-p f)
+              (write-region "" nil f nil 'silent nil 'excl))
+            (gamegrid-add-score-with-update-game-score-1 file f score))))))
 
 (defun gamegrid-add-score-with-update-game-score-1 (file target score)
   (let ((default-directory "/")
diff --git a/lisp/play/gametree.el b/lisp/play/gametree.el
index 5b05ae1..c0226c8 100644
--- a/lisp/play/gametree.el
+++ b/lisp/play/gametree.el
@@ -1,6 +1,6 @@
 ;;; gametree.el --- manage game analysis trees in Emacs
 
-;; Copyright (C) 1997, 1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1999, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Ian T Zimmerman <address@hidden>
 ;; Created: Wed Dec 10 07:41:46 PST 1997
diff --git a/lisp/play/gomoku.el b/lisp/play/gomoku.el
index 6ce2750..6d5553b 100644
--- a/lisp/play/gomoku.el
+++ b/lisp/play/gomoku.el
@@ -1,6 +1,6 @@
 ;;; gomoku.el --- Gomoku game between you and Emacs  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1988, 1994, 1996, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1988, 1994, 1996, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Philippe Schnoebelen <address@hidden>
@@ -656,48 +656,48 @@ that DVAL has been added on SQUARE."
     ((eq result 'emacs-won)
      (setq gomoku-number-of-emacs-wins (1+ gomoku-number-of-emacs-wins))
      (cond ((< gomoku-number-of-moves 20)
-           "This was a REALLY QUICK win.")
+           "I won...  I hope you like the game as you get better.")
           (gomoku-human-refused-draw
            "I won...  Too bad you refused my offer of a draw!")
           (gomoku-human-took-back
-           "I won...  Taking moves back will not help you!")
+           "I won...  It's OK to take back more moves next time.")
           ((not gomoku-emacs-played-first)
-           "I won...  Playing first did not help you much!")
+           "I won...  Use C-c C-b to take back a move on second thought.")
           ((and (zerop gomoku-number-of-human-wins)
                 (zerop gomoku-number-of-draws)
                 (> gomoku-number-of-emacs-wins 1))
-           "I'm becoming tired of winning...")
+           "I won...  It might be time take a break before trying again.")
           ("I won.")))
     ((eq result 'human-won)
      (setq gomoku-number-of-human-wins (1+ gomoku-number-of-human-wins))
      (concat "OK, you won this one."
             (cond
              (gomoku-human-took-back
-              "  I, for one, never take my moves back...")
+              "  For a bigger challenge, play without taking moves back.")
              (gomoku-emacs-played-first
-              ".. so what?")
-             ("  Now, let me play first just once."))))
+              "  Congratulations!")
+             ("  For a bigger challenge, let me play first."))))
     ((eq result 'human-resigned)
      (setq gomoku-number-of-emacs-wins (1+ gomoku-number-of-emacs-wins))
-     "So you resign.  That's just one more win for me.")
+     "I see that you resigned.  Better luck next time.")
     ((eq result 'nobody-won)
      (setq gomoku-number-of-draws (1+ gomoku-number-of-draws))
      (concat "This is a draw.  "
             (cond
              (gomoku-human-took-back
-              "I, for one, never take my moves back...")
+              "  For a bigger challenge, try without taking moves back.")
              (gomoku-emacs-played-first
-              "Just chance, I guess.")
-             ("Now, let me play first just once."))))
+              "Wow, that was a long game.  We both played well.")
+             ("  For a bigger challenge, let me play first."))))
     ((eq result 'draw-agreed)
      (setq gomoku-number-of-draws (1+ gomoku-number-of-draws))
      (concat "Draw agreed.  "
             (cond
              (gomoku-human-took-back
-              "I, for one, never take my moves back...")
+              "  For a bigger challenge, try without taking moves back.")
              (gomoku-emacs-played-first
-              "You were lucky.")
-             ("Now, let me play first just once."))))
+              "Good game.")
+             ("  For a bigger challenge, let me play first."))))
     ((eq result 'crash-game)
      "Sorry, I have been interrupted and cannot resume that game...")))
   (gomoku-display-statistics)
diff --git a/lisp/play/handwrite.el b/lisp/play/handwrite.el
index 85723a6..15fac08 100644
--- a/lisp/play/handwrite.el
+++ b/lisp/play/handwrite.el
@@ -1,6 +1,6 @@
 ;;; handwrite.el --- turns your emacs buffer into a handwritten document
 
-;; Copyright (C) 1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Danny Roozendaal (was: <address@hidden>)
 ;; Created: October 21 1996
diff --git a/lisp/play/hanoi.el b/lisp/play/hanoi.el
index 635e4a9..d762290 100644
--- a/lisp/play/hanoi.el
+++ b/lisp/play/hanoi.el
@@ -381,7 +381,7 @@ BITS must be of length nrings.  Start at START-TIME."
        (cl-loop for elapsed = (- (float-time) start-time)
                  while (< elapsed hanoi-move-period)
                  with tick-period = (/ (float hanoi-move-period) total-ticks)
-                 for tick = (ceiling (/ elapsed tick-period)) do
+                for tick = (ceiling elapsed tick-period) do
                  (hanoi-ring-to-pos ring (funcall tick-to-pos tick))
                  (hanoi-sit-for (- (* tick tick-period) elapsed)))
       (cl-loop for tick from 1 to total-ticks by 2 do
diff --git a/lisp/play/life.el b/lisp/play/life.el
index c15f72b..6cce1e5 100644
--- a/lisp/play/life.el
+++ b/lisp/play/life.el
@@ -1,6 +1,6 @@
 ;;; life.el --- John Horton Conway's `Life' game for GNU Emacs
 
-;; Copyright (C) 1988, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Kyle Jones <kyleuunet.uu.net>
 ;; Maintainer: address@hidden
diff --git a/lisp/play/morse.el b/lisp/play/morse.el
index 3205394..1f62ec3 100644
--- a/lisp/play/morse.el
+++ b/lisp/play/morse.el
@@ -1,6 +1,6 @@
 ;;; morse.el --- convert text to morse code and back
 
-;; Copyright (C) 1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Rick Farnbach <address@hidden>
 ;; Keywords: games
diff --git a/lisp/play/mpuz.el b/lisp/play/mpuz.el
index c446dbe..b280a42 100644
--- a/lisp/play/mpuz.el
+++ b/lisp/play/mpuz.el
@@ -1,6 +1,6 @@
 ;;; mpuz.el --- multiplication puzzle for GNU Emacs
 
-;; Copyright (C) 1990, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Philippe Schnoebelen <address@hidden>
 ;; Overhauled: Daniel Pfeiffer <address@hidden>
diff --git a/lisp/play/pong.el b/lisp/play/pong.el
index 3b97af5..555c193 100644
--- a/lisp/play/pong.el
+++ b/lisp/play/pong.el
@@ -1,6 +1,6 @@
 ;;; pong.el --- classical implementation of pong
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Benjamin Drieu <address@hidden>
 ;; Keywords: games
diff --git a/lisp/play/snake.el b/lisp/play/snake.el
index 78cea3e..7c19733 100644
--- a/lisp/play/snake.el
+++ b/lisp/play/snake.el
@@ -1,6 +1,6 @@
 ;;; snake.el --- implementation of Snake for Emacs
 
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Glynn Clements <address@hidden>
 ;; Created: 1997-09-10
diff --git a/lisp/play/solitaire.el b/lisp/play/solitaire.el
index a1c8638..34b2c7c 100644
--- a/lisp/play/solitaire.el
+++ b/lisp/play/solitaire.el
@@ -1,6 +1,6 @@
 ;;; solitaire.el --- game of solitaire in Emacs Lisp
 
-;; Copyright (C) 1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Jan Schormann <address@hidden>
 ;; Created: Fri afternoon, Jun  3,  1994
diff --git a/lisp/play/spook.el b/lisp/play/spook.el
index 93ef021..d884c0a 100644
--- a/lisp/play/spook.el
+++ b/lisp/play/spook.el
@@ -1,6 +1,6 @@
 ;;; spook.el --- spook phrase utility for overloading the NSA line eater
 
-;; Copyright (C) 1988, 1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: games
diff --git a/lisp/play/tetris.el b/lisp/play/tetris.el
index 9d6a212..1e0681d 100644
--- a/lisp/play/tetris.el
+++ b/lisp/play/tetris.el
@@ -1,6 +1,6 @@
 ;;; tetris.el --- implementation of Tetris for Emacs
 
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Glynn Clements <address@hidden>
 ;; Version: 2.01
diff --git a/lisp/play/zone.el b/lisp/play/zone.el
index 75f1364..40d43dc 100644
--- a/lisp/play/zone.el
+++ b/lisp/play/zone.el
@@ -1,6 +1,6 @@
 ;;; zone.el --- idle display hacks
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Victor Zandy <address@hidden>
 ;; Maintainer: Thien-Thi Nguyen <address@hidden>
diff --git a/lisp/plstore.el b/lisp/plstore.el
index bbee41c..f24bac3 100644
--- a/lisp/plstore.el
+++ b/lisp/plstore.el
@@ -1,5 +1,5 @@
 ;;; plstore.el --- secure plist store -*- lexical-binding: t -*-
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Daiki Ueno <address@hidden>
 ;; Keywords: PGP, GnuPG
diff --git a/lisp/printing.el b/lisp/printing.el
index 2fc2323..f2495ec 100644
--- a/lisp/printing.el
+++ b/lisp/printing.el
@@ -1,6 +1,6 @@
-;;; printing.el --- printing utilities
+;;; printing.el --- printing utilities  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2000-2001, 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2001, 2003-2019 Free Software Foundation, Inc.
 
 ;; Author: Vinicius Jose Latorre <address@hidden>
 ;; Maintainer: Vinicius Jose Latorre <address@hidden>
@@ -460,7 +460,7 @@ Please send all bug fixes and enhancements to
 ;; subjects shows up at the printer.  With major mode printing you don't need
 ;; to switch from gnus *Summary* buffer first.
 ;;
-;; Current global keyboard mapping for GNU Emacs is:
+;; Current global keyboard mapping is:
 ;;
 ;;    (global-set-key [print]     'pr-ps-fast-fire)
 ;;    (global-set-key [M-print]   'pr-ps-mode-using-ghostscript)
@@ -468,14 +468,6 @@ Please send all bug fixes and enhancements to
 ;;    (global-set-key [C-print]   'pr-txt-fast-fire)
 ;;    (global-set-key [C-M-print] 'pr-txt-fast-fire)
 ;;
-;; And for XEmacs is:
-;;
-;;    (global-set-key 'f22                'pr-ps-fast-fire)
-;;    (global-set-key '(meta f22)         'pr-ps-mode-using-ghostscript)
-;;    (global-set-key '(shift f22)        'pr-ps-mode-using-ghostscript)
-;;    (global-set-key '(control f22)      'pr-txt-fast-fire)
-;;    (global-set-key '(control meta f22) 'pr-txt-fast-fire)
-;;
 ;; As a suggestion of global keyboard mapping for some `printing' commands:
 ;;
 ;;    (global-set-key "\C-ci"  'pr-interface)
@@ -493,7 +485,7 @@ Please send all bug fixes and enhancements to
 ;; Below it's shown a brief description of `printing' options, please, see the
 ;; options declaration in the code for a long documentation.
 ;;
-;; `pr-path-style'             Specify which path style to use for external
+;; `pr-filename-style'         Specify which filename style to use for external
 ;;                             commands.
 ;;
 ;; `pr-path-alist'             Specify an alist for command paths.
@@ -999,7 +991,7 @@ Please send all bug fixes and enhancements to
 ;;    - automagic region detection.
 ;;    - menu entry hiding.
 ;;    - fast fire PostScript printing command.
-;;    - `pr-path-style' variable.
+;;    - `pr-filename-style' variable.
 ;;
 ;; Thanks to Kim F. Storm <address@hidden> for beta-test and for suggestions:
 ;;    - PostScript Print and PostScript Print Preview merge.
@@ -1023,7 +1015,7 @@ Please send all bug fixes and enhancements to
 
 (require 'lpr)
 (require 'ps-print)
-
+(require 'easymenu)
 
 (and (string< ps-print-version "6.6.4")
      (error "`printing' requires `ps-print' package version 6.6.4 or later"))
@@ -1038,93 +1030,16 @@ Please send all bug fixes and enhancements to
 ;; To avoid compilation gripes
 
 
-;; Emacs has this since at least 21.1.
-(when (featurep 'xemacs)
-  (or (fboundp 'subst-char-in-string)  ; hacked from subr.el
-      (defun subst-char-in-string (fromchar tochar string &optional inplace)
-       "Replace FROMCHAR with TOCHAR in STRING each time it occurs.
-Unless optional argument INPLACE is non-nil, return a new string."
-       (let ((i (length string))
-             (newstr (if inplace string (copy-sequence string))))
-         (while (> (setq i (1- i)) 0)
-           (if (eq (aref newstr i) fromchar)
-               (aset newstr i tochar)))
-         newstr))))
-
-
-;; Emacs has this since at least 21.1, but the SUFFIX argument
-;; (which this file uses) only since 22.1.  So the fboundp test
-;; wasn't even correct/adequate.  Whatever, no-one is using
-;; this file on older Emacs version, so it's irrelevant.
-(when (featurep 'xemacs)
-  (or (fboundp 'make-temp-file)                ; hacked from subr.el
-      (defun make-temp-file (prefix &optional dir-flag suffix)
-      "Create a temporary file.
-The returned file name (created by appending some random characters at the end
-of PREFIX, and expanding against `temporary-file-directory' if necessary),
-is guaranteed to point to a newly created empty file.
-You can then use `write-region' to write new data into the file.
-
-If DIR-FLAG is non-nil, create a new empty directory instead of a file.
-
-If SUFFIX is non-nil, add that at the end of the file name."
-      (let ((umask (default-file-modes))
-           file)
-       (unwind-protect
-           (progn
-             ;; Create temp files with strict access rights.  It's easy to
-             ;; loosen them later, whereas it's impossible to close the
-             ;; time-window of loose permissions otherwise.
-             (set-default-file-modes ?\700)
-             (while (condition-case ()
-                        (progn
-                          (setq file
-                                (make-temp-name
-                                 (expand-file-name prefix 
temporary-file-directory)))
-                          (if suffix
-                              (setq file (concat file suffix)))
-                          (if dir-flag
-                              (make-directory file)
-                            (write-region "" nil file nil 'silent nil 'excl))
-                          nil)
-                      (file-already-exists t))
-               ;; the file was somehow created by someone else between
-               ;; `make-temp-name' and `write-region', let's try again.
-               nil)
-             file)
-         ;; Reset the umask.
-         (set-default-file-modes umask))))))
-
-
-(eval-when-compile
-  ;; User Interface --- declared here to avoid compiler warnings
-  (defvar pr-path-style)
-  (defvar pr-auto-region)
-  (defvar pr-menu-char-height)
-  (defvar pr-menu-char-width)
-  (defvar pr-menu-lock)
-  (defvar pr-ps-printer-alist)
-  (defvar pr-txt-printer-alist)
-  (defvar pr-ps-utility-alist)
-
-
-  ;; Internal fun alias to avoid compilation gripes
-  (defalias 'pr-menu-lookup            'ignore)
-  (defalias 'pr-menu-lock              'ignore)
-  (defalias 'pr-menu-alist             'ignore)
-  (defalias 'pr-even-or-odd-pages      'ignore)
-  (defalias 'pr-menu-get-item          'ignore)
-  (defalias 'pr-menu-set-item-name     'ignore)
-  (defalias 'pr-menu-set-utility-title 'ignore)
-  (defalias 'pr-menu-set-ps-title      'ignore)
-  (defalias 'pr-menu-set-txt-title     'ignore)
-  (defalias 'pr-region-active-p        'ignore)
-  (defalias 'pr-do-update-menus        'ignore)
-  (defalias 'pr-update-mode-line       'ignore)
-  (defalias 'pr-read-string            'ignore)
-  (defalias 'pr-set-keymap-parents     'ignore)
-  (defalias 'pr-keep-region-active     'ignore))
-
+;; User Interface --- declared here to avoid compiler warnings
+(define-obsolete-variable-alias 'pr-path-style 'pr-filename-style "27.1")
+(defvar pr-filename-style)
+(defvar pr-auto-region)
+(defvar pr-menu-char-height)
+(defvar pr-menu-char-width)
+(defvar pr-menu-lock)
+(defvar pr-ps-printer-alist)
+(defvar pr-txt-printer-alist)
+(defvar pr-ps-utility-alist)
 
 ;; Internal Vars --- defined here to avoid compiler warnings
 (defvar pr-menu-print-item "print"
@@ -1151,480 +1066,206 @@ Used by `pr-menu-bind' and `pr-update-menus'.")
 
 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; XEmacs Definitions
-
-
-(cond
- ((featurep 'xemacs)                   ; XEmacs
-  ;; XEmacs
-  (defalias 'pr-set-keymap-parents 'set-keymap-parents)
-  (defalias 'pr-set-keymap-name    'set-keymap-name)
-
-  ;; XEmacs
-  (defun pr-read-string (prompt initial history default)
-    (let ((str (read-string prompt initial)))
-      (if (and str (not (string= str "")))
-         str
-       default)))
-
-  ;; XEmacs
-  (defvar zmacs-region-stays  nil)
-
-  ;; XEmacs
-  (defun pr-keep-region-active ()
-    (setq zmacs-region-stays t))
-
-  ;; XEmacs
-  (defun pr-region-active-p ()
-    (and pr-auto-region (not zmacs-region-stays) (ps-mark-active-p)))
-
-  ;; XEmacs
-  (defun pr-menu-char-height ()
-    (font-height (face-font 'default)))
-
-  ;; XEmacs
-  (defun pr-menu-char-width ()
-    (font-width (face-font 'default)))
-
-  ;; XEmacs
-  (defmacro pr-xemacs-global-menubar (&rest body)
-    `(save-excursion
-       (let ((temp (get-buffer-create (make-temp-name " *Temp"))))
-        ;; be sure to access global menubar
-        (set-buffer temp)
-        ,@body
-        (kill-buffer temp))))
-
-  ;; XEmacs
-  (defun pr-global-menubar (pr-menu-spec)
-    ;; Menu binding
-    (pr-xemacs-global-menubar
-     (add-submenu nil (cons "Printing" pr-menu-spec) "Apps"))
-    (setq pr-menu-print-item nil))
-
-  ;; XEmacs
-  (defvar current-mouse-event nil)
-  (defun pr-menu-position (entry index horizontal)
-    (make-event
-     'button-release
-     (list 'button 1
-          'x (- (event-x-pixel current-mouse-event) ; X
-                (* horizontal pr-menu-char-width))
-          'y (- (event-y-pixel current-mouse-event) ; Y
-                (* (pr-menu-index entry index) pr-menu-char-height)))))
-
-  (defvar pr-menu-position nil)
-  (defvar pr-menu-state nil)
-
-  ;; XEmacs
-  (defvar current-menubar nil)         ; to avoid compilation gripes
-  (defun pr-menu-lookup (path)
-    (car (find-menu-item current-menubar (cons "Printing" path))))
-
-  ;; XEmacs
-  (defun pr-menu-lock (entry index horizontal state path)
-    (when pr-menu-lock
-      (or (and pr-menu-position (eq state pr-menu-state))
-         (setq pr-menu-position (pr-menu-position entry index horizontal)
-               pr-menu-state    state))
-      (let* ((menu   (pr-menu-lookup path))
-            (result (get-popup-menu-response menu pr-menu-position)))
-       (and (misc-user-event-p result)
-            (funcall (event-function result)
-                     (event-object result))))
-      (setq pr-menu-position nil)))
-
-  ;; XEmacs
-  (defalias 'pr-update-mode-line 'set-menubar-dirty-flag)
-
-  ;; XEmacs
-  (defvar pr-ps-name-old     "PostScript Printers")
-  (defvar pr-txt-name-old    "Text Printers")
-  (defvar pr-ps-utility-old  "PostScript Utility")
-  (defvar pr-even-or-odd-old "Print All Pages")
-
-  ;; XEmacs
-  (defun pr-do-update-menus (&optional force)
-    (pr-menu-alist pr-ps-printer-alist
-                  'pr-ps-name
-                  'pr-menu-set-ps-title
-                  '("Printing")
-                  'pr-ps-printer-menu-modified
-                  force
-                  pr-ps-name-old
-                  'postscript 2)
-    (pr-menu-alist pr-txt-printer-alist
-                  'pr-txt-name
-                  'pr-menu-set-txt-title
-                  '("Printing")
-                  'pr-txt-printer-menu-modified
-                  force
-                  pr-txt-name-old
-                  'text 2)
-    (let ((save-var pr-ps-utility-menu-modified))
-      (pr-menu-alist pr-ps-utility-alist
-                    'pr-ps-utility
-                    'pr-menu-set-utility-title
-                    '("Printing" "PostScript Print" "File")
-                    'save-var
-                    force
-                    pr-ps-utility-old
-                    nil 1))
-    (pr-menu-alist pr-ps-utility-alist
-                  'pr-ps-utility
-                  'pr-menu-set-utility-title
-                  '("Printing" "PostScript Preview" "File")
-                  'pr-ps-utility-menu-modified
-                  force
-                  pr-ps-utility-old
-                  nil 1)
-    (pr-even-or-odd-pages ps-even-or-odd-pages force))
-
-  ;; XEmacs
-  (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name
-                             entry index)
-    (when (and alist (or force (symbol-value modified-sym)))
-      (pr-xemacs-global-menubar
-       (add-submenu menu-path
-                   (pr-menu-create name alist var-sym
-                                   fun entry index)))
-      (funcall fun (symbol-value var-sym))
-      (set modified-sym nil)))
-
-  ;; XEmacs
-  (defun pr-relabel-menu-item (newname var-sym)
-    (pr-xemacs-global-menubar
-     (relabel-menu-item
-      (list "Printing" (symbol-value var-sym))
-      newname)
-     (set var-sym newname)))
-
-  ;; XEmacs
-  (defun pr-menu-set-ps-title (value &optional item entry index)
-    (pr-relabel-menu-item (format "PostScript Printer: %s" value)
-                         'pr-ps-name-old)
-    (pr-ps-set-printer value)
-    (and index
-        (pr-menu-lock entry index 12 'toggle nil)))
-
-  ;; XEmacs
-  (defun pr-menu-set-txt-title (value &optional item entry index)
-    (pr-relabel-menu-item (format "Text Printer: %s" value)
-                         'pr-txt-name-old)
-    (pr-txt-set-printer value)
-    (and index
-        (pr-menu-lock entry index 12 'toggle nil)))
-
-  ;; XEmacs
-  (defun pr-menu-set-utility-title (value &optional item entry index)
-    (pr-xemacs-global-menubar
-     (let ((newname (format "%s" value)))
-       (relabel-menu-item
-       (list "Printing" "PostScript Print" "File" pr-ps-utility-old)
-       newname)
-       (relabel-menu-item
-       (list "Printing" "PostScript Preview" "File" pr-ps-utility-old)
-       newname)
-       (setq pr-ps-utility-old newname)))
-    (pr-ps-set-utility value)
-    (and index
-        (pr-menu-lock entry index 5 nil '("PostScript Print" "File"))))
-
-  ;; XEmacs
-  (defun pr-even-or-odd-pages (value &optional no-lock)
-    (pr-relabel-menu-item (cdr (assq value pr-even-or-odd-alist))
-                         'pr-even-or-odd-old)
-    (setq ps-even-or-odd-pages value)
-    (or no-lock
-       (pr-menu-lock 'postscript-options 8 12 'toggle nil)))
-
-  )
- (t                                    ; GNU Emacs
-  ;; Do nothing
-  ))                                   ; end cond featurep
+;; GNU Emacs Definitions
 
+(defun pr-keep-region-active ()
+  (setq deactivate-mark nil))
 
-
-;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; GNU Emacs Definitions
+(defun pr-region-active-p ()
+  (and pr-auto-region (use-region-p)))
 
-(eval-and-compile
-  (unless (featurep 'xemacs)
-    (defvar pr-menu-bar nil
-      "Specify Printing menu-bar entry.")))
-
-(cond
- ((featurep 'xemacs)                   ; XEmacs
-  ;; Do nothing
-  )
- (t                                    ; GNU Emacs
-  ;; GNU Emacs
-  (defalias 'pr-set-keymap-parents 'set-keymap-parent)
-  (defalias 'pr-set-keymap-name    'ignore)
-  (defalias 'pr-read-string        'read-string)
-
-  ;; GNU Emacs
-  (defvar deactivate-mark)
-
-  ;; GNU Emacs
-  (defun pr-keep-region-active ()
-    (setq deactivate-mark nil))
-
-  ;; GNU Emacs
-  (defun pr-region-active-p ()
-    (and pr-auto-region transient-mark-mode mark-active))
-
-  ;; GNU Emacs
-  (defun pr-menu-char-height ()
-    (frame-char-height))
-
-  ;; GNU Emacs
-  (defun pr-menu-char-width ()
-    (frame-char-width))
-
-  ;; GNU Emacs
-  ;; Menu binding
-  ;; Replace existing "print" item by "Printing" item.
-  ;; If you're changing this file, you'll load it a second,
-  ;; third... time, but "print" item exists only in the first load.
-  (eval-when-compile
-    (require 'easymenu))               ; to avoid compilation gripes
-
-  (declare-function easy-menu-add-item "easymenu"
-                    (map path item &optional before))
-  (declare-function easy-menu-remove-item "easymenu" (map path name))
-
-  (eval-and-compile
-      (defun pr-global-menubar (pr-menu-spec)
-       (require 'easymenu)
-       (let ((menu-file (if (= emacs-major-version 21)
-                            '("menu-bar" "files") ; GNU Emacs 21
-                          '("menu-bar" "file")))) ; GNU Emacs 22 or higher
-         (cond
-          (pr-menu-print-item
-           (easy-menu-add-item global-map menu-file
-                               (easy-menu-create-menu "Print" pr-menu-spec)
-                               "print-buffer")
-           (dolist (item '("print-buffer"          "print-region"
-                           "ps-print-buffer-faces" "ps-print-region-faces"
-                           "ps-print-buffer"       "ps-print-region"))
-             (easy-menu-remove-item global-map menu-file item))
-           (setq pr-menu-print-item nil
-                 pr-menu-bar (vector 'menu-bar
-                                     (pr-get-symbol (nth 1 menu-file))
-                                     (pr-get-symbol "Print"))))
-          (t
-           (easy-menu-add-item global-map menu-file
-                               (easy-menu-create-menu "Print" pr-menu-spec)))
-          ))))
-
-  (eval-and-compile
+;; Menu binding
+;; Replace existing "print" item by "Printing" item.
+;; If you're changing this file, you'll load it a second,
+;; third... time, but "print" item exists only in the first load.
+
+(defvar pr-menu-bar nil
+  "Specify Printing menu-bar entry.")
+
+(defun pr-global-menubar (menu-spec)
+  (let ((menu-file '("menu-bar" "file")))
     (cond
-     (lpr-windows-system
-      ;; GNU Emacs for Windows 9x/NT
-      (defun pr-menu-position (entry index horizontal)
-       (let ((pos (cdr (mouse-pixel-position))))
-         (list
-          (list (or (car pos) 0)       ; X
-                (- (or (cdr pos) 0)    ; Y
-                   (* (pr-menu-index entry index) pr-menu-char-height)))
-          (selected-frame))))          ; frame
-      )
+     (pr-menu-print-item
+      (easy-menu-add-item global-map menu-file
+                          (easy-menu-create-menu "Print" menu-spec)
+                          "print-buffer")
+      (dolist (item '("print-buffer"          "print-region"
+                      "ps-print-buffer-faces" "ps-print-region-faces"
+                      "ps-print-buffer"       "ps-print-region"))
+        (easy-menu-remove-item global-map menu-file item))
+      (setq pr-menu-print-item nil
+            pr-menu-bar (vector 'menu-bar
+                                (easy-menu-intern (nth 1 menu-file))
+                                (easy-menu-intern "Print"))))
      (t
-      ;; GNU Emacs
-      (defun pr-menu-position (entry index horizontal)
-       (let ((pos (cdr (mouse-pixel-position))))
-         (list
-          (list (- (or (car pos) 0)    ; X
-                   (* horizontal pr-menu-char-width))
-                (- (or (cdr pos) 0)    ; Y
-                   (* (pr-menu-index entry index) pr-menu-char-height)))
-          (selected-frame))))          ; frame
-      )))
-
-  (defvar pr-menu-position nil)
-  (defvar pr-menu-state    nil)
-
-  ;; GNU Emacs
-  (defun pr-menu-lookup (path)
-    (lookup-key global-map
-               (if path
-                   (vconcat pr-menu-bar
-                            (mapcar 'pr-get-symbol
-                                    (if (listp path)
-                                        path
-                                      (list path))))
-                 pr-menu-bar)))
-
-  ;; GNU Emacs
-  (defun pr-menu-lock (entry index horizontal state path)
-    (when pr-menu-lock
-      (or (and pr-menu-position (eq state pr-menu-state))
-         (setq pr-menu-position (pr-menu-position entry index horizontal)
-               pr-menu-state    state))
-      (let* ((menu   (pr-menu-lookup path))
-            (result (x-popup-menu pr-menu-position menu)))
-       (and result
-            (let ((command (lookup-key menu (vconcat result))))
-              (if (fboundp command)
-                  (funcall command)
-                (eval command)))))
-      (setq pr-menu-position nil)))
-
-  ;; GNU Emacs
-  (defalias 'pr-update-mode-line 'force-mode-line-update)
-
-  ;; GNU Emacs
-  (defun pr-do-update-menus (&optional force)
-    (pr-menu-alist pr-ps-printer-alist
-                  'pr-ps-name
-                  'pr-menu-set-ps-title
-                  "PostScript Printers"
-                  'pr-ps-printer-menu-modified
-                  force
-                  "PostScript Printers"
-                  'postscript 2)
-    (pr-menu-alist pr-txt-printer-alist
-                  'pr-txt-name
-                  'pr-menu-set-txt-title
-                  "Text Printers"
-                  'pr-txt-printer-menu-modified
-                  force
-                  "Text Printers"
-                  'text 2)
-    (let ((save-var pr-ps-utility-menu-modified))
-      (pr-menu-alist pr-ps-utility-alist
-                    'pr-ps-utility
-                    'pr-menu-set-utility-title
-                    '("PostScript Print" "File" "PostScript Utility")
-                    'save-var
-                    force
-                    "PostScript Utility"
-                    nil 1))
+      (easy-menu-add-item global-map menu-file
+                          (easy-menu-create-menu "Print" menu-spec)))
+     )))
+
+(defun pr-menu-position (entry index horizontal)
+  (let ((pos (cdr (mouse-pixel-position))))
+    (list
+     (list (- (or (car pos) 0) ; X
+              (if lpr-windows-system
+                  0 ;; GNU Emacs for Windows 9x/NT
+                (* horizontal pr-menu-char-width)))
+           (- (or (cdr pos) 0) ; Y
+              (* (pr-menu-index entry index) pr-menu-char-height)))
+     (selected-frame))))               ; frame
+
+(defvar pr-menu-position nil)
+(defvar pr-menu-state    nil)
+
+(defun pr-menu-lookup (path)
+  (lookup-key global-map
+             (if path
+                 (vconcat pr-menu-bar
+                          (mapcar #'easy-menu-intern
+                                  (if (listp path)
+                                      path
+                                    (list path))))
+               pr-menu-bar)))
+
+(defun pr-menu-lock (entry index horizontal state path)
+  (when pr-menu-lock
+    (or (and pr-menu-position (eq state pr-menu-state))
+       (setq pr-menu-position (pr-menu-position entry index horizontal)
+             pr-menu-state    state))
+    (let* ((menu   (pr-menu-lookup path))
+          (result (x-popup-menu pr-menu-position menu)))
+      (and result
+          (let ((command (lookup-key menu (vconcat result))))
+            (if (fboundp command)
+                (funcall command)
+              (eval command)))))
+    (setq pr-menu-position nil)))
+
+(defun pr-do-update-menus (&optional force)
+  (pr-menu-alist pr-ps-printer-alist
+                'pr-ps-name
+                #'pr-menu-set-ps-title
+                "PostScript Printers"
+                'pr-ps-printer-menu-modified
+                force
+                "PostScript Printers"
+                'postscript 2)
+  (pr-menu-alist pr-txt-printer-alist
+                'pr-txt-name
+                #'pr-menu-set-txt-title
+                "Text Printers"
+                'pr-txt-printer-menu-modified
+                force
+                "Text Printers"
+                'text 2)
+  (defvar pr--save-var)
+  (let ((pr--save-var pr-ps-utility-menu-modified))
     (pr-menu-alist pr-ps-utility-alist
                   'pr-ps-utility
-                  'pr-menu-set-utility-title
-                  '("PostScript Preview" "File" "PostScript Utility")
-                  'pr-ps-utility-menu-modified
+                  #'pr-menu-set-utility-title
+                  '("PostScript Print" "File" "PostScript Utility")
+                  'pr--save-var
                   force
                   "PostScript Utility"
-                  nil 1)
-    (pr-even-or-odd-pages ps-even-or-odd-pages force))
-
-  ;; GNU Emacs
-  (defun pr-menu-get-item (name-list)
-    ;; NAME-LIST is a string or a list of strings.
-    (or (listp name-list)
-       (setq name-list (list name-list)))
-    (and name-list
-        (let* ((reversed (reverse name-list))
-               (name (pr-get-symbol (car reversed)))
-               (path (nreverse (cdr reversed)))
-               (menu (lookup-key
-                      global-map
-                      (vconcat pr-menu-bar
-                               (mapcar 'pr-get-symbol path)))))
-          (assq name (nthcdr 2 menu)))))
-
-  ;; GNU Emacs
-  (defvar pr-temp-menu nil)
-
-  ;; GNU Emacs
-  (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name
-                             entry index)
-    (when (and alist (or force (symbol-value modified-sym)))
-      (easy-menu-define pr-temp-menu nil ""
-       (pr-menu-create name alist var-sym fun entry index))
-      (let ((item (pr-menu-get-item menu-path)))
-       (and item
-            (let* ((binding     (nthcdr 3 item))
-                   (key-binding (cdr binding)))
-              (setcar binding pr-temp-menu)
-              (and key-binding (listp (car key-binding))
-                   (setcdr binding (cdr key-binding))) ; skip KEY-BINDING
-              (funcall fun (symbol-value var-sym) item))))
-      (set modified-sym nil)))
-
-  ;; GNU Emacs
-  (defun pr-menu-set-item-name (item name)
-    (and item
-        (setcar (nthcdr 2 item) name))) ; ITEM-NAME
-
-  ;; GNU Emacs
-  (defun pr-menu-set-ps-title (value &optional item entry index)
-    (pr-menu-set-item-name (or item
-                              (pr-menu-get-item "PostScript Printers"))
-                          (format "PostScript Printer: %s" value))
-    (pr-ps-set-printer value)
-    (and index
-        (pr-menu-lock entry index 12 'toggle nil)))
-
-  ;; GNU Emacs
-  (defun pr-menu-set-txt-title (value &optional item entry index)
-    (pr-menu-set-item-name (or item
-                              (pr-menu-get-item "Text Printers"))
-                          (format "Text Printer: %s" value))
-    (pr-txt-set-printer value)
-    (and index
-        (pr-menu-lock entry index 12 'toggle nil)))
-
-  ;; GNU Emacs
-  (defun pr-menu-set-utility-title (value &optional item entry index)
-    (let ((name (symbol-name value)))
-      (if item
-         (pr-menu-set-item-name item name)
-       (pr-menu-set-item-name
-        (pr-menu-get-item
-         '("PostScript Print"   "File" "PostScript Utility"))
-        name)
-       (pr-menu-set-item-name
-        (pr-menu-get-item
-         '("PostScript Preview" "File" "PostScript Utility"))
-        name)))
-    (pr-ps-set-utility value)
-    (and index
-        (pr-menu-lock entry index 5 nil '("PostScript Print" "File"))))
-
-  ;; GNU Emacs
-  (defun pr-even-or-odd-pages (value &optional no-lock)
-    (pr-menu-set-item-name (pr-menu-get-item "Print All Pages")
-                          (cdr (assq value pr-even-or-odd-alist)))
-    (setq ps-even-or-odd-pages value)
-    (or no-lock
-       (pr-menu-lock 'postscript-options 8 12 'toggle nil)))
-
-  ))                                   ; end cond featurep
-
+                  nil 1))
+  (pr-menu-alist pr-ps-utility-alist
+                'pr-ps-utility
+                #'pr-menu-set-utility-title
+                '("PostScript Preview" "File" "PostScript Utility")
+                'pr-ps-utility-menu-modified
+                force
+                "PostScript Utility"
+                nil 1)
+  (pr-even-or-odd-pages ps-even-or-odd-pages force))
+
+(defun pr-menu-get-item (name-list)
+  ;; NAME-LIST is a string or a list of strings.
+  (or (listp name-list)
+      (setq name-list (list name-list)))
+  (and name-list
+       (let* ((reversed (reverse name-list))
+             (name (easy-menu-intern (car reversed)))
+             (path (nreverse (cdr reversed)))
+             (menu (lookup-key
+                    global-map
+                    (vconcat pr-menu-bar
+                             (mapcar #'easy-menu-intern path)))))
+        (assq name (nthcdr 2 menu)))))
+
+(defvar pr-temp-menu nil)
+
+(defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name
+                           entry index)
+  (when (and alist (or force (symbol-value modified-sym)))
+    (easy-menu-define pr-temp-menu nil ""
+      (pr-menu-create name alist var-sym fun entry index))
+    (let ((item (pr-menu-get-item menu-path)))
+      (and item
+           (progn
+            (setf (nth 3 item) pr-temp-menu)
+            (funcall fun (symbol-value var-sym) item))))
+    (set modified-sym nil)))
+
+(defun pr-menu-set-item-name (item name)
+  (and item
+       (setcar (nthcdr 2 item) name))) ; ITEM-NAME
+
+(defun pr-menu-set-ps-title (value &optional item entry index)
+  (pr-menu-set-item-name (or item
+                            (pr-menu-get-item "PostScript Printers"))
+                        (format "PostScript Printer: %s" value))
+  (pr-ps-set-printer value)
+  (and index
+       (pr-menu-lock entry index 12 'toggle nil)))
+
+(defun pr-menu-set-txt-title (value &optional item entry index)
+  (pr-menu-set-item-name (or item
+                            (pr-menu-get-item "Text Printers"))
+                        (format "Text Printer: %s" value))
+  (pr-txt-set-printer value)
+  (and index
+       (pr-menu-lock entry index 12 'toggle nil)))
+
+(defun pr-menu-set-utility-title (value &optional item entry index)
+  (let ((name (symbol-name value)))
+    (if item
+       (pr-menu-set-item-name item name)
+      (pr-menu-set-item-name
+       (pr-menu-get-item
+       '("PostScript Print"   "File" "PostScript Utility"))
+       name)
+      (pr-menu-set-item-name
+       (pr-menu-get-item
+       '("PostScript Preview" "File" "PostScript Utility"))
+       name)))
+  (pr-ps-set-utility value)
+  (and index
+       (pr-menu-lock entry index 5 nil '("PostScript Print" "File"))))
+
+(defun pr-even-or-odd-pages (value &optional no-lock)
+  (pr-menu-set-item-name (pr-menu-get-item "Print All Pages")
+                        (cdr (assq value pr-even-or-odd-alist)))
+  (setq ps-even-or-odd-pages value)
+  (or no-lock
+      (pr-menu-lock 'postscript-options 8 12 'toggle nil)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Internal Functions (I)
 
 
-(defun pr-dosify-file-name (path)
+(defun pr-dosify-file-name (filename)
   "Replace unix-style directory separator character with dos/windows one."
-  (interactive "sPath: ")
-  (if (eq pr-path-style 'windows)
-      (subst-char-in-string ?/ ?\\ path)
-    path))
-
+  (if (eq pr-filename-style 'windows)
+      (subst-char-in-string ?/ ?\\ filename)
+    filename))
 
-(defun pr-unixify-file-name (path)
-  "Replace dos/windows-style directory separator character with unix one."
-  (interactive "sPath: ")
-  (if (eq pr-path-style 'windows)
-      (subst-char-in-string ?\\ ?/ path)
-    path))
-
-
-(defun pr-standard-file-name (path)
+(defun pr-standard-file-name (filename)
   "Ensure the proper directory separator depending on the OS.
 That is, if Emacs is running on DOS/Windows, ensure dos/windows-style directory
 separator; otherwise, ensure unix-style directory separator."
+  ;; FIXME: Why not use pr-dosify-file-name?
   (if (or pr-cygwin-system lpr-windows-system)
-      (subst-char-in-string ?/ ?\\ path)
-    (subst-char-in-string ?\\ ?/ path)))
-
+      (subst-char-in-string ?/ ?\\ filename)
+    filename))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Customization Functions
@@ -1672,22 +1313,21 @@ separator; otherwise, ensure unix-style directory 
separator."
   :group 'postscript)
 
 
-(defcustom pr-path-style
+(defcustom pr-filename-style
   (if (and (not pr-cygwin-system)
           lpr-windows-system)
       'windows
     'unix)
-  "Specify which path style to use for external commands.
+  "Specify which filename style to use for external commands.
 
 Valid values are:
 
    windows     Windows 9x/NT style (\\)
 
    unix                Unix style (/)"
-  :type '(choice :tag "Path style"
+  :type '(choice :tag "Filename style"
                 (const :tag "Windows 9x/NT Style (\\)" :value windows)
-                (const :tag "Unix Style (/)" :value unix))
-  :group 'printing)
+                (const :tag "Unix Style (/)" :value unix)))
 
 
 (defcustom pr-path-alist
@@ -1708,13 +1348,13 @@ Where:
 ENTRY          It's a symbol, used to identify this entry.
                There must exist at least one of the following entries:
 
-               unix    this entry is used when Emacs is running on GNU or
+               `unix'  this entry is used when Emacs is running on GNU or
                        Unix system.
 
-               cygwin  this entry is used when Emacs is running on Windows
+               `cygwin'        this entry is used when Emacs is running on 
Windows
                        95/98/NT/2000 with Cygwin.
 
-               windows this entry is used when Emacs is running on Windows
+               `windows'       this entry is used when Emacs is running on 
Windows
                        95/98/NT/2000.
 
 DIRECTORY      It should be a string or a symbol.  If it's a symbol, it should
@@ -1764,8 +1404,7 @@ Examples:
                        (choice :menu-tag "Directory"
                                :tag "Directory"
                                (string :value "")
-                               (symbol :value symbol)))))
-  :group 'printing)
+                               (symbol :value symbol))))))
 
 
 (defcustom pr-txt-name 'default
@@ -1778,8 +1417,7 @@ This variable should be modified by customization engine. 
 If this variable is
 modified by other means (for example, a lisp function), use `pr-update-menus'
 function (see it for documentation) to update text printer menu."
   :type 'symbol
-  :set 'pr-txt-name-custom-set
-  :group 'printing)
+  :set 'pr-txt-name-custom-set)
 
 
 (defcustom pr-txt-printer-alist
@@ -1910,8 +1548,7 @@ Useful links:
                        :tag "Printer Name"
                        (const :tag "None" nil)
                        string)))
-  :set 'pr-alist-custom-set
-  :group 'printing)
+  :set 'pr-alist-custom-set)
 
 
 (defcustom pr-ps-name 'default
@@ -1924,8 +1561,7 @@ This variable should be modified by customization engine. 
 If this variable is
 modified by other means (for example, a lisp function), use `pr-update-menus'
 function (see it for documentation) to update PostScript printer menu."
   :type 'symbol
-  :set 'pr-ps-name-custom-set
-  :group 'printing)
+  :set 'pr-ps-name-custom-set)
 
 
 (defcustom pr-ps-printer-alist
@@ -2196,33 +1832,21 @@ Useful links:
              (variable :tag "Other"))
             (sexp :tag "Value")))
           ))
-  :set 'pr-alist-custom-set
-  :group 'printing)
-
-
-(defcustom pr-temp-dir
-  (pr-dosify-file-name
-   (if (boundp 'temporary-file-directory)
-       (symbol-value 'temporary-file-directory)
-     ;; hacked from `temporary-file-directory' variable in files.el
-     (file-name-as-directory
-      (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP")
-         (cond (lpr-windows-system "c:/temp")
-               (t "/tmp")
-               )))))
+  :set 'pr-alist-custom-set)
+
+
+(defcustom pr-temp-dir temporary-file-directory
   "Specify a directory for temporary files during printing.
 
 See also `pr-ps-temp-file' and `pr-file-modes'."
-  :type '(directory :tag "Temporary Directory")
-  :group 'printing)
+  :type '(directory :tag "Temporary Directory"))
 
 
 (defcustom pr-ps-temp-file "prspool-"
   "Specify PostScript temporary file name prefix.
 
 See also `pr-temp-dir' and `pr-file-modes'."
-  :type '(file :tag "PostScript Temporary File Name")
-  :group 'printing)
+  :type '(file :tag "PostScript Temporary File Name"))
 
 
 ;; It uses 0600 as default instead of (default-file-modes).
@@ -2234,8 +1858,7 @@ See also `pr-temp-dir' and `pr-file-modes'."
 It should be an integer; only the low 9 bits are used.
 
 See also `pr-temp-dir' and `pr-ps-temp-file'."
-  :type '(integer :tag "File Permission Bits")
-  :group 'printing)
+  :type '(integer :tag "File Permission Bits"))
 
 
 (defcustom pr-gv-command
@@ -2275,8 +1898,7 @@ Useful links:
 * MacGSView (Mac OS)
   `http://www.cs.wisc.edu/~ghost/macos/index.htm'
 "
-  :type '(string :tag "Ghostview Utility")
-  :group 'printing)
+  :type '(string :tag "Ghostview Utility"))
 
 
 (defcustom pr-gs-command
@@ -2301,8 +1923,7 @@ Useful links:
 * Printer compatibility
   `http://www.cs.wisc.edu/~ghost/doc/printer.htm'
 "
-  :type '(string :tag "Ghostscript Utility")
-  :group 'printing)
+  :type '(string :tag "Ghostscript Utility"))
 
 
 (defcustom pr-gs-switches
@@ -2343,8 +1964,7 @@ Useful links:
 * Printer compatibility
   `http://www.cs.wisc.edu/~ghost/doc/printer.htm'
 "
-  :type '(repeat (string :tag "Ghostscript Switch"))
-  :group 'printing)
+  :type '(repeat (string :tag "Ghostscript Switch")))
 
 
 (defcustom pr-gs-device
@@ -2359,8 +1979,7 @@ A note on the gs switches:
 
 See `pr-gs-switches' for documentation.
 See also `pr-ps-printer-alist'."
-  :type '(string :tag "Ghostscript Device")
-  :group 'printing)
+  :type '(string :tag "Ghostscript Device"))
 
 
 (defcustom pr-gs-resolution 300
@@ -2372,8 +1991,7 @@ A note on the gs switches:
 
 See `pr-gs-switches' for documentation.
 See also `pr-ps-printer-alist'."
-  :type '(integer :tag "Ghostscript Resolution")
-  :group 'printing)
+  :type '(integer :tag "Ghostscript Resolution"))
 
 
 (defcustom pr-print-using-ghostscript nil
@@ -2384,32 +2002,27 @@ ghostscript to print a PostScript file.
 
 In GNU or Unix system, if ghostscript is set as a PostScript filter, this
 variable should be nil."
-  :type 'boolean
-  :group 'printing)
+  :type 'boolean)
 
 
 (defcustom pr-faces-p nil
   "Non-nil means print with face attributes."
-  :type 'boolean
-  :group 'printing)
+  :type 'boolean)
 
 
 (defcustom pr-spool-p nil
   "Non-nil means spool printing in a buffer."
-  :type 'boolean
-  :group 'printing)
+  :type 'boolean)
 
 
 (defcustom pr-file-landscape nil
   "Non-nil means print PostScript file in landscape orientation."
-  :type 'boolean
-  :group 'printing)
+  :type 'boolean)
 
 
 (defcustom pr-file-duplex nil
   "Non-nil means print PostScript file in duplex mode."
-  :type 'boolean
-  :group 'printing)
+  :type 'boolean)
 
 
 (defcustom pr-file-tumble nil
@@ -2419,8 +2032,7 @@ If tumble is off, produces a printing suitable for 
binding on the left or
 right.
 If tumble is on, produces a printing suitable for binding at the top or
 bottom."
-  :type 'boolean
-  :group 'printing)
+  :type 'boolean)
 
 
 (defcustom pr-auto-region t
@@ -2431,8 +2043,7 @@ Note that this will only work if you're using transient 
mark mode.
 When this variable is non-nil, the `*-buffer*' commands will behave like
 `*-region*' commands, that is, `*-buffer*' commands will print only the region
 marked instead of all buffer."
-  :type 'boolean
-  :group 'printing)
+  :type 'boolean)
 
 
 (defcustom pr-auto-mode t
@@ -2442,8 +2053,7 @@ That is, if current major-mode is declared in 
`pr-mode-alist', the `*-buffer*'
 and `*-region*' commands will behave like `*-mode*' commands; otherwise,
 `*-buffer*' commands will print the current buffer and `*-region*' commands
 will print the current region."
-  :type 'boolean
-  :group 'printing)
+  :type 'boolean)
 
 
 (defcustom pr-mode-alist
@@ -2642,8 +2252,7 @@ DEFAULT           It's a way to set default values when 
this entry is selected.
              (const :tag "inherits-from:"         inherits-from:)
              (variable :tag "Other"))
             (sexp :tag "Value")))
-          ))
-  :group 'printing)
+          )))
 
 
 (defcustom pr-ps-utility 'mpage
@@ -2659,8 +2268,7 @@ function (see it for documentation) to update PostScript 
utility menu.
 NOTE: Don't forget to download and install the utilities declared on
       `pr-ps-utility-alist'."
   :type '(symbol :tag "PS File Utility")
-  :set 'pr-ps-utility-custom-set
-  :group 'printing)
+  :set 'pr-ps-utility-custom-set)
 
 
 (defcustom pr-ps-utility-alist
@@ -2871,38 +2479,34 @@ Useful links:
                   (variable :tag "Other"))
                  (sexp :tag "Value")))
                ))
-  :set 'pr-alist-custom-set
-  :group 'printing)
+  :set 'pr-alist-custom-set)
 
 
 (defcustom pr-menu-lock t
   "Non-nil means menu is locked while selecting toggle options.
 
 See also `pr-menu-char-height' and `pr-menu-char-width'."
-  :type 'boolean
-  :group 'printing)
+  :type 'boolean)
 
 
-(defcustom pr-menu-char-height (pr-menu-char-height)
+(defcustom pr-menu-char-height (frame-char-height)
   "Specify menu char height in pixels.
 
 This variable is used to guess which vertical position should be locked the
 menu, so don't forget to adjust it if menu position is not ok.
 
 See also `pr-menu-lock' and `pr-menu-char-width'."
-  :type 'integer
-  :group 'printing)
+  :type 'integer)
 
 
-(defcustom pr-menu-char-width (pr-menu-char-width)
+(defcustom pr-menu-char-width (frame-char-width)
   "Specify menu char width in pixels.
 
 This variable is used to guess which horizontal position should be locked the
 menu, so don't forget to adjust it if menu position is not ok.
 
 See also `pr-menu-lock' and `pr-menu-char-height'."
-  :type 'integer
-  :group 'printing)
+  :type 'integer)
 
 
 (defcustom pr-setting-database
@@ -3017,8 +2621,7 @@ SETTING           It's a cons like:
              (const :tag "Ghostscript Resolution" pr-gs-resolution)
              (variable :tag "Other"))
             (sexp :tag "Value")))
-          ))
-  :group 'printing)
+          )))
 
 
 (defcustom pr-visible-entry-list
@@ -3070,8 +2673,7 @@ Any other value is ignored."
                         (const postscript-options)
                         (const postscript-process)
                         (const printing)
-                        (const help)))
-  :group 'printing)
+                        (const help))))
 
 
 (defcustom pr-delete-temp-file t
@@ -3081,8 +2683,7 @@ Set `pr-delete-temp-file' to nil, if the following 
message (or a similar)
 happens when printing:
 
    Error: could not open \"c:\\temp\\prspool.ps\" for reading."
-  :type 'boolean
-  :group 'printing)
+  :type 'boolean)
 
 
 (defcustom pr-list-directory nil
@@ -3094,16 +2695,14 @@ argument of functions below) are also printed (as 
dired-mode listings).
 It's used by `pr-ps-directory-preview', `pr-ps-directory-using-ghostscript',
 `pr-ps-directory-print', `pr-ps-directory-ps-print', `pr-printify-directory'
 and `pr-txt-directory'."
-  :type 'boolean
-  :group 'printing)
+  :type 'boolean)
 
 
 (defcustom pr-buffer-name "*Printing Interface*"
   "Specify the name of the buffer interface for printing package.
 
 It's used by `pr-interface'."
-  :type 'string
-  :group 'printing)
+  :type 'string)
 
 
 (defcustom pr-buffer-name-ignore
@@ -3115,16 +2714,14 @@ NOTE: Case is important for matching, that is, 
`case-fold-search' is always
       nil.
 
 It's used by `pr-interface'."
-  :type '(repeat (regexp :tag "Buffer Name Regexp"))
-  :group 'printing)
+  :type '(repeat (regexp :tag "Buffer Name Regexp")))
 
 
 (defcustom pr-buffer-verbose t
   "Non-nil means to be verbose when editing a field in interface buffer.
 
 It's used by `pr-interface'."
-  :type 'boolean
-  :group 'printing)
+  :type 'boolean)
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -3167,15 +2764,6 @@ See `pr-ps-printer-alist'.")
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Macros
-
-
-(defmacro pr-save-file-modes (&rest body)
-  "Execute BODY with file permissions temporarily set to `pr-file-modes'."
-  (declare (obsolete with-file-modes "25.1"))
-  `(with-file-modes pr-file-modes ,@body))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Keys & Menus
 
 
@@ -3195,252 +2783,211 @@ See `pr-ps-printer-alist'.")
   (and pr-print-using-ghostscript (not pr-spool-p)))
 
 
-(defalias 'pr-get-symbol
-  (if (featurep 'emacs) 'easy-menu-intern ; since 22.1
-    (if (fboundp 'easy-menu-intern)    ; hacked from easymenu.el
-       'easy-menu-intern
-      (lambda (s) (if (stringp s) (intern s) s)))))
-
-
 (defconst pr-menu-spec
-  ;; Menu mapping:
-  ;;   unfortunately XEmacs doesn't support :active for submenus,
-  ;;   only for items.
-  ;;   So, it uses :included instead of :active.
-  ;;   Also, XEmacs doesn't support :help tag.
-  (let ((pr-:active  (if (featurep 'xemacs)
-                        :included      ; XEmacs
-                      :active))        ; GNU Emacs
-       (pr-:help    (if (featurep 'xemacs)
-                        'ignore                                ; XEmacs
-                      #'(lambda (text) (list :help text)))))   ; GNU Emacs
-    `(
-      ["Printing Interface" pr-interface
-       ,@(funcall
-         pr-:help "Use buffer interface instead of menu interface")]
+  '(
+    ["Printing Interface" pr-interface
+     :help "Use buffer interface instead of menu interface"]
+    "--"
+    ("PostScript Preview" :included (pr-visible-p 'postscript)
+     :help "Preview PostScript instead of sending to printer"
+     ("Directory" :active (not pr-spool-p)
+      ["1-up"     (pr-ps-directory-preview 1   nil nil t) t]
+      ["2-up"     (pr-ps-directory-preview 2   nil nil t) t]
+      ["4-up"     (pr-ps-directory-preview 4   nil nil t) t]
+      ["Other..." (pr-ps-directory-preview nil nil nil t)
+       :keys "\\[pr-ps-buffer-preview]"])
+     ("Buffer" :active (not pr-spool-p)
+      ["1-up"     (pr-ps-buffer-preview 1   t) t]
+      ["2-up"     (pr-ps-buffer-preview 2   t) t]
+      ["4-up"     (pr-ps-buffer-preview 4   t) t]
+      ["Other..." (pr-ps-buffer-preview nil t)
+       :keys "\\[pr-ps-buffer-preview]"])
+     ("Region" :active (and (not pr-spool-p) (ps-mark-active-p))
+      ["1-up"     (pr-ps-region-preview 1   t) t]
+      ["2-up"     (pr-ps-region-preview 2   t) t]
+      ["4-up"     (pr-ps-region-preview 4   t) t]
+      ["Other..." (pr-ps-region-preview nil t)
+       :keys "\\[pr-ps-region-preview]"])
+     ("Mode" :active (and (not pr-spool-p) (pr-mode-alist-p))
+      ["1-up"     (pr-ps-mode-preview 1   t) t]
+      ["2-up"     (pr-ps-mode-preview 2   t) t]
+      ["4-up"     (pr-ps-mode-preview 4   t) t]
+      ["Other..." (pr-ps-mode-preview nil t)
+       :keys "\\[pr-ps-mode-preview]"])
+     ("File"
+      ["No Preprocessing..." (call-interactively 'pr-ps-file-preview)
+       :keys "\\[pr-ps-file-preview]"
+       :help "Preview PostScript file"]
       "--"
-      ("PostScript Preview" :included (pr-visible-p 'postscript)
-       ,@(funcall
-         pr-:help "Preview PostScript instead of sending to printer")
-       ("Directory" ,pr-:active (not pr-spool-p)
-       ["1-up"     (pr-ps-directory-preview 1   nil nil t) t]
-       ["2-up"     (pr-ps-directory-preview 2   nil nil t) t]
-       ["4-up"     (pr-ps-directory-preview 4   nil nil t) t]
-       ["Other..." (pr-ps-directory-preview nil nil nil t)
-        :keys "\\[pr-ps-buffer-preview]"])
-       ("Buffer" ,pr-:active (not pr-spool-p)
-       ["1-up"     (pr-ps-buffer-preview 1   t) t]
-       ["2-up"     (pr-ps-buffer-preview 2   t) t]
-       ["4-up"     (pr-ps-buffer-preview 4   t) t]
-       ["Other..." (pr-ps-buffer-preview nil t)
-        :keys "\\[pr-ps-buffer-preview]"])
-       ("Region" ,pr-:active (and (not pr-spool-p) (ps-mark-active-p))
-       ["1-up"     (pr-ps-region-preview 1   t) t]
-       ["2-up"     (pr-ps-region-preview 2   t) t]
-       ["4-up"     (pr-ps-region-preview 4   t) t]
-       ["Other..." (pr-ps-region-preview nil t)
-        :keys "\\[pr-ps-region-preview]"])
-       ("Mode" ,pr-:active (and (not pr-spool-p) (pr-mode-alist-p))
-       ["1-up"     (pr-ps-mode-preview 1   t) t]
-       ["2-up"     (pr-ps-mode-preview 2   t) t]
-       ["4-up"     (pr-ps-mode-preview 4   t) t]
-       ["Other..." (pr-ps-mode-preview nil t)
-        :keys "\\[pr-ps-mode-preview]"])
-       ("File"
-       ["No Preprocessing..." (call-interactively 'pr-ps-file-preview)
-        :keys "\\[pr-ps-file-preview]"
-        ,@(funcall
-           pr-:help "Preview PostScript file")]
-       "--"
-       ["PostScript Utility" pr-update-menus :active pr-ps-utility-alist
-        ,@(funcall
-           pr-:help "Select PostScript utility")]
-       "--"
-       ["1-up..."   (pr-ps-file-up-preview 1   t t) pr-ps-utility-alist]
-       ["2-up..."   (pr-ps-file-up-preview 2   t t) pr-ps-utility-alist]
-       ["4-up..."   (pr-ps-file-up-preview 4   t t) pr-ps-utility-alist]
-       ["Other..."  (pr-ps-file-up-preview nil t t)
-        :keys "\\[pr-ps-file-up-preview]" :active pr-ps-utility-alist]
-       "--"
-       ["Landscape" pr-toggle-file-landscape-menu
-        :style toggle :selected pr-file-landscape
-        ,@(funcall
-           pr-:help "Toggle landscape for PostScript file")
-        :active pr-ps-utility-alist]
-       ["Duplex"    pr-toggle-file-duplex-menu
-        :style toggle :selected pr-file-duplex
-        ,@(funcall
-           pr-:help "Toggle duplex for PostScript file")
-        :active pr-ps-utility-alist]
-       ["Tumble"    pr-toggle-file-tumble-menu
-        :style toggle :selected pr-file-tumble
-        ,@(funcall
-           pr-:help "Toggle tumble for PostScript file")
-        :active (and pr-file-duplex pr-ps-utility-alist)])
-       ["Despool..." (call-interactively 'pr-despool-preview)
-       :active pr-spool-p :keys "\\[pr-despool-preview]"
-       ,@(funcall
-          pr-:help "Despool PostScript buffer to printer or file (C-u)")])
-      ("PostScript Print" :included (pr-visible-p 'postscript)
-       ,@(funcall
-         pr-:help "Send PostScript to printer or file (C-u)")
-       ("Directory"
-       ["1-up"     (pr-ps-directory-ps-print 1   nil nil t) t]
-       ["2-up"     (pr-ps-directory-ps-print 2   nil nil t) t]
-       ["4-up"     (pr-ps-directory-ps-print 4   nil nil t) t]
-       ["Other..." (pr-ps-directory-ps-print nil nil nil t)
-        :keys "\\[pr-ps-buffer-ps-print]"])
-       ("Buffer"
-       ["1-up"     (pr-ps-buffer-ps-print 1   t) t]
-       ["2-up"     (pr-ps-buffer-ps-print 2   t) t]
-       ["4-up"     (pr-ps-buffer-ps-print 4   t) t]
-       ["Other..." (pr-ps-buffer-ps-print nil t)
-        :keys "\\[pr-ps-buffer-ps-print]"])
-       ("Region" ,pr-:active (ps-mark-active-p)
-       ["1-up"     (pr-ps-region-ps-print 1   t) t]
-       ["2-up"     (pr-ps-region-ps-print 2   t) t]
-       ["4-up"     (pr-ps-region-ps-print 4   t) t]
-       ["Other..." (pr-ps-region-ps-print nil t)
-        :keys "\\[pr-ps-region-ps-print]"])
-       ("Mode" ,pr-:active (pr-mode-alist-p)
-       ["1-up"     (pr-ps-mode-ps-print 1   t) t]
-       ["2-up"     (pr-ps-mode-ps-print 2   t) t]
-       ["4-up"     (pr-ps-mode-ps-print 4   t) t]
-       ["Other..." (pr-ps-mode-ps-print nil t)
-        :keys "\\[pr-ps-mode-ps-print]"])
-       ("File"
-       ["No Preprocessing..." (call-interactively 'pr-ps-file-ps-print)
-        :keys "\\[pr-ps-file-ps-print]"
-        ,@(funcall
-           pr-:help "Send PostScript file to printer")]
-       "--"
-       ["PostScript Utility" pr-update-menus :active pr-ps-utility-alist
-        ,@(funcall
-           pr-:help "Select PostScript utility")]
-       "--"
-       ["1-up..."   (pr-ps-file-up-ps-print 1   t t) pr-ps-utility-alist]
-       ["2-up..."   (pr-ps-file-up-ps-print 2   t t) pr-ps-utility-alist]
-       ["4-up..."   (pr-ps-file-up-ps-print 4   t t) pr-ps-utility-alist]
-       ["Other..."  (pr-ps-file-up-ps-print nil t t)
-        :keys "\\[pr-ps-file-up-ps-print]" :active pr-ps-utility-alist]
-       "--"
-       ["Landscape" pr-toggle-file-landscape-menu
-        :style toggle :selected pr-file-landscape
-        ,@(funcall
-           pr-:help "Toggle landscape for PostScript file")
-        :active pr-ps-utility-alist]
-       ["Duplex"    pr-toggle-file-duplex-menu
-        :style toggle :selected pr-file-duplex
-        ,@(funcall
-           pr-:help "Toggle duplex for PostScript file")
-        :active pr-ps-utility-alist]
-       ["Tumble"    pr-toggle-file-tumble-menu
-        :style toggle :selected pr-file-tumble
-        ,@(funcall
-           pr-:help "Toggle tumble for PostScript file")
-        :active (and pr-file-duplex pr-ps-utility-alist)])
-       ["Despool..." (call-interactively 'pr-despool-ps-print)
-       :active pr-spool-p :keys "\\[pr-despool-ps-print]"
-       ,@(funcall
-          pr-:help "Despool PostScript buffer to printer or file (C-u)")])
-      ["PostScript Printers" pr-update-menus
-       :active pr-ps-printer-alist :included (pr-visible-p 'postscript)
-       ,@(funcall
-         pr-:help "Select PostScript printer")]
+      ["PostScript Utility" pr-update-menus :active pr-ps-utility-alist
+       :help "Select PostScript utility"]
       "--"
-      ("Printify" :included (pr-visible-p 'text)
-       ,@(funcall
-         pr-:help
-         "Replace non-printing chars with printable representations.")
-       ["Directory" pr-printify-directory t]
-       ["Buffer"    pr-printify-buffer    t]
-       ["Region"    pr-printify-region    (ps-mark-active-p)])
-      ("Print" :included (pr-visible-p 'text)
-       ,@(funcall
-         pr-:help "Send text to printer")
-       ["Directory" pr-txt-directory t]
-       ["Buffer"    pr-txt-buffer    t]
-       ["Region"    pr-txt-region    (ps-mark-active-p)]
-       ["Mode"      pr-txt-mode      (pr-mode-alist-p)])
-      ["Text Printers" pr-update-menus
-       :active pr-txt-printer-alist :included (pr-visible-p 'text)
-       ,@(funcall
-         pr-:help "Select text printer")]
+      ["1-up..."   (pr-ps-file-up-preview 1   t t) pr-ps-utility-alist]
+      ["2-up..."   (pr-ps-file-up-preview 2   t t) pr-ps-utility-alist]
+      ["4-up..."   (pr-ps-file-up-preview 4   t t) pr-ps-utility-alist]
+      ["Other..."  (pr-ps-file-up-preview nil t t)
+       :keys "\\[pr-ps-file-up-preview]" :active pr-ps-utility-alist]
       "--"
-      ["Landscape"               pr-toggle-landscape-menu
-       :style toggle :selected ps-landscape-mode
-       :included (pr-visible-p 'postscript-options)]
-      ["Print Header"            pr-toggle-header-menu
-       :style toggle :selected ps-print-header
-       :included (pr-visible-p 'postscript-options)]
-      ["Print Header Frame"      pr-toggle-header-frame-menu
-       :style toggle :selected ps-print-header-frame :active ps-print-header
-       :included (pr-visible-p 'postscript-options)]
-      ["Line Number"             pr-toggle-line-menu
-       :style toggle :selected ps-line-number
-       :included (pr-visible-p 'postscript-options)]
-      ["Zebra Stripes"           pr-toggle-zebra-menu
-       :style toggle :selected ps-zebra-stripes
-       :included (pr-visible-p 'postscript-options)]
-      ["Duplex"                  pr-toggle-duplex-menu
-       :style toggle :selected ps-spool-duplex
-       :included (pr-visible-p 'postscript-options)]
-      ["Tumble"                  pr-toggle-tumble-menu
-       :style toggle :selected ps-spool-tumble :active ps-spool-duplex
-       :included (pr-visible-p 'postscript-options)]
-      ["Upside-Down"             pr-toggle-upside-down-menu
-       :style toggle :selected ps-print-upside-down
-       :included (pr-visible-p 'postscript-options)]
-      ("Print All Pages" :included (pr-visible-p 'postscript-options)
-       ,@(funcall
-         pr-:help "Select odd/even pages/sheets to print")
-       ["All Pages"   (pr-even-or-odd-pages nil)
-       :style radio :selected (eq ps-even-or-odd-pages nil)]
-       ["Even Pages"  (pr-even-or-odd-pages 'even-page)
-       :style radio :selected (eq ps-even-or-odd-pages 'even-page)]
-       ["Odd Pages"   (pr-even-or-odd-pages 'odd-page)
-       :style radio :selected (eq ps-even-or-odd-pages 'odd-page)]
-       ["Even Sheets" (pr-even-or-odd-pages 'even-sheet)
-       :style radio :selected (eq ps-even-or-odd-pages 'even-sheet)]
-       ["Odd Sheets"  (pr-even-or-odd-pages 'odd-sheet)
-       :style radio :selected (eq ps-even-or-odd-pages 'odd-sheet)])
+      ["Landscape" pr-toggle-file-landscape-menu
+       :style toggle :selected pr-file-landscape
+       :help "Toggle landscape for PostScript file"
+       :active pr-ps-utility-alist]
+      ["Duplex"    pr-toggle-file-duplex-menu
+       :style toggle :selected pr-file-duplex
+       :help "Toggle duplex for PostScript file"
+       :active pr-ps-utility-alist]
+      ["Tumble"    pr-toggle-file-tumble-menu
+       :style toggle :selected pr-file-tumble
+       :help "Toggle tumble for PostScript file"
+       :active (and pr-file-duplex pr-ps-utility-alist)])
+     ["Despool..." (call-interactively 'pr-despool-preview)
+      :active pr-spool-p :keys "\\[pr-despool-preview]"
+      :help "Despool PostScript buffer to printer or file (C-u)"])
+    ("PostScript Print" :included (pr-visible-p 'postscript)
+     :help "Send PostScript to printer or file (C-u)"
+     ("Directory"
+      ["1-up"     (pr-ps-directory-ps-print 1   nil nil t) t]
+      ["2-up"     (pr-ps-directory-ps-print 2   nil nil t) t]
+      ["4-up"     (pr-ps-directory-ps-print 4   nil nil t) t]
+      ["Other..." (pr-ps-directory-ps-print nil nil nil t)
+       :keys "\\[pr-ps-buffer-ps-print]"])
+     ("Buffer"
+      ["1-up"     (pr-ps-buffer-ps-print 1   t) t]
+      ["2-up"     (pr-ps-buffer-ps-print 2   t) t]
+      ["4-up"     (pr-ps-buffer-ps-print 4   t) t]
+      ["Other..." (pr-ps-buffer-ps-print nil t)
+       :keys "\\[pr-ps-buffer-ps-print]"])
+     ("Region" :active (ps-mark-active-p)
+      ["1-up"     (pr-ps-region-ps-print 1   t) t]
+      ["2-up"     (pr-ps-region-ps-print 2   t) t]
+      ["4-up"     (pr-ps-region-ps-print 4   t) t]
+      ["Other..." (pr-ps-region-ps-print nil t)
+       :keys "\\[pr-ps-region-ps-print]"])
+     ("Mode" :active (pr-mode-alist-p)
+      ["1-up"     (pr-ps-mode-ps-print 1   t) t]
+      ["2-up"     (pr-ps-mode-ps-print 2   t) t]
+      ["4-up"     (pr-ps-mode-ps-print 4   t) t]
+      ["Other..." (pr-ps-mode-ps-print nil t)
+       :keys "\\[pr-ps-mode-ps-print]"])
+     ("File"
+      ["No Preprocessing..." (call-interactively 'pr-ps-file-ps-print)
+       :keys "\\[pr-ps-file-ps-print]"
+       :help "Send PostScript file to printer"]
       "--"
-      ["Spool Buffer"            pr-toggle-spool-menu
-       :style toggle :selected pr-spool-p
-       :included (pr-visible-p 'postscript-process)
-       ,@(funcall
-         pr-:help "Toggle PostScript spooling")]
-      ["Print with faces"        pr-toggle-faces-menu
-       :style toggle :selected pr-faces-p
-       :included (pr-visible-p 'postscript-process)
-       ,@(funcall
-         pr-:help "Toggle PostScript printing with faces")]
-      ["Print via Ghostscript" pr-toggle-ghostscript-menu
-       :style toggle :selected pr-print-using-ghostscript
-       :included (pr-visible-p 'postscript-process)
-       ,@(funcall
-         pr-:help "Toggle PostScript generation using ghostscript")]
+      ["PostScript Utility" pr-update-menus :active pr-ps-utility-alist
+       :help "Select PostScript utility"]
       "--"
-      ["Auto Region" pr-toggle-region-menu
-       :style toggle :selected pr-auto-region
-       :included (pr-visible-p 'printing)]
-      ["Auto Mode"   pr-toggle-mode-menu
-       :style toggle :selected pr-auto-mode
-       :included (pr-visible-p 'printing)]
-      ["Menu Lock"   pr-toggle-lock-menu
-       :style toggle :selected pr-menu-lock
-       :included (pr-visible-p 'printing)]
+      ["1-up..."   (pr-ps-file-up-ps-print 1   t t) pr-ps-utility-alist]
+      ["2-up..."   (pr-ps-file-up-ps-print 2   t t) pr-ps-utility-alist]
+      ["4-up..."   (pr-ps-file-up-ps-print 4   t t) pr-ps-utility-alist]
+      ["Other..."  (pr-ps-file-up-ps-print nil t t)
+       :keys "\\[pr-ps-file-up-ps-print]" :active pr-ps-utility-alist]
       "--"
-      ("Customize" :included (pr-visible-p 'help)
-       ["printing" pr-customize       t]
-       ["ps-print" ps-print-customize t]
-       ["lpr"      lpr-customize      t])
-      ("Show Settings" :included (pr-visible-p 'help)
-       ["printing" pr-show-pr-setup  t]
-       ["ps-print" pr-show-ps-setup  t]
-       ["lpr"      pr-show-lpr-setup t])
-      ["Help" pr-help :active t :included (pr-visible-p 'help)]
-      )))
+      ["Landscape" pr-toggle-file-landscape-menu
+       :style toggle :selected pr-file-landscape
+       :help "Toggle landscape for PostScript file"
+       :active pr-ps-utility-alist]
+      ["Duplex"    pr-toggle-file-duplex-menu
+       :style toggle :selected pr-file-duplex
+       :help "Toggle duplex for PostScript file"
+       :active pr-ps-utility-alist]
+      ["Tumble"    pr-toggle-file-tumble-menu
+       :style toggle :selected pr-file-tumble
+       :help "Toggle tumble for PostScript file"
+       :active (and pr-file-duplex pr-ps-utility-alist)])
+     ["Despool..." (call-interactively 'pr-despool-ps-print)
+      :active pr-spool-p :keys "\\[pr-despool-ps-print]"
+      :help "Despool PostScript buffer to printer or file (C-u)"])
+    ["PostScript Printers" pr-update-menus
+     :active pr-ps-printer-alist :included (pr-visible-p 'postscript)
+     :help "Select PostScript printer"]
+    "--"
+    ("Printify" :included (pr-visible-p 'text)
+     :help
+     "Replace non-printing chars with printable representations."
+     ["Directory" pr-printify-directory t]
+     ["Buffer"    pr-printify-buffer    t]
+     ["Region"    pr-printify-region    (ps-mark-active-p)])
+    ("Print" :included (pr-visible-p 'text)
+     :help "Send text to printer"
+     ["Directory" pr-txt-directory t]
+     ["Buffer"    pr-txt-buffer    t]
+     ["Region"    pr-txt-region    (ps-mark-active-p)]
+     ["Mode"      pr-txt-mode      (pr-mode-alist-p)])
+    ["Text Printers" pr-update-menus
+     :active pr-txt-printer-alist :included (pr-visible-p 'text)
+     :help "Select text printer"]
+    "--"
+    ["Landscape"               pr-toggle-landscape-menu
+     :style toggle :selected ps-landscape-mode
+     :included (pr-visible-p 'postscript-options)]
+    ["Print Header"            pr-toggle-header-menu
+     :style toggle :selected ps-print-header
+     :included (pr-visible-p 'postscript-options)]
+    ["Print Header Frame"      pr-toggle-header-frame-menu
+     :style toggle :selected ps-print-header-frame :active ps-print-header
+     :included (pr-visible-p 'postscript-options)]
+    ["Line Number"             pr-toggle-line-menu
+     :style toggle :selected ps-line-number
+     :included (pr-visible-p 'postscript-options)]
+    ["Zebra Stripes"           pr-toggle-zebra-menu
+     :style toggle :selected ps-zebra-stripes
+     :included (pr-visible-p 'postscript-options)]
+    ["Duplex"                  pr-toggle-duplex-menu
+     :style toggle :selected ps-spool-duplex
+     :included (pr-visible-p 'postscript-options)]
+    ["Tumble"                  pr-toggle-tumble-menu
+     :style toggle :selected ps-spool-tumble :active ps-spool-duplex
+     :included (pr-visible-p 'postscript-options)]
+    ["Upside-Down"             pr-toggle-upside-down-menu
+     :style toggle :selected ps-print-upside-down
+     :included (pr-visible-p 'postscript-options)]
+    ("Print All Pages" :included (pr-visible-p 'postscript-options)
+     :help "Select odd/even pages/sheets to print"
+     ["All Pages"   (pr-even-or-odd-pages nil)
+      :style radio :selected (eq ps-even-or-odd-pages nil)]
+     ["Even Pages"  (pr-even-or-odd-pages 'even-page)
+      :style radio :selected (eq ps-even-or-odd-pages 'even-page)]
+     ["Odd Pages"   (pr-even-or-odd-pages 'odd-page)
+      :style radio :selected (eq ps-even-or-odd-pages 'odd-page)]
+     ["Even Sheets" (pr-even-or-odd-pages 'even-sheet)
+      :style radio :selected (eq ps-even-or-odd-pages 'even-sheet)]
+     ["Odd Sheets"  (pr-even-or-odd-pages 'odd-sheet)
+      :style radio :selected (eq ps-even-or-odd-pages 'odd-sheet)])
+    "--"
+    ["Spool Buffer"            pr-toggle-spool-menu
+     :style toggle :selected pr-spool-p
+     :included (pr-visible-p 'postscript-process)
+     :help "Toggle PostScript spooling"]
+    ["Print with faces"        pr-toggle-faces-menu
+     :style toggle :selected pr-faces-p
+     :included (pr-visible-p 'postscript-process)
+     :help "Toggle PostScript printing with faces"]
+    ["Print via Ghostscript" pr-toggle-ghostscript-menu
+     :style toggle :selected pr-print-using-ghostscript
+     :included (pr-visible-p 'postscript-process)
+     :help "Toggle PostScript generation using ghostscript"]
+    "--"
+    ["Auto Region" pr-toggle-region-menu
+     :style toggle :selected pr-auto-region
+     :included (pr-visible-p 'printing)]
+    ["Auto Mode"   pr-toggle-mode-menu
+     :style toggle :selected pr-auto-mode
+     :included (pr-visible-p 'printing)]
+    ["Menu Lock"   pr-toggle-lock-menu
+     :style toggle :selected pr-menu-lock
+     :included (pr-visible-p 'printing)]
+    "--"
+    ("Customize" :included (pr-visible-p 'help)
+     ["printing" pr-customize       t]
+     ["ps-print" ps-print-customize t]
+     ["lpr"      lpr-customize      t])
+    ("Show Settings" :included (pr-visible-p 'help)
+     ["printing" pr-show-pr-setup  t]
+     ["ps-print" pr-show-ps-setup  t]
+     ["lpr"      pr-show-lpr-setup t])
+    ["Help" pr-help :active t :included (pr-visible-p 'help)]
+    ))
 
 
 (defun pr-menu-bind ()
@@ -3453,19 +3000,17 @@ Calls `pr-update-menus' to adjust menus."
 
 
 ;; Key binding
-(let ((pr-print-key (if (featurep 'xemacs)
-                       'f22            ; XEmacs
-                     'print)))         ; GNU Emacs
-  (global-set-key `[,pr-print-key]                'pr-ps-fast-fire)
-  ;; Well, M-print and S-print are used because in my keyboard S-print works
-  ;; and M-print doesn't.  But M-print can work in other keyboard.
-  (global-set-key `[(meta ,pr-print-key)]         
'pr-ps-mode-using-ghostscript)
-  (global-set-key `[(shift ,pr-print-key)]        
'pr-ps-mode-using-ghostscript)
-  ;; Well, C-print and C-M-print are used because in my keyboard C-M-print 
works
-  ;; and C-print doesn't.  But C-print can work in other keyboard.
-  (global-set-key `[(control ,pr-print-key)]      'pr-txt-fast-fire)
-  (global-set-key `[(control meta ,pr-print-key)] 'pr-txt-fast-fire))
-
+;; FIXME: These should be moved to a function so that just loading the file
+;; doesn't affect the global keymap!
+(global-set-key [print]                'pr-ps-fast-fire)
+;; Well, M-print and S-print are used because on my keyboard S-print works
+;; and M-print doesn't.  But M-print can work on other keyboards.
+(global-set-key [(meta print)]         'pr-ps-mode-using-ghostscript)
+(global-set-key [(shift print)]        'pr-ps-mode-using-ghostscript)
+;; Well, C-print and C-M-print are used because in my keyboard C-M-print works
+;; and C-print doesn't.  But C-print can work in other keyboard.
+(global-set-key [(control print)]      'pr-txt-fast-fire)
+(global-set-key [(control meta print)] 'pr-txt-fast-fire)
 
 ;;; You can also use something like:
 ;;;(global-set-key "\C-ci"  'pr-interface)
@@ -3962,13 +3507,16 @@ file name.
 
 See also documentation for `pr-list-directory'."
   (interactive (pr-interactive-ps-dir-args (pr-prompt "PS preview dir")))
-  (pr-set-ps-dir-args 'n-up 'dir 'file-regexp 'filename
-                     (pr-prompt "PS preview dir"))
-  (setq filename (pr-ps-file filename))
-  (pr-ps-file-list n-up dir file-regexp filename)
-  (or pr-spool-p
-      (pr-ps-file-preview filename)))
-
+  (defvar pr--n-up) (defvar pr--dir) (defvar pr--file-regexp)
+  (defvar pr--filename)
+  (let ((pr--n-up n-up) (pr--dir dir) (pr--file-regexp file-regexp)
+        (pr--filename filename))
+    (pr-set-ps-dir-args 'pr--n-up 'pr--dir 'pr--file-regexp 'pr--filename
+                        (pr-prompt "PS preview dir"))
+    (setq pr--filename (pr-ps-file pr--filename))
+    (pr-ps-file-list pr--n-up pr--dir pr--file-regexp pr--filename)
+    (or pr-spool-p
+        (pr-ps-file-preview pr--filename))))
 
 ;;;###autoload
 (defun pr-ps-directory-using-ghostscript (n-up dir file-regexp &optional 
filename)
@@ -3988,12 +3536,16 @@ file name.
 
 See also documentation for `pr-list-directory'."
   (interactive (pr-interactive-ps-dir-args (pr-prompt "PS print dir GS")))
-  (pr-set-ps-dir-args 'n-up 'dir 'file-regexp 'filename
-                     (pr-prompt "PS print dir GS"))
-  (let ((file (pr-ps-file filename)))
-    (pr-ps-file-list n-up dir file-regexp file)
-    (pr-ps-file-using-ghostscript file)
-    (or filename (pr-delete-file file))))
+  (defvar pr--n-up) (defvar pr--dir) (defvar pr--file-regexp)
+  (defvar pr--filename)
+  (let ((pr--n-up n-up) (pr--dir dir) (pr--file-regexp file-regexp)
+        (pr--filename filename))
+    (pr-set-ps-dir-args 'pr--n-up 'pr--dir 'pr--file-regexp 'pr--filename
+                        (pr-prompt "PS print dir GS"))
+    (let ((file (pr-ps-file pr--filename)))
+      (pr-ps-file-list pr--n-up pr--dir pr--file-regexp file)
+      (pr-ps-file-using-ghostscript file)
+      (or pr--filename (pr-delete-file file)))))
 
 
 ;;;###autoload
@@ -4014,12 +3566,16 @@ file name.
 
 See also documentation for `pr-list-directory'."
   (interactive (pr-interactive-ps-dir-args (pr-prompt "PS print dir")))
-  (pr-set-ps-dir-args 'n-up 'dir 'file-regexp 'filename
-                     (pr-prompt "PS print dir"))
-  (let ((file (pr-ps-file filename)))
-    (pr-ps-file-list n-up dir file-regexp file)
-    (pr-ps-file-print file)
-    (or filename (pr-delete-file file))))
+  (defvar pr--n-up) (defvar pr--dir) (defvar pr--file-regexp)
+  (defvar pr--filename)
+  (let ((pr--n-up n-up) (pr--dir dir) (pr--file-regexp file-regexp)
+        (pr--filename filename))
+    (pr-set-ps-dir-args 'pr--n-up 'pr--dir 'pr--file-regexp 'pr--filename
+                        (pr-prompt "PS print dir"))
+    (let ((file (pr-ps-file pr--filename)))
+      (pr-ps-file-list pr--n-up pr--dir pr--file-regexp file)
+      (pr-ps-file-print file)
+      (or pr--filename (pr-delete-file file)))))
 
 
 ;;;###autoload
@@ -4043,11 +3599,16 @@ file name.
 See also documentation for `pr-list-directory'."
   (interactive (pr-interactive-ps-dir-args
                (pr-prompt (pr-prompt-gs "PS print dir"))))
-  (pr-set-ps-dir-args 'n-up 'dir 'file-regexp 'filename
-                     (pr-prompt (pr-prompt-gs "PS print dir")))
-  (if (pr-using-ghostscript-p)
-      (pr-ps-directory-using-ghostscript n-up dir file-regexp filename)
-    (pr-ps-directory-print n-up dir file-regexp filename)))
+  (defvar pr--n-up) (defvar pr--dir) (defvar pr--file-regexp)
+  (defvar pr--filename)
+  (let ((pr--n-up n-up) (pr--dir dir) (pr--file-regexp file-regexp)
+        (pr--filename filename))
+    (pr-set-ps-dir-args 'pr--n-up 'pr--dir 'pr--file-regexp 'pr--filename
+                        (pr-prompt (pr-prompt-gs "PS print dir")))
+    (funcall (if (pr-using-ghostscript-p)
+                 #'pr-ps-directory-using-ghostscript
+               #'pr-ps-directory-print)
+             pr--n-up pr--dir pr--file-regexp pr--filename)))
 
 
 ;;;###autoload
@@ -4191,11 +3752,13 @@ See also `pr-ps-buffer-ps-print'."
 
 See also `pr-ps-buffer-preview'."
   (interactive (pr-interactive-n-up-file "PS preview mode"))
-  (pr-set-n-up-and-filename 'n-up 'filename "PS preview mode")
-  (let ((file (pr-ps-file filename)))
-    (and (pr-ps-mode n-up file)
-        (not pr-spool-p)
-        (pr-ps-file-preview file))))
+  (defvar pr--n-up) (defvar pr--filename)
+  (let ((pr--n-up n-up) (pr--filename filename))
+    (pr-set-n-up-and-filename 'pr--n-up 'pr--filename "PS preview mode")
+    (let ((file (pr-ps-file pr--filename)))
+      (and (pr-ps-mode pr--n-up file)
+           (not pr-spool-p)
+           (pr-ps-file-preview file)))))
 
 
 ;;;###autoload
@@ -4204,12 +3767,14 @@ See also `pr-ps-buffer-preview'."
 
 See also `pr-ps-buffer-using-ghostscript'."
   (interactive (pr-interactive-n-up-file "PS print GS mode"))
-  (pr-set-n-up-and-filename 'n-up 'filename "PS print GS mode")
-  (let ((file (pr-ps-file filename)))
-    (when (and (pr-ps-mode n-up file)
-              (not pr-spool-p))
-      (pr-ps-file-using-ghostscript file)
-      (or filename (pr-delete-file file)))))
+  (defvar pr--n-up) (defvar pr--filename)
+  (let ((pr--n-up n-up) (pr--filename filename))
+    (pr-set-n-up-and-filename 'pr--n-up 'pr--filename "PS print GS mode")
+    (let ((file (pr-ps-file pr--filename)))
+      (when (and (pr-ps-mode pr--n-up file)
+                 (not pr-spool-p))
+        (pr-ps-file-using-ghostscript file)
+        (or pr--filename (pr-delete-file file))))))
 
 
 ;;;###autoload
@@ -4218,8 +3783,10 @@ See also `pr-ps-buffer-using-ghostscript'."
 
 See also `pr-ps-buffer-print'."
   (interactive (pr-interactive-n-up-file "PS print mode"))
-  (pr-set-n-up-and-filename 'n-up 'filename "PS print mode")
-  (pr-ps-mode n-up filename))
+  (defvar pr--n-up) (defvar pr--filename)
+  (let ((pr--n-up n-up) (pr--filename filename))
+    (pr-set-n-up-and-filename 'pr--n-up 'pr--filename "PS print mode")
+    (pr-ps-mode pr--n-up pr--filename)))
 
 
 ;;;###autoload
@@ -4247,8 +3814,10 @@ prompts for FILE(name)-REGEXP.
 
 See also documentation for `pr-list-directory'."
   (interactive (pr-interactive-dir-args "Printify dir"))
-  (pr-set-dir-args 'dir 'file-regexp "Printify dir")
-  (pr-file-list dir file-regexp 'pr-printify-buffer))
+  (defvar pr--dir) (defvar pr--file-regexp)
+  (let ((pr--dir dir) (pr--file-regexp file-regexp))
+    (pr-set-dir-args 'pr--dir 'pr--file-regexp "Printify dir")
+    (pr-file-list pr--dir pr--file-regexp 'pr-printify-buffer)))
 
 
 ;;;###autoload
@@ -4283,8 +3852,10 @@ prompts for FILE(name)-REGEXP.
 
 See also documentation for `pr-list-directory'."
   (interactive (pr-interactive-dir-args "Print dir"))
-  (pr-set-dir-args 'dir 'file-regexp "Print dir")
-  (pr-file-list dir file-regexp 'pr-txt-buffer))
+  (defvar pr--dir) (defvar pr--file-regexp)
+  (let ((pr--dir dir) (pr--file-regexp file-regexp))
+    (pr-set-dir-args 'pr--dir 'pr--file-regexp "Print dir")
+    (pr-file-list pr--dir pr--file-regexp 'pr-txt-buffer)))
 
 
 ;;;###autoload
@@ -4406,10 +3977,12 @@ image in a file with that name."
 (defun pr-ps-file-up-preview (n-up ifilename &optional ofilename)
   "Preview PostScript file FILENAME."
   (interactive (pr-interactive-n-up-inout "PS preview"))
-  (let ((outfile (pr-ps-utility-args 'n-up 'ifilename 'ofilename
-                                    "PS preview ")))
-    (pr-ps-utility-process n-up ifilename outfile)
-    (pr-ps-file-preview outfile)))
+  (defvar pr--n-up) (defvar pr--ifilename) (defvar pr--ofilename)
+  (let ((pr--n-up n-up) (pr--ifilename ifilename) (pr--ofilename ofilename))
+    (let ((outfile (pr-ps-utility-args 'pr--n-up 'pr--ifilename 'pr--ofilename
+                                       "PS preview ")))
+      (pr-ps-utility-process pr--n-up pr--ifilename outfile)
+      (pr-ps-file-preview outfile))))
 
 
 ;;;###autoload
@@ -4417,15 +3990,18 @@ image in a file with that name."
   "Print PostScript file FILENAME using ghostscript."
   (interactive (list (pr-ps-infile-preprint "Print preview ")))
   (and (stringp filename) (file-exists-p filename)
-       (let* ((file (pr-expand-file-name filename))
-             (tempfile (pr-dosify-file-name (make-temp-file file))))
+       (let* ((file (expand-file-name filename))
+             (tempfile (make-temp-file file)))
         ;; gs use
         (pr-call-process pr-gs-command
                          (format "-sDEVICE=%s" pr-gs-device)
                          (format "-r%d" pr-gs-resolution)
                          (pr-switches-string pr-gs-switches "pr-gs-switches")
-                         (format "-sOutputFile=\"%s\"" tempfile)
-                         file
+                         (format "-sOutputFile=\"%s\""
+                                  ;; FIXME: Do we need to dosify here really?
+                                  (pr-dosify-file-name tempfile))
+                          ;; FIXME: Do we need to dosify here really?
+                         (pr-dosify-file-name file)
                          "-c quit")
         ;; printing
         (pr-ps-file-print tempfile)
@@ -4439,7 +4015,7 @@ image in a file with that name."
   (interactive (list (pr-ps-infile-preprint "Print ")))
   (and (stringp filename) (file-exists-p filename)
        ;; printing
-       (let ((file (pr-expand-file-name filename)))
+       (let ((file (expand-file-name filename)))
         (if (string= pr-ps-command "")
             ;; default action
             (let ((ps-spool-buffer (get-buffer-create ps-spool-buffer-name)))
@@ -4448,16 +4024,16 @@ image in a file with that name."
                 (insert-file-contents-literally file))
               (pr-despool-print))
           ;; use `pr-ps-command' to print
-          (apply 'pr-call-process
+          (apply #'pr-call-process
                  pr-ps-command
                  (pr-switches-string pr-ps-switches "pr-ps-switches")
                  (if (string-match "cp" pr-ps-command)
                      ;; for "cp" (cmd in out)
-                     (list file
+                     (list (pr-dosify-file-name file)
                            (concat pr-ps-printer-switch pr-ps-printer))
                    ;; else, for others (cmd out in)
                    (list (concat pr-ps-printer-switch pr-ps-printer)
-                         file)))))))
+                         (pr-dosify-file-name file))))))))
 
 
 ;;;###autoload
@@ -4492,14 +4068,16 @@ file name."
                (if pr-print-using-ghostscript
                    "PS print GS"
                  "PS print")))
-  (let ((outfile (pr-ps-utility-args 'n-up 'ifilename 'ofilename
-                                    (if pr-print-using-ghostscript
-                                        "PS print GS "
-                                      "PS print "))))
-    (pr-ps-utility-process n-up ifilename outfile)
-    (unless ofilename
-      (pr-ps-file-ps-print outfile)
-      (pr-delete-file outfile))))
+  (defvar pr--n-up) (defvar pr--ifilename) (defvar pr--ofilename)
+  (let ((pr--n-up n-up) (pr--ifilename ifilename) (pr--ofilename ofilename))
+    (let ((outfile (pr-ps-utility-args 'pr--n-up 'pr--ifilename 'pr--ofilename
+                                       (if pr-print-using-ghostscript
+                                           "PS print GS "
+                                         "PS print "))))
+      (pr-ps-utility-process pr--n-up pr--ifilename outfile)
+      (unless pr--ofilename
+        (pr-ps-file-ps-print outfile)
+        (pr-delete-file outfile)))))
 
 
 ;;;###autoload
@@ -5210,9 +4788,9 @@ If menu binding was not done, calls `pr-menu-bind'."
             (let ((sym (car elt)))
               (vector
                (symbol-name sym)
-               (list fun (list 'quote sym) nil (list 'quote entry) index)
+               `(,fun ',sym nil ',entry ',index)
                :style 'radio
-               :selected (list 'eq var-sym (list 'quote sym)))))
+               :selected `(eq ,var-sym ',sym))))
         alist)))
 
 
@@ -5224,7 +4802,7 @@ If menu binding was not done, calls `pr-menu-bind'."
         value))
     (setq pr-ps-utility value)
     (pr-eval-alist (nthcdr 9 item)))
-  (pr-update-mode-line))
+  (force-mode-line-update))
 
 
 (defun pr-ps-set-printer (value)
@@ -5234,7 +4812,7 @@ If menu binding was not done, calls `pr-menu-bind'."
         "Invalid PostScript printer name `%s' for variable `pr-ps-name'"
         value))
     (setq pr-ps-name           value
-         pr-ps-command        (pr-dosify-file-name (nth 0 ps))
+         pr-ps-command        (nth 0 ps)
          pr-ps-switches       (nth 1 ps)
          pr-ps-printer-switch (nth 2 ps)
          pr-ps-printer        (nth 3 ps))
@@ -5251,7 +4829,7 @@ If menu binding was not done, calls `pr-menu-bind'."
                    (t                 "-P")
                    )))
     (pr-eval-alist (nthcdr 4 ps)))
-  (pr-update-mode-line))
+  (force-mode-line-update))
 
 
 (defun pr-txt-set-printer (value)
@@ -5260,7 +4838,7 @@ If menu binding was not done, calls `pr-menu-bind'."
        (error "Invalid text printer name `%s' for variable `pr-txt-name'"
               value))
     (setq pr-txt-name     value
-         pr-txt-command  (pr-dosify-file-name (nth 0 txt))
+         pr-txt-command  (nth 0 txt)
          pr-txt-switches (nth 1 txt)
          pr-txt-printer  (nth 2 txt)))
   (or (stringp pr-txt-command)
@@ -5269,30 +4847,28 @@ If menu binding was not done, calls `pr-menu-bind'."
                  (lpr-lp-system      "lp")
                  (t                 "lpr")
                  )))
-  (pr-update-mode-line))
+  (force-mode-line-update))
 
 
 (defun pr-eval-alist (alist)
-  (mapcar #'(lambda (option)
-             (let ((var-sym (car option))
-                   (value   (cdr option)))
-               (if (eq var-sym 'inherits-from:)
-                   (pr-eval-setting-alist value 'global)
-                 (set var-sym (eval value)))))
-         alist))
+  (dolist (option alist)
+    (let ((var-sym (car option))
+          (value   (cdr option)))
+      (if (eq var-sym 'inherits-from:)
+          (pr-eval-setting-alist value 'global)
+        (set var-sym (eval value))))))
 
 
 (defun pr-eval-local-alist (alist)
   (let (local-list)
-    (mapc #'(lambda (option)
-             (let ((var-sym (car option))
-                   (value   (cdr option)))
-               (setq local-list
-                     (if (eq var-sym 'inherits-from:)
-                         (nconc (pr-eval-setting-alist value) local-list)
-                       (set (make-local-variable var-sym) (eval value))
-                       (cons var-sym local-list)))))
-         alist)
+    (dolist (option alist)
+      (let ((var-sym (car option))
+            (value   (cdr option)))
+        (setq local-list
+              (if (eq var-sym 'inherits-from:)
+                  (nconc (pr-eval-setting-alist value) local-list)
+                (set (make-local-variable var-sym) (eval value))
+                (cons var-sym local-list)))))
     local-list))
 
 
@@ -5338,7 +4914,7 @@ If menu binding was not done, calls `pr-menu-bind'."
 
 
 (defun pr-kill-local-variable (local-var-list)
-  (mapcar 'kill-local-variable local-var-list))
+  (mapcar #'kill-local-variable local-var-list))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -5526,10 +5102,6 @@ If menu binding was not done, calls `pr-menu-bind'."
        (delete-file file)))
 
 
-(defun pr-expand-file-name (filename)
-  (pr-dosify-file-name (expand-file-name filename)))
-
-
 (defun pr-ps-outfile-preprint (&optional mess)
   (let* ((prompt (format "%soutput PostScript file name: " (or mess "")))
         (res    (read-file-name prompt default-directory "" nil)))
@@ -5549,7 +5121,7 @@ If menu binding was not done, calls `pr-menu-bind'."
                 (format "File %s; PostScript file: " prompt)
                 (file-name-directory res) nil nil
                 (file-name-nondirectory res))))
-    (pr-expand-file-name res)))
+    (expand-file-name res)))
 
 
 (defun pr-ps-infile-preprint (&optional mess)
@@ -5569,7 +5141,7 @@ If menu binding was not done, calls `pr-menu-bind'."
                 (format "File %s; PostScript file: " prompt)
                 (file-name-directory res) nil nil
                 (file-name-nondirectory res))))
-    (pr-expand-file-name res)))
+    (expand-file-name res)))
 
 
 (defun pr-ps-utility-args (n-up-sym infile-sym outfile-sym prompt)
@@ -5582,13 +5154,10 @@ If menu binding was not done, calls `pr-menu-bind'."
        (set infile-sym (pr-ps-infile-preprint prompt)))
   (or (symbol-value infile-sym)
       (error "%s: input PostScript file name is missing" prompt))
-  (set infile-sym (pr-dosify-file-name (symbol-value infile-sym)))
   ;; output file
   (and (eq (symbol-value outfile-sym) t)
        (set outfile-sym (and current-prefix-arg
                             (pr-ps-outfile-preprint prompt))))
-  (and (symbol-value outfile-sym)
-       (set outfile-sym (pr-dosify-file-name (symbol-value outfile-sym))))
   (pr-ps-file (symbol-value outfile-sym)))
 
 
@@ -5608,9 +5177,9 @@ If menu binding was not done, calls `pr-menu-bind'."
                          (and pr-file-landscape (nth 4 item))
                          (and pr-file-duplex    (nth 5 item))
                          (and pr-file-tumble    (nth 6 item))
-                         (pr-expand-file-name infile)
+                         (pr-dosify-file-name (expand-file-name infile))
                          (nth 7 item)
-                         (pr-expand-file-name outfile)))))
+                         (pr-dosify-file-name (expand-file-name outfile))))))
 
 
 (defun pr-remove-nil-from-list (lst)
@@ -5640,7 +5209,7 @@ If menu binding was not done, calls `pr-menu-bind'."
     (with-file-modes pr-file-modes
       (setq status
            (condition-case data
-               (apply 'call-process cmd nil buffer nil args)
+               (apply #'call-process cmd nil buffer nil args)
              ((quit error)
               (error-message-string data)))))
     ;; *Printing Command Output* == show exit status
@@ -5666,47 +5235,53 @@ If menu binding was not done, calls `pr-menu-bind'."
   ;; If SWITCHES is nil, return nil.
   ;; Otherwise, return the list of string in a string.
   (and switches
-       (mapconcat 'identity (pr-switches switches mess) " ")))
+       (mapconcat #'identity (pr-switches switches mess) " ")))
 
 
 (defun pr-switches (switches mess)
   (or (listp switches)
       (error "%S should have a list of strings" mess))
-  (lpr-flatten-list                    ; dynamic evaluation
+  (flatten-tree                        ; dynamic evaluation
    (mapcar #'lpr-eval-switch switches)))
 
 
 (defun pr-ps-preview (kind n-up filename mess)
-  (pr-set-n-up-and-filename 'n-up 'filename mess)
-  (let ((file (pr-ps-file filename)))
-    (pr-text2ps kind n-up file)
-    (or pr-spool-p (pr-ps-file-preview file))))
+  (defvar pr--n-up) (defvar pr--filename)
+  (let ((pr--n-up n-up) (pr--filename filename))
+    (pr-set-n-up-and-filename 'pr--n-up 'pr--filename mess)
+    (let ((file (pr-ps-file pr--filename)))
+      (pr-text2ps kind pr--n-up file)
+      (or pr-spool-p (pr-ps-file-preview file)))))
 
 
 (defun pr-ps-using-ghostscript (kind n-up filename mess)
-  (pr-set-n-up-and-filename 'n-up 'filename mess)
-  (let ((file (pr-ps-file filename)))
-    (pr-text2ps kind n-up file)
-    (unless (or pr-spool-p filename)
-      (pr-ps-file-using-ghostscript file)
-      (pr-delete-file file))))
+  (defvar pr--n-up) (defvar pr--filename)
+  (let ((pr--n-up n-up) (pr--filename filename))
+    (pr-set-n-up-and-filename 'pr--n-up 'pr--filename mess)
+    (let ((file (pr-ps-file pr--filename)))
+      (pr-text2ps kind pr--n-up file)
+      (unless (or pr-spool-p pr--filename)
+        (pr-ps-file-using-ghostscript file)
+        (pr-delete-file file)))))
 
 
 (defun pr-ps-print (kind n-up filename mess)
-  (pr-set-n-up-and-filename 'n-up 'filename mess)
-  (let ((file (pr-ps-file filename)))
-    (pr-text2ps kind n-up file)
-    (unless (or pr-spool-p filename)
-      (pr-ps-file-print file)
-      (pr-delete-file file))))
+  (defvar pr--n-up) (defvar pr--filename)
+  (let ((pr--n-up n-up) (pr--filename filename))
+    (pr-set-n-up-and-filename 'pr--n-up 'pr--filename mess)
+    (let ((file (pr-ps-file pr--filename)))
+      (pr-text2ps kind pr--n-up file)
+      (unless (or pr-spool-p pr--filename)
+        (pr-ps-file-print file)
+        (pr-delete-file file)))))
 
 
 (defun pr-ps-file (&optional filename)
-  (pr-dosify-file-name (or filename
-                          (make-temp-file
-                           (convert-standard-filename
-                            (expand-file-name pr-ps-temp-file pr-temp-dir))
-                           nil ".ps"))))
+  (or filename
+      (make-temp-file
+       (convert-standard-filename
+        (expand-file-name pr-ps-temp-file pr-temp-dir))
+       nil ".ps")))
 
 
 (defun pr-interactive-n-up (mess)
@@ -5714,7 +5289,7 @@ If menu binding was not done, calls `pr-menu-bind'."
   (save-match-data
     (let* ((fmt-prompt "%s[%s] N-up printing (default 1): ")
           (prompt "")
-          (str (pr-read-string (format fmt-prompt prompt mess) "1" nil "1"))
+          (str (read-string (format fmt-prompt prompt mess) nil nil "1"))
           int)
       (while (if (string-match "^\\s *[0-9]+$" str)
                 (setq int (string-to-number str)
@@ -5724,7 +5299,7 @@ If menu binding was not done, calls `pr-menu-bind'."
               (setq prompt "Invalid integer syntax; "))
        (ding)
        (setq str
-             (pr-read-string (format fmt-prompt prompt mess) str nil "1")))
+             (read-string (format fmt-prompt prompt mess) str nil "1")))
       int)))
 
 
@@ -5749,7 +5324,7 @@ If menu binding was not done, calls `pr-menu-bind'."
 
 
 (defun pr-interactive-regexp (mess)
-  (pr-read-string (format "[%s] File regexp to print: " mess) "" nil ""))
+  (read-string (format "[%s] File regexp to print: " mess) nil nil ""))
 
 
 (defun pr-interactive-dir-args (mess)
@@ -5796,9 +5371,7 @@ If menu binding was not done, calls `pr-menu-bind'."
   (and (not pr-spool-p)
        (eq (symbol-value filename-sym) t)
        (set filename-sym (and current-prefix-arg
-                             (ps-print-preprint current-prefix-arg))))
-  (and (symbol-value filename-sym)
-       (set filename-sym (pr-dosify-file-name (symbol-value filename-sym)))))
+                             (ps-print-preprint current-prefix-arg)))))
 
 
 (defun pr-set-n-up-and-filename (n-up-sym filename-sym mess)
@@ -5875,7 +5448,7 @@ If menu binding was not done, calls `pr-menu-bind'."
 
 
 (defun pr-ps-file-list (n-up dir file-regexp filename)
-  (pr-delete-file-if-exists (setq filename (pr-expand-file-name filename)))
+  (pr-delete-file-if-exists (setq filename (expand-file-name filename)))
   (let ((pr-spool-p t))
     (pr-file-list dir file-regexp
                  #'(lambda ()
@@ -5941,15 +5514,14 @@ If Emacs is running on Windows 95/98/NT/2000, tries to 
find COMMAND,
 COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
   (if (string= command "")
       command
-    (pr-dosify-file-name
-     (or (pr-find-command command)
-        (pr-path-command (cond (pr-cygwin-system  'cygwin)
-                               (lpr-windows-system 'windows)
-                               (t                 'unix))
-                         (file-name-nondirectory command)
-                         nil)
-        (error "Command not found: %s"
-               (file-name-nondirectory command))))))
+    (or (pr-find-command command)
+        (pr-path-command (cond (pr-cygwin-system  'cygwin)
+                               (lpr-windows-system 'windows)
+                               (t                 'unix))
+                         (file-name-nondirectory command)
+                         nil)
+        (error "Command not found: %s"
+               (file-name-nondirectory command)))))
 
 
 (defun pr-path-command (symbol command sym-list)
@@ -6004,12 +5576,6 @@ COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
 ;; Printing Interface (inspired by ps-print-interface.el)
 
 
-(eval-when-compile
-  (require 'cus-edit)
-  (require 'wid-edit)
-  (require 'widget))
-
-
 (defvar pr-i-window-configuration nil)
 
 (defvar pr-i-buffer     nil)
@@ -6027,20 +5593,13 @@ COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
 (defvar pr-i-ps-send    'printer)
 
 
-(defvar pr-interface-map nil
-  "Keymap for pr-interface.")
-
-(unless pr-interface-map
+(defvar pr-interface-map
   (let ((map (make-sparse-keymap)))
-    (cond ((featurep 'xemacs)          ; XEmacs
-          (pr-set-keymap-parents map (list widget-keymap))
-          (pr-set-keymap-name    map 'pr-interface-map))
-         (t                            ; GNU Emacs
-          (pr-set-keymap-parents map widget-keymap)))
+    (set-keymap-parent map widget-keymap)
     (define-key map "q" 'pr-interface-quit)
     (define-key map "?" 'pr-interface-help)
-    (setq pr-interface-map map)))
-
+    map)
+  "Keymap for pr-interface.")
 
 (defmacro pr-interface-save (&rest body)
   `(with-current-buffer pr-i-buffer
@@ -6111,15 +5670,13 @@ COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
                          (setq found  (string-match (car ignore) name)
                                ignore (cdr ignore)))
                        (or found
-                           (setq choices
-                                 (cons (list 'quote
-                                             (list 'choice-item
-                                                   :format "%[%t%]"
-                                                   name))
-                                       choices)))))
+                           (push (list 'choice-item
+                                        :format "%[%t%]"
+                                        name)
+                                  choices))))
                    (nreverse choices))
                  " Buffer : " nil
-                 '(progn
+                 (lambda ()
                     (pr-interface-save
                      (setq pr-i-region (ps-mark-active-p)
                            pr-i-mode   (pr-mode-alist-p)))
@@ -6345,11 +5902,10 @@ COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
   (pr-insert-italic "\n\nSelect Pages  :   " 2 14)
   (pr-insert-menu "Page Parity" 'ps-even-or-odd-pages
                  (mapcar #'(lambda (alist)
-                             (list 'quote
-                                   (list 'choice-item
-                                         :format "%[%t%]"
-                                         :tag (cdr alist)
-                                         :value (car alist))))
+                              (list 'choice-item
+                                    :format "%[%t%]"
+                                    :tag (cdr alist)
+                                    :value (car alist)))
                          pr-even-or-odd-alist)))
 
 
@@ -6605,8 +6161,8 @@ COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
 
 (defun pr-insert-toggle (var-sym label)
   (widget-create 'checkbox
-                :notify `(lambda (&rest _ignore)
-                           (setq ,var-sym (not ,var-sym)))
+                :notify (lambda (&rest _ignore)
+                          (set var-sym (not (symbol-value var-sym))))
                 (symbol-value var-sym))
   (widget-insert label))
 
@@ -6619,32 +6175,32 @@ COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
        (widget-insert separator)))
 
 
-(defun pr-insert-menu (tag var-sym choices &optional before after &rest body)
+(defun pr-insert-menu (tag var-sym choices &optional before after body)
   (and before (widget-insert before))
-  (eval `(widget-create 'menu-choice
-                       :tag ,tag
-                       :format "%v"
-                       :inline t
-                       :value ,var-sym
-                       :notify (lambda (widget &rest _ignore)
-                                 (setq ,var-sym (widget-value widget))
-                                 ,@body)
-                       :void '(choice-item :format "%[%t%]"
-                                           :tag "Can not display value!")
-                       ,@choices))
-    (and after (widget-insert after)))
+  (apply #'widget-create 'menu-choice
+         :tag tag
+         :format "%v"
+         :inline t
+         :value (symbol-value var-sym)
+         :notify (lambda (widget &rest _ignore)
+                   (set var-sym (widget-value widget))
+                   (when body (funcall body)))
+         :void '(choice-item :format "%[%t%]"
+                 :tag "Can not display value!")
+         choices)
+  (and after (widget-insert after)))
 
 
 (defun pr-insert-radio-button (var-sym sym)
   (widget-insert "\n")
   (let ((wid-list (get var-sym 'pr-widget-list))
-       (wid (eval `(widget-create
-                    'radio-button
-                    :format "  %[%v%]"
-                    :value (eq ,var-sym (quote ,sym))
-                    :notify (lambda (&rest _ignore)
-                              (setq ,var-sym (quote ,sym))
-                              (pr-update-radio-button (quote ,var-sym)))))))
+       (wid (widget-create
+              'radio-button
+              :format "  %[%v%]"
+              :value (eq (symbol-value var-sym) sym)
+              :notify (lambda (&rest _ignore)
+                        (set var-sym sym)
+                        (pr-update-radio-button var-sym)))))
     (put var-sym 'pr-widget-list (cons (cons wid sym) wid-list))))
 
 
@@ -6666,20 +6222,18 @@ COMMAND.exe, COMMAND.bat and COMMAND.com in this order."
 
 
 (defun pr-choice-alist (alist)
-  (let ((max (apply 'max (mapcar #'(lambda (alist)
-                                    (length (symbol-name (car alist))))
-                                alist))))
+  (let ((max (apply #'max (mapcar #'(lambda (alist)
+                                      (length (symbol-name (car alist))))
+                                  alist))))
     (mapcar #'(lambda (alist)
                (let* ((sym  (car alist))
                       (name (symbol-name sym)))
-                 (list
-                  'quote
-                  (list
-                   'choice-item
-                   :format "%[%t%]"
-                   :tag (concat name
-                                (make-string (- max (length name)) ?_))
-                   :value sym))))
+                  (list
+                   'choice-item
+                   :format "%[%t%]"
+                   :tag (concat name
+                                (make-string (- max (length name)) ?_))
+                   :value sym)))
            alist)))
 
 
diff --git a/lisp/proced.el b/lisp/proced.el
index 45ed273..ce379a7 100644
--- a/lisp/proced.el
+++ b/lisp/proced.el
@@ -1,6 +1,6 @@
 ;;; proced.el --- operate on system processes like dired
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Roland Winkler <address@hidden>
 ;; Keywords: Processes, Unix
@@ -1348,7 +1348,7 @@ Prefix ARG controls sort order, see 
`proced-sort-interactive'."
 
 (defun proced-format-time (time)
   "Format time interval TIME."
-  (let* ((ftime (float-time time))
+  (let* ((ftime (encode-time time 'integer))
          (days (truncate ftime 86400))
          (ftime (mod ftime 86400))
          (hours (truncate ftime 3600))
diff --git a/lisp/profiler.el b/lisp/profiler.el
index 41dea68..45dc1d1 100644
--- a/lisp/profiler.el
+++ b/lisp/profiler.el
@@ -1,6 +1,6 @@
 ;;; profiler.el --- UI and helper functions for Emacs's native profiler -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Tomohiro Matsuyama <address@hidden>
 ;; Keywords: lisp
diff --git a/lisp/progmodes/ada-mode.el b/lisp/progmodes/ada-mode.el
index fd6a2b0..e01f1e8 100644
--- a/lisp/progmodes/ada-mode.el
+++ b/lisp/progmodes/ada-mode.el
@@ -1,6 +1,6 @@
 ;;; ada-mode.el --- major-mode for editing Ada sources
 
-;; Copyright (C) 1994-1995, 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1995, 1997-2019 Free Software Foundation, Inc.
 
 ;; Author: Rolf Ebert      <address@hidden>
 ;;      Markus Heritsch <address@hidden>
@@ -767,7 +767,7 @@ the 4 file locations can be clicked on and jumped to."
   (interactive "d")
   (goto-char pos)
 
-  (skip-chars-backward "-a-zA-Z0-9_:./\\")
+  (skip-chars-backward "-a-zA-Z0-9_:./\\\\")
   (cond
    ;;  special case: looking at a filename:line not at the beginning of a line
    ;;  or a simple line reference "at line ..."
diff --git a/lisp/progmodes/ada-prj.el b/lisp/progmodes/ada-prj.el
index 91c8091..d9fa77c 100644
--- a/lisp/progmodes/ada-prj.el
+++ b/lisp/progmodes/ada-prj.el
@@ -1,6 +1,6 @@
 ;;; ada-prj.el --- GUI editing of project files for the ada-mode
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Emmanuel Briot <address@hidden>
 ;; Maintainer: Stephen Leake <address@hidden>
diff --git a/lisp/progmodes/ada-stmt.el b/lisp/progmodes/ada-stmt.el
index f1ed01e..ef42b0d 100644
--- a/lisp/progmodes/ada-stmt.el
+++ b/lisp/progmodes/ada-stmt.el
@@ -1,6 +1,6 @@
 ;;; ada-stmt.el --- an extension to Ada mode for inserting statement templates
 
-;; Copyright (C) 1987, 1993-1994, 1996-2018 Free Software Foundation,
+;; Copyright (C) 1987, 1993-1994, 1996-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Authors: Daniel Pfeiffer
diff --git a/lisp/progmodes/ada-xref.el b/lisp/progmodes/ada-xref.el
index 359c187..c9c923e 100644
--- a/lisp/progmodes/ada-xref.el
+++ b/lisp/progmodes/ada-xref.el
@@ -1,6 +1,6 @@
 ;; ada-xref.el --- for lookup and completion in Ada mode
 
-;; Copyright (C) 1994-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-2019 Free Software Foundation, Inc.
 
 ;; Author: Markus Heritsch <address@hidden>
 ;;      Rolf Ebert <address@hidden>
@@ -416,7 +416,7 @@ As a special case, ${current} is replaced with the name of 
the current
 file, minus extension but with directory, and ${full_current} is
 replaced by the name including the extension."
 
-  (while (string-match "\\(-[^-$IO]*[IO]\\)?${\\([^}]+\\)}" cmd-string)
+  (while (string-match "\\(-[^-$IO]*[IO]\\)?\\${\\([^}]+\\)}" cmd-string)
     (let (value
          (name (match-string 2 cmd-string)))
       (cond
@@ -1133,8 +1133,7 @@ If OTHER-FRAME is non-nil, display the cross-reference in 
another frame."
        (ada-find-in-ali identlist other-frame)
       ;; File not found: print explicit error message
       (ada-error-file-not-found
-       (message (concat (error-message-string err)
-                       (nthcdr 1 err))))
+       (message "%s%s" (error-message-string err) (nthcdr 1 err)))
 
       (error
        (let ((ali-file (ada-get-ali-file-name (ada-file-of identlist))))
diff --git a/lisp/progmodes/antlr-mode.el b/lisp/progmodes/antlr-mode.el
index 775fd87..40bef0b 100644
--- a/lisp/progmodes/antlr-mode.el
+++ b/lisp/progmodes/antlr-mode.el
@@ -1,6 +1,6 @@
 ;;; antlr-mode.el --- major mode for ANTLR grammar files
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Christoph Wedler <address@hidden>
 ;; Keywords: languages, ANTLR, code generator
diff --git a/lisp/progmodes/asm-mode.el b/lisp/progmodes/asm-mode.el
index fb16828..c56d16e 100644
--- a/lisp/progmodes/asm-mode.el
+++ b/lisp/progmodes/asm-mode.el
@@ -1,6 +1,6 @@
 ;;; asm-mode.el --- mode for editing assembler code
 
-;; Copyright (C) 1991, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1991, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric S. Raymond <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/progmodes/autoconf.el b/lisp/progmodes/autoconf.el
index c6e60a1..9d70aeb 100644
--- a/lisp/progmodes/autoconf.el
+++ b/lisp/progmodes/autoconf.el
@@ -1,6 +1,6 @@
 ;;; autoconf.el --- mode for editing Autoconf configure.ac files
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Love <address@hidden>
 ;; Keywords: languages
diff --git a/lisp/progmodes/bat-mode.el b/lisp/progmodes/bat-mode.el
index 51acc6a..a8b002b 100644
--- a/lisp/progmodes/bat-mode.el
+++ b/lisp/progmodes/bat-mode.el
@@ -1,6 +1,6 @@
 ;;; bat-mode.el --- Major mode for editing DOS/Windows scripts
 
-;; Copyright (C) 2003, 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Arni Magnusson <address@hidden>
 ;; Keywords: languages
@@ -78,7 +78,7 @@
              "goto" "gtr" "if" "in" "leq" "lss" "neq" "not" "start"))
           (UNIX
            '("bash" "cat" "cp" "fgrep" "grep" "ls" "sed" "sh" "mv" "rm")))
-      `(("\\_<\\(call\\|goto\\)\\_>[ \t]+%?\\([A-Za-z0-9-_\\:.]+\\)%?"
+      `(("\\_<\\(call\\|goto\\)\\_>[ \t]+%?\\([A-Za-z0-9_\\:.-]+\\)%?"
          (2 font-lock-constant-face t))
         ("^:[^:].*"
          . 'bat-label-face)
diff --git a/lisp/progmodes/bug-reference.el b/lisp/progmodes/bug-reference.el
index 75bd0ba..813ecbe 100644
--- a/lisp/progmodes/bug-reference.el
+++ b/lisp/progmodes/bug-reference.el
@@ -1,6 +1,6 @@
-;; bug-reference.el --- buttonize bug references
+;; bug-reference.el --- buttonize bug references  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Tom Tromey <address@hidden>
 ;; Created: 21 Mar 2007
@@ -69,7 +69,7 @@ so that it is considered safe, see `enable-local-variables'.")
                 (get s 'bug-reference-url-format)))))
 
 (defcustom bug-reference-bug-regexp
-  "\\([Bb]ug ?#?\\|[Pp]atch ?#\\|RFE ?#\\|PR 
[a-z-+]+/\\)\\([0-9]+\\(?:#[0-9]+\\)?\\)"
+  "\\([Bb]ug ?#?\\|[Pp]atch ?#\\|RFE ?#\\|PR 
[a-z+-]+/\\)\\([0-9]+\\(?:#[0-9]+\\)?\\)"
   "Regular expression matching bug references.
 The second subexpression should match the bug reference (usually a number)."
   :type 'string
@@ -91,7 +91,7 @@ The second subexpression should match the bug reference 
(usually a number)."
 (bug-reference-set-overlay-properties)
 
 (defun bug-reference-unfontify (start end)
-  "Remove bug reference overlays from region."
+  "Remove bug reference overlays from the region between START and END."
   (dolist (o (overlays-in start end))
     (when (eq (overlay-get o 'category) 'bug-reference)
       (delete-overlay o))))
@@ -99,7 +99,7 @@ The second subexpression should match the bug reference 
(usually a number)."
 (defvar bug-reference-prog-mode)
 
 (defun bug-reference-fontify (start end)
-  "Apply bug reference overlays to region."
+  "Apply bug reference overlays to the region between START and END."
   (save-excursion
     (let ((beg-line (progn (goto-char start) (line-beginning-position)))
          (end-line (progn (goto-char end) (line-end-position))))
diff --git a/lisp/progmodes/cc-align.el b/lisp/progmodes/cc-align.el
index 1b48a5a..009f58e 100644
--- a/lisp/progmodes/cc-align.el
+++ b/lisp/progmodes/cc-align.el
@@ -1,6 +1,6 @@
 ;;; cc-align.el --- custom indentation functions for CC Mode
 
-;; Copyright (C) 1985, 1987, 1992-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1992-2019 Free Software Foundation, Inc.
 
 ;; Authors:    2004- Alan Mackenzie
 ;;             1998- Martin Stjernholm
@@ -1083,6 +1083,130 @@ arglist-cont."
              (vector (+ (current-column) c-basic-offset))))
        (vector 0)))))
 
+(defun c-lineup-2nd-brace-entry-in-arglist (langelem)
+  "Lineup the second entry of a brace block under the first, when the first
+line is also contained in an arglist or an enclosing brace ON THAT LINE.
+
+I.e. handle something like the following:
+
+    set_line (line_t {point_t{0.4, 0.2},
+                      point_t{0.2, 0.5},       <---- brace-list-intro
+                      .....});
+             ^ enclosing parenthesis.
+
+The middle line of that example will have a syntactic context
+with three syntactic symbols, arglist-cont-nonempty, brace-list-intro, and
+brace-list-entry.
+
+This function is intended for use in a list.  If the construct
+being analyzed isn't like the preceding, the function returns nil.
+Otherwise it returns the function `c-lineup-arglist-intro-after-paren', which
+the caller then uses to perform indentation.
+
+Works with brace-list-intro."
+  ;; brace-list-intro and brace-list-entry are both present for the second
+  ;; entry of the list when the first entry is on the same line as the opening
+  ;; brace.
+  (and (assq 'brace-list-intro c-syntactic-context)
+       (assq 'brace-list-entry c-syntactic-context)
+       (or (assq 'arglist-cont-nonempty c-syntactic-context) ; "(" earlier on
+                                                            ; the line.
+          (save-excursion              ; "{" earlier on the line
+            (goto-char (c-langelem-pos
+                        (assq 'brace-list-intro c-syntactic-context)))
+            (and
+             (eq (c-backward-token-2
+                  1 nil
+                  (c-point 'bol (c-langelem-pos
+                                 (assq 'brace-list-entry
+                                       c-syntactic-context))))
+                 0)
+             (eq (char-after) ?{))))
+       'c-lineup-arglist-intro-after-paren))
+
+(defun c-lineup-class-decl-init-+ (langelem)
+  "Line up the second entry of a class (etc.) initializer c-basic-offset
+characters in from the identifier when:
+\(i) The type is a class, struct, union, etc. (but not an enum);
+\(ii) There is a brace block in the type declaration, specifying it; and
+\(iii) The first element of the initializer is on the same line as its opening
+brace.
+
+I.e. we have a construct like this:
+
+    struct STR {
+        int i; float f;
+    } str_1 = {1, 1.7},
+        str_2 = {2,
+             3.1                   <---- brace-list-intro
+        };
+        <-->                       <---- c-basic-offset
+
+Note that the syntactic context of the brace-list-intro line also has a
+syntactic element with the symbol brace-list-entry.
+
+This function is intended for use in a list.  If the above structure isn't
+present, this function returns nil, allowing a different offset specification
+to indent the line.
+
+Works with: brace-list-intro."
+  (and (assq 'brace-list-intro c-syntactic-context)
+       (assq 'brace-list-entry c-syntactic-context)
+       (let ((init-pos (c-point 'boi (c-langelem-pos
+                                     (assq 'brace-list-entry
+                                           c-syntactic-context))))
+            )
+        (save-excursion
+          (goto-char (c-langelem-pos (assq 'brace-list-intro
+                                           c-syntactic-context)))
+          (and
+           (c-forward-class-decl)
+           (not (c-do-declarators init-pos t nil nil nil))
+           (eq (point) init-pos)
+           (vector (+ (current-column) c-basic-offset)))))))
+
+(defun c-lineup-class-decl-init-after-brace (langelem)
+  "Line up the second entry of a class (etc.) initializer after its opening
+brace when:
+\(i) The type is a class, struct, union, etc. (but not an enum);
+\(ii) There is a brace block in the type declaration, specifying it; and
+\(iii) The first element of the initializer is on the same line as its opening
+brace.
+
+I.e. we have a construct like this:
+
+    struct STR {
+        int i; float f;
+    } str_1 = {1, 1.7},
+        str_2 = {2,
+                 3.1                   <---- brace-list-intro
+        };
+
+Note that the syntactic context of the brace-list-intro line also has a
+syntactic element with the symbol brace-list-entry.  Also note that this
+function works by returning the symbol `c-lineup-arglist-intro-after-paren',
+which the caller then uses to perform the indentation.
+
+This function is intended for use in a list.  If the above structure isn't
+present, this function returns nil, allowing a different offset specification
+to indent the line.
+
+Works with: brace-list-intro."
+  (and (assq 'brace-list-intro c-syntactic-context)
+       (assq 'brace-list-entry c-syntactic-context)
+       (let ((init-pos (c-point 'boi (c-langelem-pos
+                                     (assq 'brace-list-entry
+                                           c-syntactic-context))))
+            )
+        (save-excursion
+          (goto-char (c-langelem-pos (assq 'brace-list-intro
+                                           c-syntactic-context)))
+          (and
+           (c-forward-class-decl)
+           (not (c-do-declarators init-pos t nil nil nil))
+           (eq (point) init-pos)
+           'c-lineup-arglist-intro-after-paren)))))
+
 (defun c-lineup-cpp-define (_langelem)
   "Line up macro continuation lines according to the indentation of
 the construct preceding the macro.  E.g.:
diff --git a/lisp/progmodes/cc-awk.el b/lisp/progmodes/cc-awk.el
index 4c04b59..1a67a95 100644
--- a/lisp/progmodes/cc-awk.el
+++ b/lisp/progmodes/cc-awk.el
@@ -1,6 +1,6 @@
 ;;; cc-awk.el --- AWK specific code within cc-mode.
 
-;; Copyright (C) 1988, 1994, 1996, 2000-2018 Free Software Foundation,
+;; Copyright (C) 1988, 1994, 1996, 2000-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Alan Mackenzie <address@hidden> (originally based on awk-mode.el)
@@ -95,7 +95,7 @@
 ;; Emacs has in the past used \r to mark hidden lines in some fashion (and
 ;; maybe still does).
 
-(defconst c-awk-esc-pair-re "\\\\\\(.\\|\n\\|\r\\|\\'\\)")
+(defconst c-awk-esc-pair-re "\\\\\\(.\\|\n\\|\\'\\)")
 ;;   Matches any escaped (with \) character-pair, including an escaped newline.
 (defconst c-awk-non-eol-esc-pair-re "\\\\\\(.\\|\\'\\)")
 ;;   Matches any escaped (with \) character-pair, apart from an escaped 
newline.
@@ -130,7 +130,7 @@
 ;; REGEXPS FOR "HARMLESS" STRINGS/LINES.
 (defconst c-awk-harmless-_ "_\\([^\"]\\|\\'\\)")
 ;;   Matches an underline NOT followed by ".
-(defconst c-awk-harmless-char-re "[^_#/\"{}();\\\\\n\r]")
+(defconst c-awk-harmless-char-re "[^_#/\"{}();\\\n\r]")
 ;;   Matches any character not significant in the state machine applying
 ;; syntax-table properties to "s and /s.
 (defconst c-awk-harmless-string*-re
@@ -141,7 +141,7 @@
   (concat "\\=" c-awk-harmless-string*-re))
 ;; Matches the (possibly empty) sequence of "insignificant" chars at point.
 
-(defconst c-awk-harmless-line-char-re "[^_#/\"\\\\\n\r]")
+(defconst c-awk-harmless-line-char-re "[^_#/\"\\\n\r]")
 ;;   Matches any character but a _, #, /, ", \, or newline.  N.B. _" starts a
 ;; localization string in gawk 3.1
 (defconst c-awk-harmless-line-string*-re
@@ -188,8 +188,8 @@
   "\\[:[a-z]+:\\]")
   ;; Matches a character class spec (e.g. [:alpha:]).
 (defconst c-awk-regexp-char-list-re
-  (concat "\\[" c-awk-escaped-newlines*-re "^?" c-awk-escaped-newlines*-re "]?"
-          "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-class-re
+  (concat "\\[\\(" c-awk-escaped-newlines*-re "\\^\\)?" 
c-awk-escaped-newlines*-re "]?"
+         "\\(" c-awk-esc-pair-re "\\|" c-awk-regexp-char-class-re
          "\\|" "[^]\n\r]" "\\)*" "\\(]\\|$\\)"))
 ;;   Matches a regexp char list, up to (but not including) EOL if the ] is
 ;;   missing.
@@ -250,7 +250,7 @@
 ;; which can precede an expression.
 
 ;; REGEXPS USED FOR FINDING THE POSITION OF A "virtual semicolon"
-(defconst c-awk-_-harmless-nonws-char-re "[^#/\"\\\\\n\r \t]")
+(defconst c-awk-_-harmless-nonws-char-re "[^#/\"\\\n\r \t]")
 (defconst c-awk-non-/-syn-ws*-re
   (concat
    "\\(" c-awk-escaped-nls*-with-space*
diff --git a/lisp/progmodes/cc-bytecomp.el b/lisp/progmodes/cc-bytecomp.el
index 754edf9..0cbff57 100644
--- a/lisp/progmodes/cc-bytecomp.el
+++ b/lisp/progmodes/cc-bytecomp.el
@@ -1,6 +1,6 @@
 ;;; cc-bytecomp.el --- compile time setup for proper compilation
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author:     Martin Stjernholm
 ;; Maintainer: address@hidden
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el
index 0269c01..efc6747 100644
--- a/lisp/progmodes/cc-cmds.el
+++ b/lisp/progmodes/cc-cmds.el
@@ -1,6 +1,6 @@
 ;;; cc-cmds.el --- user level commands for CC Mode
 
-;; Copyright (C) 1985, 1987, 1992-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1992-2019 Free Software Foundation, Inc.
 
 ;; Authors:    2003- Alan Mackenzie
 ;;             1998- Martin Stjernholm
@@ -47,6 +47,7 @@
 ;; Silence the compiler.
 (cc-bytecomp-defvar filladapt-mode)    ; c-fill-paragraph contains a kludge
                                        ; which looks at this.
+(cc-bytecomp-defun electric-pair-post-self-insert-function)
 
 ;; Indentation / Display syntax functions
 (defvar c-fix-backslashes t)
@@ -503,7 +504,8 @@ inside a literal or a macro, nothing special happens."
                          (eq (char-before) ?\\))))
            (c-in-literal)))
       ;; do nothing special
-      (self-insert-command (prefix-numeric-value arg))
+      (let (post-self-insert-hook)     ; Disable random functionality.
+       (self-insert-command (prefix-numeric-value arg)))
     ;; place the pound character at the left edge
     (let ((pos (- (point-max) (point)))
          (bolp (bolp)))
@@ -694,6 +696,134 @@ inside a literal or a macro, nothing special happens."
                            t))))
          (goto-char (- (point-max) pos))))))
 
+(defun c-do-brace-electrics (before after)
+  ;; Point is just after a brace.  Indent the various lines, add any required
+  ;; auto newlines, and apply pertinent clean ups.  It is assumed that the
+  ;; caller has checked that point is at EOL if need be, and that the brace is
+  ;; not in a comment or string, and suchlike.
+  ;;
+  ;; BEFORE and AFTER qualify the newlines required before and after the
+  ;; brace as follows:
+  ;; If
+  ;;  o - nil: insert a newline or not according to `c-hanging-braces-alist'.
+  ;;  o - 'ignore: don't insert a newline.
+  ;;  o - 'assume: insert a newline.
+  ;;
+  ;; The return value has no significance.
+  (let (;; shut this up too
+       (c-echo-syntactic-information-p nil)
+       newlines
+       ln-syntax br-syntax syntax)  ; Syntactic context of the original line,
+                                       ; of the brace itself, of the line the
+                                       ; brace ends up on.
+    (c-save-buffer-state ((c-syntactic-indentation-in-macros t)
+                         (c-auto-newline-analysis t))
+      (setq ln-syntax (c-guess-basic-syntax)))
+    (if c-syntactic-indentation
+       (c-indent-line ln-syntax))
+
+    (when c-auto-newline
+      (backward-char)
+      (setq br-syntax (c-point-syntax)
+           newlines (c-brace-newlines br-syntax))
+
+      ;; Insert the BEFORE newline, if wanted, and reindent the newline.
+      (if (or (and (null before) (memq 'before newlines)
+                  (> (current-column) (current-indentation)))
+             (eq before 'assume))
+         (if c-syntactic-indentation
+             ;; Only a plain newline for now - it's indented
+             ;; after the cleanups when the line has its final
+             ;; appearance.
+             (newline)
+           (c-newline-and-indent)))
+      (forward-char)
+
+      ;; `syntax' is the syntactic context of the line which ends up
+      ;; with the brace on it.
+      (setq syntax (if (memq 'before newlines) br-syntax ln-syntax))
+
+      ;; Do all appropriate clean ups
+      (let ((here (point))
+           (pos (- (point-max) (point)))
+           mbeg mend
+           )
+
+       ;; `}': clean up empty defun braces
+       (when (c-save-buffer-state ()
+               (and (memq 'empty-defun-braces c-cleanup-list)
+                    (eq (c-last-command-char) ?\})
+                    (c-intersect-lists '(defun-close class-close inline-close)
+                                       syntax)
+                    (progn
+                      (forward-char -1)
+                      (c-skip-ws-backward)
+                      (eq (char-before) ?\{))
+                    ;; make sure matching open brace isn't in a comment
+                    (not (c-in-literal))))
+         (delete-region (point) (1- here))
+         (setq here (- (point-max) pos)))
+       (goto-char here)
+
+       ;; `}': compact to a one-liner defun?
+       (save-match-data
+         (when
+             (and (eq (c-last-command-char) ?\})
+                  (memq 'one-liner-defun c-cleanup-list)
+                  (c-intersect-lists '(defun-close) syntax)
+                  (c-try-one-liner))
+           (setq here (- (point-max) pos))))
+
+       ;; `{': clean up brace-else-brace and brace-elseif-brace
+       (when (eq (c-last-command-char) ?\{)
+         (cond
+          ((and (memq 'brace-else-brace c-cleanup-list)
+                (re-search-backward
+                 (concat "}"
+                         "\\([ \t\n]\\|\\\\\n\\)*"
+                         "else"
+                         "\\([ \t\n]\\|\\\\\n\\)*"
+                         "{"
+                         "\\=")
+                 nil t))
+           (delete-region (match-beginning 0) (match-end 0))
+           (insert-and-inherit "} else {"))
+          ((and (memq 'brace-elseif-brace c-cleanup-list)
+                (progn
+                  (goto-char (1- here))
+                  (setq mend (point))
+                  (c-skip-ws-backward)
+                  (setq mbeg (point))
+                  (eq (char-before) ?\)))
+                (zerop (c-save-buffer-state nil (c-backward-token-2 1 t)))
+                (eq (char-after) ?\()
+                (re-search-backward
+                 (concat "}"
+                         "\\([ \t\n]\\|\\\\\n\\)*"
+                         "else"
+                         "\\([ \t\n]\\|\\\\\n\\)+"
+                         "if"
+                         "\\([ \t\n]\\|\\\\\n\\)*"
+                         "\\=")
+                 nil t))
+           (delete-region mbeg mend)
+           (goto-char mbeg)
+           (insert ?\ ))))
+
+       (goto-char (- (point-max) pos))
+
+       ;; Indent the line after the cleanups since it might
+       ;; very well indent differently due to them, e.g. if
+       ;; c-indent-one-line-block is used together with the
+       ;; one-liner-defun cleanup.
+       (when c-syntactic-indentation
+         (c-indent-line)))
+
+      ;; does a newline go after the brace?
+      (if (or (and (null after) (memq 'after newlines))
+             (eq after 'assume))
+         (c-newline-and-indent)))))
+
 (defun c-electric-brace (arg)
   "Insert a brace.
 
@@ -716,7 +846,10 @@ settings of `c-cleanup-list' are done."
        ;; We want to inhibit blinking the paren since this would be
        ;; most disruptive.  We'll blink it ourselves later on.
        (old-blink-paren blink-paren-function)
-       blink-paren-function case-fold-search)
+       blink-paren-function case-fold-search
+       (at-eol (looking-at "[ \t]*\\\\?$"))
+       (active-region (and (fboundp 'use-region-p) (use-region-p)))
+       got-pair-} electric-pair-deletion)
 
     (c-save-buffer-state ()
       (setq safepos (c-safe-position (point) (c-parse-state))
@@ -724,128 +857,36 @@ settings of `c-cleanup-list' are done."
 
     ;; Insert the brace.  Note that expand-abbrev might reindent
     ;; the line here if there's a preceding "else" or something.
-    (self-insert-command (prefix-numeric-value arg))
-
-    (when (and c-electric-flag (not literal) (not arg))
-      (if (not (looking-at "[ \t]*\\\\?$"))
-         (if c-syntactic-indentation
-             (indent-according-to-mode))
-
-       (let ( ;; shut this up too
-             (c-echo-syntactic-information-p nil)
-             newlines
-             ln-syntax br-syntax syntax) ; Syntactic context of the original 
line,
-                       ; of the brace itself, of the line the brace ends up on.
-         (c-save-buffer-state ((c-syntactic-indentation-in-macros t)
-                               (c-auto-newline-analysis t))
-           (setq ln-syntax (c-guess-basic-syntax)))
-         (if c-syntactic-indentation
-             (c-indent-line ln-syntax))
-
-         (when c-auto-newline
-           (backward-char)
-           (setq br-syntax (c-point-syntax)
-                 newlines (c-brace-newlines br-syntax))
-
-           ;; Insert the BEFORE newline, if wanted, and reindent the newline.
-           (if (and (memq 'before newlines)
-                    (> (current-column) (current-indentation)))
-               (if c-syntactic-indentation
-                   ;; Only a plain newline for now - it's indented
-                   ;; after the cleanups when the line has its final
-                   ;; appearance.
-                   (newline)
-                 (c-newline-and-indent)))
+    (let (post-self-insert-hook) ; the only way to get defined functionality
+                                ; from `self-insert-command'.
+      (self-insert-command (prefix-numeric-value arg)))
+
+    ;; Emulate `electric-pair-mode'.
+    (when (and (boundp 'electric-pair-mode)
+              electric-pair-mode)
+      (let ((size (buffer-size))
+           (c-in-electric-pair-functionality t)
+           post-self-insert-hook)
+       (electric-pair-post-self-insert-function)
+       (setq got-pair-} (and at-eol
+                             (eq (c-last-command-char) ?{)
+                             (eq (char-after) ?}))
+             electric-pair-deletion (< (buffer-size) size))))
+
+    ;; Perform any required CC Mode electric actions.
+    (cond
+     ((or literal arg (not c-electric-flag) active-region))
+     ((not at-eol)
+      (c-indent-line))
+     (electric-pair-deletion
+      (c-indent-line)
+      (c-do-brace-electrics 'ignore nil))
+     (t (c-do-brace-electrics nil nil)
+       (when got-pair-}
+         (save-excursion
            (forward-char)
-
-           ;; `syntax' is the syntactic context of the line which ends up
-           ;; with the brace on it.
-           (setq syntax (if (memq 'before newlines) br-syntax ln-syntax))
-
-           ;; Do all appropriate clean ups
-           (let ((here (point))
-                 (pos (- (point-max) (point)))
-                 mbeg mend
-                 )
-
-             ;; `}': clean up empty defun braces
-             (when (c-save-buffer-state ()
-                     (and (memq 'empty-defun-braces c-cleanup-list)
-                          (eq (c-last-command-char) ?\})
-                          (c-intersect-lists '(defun-close class-close 
inline-close)
-                                             syntax)
-                          (progn
-                            (forward-char -1)
-                            (c-skip-ws-backward)
-                            (eq (char-before) ?\{))
-                          ;; make sure matching open brace isn't in a comment
-                          (not (c-in-literal))))
-               (delete-region (point) (1- here))
-               (setq here (- (point-max) pos)))
-             (goto-char here)
-
-             ;; `}': compact to a one-liner defun?
-             (save-match-data
-               (when
-                   (and (eq (c-last-command-char) ?\})
-                        (memq 'one-liner-defun c-cleanup-list)
-                        (c-intersect-lists '(defun-close) syntax)
-                        (c-try-one-liner))
-                 (setq here (- (point-max) pos))))
-
-             ;; `{': clean up brace-else-brace and brace-elseif-brace
-             (when (eq (c-last-command-char) ?\{)
-               (cond
-                ((and (memq 'brace-else-brace c-cleanup-list)
-                      (re-search-backward
-                       (concat "}"
-                               "\\([ \t\n]\\|\\\\\n\\)*"
-                               "else"
-                               "\\([ \t\n]\\|\\\\\n\\)*"
-                               "{"
-                               "\\=")
-                       nil t))
-                 (delete-region (match-beginning 0) (match-end 0))
-                 (insert-and-inherit "} else {"))
-                ((and (memq 'brace-elseif-brace c-cleanup-list)
-                      (progn
-                        (goto-char (1- here))
-                        (setq mend (point))
-                        (c-skip-ws-backward)
-                        (setq mbeg (point))
-                        (eq (char-before) ?\)))
-                      (zerop (c-save-buffer-state nil (c-backward-token-2 1 
t)))
-                      (eq (char-after) ?\()
-                     ; (progn
-                       ; (setq tmp (point))
-                        (re-search-backward
-                         (concat "}"
-                                 "\\([ \t\n]\\|\\\\\n\\)*"
-                                 "else"
-                                 "\\([ \t\n]\\|\\\\\n\\)+"
-                                 "if"
-                                 "\\([ \t\n]\\|\\\\\n\\)*"
-                                 "\\=")
-                         nil t);)
-                      ;(eq (match-end 0) tmp);
-                        )
-                 (delete-region mbeg mend)
-                 (goto-char mbeg)
-                 (insert ?\ ))))
-
-             (goto-char (- (point-max) pos))
-
-             ;; Indent the line after the cleanups since it might
-             ;; very well indent differently due to them, e.g. if
-             ;; c-indent-one-line-block is used together with the
-             ;; one-liner-defun cleanup.
-             (when c-syntactic-indentation
-               (c-indent-line)))
-
-           ;; does a newline go after the brace?
-           (if (memq 'after newlines)
-               (c-newline-and-indent))
-           ))))
+           (c-do-brace-electrics 'assume 'ignore))
+         (c-indent-line))))
 
     ;; blink the paren
     (and (eq (c-last-command-char) ?\})
@@ -903,7 +944,8 @@ is inhibited."
                       c-electric-flag
                       (eq (c-last-command-char) ?/)
                       (eq (char-before) (if literal ?* ?/))))
-    (self-insert-command (prefix-numeric-value arg))
+    (let (post-self-insert-hook)       ; Disable random functionality.
+      (self-insert-command (prefix-numeric-value arg)))
     (if indentp
        (indent-according-to-mode))))
 
@@ -916,7 +958,8 @@ supplied, point is inside a literal, or 
`c-syntactic-indentation' is nil,
 this indentation is inhibited."
 
   (interactive "*P")
-  (self-insert-command (prefix-numeric-value arg))
+  (let (post-self-insert-hook)         ; Disable random functionality.
+    (self-insert-command (prefix-numeric-value arg)))
   ;; if we are in a literal, or if arg is given do not reindent the
   ;; current line, unless this star introduces a comment-only line.
   (if (c-save-buffer-state ()
@@ -963,7 +1006,8 @@ settings of `c-cleanup-list'."
       (setq lim (c-most-enclosing-brace (c-parse-state))
            literal (c-in-literal lim)))
 
-    (self-insert-command (prefix-numeric-value arg))
+    (let (post-self-insert-hook)       ; Disable random functionality.
+      (self-insert-command (prefix-numeric-value arg)))
 
     (if (and c-electric-flag (not literal) (not arg))
        ;; do all cleanups and newline insertions if c-auto-newline is on.
@@ -1032,7 +1076,8 @@ reindented unless `c-syntactic-indentation' is nil.
         newlines is-scope-op
         ;; shut this up
         (c-echo-syntactic-information-p nil))
-    (self-insert-command (prefix-numeric-value arg))
+    (let (post-self-insert-hook)       ; Disable random functionality.
+      (self-insert-command (prefix-numeric-value arg)))
     ;; Any electric action?
     (if (and c-electric-flag (not literal) (not arg))
        ;; Unless we're at EOL, only re-indentation happens.
@@ -1122,49 +1167,76 @@ finishes a C++ style stream operator in C++ mode.  
Exceptions are when a
 numeric argument is supplied, or the point is inside a literal."
 
   (interactive "*P")
-  (let ((c-echo-syntactic-information-p nil)
+  (let ((literal (c-save-buffer-state () (c-in-literal)))
+       template-delim include-delim
+       (c-echo-syntactic-information-p nil)
        final-pos found-delim case-fold-search)
 
-    (self-insert-command (prefix-numeric-value arg))
+    (let (post-self-insert-hook)       ; Disable random functionality.
+      (self-insert-command (prefix-numeric-value arg)))
     (setq final-pos (point))
 
 ;;;; 2010-01-31: There used to be code here to put a syntax-table text
 ;;;; property on the new < or > and its mate (if any) when they are template
 ;;;; parens.  This is now done in an after-change function.
 
-    ;; Indent the line if appropriate.
-    (when (and c-electric-flag c-syntactic-indentation c-recognize-<>-arglists)
-      (setq found-delim
-           (if (eq (c-last-command-char) ?<)
-               ;; If a <, basically see if it's got "template" before it .....
-               (or (and (progn
-                          (backward-char)
-                          (= (point)
-                             (progn (c-beginning-of-current-token) (point))))
-                        (progn
-                          (c-backward-token-2)
-                          (looking-at c-opt-<>-sexp-key)))
-                   ;; ..... or is a C++ << operator.
+    (when (and (not arg) (not literal))
+      ;; Have we got a delimiter on a #include directive?
+      (beginning-of-line)
+      (setq include-delim
+           (and
+            (looking-at c-cpp-include-key)
+            (if (eq (c-last-command-char) ?<)
+                (eq (match-end 0) (1- final-pos))
+              (goto-char (1- final-pos))
+              (skip-chars-backward "^<>" (c-point 'bol))
+              (eq (char-before) ?<))))
+      (goto-char final-pos)
+
+      ;; Indent the line if appropriate.
+      (when (and c-electric-flag c-syntactic-indentation 
c-recognize-<>-arglists)
+       (setq found-delim
+             (if (eq (c-last-command-char) ?<)
+                 ;; If a <, basically see if it's got "template" before it 
.....
+                 (or (and (progn
+                            (backward-char)
+                            (= (point)
+                               (progn (c-beginning-of-current-token) (point))))
+                          (progn
+                            (c-backward-token-2)
+                            (looking-at c-opt-<>-sexp-key))
+                          (setq template-delim t))
+                     ;; ..... or is a C++ << operator.
+                     (and (c-major-mode-is 'c++-mode)
+                          (progn
+                            (goto-char (1- final-pos))
+                            (c-beginning-of-current-token)
+                            (looking-at "<<"))
+                          (>= (match-end 0) final-pos)))
+
+               ;; It's a >.  Either a template/generic terminator ...
+               (or (and (c-get-char-property (1- final-pos) 'syntax-table)
+                        (setq template-delim t))
+                   ;; or a C++ >> operator.
                    (and (c-major-mode-is 'c++-mode)
                         (progn
                           (goto-char (1- final-pos))
                           (c-beginning-of-current-token)
-                          (looking-at "<<"))
-                        (>= (match-end 0) final-pos)))
+                          (looking-at ">>"))
+                        (>= (match-end 0) final-pos)))))
+       (goto-char final-pos)
 
-             ;; It's a >.  Either a template/generic terminator ...
-             (or (c-get-char-property (1- final-pos) 'syntax-table)
-                 ;; or a C++ >> operator.
-                 (and (c-major-mode-is 'c++-mode)
-                      (progn
-                        (goto-char (1- final-pos))
-                        (c-beginning-of-current-token)
-                        (looking-at ">>"))
-                      (>= (match-end 0) final-pos))))))
+       (when found-delim
+         (indent-according-to-mode)))
+
+      ;; On the off chance that < and > are configured as pairs in
+      ;; electric-pair-mode.
+      (when (and (boundp 'electric-pair-mode) electric-pair-mode
+                (or template-delim include-delim))
+       (let (post-self-insert-hook)
+         (electric-pair-post-self-insert-function))))
 
-    (goto-char final-pos)
     (when found-delim
-      (indent-according-to-mode)
       (when (and (eq (char-before) ?>)
                 (not executing-kbd-macro)
                 blink-paren-function)
@@ -1190,10 +1262,12 @@ newline cleanups are done if appropriate; see the 
variable `c-cleanup-list'."
        ;; shut this up
        (c-echo-syntactic-information-p nil)
        case-fold-search)
-    (self-insert-command (prefix-numeric-value arg))
+    (let (post-self-insert-hook) ; The only way to get defined functionality
+                                ; from `self-insert-command'.
+      (self-insert-command (prefix-numeric-value arg)))
 
     (if (and (not arg) (not literal))
-       (let* ( ;; We want to inhibit blinking the paren since this will
+       (let* (;; We want to inhibit blinking the paren since this will
               ;; be most disruptive.  We'll blink it ourselves
               ;; afterwards.
               (old-blink-paren blink-paren-function)
@@ -1239,6 +1313,12 @@ newline cleanups are done if appropriate; see the 
variable `c-cleanup-list'."
              (delete-region (match-beginning 0) (match-end 0))
              (insert-and-inherit "} catch (")))
 
+         ;; Apply `electric-pair-mode' stuff.
+         (when (and (boundp 'electric-pair-mode)
+                    electric-pair-mode)
+           (let (post-self-insert-hook)
+             (electric-pair-post-self-insert-function)))
+
          ;; Check for clean-ups at function calls.  These two DON'T need
          ;; `c-electric-flag' or `c-syntactic-indentation' set.
          ;; Point is currently just after the inserted paren.
@@ -1263,21 +1343,26 @@ newline cleanups are done if appropriate; see the 
variable `c-cleanup-list'."
                (insert ?\ )))
 
             ;; compact-empty-funcall clean-up?
-                 ((c-save-buffer-state ()
-                    (and (memq 'compact-empty-funcall c-cleanup-list)
-                         (eq (c-last-command-char) ?\))
-                         (save-excursion
-                           (c-safe (backward-char 2))
-                           (when (looking-at "()")
-                             (setq end (point))
-                             (skip-chars-backward " \t")
-                             (setq beg (point))
-                             (c-on-identifier)))))
-                  (delete-region beg end))))
+            ((c-save-buffer-state ()
+               (and (memq 'compact-empty-funcall c-cleanup-list)
+                    (eq (c-last-command-char) ?\))
+                    (save-excursion
+                      (c-safe (backward-char 2))
+                      (when (looking-at "()")
+                        (setq end (point))
+                        (skip-chars-backward " \t")
+                        (setq beg (point))
+                        (c-on-identifier)))))
+             (delete-region beg end))))
          (and (eq last-input-event ?\))
               (not executing-kbd-macro)
               old-blink-paren
-              (funcall old-blink-paren))))))
+              (funcall old-blink-paren)))
+
+      ;; Apply `electric-pair-mode' stuff inside a string or comment.
+      (when (and (boundp 'electric-pair-mode) electric-pair-mode)
+       (let (post-self-insert-hook)
+         (electric-pair-post-self-insert-function))))))
 
 (defun c-electric-continued-statement ()
   "Reindent the current line if appropriate.
@@ -3524,7 +3609,7 @@ Otherwise reindent just the current line."
                                    (save-excursion
                                      (goto-char end)
                                      (point-marker))
-                                   (nth 1 (current-time))
+                                   (encode-time nil 'integer)
                                    context))
       (message "Indenting region..."))
    ))
@@ -3532,7 +3617,7 @@ Otherwise reindent just the current line."
 (defun c-progress-update ()
   (if (not (and c-progress-info c-progress-interval))
       nil
-    (let ((now (nth 1 (current-time)))
+    (let ((now (encode-time nil 'integer))
          (start (aref c-progress-info 0))
          (end (aref c-progress-info 1))
          (lastsecs (aref c-progress-info 2)))
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el
index 83b27ef1..cd4ed6b 100644
--- a/lisp/progmodes/cc-defs.el
+++ b/lisp/progmodes/cc-defs.el
@@ -1,6 +1,6 @@
 ;;; cc-defs.el --- compile time definitions for CC Mode
 
-;; Copyright (C) 1985, 1987, 1992-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1992-2019 Free Software Foundation, Inc.
 
 ;; Authors:    2003- Alan Mackenzie
 ;;             1998- Martin Stjernholm
@@ -87,7 +87,7 @@
 
 ;;; Variables also used at compile time.
 
-(defconst c-version "5.33.1"
+(defconst c-version "5.33.2"
   "CC Mode version number.")
 
 (defconst c-version-sym (intern c-version))
@@ -212,6 +212,13 @@ This variant works around bugs in `eval-when-compile' in 
various
        `(cl-delete-duplicates ,cl-seq ,@cl-keys)
       `(delete-duplicates ,cl-seq ,@cl-keys))))
 
+(defmacro c-font-lock-flush (beg end)
+  "Declare the region BEG...END's fontification as out-of-date.
+On XEmacs and older Emacsen, this refontifies that region immediately."
+  (if (fboundp 'font-lock-flush)
+      `(font-lock-flush ,beg ,end)
+    `(font-lock-fontify-region ,beg ,end)))
+
 (defmacro c-point (position &optional point)
   "Return the value of certain commonly referenced POSITIONs relative to POINT.
 The current point is used if POINT isn't specified.  POSITION can be
@@ -258,10 +265,12 @@ to it is returned.  This function does not modify the 
point or the mark."
         ((eq position 'eoll)
          `(save-excursion
             ,@(if point `((goto-char ,point)))
-            (while (progn
-                     (end-of-line)
-                     (prog1 (eq (logand 1 (skip-chars-backward "\\\\")) 1)))
-              (beginning-of-line 2))
+            (while (and
+                    (not (eobp))
+                    (progn
+                      (end-of-line)
+                      (prog1 (eq (logand 1 (skip-chars-backward "\\\\")) 1))))
+              (forward-line))
             (end-of-line)
             (point)))
 
@@ -494,6 +503,31 @@ to it is returned.  This function does not modify the 
point or the mark."
     ;; Emacs <22 + XEmacs
     '(default-value 'sentence-end)))
 
+(defconst c-c++-raw-string-opener-re "R\"\\([^ ()\\\n\r\t]\\{0,16\\}\\)(")
+;; Matches a C++ raw string opener.  Submatch 1 is its identifier.
+
+(defconst c-c++-raw-string-opener-1-re "\"\\([^ ()\\\n\r\t]\\{0,16\\}\\)(")
+;; Matches a C++ raw string opener starting after the initial R.
+
+(defmacro c-sub-at-c++-raw-string-opener ()
+  `(save-excursion
+     (and
+      (if (eq (char-after) ?R)
+         (progn (forward-char) t)
+       (eq (char-before) ?R))
+      (looking-at c-c++-raw-string-opener-1-re))))
+
+(defmacro c-at-c++-raw-string-opener (&optional pos)
+  ;; Return non-nil if POS (default point) is either at the start of a C++ raw
+  ;; string opener, or after the introductory R of one.  The match data is
+  ;; overwritten.  On success the opener's identifier will be (match-string
+  ;; 1).  Text properties on any characters are ignored.
+  (if pos
+      `(save-excursion
+        (goto-char ,pos)
+        (c-sub-at-c++-raw-string-opener))
+    `(c-sub-at-c++-raw-string-opener)))
+
 ;; The following is essentially `save-buffer-state' from lazy-lock.el.
 ;; It ought to be a standard macro.
 (defmacro c-save-buffer-state (varlist &rest body)
@@ -1214,7 +1248,7 @@ Leave point just after the character, and set the match 
data on
 this character, and return point.  If the search fails, return
 nil; point is then left undefined."
   `(let ((char-skip (concat "^" (char-to-string ,char)))
-        (-limit- ,limit)
+        (-limit- (or ,limit (point-max)))
         (-value- ,value))
      (while
         (and
@@ -1226,15 +1260,39 @@ nil; point is then left undefined."
        (search-forward-regexp ".")     ; to set the match-data.
        (point))))
 
+(defmacro c-search-forward-char-property-without-value-on-char
+    (property value char &optional limit)
+  "Search forward for a character CHAR without text property PROPERTY having
+a value CHAR.
+LIMIT bounds the search.  The value comparison is done with `equal'.
+PROPERTY must be a constant.
+
+Leave point just after the character, and set the match data on
+this character, and return point.  If the search fails, return
+nil; point is then left undefined."
+  `(let ((char-skip (concat "^" (char-to-string ,char)))
+        (-limit- (or ,limit (point-max)))
+        (-value- ,value))
+     (while
+        (and
+         (progn (skip-chars-forward char-skip -limit-)
+                (< (point) -limit-))
+         (equal (c-get-char-property (point) ,property) -value-))
+       (forward-char))
+     (when (< (point) -limit-)
+       (search-forward-regexp ".")     ; to set the match-data.
+       (point))))
+
 (defun c-clear-char-property-with-value-on-char-function (from to property
                                                               value char)
   "Remove all text-properties PROPERTY with value VALUE on
 characters with value CHAR from the region [FROM, TO), as tested
 by `equal'.  These properties are assumed to be over individual
 characters, having been put there by c-put-char-property.  POINT
-remains unchanged."
+remains unchanged.  Return the position of the first removed
+property, or nil."
   (let ((place from)
-       )
+       first)
     (while                       ; loop round occurrences of (PROPERTY VALUE)
        (progn
          (while           ; loop round changes in PROPERTY till we find VALUE
@@ -1243,28 +1301,34 @@ remains unchanged."
               (not (equal (get-text-property place property) value)))
            (setq place (c-next-single-property-change place property nil to)))
          (< place to))
-      (if (eq (char-after place) char)
-         (remove-text-properties place (1+ place) (cons property nil)))
+      (when (eq (char-after place) char)
+       (remove-text-properties place (1+ place) (cons property nil))
+       (or first (setq first place)))
       ;; Do we have to do anything with stickiness here?
-      (setq place (1+ place)))))
+      (setq place (1+ place)))
+    first))
 
 (defmacro c-clear-char-property-with-value-on-char (from to property value 
char)
   "Remove all text-properties PROPERTY with value VALUE on
 characters with value CHAR from the region [FROM, TO), as tested
 by `equal'.  These properties are assumed to be over individual
 characters, having been put there by c-put-char-property.  POINT
-remains unchanged."
+remains unchanged.  Return the position of the first removed
+property, or nil."
   (if c-use-extents
       ;; XEmacs
       `(let ((-property- ,property)
-            (-char- ,char))
+            (-char- ,char)
+            (first (1+ (point-max))))
         (map-extents (lambda (ext val)
-                       (if (and (equal (extent-property ext -property-) val)
-                                (eq (char-after
-                                     (extent-start-position ext))
-                                    -char-))
-                           (delete-extent ext)))
-                     nil ,from ,to ,value nil -property-))
+                       (when (and (equal (extent-property ext -property-) val)
+                                  (eq (char-after
+                                       (extent-start-position ext))
+                                      -char-))
+                         (setq first (min first (extent-start-position ext)))
+                         (delete-extent ext)))
+                     nil ,from ,to ,value nil -property-)
+        (and (<= first (point-max)) first))
     ;; GNU Emacs
     `(c-clear-char-property-with-value-on-char-function ,from ,to ,property
                                                        ,value ,char)))
@@ -1316,6 +1380,7 @@ with value CHAR in the region [FROM to)."
 ;(eval-after-load "edebug" ; 2006-07-09: def-edebug-spec is now in subr.el.
 ;  '(progn
 (def-edebug-spec cc-eval-when-compile (&rest def-form))
+(def-edebug-spec c-font-lock-flush t)
 (def-edebug-spec c--mapcan t)
 (def-edebug-spec c--set-difference (form form &rest [symbolp form]))
 (def-edebug-spec c--intersection (form form &rest [symbolp form]))
@@ -1769,7 +1834,8 @@ when it's needed.  The default is the current language 
taken from
                                     t))
                         (setq pos (cdr pos)))
                       found))
-             (setq pos list)
+             (setq pos (copy-tree list)
+                   )
              (while pos
                (if (string-match "\\w\\'" (car pos))
                    (setcar pos (concat (car pos) unique)))
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 376d0bb..242954d 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -1,6 +1,6 @@
 ;;; cc-engine.el --- core syntax guessing engine for CC mode -*- coding: utf-8 
-*-
 
-;; Copyright (C) 1985, 1987, 1992-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1992-2019 Free Software Foundation, Inc.
 
 ;; Authors:    2001- Alan Mackenzie
 ;;             1998- Martin Stjernholm
@@ -152,7 +152,9 @@
 (cc-require-when-compile 'cc-langs)
 (cc-require 'cc-vars)
 
-(eval-when-compile (require 'cl))
+(defvar c-doc-line-join-re)
+(defvar c-doc-bright-comment-start-re)
+(defvar c-doc-line-join-end-ch)
 
 
 ;; Make declarations for all the `c-lang-defvar' variables in cc-langs.
@@ -665,10 +667,12 @@ comment at the start of cc-engine.el for more info."
             stack (cdr stack))
        t
      ,do-if-done
+     (setq pre-stmt-found t)
      (throw 'loop nil)))
 (defmacro c-bos-pop-state-and-retry ()
   '(throw 'loop (setq state (car (car stack))
                      saved-pos (cdr (car stack))
+                     pre-stmt-found (not (cdr stack))
                      ;; Throw nil if stack is empty, else throw non-nil.
                      stack (cdr stack))))
 (defmacro c-bos-save-pos ()
@@ -694,7 +698,7 @@ comment at the start of cc-engine.el for more info."
                             (c-point 'bol (elt saved-pos 0))))))))
 
 (defun c-beginning-of-statement-1 (&optional lim ignore-labels
-                                            noerror comma-delim)
+                                            noerror comma-delim hit-lim)
   "Move to the start of the current statement or declaration, or to
 the previous one if already at the beginning of one.  Only
 statements/declarations on the same level are considered, i.e. don't
@@ -729,14 +733,16 @@ Return:
 `up'            if stepped to a containing statement;
 `previous'      if stepped to a preceding statement;
 `beginning'     if stepped from a statement continuation clause to
-                its start clause; or
-`macro'         if stepped to a macro start.
+                its start clause;
+`macro'         if stepped to a macro start; or
+nil             if HIT-LIM is non-nil, and we hit the limit.
 Note that `same' and not `label' is returned if stopped at the same
 label without crossing the colon character.
 
 LIM may be given to limit the search.  If the search hits the limit,
 point will be left at the closest following token, or at the start
-position if that is less (`same' is returned in this case).
+position if that is less.  If HIT-LIM is non-nil, nil is returned in
+this case, otherwise `same'.
 
 NOERROR turns off error logging to `c-parsing-error'.
 
@@ -840,6 +846,10 @@ comment at the start of cc-engine.el for more info."
        pos
        ;; Position of last stmt boundary character (e.g. ;).
        boundary-pos
+       ;; Non-nil when a construct has been found which delimits the search
+       ;; for a statement start, e.g. an opening brace or a macro start, or a
+       ;; keyword like `if' when the PDA stack is empty.
+       pre-stmt-found
        ;; The position of the last sexp or bound that follows the
        ;; first found colon, i.e. the start of the nonlabel part of
        ;; the statement.  It's `start' if a colon is found just after
@@ -877,7 +887,10 @@ comment at the start of cc-engine.el for more info."
        tok ptok pptok)
 
     (save-restriction
-      (if lim (narrow-to-region lim (point-max)))
+      (setq lim (if lim
+                   (max lim (point-min))
+                 (point-min)))
+      (widen)
 
       (if (save-excursion
            (and (c-beginning-of-macro)
@@ -923,9 +936,10 @@ comment at the start of cc-engine.el for more info."
        ;; The loop is exited only by throwing nil to the (catch 'loop ...):
        ;; 1. On reaching the start of a macro;
        ;; 2. On having passed a stmt boundary with the PDA stack empty;
-       ;; 3. On reaching the start of an Objective C method def;
-       ;; 4. From macro `c-bos-pop-state'; when the stack is empty;
-       ;; 5. From macro `c-bos-pop-state-and-retry' when the stack is empty.
+       ;; 3. Going backwards past the search limit.
+       ;; 4. On reaching the start of an Objective C method def;
+       ;; 5. From macro `c-bos-pop-state'; when the stack is empty;
+       ;; 6. From macro `c-bos-pop-state-and-retry' when the stack is empty.
        (while
            (catch 'loop ;; Throw nil to break, non-nil to continue.
              (cond
@@ -950,6 +964,7 @@ comment at the start of cc-engine.el for more info."
                  (setq pos saved
                        ret 'macro
                        ignore-labels t))
+               (setq pre-stmt-found t)
                (throw 'loop nil))      ; 1. Start of macro.
 
               ;; Do a round through the automaton if we've just passed a
@@ -959,6 +974,7 @@ comment at the start of cc-engine.el for more info."
                         (setq sym (intern (match-string 1)))))
 
                (when (and (< pos start) (null stack))
+                 (setq pre-stmt-found t)
                  (throw 'loop nil))    ; 2. Statement boundary.
 
                ;; The PDA state handling.
@@ -1071,7 +1087,8 @@ comment at the start of cc-engine.el for more info."
              ;; Step to the previous sexp, but not if we crossed a
              ;; boundary, since that doesn't consume an sexp.
              (if (eq sym 'boundary)
-                 (setq ret 'previous)
+                 (when (>= (point) lim)
+                   (setq ret 'previous))
 
                 ;; HERE IS THE SINGLE PLACE INSIDE THE PDA LOOP WHERE WE MOVE
                ;; BACKWARDS THROUGH THE SOURCE.
@@ -1093,6 +1110,7 @@ comment at the start of cc-engine.el for more info."
                          ;; Give up if we hit an unbalanced block.  Since the
                          ;; stack won't be empty the code below will report a
                          ;; suitable error.
+                         (setq pre-stmt-found t)
                          (throw 'loop nil))
                        (cond
                         ;; Have we moved into a macro?
@@ -1162,12 +1180,17 @@ comment at the start of cc-engine.el for more info."
                    ;; Like a C "continue".  Analyze the next sexp.
                    (throw 'loop t))))
 
+             ;; Have we gone past the limit?
+             (when (< (point) lim)
+               (throw 'loop nil))      ; 3. Gone back over the limit.
+
              ;; ObjC method def?
              (when (and c-opt-method-key
                         (setq saved (c-in-method-def-p)))
                (setq pos saved
+                     pre-stmt-found t
                      ignore-labels t)  ; Avoid the label check on exit.
-               (throw 'loop nil))      ; 3. ObjC method def.
+               (throw 'loop nil))      ; 4. ObjC method def.
 
              ;; Might we have a bitfield declaration, "<type> <id> : <size>"?
              (if c-has-bitfields
@@ -1228,9 +1251,15 @@ comment at the start of cc-engine.el for more info."
                    ptok tok
                    tok (point)
                    pos tok) ; always non-nil
-             )              ; end of (catch loop ....)
+             )              ; end of (catch 'loop ....)
          )                  ; end of sexp-at-a-time (while ....)
 
+       (when (and hit-lim
+                  (or (not pre-stmt-found)
+                      (< pos lim)
+                      (>= pos start)))
+         (setq ret nil))
+
        ;; If the stack isn't empty there might be errors to report.
        (while stack
          (if (and (vectorp saved-pos) (eq (length saved-pos) 3))
@@ -1707,6 +1736,7 @@ comment at the start of cc-engine.el for more info."
      (put-text-property beg end 'c-is-sws t)
      ,@(when (facep 'c-debug-is-sws-face)
         '((c-debug-add-face beg end 'c-debug-is-sws-face)))))
+(def-edebug-spec c-put-is-sws t)
 
 (defmacro c-put-in-sws (beg end)
   ;; This macro does a hidden buffer change.
@@ -1714,6 +1744,7 @@ comment at the start of cc-engine.el for more info."
      (put-text-property beg end 'c-in-sws t)
      ,@(when (facep 'c-debug-is-sws-face)
         '((c-debug-add-face beg end 'c-debug-in-sws-face)))))
+(def-edebug-spec c-put-in-sws t)
 
 (defmacro c-remove-is-sws (beg end)
   ;; This macro does a hidden buffer change.
@@ -1721,6 +1752,7 @@ comment at the start of cc-engine.el for more info."
      (remove-text-properties beg end '(c-is-sws nil))
      ,@(when (facep 'c-debug-is-sws-face)
         '((c-debug-remove-face beg end 'c-debug-is-sws-face)))))
+(def-edebug-spec c-remove-is-sws t)
 
 (defmacro c-remove-in-sws (beg end)
   ;; This macro does a hidden buffer change.
@@ -1728,6 +1760,7 @@ comment at the start of cc-engine.el for more info."
      (remove-text-properties beg end '(c-in-sws nil))
      ,@(when (facep 'c-debug-is-sws-face)
         '((c-debug-remove-face beg end 'c-debug-in-sws-face)))))
+(def-edebug-spec c-remove-in-sws t)
 
 (defmacro c-remove-is-and-in-sws (beg end)
   ;; This macro does a hidden buffer change.
@@ -1736,6 +1769,7 @@ comment at the start of cc-engine.el for more info."
      ,@(when (facep 'c-debug-is-sws-face)
         '((c-debug-remove-face beg end 'c-debug-is-sws-face)
           (c-debug-remove-face beg end 'c-debug-in-sws-face)))))
+(def-edebug-spec c-remove-is-and-in-sws t)
 
 ;; The type of literal position `end' is in a `before-change-functions'
 ;; function - one of `c', `c++', `pound', or nil (but NOT `string').
@@ -1744,12 +1778,14 @@ comment at the start of cc-engine.el for more info."
 ;; enclosing END, if any, else nil.
 (defvar c-sws-lit-limits nil)
 
-(defun c-invalidate-sws-region-before (end)
-  ;; Called from c-before-change.  END is the end of the change region, the
-  ;; standard parameter given to all before-change-functions.
+(defun c-invalidate-sws-region-before (beg end)
+  ;; Called from c-before-change.  BEG and END are the bounds of the change
+  ;; region, the standard parameters given to all before-change-functions.
   ;;
-  ;; Note whether END is inside a comment or CPP construct, and if so note its
-  ;; bounds in `c-sws-lit-limits' and type in `c-sws-lit-type'.
+  ;; Note whether END is inside a comment, CPP construct, or noise macro, and
+  ;; if so note its bounds in `c-sws-lit-limits' and type in `c-sws-lit-type'.
+  (setq c-sws-lit-type nil
+       c-sws-lit-limits nil)
   (save-excursion
     (goto-char end)
     (let* ((limits (c-literal-limits))
@@ -1762,8 +1798,19 @@ comment at the start of cc-engine.el for more info."
        (setq c-sws-lit-type 'pound
              c-sws-lit-limits (cons (point)
                                     (progn (c-end-of-macro) (point)))))
-       (t (setq c-sws-lit-type nil
-               c-sws-lit-limits nil))))))
+       ((progn (skip-syntax-backward "w_")
+              (looking-at c-noise-macro-name-re))
+       (setq c-sws-lit-type 'noise
+             c-sws-lit-limits (cons (match-beginning 1) (match-end 1))))
+       (t))))
+  (save-excursion
+    (goto-char beg)
+    (skip-syntax-backward "w_")
+    (when (looking-at c-noise-macro-name-re)
+      (setq c-sws-lit-type 'noise)
+      (if (consp c-sws-lit-limits)
+         (setcar c-sws-lit-limits (match-beginning 1))
+       (setq c-sws-lit-limits (cons (match-beginning 1) (match-end 1)))))))
 
 (defun c-invalidate-sws-region-after-del (beg end old-len)
   ;; Text has been deleted, OLD-LEN characters of it starting from position
@@ -1772,7 +1819,6 @@ comment at the start of cc-engine.el for more info."
   ;; deletion deleted or "damaged" its opening delimiter.  If so, return the
   ;; current position of where the construct ended, otherwise return nil.
   (when c-sws-lit-limits
-    (setcdr c-sws-lit-limits (- (cdr c-sws-lit-limits) old-len))
     (if (and (< beg (+ (car c-sws-lit-limits) 2)) ; A lazy assumption that
                                                  ; comment delimiters are 2
                                                  ; chars long.
@@ -1790,9 +1836,9 @@ comment at the start of cc-engine.el for more info."
   ;; or `c-is-sws' text properties inside this literal.  If there are, return
   ;; the buffer position of the end of the literal, else return nil.
   (save-excursion
+    (goto-char end)
     (let* ((limits (c-literal-limits))
           (lit-type (c-literal-type limits)))
-      (goto-char end)
       (when (and (not (memq lit-type '(c c++)))
                 (c-beginning-of-macro))
        (setq lit-type 'pound
@@ -1816,6 +1862,10 @@ comment at the start of cc-engine.el for more info."
   ;; properties right after they're added.
   ;;
   ;; This function does hidden buffer changes.
+  (when c-sws-lit-limits
+    (setcar c-sws-lit-limits (min beg (car c-sws-lit-limits)))
+    (setcdr c-sws-lit-limits
+           (max end (- (+ (cdr c-sws-lit-limits) (- end beg)) old-len))))
   (let ((del-end
         (and (> old-len 0)
              (c-invalidate-sws-region-after-del beg end old-len)))
@@ -1835,6 +1885,10 @@ comment at the start of cc-engine.el for more info."
       (when (and (eolp) (not (eobp)))
        (setq end (1+ (point)))))
 
+    (when (eq c-sws-lit-type 'noise)
+      (setq beg (car c-sws-lit-limits)
+           end (cdr c-sws-lit-limits))) ; This last setting may be redundant.
+
     (when (and (= beg end)
               (get-text-property beg 'c-in-sws)
               (> beg (point-min))
@@ -1854,6 +1908,7 @@ comment at the start of cc-engine.el for more info."
 
     (setq end (max (or del-end end)
                   (or ins-end end)
+                  (or (cdr c-sws-lit-limits) end)
                   end))
 
     (c-debug-sws-msg "c-invalidate-sws-region-after [%s..%s]" beg end)
@@ -1879,7 +1934,8 @@ comment at the start of cc-engine.el for more info."
     (skip-chars-forward " \t\n\r\f\v")
     (when (or (looking-at c-syntactic-ws-start)
              (and c-opt-cpp-prefix
-                  (looking-at c-noise-macro-name-re)))
+                  (looking-at c-noise-macro-name-re))
+             (looking-at c-doc-line-join-re))
 
       (setq rung-end-pos (min (1+ (point)) (point-max)))
       (if (setq rung-is-marked (text-property-any rung-pos rung-end-pos
@@ -2009,6 +2065,13 @@ comment at the start of cc-engine.el for more info."
                   (looking-at c-noise-macro-name-re))
              ;; Skip over a noise macro.
              (goto-char (match-end 1))
+             (not (eobp)))
+
+            ((looking-at c-doc-line-join-re)
+             ;; Skip over a line join in (e.g.) Pike autodoc.
+             (goto-char (match-end 0))
+             (setq safe-start nil) ; Never cache this; the doc style could be
+                                       ; changed at any time.
              (not (eobp)))))
 
        ;; We've searched over a piece of non-white syntactic ws.  See if this
@@ -2103,7 +2166,8 @@ comment at the start of cc-engine.el for more info."
   (let (;; `rung-pos' is set to a position as late as possible in the unmarked
        ;; part of the simple ws region.
        (rung-pos (point)) next-rung-pos last-put-in-sws-pos
-       rung-is-marked simple-ws-beg cmt-skip-pos)
+       rung-is-marked simple-ws-beg cmt-skip-pos
+       (doc-line-join-here (concat c-doc-line-join-re "\\=")))
 
     ;; Skip simple horizontal ws and do a quick check on the preceding
     ;; character to see if it's anything that can't end syntactic ws, so we can
@@ -2113,16 +2177,22 @@ comment at the start of cc-engine.el for more info."
     (skip-chars-backward " \t\f")
     (when (and (not (bobp))
               (save-excursion
-                (backward-char)
-                (or (looking-at c-syntactic-ws-end)
-                    (and c-opt-cpp-prefix
-                         (looking-at c-symbol-char-key)
-                         (progn (c-beginning-of-current-token)
-                                (looking-at c-noise-macro-name-re))))))
+                (or (and
+                     (memq (char-before) c-doc-line-join-end-ch) ; For speed.
+                     (re-search-backward doc-line-join-here
+                                         (c-point 'bopl) t))
+                    (progn
+                      (backward-char)
+                      (or (looking-at c-syntactic-ws-end)
+                          (and c-opt-cpp-prefix
+                               (looking-at c-symbol-char-key)
+                               (progn (c-beginning-of-current-token)
+                                      (looking-at c-noise-macro-name-re))))))))
       ;; Try to find a rung position in the simple ws preceding point, so that
       ;; we can get a cache hit even if the last bit of the simple ws has
       ;; changed recently.
-      (setq simple-ws-beg (point))
+      (setq simple-ws-beg (or (match-end 1) ; Noise macro
+                             (match-end 0))) ; c-syntactic-ws-end
       (skip-chars-backward " \t\n\r\f\v")
       (if (setq rung-is-marked (text-property-any
                                (point) (min (1+ rung-pos) (point-max))
@@ -2257,7 +2327,11 @@ comment at the start of cc-engine.el for more info."
                                 (looking-at c-noise-macro-name-re)))))
              ;; Skipped over a noise macro
              (goto-char next-rung-pos)
-             t)))
+             t)
+
+            ((and
+              (memq (char-before) c-doc-line-join-end-ch) ; For speed.
+              (re-search-backward doc-line-join-here (c-point 'bopl) t)))))
 
        ;; We've searched over a piece of non-white syntactic ws.  See if this
        ;; can be cached.
@@ -5066,7 +5140,7 @@ comment at the start of cc-engine.el for more info."
              (setq beg (c-safe (c-backward-sexp 1) (point))))
 
             ((and (c-safe (forward-char -2) t)
-                  (looking-at "*/"))
+                  (looking-at "\\*/"))
              ;; Block comment.  Due to the nature of line
              ;; comments, they will always be covered by the
              ;; normal case above.
@@ -5594,8 +5668,12 @@ comment at the start of cc-engine.el for more info."
               ;; Pseudo match inside a comment or string literal.  Skip out
               ;; of comments and string literals.
               (while (progn
-                       (goto-char (c-next-single-property-change
-                                   (point) 'face nil cfd-limit))
+                       (unless
+                           (and (match-end 1)
+                                (c-got-face-at (1- (point)) c-literal-faces)
+                                (not (c-got-face-at (point) c-literal-faces)))
+                         (goto-char (c-next-single-property-change
+                                     (point) 'face nil cfd-limit)))
                        (and (< (point) cfd-limit)
                             (c-got-face-at (point) c-literal-faces))))
               t)                     ; Continue the loop over pseudo matches.
@@ -5635,7 +5713,16 @@ comment at the start of cc-engine.el for more info."
 
      (when (< cfd-match-pos cfd-limit)
        ;; Skip forward past comments only so we don't skip macros.
-       (c-forward-comments)
+       (while
+          (progn
+            (c-forward-comments)
+            ;; The following is of use within a doc comment when a doc
+            ;; comment style has removed face properties from a construct,
+            ;; and is relying on `c-font-lock-declarations' to add them
+            ;; again.
+            (and (< (point) cfd-limit)
+                 (looking-at c-doc-line-join-re)
+                 (goto-char (match-end 0)))))
        ;; Set the position to continue at.  We can avoid going over
        ;; the comments skipped above a second time, but it's possible
        ;; that the comment skipping has taken us past `cfd-prop-match'
@@ -5894,7 +5981,7 @@ comment at the start of cc-engine.el for more info."
          (goto-char (or start-in-literal cfd-start-pos))
          ;; The only syntactic ws in macros are comments.
          (c-backward-comments)
-         (backward-char)
+         (or (bobp) (backward-char))
          (c-beginning-of-current-token))
 
         (start-in-literal
@@ -5919,7 +6006,8 @@ comment at the start of cc-engine.el for more info."
                          (not (eq (c-get-char-property (point) 'c-type)
                                   'c-decl-end))))))
 
-         (when (= (point) start-in-literal)
+         (when (and (= (point) start-in-literal)
+                    (not (looking-at c-doc-bright-comment-start-re)))
            ;; Didn't find any property inside the comment, so we can
            ;; skip it entirely.  (This won't skip past a string, but
            ;; that'll be handled quickly by the next
@@ -6298,9 +6386,8 @@ comment at the start of cc-engine.el for more info."
 ;; Set by c-common-init in cc-mode.el.
 (defvar c-new-BEG)
 (defvar c-new-END)
-;; Set by c-after-change in cc-mode.el.
-(defvar c-old-BEG)
-(defvar c-old-END)
+;; Set by c-before-change-check-raw-strings.
+(defvar c-old-END-literality)
 
 (defun c-before-change-check-<>-operators (beg end)
   ;; Unmark certain pairs of "< .... >" which are currently marked as
@@ -6432,9 +6519,9 @@ comment at the start of cc-engine.el for more info."
 ;; A valid C++ raw string looks like
 ;;     R"<id>(<contents>)<id>"
 ;; , where <id> is an identifier from 0 to 16 characters long, not containing
-;; spaces, control characters, double quote or left/right paren.  <contents>
-;; can include anything which isn't the terminating )<id>", including new
-;; lines, "s, parentheses, etc.
+;; spaces, control characters, or left/right paren.  <contents> can include
+;; anything which isn't the terminating )<id>", including new lines, "s,
+;; parentheses, etc.
 ;;
 ;; CC Mode handles C++ raw strings by the use of `syntax-table' text
 ;; properties as follows:
@@ -6444,16 +6531,18 @@ comment at the start of cc-engine.el for more info."
 ;;   contents is given the property value "punctuation" (`(1)') to prevent it
 ;;   interacting with the "s in the delimiters.
 ;;
-;;   The font locking routine `c-font-lock-c++-raw-strings' (in cc-fonts.el)
+;;   The font locking routine `c-font-lock-raw-strings' (in cc-fonts.el)
 ;;   recognizes valid raw strings, and fontifies the delimiters (apart from
 ;;   the parentheses) with the default face and the parentheses and the
 ;;   <contents> with font-lock-string-face.
 ;;
 ;; (ii) A valid, but unterminated, raw string opening delimiter gets the
 ;;   "punctuation" value (`(1)') of the `syntax-table' text property, and the
-;;   open parenthesis gets the "string fence" value (`(15)').
+;;   open parenthesis gets the "string fence" value (`(15)').  When such a
+;;   delimiter is found, no attempt is made in any way to "correct" any text
+;;   properties after the delimiter.
 ;;
-;;   `c-font-lock-c++-raw-strings' puts c-font-lock-warning-face on the entire
+;;   `c-font-lock-raw-strings' puts c-font-lock-warning-face on the entire
 ;;   unmatched opening delimiter (from the R up to the open paren), and allows
 ;;   the rest of the buffer to get font-lock-string-face, caused by the
 ;;   unmatched "string fence" `syntax-table' text property value.
@@ -6470,10 +6559,17 @@ comment at the start of cc-engine.el for more info."
 ;;   already at the end of the macro, it gets the "punctuation" value, and no
 ;;   "string fence"s are used.
 ;;
-;;   The effect on the fontification of either of these tactics is that rest of
-;;   the macro (if any) after the "(" gets font-lock-string-face, but the rest
-;;   of the file is fontified normally.
-
+;;   The effect on the fontification of either of these tactics is that the
+;;   rest of the macro (if any) after the "(" gets font-lock-string-face, but
+;;   the rest of the file is fontified normally.
+
+;; The values of the function `c-raw-string-pos' at before-change-functions'
+;; BEG and END.
+(defvar c-old-beg-rs nil)
+(defvar c-old-end-rs nil)
+;; Whether a buffer change has disrupted or will disrupt the terminating id of
+;; a raw string.
+(defvar c-raw-string-end-delim-disrupted nil)
 
 (defun c-raw-string-pos ()
   ;; Get POINT's relationship to any containing raw string.
@@ -6490,7 +6586,7 @@ comment at the start of cc-engine.el for more info."
   ;; characters.)  If the raw string is not terminated, E\) and E\" are set to
   ;; nil.
   ;;
-  ;; Note: this routine is dependant upon the correct syntax-table text
+  ;; Note: this function is dependant upon the correct syntax-table text
   ;; properties being set.
   (let ((state (c-state-semi-pp-to-literal (point)))
        open-quote-pos open-paren-pos close-paren-pos close-quote-pos id)
@@ -6503,11 +6599,22 @@ comment at the start of cc-engine.el for more info."
                 (search-backward "\"" (max (- (point) 17) (point-min)) t)))
            ((and (eq (cadr state) 'string)
                  (goto-char (nth 2 state))
-                 (or (eq (char-after) ?\")
-                     (search-backward "\"" (max (- (point) 17) (point-min)) t))
+                 (cond
+                  ((eq (char-after) ?\"))
+                  ((eq (char-after) ?\()
+                   (let ((here (point)))
+                     (goto-char (max (- (point) 18) (point-min)))
+                     (while
+                         (and
+                          (search-forward-regexp
+                           c-c++-raw-string-opener-re
+                           (1+ here) 'limit)
+                          (< (point) here)))
+                     (and (eq (point) (1+ here))
+                          (match-beginning 1)
+                          (goto-char (1- (match-beginning 1)))))))
                  (not (bobp)))))
-          (eq (char-before) ?R)
-          (looking-at "\"\\([^ ()\\\n\r\t]\\{0,16\\}\\)("))
+          (c-at-c++-raw-string-opener))
        (setq open-quote-pos (point)
              open-paren-pos (match-end 1)
              id (match-string-no-properties 1))
@@ -6527,6 +6634,21 @@ comment at the start of cc-engine.el for more info."
           (t nil))
          open-quote-pos open-paren-pos close-paren-pos close-quote-pos))))
 
+(defun c-raw-string-in-end-delim (beg end)
+  ;; If the region (BEG END) intersects a possible raw string terminator,
+  ;; return a cons of the position of the ) and the position of the " in the
+  ;; first one found.
+  (save-excursion
+    (goto-char (max (- beg 17) (point-min)))
+    (while
+       (and
+        (search-forward-regexp ")\\([^ ()\\\n\r\t]\\{0,16\\}\\)\""
+                               (min (+ end 17) (point-max)) t)
+        (<= (point) beg)))
+    (unless (or (<= (point) beg)
+               (>= (match-beginning 0) end))
+      (cons (match-beginning 0) (match-end 1)))))
+
 (defun c-depropertize-raw-string (id open-quote open-paren bound)
   ;; Point is immediately after a raw string opening delimiter.  Remove any
   ;; `syntax-table' text properties associated with the delimiter (if it's
@@ -6535,29 +6657,55 @@ comment at the start of cc-engine.el for more info."
   ;; ID, a string, is the delimiter's identifier.  OPEN-QUOTE and OPEN-PAREN
   ;; are the buffer positions of the delimiter's components.  BOUND is the
   ;; bound for searching for a matching closing delimiter; it is usually nil,
-  ;; but if we're inside a macro, it's the end of the macro.
+  ;; but if we're inside a macro, it's the end of the macro (i.e. just before
+  ;; the terminating \n).
   ;;
   ;; Point is moved to after the (terminated) raw string, or left after the
   ;; unmatched opening delimiter, as the case may be.  The return value is of
   ;; no significance.
-  (let ((open-paren-prop (c-get-char-property open-paren 'syntax-table)))
+  (let ((open-paren-prop (c-get-char-property open-paren 'syntax-table))
+       first)
+    ;; If the delimiter is "unclosed", or sombody's used " in their id, clear
+    ;; the 'syntax-table property from all of them.
+    (setq first (c-clear-char-property-with-value-on-char
+                open-quote open-paren 'syntax-table '(1) ?\"))
+    (if first (c-truncate-semi-nonlit-pos-cache first))
     (cond
      ((null open-paren-prop)
-      ;; A terminated raw string
+      ;; Should be a terminated raw string...
       (when (search-forward (concat ")" id "\"") nil t)
+       ;; Yes, it is.  :-)
+       ;; Clear any '(1)s from "s in the identifier.
+       (setq first (c-clear-char-property-with-value-on-char
+                    (1+ (match-beginning 0)) (1- (match-end 0))
+                    'syntax-table '(1) ?\"))
+       (if first (c-truncate-semi-nonlit-pos-cache first))
+       ;; Clear any random `syntax-table' text properties from the contents.
        (let* ((closing-paren (match-beginning 0))
-              (first-punctuation
-               (save-match-data
-                 (goto-char (1+ open-paren))
-                 (and (c-search-forward-char-property 'syntax-table '(1)
-                                                      closing-paren)
-                      (1- (point)))))
-              )
-         (when first-punctuation
-           (c-clear-char-property-with-value
-            first-punctuation (match-beginning 0) 'syntax-table '(1))
-           (c-truncate-semi-nonlit-pos-cache first-punctuation)
-           ))))
+              (first-st
+               (and
+                (< (1+ open-paren) closing-paren)
+                (or
+                 (and (c-get-char-property (1+ open-paren) 'syntax-table)
+                      (1+ open-paren))
+                 (and
+                  (setq first
+                        (c-next-single-property-change
+                         (1+ open-paren) 'syntax-table nil closing-paren))
+                  (< first closing-paren)
+                  first)))))
+         (when first-st
+           (c-clear-char-properties first-st (match-beginning 0)
+                                    'syntax-table)
+           (c-truncate-semi-nonlit-pos-cache first-st))
+         (when (c-get-char-property (1- (match-end 0)) 'syntax-table)
+           ;; Was previously an unterminated (ordinary) string
+           (save-excursion
+             (goto-char (1- (match-end 0)))
+             (when (c-safe (c-forward-sexp)) ; to '(1) at EOL.
+               (c-clear-char-property (1- (point)) 'syntax-table))
+             (c-clear-char-property (1- (match-end 0)) 'syntax-table)
+             (c-truncate-semi-nonlit-pos-cache (1- (match-end 0))))))))
      ((or (and (equal open-paren-prop '(15)) (null bound))
          (equal open-paren-prop '(1)))
       ;; An unterminated raw string either not in a macro, or in a macro with
@@ -6571,13 +6719,8 @@ comment at the start of cc-engine.el for more info."
       (c-clear-char-property open-quote 'syntax-table)
       (c-truncate-semi-nonlit-pos-cache open-quote)
       (c-clear-char-property open-paren 'syntax-table)
-      (let ((after-string-fence-pos
-            (save-excursion
-              (goto-char (1+ open-paren))
-              (c-search-forward-char-property 'syntax-table '(15) bound))))
-       (when after-string-fence-pos
-         (c-clear-char-property (1- after-string-fence-pos) 'syntax-table)))
-      ))))
+      (c-clear-char-property-with-value (1+ open-paren) bound 'syntax-table
+                                       '(15))))))
 
 (defun c-depropertize-raw-strings-in-region (start finish)
   ;; Remove any `syntax-table' text properties associated with C++ raw strings
@@ -6589,7 +6732,7 @@ comment at the start of cc-engine.el for more info."
               (concat "\\("                                 ; 1
                       c-anchored-cpp-prefix                 ; 2
                       "\\)\\|\\("                           ; 3
-                      "R\"\\([^ ()\\\n\r\t]\\{0,16\\}\\)("  ; 4
+                      c-c++-raw-string-opener-re            ; 4
                       "\\)")
               finish t))
     (when (save-excursion
@@ -6608,7 +6751,7 @@ comment at the start of cc-engine.el for more info."
          (goto-char (match-end 2))     ; after the "#".
          (while (and (< (point) eom)
                      (c-syntactic-re-search-forward
-                      "R\"\\([^ ()\\\n\r\t]\\{0,16\\}\\)(" eom t))
+                      c-c++-raw-string-opener-re eom t))
            (c-depropertize-raw-string
             (match-string-no-properties 1) ; id
             (1+ (match-beginning 0))       ; open quote
@@ -6617,37 +6760,85 @@ comment at the start of cc-engine.el for more info."
 
 (defun c-before-change-check-raw-strings (beg end)
   ;; This function clears `syntax-table' text properties from C++ raw strings
-  ;; in the region (c-new-BEG c-new-END).  BEG and END are the standard
-  ;; arguments supplied to any before-change function.
+  ;; whose delimiters are about to change in the region (c-new-BEG c-new-END).
+  ;; BEG and END are the standard arguments supplied to any before-change
+  ;; function.
   ;;
   ;; Point is undefined on both entry and exit, and the return value has no
   ;; significance.
   ;;
   ;; This function is called as a before-change function solely due to its
   ;; membership of the C++ value of `c-get-state-before-change-functions'.
+  (goto-char end)
+  (setq c-raw-string-end-delim-disrupted nil)
+  ;; We use the following to detect a R"<id>( being swallowed into a string by
+  ;; the pending change.
+  (setq c-old-END-literality (c-in-literal))
   (c-save-buffer-state
-      ((beg-rs (progn (goto-char beg) (c-raw-string-pos)))
-       (beg-plus (if (null beg-rs)
-                    beg
-                  (max beg
-                       (1+ (or (nth 4 beg-rs) (nth 2 beg-rs))))))
-       (end-rs (progn (goto-char end) (c-raw-string-pos))) ; FIXME!!!
-                                       ; Optimize this so that we don't call
-                                       ; `c-raw-string-pos' twice when once
-                                       ; will do.  (2016-06-02).
-       (end-minus (if (null end-rs)
-                     end
-                   (min end (cadr end-rs))))
-       )
-    (when beg-rs
-      (setq c-new-BEG (min c-new-BEG (1- (cadr beg-rs)))))
-    (c-depropertize-raw-strings-in-region c-new-BEG beg-plus)
-
-    (when end-rs
-      (setq c-new-END (max c-new-END
-                          (1+ (or (nth 4 end-rs)
-                                  (nth 2 end-rs))))))
-    (c-depropertize-raw-strings-in-region end-minus c-new-END)))
+      ((term-del (c-raw-string-in-end-delim beg end))
+       Rquote close-quote)
+    (setq c-old-beg-rs (progn (goto-char beg) (c-raw-string-pos))
+         c-old-end-rs (progn (goto-char end) (c-raw-string-pos)))
+    (cond
+     ;; We're not changing, or we're obliterating raw strings.
+     ((and (null c-old-beg-rs) (null c-old-end-rs)))
+     ;; We're changing the putative terminating delimiter of a raw string
+     ;; containing BEG.
+     ((and c-old-beg-rs term-del
+          (or (null (nth 3 c-old-beg-rs))
+              (<= (car term-del) (nth 3 c-old-beg-rs))))
+      (setq Rquote (1- (cadr c-old-beg-rs))
+           close-quote (1+ (cdr term-del)))
+      (setq c-raw-string-end-delim-disrupted t)
+      (c-depropertize-raw-strings-in-region Rquote close-quote)
+      (setq c-new-BEG (min c-new-BEG Rquote)
+           c-new-END (max c-new-END close-quote)))
+     ;; We're breaking an escaped NL in a raw string in a macro.
+     ((and c-old-end-rs
+          (< beg end)
+          (goto-char end) (eq (char-before) ?\\)
+          (c-beginning-of-macro))
+      (let ((bom (point))
+           (eom (progn (c-end-of-macro) (point))))
+       (c-depropertize-raw-strings-in-region bom eom)
+       (setq c-new-BEG (min c-new-BEG bom)
+             c-new-END (max c-new-END eom))))
+     ;; We're changing only the contents of a raw string.
+     ((and (equal (cdr c-old-beg-rs) (cdr c-old-end-rs))
+          (null (car c-old-beg-rs)) (null (car c-old-end-rs))))
+     ((or
+       ;; We're removing (at least part of) the R" of the starting delim of a
+       ;; raw string:
+       (null c-old-beg-rs)
+       (and (eq beg (cadr c-old-beg-rs))
+           (< beg end))
+       ;; Or we're removing the ( of the starting delim of a raw string.
+       (and (eq (car c-old-beg-rs) 'open-delim)
+           (or (null c-old-end-rs)
+               (not (eq (car c-old-end-rs) 'open-delim))
+               (not (equal (cdr c-old-beg-rs) (cdr c-old-end-rs))))))
+      (let ((close (nth 4 (or c-old-end-rs c-old-beg-rs))))
+       (setq Rquote (1- (cadr (or c-old-end-rs c-old-beg-rs)))
+             close-quote (if close (1+ close) (point-max))))
+      (c-depropertize-raw-strings-in-region Rquote close-quote)
+      (setq c-new-BEG (min c-new-BEG Rquote)
+           c-new-END (max c-new-END close-quote)))
+     ;; We're changing only the text of the identifier of the opening
+     ;; delimiter of a raw string.
+     ((and (eq (car c-old-beg-rs) 'open-delim)
+          (equal c-old-beg-rs c-old-end-rs))))))
+
+(defun c-propertize-raw-string-id (start end)
+  ;; If the raw string identifier between buffer positions START and END
+  ;; contains any double quote characters, put a punctuation syntax-table text
+  ;; property on them.  The return value is of no significance.
+  (save-excursion
+    (goto-char start)
+    (while (and (skip-chars-forward "^\"" end)
+               (< (point) end))
+      (c-put-char-property (point) 'syntax-table '(1))
+      (c-truncate-semi-nonlit-pos-cache (point))
+      (forward-char))))
 
 (defun c-propertize-raw-string-opener (id open-quote open-paren bound)
   ;; Point is immediately after a raw string opening delimiter.  Apply any
@@ -6657,117 +6848,266 @@ comment at the start of cc-engine.el for more info."
   ;; ID, a string, is the delimiter's identifier.  OPEN-QUOTE and OPEN-PAREN
   ;; are the buffer positions of the delimiter's components.  BOUND is the
   ;; bound for searching for a matching closing delimiter; it is usually nil,
-  ;; but if we're inside a macro, it's the end of the macro.
-  ;;
-  ;; Point is moved to after the (terminated) raw string, or left after the
-  ;; unmatched opening delimiter, as the case may be.  The return value is of
-  ;; no significance.
-  (if (search-forward (concat ")" id "\"") bound t)
-      (let ((end-string (match-beginning 0))
-           (after-quote (match-end 0)))
-       (goto-char open-paren)
-       (while (progn (skip-syntax-forward "^\"" end-string)
-                     (< (point) end-string))
-         (c-put-char-property (point) 'syntax-table '(1)) ; punctuation
-         (c-truncate-semi-nonlit-pos-cache (point))
-         (forward-char))
-       (goto-char after-quote))
-    (c-put-char-property open-quote 'syntax-table '(1))             ; 
punctuation
-    (c-truncate-semi-nonlit-pos-cache open-quote)
-    (c-put-char-property open-paren 'syntax-table '(15))     ; generic string
-    (when bound
-      ;; In a CPP construct, we try to apply a generic-string `syntax-table'
-      ;; text property to the last possible character in the string, so that
-      ;; only characters within the macro get "stringed out".
-      (goto-char bound)
-      (if (save-restriction
-           (narrow-to-region (1+ open-paren) (point-max))
-           (re-search-backward
-            (eval-when-compile
-              ;; This regular expression matches either an escape pair (which
-              ;; isn't an escaped NL) (submatch 5) or a non-escaped character
-              ;; (which isn't itself a backslash) (submatch 10).  The long
-              ;; preambles to these (respectively submatches 2-4 and 6-9)
-              ;; ensure that we have the correct parity for sequences of
-              ;; backslashes, etc..
-              (concat "\\("            ; 1
-                      "\\(\\`[^\\]?\\|[^\\][^\\]\\)\\(\\\\\\(.\\|\n\\)\\)*" ; 
2-4
-                      "\\(\\\\.\\)"    ; 5
-                      "\\|"
-                      
"\\(\\`\\|[^\\]\\|\\(\\`[^\\]?\\|[^\\][^\\]\\)\\(\\\\\\(.\\|\n\\)\\)+\\)" ; 6-9
-                      "\\([^\\]\\)"    ; 10
-                      "\\)"
-                      "\\(\\\\\n\\)*\\=")) ; 11
-             (1+ open-paren) t))
-         (if (match-beginning 10)
-             (progn
-               (c-put-char-property (match-beginning 10) 'syntax-table '(15))
-               (c-truncate-semi-nonlit-pos-cache (match-beginning 10)))
-           (c-put-char-property (match-beginning 5) 'syntax-table '(1))
-           (c-put-char-property (1+ (match-beginning 5)) 'syntax-table '(15))
-           (c-truncate-semi-nonlit-pos-cache (1+ (match-beginning 5))))
-       (c-put-char-property open-paren 'syntax-table '(1)))
-      (goto-char bound))))
-
-(defun c-after-change-re-mark-raw-strings (_beg _end _old-len)
-  ;; This function applies `syntax-table' text properties to C++ raw strings
-  ;; beginning in the region (c-new-BEG c-new-END).  BEG, END, and OLD-LEN are
-  ;; the standard arguments supplied to any after-change function.
+  ;; but if we're inside a macro, it's the end of the macro (i.e. the position
+  ;; of the closing newline).
+  ;;
+  ;; Point is moved to after the (terminated) raw string and t is returned, or
+  ;; it is left after the unmatched opening delimiter and nil is returned.
+  (c-propertize-raw-string-id (1+ open-quote) open-paren)
+  (prog1
+      (if (search-forward (concat ")" id "\"") bound t)
+         (let ((end-string (match-beginning 0))
+               (after-quote (match-end 0)))
+           (c-propertize-raw-string-id
+            (1+ (match-beginning 0)) (1- (match-end 0)))
+           (goto-char open-paren)
+           (while (progn (skip-syntax-forward "^\"" end-string)
+                         (< (point) end-string))
+             (c-put-char-property (point) 'syntax-table '(1)) ; punctuation
+             (c-truncate-semi-nonlit-pos-cache (point))
+             (forward-char))
+           (goto-char after-quote)
+           t)
+       (c-put-char-property open-quote 'syntax-table '(1)) ; punctuation
+       (c-truncate-semi-nonlit-pos-cache open-quote)
+       (c-put-char-property open-paren 'syntax-table '(15)) ; generic string
+       (when bound
+         ;; In a CPP construct, we try to apply a generic-string
+         ;; `syntax-table' text property to the last possible character in
+         ;; the string, so that only characters within the macro get
+         ;; "stringed out".
+         (goto-char bound)
+         (if (save-restriction
+               (narrow-to-region (1+ open-paren) (point-max))
+               (re-search-backward
+                (eval-when-compile
+                  ;; This regular expression matches either an escape pair
+                  ;; (which isn't an escaped NL) (submatch 5) or a
+                  ;; non-escaped character (which isn't itself a backslash)
+                  ;; (submatch 10).  The long preambles to these
+                  ;; (respectively submatches 2-4 and 6-9) ensure that we
+                  ;; have the correct parity for sequences of backslashes,
+                  ;; etc..
+                  (concat "\\("        ; 1
+                          
"\\(\\`[^\\]?\\|[^\\][^\\]\\)\\(\\\\\\(.\\|\n\\)\\)*" ; 2-4
+                          "\\(\\\\.\\)" ; 5
+                          "\\|"
+                          
"\\(\\`\\|[^\\]\\|\\(\\`[^\\]?\\|[^\\][^\\]\\)\\(\\\\\\(.\\|\n\\)\\)+\\)" ; 6-9
+                          "\\([^\\]\\)" ; 10
+                          "\\)"
+                          "\\(\\\\\n\\)*\\=")) ; 11
+                (1+ open-paren) t))
+             (if (match-beginning 10)
+                 (progn
+                   (c-put-char-property (match-beginning 10) 'syntax-table 
'(15))
+                   (c-truncate-semi-nonlit-pos-cache (match-beginning 10)))
+               (c-put-char-property (match-beginning 5) 'syntax-table '(1))
+               (c-put-char-property (1+ (match-beginning 5)) 'syntax-table 
'(15))
+               (c-truncate-semi-nonlit-pos-cache (1+ (match-beginning 5))))
+           ;; (c-put-char-property open-paren 'syntax-table '(1))
+           )
+         (goto-char bound))
+       nil)
+  ;; Ensure the opening delimiter will get refontified.
+    (c-font-lock-flush (1- open-quote) (1+ open-paren))))
+
+(defun c-after-change-unmark-raw-strings (beg end _old-len)
+  ;; This function removes `syntax-table' text properties from any raw strings
+  ;; which have been affected by the current change.  These are those which
+  ;; have been "stringed out" and from newly formed raw strings, or any
+  ;; existing raw string which the new text terminates.  BEG, END, and
+  ;; _OLD-LEN are the standard arguments supplied to any
+  ;; after-change-function.
   ;;
   ;; Point is undefined on both entry and exit, and the return value has no
   ;; significance.
   ;;
-  ;; This function is called as an after-change function solely due to its
+  ;; This functions is called as an after-change function by virtue of its
   ;; membership of the C++ value of `c-before-font-lock-functions'.
-  (c-save-buffer-state ()
-    ;; If the region (c-new-BEG c-new-END) has expanded, remove
-    ;; `syntax-table' text-properties from the new piece(s).
-    (when (< c-new-BEG c-old-BEG)
-      (let ((beg-rs (progn (goto-char c-old-BEG) (c-raw-string-pos))))
-       (c-depropertize-raw-strings-in-region
-        c-new-BEG
-        (if beg-rs
-            (1+ (or (nth 4 beg-rs) (nth 2 beg-rs)))
-          c-old-BEG))))
-    (when (> c-new-END c-old-END)
-      (let ((end-rs (progn (goto-char c-old-END) (c-raw-string-pos))))
-       (c-depropertize-raw-strings-in-region
-        (if end-rs
-            (cadr end-rs)
-          c-old-END)
-        c-new-END)))
+  ;; (when (< beg end)
+    (c-save-buffer-state (found eoll state id found-beg found-end)
+      ;; Has an inserted " swallowed up a R"(, turning it into "...R"(?
+      (goto-char end)
+      (setq eoll (c-point 'eoll))
+      (when (and (null c-old-END-literality)
+                (search-forward-regexp c-c++-raw-string-opener-re eoll t))
+       (setq state (c-state-semi-pp-to-literal end))
+       (when (eq (cadr state) 'string)
+         (unwind-protect
+             ;; Temporarily insert a closing string delimiter....
+             (progn
+               (goto-char end)
+               (cond
+                ((c-characterp (nth 3 (car state)))
+                 (insert (nth 3 (car state))))
+                ((eq (nth 3 (car state)) t)
+                 (insert ?\")
+                 (c-put-char-property end 'syntax-table '(15))))
+               (c-truncate-semi-nonlit-pos-cache end)
+               ;; ....ensure c-new-END extends right to the end of the about
+               ;; to be un-stringed raw string....
+               (save-excursion
+                 (goto-char (match-beginning 1))
+                 (let ((end-bs (c-raw-string-pos)))
+                   (setq c-new-END
+                         (max c-new-END
+                              (if (nth 4 end-bs)
+                                  (1+ (nth 4 end-bs))
+                                eoll)))))
+
+               ;; ...and clear `syntax-table' text propertes from the
+               ;; following raw strings.
+               (c-depropertize-raw-strings-in-region (point) (1+ eoll)))
+           ;; Remove the temporary string delimiter.
+           (goto-char end)
+           (delete-char 1))))
+
+      ;; Have we just created a new starting id?
+      (goto-char (max (- beg 18) (point-min)))
+      (while
+         (and
+          (setq found
+                (search-forward-regexp c-c++-raw-string-opener-re
+                                      c-new-END 'bound))
+          (<= (match-end 0) beg)))
+      (when (and found (<= (match-beginning 0) end))
+       (setq c-new-BEG (min c-new-BEG (match-beginning 0)))
+       (c-depropertize-raw-strings-in-region c-new-BEG c-new-END))
+
+      ;; Have we invalidated an opening delimiter by typing into it?
+      (when (and c-old-beg-rs
+                (eq (car c-old-beg-rs) 'open-delim)
+                (equal (c-get-char-property (cadr c-old-beg-rs)
+                                            'syntax-table)
+                       '(1)))
+       (goto-char (1- (cadr c-old-beg-rs)))
+       (unless (looking-at c-c++-raw-string-opener-re)
+         (c-clear-char-property (1+ (point)) 'syntax-table)
+         (c-truncate-semi-nonlit-pos-cache (1+ (point)))
+         (if (c-search-forward-char-property 'syntax-table '(15)
+                                             (c-point 'eol))
+             (c-clear-char-property (1- (point)) 'syntax-table))))
+
+      ;; Have we matched up with an existing terminator by typing into an
+      ;; opening delimiter? ... or by messing up a raw string's terminator so
+      ;; that it now matches a later terminator?
+      (when
+         (or c-raw-string-end-delim-disrupted
+             (and c-old-beg-rs
+                  (eq (car c-old-beg-rs) 'open-delim)))
+       (goto-char (cadr c-old-beg-rs))
+       (when (looking-at c-c++-raw-string-opener-1-re)
+         (setq id (match-string-no-properties 1))
+         (when (re-search-forward (concat ")" id "\"") nil t) ; No bound.
+           (setq c-new-END (point-max))
+           (c-clear-char-properties (cadr c-old-beg-rs) c-new-END
+                                    'syntax-table)
+           (c-truncate-semi-nonlit-pos-cache (cadr c-old-beg-rs)))))
+      ;; Have we terminated an existing raw string by inserting or removing
+      ;; text?
+      (when (eq c-old-END-literality 'string)
+       ;; Have we just made or modified a closing delimiter?
+       (goto-char (max (- beg 18) (point-min)))
+       (while
+           (and
+            (setq found
+                  (search-forward-regexp ")\\([^ ()\\\n\r\t]\\{0,16\\}\\)\""
+                                         (+ end 17) t))
+            (< (match-end 0) beg)))
+       (when (and found (<= (match-beginning 0) end))
+         (setq id (match-string-no-properties 1))
+         (goto-char (match-beginning 0))
+         (while
+             (and
+              (setq found (search-backward (concat "R\"" id "(") nil t))
+              (setq state (c-state-semi-pp-to-literal (point)))
+              (memq (nth 3 (car state)) '(t ?\"))))
+         (when found
+           (setq c-new-BEG (min (point) c-new-BEG)
+                 c-new-END (point-max))
+           (c-clear-char-properties (point) c-new-END 'syntax-table)
+           (c-truncate-semi-nonlit-pos-cache (point)))))
+
+      ;; Are there any raw strings in a newly created macro?
+      (when (< beg end)
+       (goto-char beg)
+       (setq found-beg (point))
+       (when (search-forward-regexp c-anchored-cpp-prefix end t)
+         (c-end-of-macro)
+         (c-depropertize-raw-strings-in-region found-beg (point))))))
 
-    (goto-char c-new-BEG)
-    (while (and (< (point) c-new-END)
-               (re-search-forward
-                (concat "\\("                                 ; 1
-                        c-anchored-cpp-prefix                 ; 2
-                        "\\)\\|\\("                           ; 3
-                        "R\"\\([^ ()\\\n\r\t]\\{0,16\\}\\)("  ; 4
-                        "\\)")
-                c-new-END t))
-      (when (save-excursion
-             (goto-char (match-beginning 0)) (not (c-in-literal)))
-       (if (match-beginning 4)         ; the id
-           ;; We've found a raw string.
+(defun c-maybe-re-mark-raw-string ()
+  ;; When this function is called, point is immediately after a ".  If this "
+  ;; is the characteristic " of of a raw string delimiter, apply the pertinent
+  ;; `syntax-table' text properties to the entire raw string (when properly
+  ;; terminated) or just the delimiter (otherwise).
+  ;;
+  ;; If the " is in any way part of a raw string, return non-nil.  Otherwise
+  ;; return nil.
+  (let ((here (point))
+       in-macro macro-end id Rquote found)
+    (cond
+     ((and
+       (eq (char-before (1- (point))) ?R)
+       (looking-at "\\([^ ()\\\n\r\t]\\{0,16\\}\\)("))
+      (save-excursion
+       (setq in-macro (c-beginning-of-macro))
+       (setq macro-end (when in-macro
+                         (c-end-of-macro)
+                         (point) ;; (min (1+ (point)) (point-max))
+                         )))
+      (if (not
+          (c-propertize-raw-string-opener
+           (match-string-no-properties 1) ; id
+           (1- (point))                   ; open quote
+           (match-end 1)                  ; open paren
+           macro-end))              ; bound (end of macro) or nil.
+         (goto-char (or macro-end (point-max))))
+      t)
+     ((save-excursion
+       (and
+        (search-backward-regexp ")\\([^ ()\\\n\r\t]\\{0,16\\}\\)\"\\=" nil t)
+        (setq id (match-string-no-properties 1))
+        (let* ((quoted-id (regexp-quote id))
+               (quoted-id-depth (regexp-opt-depth quoted-id)))
+          (while
+              (and
+               ;; Search back for an opening delimiter with identifier `id'.
+               ;; A closing delimiter with `id' "blocks" our search.
+               (search-backward-regexp ; This could be slow.
+                (concat "\\(R\"" quoted-id "(\\)"
+                        "\\|"
+                        "\\()" quoted-id "\"\\)")
+                nil t)
+               (setq found t)
+               (if (eq (c-in-literal) 'string)
+                   (match-beginning 1)
+                 (match-beginning (+ 2 quoted-id-depth)))))
+          (and found
+               (null (c-in-literal))
+               (match-beginning 1)))
+        (setq Rquote (point))))
+      (save-excursion
+       (goto-char Rquote)
+       (setq in-macro (c-beginning-of-macro))
+       (setq macro-end (when in-macro
+                         (c-end-of-macro)
+                         (point))))
+      (if (or (not in-macro)
+             (<= here macro-end))
+         (progn
            (c-propertize-raw-string-opener
-            (match-string-no-properties 4) ; id
-            (1+ (match-beginning 3))       ; open quote
-            (match-end 4)                  ; open paren
-            nil)                           ; bound
-         ;; We've found a CPP construct.  Search for raw strings within it.
-         (goto-char (match-beginning 2)) ; the "#"
-         (c-end-of-macro)
-         (let ((eom (point)))
-           (goto-char (match-end 2))   ; after the "#".
-           (while (and (< (point) eom)
-                       (c-syntactic-re-search-forward
-                        "R\"\\([^ ()\\\n\r\t]\\{0,16\\}\\)(" eom t))
-             (c-propertize-raw-string-opener
-              (match-string-no-properties 1) ; id
-              (1+ (match-beginning 0))       ; open quote
-              (match-end 1)                  ; open paren
-              eom))))))))                    ; bound
+            id (1+ (point)) (match-end 1) macro-end)
+           (goto-char here)
+           t)
+       (goto-char here)
+       nil))
+
+     (t
+      ;; If the " is in another part of a raw string (whether as part of the
+      ;; identifier, or in the string itself) the `syntax-table' text
+      ;; properties on the raw string will be current.  So, we can use...
+      (c-raw-string-pos)))))
 
 
 ;; Handling of small scale constructs like types and names.
@@ -7988,49 +8328,28 @@ comment at the start of cc-engine.el for more info."
     (or res (goto-char here))
     res))
 
+(defun c-forward-class-decl ()
+  "From the beginning of a struct/union, etc. move forward to
+after the brace block which defines it, leaving point at the
+start of the next token and returning point.  On failure leave
+point unchanged and return nil."
+  (let ((here (point)))
+    (if
+       (and
+        (looking-at c-class-key)
+        (eq (c-forward-token-2) 0)
+        (c-on-identifier)
+        (eq (c-forward-token-2) 0)
+        (eq (char-after) ?{)
+        (c-go-list-forward))
+       (progn
+         (c-forward-syntactic-ws)
+         (point))
+      (goto-char here)
+      nil)))
 
 ;; Handling of large scale constructs like statements and declarations.
 
-;; Macro used inside `c-forward-decl-or-cast-1'.  It ought to be a
-;; defsubst or perhaps even a defun, but it contains lots of free
-;; variables that refer to things inside `c-forward-decl-or-cast-1'.
-(defmacro c-fdoc-shift-type-backward (&optional short)
-  ;; `c-forward-decl-or-cast-1' can consume an arbitrary length list
-  ;; of types when parsing a declaration, which means that it
-  ;; sometimes consumes the identifier in the declaration as a type.
-  ;; This is used to "backtrack" and make the last type be treated as
-  ;; an identifier instead.
-  `(progn
-     ,(unless short
-       ;; These identifiers are bound only in the inner let.
-       '(setq identifier-type at-type
-              identifier-start type-start
-              got-parens nil
-              got-identifier t
-              got-suffix t
-              got-suffix-after-parens id-start
-              paren-depth 0))
-
-     (if (setq at-type (if (eq backup-at-type 'prefix)
-                          t
-                        backup-at-type))
-        (setq type-start backup-type-start
-              id-start backup-id-start)
-       (setq type-start start-pos
-            id-start start-pos))
-
-     ;; When these flags already are set we've found specifiers that
-     ;; unconditionally signal these attributes - backtracking doesn't
-     ;; change that.  So keep them set in that case.
-     (or at-type-decl
-        (setq at-type-decl backup-at-type-decl))
-     (or maybe-typeless
-        (setq maybe-typeless backup-maybe-typeless))
-
-     ,(unless short
-       ;; This identifier is bound only in the inner let.
-       '(setq start id-start))))
-
 (defun c-forward-declarator (&optional limit accept-anon)
   ;; Assuming point is at the start of a declarator, move forward over it,
   ;; leaving point at the next token after it (e.g. a ) or a ; or a ,).
@@ -8183,6 +8502,176 @@ comment at the start of cc-engine.el for more info."
       (goto-char here)
       nil)))
 
+(defun c-do-declarators
+    (cdd-limit cdd-list cdd-not-top cdd-comma-prop cdd-function)
+  "Assuming point is at the start of a comma separated list of declarators,
+apply CDD-FUNCTION to each declarator (when CDD-LIST is non-nil) or just the
+first declarator (when CDD-LIST is nil).  When CDD-FUNCTION is nil, no
+function is applied.
+
+CDD-FUNCTION is supplied with 6 arguments:
+0. The start position of the declarator's identifier;
+1. The end position of this identifier;
+\[Note: if there is no identifier, as in int (*);, both of these are nil.]
+2. The position of the next token after the declarator (CLARIFY!!!).
+3. CDD-NOT-TOP;
+4. Non-nil if the identifier is of a function.
+5. When there is an initialization following the declarator (such as \"=
+....\" or \"( ....\".), the character which introduces this initialization,
+otherwise nil.
+
+Additionally, if CDD-COMMA-PROP is non-nil, mark the separating commas with
+this value of the c-type property, when CDD-LIST is non-nil.
+
+Stop at or before CDD-LIMIT (which may NOT be nil).
+
+If CDD-NOT-TOP is non-nil, we are not at the top-level (\"top-level\" includes
+being directly inside a class or namespace, etc.).
+
+Return non-nil if we've reached the token after the last declarator (often a
+semicolon, or a comma when CDD-LIST is nil); otherwise (when we hit CDD-LIMIT,
+or fail otherwise) return nil, leaving point at the beginning of the putative
+declarator that could not be processed.
+
+This function might do hidden buffer changes."
+  ;; N.B.: We use the "cdd-" prefix in this routine to try to prevent
+  ;; confusion with possible reference to common variable names from within
+  ;; CDD-FUNCTION.
+  (let
+      ((cdd-pos (point)) cdd-next-pos cdd-id-start cdd-id-end
+       cdd-decl-res cdd-got-func cdd-got-type cdd-got-init
+       c-last-identifier-range cdd-exhausted)
+
+    ;; The following `while' applies `cdd-function' to a single declarator id
+    ;; each time round.  It loops only when CDD-LIST is non-nil.
+    (while
+       (and (not cdd-exhausted)
+            (setq cdd-decl-res (c-forward-declarator cdd-limit)))
+      (setq cdd-next-pos (point)
+           cdd-id-start (car cdd-decl-res)
+           cdd-id-end (cadr cdd-decl-res)
+           cdd-got-func (and (eq (char-after) ?\()
+                         (or (not (c-major-mode-is 'c++-mode))
+                             (not cdd-not-top)
+                             (car (cddr (cddr cdd-decl-res))) ; Id is in
+                                       ; parens, etc.
+                             (save-excursion
+                               (forward-char)
+                               (c-forward-syntactic-ws)
+                               (looking-at "[*&]")))
+                         (not (car (cddr cdd-decl-res)))
+                         (or (not (c-major-mode-is 'c++-mode))
+                             (save-excursion
+                               (let (c-last-identifier-range)
+                                 (forward-char)
+                                 (c-forward-syntactic-ws)
+                                 (catch 'is-function
+                                   (while
+                                       (progn
+                                         (if (eq (char-after) ?\))
+                                             (throw 'is-function t))
+                                         (setq cdd-got-type (c-forward-type))
+                                         (cond
+                                          ((null cdd-got-type)
+                                           (throw 'is-function nil))
+                                          ((not (eq cdd-got-type 'maybe))
+                                           (throw 'is-function t)))
+                                         (c-forward-declarator nil t)
+                                         (eq (char-after) ?,))
+                                     (forward-char)
+                                     (c-forward-syntactic-ws))
+                                   t)))))
+           cdd-got-init (and (cadr (cddr cdd-decl-res))
+                         (char-after)))
+
+      ;; Jump past any initializer or function prototype to see if
+      ;; there's a ',' to continue at.
+      (cond (cdd-got-func
+            ;; Skip a parenthesized initializer (C++) or a function
+            ;; prototype.
+            (if (c-go-list-forward (point) cdd-limit) ; over the parameter 
list.
+                (c-forward-syntactic-ws cdd-limit)
+              (setq cdd-exhausted t))) ; unbalanced parens
+
+           (cdd-got-init       ; "=" sign OR opening "(", "[", or "{"
+            ;; Skip an initializer expression.  If we're at a '='
+            ;; then accept a brace list directly after it to cope
+            ;; with array initializers.  Otherwise stop at braces
+            ;; to avoid going past full function and class blocks.
+            (if (and (if (and (eq cdd-got-init ?=)
+                              (= (c-forward-token-2 1 nil cdd-limit) 0)
+                              (looking-at "{"))
+                         (c-go-list-forward (point) cdd-limit)
+                       t)
+                     ;; FIXME: Should look for c-decl-end markers here;
+                     ;; we might go far into the following declarations
+                     ;; in e.g. ObjC mode (see e.g. methods-4.m).
+                     (c-syntactic-re-search-forward "[;,{]" cdd-limit 'move t))
+                (backward-char)
+              (setq cdd-exhausted t)
+              ))
+
+           (t (c-forward-syntactic-ws cdd-limit)))
+
+      (if cdd-function
+         (funcall cdd-function cdd-id-start cdd-id-end cdd-next-pos
+                  cdd-not-top cdd-got-func cdd-got-init))
+
+      ;; If a ',' is found we set cdd-pos to the next declarator and iterate.
+      (if (and cdd-list (< (point) cdd-limit) (looking-at ","))
+         (progn
+           (when cdd-comma-prop
+             (c-put-char-property (point) 'c-type cdd-comma-prop))
+           (forward-char)
+           (c-forward-syntactic-ws cdd-limit)
+           (setq cdd-pos (point)))
+       (setq cdd-exhausted t)))
+
+    (if (> (point) cdd-pos)
+       t
+      (goto-char cdd-pos)
+      nil)))
+
+;; Macro used inside `c-forward-decl-or-cast-1'.  It ought to be a
+;; defsubst or perhaps even a defun, but it contains lots of free
+;; variables that refer to things inside `c-forward-decl-or-cast-1'.
+(defmacro c-fdoc-shift-type-backward (&optional short)
+  ;; `c-forward-decl-or-cast-1' can consume an arbitrary length list
+  ;; of types when parsing a declaration, which means that it
+  ;; sometimes consumes the identifier in the declaration as a type.
+  ;; This is used to "backtrack" and make the last type be treated as
+  ;; an identifier instead.
+  `(progn
+     ,(unless short
+       ;; These identifiers are bound only in the inner let.
+       '(setq identifier-type at-type
+              identifier-start type-start
+              got-parens nil
+              got-identifier t
+              got-suffix t
+              got-suffix-after-parens id-start
+              paren-depth 0))
+
+     (if (setq at-type (if (eq backup-at-type 'prefix)
+                          t
+                        backup-at-type))
+        (setq type-start backup-type-start
+              id-start backup-id-start)
+       (setq type-start start-pos
+            id-start start-pos))
+
+     ;; When these flags already are set we've found specifiers that
+     ;; unconditionally signal these attributes - backtracking doesn't
+     ;; change that.  So keep them set in that case.
+     (or at-type-decl
+        (setq at-type-decl backup-at-type-decl))
+     (or maybe-typeless
+        (setq maybe-typeless backup-maybe-typeless))
+
+     ,(unless short
+       ;; This identifier is bound only in the inner let.
+       '(setq start id-start))))
+
 (defun c-forward-decl-or-cast-1 (preceding-token-end context last-cast-end)
   ;; Move forward over a declaration or a cast if at the start of one.
   ;; The point is assumed to be at the start of some token.  Nil is
@@ -8550,6 +9039,8 @@ comment at the start of cc-engine.el for more info."
          got-parens
          ;; True if there is an identifier in the declarator.
          got-identifier
+         ;; True if we find a number where an identifier was expected.
+         got-number
          ;; True if there's a non-close-paren match of
          ;; `c-type-decl-suffix-key'.
          got-suffix
@@ -8627,7 +9118,9 @@ comment at the start of cc-engine.el for more info."
          (and (looking-at c-identifier-start)
               (setq pos (point))
               (setq got-identifier (c-forward-name))
-              (setq name-start pos)))
+              (setq name-start pos))
+         (when (looking-at "[0-9]")
+           (setq got-number t))) ; We've probably got an arithmetic expression.
 
       ;; Skip over type decl suffix operators and trailing noise macros.
       (while
@@ -8643,7 +9136,16 @@ comment at the start of cc-engine.el for more info."
                 (not (and (c-major-mode-is 'c-mode)
                           (not got-prefix)
                           (or (eq context 'top) make-top)
-                          (eq (char-after) ?\)))))
+                          (eq (char-after) ?\))
+                          (or (memq at-type '(nil maybe))
+                              (not got-identifier)
+                              (save-excursion
+                                (goto-char after-paren-pos)
+                                (c-forward-syntactic-ws)
+                                ;; Prevent the symbol being recorded as a type.
+                                (let (c-record-type-identifiers)
+                                  (not (memq (c-forward-type)
+                                             '(nil maybe)))))))))
            (if (eq (char-after) ?\))
                (when (> paren-depth 0)
                  (setq paren-depth (1- paren-depth))
@@ -8754,7 +9256,7 @@ comment at the start of cc-engine.el for more info."
 
         (setq at-decl-end
               (looking-at (cond ((eq context '<>) "[,>]")
-                                ((not (memq context '(nil top))) "[,\)]")
+                                ((not (memq context '(nil top))) "[,)]")
                                 (t "[,;]"))))
 
         ;; Now we've collected info about various characteristics of
@@ -9101,7 +9603,7 @@ comment at the start of cc-engine.el for more info."
 
           ;; CASE 18
           (when (and (not (memq context '(nil top)))
-                     (or got-prefix
+                     (or (and got-prefix (not got-number))
                          (and (eq context 'decl)
                               (not c-recognize-paren-inits)
                               (or got-parens got-suffix))))
@@ -9655,7 +10157,7 @@ comment at the start of cc-engine.el for more info."
 
   (let ((beg (point)) id-start)
     (and
-     (eq (c-beginning-of-statement-1 lim) 'same)
+     (eq (c-beginning-of-statement-1 lim nil nil nil t) 'same)
 
      (not (and (c-major-mode-is 'objc-mode)
               (c-forward-objc-directive)))
@@ -10107,7 +10609,7 @@ comment at the start of cc-engine.el for more info."
                          ;; Check for `c-opt-block-decls-with-vars-key'
                          ;; before the first paren.
                          (c-syntactic-re-search-forward
-                          (concat "[;=\(\[{]\\|\\("
+                          (concat "[;=([{]\\|\\("
                                   c-opt-block-decls-with-vars-key
                                   "\\)")
                           lim t t t)
@@ -10115,7 +10617,7 @@ comment at the start of cc-engine.el for more info."
                          (not (eq (char-before) ?_))
                          ;; Check that the first following paren is
                          ;; the block.
-                         (c-syntactic-re-search-forward "[;=\(\[{]"
+                         (c-syntactic-re-search-forward "[;=([{]"
                                                         lim t t t)
                          (eq (char-before) ?{))))))
            ;; The declaration doesn't have any of the
@@ -10483,7 +10985,8 @@ comment at the start of cc-engine.el for more info."
                      (eq (char-after) ?\())
                 (setq braceassignp 'c++-noassign
                       in-paren 'in-paren))
-               ((looking-at c-pre-id-bracelist-key))
+               ((looking-at c-pre-id-bracelist-key)
+                (setq braceassignp nil))
                ((looking-at c-return-key))
                ((and (looking-at c-symbol-start)
                      (not (looking-at c-keywords-regexp)))
@@ -10525,6 +11028,8 @@ comment at the start of cc-engine.el for more info."
 
       (setq pos (point))
       (cond
+       ((not braceassignp)
+       nil)
        ((and after-type-id-pos
             (goto-char after-type-id-pos)
             (setq res (c-back-over-member-initializers))
@@ -10599,14 +11104,20 @@ comment at the start of cc-engine.el for more info."
                                     ))))
                           nil)
                          (t t))))))
-         (when (and (eq braceassignp 'dontknow)
-                    (/= (c-backward-token-2 1 t lim) 0))
-           (if (save-excursion
-                 (and c-has-compound-literals
-                      (eq (c-backward-token-2 1 nil lim) 0)
-                      (eq (char-after) ?\()))
-               (setq braceassignp t)
-             (setq braceassignp nil))))
+         (when (eq braceassignp 'dontknow)
+           (cond ((and
+                   (not (eq (char-after) ?,))
+                   (save-excursion
+                     (c-backward-syntactic-ws)
+                     (eq (char-before) ?})))
+                  (setq braceassignp nil))
+                 ((/= (c-backward-token-2 1 t lim) 0)
+                  (if (save-excursion
+                        (and c-has-compound-literals
+                             (eq (c-backward-token-2 1 nil lim) 0)
+                             (eq (char-after) ?\()))
+                      (setq braceassignp t)
+                    (setq braceassignp nil))))))
 
        (cond
         (braceassignp
@@ -10638,9 +11149,14 @@ comment at the start of cc-engine.el for more info."
                    (and (consp res)
                         (eq (car res) after-type-id-pos))))))
          (cons bufpos (or in-paren inexpr-brace-list)))
-        ((eq (char-after) ?\;)
-         ;; Brace lists can't contain a semicolon, so we're done.
-         ;; (setq containing-sexp nil)
+        ((or (eq (char-after) ?\;)
+             ;; Brace lists can't contain a semicolon, so we're done.
+             (save-excursion
+               (c-backward-syntactic-ws)
+               (eq (char-before) ?}))
+             ;; They also can't contain a bare }, which is probably the end
+             ;; of a function.
+             )
          nil)
         ((and (setq macro-start (point))
               (c-forward-to-cpp-define-body)
@@ -10662,12 +11178,17 @@ comment at the start of cc-engine.el for more info."
       )))
 
 (defun c-inside-bracelist-p (containing-sexp paren-state accept-in-paren)
-  ;; return the buffer position of the beginning of the brace list
-  ;; statement if we're inside a brace list, otherwise return nil.
-  ;; CONTAINING-SEXP is the buffer pos of the innermost containing
-  ;; paren.  PAREN-STATE is the remainder of the state of enclosing
-  ;; braces.  ACCEPT-IN-PAREN is non-nil iff we will accept as a brace
-  ;; list a brace directly enclosed in a parenthesis.
+  ;; return the buffer position of the beginning of the brace list statement
+  ;; if CONTAINING-SEXP is inside a brace list, otherwise return nil.
+  ;;
+  ;; CONTAINING-SEXP is the buffer pos of the innermost containing paren.  NO
+  ;; IT ISN'T!!!  [This function is badly designed, and probably needs
+  ;; reformulating without its first argument, and the critical position being
+  ;; at point.]
+  ;;
+  ;; PAREN-STATE is the remainder of the state of enclosing braces.
+  ;; ACCEPT-IN-PAREN is non-nil iff we will accept as a brace list a brace
+  ;; directly enclosed in a parenthesis.
   ;;
   ;; The "brace list" here is recognized solely by its context, not by
   ;; its contents.
@@ -10787,7 +11308,8 @@ comment at the start of cc-engine.el for more info."
 (defun c-looking-at-statement-block ()
   ;; Point is at an opening brace.  If this is a statement block (i.e. the
   ;; elements in the block are terminated by semicolons, or the block is
-  ;; empty, or the block contains a keyword) return t.  Otherwise, return nil.
+  ;; empty, or the block contains a keyword) return non-nil.  Otherwise,
+  ;; return nil.
   (let ((here (point)))
     (prog1
        (if (c-go-list-forward)
@@ -11291,7 +11813,7 @@ comment at the start of cc-engine.el for more info."
 
            (if (and (eq step-type 'same)
                     (/= paren-pos (point)))
-               (let (inexpr)
+               (let (inexpr bspec)
                  (cond
                   ((save-excursion
                      (goto-char paren-pos)
@@ -11313,6 +11835,13 @@ comment at the start of cc-engine.el for more info."
                          (c-looking-at-statement-block))
                        (c-add-syntax 'defun-block-intro nil)
                      (c-add-syntax 'brace-list-intro nil)))
+                  ((save-excursion
+                     (goto-char paren-pos)
+                     (setq bspec (c-looking-at-or-maybe-in-bracelist
+                                  containing-sexp containing-sexp))
+                     (and (consp bspec)
+                          (eq (cdr bspec) 'in-paren)))
+                   (c-add-syntax 'brace-list-intro (car bspec)))
                   (t (c-add-syntax 'defun-block-intro nil))))
 
              (c-add-syntax 'statement-block-intro nil)))
@@ -12237,6 +12766,13 @@ comment at the start of cc-engine.el for more info."
                        (if (eq (char-after) ?<)
                            (zerop (c-forward-token-2 1 t indent-point))
                          t)
+                       (progn
+                         (while
+                             (and
+                              (< (point) indent-point)
+                              (looking-at c-class-id-suffix-ws-ids-key)
+                              (zerop (c-forward-token-2 1 nil indent-point))))
+                         t)
                        (eq (char-after) ?:))))
            (goto-char placeholder)
            (c-add-syntax 'inher-cont (c-point 'boi)))
@@ -13177,7 +13713,7 @@ Cannot combine absolute offsets %S and %S in `add' 
method"
           nil))))
 
     (if (or (null res) (integerp res)
-           (and (vectorp res) (= (length res) 1) (integerp (aref res 0))))
+           (and (vectorp res) (>= (length res) 1) (integerp (aref res 0))))
        res
       (c-benign-error "Error evaluating offset %S for %s: Got invalid value %S"
                      offset symbol res)
@@ -13200,12 +13736,11 @@ Cannot combine absolute offsets %S and %S in `add' 
method"
       (if c-strict-syntax-p
          (c-benign-error "No offset found for syntactic symbol %s" symbol))
       (setq offset 0))
-    (if (vectorp offset)
-       offset
-      (or (and (numberp offset) offset)
-         (and (symbolp offset) (symbol-value offset))
-         0))
-    ))
+    (cond
+     ((or (vectorp offset) (numberp offset))
+      offset)
+     ((and (symbolp offset) (symbol-value offset)))
+     (t 0))))
 
 (defun c-get-offset (langelem)
   ;; This is a compatibility wrapper for `c-calc-offset' in case
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index a216061..831fa30 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -1,6 +1,6 @@
 ;;; cc-fonts.el --- font lock support for CC Mode
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Authors:    2003- Alan Mackenzie
 ;;             2002- Martin Stjernholm
@@ -880,48 +880,51 @@ casts and declarations are fontified.  Used on level 2 
and higher."
   (when (bobp)
     (c-clear-found-types))
 
-  ;; Clear the c-type char properties which mark the region, to recalculate
-  ;; them properly.  The most interesting properties are those put on the
-  ;; closest token before the region.
-  (save-excursion
-    (let ((pos (point)))
-      (c-backward-syntactic-ws)
-      (c-clear-char-properties
-       (if (and (not (bobp))
-               (memq (c-get-char-property (1- (point)) 'c-type)
-                     '(c-decl-arg-start
-                       c-decl-end
-                       c-decl-id-start
-                       c-decl-type-start)))
-          (1- (point))
-        pos)
-       limit 'c-type)))
-
-  ;; Update `c-state-cache' to the beginning of the region.  This will
-  ;; make `c-beginning-of-syntax' go faster when it's used later on,
-  ;; and it's near the point most of the time.
-  (c-parse-state)
-
-  ;; Check if the fontified region starts inside a declarator list so
-  ;; that `c-font-lock-declarators' should be called at the start.
-  ;; The declared identifiers are font-locked correctly as types, if
-  ;; that is what they are.
-  (let ((prop (save-excursion
-               (c-backward-syntactic-ws)
-               (unless (bobp)
-                 (c-get-char-property (1- (point)) 'c-type)))))
-    (when (memq prop '(c-decl-id-start c-decl-type-start))
-      (c-forward-syntactic-ws limit)
-      (c-font-lock-declarators limit t (eq prop 'c-decl-type-start)
-                              (not (c-bs-at-toplevel-p (point))))))
-
-  (setq c-font-lock-context ;; (c-guess-font-lock-context)
-       (save-excursion
-         (if (and c-cpp-expr-intro-re
-                  (c-beginning-of-macro)
-                  (looking-at c-cpp-expr-intro-re))
-             'in-cpp-expr)))
-  nil)
+  (c-skip-comments-and-strings limit)
+  (when (< (point) limit)
+
+    ;; Clear the c-type char properties which mark the region, to recalculate
+    ;; them properly.  The most interesting properties are those put on the
+    ;; closest token before the region.
+    (save-excursion
+      (let ((pos (point)))
+       (c-backward-syntactic-ws)
+       (c-clear-char-properties
+        (if (and (not (bobp))
+                 (memq (c-get-char-property (1- (point)) 'c-type)
+                       '(c-decl-arg-start
+                         c-decl-end
+                         c-decl-id-start
+                         c-decl-type-start)))
+            (1- (point))
+          pos)
+        limit 'c-type)))
+
+    ;; Update `c-state-cache' to the beginning of the region.  This will
+    ;; make `c-beginning-of-syntax' go faster when it's used later on,
+    ;; and it's near the point most of the time.
+    (c-parse-state)
+
+    ;; Check if the fontified region starts inside a declarator list so
+    ;; that `c-font-lock-declarators' should be called at the start.
+    ;; The declared identifiers are font-locked correctly as types, if
+    ;; that is what they are.
+    (let ((prop (save-excursion
+                 (c-backward-syntactic-ws)
+                 (unless (bobp)
+                   (c-get-char-property (1- (point)) 'c-type)))))
+      (when (memq prop '(c-decl-id-start c-decl-type-start))
+       (c-forward-syntactic-ws limit)
+       (c-font-lock-declarators limit t (eq prop 'c-decl-type-start)
+                                (not (c-bs-at-toplevel-p (point))))))
+
+    (setq c-font-lock-context ;; (c-guess-font-lock-context)
+         (save-excursion
+           (if (and c-cpp-expr-intro-re
+                    (c-beginning-of-macro)
+                    (looking-at c-cpp-expr-intro-re))
+               'in-cpp-expr)))
+    nil))
 
 (defun c-font-lock-<>-arglists (limit)
   ;; This function will be called from font-lock for a region bounded by POINT
@@ -936,73 +939,76 @@ casts and declarations are fontified.  Used on level 2 
and higher."
   ;;
   ;; This function might do hidden buffer changes.
 
-  (let (;; The font-lock package in Emacs is known to clobber
-       ;; `parse-sexp-lookup-properties' (when it exists).
-       (parse-sexp-lookup-properties
-        (cc-eval-when-compile
-          (boundp 'parse-sexp-lookup-properties)))
-       (c-parse-and-markup-<>-arglists t)
-       c-restricted-<>-arglists
-       id-start id-end id-face pos kwd-sym)
+  (c-skip-comments-and-strings limit)
+  (when (< (point) limit)
 
-    (while (and (< (point) limit)
-               (re-search-forward c-opt-<>-arglist-start limit t))
+    (let (;; The font-lock package in Emacs is known to clobber
+         ;; `parse-sexp-lookup-properties' (when it exists).
+         (parse-sexp-lookup-properties
+          (cc-eval-when-compile
+            (boundp 'parse-sexp-lookup-properties)))
+         (c-parse-and-markup-<>-arglists t)
+         c-restricted-<>-arglists
+         id-start id-end id-face pos kwd-sym)
 
-      (setq id-start (match-beginning 1)
-           id-end (match-end 1)
-           pos (point))
+      (while (and (< (point) limit)
+                 (re-search-forward c-opt-<>-arglist-start limit t))
 
-      (goto-char id-start)
-      (unless (c-skip-comments-and-strings limit)
-       (setq kwd-sym nil
-             c-restricted-<>-arglists nil
-             id-face (get-text-property id-start 'face))
-
-       (if (cond
-            ((eq id-face 'font-lock-type-face)
-             ;; The identifier got the type face so it has already been
-             ;; handled in `c-font-lock-declarations'.
-             nil)
-
-            ((eq id-face 'font-lock-keyword-face)
-             (when (looking-at c-opt-<>-sexp-key)
-               ;; There's a special keyword before the "<" that tells
-               ;; that it's an angle bracket arglist.
-               (setq kwd-sym (c-keyword-sym (match-string 1)))))
-
-            (t
-             ;; There's a normal identifier before the "<".  If we're not in
-             ;; a declaration context then we set `c-restricted-<>-arglists'
-             ;; to avoid recognizing templates in function calls like "foo (a
-             ;; < b, c > d)".
-             (c-backward-syntactic-ws)
-             (when (and (memq (char-before) '(?\( ?,))
-                        (not (eq (get-text-property (1- (point)) 'c-type)
-                                 'c-decl-arg-start)))
-               (setq c-restricted-<>-arglists t))
-             t))
+       (setq id-start (match-beginning 1)
+             id-end (match-end 1)
+             pos (point))
 
-           (progn
-             (goto-char (1- pos))
-             ;; Check for comment/string both at the identifier and
-             ;; at the "<".
-             (unless (c-skip-comments-and-strings limit)
-
-               (c-fontify-types-and-refs ()
-                 (when (c-forward-<>-arglist (c-keyword-member
-                                              kwd-sym 'c-<>-type-kwds))
-                   (when (and c-opt-identifier-concat-key
-                              (not (get-text-property id-start 'face)))
-                     (c-forward-syntactic-ws)
-                     (cond ((looking-at c-opt-identifier-concat-key)
-                            (c-put-font-lock-face id-start id-end
-                                               c-reference-face-name))
-                           ((eq (char-after) ?\())
-                           (t (c-put-font-lock-face id-start id-end
-                                             'font-lock-type-face))))))
-
-               (goto-char pos)))
-         (goto-char pos)))))
+       (goto-char id-start)
+       (unless (c-skip-comments-and-strings limit)
+         (setq kwd-sym nil
+               c-restricted-<>-arglists nil
+               id-face (get-text-property id-start 'face))
+
+         (if (cond
+              ((eq id-face 'font-lock-type-face)
+               ;; The identifier got the type face so it has already been
+               ;; handled in `c-font-lock-declarations'.
+               nil)
+
+              ((eq id-face 'font-lock-keyword-face)
+               (when (looking-at c-opt-<>-sexp-key)
+                 ;; There's a special keyword before the "<" that tells
+                 ;; that it's an angle bracket arglist.
+                 (setq kwd-sym (c-keyword-sym (match-string 1)))))
+
+              (t
+               ;; There's a normal identifier before the "<".  If we're not in
+               ;; a declaration context then we set `c-restricted-<>-arglists'
+               ;; to avoid recognizing templates in function calls like "foo (a
+               ;; < b, c > d)".
+               (c-backward-syntactic-ws)
+               (when (and (memq (char-before) '(?\( ?,))
+                          (not (eq (get-text-property (1- (point)) 'c-type)
+                                   'c-decl-arg-start)))
+                 (setq c-restricted-<>-arglists t))
+               t))
+
+             (progn
+               (goto-char (1- pos))
+               ;; Check for comment/string both at the identifier and
+               ;; at the "<".
+               (unless (c-skip-comments-and-strings limit)
+
+                 (c-fontify-types-and-refs ()
+                   (when (c-forward-<>-arglist (c-keyword-member
+                                                kwd-sym 'c-<>-type-kwds))
+                     (when (and c-opt-identifier-concat-key
+                                (not (get-text-property id-start 'face)))
+                       (c-forward-syntactic-ws)
+                       (cond ((looking-at c-opt-identifier-concat-key)
+                              (c-put-font-lock-face id-start id-end
+                                                    c-reference-face-name))
+                             ((eq (char-after) ?\())
+                             (t (c-put-font-lock-face id-start id-end
+                                                      
'font-lock-type-face))))))
+
+                 (goto-char pos)))
+           (goto-char pos))))))
   nil)
 
 (defun c-font-lock-declarators (limit list types not-top
@@ -1032,114 +1038,41 @@ casts and declarations are fontified.  Used on level 2 
and higher."
 
   ;;(message "c-font-lock-declarators from %s to %s" (point) limit)
   (c-fontify-types-and-refs
-      ((pos (point)) next-pos id-start
-       decl-res
-       id-face got-type got-init
-       c-last-identifier-range
-       (separator-prop (if types 'c-decl-type-start 'c-decl-id-start)))
-
-    ;; The following `while' fontifies a single declarator id each time round.
-    ;; It loops only when LIST is non-nil.
-    (while
-       (and pos (setq decl-res (c-forward-declarator)))
-      (setq next-pos (point)
-           id-start (car decl-res)
-           id-face (if (and (eq (char-after) ?\()
-                            (or (not (c-major-mode-is 'c++-mode))
-                                (not not-top)
-                                (car (cddr (cddr decl-res))) ; Id is in
-                                                             ; parens, etc.
-                                (save-excursion
-                                  (forward-char)
-                                  (c-forward-syntactic-ws)
-                                  (looking-at "[*&]")))
-                            (not (car (cddr decl-res)))
-                            (or (not (c-major-mode-is 'c++-mode))
-                                (save-excursion
-                                  (let (c-last-identifier-range)
-                                    (forward-char)
-                                    (c-forward-syntactic-ws)
-                                    (catch 'is-function
-                                      (while
-                                          (progn
-                                            (if (eq (char-after) ?\))
-                                                (throw 'is-function t))
-                                            (setq got-type (c-forward-type))
-                                            (cond
-                                             ((null got-type)
-                                              (throw 'is-function nil))
-                                             ((not (eq got-type 'maybe))
-                                              (throw 'is-function t)))
-                                            (c-forward-declarator nil t)
-                                            (eq (char-after) ?,))
-                                        (forward-char)
-                                        (c-forward-syntactic-ws))
-                                      t)))))
-                       'font-lock-function-name-face
-                     'font-lock-variable-name-face)
-           got-init (and (cadr (cddr decl-res)) ; got-init
-                         (char-after)))
-
-      (if types
-         ;; Register and fontify the identifier as a type.
-         (let ((c-promote-possible-types t))
-           (goto-char id-start)
-           (c-forward-type))
-       ;; Fontify the last symbol in the identifier if it isn't fontified
-       ;; already.  The check is necessary only in certain cases where this
-       ;; function is used "sloppily", e.g. in `c-simple-decl-matchers'.
-       (when (and c-last-identifier-range
-                  (not (get-text-property (car c-last-identifier-range)
-                                          'face)))
-         (c-put-font-lock-face (car c-last-identifier-range)
-                               (cdr c-last-identifier-range)
-                               id-face)))
-
-      (goto-char next-pos)
-      (setq pos nil)         ; So as to terminate the enclosing `while' form.
-      (if (and template-class
-              (eq got-init ?=) ; C++ "<class X = Y>"?
-              (c-forward-token-2 1 nil limit) ; Over "="
-              (let ((c-promote-possible-types t))
-                (c-forward-type t)))          ; Over "Y"
-         (setq list nil)) ; Shouldn't be needed.  We can't have a list, here.
-
-      (when list
-       ;; Jump past any initializer or function prototype to see if
-       ;; there's a ',' to continue at.
-       (cond ((eq id-face 'font-lock-function-name-face)
-              ;; Skip a parenthesized initializer (C++) or a function
-              ;; prototype.
-              (if (c-safe (c-forward-sexp 1) t) ; over the parameter list.
-                  (c-forward-syntactic-ws limit)
-                (goto-char limit)))    ; unbalanced parens
-
-             (got-init ; "=" sign OR opening "(", "[", or "{"
-              ;; Skip an initializer expression.  If we're at a '='
-              ;; then accept a brace list directly after it to cope
-              ;; with array initializers.  Otherwise stop at braces
-              ;; to avoid going past full function and class blocks.
-              (and (if (and (eq got-init ?=)
-                            (= (c-forward-token-2 1 nil limit) 0)
-                            (looking-at "{"))
-                       (c-safe (c-forward-sexp) t) ; over { .... }
-                     t)
-                   (< (point) limit)
-                   ;; FIXME: Should look for c-decl-end markers here;
-                   ;; we might go far into the following declarations
-                   ;; in e.g. ObjC mode (see e.g. methods-4.m).
-                   (c-syntactic-re-search-forward "[;,{]" limit 'move t)
-                   (backward-char)))
-
-             (t (c-forward-syntactic-ws limit)))
-
-       ;; If a ',' is found we set pos to the next declarator and iterate.
-       (when (and (< (point) limit) (looking-at ","))
-         (c-put-char-property (point) 'c-type separator-prop)
-         (forward-char)
-         (c-forward-syntactic-ws limit)
-         (setq pos (point))))))     ; acts to make the `while' form continue.
-  nil)
+      ()
+    (c-do-declarators
+     limit list not-top
+     (if types 'c-decl-type-start 'c-decl-id-start)
+     (lambda (id-start id-end end-pos not-top is-function init-char)
+       (if types
+          ;; Register and fontify the identifier as a type.
+          (let ((c-promote-possible-types t))
+            (goto-char id-start)
+            (c-forward-type))
+        ;; The following doesn't work properly (yet, 2018-09-22).
+        ;; (c-put-font-lock-face id-start id-end
+        ;;                    (if is-function
+        ;;                        'font-lock-function-name-face
+        ;;                      'font-lock-variable-name-face))
+        (when (and c-last-identifier-range
+                   (not (get-text-property (car c-last-identifier-range)
+                                           'face)))
+          ;; We use `c-last-identifier-range' rather than `id-start' and
+          ;; `id-end', since the latter two can be erroneous.  E.g. in
+          ;; "~Foo", `id-start' is at the tilde.  This is a bug in
+          ;; `c-forward-declarator'.
+          (c-put-font-lock-face (car c-last-identifier-range)
+                                (cdr c-last-identifier-range)
+                                (if is-function
+                                    'font-lock-function-name-face
+                                  'font-lock-variable-name-face))))
+       (and template-class
+           (eq init-char ?=)           ; C++ "<class X = Y>"?
+           (progn
+             (goto-char end-pos)
+             (c-forward-token-2 1 nil limit) ; Over "="
+             (let ((c-promote-possible-types t))
+               (c-forward-type t))))))
+    nil))
 
 (defun c-get-fontification-context (match-pos not-front-decl &optional toplev)
   ;; Return a cons (CONTEXT . RESTRICTED-<>-ARGLISTS) for MATCH-POS.
@@ -1250,12 +1183,14 @@ casts and declarations are fontified.  Used on level 2 
and higher."
           (c-put-char-property (1- match-pos)
                                'c-type 'c-decl-arg-start)
           (cons 'decl nil))
-         ;; Got an open paren preceded by an arith operator.
+         ;; Got (an) open paren(s) preceded by an arith operator.
          ((and (eq (char-before match-pos) ?\()
                (save-excursion
                  (goto-char match-pos)
-                 (and (zerop (c-backward-token-2 2))
-                      (looking-at c-arithmetic-op-regexp))))
+                 (while
+                     (and (zerop (c-backward-token-2))
+                          (eq (char-after) ?\()))
+                 (looking-at c-arithmetic-op-regexp)))
           (cons nil nil))
          ;; In a C++ member initialization list.
          ((and (eq (char-before match-pos) ?,)
@@ -1382,227 +1317,229 @@ casts and declarations are fontified.  Used on level 
2 and higher."
   ;; This function might do hidden buffer changes.
 
   ;;(message "c-font-lock-declarations search from %s to %s" (point) limit)
+  (c-skip-comments-and-strings limit)
+  (when (< (point) limit)
+  
+    (save-restriction
+      (let (;; The position where `c-find-decl-spots' last stopped.
+           start-pos
+           ;; o - 'decl if we're in an arglist containing declarations
+           ;;   (but if `c-recognize-paren-inits' is set it might also be
+           ;;   an initializer arglist);
+           ;; o - '<> if the arglist is of angle bracket type;
+           ;; o - 'arglist if it's some other arglist;
+           ;; o - nil, if not in an arglist at all.  This includes the
+           ;;   parenthesized condition which follows "if", "while", etc.
+           context
+           ;; A list of starting positions of possible type declarations, or of
+           ;; the typedef preceding one, if any.
+           last-cast-end
+           ;; The result from `c-forward-decl-or-cast-1'.
+           decl-or-cast
+           ;; The maximum of the end positions of all the checked type
+           ;; decl expressions in the successfully identified
+           ;; declarations.  The position might be either before or
+           ;; after the syntactic whitespace following the last token
+           ;; in the type decl expression.
+           (max-type-decl-end 0)
+           ;; Same as `max-type-decl-*', but used when we're before
+           ;; `token-pos'.
+           (max-type-decl-end-before-token 0)
+           ;; End of <..> construct which has had c-<>-arg-sep c-type
+           ;; properties set within it.
+           (max-<>-end 0)
+           ;; Set according to the context to direct the heuristics for
+           ;; recognizing C++ templates.
+           c-restricted-<>-arglists
+           ;; Turn on recording of identifier ranges in
+           ;; `c-forward-decl-or-cast-1' and `c-forward-label' for
+           ;; later fontification.
+           (c-record-type-identifiers t)
+           label-type
+           c-record-ref-identifiers
+           ;; Make `c-forward-type' calls mark up template arglists if
+           ;; it finds any.  That's necessary so that we later will
+           ;; stop inside them to fontify types there.
+           (c-parse-and-markup-<>-arglists t)
+           ;; The font-lock package in Emacs is known to clobber
+           ;; `parse-sexp-lookup-properties' (when it exists).
+           (parse-sexp-lookup-properties
+            (cc-eval-when-compile
+              (boundp 'parse-sexp-lookup-properties))
+            ))
+
+       ;; Below we fontify a whole declaration even when it crosses the limit,
+       ;; to avoid gaps when jit/lazy-lock fontifies the file a block at a
+       ;; time.  That is however annoying during editing, e.g. the following is
+       ;; a common situation while the first line is being written:
+       ;;
+       ;;     my_variable
+       ;;     some_other_variable = 0;
+       ;;
+       ;; font-lock will put the limit at the beginning of the second line
+       ;; here, and if we go past it we'll fontify "my_variable" as a type and
+       ;; "some_other_variable" as an identifier, and the latter will not
+       ;; correct itself until the second line is changed.  To avoid that we
+       ;; narrow to the limit if the region to fontify is a single line.
+       (if (<= limit (c-point 'bonl))
+           (narrow-to-region
+            (point-min)
+            (save-excursion
+              ;; Narrow after any operator chars following the limit though,
+              ;; since those characters can be useful in recognizing a
+              ;; declaration (in particular the '{' that opens a function body
+              ;; after the header).
+              (goto-char limit)
+              (skip-chars-forward c-nonsymbol-chars)
+              (point))))
+
+       (c-find-decl-spots
+        limit
+        c-decl-start-re
+        (eval c-maybe-decl-faces)
+
+        (lambda (match-pos inside-macro &optional toplev)
+          ;; Note to maintainers: don't use `limit' inside this lambda form;
+          ;; c-find-decl-spots sometimes narrows to less than `limit'.
+          (setq start-pos (point))
+          (when
+              ;; The result of the form below is true when we don't recognize a
+              ;; declaration or cast, and we don't recognize a "non-decl",
+              ;; typically a brace list.
+              (if (or (and (eq (get-text-property (point) 'face)
+                               'font-lock-keyword-face)
+                           (looking-at c-not-decl-init-keywords))
+                      (and c-macro-with-semi-re
+                           (looking-at c-macro-with-semi-re))) ; 2008-11-04
+                  ;; Don't do anything more if we're looking at a keyword that
+                  ;; can't start a declaration.
+                  t
+
+                ;; Set `context' and `c-restricted-<>-arglists'.  Look for
+                ;; "<" for the sake of C++-style template arglists.
+                ;; Ignore "(" when it's part of a control flow construct
+                ;; (e.g. "for (").
+                (let ((got-context
+                       (c-get-fontification-context
+                        match-pos
+                        (< match-pos (if inside-macro
+                                         max-type-decl-end-before-token
+                                       max-type-decl-end))
+                        toplev)))
+                  (setq context (car got-context)
+                        c-restricted-<>-arglists (cdr got-context)))
+
+                ;; Check we haven't missed a preceding "typedef".
+                (when (not (looking-at c-typedef-key))
+                  (c-backward-syntactic-ws)
+                  (c-backward-token-2)
+                  (or (looking-at c-typedef-key)
+                      (goto-char start-pos)))
+
+                ;; In QT, "more" is an irritating keyword that expands to 
nothing.
+                ;; We skip over it to prevent recognition of "more slots: 
<symbol>"
+                ;; as a bitfield declaration.
+                (when (and (c-major-mode-is 'c++-mode)
+                           (looking-at
+                            (concat "\\(more\\)\\([^" c-symbol-chars 
"]\\|$\\)")))
+                  (goto-char (match-end 1))
+                  (c-forward-syntactic-ws))
 
-  (save-restriction
-    (let (;; The position where `c-find-decl-spots' last stopped.
-         start-pos
-         ;; o - 'decl if we're in an arglist containing declarations
-         ;;   (but if `c-recognize-paren-inits' is set it might also be
-         ;;   an initializer arglist);
-         ;; o - '<> if the arglist is of angle bracket type;
-         ;; o - 'arglist if it's some other arglist;
-         ;; o - nil, if not in an arglist at all.  This includes the
-         ;;   parenthesized condition which follows "if", "while", etc.
-         context
-         ;; A list of starting positions of possible type declarations, or of
-         ;; the typedef preceding one, if any.
-         last-cast-end
-         ;; The result from `c-forward-decl-or-cast-1'.
-         decl-or-cast
-         ;; The maximum of the end positions of all the checked type
-         ;; decl expressions in the successfully identified
-         ;; declarations.  The position might be either before or
-         ;; after the syntactic whitespace following the last token
-         ;; in the type decl expression.
-         (max-type-decl-end 0)
-         ;; Same as `max-type-decl-*', but used when we're before
-         ;; `token-pos'.
-         (max-type-decl-end-before-token 0)
-         ;; End of <..> construct which has had c-<>-arg-sep c-type
-         ;; properties set within it.
-         (max-<>-end 0)
-         ;; Set according to the context to direct the heuristics for
-         ;; recognizing C++ templates.
-         c-restricted-<>-arglists
-         ;; Turn on recording of identifier ranges in
-         ;; `c-forward-decl-or-cast-1' and `c-forward-label' for
-         ;; later fontification.
-         (c-record-type-identifiers t)
-         label-type
-         c-record-ref-identifiers
-         ;; Make `c-forward-type' calls mark up template arglists if
-         ;; it finds any.  That's necessary so that we later will
-         ;; stop inside them to fontify types there.
-         (c-parse-and-markup-<>-arglists t)
-         ;; The font-lock package in Emacs is known to clobber
-         ;; `parse-sexp-lookup-properties' (when it exists).
-         (parse-sexp-lookup-properties
-          (cc-eval-when-compile
-            (boundp 'parse-sexp-lookup-properties))
-          ))
-
-      ;; Below we fontify a whole declaration even when it crosses the limit,
-      ;; to avoid gaps when jit/lazy-lock fontifies the file a block at a
-      ;; time.  That is however annoying during editing, e.g. the following is
-      ;; a common situation while the first line is being written:
-      ;;
-      ;;     my_variable
-      ;;     some_other_variable = 0;
-      ;;
-      ;; font-lock will put the limit at the beginning of the second line
-      ;; here, and if we go past it we'll fontify "my_variable" as a type and
-      ;; "some_other_variable" as an identifier, and the latter will not
-      ;; correct itself until the second line is changed.  To avoid that we
-      ;; narrow to the limit if the region to fontify is a single line.
-      (if (<= limit (c-point 'bonl))
-         (narrow-to-region
-          (point-min)
-          (save-excursion
-            ;; Narrow after any operator chars following the limit though,
-            ;; since those characters can be useful in recognizing a
-            ;; declaration (in particular the '{' that opens a function body
-            ;; after the header).
-            (goto-char limit)
-            (skip-chars-forward c-nonsymbol-chars)
-            (point))))
-
-      (c-find-decl-spots
-       limit
-       c-decl-start-re
-       (eval c-maybe-decl-faces)
-
-       (lambda (match-pos inside-macro &optional toplev)
-        ;; Note to maintainers: don't use `limit' inside this lambda form;
-        ;; c-find-decl-spots sometimes narrows to less than `limit'.
-        (setq start-pos (point))
-        (when
-         ;; The result of the form below is true when we don't recognize a
-         ;; declaration or cast, and we don't recognize a "non-decl",
-         ;; typically a brace list.
-         (if (or (and (eq (get-text-property (point) 'face)
-                          'font-lock-keyword-face)
-                      (looking-at c-not-decl-init-keywords))
-                 (and c-macro-with-semi-re
-                      (looking-at c-macro-with-semi-re))) ; 2008-11-04
-             ;; Don't do anything more if we're looking at a keyword that
-             ;; can't start a declaration.
-             t
-
-           ;; Set `context' and `c-restricted-<>-arglists'.  Look for
-           ;; "<" for the sake of C++-style template arglists.
-           ;; Ignore "(" when it's part of a control flow construct
-           ;; (e.g. "for (").
-           (let ((got-context
-                  (c-get-fontification-context
-                   match-pos
-                   (< match-pos (if inside-macro
-                                    max-type-decl-end-before-token
-                                  max-type-decl-end))
-                   toplev)))
-             (setq context (car got-context)
-                   c-restricted-<>-arglists (cdr got-context)))
-
-           ;; Check we haven't missed a preceding "typedef".
-           (when (not (looking-at c-typedef-key))
-             (c-backward-syntactic-ws)
-             (c-backward-token-2)
-             (or (looking-at c-typedef-key)
-                 (goto-char start-pos)))
-
-           ;; In QT, "more" is an irritating keyword that expands to nothing.
-           ;; We skip over it to prevent recognition of "more slots: <symbol>"
-           ;; as a bitfield declaration.
-           (when (and (c-major-mode-is 'c++-mode)
-                      (looking-at
-                       (concat "\\(more\\)\\([^" c-symbol-chars "]\\|$\\)")))
-             (goto-char (match-end 1))
-             (c-forward-syntactic-ws))
-
-           ;; Now analyze the construct.
-           (if (eq context 'not-decl)
-               (progn
-                 (setq decl-or-cast nil)
-                 (if (c-syntactic-re-search-forward
-                      "," (min limit (point-max)) 'at-limit t)
-                     (c-put-char-property (1- (point)) 'c-type 'c-not-decl))
-                 nil)
-             (setq decl-or-cast
-                   (c-forward-decl-or-cast-1
-                    match-pos context last-cast-end))
-
-             ;; Ensure that c-<>-arg-sep c-type properties are in place on the
-             ;; commas separating the arguments inside template/generic <..>s.
-             (when (and (eq (char-before match-pos) ?<)
-                        (> match-pos max-<>-end))
-               (save-excursion
-                 (goto-char match-pos)
-                 (c-backward-token-2)
-                 (if (and
-                      (eq (char-after) ?<)
-                      (let ((c-restricted-<>-arglists
-                             (save-excursion
-                               (c-backward-token-2)
-                               (and
-                                (not (looking-at c-opt-<>-sexp-key))
-                                (progn (c-backward-syntactic-ws)
-                                       (memq (char-before) '(?\( ?,)))
-                                (not (eq (c-get-char-property (1- (point))
-                                                              'c-type)
-                                         'c-decl-arg-start))))))
-                        (c-forward-<>-arglist nil)))
-                     (setq max-<>-end (point)))))
-
-             (cond
-              ((eq decl-or-cast 'cast)
-               ;; Save the position after the previous cast so we can feed
-               ;; it to `c-forward-decl-or-cast-1' in the next round.  That
-               ;; helps it discover cast chains like "(a) (b) c".
-               (setq last-cast-end (point))
-               (c-fontify-recorded-types-and-refs)
-               nil)
-
-              (decl-or-cast
-               ;; We've found a declaration.
-
-               ;; Set `max-type-decl-end' or `max-type-decl-end-before-token'
-               ;; under the assumption that we're after the first type decl
-               ;; expression in the declaration now.  That's not really true;
-               ;; we could also be after a parenthesized initializer
-               ;; expression in C++, but this is only used as a last resort
-               ;; to slant ambiguous expression/declarations, and overall
-               ;; it's worth the risk to occasionally fontify an expression
-               ;; as a declaration in an initializer expression compared to
-               ;; getting ambiguous things in normal function prototypes
-               ;; fontified as expressions.
-               (if inside-macro
-                   (when (> (point) max-type-decl-end-before-token)
-                     (setq max-type-decl-end-before-token (point)))
-                 (when (> (point) max-type-decl-end)
-                   (setq max-type-decl-end (point))))
-               (goto-char start-pos)
-               (c-font-lock-single-decl limit decl-or-cast match-pos
-                                        context
-                                        (or toplev (nth 4 decl-or-cast))))
-
-              (t t))))
-
-         ;; It was a false alarm.  Check if we're in a label (or other
-         ;; construct with `:' except bitfield) instead.
-         (goto-char start-pos)
-         (when (setq label-type (c-forward-label t match-pos nil))
-           ;; Can't use `c-fontify-types-and-refs' here since we
-           ;; use the label face at times.
-           (cond ((eq label-type 'goto-target)
-                  (c-put-font-lock-face (caar c-record-ref-identifiers)
-                                        (cdar c-record-ref-identifiers)
-                                        c-label-face-name))
-                 ((eq label-type 'qt-1kwd-colon)
-                  (c-put-font-lock-face (caar c-record-ref-identifiers)
-                                        (cdar c-record-ref-identifiers)
-                                        'font-lock-keyword-face))
-                 ((eq label-type 'qt-2kwds-colon)
-                  (mapc
-                   (lambda (kwd)
-                     (c-put-font-lock-face (car kwd) (cdr kwd)
+                ;; Now analyze the construct.
+                (if (eq context 'not-decl)
+                    (progn
+                      (setq decl-or-cast nil)
+                      (if (c-syntactic-re-search-forward
+                           "," (min limit (point-max)) 'at-limit t)
+                          (c-put-char-property (1- (point)) 'c-type 
'c-not-decl))
+                      nil)
+                  (setq decl-or-cast
+                        (c-forward-decl-or-cast-1
+                         match-pos context last-cast-end))
+
+                  ;; Ensure that c-<>-arg-sep c-type properties are in place 
on the
+                  ;; commas separating the arguments inside template/generic 
<..>s.
+                  (when (and (eq (char-before match-pos) ?<)
+                             (> match-pos max-<>-end))
+                    (save-excursion
+                      (goto-char match-pos)
+                      (c-backward-token-2)
+                      (if (and
+                           (eq (char-after) ?<)
+                           (let ((c-restricted-<>-arglists
+                                  (save-excursion
+                                    (c-backward-token-2)
+                                    (and
+                                     (not (looking-at c-opt-<>-sexp-key))
+                                     (progn (c-backward-syntactic-ws)
+                                            (memq (char-before) '(?\( ?,)))
+                                     (not (eq (c-get-char-property (1- (point))
+                                                                   'c-type)
+                                              'c-decl-arg-start))))))
+                             (c-forward-<>-arglist nil)))
+                          (setq max-<>-end (point)))))
+
+                  (cond
+                   ((eq decl-or-cast 'cast)
+                    ;; Save the position after the previous cast so we can feed
+                    ;; it to `c-forward-decl-or-cast-1' in the next round.  
That
+                    ;; helps it discover cast chains like "(a) (b) c".
+                    (setq last-cast-end (point))
+                    (c-fontify-recorded-types-and-refs)
+                    nil)
+
+                   (decl-or-cast
+                    ;; We've found a declaration.
+
+                    ;; Set `max-type-decl-end' or 
`max-type-decl-end-before-token'
+                    ;; under the assumption that we're after the first type 
decl
+                    ;; expression in the declaration now.  That's not really 
true;
+                    ;; we could also be after a parenthesized initializer
+                    ;; expression in C++, but this is only used as a last 
resort
+                    ;; to slant ambiguous expression/declarations, and overall
+                    ;; it's worth the risk to occasionally fontify an 
expression
+                    ;; as a declaration in an initializer expression compared 
to
+                    ;; getting ambiguous things in normal function prototypes
+                    ;; fontified as expressions.
+                    (if inside-macro
+                        (when (> (point) max-type-decl-end-before-token)
+                          (setq max-type-decl-end-before-token (point)))
+                      (when (> (point) max-type-decl-end)
+                        (setq max-type-decl-end (point))))
+                    (goto-char start-pos)
+                    (c-font-lock-single-decl limit decl-or-cast match-pos
+                                             context
+                                             (or toplev (nth 4 decl-or-cast))))
+
+                   (t t))))
+
+            ;; It was a false alarm.  Check if we're in a label (or other
+            ;; construct with `:' except bitfield) instead.
+            (goto-char start-pos)
+            (when (setq label-type (c-forward-label t match-pos nil))
+              ;; Can't use `c-fontify-types-and-refs' here since we
+              ;; use the label face at times.
+              (cond ((eq label-type 'goto-target)
+                     (c-put-font-lock-face (caar c-record-ref-identifiers)
+                                           (cdar c-record-ref-identifiers)
+                                           c-label-face-name))
+                    ((eq label-type 'qt-1kwd-colon)
+                     (c-put-font-lock-face (caar c-record-ref-identifiers)
+                                           (cdar c-record-ref-identifiers)
                                            'font-lock-keyword-face))
-                   c-record-ref-identifiers)))
-           (setq c-record-ref-identifiers nil)
-           ;; `c-forward-label' has probably added a `c-decl-end'
-           ;; marker, so return t to `c-find-decl-spots' to signal
-           ;; that.
-           t))))
-
-      nil)))
+                    ((eq label-type 'qt-2kwds-colon)
+                     (mapc
+                      (lambda (kwd)
+                        (c-put-font-lock-face (car kwd) (cdr kwd)
+                                              'font-lock-keyword-face))
+                      c-record-ref-identifiers)))
+              (setq c-record-ref-identifiers nil)
+              ;; `c-forward-label' has probably added a `c-decl-end'
+              ;; marker, so return t to `c-find-decl-spots' to signal
+              ;; that.
+              t))))
+
+       nil))))
 
 (defun c-font-lock-enum-body (limit)
   ;; Fontify the identifiers of each enum we find by searching forward.
@@ -1632,19 +1569,21 @@ casts and declarations are fontified.  Used on level 2 
and higher."
   ;;
   ;; Note that this function won't attempt to fontify beyond the end of the
   ;; current enum block, if any.
-  (let* ((paren-state (c-parse-state))
-        (encl-pos (c-most-enclosing-brace paren-state)))
-    (when (and
-          encl-pos
-          (eq (char-after encl-pos) ?\{)
-          (save-excursion
-            (goto-char encl-pos)
-            (c-backward-over-enum-header)))
-      (c-syntactic-skip-backward "^{," nil t)
-      (c-put-char-property (1- (point)) 'c-type 'c-decl-id-start)
+  (c-skip-comments-and-strings limit)
+  (when (< (point) limit)
+    (let* ((paren-state (c-parse-state))
+          (encl-pos (c-most-enclosing-brace paren-state)))
+      (when (and
+            encl-pos
+            (eq (char-after encl-pos) ?\{)
+            (save-excursion
+              (goto-char encl-pos)
+              (c-backward-over-enum-header)))
+       (c-syntactic-skip-backward "^{," nil t)
+       (c-put-char-property (1- (point)) 'c-type 'c-decl-id-start)
 
-      (c-forward-syntactic-ws)
-      (c-font-lock-declarators limit t nil t)))
+       (c-forward-syntactic-ws)
+       (c-font-lock-declarators limit t nil t))))
   nil)
 
 (defun c-font-lock-cut-off-declarators (limit)
@@ -1656,46 +1595,48 @@ casts and declarations are fontified.  Used on level 2 
and higher."
   ;; font-lock-keyword-face.  It always returns NIL to inhibit this and
   ;; prevent a repeat invocation.  See elisp/lispref page "Search-based
   ;; fontification".
-  (let ((here (point))
-       (decl-search-lim (c-determine-limit 1000))
-       paren-state encl-pos token-end context decl-or-cast
-       start-pos top-level c-restricted-<>-arglists
-       c-recognize-knr-p)              ; Strictly speaking, bogus, but it
+  (c-skip-comments-and-strings limit)
+  (when (< (point) limit)
+    (let ((here (point))
+         (decl-search-lim (c-determine-limit 1000))
+         paren-state encl-pos token-end context decl-or-cast
+         start-pos top-level c-restricted-<>-arglists
+         c-recognize-knr-p)            ; Strictly speaking, bogus, but it
                                        ; speeds up lisp.h tremendously.
-    (save-excursion
-      (when (not (c-back-over-member-initializers))
-       (unless (or (eobp)
-                   (looking-at "\\s(\\|\\s)"))
-         (forward-char))
-       (c-syntactic-skip-backward "^;{}" decl-search-lim t)
-       (when (eq (char-before) ?})
-         (c-go-list-backward)  ; brace block of struct, etc.?
-         (c-syntactic-skip-backward "^;{}" decl-search-lim t))
-       (when (or (bobp)
-                 (memq (char-before) '(?\; ?{ ?})))
-         (setq token-end (point))
-         (c-forward-syntactic-ws here)
-         (when (< (point) here)
-           ;; We're now putatively at the declaration.
-           (setq start-pos (point))
-           (setq paren-state (c-parse-state))
-           ;; At top level or inside a "{"?
-           (if (or (not (setq encl-pos
-                              (c-most-enclosing-brace paren-state)))
-                   (eq (char-after encl-pos) ?\{))
-               (progn
-                 (setq top-level (c-at-toplevel-p))
-                 (let ((got-context (c-get-fontification-context
-                                     token-end nil top-level)))
-                   (setq context (car got-context)
-                         c-restricted-<>-arglists (cdr got-context)))
-                 (setq decl-or-cast
-                       (c-forward-decl-or-cast-1 token-end context nil))
-                 (when (consp decl-or-cast)
-                   (goto-char start-pos)
-                   (c-font-lock-single-decl limit decl-or-cast token-end
-                                            context top-level))))))))
-    nil))
+      (save-excursion
+       (when (not (c-back-over-member-initializers))
+         (unless (or (eobp)
+                     (looking-at "\\s(\\|\\s)"))
+           (forward-char))
+         (c-syntactic-skip-backward "^;{}" decl-search-lim t)
+         (when (eq (char-before) ?})
+           (c-go-list-backward)        ; brace block of struct, etc.?
+           (c-syntactic-skip-backward "^;{}" decl-search-lim t))
+         (when (or (bobp)
+                   (memq (char-before) '(?\; ?{ ?})))
+           (setq token-end (point))
+           (c-forward-syntactic-ws here)
+           (when (< (point) here)
+             ;; We're now putatively at the declaration.
+             (setq start-pos (point))
+             (setq paren-state (c-parse-state))
+             ;; At top level or inside a "{"?
+             (if (or (not (setq encl-pos
+                                (c-most-enclosing-brace paren-state)))
+                     (eq (char-after encl-pos) ?\{))
+                 (progn
+                   (setq top-level (c-at-toplevel-p))
+                   (let ((got-context (c-get-fontification-context
+                                       token-end nil top-level)))
+                     (setq context (car got-context)
+                           c-restricted-<>-arglists (cdr got-context)))
+                   (setq decl-or-cast
+                         (c-forward-decl-or-cast-1 token-end context nil))
+                   (when (consp decl-or-cast)
+                     (goto-char start-pos)
+                     (c-font-lock-single-decl limit decl-or-cast token-end
+                                              context top-level))))))))
+      nil)))
 
 (defun c-font-lock-enclosing-decls (limit)
   ;; Fontify the declarators of (nested) declarations we're in the middle of.
@@ -1707,27 +1648,29 @@ casts and declarations are fontified.  Used on level 2 
and higher."
   ;; font-lock-keyword-face.  It always returns NIL to inhibit this and
   ;; prevent a repeat invocation.  See elisp/lispref page "Search-based
   ;; Fontification".
-  (let* ((paren-state (c-parse-state))
-        (decl-search-lim (c-determine-limit 1000))
-        in-typedef ps-elt)
-    ;; Are we in any nested struct/union/class/etc. braces?
-    (while paren-state
-      (setq ps-elt (car paren-state)
-           paren-state (cdr paren-state))
-      (when (and (atom ps-elt)
-                (eq (char-after ps-elt) ?\{))
-       (goto-char ps-elt)
-       (c-syntactic-skip-backward "^;{}" decl-search-lim)
-       (c-forward-syntactic-ws)
-       (setq in-typedef (looking-at c-typedef-key))
-       (if in-typedef (c-forward-over-token-and-ws))
-       (when (and c-opt-block-decls-with-vars-key
-                  (looking-at c-opt-block-decls-with-vars-key))
+  (c-skip-comments-and-strings limit)
+  (when (< (point) limit)
+    (let* ((paren-state (c-parse-state))
+          (decl-search-lim (c-determine-limit 1000))
+          in-typedef ps-elt)
+      ;; Are we in any nested struct/union/class/etc. braces?
+      (while paren-state
+       (setq ps-elt (car paren-state)
+             paren-state (cdr paren-state))
+       (when (and (atom ps-elt)
+                  (eq (char-after ps-elt) ?\{))
          (goto-char ps-elt)
-         (when (c-safe (c-forward-sexp))
-           (c-forward-syntactic-ws)
-           (c-font-lock-declarators limit t in-typedef
-                                    (not (c-bs-at-toplevel-p (point))))))))))
+         (c-syntactic-skip-backward "^;{}" decl-search-lim)
+         (c-forward-syntactic-ws)
+         (setq in-typedef (looking-at c-typedef-key))
+         (if in-typedef (c-forward-over-token-and-ws))
+         (when (and c-opt-block-decls-with-vars-key
+                    (looking-at c-opt-block-decls-with-vars-key))
+           (goto-char ps-elt)
+           (when (c-safe (c-forward-sexp))
+             (c-forward-syntactic-ws)
+             (c-font-lock-declarators limit t in-typedef
+                                      (not (c-bs-at-toplevel-p 
(point)))))))))))
 
 (defun c-font-lock-raw-strings (limit)
   ;; Fontify C++ raw strings.
@@ -1741,29 +1684,37 @@ casts and declarations are fontified.  Used on level 2 
and higher."
         (string-start (and (eq (cadr state) 'string)
                            (car (cddr state))))
         (raw-id (and string-start
-                     (save-excursion
-                       (goto-char string-start)
-                       (and (eq (char-before) ?R)
-                            (looking-at "\"\\([^ ()\\\n\r\t]\\{0,16\\}\\)(")
-                            (match-string-no-properties 1))))))
+                     (c-at-c++-raw-string-opener string-start)
+                     (match-string-no-properties 1)))
+        (content-start (and raw-id (point))))
+    ;; We go round the next loop twice per raw string, once for each "end".
     (while (< (point) limit)
       (if raw-id
+         ;; Search for the raw string end delimiter
          (progn
-           (if (search-forward-regexp (concat ")\\(" (regexp-quote raw-id) 
"\\)\"")
-                                      limit 'limit)
-               (c-put-font-lock-face (match-beginning 1) (point) 'default))
+           (when (search-forward-regexp (concat ")\\(" (regexp-quote raw-id) 
"\\)\"")
+                                        limit 'limit)
+             (c-put-font-lock-face content-start (match-beginning 1)
+                                   'font-lock-string-face)
+             (c-remove-font-lock-face (match-beginning 1) (point)))
            (setq raw-id nil))
-
+       ;; Search for the start of a raw string.
        (when (search-forward-regexp
               "R\\(\"\\)\\([^ ()\\\n\r\t]\\{0,16\\}\\)(" limit 'limit)
          (when
-             (or (and (eobp)
-                      (eq (c-get-char-property (1- (point)) 'face)
-                          'font-lock-warning-face))
-                 (eq (c-get-char-property (point) 'face) 
'font-lock-string-face)
-                 (and (equal (c-get-char-property (match-end 2) 'syntax-table) 
'(1))
-                      (equal (c-get-char-property (match-beginning 1) 
'syntax-table)
-                             '(1))))
+             ;; Make sure we're not in a comment or string.
+             (and
+              (not (memq (c-get-char-property (match-beginning 0) 'face)
+                         '(font-lock-comment-face 
font-lock-comment-delimiter-face
+                                                  font-lock-string-face)))
+              (or (and (eobp)
+                       (eq (c-get-char-property (1- (point)) 'face)
+                           'font-lock-warning-face))
+                  (not (eq (c-get-char-property (point) 'face) 
'font-lock-comment-face))
+                  ;; (eq (c-get-char-property (point) 'face) 
'font-lock-string-face)
+                  (and (equal (c-get-char-property (match-end 2) 
'syntax-table) '(1))
+                       (equal (c-get-char-property (match-beginning 1) 
'syntax-table)
+                              '(1)))))
            (let ((paren-prop (c-get-char-property (1- (point)) 'syntax-table)))
              (if paren-prop
                  (progn
@@ -1774,8 +1725,9 @@ casts and declarations are fontified.  Used on level 2 
and higher."
                         (equal paren-prop '(15))
                         (not (c-search-forward-char-property 'syntax-table 
'(15) limit)))
                      (goto-char limit)))
-               (c-put-font-lock-face (match-beginning 1) (match-end 2) 
'default)
-               (setq raw-id (match-string-no-properties 2)))))))))
+               (c-remove-font-lock-face (match-beginning 0) (match-end 2))
+               (setq raw-id (match-string-no-properties 2))
+               (setq content-start (match-end 0)))))))))
   nil)
 
 (defun c-font-lock-c++-lambda-captures (limit)
@@ -2148,6 +2100,14 @@ higher."
            (c-lang-const c-complex-decl-matchers)
            (c-lang-const c-basic-matchers-after)))
 
+(defun c-get-doc-comment-style ()
+  ;; Get the symbol (or list of symbols) constituting the document style.
+  ;; Return nil if there is no such, otherwise something like `autodoc'.
+  (if (consp (car-safe c-doc-comment-style))
+      (cdr-safe (or (assq c-buffer-is-cc-mode c-doc-comment-style)
+                   (assq 'other c-doc-comment-style)))
+    c-doc-comment-style))
+
 (defun c-compose-keywords-list (base-list)
   ;; Incorporate the font lock keyword lists according to
   ;; `c-doc-comment-style' on the given keyword list and return it.
@@ -2158,11 +2118,7 @@ higher."
   (unless (memq c-doc-face-name c-literal-faces)
     (setq c-literal-faces (cons c-doc-face-name c-literal-faces)))
 
-  (let* ((doc-keywords
-         (if (consp (car-safe c-doc-comment-style))
-             (cdr-safe (or (assq c-buffer-is-cc-mode c-doc-comment-style)
-                           (assq 'other c-doc-comment-style)))
-           c-doc-comment-style))
+  (let* ((doc-keywords (c-get-doc-comment-style))
         (list (nconc (c--mapcan
                       (lambda (doc-style)
                         (let ((sym (intern
@@ -2611,15 +2567,88 @@ need for `pike-font-lock-extra-types'.")
   "Default expressions to highlight in Pike mode.")
 
 (defun pike-font-lock-keywords-2 ()
+  (c-set-doc-comment-res)
   (c-compose-keywords-list pike-font-lock-keywords-2))
 (defun pike-font-lock-keywords-3 ()
+  (c-set-doc-comment-res)
   (c-compose-keywords-list pike-font-lock-keywords-3))
 (defun pike-font-lock-keywords ()
+  (c-set-doc-comment-res)
   (c-compose-keywords-list pike-font-lock-keywords))
 
 
 ;;; Doc comments.
 
+(defvar c-doc-line-join-re "a\\`")
+;; Matches a join of two lines in a doc comment.
+;; This should not be changed directly, but instead set by
+;; `c-setup-doc-comment-style'.  This variable is used in `c-find-decl-spots'
+;; in (e.g.) autodoc style comments to bridge the gap between a "@\n" at an
+;; EOL and the token following "//!" on the next line.
+
+(defvar c-doc-bright-comment-start-re "a\\`")
+;; Matches the start of a "bright" comment, one whose contents may be
+;; fontified by, e.g., `c-font-lock-declarations'.
+
+(defvar c-doc-line-join-end-ch nil)
+;; A list of characters, each being a last character of a doc comment marker,
+;; e.g. the ! from pike autodoc's "//!".
+
+(defmacro c-set-doc-comment-re-element (suffix)
+  ;; Set the variable `c-doc-line-join-re' to a buffer local value suitable
+  ;; for the current doc comment style, or kill the local value.
+  (let ((var (intern (concat "c-doc" suffix))))
+    `(let* ((styles (c-get-doc-comment-style))
+           elts)
+       (when (atom styles)
+        (setq styles (list styles)))
+       (setq elts
+            (mapcar (lambda (style)
+                      (let ((sym
+                             (intern-soft
+                              (concat (symbol-name style) ,suffix))))
+                        (and sym
+                             (boundp sym)
+                             (symbol-value sym))))
+                    styles))
+       (setq elts (delq nil elts))
+       (setq elts (and elts
+                      (concat "\\("
+                              (mapconcat #'identity elts "\\|")
+                              "\\)")))
+       (if elts
+          (set (make-local-variable ',var) elts)
+        (kill-local-variable ',var)))))
+
+(defmacro c-set-doc-comment-char-list (suffix)
+  ;; Set the variable 'c-doc-<suffix>' to the list of *-<suffix>, which must
+  ;; be characters, and * represents the doc comment style.
+  (let ((var (intern (concat "c-doc" suffix))))
+    `(let* ((styles (c-get-doc-comment-style))
+           elts)
+       (when (atom styles)
+        (setq styles (list styles)))
+       (setq elts
+            (mapcar (lambda (style)
+                      (let ((sym
+                             (intern-soft
+                              (concat (symbol-name style) ,suffix))))
+                        (and sym
+                             (boundp sym)
+                             (symbol-value sym))))
+                    styles))
+       (setq elts (delq nil elts))
+       (if elts
+          (set (make-local-variable ',var) elts)
+        (kill-local-variable ',var)))))
+
+(defun c-set-doc-comment-res ()
+  ;; Set the variables `c-doc-line-join-re' and
+  ;; `c-doc-bright-comment-start-re' from the current doc comment style(s).
+  (c-set-doc-comment-re-element "-line-join-re")
+  (c-set-doc-comment-re-element "-bright-comment-start-re")
+  (c-set-doc-comment-char-list "-line-join-end-ch"))
+
 (defun c-font-lock-doc-comments (prefix limit keywords)
   ;; Fontify the comments between the point and LIMIT whose start
   ;; matches PREFIX with `c-doc-face-name'.  Assumes comments have been
@@ -2680,17 +2709,20 @@ need for `pike-font-lock-extra-types'.")
            (goto-char comment-beg)
            (while (and (progn
                          (c-forward-single-comment)
+                         (c-put-font-lock-face comment-beg (point)
+                                               c-doc-face-name)
                          (skip-syntax-forward " ")
+                         (setq comment-beg (point))
                          (< (point) limit))
                        (looking-at prefix))))
        (goto-char comment-beg)
-       (c-forward-single-comment))
+       (c-forward-single-comment)
+       (c-put-font-lock-face comment-beg (point) c-doc-face-name))
       (if (> (point) limit) (goto-char limit))
       (setq comment-beg nil)
 
       (let ((region-end (point))
            (keylist keywords) keyword matcher highlights)
-       (c-put-font-lock-face region-beg region-end c-doc-face-name)
        (save-restriction
          ;; Narrow to the doc comment.  Among other things, this
          ;; helps by making "^" match at the start of the comment.
@@ -2897,6 +2929,13 @@ need for `pike-font-lock-extra-types'.")
      0 'font-lock-warning-face prepend nil)
     ))
 
+(defconst autodoc-line-join-re "@[\n\r][ \t]*/[/*]!")
+;; Matches a line continuation in autodoc comment style.
+(defconst autodoc-bright-comment-start-re "/[/*]!")
+;; Matches an autodoc comment opener.
+(defconst autodoc-line-join-end-ch ?!)
+;; The final character of `autodoc-line-join-re'.
+
 (defun autodoc-font-lock-keywords ()
   ;; Note that we depend on that `c-current-comment-prefix' has got
   ;; its proper value here.
diff --git a/lisp/progmodes/cc-guess.el b/lisp/progmodes/cc-guess.el
index 866e8b4..88e577a 100644
--- a/lisp/progmodes/cc-guess.el
+++ b/lisp/progmodes/cc-guess.el
@@ -1,6 +1,6 @@
 ;;; cc-guess.el --- guess indentation values by scanning existing code
 
-;; Copyright (C) 1985, 1987, 1992-2006, 2011-2018 Free Software
+;; Copyright (C) 1985, 1987, 1992-2006, 2011-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author:     1994-1995 Barry A. Warsaw
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index 8c148e5..50f8b84 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -1,6 +1,6 @@
 ;;; cc-langs.el --- language specific settings for CC Mode -*- coding: utf-8 
-*-
 
-;; Copyright (C) 1985, 1987, 1992-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1992-2019 Free Software Foundation, Inc.
 
 ;; Authors:    2002- Alan Mackenzie
 ;;             1998- Martin Stjernholm
@@ -497,25 +497,25 @@ parameters \(point-min) and \(point-max).")
   ;; For documentation see the following c-lang-defvar of the same name.
   ;; The value here may be a list of functions or a single function.
   t '(c-depropertize-new-text
-      c-after-change-re-mark-unbalanced-strings
+      c-after-change-mark-abnormal-strings
       c-change-expand-fl-region)
   (c objc) '(c-depropertize-new-text
             c-parse-quotes-after-change
-            c-after-change-re-mark-unbalanced-strings
+            c-after-change-mark-abnormal-strings
             c-extend-font-lock-region-for-macros
             c-neutralize-syntax-in-CPP
             c-change-expand-fl-region)
   c++ '(c-depropertize-new-text
+       c-after-change-unmark-raw-strings
        c-parse-quotes-after-change
-       c-after-change-re-mark-unbalanced-strings
+       c-after-change-mark-abnormal-strings
        c-extend-font-lock-region-for-macros
-       c-after-change-re-mark-raw-strings
        c-neutralize-syntax-in-CPP
        c-restore-<>-properties
        c-change-expand-fl-region)
   java '(c-depropertize-new-text
         c-parse-quotes-after-change
-        c-after-change-re-mark-unbalanced-strings
+        c-after-change-mark-abnormal-strings
         c-restore-<>-properties
         c-change-expand-fl-region)
   awk '(c-depropertize-new-text
@@ -599,13 +599,21 @@ EOL terminated statements."
 (c-lang-defvar c-has-bitfields (c-lang-const c-has-bitfields))
 
 (c-lang-defconst c-single-quotes-quote-strings
-  "Whether the language uses single quotes for multi-char strings."
+  "Whether the language uses single quotes for multi-char strings.
+
+Note that to set up a language to use this, additionally:
+\(i) the syntax of \"'\" must be \"string quote\" (7);
+\(ii) the language's value of `c-has-quoted-numbers' must be nil;
+\(iii) the language's value of `c-get-state-before-change-functions' may not
+  contain `c-parse-quotes-before-change';
+\(iv) the language's value of `c-before-font-lock-functions' may not contain
+  `c-parse-quotes-after-change'."
   t nil)
 (c-lang-defvar c-single-quotes-quote-strings
               (c-lang-const c-single-quotes-quote-strings))
 
 (c-lang-defconst c-string-delims
-  "A list of characters which can delimit arbitrary length strings"
+;; A list of characters which can delimit arbitrary length strings.
   t (if (c-lang-const c-single-quotes-quote-strings)
        '(?\" ?\')
       '(?\")))
@@ -927,6 +935,19 @@ file name in angle brackets or quotes."
           '("include"))
   objc '("include" "import"))
 
+(c-lang-defconst c-cpp-include-key
+  ;; Matches an include directive anchored at BOL including any trailing
+  ;; whitespace, e.g. " # include  "
+  t (if (and (c-lang-const c-anchored-cpp-prefix)
+            (c-lang-const c-cpp-include-directives))
+       (concat
+        (c-lang-const c-anchored-cpp-prefix)
+        (c-make-keywords-re 'appendable
+          (c-lang-const c-cpp-include-directives))
+        "[ \t]*")
+      "a\\`"))                         ; Doesn't match anything
+(c-lang-defvar c-cpp-include-key (c-lang-const c-cpp-include-key))
+
 (c-lang-defconst c-opt-cpp-macro-define
   "Cpp directive (without the prefix) that is followed by a macro
 definition, or nil if the language doesn't have any."
@@ -1529,6 +1550,17 @@ properly."
 (c-lang-defvar c-block-comment-ender-regexp
               (c-lang-const c-block-comment-ender-regexp))
 
+(c-lang-defconst c-font-lock-comment-end-skip
+  ;; Regexp which matches whitespace followed by the end of a block comment
+  ;; (if such exists in the language).  This is used by font lock to determine
+  ;; the portion of the end of a comment to fontify with
+  ;; `font-lock-comment-delimiter-face'.
+  t (if (c-lang-const c-block-comment-ender)
+       (concat "[ \t]*" (c-lang-const c-block-comment-ender-regexp))
+      "a\\`"))                         ; Doesn't match anything.
+(c-lang-setvar font-lock-comment-end-skip
+              (c-lang-const c-font-lock-comment-end-skip))
+
 (c-lang-defconst c-comment-start-regexp
   ;; Regexp to match the start of any type of comment.
   t (let ((re (c-make-keywords-re nil
@@ -2017,6 +2049,19 @@ effect in the declaration, but are syntactically like 
whitespace."
 (c-lang-defvar c-type-decl-suffix-ws-ids-key
   (c-lang-const c-type-decl-suffix-ws-ids-key))
 
+(c-lang-defconst c-class-id-suffix-ws-ids-kwds
+  "\"Identifiers\" that when immediately following the identifier
+of a class declaration have semantic effect in the declaration,
+but are syntactically like whitespace."
+  t    nil
+  c++ '("final"))
+
+(c-lang-defconst c-class-id-suffix-ws-ids-key
+  ;; An adorned regexp matching `c-class-id-suffix-ws-ids-kwds'.
+  t (c-make-keywords-re t (c-lang-const c-class-id-suffix-ws-ids-kwds)))
+(c-lang-defvar c-class-id-suffix-ws-ids-key
+  (c-lang-const c-class-id-suffix-ws-ids-key))
+
 (c-lang-defconst c-class-decl-kwds
   "Keywords introducing declarations where the following block (if any)
 contains another declaration level that should be considered a class.
@@ -3234,7 +3279,7 @@ Identifier syntax is in effect when this is matched \(see
               "\\|"
               "\\.\\.\\."
               "\\|"
-              "[*(&]"
+              "[*(&~]"
               "\\|"
               (c-lang-const c-type-decl-prefix-key)
               "\\|"
diff --git a/lisp/progmodes/cc-menus.el b/lisp/progmodes/cc-menus.el
index a42fe27..c8e37e0 100644
--- a/lisp/progmodes/cc-menus.el
+++ b/lisp/progmodes/cc-menus.el
@@ -1,6 +1,6 @@
 ;;; cc-menus.el --- imenu support for CC Mode
 
-;; Copyright (C) 1985, 1987, 1992-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1992-2019 Free Software Foundation, Inc.
 
 ;; Authors:    1998- Martin Stjernholm
 ;;             1992-1999 Barry A. Warsaw
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 4dd8f51..ea865e0 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -1,6 +1,6 @@
 ;;; cc-mode.el --- major mode for editing C and similar languages
 
-;; Copyright (C) 1985, 1987, 1992-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1992-2019 Free Software Foundation, Inc.
 
 ;; Authors:    2003- Alan Mackenzie
 ;;             1998- Martin Stjernholm
@@ -678,14 +678,12 @@ that requires a literal mode spec at compile time."
 (make-variable-buffer-local 'c-new-BEG)
 (defvar c-new-END 0)
 (make-variable-buffer-local 'c-new-END)
-;; The following two variables record the values of `c-new-BEG' and
-;; `c-new-END' just after `c-new-END' has been adjusted for the length of text
-;; inserted or removed.  They may be read by any after-change function (but
-;; should not be altered by one).
-(defvar c-old-BEG 0)
-(make-variable-buffer-local 'c-old-BEG)
-(defvar c-old-END 0)
-(make-variable-buffer-local 'c-old-END)
+
+;; Buffer local variable which notes the value of calling `c-in-literal' just
+;; before a change.  It is one of 'string, 'c, 'c++ (for the two sorts of
+;; comments), or nil.
+(defvar c-old-END-literality nil)
+(make-variable-buffer-local 'c-old-END-literality)
 
 (defun c-common-init (&optional mode)
   "Common initialization for all CC Mode modes.
@@ -900,7 +898,8 @@ Note that the style variables are always made local to the 
buffer."
 
 (defun c-depropertize-CPP (beg end)
   ;; Remove the punctuation syntax-table text property from the CPP parts of
-  ;; (c-new-BEG c-new-END).
+  ;; (c-new-BEG c-new-END), and remove all syntax-table properties from any
+  ;; raw strings within these CPP parts.
   ;;
   ;; This function is in the C/C++/ObjC values of
   ;; `c-get-state-before-change-functions' and is called exclusively as a
@@ -912,6 +911,7 @@ Note that the style variables are always made local to the 
buffer."
       (goto-char (match-beginning 1))
       (setq m-beg (point))
       (c-end-of-macro)
+      (save-excursion (c-depropertize-raw-strings-in-region m-beg (point)))
       (c-clear-char-property-with-value m-beg (point) 'syntax-table '(1)))
 
     (while (and (< (point) end)
@@ -920,14 +920,16 @@ Note that the style variables are always made local to 
the buffer."
       (goto-char (match-beginning 1))
       (setq m-beg (point))
       (c-end-of-macro))
-    (if (and ss-found (> (point) end))
-       (c-clear-char-property-with-value m-beg (point) 'syntax-table '(1)))
+    (when (and ss-found (> (point) end))
+      (save-excursion (c-depropertize-raw-strings-in-region m-beg (point)))
+      (c-clear-char-property-with-value m-beg (point) 'syntax-table '(1)))
 
     (while (and (< (point) c-new-END)
                (search-forward-regexp c-anchored-cpp-prefix c-new-END 'bound))
       (goto-char (match-beginning 1))
       (setq m-beg (point))
       (c-end-of-macro)
+      (save-excursion (c-depropertize-raw-strings-in-region m-beg (point)))
       (c-clear-char-property-with-value
        m-beg (point) 'syntax-table '(1)))))
 
@@ -1190,8 +1192,6 @@ Note that the style variables are always made local to 
the buffer."
        (beg-literal-type (and beg-limits
                                       (c-literal-type beg-limits))))
 
-    (when (eq end-literal-type 'string)
-      (setq c-new-END (max c-new-END (cdr end-limits))))
     ;; It is possible the buffer change will include inserting a string quote.
     ;; This could have the effect of flipping the meaning of any following
     ;; quotes up until the next unescaped EOL.  Also guard against the change
@@ -1210,11 +1210,15 @@ Note that the style variables are always made local to 
the buffer."
               (while
                   (and
                    (c-syntactic-re-search-forward
-                    "\"\\|\\s|" (point-max) t t)
+                    (if c-single-quotes-quote-strings
+                        "[\"']\\|\\s|"
+                      "\"\\|\\s|")
+                    (point-max) t t)
                    (progn
                      (c-clear-char-property (1- (point)) 'syntax-table)
-                     (not (eq (char-before) ?\")))))
-              (eq (char-before) ?\"))
+                     (c-truncate-semi-nonlit-pos-cache (1- (point)))
+                     (not (memq (char-before) c-string-delims)))))
+              (memq (char-before) c-string-delims))
             (progn
               (c-pps-to-string-delim (point-max))
               (< (point) (point-max))))))
@@ -1226,7 +1230,9 @@ Note that the style variables are always made local to 
the buffer."
                     (eq beg-literal-type 'string))))
       ;; Deal with deletion of backslashes before "s.
       (goto-char end)
-      (if (and (looking-at "\\\\*\"")
+      (if (and (looking-at (if c-single-quotes-quote-strings
+                              "\\\\*[\"']"
+                            "\\\\*\""))
               (eq (logand (skip-chars-backward "\\\\" beg) 1) 1))
          (setq c-bc-changed-stringiness (not c-bc-changed-stringiness)))
       (if (eq beg-literal-type 'string)
@@ -1236,7 +1242,7 @@ Note that the style variables are always made local to 
the buffer."
       (goto-char (1+ end))     ; might be a newline.
       ;; In the following regexp, the initial \n caters for a newline getting
       ;; joined to a preceding \ by the removal of what comes between.
-      (re-search-forward "[\n\r]?\\(\\\\\\(.\\|\n\\|\r\\)\\|[^\\\n\r]\\)*"
+      (re-search-forward "[\n\r]?\\(\\\\\\(.\\|\n\\)\\|[^\\\n\r]\\)*"
                         nil t)
       ;; We're at an EOLL or point-max.
       (setq c-new-END (max c-new-END (min (1+ (point)) (point-max))))
@@ -1247,27 +1253,45 @@ Note that the style variables are always made local to 
the buffer."
                (forward-char)
                (backward-sexp)
                (c-clear-char-property eoll-1 'syntax-table)
-               (c-clear-char-property (point) 'syntax-table))
+               (c-clear-char-property (point) 'syntax-table)
+               (c-truncate-semi-nonlit-pos-cache (point)))
            ;; Opening " at EOB.
            (c-clear-char-property (1- (point)) 'syntax-table))
-       (if (c-search-backward-char-property 'syntax-table '(15) c-new-BEG)
-           ;; Opening " on last line of text (without EOL).
-           (c-clear-char-property (point) 'syntax-table))))
+       (when (and (c-search-backward-char-property 'syntax-table '(15) 
c-new-BEG)
+                  (memq (char-after) c-string-delims)) ; Ignore an 
unterminated raw string's (.
+         ;; Opening " on last line of text (without EOL).
+         (c-clear-char-property (point) 'syntax-table)
+         (c-truncate-semi-nonlit-pos-cache (point))
+         (setq c-new-BEG (min c-new-BEG (point))))))
 
      (t (goto-char end)                        ; point-max
-       (if (c-search-backward-char-property 'syntax-table '(15) c-new-BEG)
-           (c-clear-char-property (point) 'syntax-table))))
-
-    (unless (and c-multiline-string-start-char
-                (not (c-characterp c-multiline-string-start-char)))
-      (when (eq end-literal-type 'string)
-       (c-clear-char-property (1- (cdr end-limits)) 'syntax-table))
-
-      (when (eq beg-literal-type 'string)
-       (setq c-new-BEG (min c-new-BEG (car beg-limits)))
-       (c-clear-char-property (car beg-limits) 'syntax-table)))))
-
-(defun c-after-change-re-mark-unbalanced-strings (beg end _old-len)
+       (when
+           (and
+            (c-search-backward-char-property 'syntax-table '(15) c-new-BEG)
+            (memq (char-after) c-string-delims))
+         (c-clear-char-property (point) 'syntax-table)
+         (c-truncate-semi-nonlit-pos-cache (point)))))
+
+    (unless 
+       (or (and
+            ;; Don't set c-new-BEG/END if we're in a raw string.
+            (eq beg-literal-type 'string)
+            (c-at-c++-raw-string-opener (car beg-limits)))
+           (and c-multiline-string-start-char
+                (not (c-characterp c-multiline-string-start-char))))
+      (when (and (eq end-literal-type 'string)
+                (not (eq (char-before (cdr end-limits)) ?\()))
+       (c-clear-char-property (1- (cdr end-limits)) 'syntax-table)
+       (c-truncate-semi-nonlit-pos-cache (1- (cdr end-limits)))
+       (setq c-new-END (max c-new-END (cdr end-limits))))
+
+      (when (and (eq beg-literal-type 'string)
+                (memq (char-after (car beg-limits)) c-string-delims))
+       (c-clear-char-property (car beg-limits) 'syntax-table)
+       (c-truncate-semi-nonlit-pos-cache (car beg-limits))
+       (setq c-new-BEG (min c-new-BEG (car beg-limits)))))))
+
+(defun c-after-change-mark-abnormal-strings (beg end _old-len)
   ;; Mark any unbalanced strings in the region (c-new-BEG c-new-END) with
   ;; string fence syntax-table text properties.
   ;;
@@ -1318,7 +1342,8 @@ Note that the style variables are always made local to 
the buffer."
               (min (1+ (point)) (point-max)))))
           ((and (null beg-literal-type)
                 (goto-char beg)
-                (eq (char-before) c-multiline-string-start-char)
+                (and (not (bobp))
+                     (eq (char-before) c-multiline-string-start-char))
                 (memq (char-after) c-string-delims))
            (cons (point)
                  (progn
@@ -1335,6 +1360,7 @@ Note that the style variables are always made local to 
the buffer."
              (car beg-limits))
             (t                         ; comment
              (cdr beg-limits))))
+      ;; Handle one string each time around the next while loop.
       (while
          (and
           (< (point) c-new-END)
@@ -1343,22 +1369,29 @@ Note that the style variables are always made local to 
the buffer."
             (while (progn
                      (setq s (parse-partial-sexp (point) c-new-END nil
                                                  nil s 'syntax-table))
-                      (and (< (point) c-new-END)
-                           (or (not (nth 3 s))
-                               (not (memq (char-before) c-string-delims))))))
+                     (and (< (point) c-new-END)
+                          (or (not (nth 3 s))
+                              (not (memq (char-before) c-string-delims))))))
             ;; We're at the start of a string.
             (memq (char-before) c-string-delims)))
-       (if (c-unescaped-nls-in-string-p (1- (point)))
-           (looking-at "\\(\\\\\\(.\\|\n|\\\r\\)\\|[^\"]\\)*")
-         (looking-at (cdr (assq (char-before) c-string-innards-re-alist))))
-       (cond
-        ((memq (char-after (match-end 0)) '(?\n ?\r))
-         (c-put-char-property (1- (point)) 'syntax-table '(15))
-         (c-put-char-property (match-end 0) 'syntax-table '(15)))
-        ((or (eq (match-end 0) (point-max))
-             (eq (char-after (match-end 0)) ?\\)) ; \ at EOB
-         (c-put-char-property (1- (point)) 'syntax-table '(15))))
-       (goto-char (min (1+ (match-end 0)) (point-max)))
+       (unless (and (c-major-mode-is 'c++-mode)
+                    (c-maybe-re-mark-raw-string))
+         (if (c-unescaped-nls-in-string-p (1- (point)))
+             (looking-at "\\(\\\\\\(.\\|\n\\)\\|[^\"]\\)*")
+           (looking-at (cdr (assq (char-before) c-string-innards-re-alist))))
+         (cond
+          ((memq (char-after (match-end 0)) '(?\n ?\r))
+           (c-put-char-property (1- (point)) 'syntax-table '(15))
+           (c-put-char-property (match-end 0) 'syntax-table '(15))
+           (setq c-new-BEG (min c-new-BEG (point))
+                 c-new-END (max c-new-END (match-end 0))))
+          ((or (eq (match-end 0) (point-max))
+               (eq (char-after (match-end 0)) ?\\)) ; \ at EOB
+           (c-put-char-property (1- (point)) 'syntax-table '(15))
+           (setq c-new-BEG (min c-new-BEG (point))
+                 c-new-END (max c-new-END (match-end 0))) ; Do we need 
c-new-END?
+           ))
+         (goto-char (min (1+ (match-end 0)) (point-max))))
        (setq s nil)))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1475,7 +1508,7 @@ Note that this is a strict tail, so won't match, e.g. 
\"0x....\".")
   ;;
   ;; This function is called exclusively as a before-change function via the
   ;; variable `c-get-state-before-change-functions'.
-  (c-save-buffer-state ()
+  (c-save-buffer-state (case-fold-search)
     (goto-char c-new-BEG)
     ;; We need to scan for 's from the BO (logical) line.
     (beginning-of-line)
@@ -1491,14 +1524,17 @@ Note that this is a strict tail, so won't match, e.g. 
\"0x....\".")
        ((c-quoted-number-head-before-point)
        (if (>= (point) c-new-BEG)
            (setq c-new-BEG (match-beginning 0))))
-       ((looking-at "\\([^'\\]\\|\\\\.\\)'")
+       ((looking-at
+        "\\([^'\\]\\|\\\\\\([0-7]\\{1,3\\}\\|[xuU][0-9a-fA-F]+\\|.\\)\\)'")
        (goto-char (match-end 0))
        (if (> (match-end 0) c-new-BEG)
            (setq c-new-BEG (1- (match-beginning 0)))))
-       ((or (>= (point) (1- c-new-BEG))
-           (and (eq (point) (- c-new-BEG 2))
-                (eq (char-after) ?\\)))
-       (setq c-new-BEG (1- (point))))
+       ((looking-at "\\\\'")
+       (setq c-new-BEG (min c-new-BEG (1- (point))))
+       (goto-char (match-end 0)))
+       ((save-excursion
+         (not (search-forward "'" c-new-BEG t)))
+       (setq c-new-BEG (min c-new-BEG (1- (point)))))
        (t nil)))
 
     (goto-char c-new-END)
@@ -1517,19 +1553,29 @@ Note that this is a strict tail, so won't match, e.g. 
\"0x....\".")
        (goto-char (match-end 0))
        (if (> (match-end 0) c-new-END)
            (setq c-new-END (match-end 0))))
-       ((looking-at "\\([^'\\]\\|\\\\.\\)'")
+       ((looking-at
+        "\\([^'\\]\\|\\\\\\([0-7]\\{1,3\\}\\|[xuU][0-9a-fA-F]+\\|.\\)\\)'")
        (goto-char (match-end 0))
        (if (> (match-end 0) c-new-END)
            (setq c-new-END (match-end 0))))
+       ((looking-at "\\\\'")
+       (goto-char (match-end 0))
+       (setq c-new-END (max c-new-END (point))))
+       ((equal (c-get-char-property (1- (point)) 'syntax-table) '(1))
+       (when (c-search-forward-char-property-with-value-on-char
+              'syntax-table '(1) ?\' (c-point 'eoll))
+         (setq c-new-END (max (point) c-new-END))))
        (t nil)))
     ;; Having reached c-new-END, handle any 's after it whose context may be
-    ;; changed by the current buffer change.
+    ;; changed by the current buffer change.  The idea is to catch
+    ;; monstrosities like ',',',',',' changing "polarity".
     (goto-char c-new-END)
     (cond
      ((c-quoted-number-tail-after-point)
       (setq c-new-END (match-end 0)))
      ((looking-at
-       "\\(\\\\.\\|.\\)?\\('\\([^'\\]\\|\\\\.\\)\\)*'")
+       "\\(\\\\\\([0-7]\\{1,3\\}\\|[xuU][0-9a-fA-F]+\\|.\\)\\|.\\)?\
+\\('\\([^'\\]\\|\\\\\\([0-7]\\{1,3\\}\\|[xuU][0-9a-fA-F]+\\|.\\)\\)\\)*'")
       (setq c-new-END (match-end 0))))
 
     ;; Remove the '(1) syntax-table property from any "'"s within (c-new-BEG
@@ -1558,7 +1604,7 @@ Note that this is a strict tail, so won't match, e.g. 
\"0x....\".")
   ;;
   ;; This function is called exclusively as an after-change function via the
   ;; variable `c-before-font-lock-functions'.
-  (c-save-buffer-state (num-beg num-end)
+  (c-save-buffer-state (num-beg num-end case-fold-search)
     ;; Apply the needed syntax-table and c-digit-separator text properties to
     ;; quotes.
     (save-restriction
@@ -1580,7 +1626,15 @@ Note that this is a strict tail, so won't match, e.g. 
\"0x....\".")
               (c-put-char-properties-on-char num-beg num-end
                                              'c-digit-separator t ?')
               (goto-char num-end))
-             ((looking-at "\\([^\\']\\|\\\\.\\)'") ; balanced quoted 
expression.
+             ((looking-at
+               "\\([^\\']\\|\\\\\\([0-7]\\{1,3\\}\\|[xuU][0-9a-fA-F]+\\|.\\)\
+\\)'") ; balanced quoted expression.
+              (goto-char (match-end 0)))
+             ((looking-at "\\\\'")     ; Anomalous construct.
+              (c-invalidate-state-cache (1- (point)))
+              (c-truncate-semi-nonlit-pos-cache (1- (point)))
+              (c-put-char-properties-on-char (1- (point)) (+ (point) 2)
+                                             'syntax-table '(1) ?')
               (goto-char (match-end 0)))
              (t
               (c-invalidate-state-cache (1- (point)))
@@ -1623,7 +1677,7 @@ Note that this is a strict tail, so won't match, e.g. 
\"0x....\".")
          ;; Are we coalescing two tokens together, e.g. "fo o" -> "foo"?
          (when (< beg end)
            (c-unfind-coalesced-tokens beg end))
-         (c-invalidate-sws-region-before end)
+         (c-invalidate-sws-region-before beg end)
          ;; Are we (potentially) disrupting the syntactic context which
          ;; makes a type a type?  E.g. by inserting stuff after "foo" in
          ;; "foo bar;", or before "foo" in "typedef foo *bar;"?
@@ -1721,7 +1775,6 @@ Note that this is a strict tail, so won't match, e.g. 
\"0x....\".")
   ;; (c-new-BEG c-new-END) will be the region to fontify.  It may become
   ;; larger than (beg end).
   (setq c-new-END (- (+ c-new-END (- end beg)) old-len))
-  (setq c-old-BEG c-new-BEG  c-old-END c-new-END)
 
   (unless (c-called-from-text-property-change-p)
     (setq c-just-done-before-change nil)
@@ -1767,6 +1820,34 @@ Note that this is a strict tail, so won't match, e.g. 
\"0x....\".")
                    (funcall fn beg end old-len))
                  c-before-font-lock-functions)))))))
 
+(defun c-doc-fl-decl-start (pos)
+  ;; If the line containing POS is in a doc comment continued line (as defined
+  ;; by `c-doc-line-join-re'), return the position of the first line of the
+  ;; sequence.  Otherwise, return nil.  Point has no significance at entry to
+  ;; and exit from this function.
+  (goto-char pos)
+  (back-to-indentation)
+  (and (or (looking-at c-comment-start-regexp)
+          (memq (c-literal-type (c-literal-limits)) '(c c++)))
+       (progn
+        (end-of-line)
+        (let ((here (point)))
+          (while (re-search-backward c-doc-line-join-re (c-point 'bopl) t))
+          (and (not (eq (point) here))
+               (c-point 'bol))))))
+
+(defun c-doc-fl-decl-end (pos)
+  ;; If the line containing POS is continued by a doc comment continuation
+  ;; marker (as defined by `c-doc-line-join-re), return the position of
+  ;; the BOL at the end of the sequence.  Otherwise, return nil.  Point has no
+  ;; significance at entry to and exit from this function.
+  (goto-char pos)
+  (back-to-indentation)
+  (let ((here (point)))
+    (while (re-search-forward c-doc-line-join-re (c-point 'eonl) t))
+    (and (not (eq (point) here))
+        (c-point 'bonl))))
+
 (defun c-fl-decl-start (pos)
   ;; If the beginning of the line containing POS is in the middle of a "local"
   ;; declaration, return the beginning of that declaration.  Otherwise return
@@ -1774,90 +1855,105 @@ Note that this is a strict tail, so won't match, e.g. 
\"0x....\".")
   ;; declaration is one which does not start outside of struct braces (and
   ;; similar) enclosing POS.  Brace list braces here are not "similar".
   ;;
+  ;; POS being in a literal does not count as being in a declaration (on
+  ;; pragmatic grounds).
+  ;;
   ;; This function is called indirectly from font locking stuff - either from
   ;; c-after-change (to prepare for after-change font-locking) or from font
   ;; lock context (etc.) fontification.
   (goto-char pos)
   (let ((lit-start (c-literal-start))
+       old-pos
        (new-pos pos)
        capture-opener
        bod-lim bo-decl)
     (goto-char (c-point 'bol new-pos))
-    (when lit-start                    ; Comment or string.
-      (goto-char lit-start))
-    (setq bod-lim (c-determine-limit 500))
-
-    ;; In C++ Mode, first check if we are within a (possibly nested) lambda
-    ;; form capture list.
-    (when (c-major-mode-is 'c++-mode)
-      (let ((paren-state (c-parse-state))
-           opener)
-       (save-excursion
-         (while (setq opener (c-pull-open-brace paren-state))
-           (goto-char opener)
-           (if (c-looking-at-c++-lambda-capture-list)
-               (setq capture-opener (point)))))))
-
-    (while
-       ;; Go to a less nested declaration each time round this loop.
-       (and
-        (c-syntactic-skip-backward "^;{}" bod-lim t)
-        (> (point) bod-lim)
-        (progn (c-forward-syntactic-ws)
-               ;; Have we got stuck in a comment at EOB?
-               (not (and (eobp)
-                         (c-literal-start))))
-        (progn (setq bo-decl (point))
-               (or (not (looking-at c-protection-key))
-                   (c-forward-keyword-clause 1)))
-        (progn
-          ;; Are we looking at a keyword such as "template" or
-          ;; "typedef" which can decorate a type, or the type itself?
-          (when (or (looking-at c-prefix-spec-kwds-re)
-                    (c-forward-type t))
-            ;; We've found another candidate position.
-            (setq new-pos (min new-pos bo-decl))
-            (goto-char bo-decl))
-          t)
-        ;; Try and go out a level to search again.
-        (progn
-          (c-backward-syntactic-ws bod-lim)
-          (and (> (point) bod-lim)
-               (or (memq (char-before) '(?\( ?\[))
-                   (and (eq (char-before) ?\<)
-                        (eq (c-get-char-property
-                             (1- (point)) 'syntax-table)
-                            c-<-as-paren-syntax))
-                   (and (eq (char-before) ?{)
-                        (save-excursion
-                          (backward-char)
-                          (consp (c-looking-at-or-maybe-in-bracelist))))
-                   )))
-        (not (bobp)))
-      (backward-char))                 ; back over (, [, <.
-    (when (and capture-opener (< capture-opener new-pos))
-      (setq new-pos capture-opener))
-    (and (/= new-pos pos) new-pos)))
+    (unless lit-start
+      (setq bod-lim (c-determine-limit 500))
+
+      ;; In C++ Mode, first check if we are within a (possibly nested) lambda
+      ;; form capture list.
+      (when (c-major-mode-is 'c++-mode)
+       (let ((paren-state (c-parse-state))
+             opener)
+         (save-excursion
+           (while (setq opener (c-pull-open-brace paren-state))
+             (goto-char opener)
+             (if (c-looking-at-c++-lambda-capture-list)
+                 (setq capture-opener (point)))))))
+
+      (while
+         ;; Go to a less nested declaration each time round this loop.
+         (and
+          (setq old-pos (point))
+          (let (pseudo)
+            (while
+                (progn
+                  (c-syntactic-skip-backward "^;{}" bod-lim t)
+                  (and (eq (char-before) ?})
+                       (save-excursion
+                         (backward-char)
+                         (setq pseudo (c-cheap-inside-bracelist-p 
(c-parse-state))))))
+              (goto-char pseudo))
+            t)
+          (> (point) bod-lim)
+          (progn (c-forward-syntactic-ws)
+                 ;; Have we got stuck in a comment at EOB?
+                 (not (and (eobp)
+                           (c-literal-start))))
+          (< (point) old-pos)
+          (progn (setq bo-decl (point))
+                 (or (not (looking-at c-protection-key))
+                     (c-forward-keyword-clause 1)))
+          (progn
+            ;; Are we looking at a keyword such as "template" or
+            ;; "typedef" which can decorate a type, or the type itself?
+            (when (or (looking-at c-prefix-spec-kwds-re)
+                      (c-forward-type t))
+              ;; We've found another candidate position.
+              (setq new-pos (min new-pos bo-decl))
+              (goto-char bo-decl))
+            t)
+          ;; Try and go out a level to search again.
+          (progn
+            (c-backward-syntactic-ws bod-lim)
+            (and (> (point) bod-lim)
+                 (or (memq (char-before) '(?\( ?\[))
+                     (and (eq (char-before) ?\<)
+                          (eq (c-get-char-property
+                               (1- (point)) 'syntax-table)
+                              c-<-as-paren-syntax))
+                     (and (eq (char-before) ?{)
+                          (save-excursion
+                            (backward-char)
+                            (consp (c-looking-at-or-maybe-in-bracelist))))
+                     )))
+          (not (bobp)))
+       (backward-char))                ; back over (, [, <.
+      (when (and capture-opener (< capture-opener new-pos))
+       (setq new-pos capture-opener))
+      (and (/= new-pos pos) new-pos))))
 
 (defun c-fl-decl-end (pos)
   ;; If POS is inside a declarator, return the end of the token that follows
-  ;; the declarator, otherwise return nil.
+  ;; the declarator, otherwise return nil.  POS being in a literal does not
+  ;; count as being in a declarator (on pragmatic grounds).
   (goto-char pos)
   (let ((lit-start (c-literal-start))
        pos1)
-    (if lit-start (goto-char lit-start))
-    (c-backward-syntactic-ws)
-    (when (setq pos1 (c-on-identifier))
-      (goto-char pos1)
-      (let ((lim (save-excursion
-                  (and (c-beginning-of-macro)
-                       (progn (c-end-of-macro) (point))))))
-       (when (and (c-forward-declarator lim)
-                  (or (not (eq (char-after) ?\())
-                      (c-go-list-forward nil lim))
-                  (eq (c-forward-token-2 1 nil lim) 0))
-         (c-backward-syntactic-ws)
-         (point))))))
+    (unless lit-start
+      (c-backward-syntactic-ws)
+      (when (setq pos1 (c-on-identifier))
+       (goto-char pos1)
+       (let ((lim (save-excursion
+                    (and (c-beginning-of-macro)
+                         (progn (c-end-of-macro) (point))))))
+         (when (and (c-forward-declarator lim)
+                    (or (not (eq (char-after) ?\())
+                        (c-go-list-forward nil lim))
+                    (eq (c-forward-token-2 1 nil lim) 0))
+           (c-backward-syntactic-ws)
+           (point)))))))
 
 (defun c-change-expand-fl-region (_beg _end _old-len)
   ;; Expand the region (c-new-BEG c-new-END) to an after-change font-lock
@@ -1870,9 +1966,10 @@ Note that this is a strict tail, so won't match, e.g. 
\"0x....\".")
   ;; and OLD-LEN are not used.
   (if font-lock-mode
       (setq c-new-BEG
-           (or (c-fl-decl-start c-new-BEG) (c-point 'bol c-new-BEG))
+           (or (c-fl-decl-start c-new-BEG) (c-doc-fl-decl-start c-new-BEG)
+               (c-point 'bol c-new-BEG))
            c-new-END
-           (or (c-fl-decl-end c-new-END)
+           (or (c-fl-decl-end c-new-END) (c-doc-fl-decl-end c-new-END)
                (c-point 'bonl c-new-END)))))
 
 (defun c-context-expand-fl-region (beg end)
@@ -1880,8 +1977,10 @@ Note that this is a strict tail, so won't match, e.g. 
\"0x....\".")
   ;; "local" declaration containing BEG (see `c-fl-decl-start') or BOL BEG is
   ;; in.  NEW-END is beginning of the line after the one END is in.
   (c-save-buffer-state ()
-    (cons (or (c-fl-decl-start beg) (c-point 'bol beg))
-         (or (c-fl-decl-end end) (c-point 'bonl (1- end))))))
+    (cons (or (c-fl-decl-start beg) (c-doc-fl-decl-start beg)
+             (c-point 'bol beg))
+         (or (c-fl-decl-end end) (c-doc-fl-decl-end end)
+             (c-point 'bonl (1- end))))))
 
 (defun c-before-context-fl-expand-region (beg end)
   ;; Expand the region (BEG END) as specified by
@@ -2511,6 +2610,7 @@ Key bindings:
 
 ;; reporter-submit-bug-report requires sendmail.
 (declare-function mail-position-on-field "sendmail" (field &optional soft))
+(declare-function mail-text "sendmail" ())
 
 (defun c-submit-bug-report ()
   "Submit via mail a bug report on CC Mode."
@@ -2575,9 +2675,26 @@ Key bindings:
        vars)
       (lambda ()
        (run-hooks 'c-prepare-bug-report-hook)
+       (let ((hook (get mail-user-agent 'hookvar)))
+         (if hook
+             (add-hook hook
+                       (lambda ()
+                         (save-excursion
+                           (mail-text)
+                           (unless (looking-at "Package: ")
+                             (insert "Package: " c-mode-bug-package "\n\n"))))
+                       nil t)))
        (save-excursion
          (or (mail-position-on-field "X-Debbugs-Package")
-             (insert c-mode-bug-package)))
+             (insert c-mode-bug-package))
+         ;; For mail clients that do not support X- headers.
+         ;; Sadly reporter-submit-bug-report unconditionally adds
+         ;; a blank line before SALUTATION, so we can't use that.
+         ;; It is also sad that reporter offers no way to leave point
+         ;; after this line we are now inserting.
+         (mail-text)
+         (or (looking-at "Package:")
+             (insert "Package: " c-mode-bug-package)))
        (insert (format "Buffer Style: %s\nc-emacs-features: %s\n"
                        style c-features)))))))
 
diff --git a/lisp/progmodes/cc-styles.el b/lisp/progmodes/cc-styles.el
index a1f3261..92ea671 100644
--- a/lisp/progmodes/cc-styles.el
+++ b/lisp/progmodes/cc-styles.el
@@ -1,6 +1,6 @@
 ;;; cc-styles.el --- support for styles in CC Mode
 
-;; Copyright (C) 1985, 1987, 1992-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1992-2019 Free Software Foundation, Inc.
 
 ;; Authors:    2004- Alan Mackenzie
 ;;             1998- Martin Stjernholm
@@ -68,7 +68,9 @@
                         (arglist-close . c-lineup-arglist)
                         (inline-open . 0)
                         (brace-list-open . +)
-                        (brace-list-intro . c-lineup-arglist-intro-after-paren)
+                        (brace-list-intro . (first
+                                             
c-lineup-2nd-brace-entry-in-arglist
+                                             c-lineup-class-decl-init-+ +))
                         (topmost-intro-cont
                          . (first c-lineup-topmost-intro-cont
                                   c-lineup-gnu-DEFUN-intro-cont))))
@@ -95,6 +97,9 @@
                         (label . 0)
                         (statement-cont . +)
                         (inline-open . 0)
+                        (brace-list-intro . (first
+                                             
c-lineup-2nd-brace-entry-in-arglist
+                                             c-lineup-class-decl-init-+ +))
                         (inexpr-class . 0))))
 
     ("stroustrup"
@@ -104,6 +109,9 @@
                         (substatement-open . 0)
                         (substatement-label . 0)
                         (label . 0)
+                        (brace-list-intro . (first
+                                             
c-lineup-2nd-brace-entry-in-arglist
+                                             c-lineup-class-decl-init-+ +))
                         (statement-cont . +))))
 
     ("whitesmith"
@@ -194,6 +202,9 @@
      (c-offsets-alist  . ((substatement-open . 0)
                          (inextern-lang . 0)
                          (arglist-intro . +)
+                         (brace-list-intro . (first
+                                              
c-lineup-2nd-brace-entry-in-arglist
+                                              c-lineup-class-decl-init-+ +))
                          (knr-argdecl-intro . +)))
      (c-hanging-braces-alist . ((brace-list-open)
                                (brace-list-intro)
@@ -219,6 +230,9 @@
                         (statement-cont        . +)
                         (arglist-intro  . c-lineup-arglist-intro-after-paren)
                         (arglist-close  . c-lineup-arglist)
+                        (brace-list-intro . (first
+                                             
c-lineup-2nd-brace-entry-in-arglist
+                                             c-lineup-class-decl-init-+ +))
                         (access-label   . 0)
                         (inher-cont     . c-lineup-java-inher)
                         (func-decl-cont . c-lineup-java-throws))))
diff --git a/lisp/progmodes/cc-vars.el b/lisp/progmodes/cc-vars.el
index 0475114..6e8acd4 100644
--- a/lisp/progmodes/cc-vars.el
+++ b/lisp/progmodes/cc-vars.el
@@ -1,6 +1,6 @@
 ;;; cc-vars.el --- user customization variables for CC Mode
 
-;; Copyright (C) 1985, 1987, 1992-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1992-2019 Free Software Foundation, Inc.
 
 ;; Authors:    2002- Alan Mackenzie
 ;;             1998- Martin Stjernholm
@@ -1115,7 +1115,7 @@ can always override the use of `c-default-style' by 
making calls to
        ;; Anchor pos: At the brace list decl start(*).
        (brace-list-intro      . +)
        ;; Anchor pos: At the brace list decl start(*).
-       (brace-list-entry      . c-lineup-under-anchor)
+       (brace-list-entry      . 0)
        ;; Anchor pos: At the first non-ws char after the open paren if
        ;; the first token is on the same line, otherwise boi at that
        ;; token.
@@ -1649,7 +1649,9 @@ white space either before or after the operator, but not 
both."
 
 ;; Initialize the next two to a regexp which never matches.
 (defvar c-noise-macro-with-parens-name-re "a\\`")
+(make-variable-buffer-local 'c-noise-macro-with-parens-name-re)
 (defvar c-noise-macro-name-re "a\\`")
+(make-variable-buffer-local 'c-noise-macro-name-re)
 
 (defcustom c-noise-macro-names nil
   "A list of names of macros which expand to nothing, or compiler extensions
@@ -1664,6 +1666,7 @@ this implicitly by reinitializing C/C++/Objc Mode on any 
buffer)."
   :type '(repeat :tag "List of names" string)
   :group 'c)
 (put 'c-noise-macro-names 'safe-local-variable #'c-string-list-p)
+(make-variable-buffer-local 'c-noise-macro-names)
 
 (defcustom c-noise-macro-with-parens-names nil
   "A list of names of macros \(or compiler extensions like \"__attribute__\")
@@ -1673,6 +1676,7 @@ These are recognized by CC Mode only in declarations."
   :type '(repeat :tag "List of names (possibly empty)" string)
   :group 'c)
 (put 'c-noise-macro-with-parens-names 'safe-local-variable #'c-string-list-p)
+(make-variable-buffer-local 'c-noise-macro-with-parens-names)
 
 (defun c-make-noise-macro-regexps ()
   ;; Convert `c-noise-macro-names' and `c-noise-macro-with-parens-names' into
diff --git a/lisp/progmodes/cfengine.el b/lisp/progmodes/cfengine.el
index 1bac042..efe648b 100644
--- a/lisp/progmodes/cfengine.el
+++ b/lisp/progmodes/cfengine.el
@@ -1,6 +1,6 @@
 ;;; cfengine.el --- mode for editing Cfengine files
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Love <address@hidden>
 ;; Maintainer: Ted Zlatanov <address@hidden>
@@ -852,8 +852,8 @@ This includes those for cfservd as well as cfagent.")
     ;; Classes.
     ("^[ \t]*\\([[:alnum:]_().|!]+\\)::" 1 font-lock-function-name-face)
     ;; Variables.
-    ("$(\\([[:alnum:]_]+\\))" 1 font-lock-variable-name-face)
-    ("${\\([[:alnum:]_]+\\)}" 1 font-lock-variable-name-face)
+    ("\\$(\\([[:alnum:]_]+\\))" 1 font-lock-variable-name-face)
+    ("\\${\\([[:alnum:]_]+\\)}" 1 font-lock-variable-name-face)
     ;; Variable definitions.
     ("\\_<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face)
     ;; File, acl &c in group:   { token ... }
diff --git a/lisp/progmodes/cmacexp.el b/lisp/progmodes/cmacexp.el
index 7dcfb10..a081c02 100644
--- a/lisp/progmodes/cmacexp.el
+++ b/lisp/progmodes/cmacexp.el
@@ -1,6 +1,6 @@
 ;;; cmacexp.el --- expand C macros in a region
 
-;; Copyright (C) 1992, 1994, 1996, 2000-2018 Free Software Foundation,
+;; Copyright (C) 1992, 1994, 1996, 2000-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Francesco Potortì <address@hidden>
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 973d3a0..1a0d9bd 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -1,6 +1,6 @@
 ;;; compile.el --- run compiler as inferior of Emacs, parse error messages  
-*- lexical-binding:t -*-
 
-;; Copyright (C) 1985-1987, 1993-1999, 2001-2018 Free Software
+;; Copyright (C) 1985-1987, 1993-1999, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Authors: Roland McGrath <address@hidden>,
@@ -43,23 +43,20 @@
 ;;;###autoload
 (defcustom compilation-mode-hook nil
   "List of hook functions run by `compilation-mode'."
-  :type 'hook
-  :group 'compilation)
+  :type 'hook)
 
 ;;;###autoload
 (defcustom compilation-start-hook nil
   "Hook run after starting a new compilation process.
 The hook is run with one argument, the new process."
-  :type 'hook
-  :group 'compilation)
+  :type 'hook)
 
 ;;;###autoload
 (defcustom compilation-window-height nil
   "Number of lines in a compilation window.
 If nil, use Emacs default."
   :type '(choice (const :tag "Default" nil)
-                integer)
-  :group 'compilation)
+                integer))
 
 (defvar compilation-filter-hook nil
   "Hook run after `compilation-filter' has inserted a string into the buffer.
@@ -80,7 +77,7 @@ If this is buffer-local in the destination buffer, Emacs obeys
 that value, otherwise it uses the value in the *compilation*
 buffer.  This enables a major-mode to specify its own value.")
 
-(defvar compilation-parse-errors-filename-function nil
+(defvar compilation-parse-errors-filename-function #'identity
   "Function to call to post-process filenames while parsing error messages.
 It takes one arg FILENAME which is the name of a file as found
 in the compilation output, and should return a transformed file name
@@ -89,18 +86,18 @@ or a buffer, the one which was compiled.")
 ;; match data.
 
 ;;;###autoload
-(defvar compilation-process-setup-function nil
+(defvar compilation-process-setup-function #'ignore
   "Function to call to customize the compilation process.
 This function is called immediately before the compilation process is
 started.  It can be used to set any variables or functions that are used
 while processing the output of the compilation process.")
 
 ;;;###autoload
-(defvar compilation-buffer-name-function nil
+(defvar compilation-buffer-name-function #'compilation--default-buffer-name
   "Function to compute the name of a compilation buffer.
 The function receives one argument, the name of the major mode of the
 compilation buffer.  It should return a string.
-If nil, compute the name with `(concat \"*\" (downcase major-mode) \"*\")'.")
+By default, it returns `(concat \"*\" (downcase name-of-mode) \"*\")'.")
 
 ;;;###autoload
 (defvar compilation-finish-functions nil
@@ -526,7 +523,7 @@ File = \\(.+\\), Line = \\([0-9]+\\)\\(?:, Column = 
\\([0-9]+\\)\\)?"
   "Alist of values for `compilation-error-regexp-alist'.")
 
 (defcustom compilation-error-regexp-alist
-  (mapcar 'car compilation-error-regexp-alist-alist)
+  (mapcar #'car compilation-error-regexp-alist-alist)
   "Alist that specifies how to match errors in compiler output.
 On GNU and Unix, any string is a valid filename, so these
 matchers must make some common sense assumptions, which catch
@@ -561,6 +558,10 @@ of lines.  COLUMN can also be of the form (COLUMN . 
END-COLUMN)
 meaning a range of columns starting on LINE and ending on
 END-LINE, if that matched.
 
+LINE, END-LINE, COL, and END-COL can also be functions of no argument
+that return the corresponding line or column number.  They can assume REGEXP
+has just been matched, and should correspondingly preserve this match data.
+
 TYPE is 2 or nil for a real error or 1 for warning or 0 for info.
 TYPE can also be of the form (WARNING . INFO).  In that case this
 will be equivalent to 1 if the WARNING'th subexpression matched
@@ -581,8 +582,7 @@ listed text properties PROP# are given values VAL# as well."
   :type '(repeat (choice (symbol :tag "Predefined symbol")
                         (sexp :tag "Error specification")))
   :link `(file-link :tag "example file"
-                   ,(expand-file-name "compilation.txt" data-directory))
-  :group 'compilation)
+                   ,(expand-file-name "compilation.txt" data-directory)))
 
 ;;;###autoload(put 'compilation-directory 'safe-local-variable 'stringp)
 (defvar compilation-directory nil
@@ -642,7 +642,6 @@ If this is buffer-local in the destination buffer, Emacs 
obeys
 that value, otherwise it uses the value in the *compilation*
 buffer.  This enables a major-mode to specify its own value."
   :type 'boolean
-  :group 'compilation
   :version "20.4")
 
 (defcustom compilation-read-command t
@@ -653,15 +652,13 @@ Note that changing this to nil may be a security risk, 
because a
 file might define a malicious `compile-command' as a file local
 variable, and you might not notice.  Therefore, `compile-command'
 is considered unsafe if this variable is nil."
-  :type 'boolean
-  :group 'compilation)
+  :type 'boolean)
 
 ;;;###autoload
 (defcustom compilation-ask-about-save t
   "Non-nil means \\[compile] asks which buffers to save before compiling.
 Otherwise, it saves all modified buffers without asking."
-  :type 'boolean
-  :group 'compilation)
+  :type 'boolean)
 
 (defcustom compilation-save-buffers-predicate nil
   "The second argument (PRED) passed to `save-some-buffers' before compiling.
@@ -675,7 +672,6 @@ of `my-compilation-root' here."
           (const :tag "Default (save all file-visiting buffers)" nil)
           (const :tag "Save all buffers" t)
           function)
-  :group 'compilation
   :version "24.1")
 
 ;;;###autoload
@@ -684,8 +680,7 @@ of `my-compilation-root' here."
 Elements should be directory names, not file names of directories.
 The value nil as an element means to try the default directory."
   :type '(repeat (choice (const :tag "Default" nil)
-                        (string :tag "Directory")))
-  :group 'compilation)
+                        (string :tag "Directory"))))
 
 ;;;###autoload
 (defcustom compile-command (purecopy "make -k ")
@@ -705,8 +700,7 @@ You might also use mode hooks to specify it in certain 
modes, like this:
                            (file-name-sans-extension buffer-file-name))))))))
 
 It's often useful to leave a space at the end of the value."
-  :type 'string
-  :group 'compilation)
+  :type 'string)
 ;;;###autoload(put 'compile-command 'safe-local-variable (lambda (a) (and 
(stringp a) (or (not (boundp 'compilation-read-command)) 
compilation-read-command))))
 
 ;;;###autoload
@@ -715,7 +709,6 @@ It's often useful to leave a space at the end of the value."
 This only affects platforms that support asynchronous processes (see
 `start-process'); synchronous compilation processes never accept input."
   :type 'boolean
-  :group 'compilation
   :version "22.1")
 
 ;; A weak per-compilation-buffer hash indexed by (FILENAME . DIRECTORY).  Each
@@ -728,8 +721,9 @@ This only affects platforms that support asynchronous 
processes (see
 Then every error line will have a debug text property with the matcher that
 fit this line and the match data.  Use `describe-text-properties'.")
 
-(defvar compilation-exit-message-function nil "\
-If non-nil, called when a compilation process dies to return a status message.
+(defvar compilation-exit-message-function
+  (lambda (_process-status exit-status msg) (cons msg exit-status))
+  "If non-nil, called when a compilation process dies to return a status 
message.
 This should be a function of three arguments: process status, exit status,
 and exit message; it returns a cons (MESSAGE . MODELINE) of the strings to
 write into the compilation buffer, and to put in its mode line.")
@@ -741,7 +735,6 @@ This list is temporarily prepended to `process-environment' 
prior to
 starting the compilation process."
   :type '(repeat (string :tag "ENVVARNAME=VALUE"))
   :options '(("LANG=C"))
-  :group 'compilation
   :version "24.1")
 
 ;; History of compile commands.
@@ -750,19 +743,16 @@ starting the compilation process."
 (defface compilation-error
   '((t :inherit error))
   "Face used to highlight compiler errors."
-  :group 'compilation
   :version "22.1")
 
 (defface compilation-warning
   '((t :inherit warning))
   "Face used to highlight compiler warnings."
-  :group 'compilation
   :version "22.1")
 
 (defface compilation-info
   '((t :inherit success))
   "Face used to highlight compiler information."
-  :group 'compilation
   :version "22.1")
 
 ;; The next three faces must be able to stand out against the
@@ -774,13 +764,11 @@ starting the compilation process."
     (((class color) (min-colors 8)) (:foreground "red"))
     (t (:inverse-video t :weight bold)))
   "Face for Compilation mode's \"error\" mode line indicator."
-  :group 'compilation
   :version "24.3")
 
 (defface compilation-mode-line-run
   '((t :inherit compilation-warning))
   "Face for Compilation mode's \"running\" mode line indicator."
-  :group 'compilation
   :version "24.3")
 
 (defface compilation-mode-line-exit
@@ -790,19 +778,16 @@ starting the compilation process."
     (((class color)) (:foreground "green" :weight bold))
     (t (:weight bold)))
   "Face for Compilation mode's \"exit\" mode line indicator."
-  :group 'compilation
   :version "24.3")
 
 (defface compilation-line-number
   '((t :inherit font-lock-keyword-face))
   "Face for displaying line numbers in compiler messages."
-  :group 'compilation
   :version "22.1")
 
 (defface compilation-column-number
   '((t :inherit font-lock-doc-face))
   "Face for displaying column numbers in compiler messages."
-  :group 'compilation
   :version "22.1")
 
 (defcustom compilation-message-face 'underline
@@ -811,7 +796,6 @@ Faces `compilation-error-face', `compilation-warning-face',
 `compilation-info-face', `compilation-line-face' and
 `compilation-column-face' get prepended to this, when applicable."
   :type 'face
-  :group 'compilation
   :version "22.1")
 
 (defvar compilation-error-face 'compilation-error
@@ -844,7 +828,6 @@ Faces `compilation-error-face', `compilation-warning-face',
 (defcustom compilation-auto-jump-to-first-error nil
   "If non-nil, automatically jump to the first error during compilation."
   :type 'boolean
-  :group 'compilation
   :version "23.1")
 
 (defvar compilation-auto-jump-to-next nil
@@ -867,7 +850,6 @@ info, are considered errors."
   :type '(choice (const :tag "Skip warnings and info" 2)
                 (const :tag "Skip info" 1)
                 (const :tag "No skip" 0))
-  :group 'compilation
   :version "22.1")
 
 (defun compilation-set-skip-threshold (level)
@@ -891,7 +873,6 @@ Visited messages are ones for which the file, line and 
column have been jumped
 to from the current content in the current compilation buffer, even if it was
 from a different message."
   :type 'boolean
-  :group 'compilation
   :version "22.1")
 
 (defun compilation-type (type)
@@ -1129,23 +1110,27 @@ POS and RES.")
          (setq file '("*unknown*")))))
     ;; All of these fields are optional, get them only if we have an index, and
     ;; it matched some part of the message.
-    (and line
-        (setq line (match-string-no-properties line))
-        (setq line (string-to-number line)))
-    (and end-line
-        (setq end-line (match-string-no-properties end-line))
-        (setq end-line (string-to-number end-line)))
-    (if col
-        (if (functionp col)
-            (setq col (funcall col))
-          (and
-           (setq col (match-string-no-properties col))
-           (setq col (string-to-number col)))))
-    (if (and end-col (functionp end-col))
-        (setq end-col (funcall end-col))
-      (if (and end-col (setq end-col (match-string-no-properties end-col)))
-          (setq end-col (- (string-to-number end-col) -1))
-        (if end-line (setq end-col -1))))
+    (setq line
+          (if (functionp line) (funcall line)
+            (and line
+                (setq line (match-string-no-properties line))
+                 (string-to-number line))))
+    (setq end-line
+          (if (functionp end-line) (funcall end-line)
+            (and end-line
+                (setq end-line (match-string-no-properties end-line))
+                 (string-to-number end-line))))
+    (setq col
+          (if (functionp col) (funcall col)
+            (and col
+                 (setq col (match-string-no-properties col))
+                 (string-to-number col))))
+    (setq end-col
+          (or (if (functionp end-col) (funcall end-col)
+                (and end-col
+                     (setq end-col (match-string-no-properties end-col))
+                     (- (string-to-number end-col) -1)))
+              (and end-line -1)))
     (if (consp type)                   ; not a static type, check what it is.
        (setq type (or (and (car type) (match-end (car type)) 1)
                       (and (cdr type) (match-end (cdr type)) 0)
@@ -1246,12 +1231,12 @@ FMTS is a list of format specs for transforming the 
file name.
     (setq loc (compilation-assq line (compilation--file-struct->loc-tree
                                       file-struct)))
     (setq end-loc
-    (if end-line
+          (if end-line
               (compilation-assq
                end-col (compilation-assq
                         end-line (compilation--file-struct->loc-tree
                                   file-struct)))
-      (if end-col                      ; use same line element
+            (if end-col                        ; use same line element
                 (compilation-assq end-col loc))))
     (setq loc (compilation-assq col loc))
     ;; If they are new, make the loc(s) reference the file they point to.
@@ -1394,92 +1379,70 @@ to `compilation-error-regexp-alist' if RULES is nil."
       (if (consp line) (setq end-line (cdr line) line (car line)))
       (if (consp col)  (setq end-col (cdr col)   col (car col)))
 
-      (if (functionp line)
-          ;; The old compile.el had here an undocumented hook that
-          ;; allowed `line' to be a function that computed the actual
-          ;; error location.  Let's do our best.
-          (progn
-            (goto-char start)
-            (while (re-search-forward pat end t)
-              (save-match-data
-                (when compilation-debug
-                  (font-lock-append-text-property
-                   (match-beginning 0) (match-end 0)
-                   'compilation-debug (vector 'functionp item)))
-                (add-text-properties
-                 (match-beginning 0) (match-end 0)
-                 (compilation--compat-error-properties
-                  (funcall line (cons (match-string file)
-                                      (cons default-directory
-                                            (nthcdr 4 item)))
-                           (if col (match-string col))))))
-              (compilation--put-prop
-               file 'font-lock-face compilation-error-face)))
+      (unless (or (null (nth 5 item)) (integerp (nth 5 item)))
+        (error "HYPERLINK should be an integer: %s" (nth 5 item)))
 
-        (unless (or (null (nth 5 item)) (integerp (nth 5 item)))
-          (error "HYPERLINK should be an integer: %s" (nth 5 item)))
+      (goto-char start)
+      (while (re-search-forward pat end t)
+        (when (setq props (compilation-error-properties
+                           file line end-line col end-col (or type 2) fmt))
 
-        (goto-char start)
-        (while (re-search-forward pat end t)
-          (when (setq props (compilation-error-properties
-                             file line end-line col end-col (or type 2) fmt))
-
-            (when (integerp file)
-              (setq type (if (consp type)
-                             (compilation-type type)
-                           (or type 2)))
-              (compilation--note-type type)
+          (when (integerp file)
+            (let ((this-type (if (consp type)
+                                 (compilation-type type)
+                               (or type 2))))
+              (compilation--note-type this-type)
 
               (compilation--put-prop
                file 'font-lock-face
                (symbol-value (aref [compilation-info-face
                                     compilation-warning-face
                                     compilation-error-face]
-                                   type))))
-
-            (compilation--put-prop
-             line 'font-lock-face compilation-line-face)
-            (compilation--put-prop
-             end-line 'font-lock-face compilation-line-face)
-
-            (compilation--put-prop
-             col 'font-lock-face compilation-column-face)
-            (compilation--put-prop
-             end-col 'font-lock-face compilation-column-face)
-
-           ;; Obey HIGHLIGHT.
-            (dolist (extra-item (nthcdr 6 item))
-              (let ((mn (pop extra-item)))
-                (when (match-beginning mn)
-                  (let ((face (eval (car extra-item))))
-                    (cond
-                     ((null face))
-                     ((or (symbolp face) (stringp face))
-                      (put-text-property
-                       (match-beginning mn) (match-end mn)
-                       'font-lock-face face))
-                    ((and (listp face)
-                          (eq (car face) 'face)
-                          (or (symbolp (cadr face))
-                              (stringp (cadr face))))
-                      (compilation--put-prop mn 'font-lock-face (cadr face))
-                      (add-text-properties
-                       (match-beginning mn) (match-end mn)
-                       (nthcdr 2 face)))
-                     (t
-                      (error "Don't know how to handle face %S"
-                             face)))))))
-            (let ((mn (or (nth 5 item) 0)))
-              (when compilation-debug
-                (font-lock-append-text-property
-                 (match-beginning 0) (match-end 0)
-                 'compilation-debug (vector 'std item props)))
-              (add-text-properties
-               (match-beginning mn) (match-end mn)
-               (cddr props))
+                                   this-type)))))
+
+          (compilation--put-prop
+           line 'font-lock-face compilation-line-face)
+          (compilation--put-prop
+           end-line 'font-lock-face compilation-line-face)
+
+          (compilation--put-prop
+           col 'font-lock-face compilation-column-face)
+          (compilation--put-prop
+           end-col 'font-lock-face compilation-column-face)
+
+         ;; Obey HIGHLIGHT.
+          (dolist (extra-item (nthcdr 6 item))
+            (let ((mn (pop extra-item)))
+              (when (match-beginning mn)
+                (let ((face (eval (car extra-item))))
+                  (cond
+                   ((null face))
+                   ((or (symbolp face) (stringp face))
+                    (put-text-property
+                     (match-beginning mn) (match-end mn)
+                     'font-lock-face face))
+                  ((and (listp face)
+                        (eq (car face) 'face)
+                        (or (symbolp (cadr face))
+                            (stringp (cadr face))))
+                    (compilation--put-prop mn 'font-lock-face (cadr face))
+                    (add-text-properties
+                     (match-beginning mn) (match-end mn)
+                     (nthcdr 2 face)))
+                   (t
+                    (error "Don't know how to handle face %S"
+                           face)))))))
+          (let ((mn (or (nth 5 item) 0)))
+            (when compilation-debug
               (font-lock-append-text-property
-               (match-beginning mn) (match-end mn)
-               'font-lock-face (cadr props)))))))))
+               (match-beginning 0) (match-end 0)
+               'compilation-debug (vector 'std item props)))
+            (add-text-properties
+             (match-beginning mn) (match-end mn)
+             (cddr props))
+            (font-lock-append-text-property
+             (match-beginning mn) (match-end mn)
+             'font-lock-face (cadr props))))))))
 
 (defvar compilation--parsed -1)
 (make-variable-buffer-local 'compilation--parsed)
@@ -1583,7 +1546,7 @@ If the optional argument `edit-command' is non-nil, the 
command can be edited."
       (setq command (compilation-read-command (or (car compilation-arguments)
                                                  command)))
       (if compilation-arguments (setcar compilation-arguments command)))
-    (apply 'compilation-start (or compilation-arguments (list command)))))
+    (apply #'compilation-start (or compilation-arguments (list command)))))
 
 (defcustom compilation-scroll-output nil
   "Non-nil to scroll the *compilation* buffer window as output appears.
@@ -1597,23 +1560,25 @@ point on its location in the *compilation* buffer."
   :type '(choice (const :tag "No scrolling" nil)
                 (const :tag "Scroll compilation output" t)
                 (const :tag "Stop scrolling at the first error" first-error))
-  :version "20.3"
-  :group 'compilation)
+  :version "20.3")
 
 
-(defun compilation-buffer-name (name-of-mode mode-command name-function)
+(defun compilation-buffer-name (name-of-mode _mode-command name-function)
   "Return the name of a compilation buffer to use.
 If NAME-FUNCTION is non-nil, call it with one argument NAME-OF-MODE
 to determine the buffer name.
 Likewise if `compilation-buffer-name-function' is non-nil.
-If current buffer has the major mode MODE-COMMAND,
+If current buffer has the NAME-OF-MODE major mode,
 return the name of the current buffer, so that it gets reused.
 Otherwise, construct a buffer name from NAME-OF-MODE."
-  (cond (name-function
-        (funcall name-function name-of-mode))
-       (compilation-buffer-name-function
-        (funcall compilation-buffer-name-function name-of-mode))
-       ((eq mode-command major-mode)
+  (funcall (or name-function
+              compilation-buffer-name-function
+               #'compilation--default-buffer-name)
+           name-of-mode))
+
+(defun compilation--default-buffer-name (name-of-mode)
+  (cond ((or (eq major-mode (intern-soft name-of-mode))
+             (eq major-mode (intern-soft (concat name-of-mode "-mode"))))
         (buffer-name))
        (t
         (concat "*" (downcase name-of-mode) "*"))))
@@ -1622,8 +1587,7 @@ Otherwise, construct a buffer name from NAME-OF-MODE."
   "If t, always kill a running compilation process before starting a new one.
 If nil, ask to kill it."
   :type 'boolean
-  :version "24.3"
-  :group 'compilation)
+  :version "24.3")
 
 ;;;###autoload
 (defun compilation-start (command &optional mode name-function 
highlight-regexp)
@@ -1780,15 +1744,16 @@ Returns the compilation buffer created."
        (if (fboundp 'make-process)
            (let ((proc
                   (if (eq mode t)
-                      ;; comint uses `start-file-process'.
-                      (get-buffer-process
-                       (with-no-warnings
-                         (comint-exec
-                          outbuf (downcase mode-name)
-                          (if (file-remote-p default-directory)
-                              "/bin/sh"
-                            shell-file-name)
-                          nil `("-c" ,command))))
+                       ;; On remote hosts, the local `shell-file-name'
+                       ;; might be useless.
+                       (with-connection-local-variables
+                       ;; comint uses `start-file-process'.
+                       (get-buffer-process
+                        (with-no-warnings
+                          (comint-exec
+                           outbuf (downcase mode-name)
+                           shell-file-name
+                           nil `(,shell-command-switch ,command)))))
                     (start-file-process-shell-command (downcase mode-name)
                                                       outbuf command))))
               ;; Make the buffer's mode line show process state.
@@ -1802,11 +1767,11 @@ Returns the compilation buffer created."
               (when compilation-always-kill
                 (set-process-query-on-exit-flag proc nil))
 
-              (set-process-sentinel proc 'compilation-sentinel)
+              (set-process-sentinel proc #'compilation-sentinel)
               (unless (eq mode t)
                 ;; Keep the comint filter, since it's needed for proper
                ;; handling of the prompts.
-               (set-process-filter proc 'compilation-filter))
+               (set-process-filter proc #'compilation-filter))
              ;; Use (point-max) here so that output comes in
              ;; after the initial text,
              ;; regardless of where the user sees point.
@@ -2091,8 +2056,7 @@ by replacing the first word, e.g., 
`compilation-scroll-output' from
                            (if (boundp 'byte-compile-bound-variables)
                                (memq (cdr v) byte-compile-bound-variables)))
                        `(set (make-local-variable ',(car v)) ,(cdr v))))
-                '(compilation-buffer-name-function
-                  compilation-directory-matcher
+                '(compilation-directory-matcher
                   compilation-error
                   compilation-error-regexp-alist
                   compilation-error-regexp-alist-alist
@@ -2114,7 +2078,7 @@ by replacing the first word, e.g., 
`compilation-scroll-output' from
       (let (revert-buffer-function)
        (revert-buffer ignore-auto noconfirm))
     (if (or noconfirm (yes-or-no-p (format "Restart compilation? ")))
-       (apply 'compilation-start compilation-arguments))))
+       (apply #'compilation-start compilation-arguments))))
 
 (defvar compilation-current-error nil
   "Marker to the location from where the next error will be found.
@@ -2150,7 +2114,7 @@ Optional argument MINOR indicates this is called from
   ;; It's generally preferable to use after-change-functions since they
   ;; can be subject to combine-after-change-calls, but if we do that, we risk
   ;; running our hook after font-lock, resulting in incorrect refontification.
-  (add-hook 'before-change-functions 'compilation--flush-parse nil t)
+  (add-hook 'before-change-functions #'compilation--flush-parse nil t)
   ;; Also for minor mode, since it's not permanent-local.
   (add-hook 'change-major-mode-hook #'compilation--remove-properties nil t)
   (if minor
@@ -2162,7 +2126,7 @@ Optional argument MINOR indicates this is called from
 (defun compilation--unsetup ()
   ;; Only for minor mode.
   (font-lock-remove-keywords nil (compilation-mode-font-lock-keywords))
-  (remove-hook 'before-change-functions 'compilation--flush-parse t)
+  (remove-hook 'before-change-functions #'compilation--flush-parse t)
   (kill-local-variable 'compilation--parsed)
   (compilation--remove-properties)
   (font-lock-flush))
@@ -2175,8 +2139,7 @@ When Compilation Shell minor mode is enabled, all the
 error-parsing commands of the Compilation major mode are
 available but bound to keys that don't collide with Shell mode.
 See `compilation-mode'."
-  nil " Shell-Compile"
-  :group 'compilation
+  :lighter " Shell-Compile"
   (if compilation-shell-minor-mode
       (compilation-setup t)
     (compilation--unsetup)))
@@ -2188,8 +2151,7 @@ See `compilation-mode'."
 When Compilation minor mode is enabled, all the error-parsing
 commands of Compilation major mode are available.  See
 `compilation-mode'."
-  nil " Compilation"
-  :group 'compilation
+  :lighter " Compilation"
   (if compilation-minor-mode
       (compilation-setup t)
     (compilation--unsetup)))
@@ -2379,7 +2341,7 @@ looking for the next message."
                                                'compilation-message))
            (setq pt (compilation-next-single-property-change
                       pt 'compilation-message nil
-                                                 (line-end-position)))
+                     (line-end-position)))
            (or (setq msg (get-text-property pt 'compilation-message))
                (setq pt (point)))))
       (setq last (compilation--loc->file-struct loc))
@@ -2397,7 +2359,7 @@ looking for the next message."
                          "Moved back before first %s" (point-min))))
     (goto-char pt)
     (or msg
-       (error "No %s here" compilation-error))))
+       (user-error "No %s here" compilation-error))))
 
 (defun compilation-previous-error (n)
   "Move point to the previous error in the compilation buffer.
@@ -2585,7 +2547,6 @@ compilation output window; an arrow in the left fringe 
points to
 the current message.  If nil and there is no left fringe, the message
 displays at the top of the window; there is no arrow."
   :type '(choice integer (const :tag "No window scrolling" nil))
-  :group 'compilation
   :version "22.1")
 
 (defsubst compilation-set-window (w mk)
@@ -2679,7 +2640,7 @@ and overlay is highlighted between MK and END-MK."
                    (numberp next-error-highlight))
                ;; We want highlighting: delete overlay on next input.
                (add-hook 'pre-command-hook
-                         'compilation-goto-locus-delete-o)
+                         #'compilation-goto-locus-delete-o)
              ;; We don't want highlighting: delete overlay now.
              (delete-overlay compilation-highlight-overlay))
            ;; We want highlighting for a limited time:
@@ -2699,7 +2660,7 @@ and overlay is highlighted between MK and END-MK."
   (if (timerp next-error-highlight-timer)
       (cancel-timer next-error-highlight-timer))
   (remove-hook 'pre-command-hook
-              'compilation-goto-locus-delete-o))
+              #'compilation-goto-locus-delete-o))
 
 (defun compilation-find-file (marker filename directory &rest formats)
   "Find a buffer for file FILENAME.
@@ -2820,7 +2781,8 @@ TRUE-DIRNAME is the `file-truename' of DIRNAME, if given."
        ;; If compilation-parse-errors-filename-function is
        ;; defined, use it to process the filename.  The result might be a
        ;; buffer.
-       (when compilation-parse-errors-filename-function
+       (unless (memq compilation-parse-errors-filename-function
+                      '(nil identity))
           (save-match-data
            (setq filename
                  (funcall compilation-parse-errors-filename-function
@@ -2865,29 +2827,6 @@ TRUE-DIRNAME is the `file-truename' of DIRNAME, if 
given."
 (defvar compilation-error-list nil)
 (defvar compilation-old-error-list nil)
 
-(defun compilation--compat-error-properties (err)
-  "Map old-style error ERR to new-style message."
-  ;; Old-style structure is (MARKER (FILE DIR) LINE COL) or
-  ;; (MARKER . MARKER).
-  (let ((dst (cdr err)))
-    (if (markerp dst)
-       `(compilation-message ,(compilation--make-message
-                                (cons nil (compilation--make-cdrloc
-                                           nil nil dst))
-                                2 nil)
-         help-echo "mouse-2: visit the source location"
-         keymap compilation-button-map
-         mouse-face highlight)
-      ;; Too difficult to do it by hand: dispatch to the normal code.
-      (let* ((file (pop dst))
-            (line (pop dst))
-            (col (pop dst))
-            (filename (pop file))
-            (dirname (pop file))
-            (fmt (pop file)))
-       (compilation-internal-error-properties
-        (cons filename dirname) line nil col nil 2 fmt)))))
-
 (defun compilation--compat-parse-errors (limit)
   (when compilation-parse-errors-function
     ;; FIXME: We should remove the rest of the compilation keywords
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index f9c390c..ba007d6 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -1,6 +1,6 @@
 ;;; cperl-mode.el --- Perl code editing commands for Emacs  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1985-1987, 1991-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1987, 1991-2019 Free Software Foundation, Inc.
 
 ;; Author: Ilya Zakharevich
 ;;     Bob Olson
@@ -1884,7 +1884,7 @@ or as help on variables `cperl-tips', `cperl-problems',
 ;;Point is at start of real comment."
 ;;  (let ((c (current-column)) target cnt prevc)
 ;;    (if (= c comment-column) nil
-;;      (setq cnt (skip-chars-backward "[ \t]"))
+;;      (setq cnt (skip-chars-backward " \t"))
 ;;      (setq target (max (1+ (setq prevc
 ;;                          (current-column))) ; Else indent at comment column
 ;;                comment-column))
@@ -3145,12 +3145,12 @@ Returns true if comment is found.  In POD will not move 
the point."
                  (cond
                   ((looking-at "\\(s\\|tr\\)\\>")
                    (or (re-search-forward
-                        "\\=\\w+[ 
\t]*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*"
+                        "\\=\\w+[ 
\t]*#\\([^\n\\#]\\|\\\\[\\#]\\)*#\\([^\n\\#]\\|\\\\[\\#]\\)*"
                         lim 'move)
                        (setq stop-in t)))
                   ((looking-at "\\(m\\|q\\([qxwr]\\)?\\)\\>")
                    (or (re-search-forward
-                        "\\=\\w+[ \t]*#\\([^\n\\\\#]\\|\\\\[\\\\#]\\)*#"
+                        "\\=\\w+[ \t]*#\\([^\n\\#]\\|\\\\[\\#]\\)*#"
                         lim 'move)
                        (setq stop-in t)))
                   (t                   ; It was fair comment
@@ -3507,18 +3507,18 @@ Should be called with the point before leading colon of 
an attribute."
 (defsubst cperl-highlight-charclass (endbracket dashface bsface onec-space)
   (let ((l '(1 5 7)) ll lle lll
        ;; 2 groups, the first takes the whole match (include \[trnfabe])
-       (singleChar (concat "\\(" "[^\\\\]" "\\|" "\\\\[^cdg-mo-qsu-zA-Z0-9_]" 
"\\|" "\\\\c." "\\|" "\\\\x" 
"\\([0-9a-fA-F][0-9a-fA-F]?\\|\\={[0-9a-fA-F]+}\\)" "\\|" 
"\\\\0?[0-7][0-7]?[0-7]?" "\\|" "\\\\N{[^{}]*}" "\\)")))
+       (singleChar (concat "\\(" "[^\\]" "\\|" "\\\\[^cdg-mo-qsu-zA-Z0-9_]" 
"\\|" "\\\\c." "\\|" "\\\\x" 
"\\([0-9a-fA-F][0-9a-fA-F]?\\|\\={[0-9a-fA-F]+}\\)" "\\|" 
"\\\\0?[0-7][0-7]?[0-7]?" "\\|" "\\\\N{[^{}]*}" "\\)")))
     (while                             ; look for unescaped - between 
non-classes
        (re-search-forward
         ;; On 19.33, certain simplifications lead
         ;; to bugs (as in  [^a-z] \\| [trnfabe]  )
         (concat                        ; 1: SingleChar (include \[trnfabe])
          singleChar
-         ;;"\\(" "[^\\\\]" "\\|" "\\\\[^cdg-mo-qsu-zA-Z0-9_]" "\\|" "\\\\c." 
"\\|" "\\\\x" "\\([0-9a-fA-F][0-9a-fA-F]?\\|\\={[0-9a-fA-F]+}\\)" "\\|" 
"\\\\0?[0-7][0-7]?[0-7]?" "\\|" "\\\\N{[^{}]*}" "\\)"
+         ;;"\\(" "[^\\]" "\\|" "\\\\[^cdg-mo-qsu-zA-Z0-9_]" "\\|" "\\\\c." 
"\\|" "\\\\x" "\\([0-9a-fA-F][0-9a-fA-F]?\\|\\={[0-9a-fA-F]+}\\)" "\\|" 
"\\\\0?[0-7][0-7]?[0-7]?" "\\|" "\\\\N{[^{}]*}" "\\)"
          "\\("                         ; 3: DASH SingleChar (match optionally)
            "\\(-\\)"                   ; 4: DASH
            singleChar                  ; 5: SingleChar
-           ;;"\\(" "[^\\\\]" "\\|" "\\\\[^cdg-mo-qsu-zA-Z0-9_]" "\\|" "\\\\c." 
"\\|" "\\\\x" "\\([0-9a-fA-F][0-9a-fA-F]?\\|\\={[0-9a-fA-F]+}\\)" "\\|" 
"\\\\0?[0-7][0-7]?[0-7]?" "\\|" "\\\\N{[^{}]*}" "\\)"
+           ;;"\\(" "[^\\]" "\\|" "\\\\[^cdg-mo-qsu-zA-Z0-9_]" "\\|" "\\\\c." 
"\\|" "\\\\x" "\\([0-9a-fA-F][0-9a-fA-F]?\\|\\={[0-9a-fA-F]+}\\)" "\\|" 
"\\\\0?[0-7][0-7]?[0-7]?" "\\|" "\\\\N{[^{}]*}" "\\)"
          "\\)?"
          "\\|"
          "\\("                         ; 7: other escapes
@@ -3749,7 +3749,7 @@ the sections using `cperl-pod-head-face', 
`cperl-pod-face',
                             state-point b nil nil state)
                      state-point b)
                (if (or (nth 3 state) (nth 4 state)
-                       (looking-at "\\(cut\\|\\end\\)\\>"))
+                       (looking-at "\\(cut\\|end\\)\\>"))
                    (if (or (nth 3 state) (nth 4 state) ignore-max)
                        nil             ; Doing a chunk only
                      (message "=cut is not preceded by a POD section")
@@ -3762,10 +3762,10 @@ the sections using `cperl-pod-head-face', 
`cperl-pod-face',
                        b1 nil)         ; error condition
                  ;; We do not search to max, since we may be called from
                  ;; some hook of fontification, and max is random
-                 (or (re-search-forward "^\n=\\(cut\\|\\end\\)\\>" stop-point 
'toend)
+                 (or (re-search-forward "^\n=\\(cut\\|end\\)\\>" stop-point 
'toend)
                      (progn
                        (goto-char b)
-                       (if (re-search-forward "\n=\\(cut\\|\\end\\)\\>" 
stop-point 'toend)
+                       (if (re-search-forward "\n=\\(cut\\|end\\)\\>" 
stop-point 'toend)
                            (progn
                              (message "=cut is not preceded by an empty line")
                              (setq b1 t)
@@ -4455,13 +4455,13 @@ the sections using `cperl-pod-head-face', 
`cperl-pod-face',
                              ;; Apparently, I can't put \] into a charclass
                              ;; in m]]: m][\\\]\]] produces [\\]]
 ;;;   POSIX?  [:word:] [:^word:] only inside []
-;;;           "\\=\\(\\\\.\\|[^][\\\\]\\|\\[:\\^?\sw+:]\\|\\[[^:]\\)*]")
+;;;           "\\=\\(\\\\.\\|[^][\\]\\|\\[:\\^?\sw+:]\\|\\[[^:]\\)*]")
                              (while    ; look for unescaped ]
                                  (and argument
                                       (re-search-forward
                                        (if (eq (char-after b) ?\] )
-                                           "\\=\\(\\\\[^]]\\|[^]\\\\]\\)*\\\\]"
-                                         "\\=\\(\\\\.\\|[^]\\\\]\\)*]")
+                                           "\\=\\(\\\\[^]]\\|[^]\\]\\)*\\\\]"
+                                         "\\=\\(\\\\.\\|[^]\\]\\)*]")
                                        (1- e) 'toend))
                                ;; Is this ] an end of POSIX class?
                                (if (save-excursion
@@ -4580,7 +4580,7 @@ the sections using `cperl-pod-head-face', 
`cperl-pod-face',
                              ;; Works also if the outside delimiters are ().
                              (or;;(if (eq (char-after b) ?\) )
                               ;;(re-search-forward
-                              ;; "[^\\\\]\\(\\\\\\\\\\)*\\\\)"
+                              ;; "[^\\]\\(\\\\\\\\\\)*\\\\)"
                               ;; (1- e) 'toend)
                               (search-forward ")" (1- e) 'toend)
                               ;;)
@@ -4924,7 +4924,7 @@ conditional/loop constructs."
                              (if (looking-at 
"\\(state\\|my\\|local\\|our\\)\\>")
                                  (forward-sexp -1))))
                        (if (looking-at
-                            (concat "\\(\\elsif\\|if\\|unless\\|while\\|until"
+                            (concat "\\(elsif\\|if\\|unless\\|while\\|until"
                                     "\\|for\\(each\\)?\\>\\(\\("
                                     cperl-maybe-white-and-comment-rex
                                     "\\(state\\|my\\|local\\|our\\)\\)?"
@@ -5003,7 +5003,7 @@ Returns some position at the last line."
        ;; Looking at:
        ;; else   {
        (if (looking-at
-            "[ \t]*}?[ 
\t]*\\<\\(\\els\\(e\\|if\\)\\|continue\\|unless\\|if\\|while\\|for\\(each\\)?\\|until\\)\\>\\(\t*\\|[
 \t][ \t]+\\)[^ \t\n#]")
+            "[ \t]*}?[ 
\t]*\\<\\(els\\(e\\|if\\)\\|continue\\|unless\\|if\\|while\\|for\\(each\\)?\\|until\\)\\>\\(\t*\\|[
 \t][ \t]+\\)[^ \t\n#]")
            (progn
              (forward-word-strictly 1)
              (delete-horizontal-space)
@@ -5031,7 +5031,7 @@ Returns some position at the last line."
        ;; Looking at (with or without "}" at start, ending after "({"):
        ;; } foreach my $var ()         OR   {
        (if (looking-at
-            "[ \t]*\\(}[ 
\t]*\\)?\\<\\(\\els\\(e\\|if\\)\\|continue\\|if\\|unless\\|while\\|for\\(each\\)?\\(\\([
 \t]+\\(state\\|my\\|local\\|our\\)\\)?[ 
\t]*\\$[_a-zA-Z0-9]+\\)?\\|until\\)\\>\\([ \t]*(\\|[ \t\n]*{\\)\\|[ \t]*{")
+            "[ \t]*\\(}[ 
\t]*\\)?\\<\\(els\\(e\\|if\\)\\|continue\\|if\\|unless\\|while\\|for\\(each\\)?\\(\\([
 \t]+\\(state\\|my\\|local\\|our\\)\\)?[ 
\t]*\\$[_a-zA-Z0-9]+\\)?\\|until\\)\\>\\([ \t]*(\\|[ \t\n]*{\\)\\|[ \t]*{")
            (progn
              (setq ml (match-beginning 8)) ; "(" or "{" after control word
              (re-search-forward "[({]")
@@ -5736,9 +5736,9 @@ indentation and initial hashes.  Behaves usually outside 
of comment."
                         (if (eq (char-after (cperl-1- (match-end 0))) ?\{ )
                             'font-lock-function-name-face
                           'font-lock-variable-name-face))))
-           '("\\<\\(package\\|require\\|use\\|import\\|no\\|bootstrap\\)[ 
\t]+\\([a-zA-z_][a-zA-z_0-9:]*\\)[ \t;]" ; require A if B;
+           '("\\<\\(package\\|require\\|use\\|import\\|no\\|bootstrap\\)[ 
\t]+\\([a-zA-Z_][a-zA-Z_0-9:]*\\)[ \t;]" ; require A if B;
              2 font-lock-function-name-face)
-           '("^[ \t]*format[ \t]+\\([a-zA-z_][a-zA-z_0-9:]*\\)[ \t]*=[ \t]*$"
+           '("^[ \t]*format[ \t]+\\([a-zA-Z_][a-zA-Z_0-9:]*\\)[ \t]*=[ \t]*$"
              1 font-lock-function-name-face)
            (cond ((featurep 'font-lock-extra)
                   '("\\([]}\\\\%@>*&]\\|\\$[a-zA-Z0-9_:]*\\)[ \t]*{[ 
\t]*\\(-?[a-zA-Z0-9_:]+\\)[ \t]*}"
@@ -7261,7 +7261,7 @@ One may build such TAGS files from CPerl mode menu."
      ".->"                             ; a->b
      "->"                              ; a SPACE ->b
      "\\[-"                            ; a[-1]
-     "\\\\[&address@hidden"                    ; \&func
+     "\\\\[&address@hidden"                    ; \&func
      "^="                              ; =head
      "\\$."                            ; $|
      "<<[a-zA-Z_'\"`]"                 ; <<FOO, <<'FOO'
@@ -7347,7 +7347,7 @@ Currently it is tuned to C and Perl syntax."
      "-[a-zA-Z]"                       ; File test
      "\\\\[a-zA-Z0]"                   ; Special chars
      "^=[a-z][a-zA-Z0-9_]*"            ; POD sections
-     "[-!&*+,-./<=>?\\\\^|~]+"         ; Operator
+     "[-!&*+,./<=>?\\^|~]+"            ; Operator
      "[a-zA-Z_0-9:]+"                  ; symbol or number
      "x="
      "#!")
@@ -7364,7 +7364,7 @@ Currently it is tuned to C and Perl syntax."
   ;; Does not save-excursion
   ;; Get to the something meaningful
   (or (eobp) (eolp) (forward-char 1))
-  (re-search-backward "[-a-zA-Z0-9_:!&*+,-./<=>?\\\\^|address@hidden"
+  (re-search-backward "[-a-zA-Z0-9_:!&*+,./<=>?\\^|address@hidden"
                      (point-at-bol)
                      'to-beg)
   ;;  (cond
@@ -7391,8 +7391,8 @@ Currently it is tuned to C and Perl syntax."
     (forward-char -1))
    ((and (looking-at "\\^") (eq (preceding-char) ?\$)) ; $^I
     (forward-char -1))
-   ((looking-at "[-!&*+,-./<=>?\\\\^|~]")
-    (skip-chars-backward "-!&*+,-./<=>?\\\\^|~")
+   ((looking-at "[-!&*+,./<=>?\\^|~]")
+    (skip-chars-backward "-!&*+,./<=>?\\^|~")
     (cond
      ((and (eq (preceding-char) ?\$)
           (not (eq (char-after (- (point) 2)) ?\$))) ; $-
@@ -7983,7 +7983,7 @@ prototype \\&SUB  Returns prototype of the function given 
a reference.
                       "\\|"            ; $ ^
                       "[$^]"
                       "\\|"            ; simple-code simple-code*?
-                      "\\(\\\\.\\|[^][()#|*+?\n]\\)\\([*+{?]\\??\\)?" ; 4 5
+                      "\\(\\\\.\\|[^][()#|*+?$^\n]\\)\\([*+{?]\\??\\)?" ; 4 5
                       "\\|"            ; Class
                       "\\(\\[\\)"      ; 6
                       "\\|"            ; Grouping
@@ -8145,7 +8145,7 @@ prototype \\&SUB  Returns prototype of the function given 
a reference.
       ;; Protect fragile " ", "#"
       (if have-x nil
        (goto-char (1+ b))
-       (while (re-search-forward "\\(\\=\\|[^\\\\]\\)\\(\\\\\\\\\\)*[ \t\n#]" 
e t) ; Need to include (?#) too?
+       (while (re-search-forward "\\(\\=\\|[^\\]\\)\\(\\\\\\\\\\)*[ \t\n#]" e 
t) ; Need to include (?#) too?
          (forward-char -1)
          (insert "\\")
          (forward-char 1)))
@@ -8174,7 +8174,7 @@ We suppose that the regexp is scanned already."
          (error "Cannot find `(' which starts a group"))
       (setq done
            (save-excursion
-             (skip-chars-backward "\\")
+             (skip-chars-backward "\\\\")
              (looking-at "\\(\\\\\\\\\\)*(")))
       (or done (forward-char -1)))))
 
@@ -8675,9 +8675,7 @@ start with default arguments, then refine the slowdown 
regions."
   (or l (setq l 1))
   (or step (setq step 500))
   (or lim (setq lim 40))
-  (let* ((timems (function (lambda ()
-                            (let ((tt (current-time)))
-                              (+ (* 1000 (nth 1 tt)) (/ (nth 2 tt) 1000))))))
+  (let* ((timems (function (lambda () (car (encode-time nil 1000)))))
         (tt (funcall timems)) (c 0) delta tot)
     (goto-char (point-min))
     (forward-line (1- l))
diff --git a/lisp/progmodes/cpp.el b/lisp/progmodes/cpp.el
index 432be1a..29988eb 100644
--- a/lisp/progmodes/cpp.el
+++ b/lisp/progmodes/cpp.el
@@ -1,6 +1,6 @@
 ;;; cpp.el --- highlight or hide text according to cpp conditionals
 
-;; Copyright (C) 1994-1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Per Abrahamsen <address@hidden>
 ;; Keywords: c, faces, tools
@@ -849,8 +849,8 @@ If that option is nil, don't prints messages.
 ARGS are the same as for `message'."
   (when cpp-message-min-time-interval
     (let ((time (current-time)))
-      (when (>= (float-time (time-subtract time cpp-progress-time))
-                cpp-message-min-time-interval)
+      (unless (time-less-p cpp-message-min-time-interval
+                          (time-subtract time cpp-progress-time))
         (setq cpp-progress-time time)
         (apply 'message args)))))
 
diff --git a/lisp/progmodes/cwarn.el b/lisp/progmodes/cwarn.el
index ff79b90..9ed9fb3 100644
--- a/lisp/progmodes/cwarn.el
+++ b/lisp/progmodes/cwarn.el
@@ -1,6 +1,6 @@
 ;;; cwarn.el --- highlight suspicious C and C++ constructions
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Anders Lindgren
 ;; Keywords: c, languages, faces
diff --git a/lisp/progmodes/dcl-mode.el b/lisp/progmodes/dcl-mode.el
index bea2519..d5803c7 100644
--- a/lisp/progmodes/dcl-mode.el
+++ b/lisp/progmodes/dcl-mode.el
@@ -1,6 +1,6 @@
 ;;; dcl-mode.el --- major mode for editing DCL command files
 
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Odd Gripenstam <address@hidden>
 ;; Maintainer: address@hidden
@@ -1580,7 +1580,7 @@ Find the column of the first non-blank character on the 
line.
 Returns the column offset."
   (save-excursion
     (beginning-of-line)
-    (re-search-forward "^$[ \t]*" nil t)
+    (re-search-forward "^\\$[ \t]*" nil t)
     (current-column)))
 
 
diff --git a/lisp/progmodes/ebnf-abn.el b/lisp/progmodes/ebnf-abn.el
index 66f1d39..b8441a7 100644
--- a/lisp/progmodes/ebnf-abn.el
+++ b/lisp/progmodes/ebnf-abn.el
@@ -1,6 +1,6 @@
 ;;; ebnf-abn.el --- parser for ABNF (Augmented BNF)
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Vinicius Jose Latorre <address@hidden>
 ;; Maintainer: Vinicius Jose Latorre <address@hidden>
diff --git a/lisp/progmodes/ebnf-bnf.el b/lisp/progmodes/ebnf-bnf.el
index 7defe98..f28f490 100644
--- a/lisp/progmodes/ebnf-bnf.el
+++ b/lisp/progmodes/ebnf-bnf.el
@@ -1,6 +1,6 @@
 ;;; ebnf-bnf.el --- parser for EBNF
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Vinicius Jose Latorre <address@hidden>
 ;; Maintainer: Vinicius Jose Latorre <address@hidden>
diff --git a/lisp/progmodes/ebnf-dtd.el b/lisp/progmodes/ebnf-dtd.el
index 2dec3f9..98284fa 100644
--- a/lisp/progmodes/ebnf-dtd.el
+++ b/lisp/progmodes/ebnf-dtd.el
@@ -1,6 +1,6 @@
 ;;; ebnf-dtd.el --- parser for DTD (Data Type Description for XML)
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Vinicius Jose Latorre <address@hidden>
 ;; Maintainer: Vinicius Jose Latorre <address@hidden>
diff --git a/lisp/progmodes/ebnf-ebx.el b/lisp/progmodes/ebnf-ebx.el
index 0dc82fc..5f9f9b2 100644
--- a/lisp/progmodes/ebnf-ebx.el
+++ b/lisp/progmodes/ebnf-ebx.el
@@ -1,6 +1,6 @@
 ;;; ebnf-ebx.el --- parser for EBNF used to specify XML (EBNFX)
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Vinicius Jose Latorre <address@hidden>
 ;; Maintainer: Vinicius Jose Latorre <address@hidden>
diff --git a/lisp/progmodes/ebnf-iso.el b/lisp/progmodes/ebnf-iso.el
index 06aaf8a..88644bb 100644
--- a/lisp/progmodes/ebnf-iso.el
+++ b/lisp/progmodes/ebnf-iso.el
@@ -1,6 +1,6 @@
 ;;; ebnf-iso.el --- parser for ISO EBNF
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Vinicius Jose Latorre <address@hidden>
 ;; Maintainer: Vinicius Jose Latorre <address@hidden>
diff --git a/lisp/progmodes/ebnf-otz.el b/lisp/progmodes/ebnf-otz.el
index 5857aa3..cbc058e 100644
--- a/lisp/progmodes/ebnf-otz.el
+++ b/lisp/progmodes/ebnf-otz.el
@@ -1,6 +1,6 @@
 ;;; ebnf-otz.el --- syntactic chart OpTimiZer
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Vinicius Jose Latorre <address@hidden>
 ;; Maintainer: Vinicius Jose Latorre <address@hidden>
diff --git a/lisp/progmodes/ebnf-yac.el b/lisp/progmodes/ebnf-yac.el
index eac0bfc..9e71235 100644
--- a/lisp/progmodes/ebnf-yac.el
+++ b/lisp/progmodes/ebnf-yac.el
@@ -1,6 +1,6 @@
 ;;; ebnf-yac.el --- parser for Yacc/Bison
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Vinicius Jose Latorre <address@hidden>
 ;; Maintainer: Vinicius Jose Latorre <address@hidden>
@@ -392,7 +392,7 @@ See documentation for variable `ebnf-yac-lex'."
 (defun ebnf-yac-skip-spaces ()
   (skip-chars-forward
    (if ebnf-yac-skip-char
-       "\n\r\t !#$&()address@hidden"
+       "-\n\r\t !#$&()*+,address@hidden"
      "\n\r\t ")
    ebnf-limit)
   (< (point) ebnf-limit))
diff --git a/lisp/progmodes/ebnf2ps.el b/lisp/progmodes/ebnf2ps.el
index e29eb74..7e7efac 100644
--- a/lisp/progmodes/ebnf2ps.el
+++ b/lisp/progmodes/ebnf2ps.el
@@ -1,6 +1,6 @@
 ;;; ebnf2ps.el --- translate an EBNF to a syntactic chart on PostScript  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Vinicius Jose Latorre <address@hidden>
 ;; Maintainer: Vinicius Jose Latorre <address@hidden>
diff --git a/lisp/progmodes/ebrowse.el b/lisp/progmodes/ebrowse.el
index 2837230..3faec49 100644
--- a/lisp/progmodes/ebrowse.el
+++ b/lisp/progmodes/ebrowse.el
@@ -1,6 +1,6 @@
-;;; ebrowse.el --- Emacs C++ class browser & tags facility
+;;; ebrowse.el --- Emacs C++ class browser & tags facility  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1992-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992-2019 Free Software Foundation, Inc.
 
 ;; Author: Gerd Moellmann <address@hidden>
 ;; Maintainer: address@hidden
@@ -233,30 +233,12 @@ Compare items with `eq' or TEST if specified."
     found))
 
 
-(defmacro ebrowse-output (&rest body)
-  "Eval BODY with a writable current buffer.
-Preserve buffer's modified state."
-  (declare (indent 0) (debug t))
-  (let ((modified (make-symbol "--ebrowse-output--")))
-    `(let (buffer-read-only (,modified (buffer-modified-p)))
-       (unwind-protect
-          (progn ,@body)
-        (set-buffer-modified-p ,modified)))))
-
-
 (defmacro ebrowse-ignoring-completion-case (&rest body)
   "Eval BODY with `completion-ignore-case' bound to t."
   (declare (indent 0) (debug t))
   `(let ((completion-ignore-case t))
      ,@body))
 
-(defmacro ebrowse-save-selective (&rest body)
-  "Eval BODY with `selective-display' restored at the end."
-  (declare (indent 0) (debug t))
-  ;; FIXME: Don't use selective-display.
-  `(let ((selective-display selective-display))
-     ,@body))
-
 (defmacro ebrowse-for-all-trees (spec &rest body)
   "For all trees in SPEC, eval BODY."
   (declare (indent 1) (debug ((sexp form) body)))
@@ -303,7 +285,7 @@ If a buffer with name NEW-NAME already exists, delete it 
first."
 (defun ebrowse-trim-string (string)
   "Return a copy of STRING with leading white space removed.
 Replace sequences of newlines with a single space."
-  (when (string-match "^[ \t\n\r]+" string)
+  (when (string-match "^[ \t\n]+" string)
     (setq string (substring string (match-end 0))))
   (cl-loop while (string-match "[\n]+" string)
            finally return string do
@@ -688,7 +670,7 @@ MARKED-ONLY non-nil means include marked classes only."
   "Return a list containing all files mentioned in a tree.
 MARKED-ONLY non-nil means include marked classes only."
   (let (list)
-    (maphash (lambda (file _dummy) (setq list (cons file list)))
+    (maphash (lambda (file _dummy) (push file list))
             (ebrowse-files-table marked-only))
     list))
 
@@ -865,7 +847,7 @@ and TREE is a list of `ebrowse-ts' structures forming the 
class tree."
     ;; Read Lisp objects.  Temporarily increase `gc-cons-threshold' to
     ;; prevent a GC that would not free any memory.
     (let ((gc-cons-threshold 2000000))
-      (while (not (progn (skip-chars-forward " \t\n\r") (eobp)))
+      (while (not (progn (skip-chars-forward " \t\n") (eobp)))
        (let* ((root (read (current-buffer)))
               (old-root-ptr (ebrowse-class-in-tree root tree)))
          (ebrowse-show-progress "Reading data" (null tree))
@@ -996,7 +978,6 @@ if for some reason a circle is in the inheritance graph."
                               (ebrowse-qualified-class-name
                                (ebrowse-ts-class (car subclass)))
                               classes)
-                    as next = nil
                     do
                     ;; Replace the subclass tree with the one found in
                     ;; CLASSES if there is already an entry for that class
@@ -1096,8 +1077,7 @@ Tree mode key bindings:
     (set (make-local-variable 'ebrowse--frozen-flag) nil)
     (setq mode-line-buffer-identification ident)
     (setq buffer-read-only t)
-    (setq selective-display t)
-    (setq selective-display-ellipses t)
+    (add-to-invisibility-spec '(ebrowse . t))
     (set (make-local-variable 'revert-buffer-function)
          #'ebrowse-revert-tree-buffer-from-file)
     (set (make-local-variable 'ebrowse--header) header)
@@ -1107,7 +1087,7 @@ Tree mode key bindings:
          (and tree (ebrowse-build-tree-obarray tree)))
     (set (make-local-variable 'ebrowse--frozen-flag) nil)
 
-    (add-hook 'write-file-functions 'ebrowse-write-file-hook-fn nil t)
+    (add-hook 'write-file-functions #'ebrowse-write-file-hook-fn nil t)
     (modify-syntax-entry ?_ (char-to-string (char-syntax ?a)))
     (when tree
       (ebrowse-redraw-tree)
@@ -1184,7 +1164,7 @@ If given a numeric N-TIMES argument, mark that many 
classes."
       ;; by a regexp replace over the whole buffer. The reason for this
       ;; is that classes might have multiple base classes. If this is
       ;; the case, they are displayed more than once in the tree.
-      (ebrowse-output
+      (with-silent-modifications
        (cl-loop
          for tree in to-change
          as regexp = (concat "^.*\\b"
@@ -1213,7 +1193,7 @@ If given a numeric N-TIMES argument, mark that many 
classes."
   "Display class marker signs in the tree between START and END."
   (interactive)
   (save-excursion
-    (ebrowse-output
+    (with-silent-modifications
       (catch 'end
        (goto-char (point-min))
        (dolist (root ebrowse--tree)
@@ -1242,8 +1222,8 @@ If given a numeric N-TIMES argument, mark that many 
classes."
 With PREFIX, insert that many filenames."
   (interactive "p")
   (unless ebrowse--show-file-names-flag
-    (ebrowse-output
-      (dotimes (i prefix)
+    (with-silent-modifications
+      (dotimes (_ prefix)
        (let ((tree (ebrowse-tree-at-point))
              start
              file-name-existing)
@@ -1393,6 +1373,18 @@ Pop to member buffer if no prefix ARG, to tree buffer 
otherwise."
 
 
 
+;;; Functions to hide/unhide text
+
+(defun ebrowse--hidden-p (&optional pos)
+  (eq (get-char-property (or pos (point)) 'invisible) 'ebrowse))
+
+(defun ebrowse--hide (start end)
+  (put-text-property start end 'invisible 'ebrowse))
+
+(defun ebrowse--unhide (start end)
+  ;; FIXME: This also removes other invisible properties!
+  (remove-text-properties start end '(invisible)))
+
 ;;; Misc tree buffer commands
 
 (defun ebrowse-set-tree-indentation ()
@@ -1418,16 +1410,14 @@ Read a class name from the minibuffer if CLASS is nil."
       (setf class
            (completing-read "Goto class: "
                             (ebrowse-tree-obarray-as-alist) nil t)))
-    (ebrowse-save-selective
-      (goto-char (point-min))
-      (widen)
-      (setf selective-display nil)
-      (setq ebrowse--last-regexp (concat "\\b" class "\\b"))
-      (if (re-search-forward ebrowse--last-regexp nil t)
-         (progn
-           (goto-char (match-beginning 0))
-           (ebrowse-unhide-base-classes))
-       (error "Not found")))))
+    (goto-char (point-min))
+    (widen)
+    (setq ebrowse--last-regexp (concat "\\b" class "\\b"))
+    (if (re-search-forward ebrowse--last-regexp nil t)
+       (progn
+         (goto-char (match-beginning 0))
+         (ebrowse-unhide-base-classes))
+      (error "Not found"))))
 
 
 
@@ -1556,7 +1546,7 @@ and possibly kill the viewed buffer."
       (setq original-frame-configuration ebrowse--frame-configuration
            exit-action ebrowse--view-exit-action))
     ;; Delete the frame in which we viewed.
-    (mapc 'delete-frame
+    (mapc #'delete-frame
          (cl-loop for frame in (frame-list)
                    when (not (assq frame original-frame-configuration))
                    collect frame))
@@ -1610,9 +1600,7 @@ specifies where to find/view the result."
   (cond (view
         (setf ebrowse-temp-position-to-view struc
               ebrowse-temp-info-to-view info)
-        (unless (boundp 'view-mode-hook)
-          (setq view-mode-hook nil))
-        (push 'ebrowse-find-pattern view-mode-hook)
+         (add-hook 'view-mode-hook #'ebrowse-find-pattern)
         (pcase where
           ('other-window (view-file-other-window file))
           ('other-frame  (ebrowse-view-file-other-frame file))
@@ -1676,7 +1664,7 @@ a pattern.  To be able to do a search in a viewed buffer,
 
 INFO is a list (TREE-HEADER TREE-OR-MEMBER MEMBER-LIST)."
   (unless position
-    (pop view-mode-hook)
+    (remove-hook 'view-mode-hook #'ebrowse-find-pattern)
     (setf viewing t
          position ebrowse-temp-position-to-view
          info ebrowse-temp-info-to-view))
@@ -1685,7 +1673,7 @@ INFO is a list (TREE-HEADER TREE-OR-MEMBER MEMBER-LIST)."
         (start (ebrowse-bs-point position))
         (offset 100)
         found)
-    (pcase-let ((`(,header ,class-or-member ,member-list) info))
+    (pcase-let ((`(,_header ,class-or-member ,member-list) info))
       ;; If no pattern is specified, construct one from the member name.
       (when (stringp pattern)
        (setq pattern (concat "^.*" (regexp-quote pattern))))
@@ -1749,7 +1737,7 @@ QUIETLY non-nil means don't display progress messages."
   (interactive)
   (or quietly (message "Displaying..."))
   (save-excursion
-    (ebrowse-output
+    (with-silent-modifications
       (erase-buffer)
       (ebrowse-draw-tree-fn)))
   (ebrowse-update-tree-buffer-mode-line)
@@ -1816,7 +1804,8 @@ This function may look weird, but this is faster than 
recursion."
                    (nconc (copy-sequence (ebrowse-ts-subclasses tree)) stack2)
                    stack1
                    (nconc (make-list (length (ebrowse-ts-subclasses tree))
-                                     (1+ level)) stack1)))))
+                                     (1+ level))
+                          stack1)))))
 
 
 
@@ -1844,69 +1833,60 @@ With prefix ARG, expand all sub-trees."
   "Expand or fold all trees in the buffer.
 COLLAPSE non-nil means fold them."
   (interactive "P")
-  (let ((line-end  (if collapse "^\n" "^\r"))
-       (insertion (if collapse "\r"  "\n")))
-    (ebrowse-output
+  (with-silent-modifications
+    (if (not collapse)
+        (ebrowse--unhide (point-min) (point-max))
       (save-excursion
        (goto-char (point-min))
-       (while (not (progn (skip-chars-forward line-end) (eobp)))
-         (when (or (not collapse)
-                   (looking-at "\n "))
-           (delete-char 1)
-           (insert insertion))
-         (when collapse
-           (skip-chars-forward "\n ")))))))
+       (while (progn (end-of-line) (not (eobp)))
+         (when (looking-at "\n ")
+            (ebrowse--hide (point) (line-end-position 2)))
+         (skip-chars-forward "\n "))))))
 
 
 (defun ebrowse-unhide-base-classes ()
   "Unhide the line the cursor is on and all base classes."
-  (ebrowse-output
+  (with-silent-modifications
     (save-excursion
       (let (indent last-indent)
-       (skip-chars-backward "^\r\n")
-       (when (not (looking-at "[\r\n][^ \t]"))
-         (skip-chars-forward "\r\n \t")
+       (forward-line 0)
+       (when (not (looking-at "\n[^ \t]"))
+         (skip-chars-forward "\n \t")
          (while (and (or (null last-indent) ;first time
                          (> indent 1)) ;not root class
-                     (re-search-backward "[\r\n][ \t]*" nil t))
+                     (re-search-backward "\n[ \t]*" nil t))
            (setf indent (- (match-end 0)
                            (match-beginning 0)))
            (when (or (null last-indent)
                      (< indent last-indent))
              (setf last-indent indent)
-             (when (looking-at "\r")
-               (delete-char 1)
-               (insert 10)))
-           (backward-char 1)))))))
+             (when (ebrowse--hidden-p)
+                (ebrowse--unhide (point) (line-end-position 2))))))))))
 
 
 (defun ebrowse-hide-line (collapse)
   "Hide/show a single line in the tree.
 COLLAPSE non-nil means hide."
-  (save-excursion
-    (ebrowse-output
-      (skip-chars-forward "^\r\n")
-      (delete-char 1)
-      (insert (if collapse 13 10)))))
+  (with-silent-modifications
+    (funcall (if collapse #'ebrowse--hide #'ebrowse--unhide)
+             (line-end-position) (line-end-position 2))))
 
 
 (defun ebrowse-collapse-fn (collapse)
   "Collapse or expand a branch of the tree.
 COLLAPSE non-nil means collapse the branch."
-  (ebrowse-output
+  (with-silent-modifications
     (save-excursion
       (beginning-of-line)
       (skip-chars-forward "> \t")
       (let ((indentation (current-column)))
        (while (and (not (eobp))
                    (save-excursion
-                     (skip-chars-forward "^\r\n")
-                     (goto-char (1+ (point)))
+                     (forward-line 1)
                      (skip-chars-forward "> \t")
                      (> (current-column) indentation)))
          (ebrowse-hide-line collapse)
-         (skip-chars-forward "^\r\n")
-         (goto-char (1+ (point))))))))
+         (forward-line 1))))))
 
 
 ;;; Electric tree selection
@@ -2164,7 +2144,7 @@ See `Electric-command-loop' for a description of STATE 
and CONDITION."
 ;;;###autoload
 (define-derived-mode ebrowse-member-mode special-mode "Ebrowse-Members"
   "Major mode for Ebrowse member buffers."
-  (mapc 'make-local-variable
+  (mapc #'make-local-variable
        '(ebrowse--decl-column          ;display column
          ebrowse--n-columns            ;number of short columns
          ebrowse--column-width         ;width of columns above
@@ -2587,7 +2567,7 @@ TAGS-FILE is the file name of the BROWSE file."
   (let ((display-fn (if ebrowse--long-display-flag
                        'ebrowse-draw-member-long-fn
                      'ebrowse-draw-member-short-fn)))
-    (ebrowse-output
+    (with-silent-modifications
       (erase-buffer)
       ;; Show this class
       (ebrowse-draw-member-buffer-class-line)
@@ -2708,7 +2688,7 @@ means the member buffer is standalone.  CLASS is its 
class."
 (defun ebrowse-draw-member-long-fn (member-list tree)
   "Display member buffer for MEMBER-LIST in long form.
 TREE is the class tree of MEMBER-LIST."
-  (dolist (member-struc (mapcar 'ebrowse-member-display-p member-list))
+  (dolist (member-struc (mapcar #'ebrowse-member-display-p member-list))
     (when member-struc
       (let ((name (ebrowse-ms-name member-struc))
            (start (point)))
@@ -3243,7 +3223,8 @@ from point as default.  Value is a list (CLASS-NAME 
MEMBER-NAME)."
        (if members
            (let* ((name (ebrowse-ignoring-completion-case
                           (completing-read prompt members nil nil 
member-name)))
-                  (completion-result (try-completion name members)))
+                  ;; (completion-result (try-completion name members))
+                   )
              ;; Cannot rely on `try-completion' returning t for exact
              ;; matches!  It returns the name as a string.
              (unless (gethash name members)
@@ -3750,6 +3731,7 @@ looks like a function call to the member."
     ;; Get the member name NAME (class-name is ignored).
     (let ((name fix-name) class-name regexp)
       (unless name
+        (ignore class-name) ;Can't use an underscore to silence the warning 
:-(!
        (cl-multiple-value-setq (class-name name)
          (cl-values-list (ebrowse-tags-read-name header "Find calls of: "))))
       ;; Set tags loop form to search for member and begin loop.
@@ -3794,14 +3776,13 @@ If VIEW is non-nil, view the position, otherwise find 
it."
         (find-file (ebrowse-position-file-name position))
         (goto-char (ebrowse-position-point position)))
        (t
-        (unwind-protect
-            (progn
-              (push (function
-                     (lambda ()
-                       (goto-char (ebrowse-position-point position))))
-                    view-mode-hook)
-              (view-file (ebrowse-position-file-name position)))
-          (pop view-mode-hook)))))
+         (let ((fn (lambda ()
+                    (goto-char (ebrowse-position-point position)))))
+          (unwind-protect
+               (progn
+                (add-hook 'view-mode-hook fn)
+                (view-file (ebrowse-position-file-name position)))
+            (remove-hook 'view-mode-hook fn))))))
 
 
 (defun ebrowse-push-position (marker info &optional target)
@@ -3904,6 +3885,7 @@ Runs the hook `ebrowse-electric-position-mode-hook'."
   (setq mode-line-buffer-identification "Electric Position Menu")
   (when (memq 'mode-name mode-line-format)
     (setq mode-line-format (copy-sequence mode-line-format))
+    ;; FIXME: Why not set `mode-name' to "Positions"?
     (setcar (memq 'mode-name mode-line-format) "Positions"))
   (set (make-local-variable 'Helper-return-blurb) "return to buffer editing")
   (setq truncate-lines t
@@ -4050,7 +4032,7 @@ Otherwise, FILE-NAME specifies the file to save the tree 
in."
          (erase-buffer)
          (setf (ebrowse-hs-member-table header) nil)
          (insert (prin1-to-string header) " ")
-         (mapc 'ebrowse-save-class tree)
+         (mapc #'ebrowse-save-class tree)
          (write-file file-name)
          (message "Tree written to file `%s'" file-name))
       (kill-buffer temp-buffer)
@@ -4065,7 +4047,7 @@ Otherwise, FILE-NAME specifies the file to save the tree 
in."
   (insert "[ebrowse-ts ")
   (prin1 (ebrowse-ts-class class))     ;class name
   (insert "(")                         ;list of subclasses
-  (mapc 'ebrowse-save-class (ebrowse-ts-subclasses class))
+  (mapc #'ebrowse-save-class (ebrowse-ts-subclasses class))
   (insert ")")
   (dolist (func ebrowse-member-list-accessors)
     (prin1 (funcall func class))
@@ -4252,12 +4234,12 @@ NUMBER-OF-STATIC-VARIABLES:"
   (unwind-protect
       (progn
        (add-hook 'electric-buffer-menu-mode-hook
-                 'ebrowse-hack-electric-buffer-menu)
+                 #'ebrowse-hack-electric-buffer-menu)
        (add-hook 'electric-buffer-menu-mode-hook
-                 'ebrowse-install-1-to-9-keys)
+                 #'ebrowse-install-1-to-9-keys)
        (call-interactively 'electric-buffer-list))
     (remove-hook 'electric-buffer-menu-mode-hook
-                'ebrowse-hack-electric-buffer-menu)))
+                #'ebrowse-hack-electric-buffer-menu)))
 
 
 ;;; Mouse support
@@ -4400,8 +4382,7 @@ EVENT is the mouse event."
     (pcase (event-click-count event)
       (2 (pcase property
           ('class-name
-           (let ((collapsed (save-excursion (skip-chars-forward "^\r\n")
-                                            (looking-at "\r"))))
+           (let ((collapsed (ebrowse--hidden-p (line-end-position))))
              (ebrowse-collapse-fn (not collapsed))))
           ('mark
            (ebrowse-toggle-mark-at-point 1)))))))
@@ -4411,9 +4392,7 @@ EVENT is the mouse event."
 (provide 'ebrowse)
 
 ;; Local variables:
-;; eval:(put 'ebrowse-output 'lisp-indent-hook 0)
 ;; eval:(put 'ebrowse-ignoring-completion-case 'lisp-indent-hook 0)
-;; eval:(put 'ebrowse-save-selective 'lisp-indent-hook 0)
 ;; eval:(put 'ebrowse-for-all-trees 'lisp-indent-hook 1)
 ;; End:
 
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 8c9b5d2..cb1b17b 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -1,6 +1,6 @@
 ;;; elisp-mode.el --- Emacs Lisp mode  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1985-1986, 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1986, 1999-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: lisp, languages
diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index 6844e9b..910c320 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -1,6 +1,6 @@
 ;;; etags.el --- etags facility for Emacs  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1985-1986, 1988-1989, 1992-1996, 1998, 2000-2018 Free
+;; Copyright (C) 1985-1986, 1988-1989, 1992-1996, 1998, 2000-2019 Free
 ;; Software Foundation, Inc.
 
 ;; Author: Roland McGrath <address@hidden>
@@ -36,7 +36,7 @@
 (require 'ring)
 (require 'button)
 (require 'xref)
-(require 'multifile)
+(require 'fileloop)
 
 ;;;###autoload
 (defvar tags-file-name nil
@@ -1281,7 +1281,7 @@ buffer-local values of tags table format variables."
       ;; This regexp matches an explicit tag name or the place where
       ;; it would start.
       (while (re-search-forward
-              "[\f\t\n\r()=,; ]?\177\\\(?:\\([^\n\001]+\\)\001\\)?"
+              "[\f\t\n\r()=,; ]?\177\\(?:\\([^\n\001]+\\)\001\\)?"
              nil t)
        (push   (prog1 (if (match-beginning 1)
                           ;; There is an explicit tag name.
@@ -1645,7 +1645,7 @@ Point should be just after a string that matches TAG."
   ;; a textual description of the four rules.
   (and (string-match "^[^ \t()=,;]+$" tag) ;rule #1
        ;; Rules #2 and #4, and a check that there's no explicit name.
-       (looking-at "[ \t()=,;]?\177\\(?:[0-9]+\\)?,\\(?:[0-9]+\\)?$")
+       (looking-at "[ \t()=,;]?\177[0-9]*,[0-9]*$")
        (save-excursion
         (backward-char (1+ (length tag)))
         (looking-at "[\n \t()=,;]")))) ;rule #3
@@ -1693,12 +1693,12 @@ Point should be just after a string that matches TAG."
     (let ((bol (point)))
       (and (search-forward "\177" (line-end-position) t)
           (re-search-backward re bol t)))))
-(define-obsolete-variable-alias 'tags-loop-revert-buffers 
'multifile-revert-buffers "27.1")
+(define-obsolete-variable-alias 'tags-loop-revert-buffers 
'fileloop-revert-buffers "27.1")
 
 ;;;###autoload
 (defalias 'next-file 'tags-next-file)
 (make-obsolete 'next-file
-               "use tags-next-file or multifile-initialize and 
multifile-next-file instead" "27.1")
+               "use tags-next-file or fileloop-initialize and 
fileloop-next-file instead" "27.1")
 ;;;###autoload
 (defun tags-next-file (&optional initialize novisit)
   "Select next file among files in current tags table.
@@ -1716,7 +1716,7 @@ if the file was newly read in, the value is the filename."
   (interactive (list (if current-prefix-arg t)))
   (when initialize ;; Not the first run.
     (tags--compat-initialize initialize))
-  (multifile-next-file novisit)
+  (fileloop-next-file novisit)
   (switch-to-buffer (current-buffer)))
 
 (defun tags--all-files ()
@@ -1742,11 +1742,11 @@ if the file was newly read in, the value is the 
filename."
                 (mapcar #'expand-file-name (tags-table-files)))))
       files)))
 
-(make-obsolete-variable 'tags-loop-operate 'multifile-initialize "27.1")
+(make-obsolete-variable 'tags-loop-operate 'fileloop-initialize "27.1")
 (defvar tags-loop-operate nil
   "Form for `tags-loop-continue' to eval to change one file.")
 
-(make-obsolete-variable 'tags-loop-scan 'multifile-initialize "27.1")
+(make-obsolete-variable 'tags-loop-scan 'fileloop-initialize "27.1")
 (defvar tags-loop-scan
   '(user-error "%s"
               (substitute-command-keys
@@ -1775,7 +1775,7 @@ Bind `case-fold-search' during the evaluation, depending 
on the value of
     (eval files))))
 
 (defun tags--compat-initialize (initialize)
-  (multifile-initialize
+  (fileloop-initialize
    (tags--compat-files initialize)
    (if tags-loop-operate
        (lambda () (tags-loop-eval tags-loop-operate))
@@ -1792,11 +1792,11 @@ argument is passed to `next-file', which see)."
   ;; interesting (it returns non-nil if so) and `tags-loop-operate' is a form 
to
   ;; evaluate to operate on an interesting file.  If the latter evaluates to
   ;; nil, we exit; otherwise we scan the next file.
-  (declare (obsolete multifile-continue "27.1"))
+  (declare (obsolete fileloop-continue "27.1"))
   (interactive)
   (when first-time ;; Backward compatibility.
     (tags--compat-initialize first-time))
-  (multifile-continue))
+  (fileloop-continue))
 
 ;; We use it to detect when the last loop was a tags-search.
 (defvar tags--last-search-operate-function nil)
@@ -1813,18 +1813,18 @@ The search will be restricted to these files.
 Also see the documentation of the `tags-file-name' variable."
   (interactive "sTags search (regexp): ")
   (unless (and (equal regexp "")
-               ;; FIXME: If some other multifile operation took place,
+               ;; FIXME: If some other fileloop operation took place,
                ;; rather than search for "", we should repeat the last search!
-              (eq multifile--operate-function
+              (eq fileloop--operate-function
                    tags--last-search-operate-function))
-    (multifile-initialize-search
+    (fileloop-initialize-search
      regexp
      (tags--compat-files (or files t))
      tags-case-fold-search)
-    ;; Store it, so we can detect if some other multifile operation took
+    ;; Store it, so we can detect if some other fileloop operation took
     ;; place since the last search!
-    (setq tags--last-search-operate-function multifile--operate-function))
-  (multifile-continue))
+    (setq tags--last-search-operate-function fileloop--operate-function))
+  (fileloop-continue))
 
 ;;;###autoload
 (defun tags-query-replace (from to &optional delimited files)
@@ -1832,15 +1832,15 @@ Also see the documentation of the `tags-file-name' 
variable."
 Third arg DELIMITED (prefix arg) means replace only word-delimited matches.
 If you exit (\\[keyboard-quit], RET or q), you can resume the query replace
 with the command \\[tags-loop-continue].
-For non-interactive use, superceded by `multifile-initialize-replace'."
+For non-interactive use, superceded by `fileloop-initialize-replace'."
   (declare (advertised-calling-convention (from to &optional delimited) 
"27.1"))
   (interactive (query-replace-read-args "Tags query replace (regexp)" t t))
-  (multifile-initialize-replace
+  (fileloop-initialize-replace
    from to
    (tags--compat-files (or files t))
    (if (equal from (downcase from)) nil 'default)
    delimited)
-  (multifile-continue))
+  (fileloop-continue))
 
 (defun tags-complete-tags-table-file (string predicate what) ; Doc string?
   (save-excursion
diff --git a/lisp/progmodes/executable.el b/lisp/progmodes/executable.el
index 9b556df..d7985a7 100644
--- a/lisp/progmodes/executable.el
+++ b/lisp/progmodes/executable.el
@@ -1,6 +1,6 @@
 ;;; executable.el --- base functionality for executable interpreter scripts 
-*- byte-compile-dynamic: t -*-
 
-;; Copyright (C) 1994-1996, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1996, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Daniel Pfeiffer <address@hidden>
 ;; Keywords: languages, unix
diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el
index c3e085d..9de8063 100644
--- a/lisp/progmodes/f90.el
+++ b/lisp/progmodes/f90.el
@@ -1,6 +1,6 @@
 ;;; f90.el --- Fortran-90 mode (free format)  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1995-1997, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-1997, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Torbjörn Einarsson <address@hidden>
 ;; Maintainer: Glenn Morris <address@hidden>
@@ -648,7 +648,7 @@ forall\\|block\\|critical\\)\\)\\_>"
 \\|enumerator\\|procedure\\|\
 logical\\|double[ \t]*precision\\|type[ \t]*(\\(?:\\sw\\|\\s_\\)+)\\|none\\)[ 
\t]*"
       (1 font-lock-keyword-face) (2 font-lock-type-face))
-    '("\\_<\\(namelist\\|common\\)[ \t]*/\\(\\(?:\\sw\\|\\s_\\)+\\)?\/"
+    '("\\_<\\(namelist\\|common\\)[ \t]*/\\(\\(?:\\sw\\|\\s_\\)+\\)?/"
       (1 font-lock-keyword-face) (2 font-lock-constant-face nil t))
     "\\_<else\\([ \t]*if\\|where\\)?\\_>"
     '("\\(&\\)[ \t]*\\(!\\|$\\)"  (1 font-lock-keyword-face))
diff --git a/lisp/progmodes/flymake-cc.el b/lisp/progmodes/flymake-cc.el
index c95d326..248c95a 100644
--- a/lisp/progmodes/flymake-cc.el
+++ b/lisp/progmodes/flymake-cc.el
@@ -1,6 +1,6 @@
 ;;; flymake-cc.el --- Flymake support for GNU tools for C/C++     -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2018  Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; Author: João Távora <address@hidden>
 ;; Keywords: languages, c
@@ -58,13 +58,15 @@ SOURCE."
   (cl-loop
    while
    (search-forward-regexp
-    "^\\(In file included from 
\\)?<stdin>:\\([0-9]+\\):\\([0-9]+\\):\n?\\(.*\\): \\(.*\\)$"
+    (concat
+     "^\\(In file included from \\)?<stdin>:\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)"
+     "?:[\n ]?\\(error\\|warning\\|note\\): \\(.*\\)$")
     nil t)
    for msg = (match-string 5)
    for (beg . end) = (flymake-diag-region
                       source
                       (string-to-number (match-string 2))
-                      (string-to-number (match-string 3)))
+                      (and (match-string 3) (string-to-number (match-string 
3))))
    for type = (if (match-string 1)
                   :error
                 (assoc-default
@@ -78,7 +80,11 @@ SOURCE."
 (defun flymake-cc-use-special-make-target ()
   "Command for checking a file via a CHK_SOURCES Make target."
   (unless (executable-find "make") (error "Make not found"))
-  '("make" "check-syntax" "CHK_SOURCES=-x c -"))
+  `("make"
+    "check-syntax"
+    ,(format "CHK_SOURCES=-x %s -c -"
+             (cond ((derived-mode-p 'c++-mode) "c++")
+                   (t "c")))))
 
 (defvar-local flymake-cc--proc nil "Internal variable for `flymake-gcc'")
 
diff --git a/lisp/progmodes/flymake-proc.el b/lisp/progmodes/flymake-proc.el
index 8600be9..dbf7561 100644
--- a/lisp/progmodes/flymake-proc.el
+++ b/lisp/progmodes/flymake-proc.el
@@ -1,6 +1,6 @@
 ;;; flymake-proc.el --- Flymake backend for external tools  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author:  Pavel Kobyakov <address@hidden>
 ;; Maintainer: João Távora <address@hidden>
@@ -874,7 +874,7 @@ can also be executed interactively independently of
   (unless (stringp file-name)
     (error "Invalid file-name"))
 
-  (let* ((dir       (file-name-directory file-name))
+  (let* ((dir       (file-name-directory (file-name-unquote file-name)))
          ;; Not sure what this slash-pos is all about, but I guess it's just
          ;; trying to remove the leading / of absolute file names.
         (slash-pos (string-match "/" dir))
@@ -887,7 +887,7 @@ can also be executed interactively independently of
 (defun flymake-proc--delete-temp-directory (dir-name)
   "Attempt to delete temp dir created by 
`flymake-proc-create-temp-with-folder-structure', do not fail on error."
   (let* ((temp-dir    temporary-file-directory)
-        (suffix      (substring dir-name (1+ (length temp-dir)))))
+        (suffix      (substring dir-name (1+ (length (directory-file-name 
temp-dir))))))
 
     (while (> (length suffix) 0)
       (setq suffix (directory-file-name suffix))
@@ -1133,7 +1133,7 @@ Use CREATE-TEMP-F for creating temp copy."
   (let* ((temp-master-file-name 
(flymake-proc--init-create-temp-source-and-master-buffer-copy
                                  'flymake-proc-get-include-dirs-dot 
'flymake-proc-create-temp-inplace
                                 '("\\.tex\\'")
-                                "[ \t]*\\in\\(?:put\\|clude\\)[ 
\t]*{\\(.*%s\\)}")))
+                                "[ \t]*in\\(?:put\\|clude\\)[ 
\t]*{\\(.*%s\\)}")))
     (when temp-master-file-name
       (flymake-proc--get-tex-args temp-master-file-name))))
 
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index ad8f50c..d6cd370 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -1,10 +1,10 @@
 ;;; flymake.el --- A universal on-the-fly syntax checker  -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author:  Pavel Kobyakov <address@hidden>
 ;; Maintainer: João Távora <address@hidden>
-;; Version: 1.0.2
+;; Version: 1.0.5
 ;; Package-Requires: ((emacs "26.1"))
 ;; Keywords: c languages tools
 
@@ -220,6 +220,15 @@ Specifically, start it when the saved buffer is actually 
displayed."
   :version "26.1"
   :type 'boolean)
 
+(defcustom flymake-suppress-zero-counters :warning
+  "Control appearance of zero-valued diagnostic counters in mode line.
+
+If set to t, supress all zero counters.  If set to a severity
+symbol like `:warning' (the default) suppress zero counters less
+severe than that severity, according to `warning-numeric-level'.
+If set to nil, don't supress any zero counters."
+  :type 'symbol)
+
 (when (fboundp 'define-fringe-bitmap)
   (define-fringe-bitmap 'flymake-double-exclamation-mark
     (vector #b00000000
@@ -293,7 +302,7 @@ generated it."
 
 (cl-defstruct (flymake--diag
                (:constructor flymake--diag-make))
-  buffer beg end type text backend data overlay)
+  buffer beg end type text backend data overlay-properties overlay)
 
 ;;;###autoload
 (defun flymake-make-diagnostic (buffer
@@ -301,13 +310,20 @@ generated it."
                                 end
                                 type
                                 text
-                                &optional data)
+                                &optional data
+                                overlay-properties)
   "Make a Flymake diagnostic for BUFFER's region from BEG to END.
 TYPE is a key to symbol and TEXT is a description of the problem
 detected in this region.  DATA is any object that the caller
-wishes to attach to the created diagnostic for later retrieval."
+wishes to attach to the created diagnostic for later retrieval.
+
+OVERLAY-PROPERTIES is an an alist of properties attached to the
+created diagnostic, overriding the default properties and any
+properties of `flymake-overlay-control' of the diagnostic's
+type."
   (flymake--diag-make :buffer buffer :beg beg :end end
-                      :type type :text text :data data))
+                      :type type :text text :data data
+                      :overlay-properties overlay-properties))
 
 ;;;###autoload
 (defun flymake-diagnostics (&optional beg end)
@@ -404,7 +420,7 @@ region is invalid."
                        (beg)
                        (progn
                          (end-of-line)
-                         (skip-chars-backward " \t\f\t\n" beg)
+                         (skip-chars-backward " \t\f\n" beg)
                          (if (eq (point) beg)
                              (line-beginning-position 2)
                            (point)))))
@@ -600,7 +616,9 @@ associated `flymake-category' return DEFAULT."
     ;; properties.
     (cl-loop
      for (ov-prop . value) in
-     (append (reverse ; ensure ealier props override later ones
+     (append (reverse
+              (flymake--diag-overlay-properties diagnostic))
+             (reverse ; ensure ealier props override later ones
               (flymake--lookup-type-property type 'flymake-overlay-control))
              (alist-get type flymake-diagnostic-types-alist))
      do (overlay-put ov ov-prop value))
@@ -724,14 +742,13 @@ report applies to that region."
           ;; the associated overlay.
           (cond
            (region
-            (dolist (diag (flymake--backend-state-diags state))
-              (let ((diag-beg (flymake--diag-beg diag))
-                    (diag-end (flymake--diag-beg diag)))
-                (when (and (< diag-beg (cdr region))
-                           (> diag-end (car region)))
-                  (delete-overlay (flymake--diag-overlay diag))
-                  (setf (flymake--backend-state-diags state)
-                        (delq diag (flymake--backend-state-diags state)))))))
+            (cl-loop for diag in (flymake--backend-state-diags state)
+                     if (or (> (flymake--diag-end diag) (car region))
+                            (< (flymake--diag-beg diag) (cdr region)))
+                     do (delete-overlay (flymake--diag-overlay diag))
+                     else collect diag into surviving
+                     finally (setf (flymake--backend-state-diags state)
+                                   surviving)))
            (first-report
             (dolist (diag (flymake--backend-state-diags state))
               (delete-overlay (flymake--diag-overlay diag)))
@@ -748,7 +765,8 @@ report applies to that region."
             (flymake-log :debug "backend %s reported %d diagnostics in %.2f 
second(s)"
                          backend
                          (length new-diags)
-                         (- (float-time) flymake-check-start-time)))
+                        (float-time
+                         (time-since flymake-check-start-time))))
           (when (and (get-buffer (flymake--diagnostics-buffer-name))
                      (get-buffer-window (flymake--diagnostics-buffer-name))
                      (null (cl-set-difference (flymake-running-backends)
@@ -956,6 +974,11 @@ special *Flymake log* buffer."  :group 'flymake :lighter
     (add-hook 'after-save-hook 'flymake-after-save-hook nil t)
     (add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook nil t)
 
+    ;; If Flymake happened to be alrady already ON, we must cleanup
+    ;; existing diagnostic overlays, lest we forget them by blindly
+    ;; reinitializing `flymake--backend-state' in the next line.
+    ;; See https://github.com/joaotavora/eglot/issues/223.
+    (mapc #'delete-overlay (flymake--overlays))
     (setq flymake--backend-state (make-hash-table))
     (setq flymake--recent-changes nil)
 
@@ -982,6 +1005,8 @@ Do it only if `flymake-no-changes-timeout' is non-nil."
     (setq
      flymake-timer
      (run-with-idle-timer
+      ;; This can use encode-time instead of seconds-to-time,
+      ;; once we can assume Emacs 27 or later.
       (seconds-to-time flymake-no-changes-timeout)
       nil
       (lambda (buffer)
@@ -1127,6 +1152,7 @@ default) no filter is applied."
 
 (put 'flymake--mode-line-format 'risky-local-variable t)
 
+
 (defun flymake--mode-line-format ()
   "Produce a pretty minor mode indicator."
   (let* ((known (hash-table-keys flymake--backend-state))
@@ -1194,8 +1220,14 @@ default) no filter is applied."
            for face = (flymake--lookup-type-property type
                                                      'mode-line-face
                                                      'compilation-error)
-           when (or diags (>= (flymake--severity type)
-                              (warning-numeric-level :warning)))
+           when (or diags
+                    (cond ((eq flymake-suppress-zero-counters t)
+                           nil)
+                          (flymake-suppress-zero-counters
+                           (>= (flymake--severity type)
+                               (warning-numeric-level
+                                flymake-suppress-zero-counters)))
+                          (t t)))
            collect `(:propertize
                      ,(format "%d" (length diags))
                      face ,face
@@ -1323,9 +1355,9 @@ POS can be a buffer position or a button"
          (target (or (get-buffer name)
                      (with-current-buffer (get-buffer-create name)
                        (flymake-diagnostics-buffer-mode)
-                       (setq flymake--diagnostics-buffer-source source)
                        (current-buffer)))))
     (with-current-buffer target
+      (setq flymake--diagnostics-buffer-source source)
       (revert-buffer)
       (display-buffer (current-buffer)))))
 
diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el
index 9c91843..f01e866 100644
--- a/lisp/progmodes/fortran.el
+++ b/lisp/progmodes/fortran.el
@@ -1,6 +1,6 @@
 ;;; fortran.el --- Fortran mode for GNU Emacs
 
-;; Copyright (C) 1986, 1993-1995, 1997-2018 Free Software Foundation,
+;; Copyright (C) 1986, 1993-1995, 1997-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Michael D. Prange <address@hidden>
@@ -1275,7 +1275,8 @@ Directive lines are treated as comments."
                      (concat "[ \t]*"
                              (regexp-quote fortran-continuation-string)))
                     (looking-at "[ \t]*$\\| \\{5\\}[^ 0\n]\\|\t[1-9]")
-                    (looking-at (concat "[ \t]*" comment-start-skip)))))
+                    (looking-at (concat "[ \t]*\\(?:"
+                                        comment-start-skip "\\)")))))
     (cond ((and continue-test
                 (not not-first-statement))
            (message "Incomplete continuation statement."))
@@ -1298,7 +1299,8 @@ Directive lines are treated as comments."
                 (or (looking-at fortran-comment-line-start-skip)
                     (looking-at fortran-directive-re)
                     (looking-at "[ \t]*$\\|     [^ 0\n]\\|\t[1-9]")
-                    (looking-at (concat "[ \t]*" comment-start-skip)))))
+                    (looking-at (concat "[ \t]*\\(?:"
+                                        comment-start-skip "\\)")))))
     (if (not not-last-statement)
         'last-statement)))
 
@@ -1795,7 +1797,7 @@ non-indentation text within the comment."
            (goto-char (match-end 0)))
           (t
            ;; Move past line number.
-           (skip-chars-forward "[ \t0-9]")))
+           (skip-chars-forward " \t0-9")))
     ;; Move past whitespace.
     (skip-chars-forward " \t")
     (current-column)))
@@ -2052,7 +2054,7 @@ If ALL is nil, only match comments that start in column > 
0."
                 (when (<= (point) bos)
                   (move-to-column (1+ fill-column))
                   ;; What is this doing???
-                  (or (re-search-forward "[\t\n,'+-/*)=]" eol t)
+                  (or (re-search-forward "[-\t\n,'+/*)=]" eol t)
                       (goto-char bol)))
                 (if (bolp)
                     (re-search-forward "[ \t]" opoint t))
@@ -2146,7 +2148,8 @@ Always returns non-nil (to prevent `fill-paragraph' being 
called)."
               (or (looking-at "[ \t]*$")
                   (looking-at fortran-comment-line-start-skip)
                   (and comment-start-skip
-                       (looking-at (concat "[ \t]*" comment-start-skip)))))
+                       (looking-at (concat "[ \t]*\\(?:"
+                                           comment-start-skip "\\)")))))
       (save-excursion
         ;; Find beginning of statement.
         (fortran-next-statement)
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index f7928f7..716f40c 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -1,6 +1,6 @@
 ;;; gdb-mi.el --- User Interface for running GDB  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Nick Roberts <address@hidden>
 ;; Maintainer: address@hidden
@@ -1373,7 +1373,7 @@ With arg, enter name of variable to be watched in the 
minibuffer."
 TEXT is the text of the button we clicked on, a + or - item.
 TOKEN is data related to this node.
 INDENT is the current indentation depth."
-  (cond ((string-match "+" text)        ;expand this node
+  (cond ((string-match "\\+" text)        ;expand this node
         (let* ((var (assoc token gdb-var-list))
                (expr (nth 1 var)) (children (nth 2 var)))
           (if (or (<= (string-to-number children) gdb-max-children)
@@ -1843,7 +1843,7 @@ commands to be prefixed by \"-interpreter-exec 
console\".")
   ;; Python and Guile commands that have an argument don't enter the
   ;; recursive reading loop.
   (let* ((control-command-p (string-match gdb-control-commands-regexp string))
-         (command-arg (match-string 3 string))
+         (command-arg (and control-command-p (match-string 3 string)))
          (python-or-guile-p (string-match gdb-python-guile-commands-regexp
                                           string)))
     (if (and control-command-p
@@ -4153,7 +4153,7 @@ member."
         (when (not value)
           (setq value "<complex data type>"))
         (if (or (not value)
-                (string-match "\\0x" value))
+                (string-match "0x" value))
             (add-text-properties 0 (length name)
                                  `(mouse-face highlight
                                               help-echo "mouse-2: create watch 
expression"
diff --git a/lisp/progmodes/glasses.el b/lisp/progmodes/glasses.el
index f2bf209..2bfc256 100644
--- a/lisp/progmodes/glasses.el
+++ b/lisp/progmodes/glasses.el
@@ -1,6 +1,6 @@
 ;;; glasses.el --- make cantReadThis readable
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Milan Zamazal <address@hidden>
 ;; Maintainer: Milan Zamazal <address@hidden>
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index b79eaf0..85f9078 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -1,6 +1,6 @@
 ;;; grep.el --- run `grep' and display the results  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1985-1987, 1993-1999, 2001-2018 Free Software
+;; Copyright (C) 1985-1987, 1993-1999, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Roland McGrath <address@hidden>
@@ -361,6 +361,9 @@ A grep buffer becomes most recent when you select Grep mode 
in it.
 Notice that using \\[next-error] or \\[compile-goto-error] modifies
 `compilation-last-buffer' rather than `grep-last-buffer'.")
 
+(defvar grep-match-face        'match
+  "Face name to use for grep matches.")
+
 ;;;###autoload
 (defconst grep-regexp-alist
   `((,(concat "^\\(?:"
@@ -384,7 +387,7 @@ Notice that using \\[next-error] or \\[compile-goto-error] 
modifies
          (when grep-highlight-matches
            (let* ((beg (match-end 0))
                   (end (save-excursion (goto-char beg) (line-end-position)))
-                  (mbeg (text-property-any beg end 'font-lock-face 
'grep-match-face)))
+                  (mbeg (text-property-any beg end 'font-lock-face 
grep-match-face)))
              (when mbeg
                (- mbeg beg)))))
       .
@@ -392,7 +395,7 @@ Notice that using \\[next-error] or \\[compile-goto-error] 
modifies
          (when grep-highlight-matches
            (let* ((beg (match-end 0))
                   (end (save-excursion (goto-char beg) (line-end-position)))
-                  (mbeg (text-property-any beg end 'font-lock-face 
'grep-match-face))
+                  (mbeg (text-property-any beg end 'font-lock-face 
grep-match-face))
                   (mend (and mbeg (next-single-property-change mbeg 
'font-lock-face nil end))))
              (when mend
                (- mend beg))))))
@@ -416,9 +419,6 @@ See `compilation-error-regexp-alist' for format details.")
 (defvar grep-error-face        'compilation-error
   "Face name to use for grep error messages.")
 
-(defvar grep-match-face        'match
-  "Face name to use for grep matches.")
-
 (defvar grep-context-face 'shadow
   "Face name to use for grep context lines.")
 
@@ -441,6 +441,15 @@ abbreviated part can also be toggled with
   :version "27.1"
   :group 'grep)
 
+(defcustom grep-search-path '(nil)
+  "Search path for grep results.
+Elements should be directory names, not file names of directories.
+The value nil as an element means to try the default directory."
+  :group 'grep
+  :version "27.1"
+  :type '(repeat (choice (const :tag "Default" nil)
+                        (string :tag "Directory"))))
+
 (defvar grep-find-abbreviate-properties
   (let ((ellipsis (if (char-displayable-p ?…) "[…]" "[...]"))
         (map (make-sparse-keymap)))
@@ -457,13 +466,13 @@ abbreviated part can also be toggled with
      (": \\(.+\\): \\(?:Permission denied\\|No such \\(?:file or 
directory\\|device or address\\)\\)$"
       1 grep-error-face)
      ;; remove match from grep-regexp-alist before fontifying
-     ("^Grep[/a-zA-z]* started.*"
+     ("^Grep[/a-zA-Z]* started.*"
       (0 '(face nil compilation-message nil help-echo nil mouse-face nil) t))
-     ("^Grep[/a-zA-z]* finished with \\(?:\\(\\(?:[0-9]+ \\)?matches 
found\\)\\|\\(no matches found\\)\\).*"
+     ("^Grep[/a-zA-Z]* finished with \\(?:\\(\\(?:[0-9]+ \\)?match\\(?:es\\)? 
found\\)\\|\\(no matches found\\)\\).*"
       (0 '(face nil compilation-message nil help-echo nil mouse-face nil) t)
       (1 compilation-info-face nil t)
       (2 compilation-warning-face nil t))
-     ("^Grep[/a-zA-z]* \\(exited 
abnormally\\|interrupt\\|killed\\|terminated\\)\\(?:.*with code 
\\([0-9]+\\)\\)?.*"
+     ("^Grep[/a-zA-Z]* \\(exited 
abnormally\\|interrupt\\|killed\\|terminated\\)\\(?:.*with code 
\\([0-9]+\\)\\)?.*"
       (0 '(face nil compilation-message nil help-echo nil mouse-face nil) t)
       (1 grep-error-face)
       (2 grep-error-face nil t))
@@ -552,7 +561,10 @@ Set up `compilation-exit-message-function' and run 
`grep-setup-hook'."
       ;; so the buffer is still unmodified if there is no output.
       (cond ((and (zerop code) (buffer-modified-p))
             (if (> grep-num-matches-found 0)
-                 (cons (format "finished with %d matches found\n" 
grep-num-matches-found)
+                 (cons (format (ngettext "finished with %d match found\n"
+                                         "finished with %d matches found\n"
+                                         grep-num-matches-found)
+                               grep-num-matches-found)
                        "matched")
                '("finished with matches found\n" . "matched")))
            ((not (buffer-modified-p))
@@ -956,8 +968,16 @@ substitution string.  Note dynamic scoping of variables.")
 The pattern can include shell wildcards.  As whitespace triggers
 completion when entering a pattern, including it requires
 quoting, e.g. `\\[quoted-insert]<space>'."
-  (let* ((bn (or (buffer-file-name)
-                (replace-regexp-in-string "<[0-9]+>\\'" "" (buffer-name))))
+  (let* ((grep-read-files-function (get major-mode 'grep-read-files))
+        (file-name-at-point
+          (run-hook-with-args-until-success 'file-name-at-point-functions))
+        (bn (if grep-read-files-function
+                (funcall grep-read-files-function)
+              (or (if (and (stringp file-name-at-point)
+                           (not (file-directory-p file-name-at-point)))
+                      file-name-at-point)
+                  (buffer-file-name)
+                  (replace-regexp-in-string "<[0-9]+>\\'" "" (buffer-name)))))
         (fn (and bn
                  (stringp bn)
                  (file-name-nondirectory bn)))
diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el
index af5b97a..4306f5d 100644
--- a/lisp/progmodes/gud.el
+++ b/lisp/progmodes/gud.el
@@ -1,6 +1,6 @@
 ;;; gud.el --- Grand Unified Debugger mode for running GDB and other debuggers 
 -*- lexical-binding:t -*-
 
-;; Copyright (C) 1992-1996, 1998, 2000-2018 Free Software Foundation,
+;; Copyright (C) 1992-1996, 1998, 2000-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Eric S. Raymond <address@hidden>
@@ -678,7 +678,7 @@ The option \"--fullname\" must be included in this value."
     ;; gud-marker-acc until we receive the rest of it.  Since we
     ;; know the full marker regexp above failed, it's pretty simple to
     ;; test for marker starts.
-    (if (string-match "\n\\(\032.*\\)?\\'" gud-marker-acc)
+    (if (string-match "\\(\n\\)?\\(\032.*\\)?\\'" gud-marker-acc)
        (progn
          ;; Everything before the potential marker start can be output.
          (setq output (concat output (substring gud-marker-acc
@@ -2237,7 +2237,7 @@ relative to a classpath directory."
                    (split-string
                     ;; Eliminate any subclass references in the class
                     ;; name string. These start with a "$"
-                     (if (string-match "$.*" p)
+                     (if (string-match "\\$.*" p)
                          (replace-match "" t t p) p)
                     "\\.") "/")
         ".java"))
diff --git a/lisp/progmodes/hideif.el b/lisp/progmodes/hideif.el
index 62e8c45..32b0b75 100644
--- a/lisp/progmodes/hideif.el
+++ b/lisp/progmodes/hideif.el
@@ -1,6 +1,6 @@
 ;;; hideif.el --- hides selected code within ifdef  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1988, 1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Brian Marick
 ;;     Daniel LaLiberte <address@hidden>
@@ -672,12 +672,7 @@ that form should be displayed.")
        result))
     (nreverse result)))
 
-(defun hif-flatten (l)
-  "Flatten a tree."
-  (apply #'nconc
-         (mapcar (lambda (x) (if (listp x)
-                                 (hif-flatten x)
-                               (list x))) l)))
+(define-obsolete-function-alias 'hif-flatten #'flatten-tree "27.1")
 
 (defun hif-expand-token-list (tokens &optional macroname expand_list)
   "Perform expansion on TOKENS till everything expanded.
@@ -748,7 +743,7 @@ detecting self-reference."
 
          expanded))
 
-      (hif-flatten (nreverse expanded)))))
+      (flatten-tree (nreverse expanded)))))
 
 (defun hif-parse-exp (token-list &optional macroname)
   "Parse the TOKEN-LIST.
@@ -1166,7 +1161,7 @@ preprocessing token"
         (setq actual-parms (cdr actual-parms)))
 
       ;; Replacement completed, flatten the whole token list
-      (setq macro-body (hif-flatten macro-body))
+      (setq macro-body (flatten-tree macro-body))
 
       ;; Stringification and token concatenation happens here
       (hif-token-concatenation (hif-token-stringification macro-body)))))
diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el
index 84b2147..dcce2a6 100644
--- a/lisp/progmodes/hideshow.el
+++ b/lisp/progmodes/hideshow.el
@@ -1,6 +1,6 @@
 ;;; hideshow.el --- minor mode cmds to selectively display code/comment blocks
 
-;; Copyright (C) 1994-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-2019 Free Software Foundation, Inc.
 
 ;; Author: Thien-Thi Nguyen <address@hidden>
 ;;      Dan Nicolaescu <address@hidden>
diff --git a/lisp/progmodes/icon.el b/lisp/progmodes/icon.el
index 6e02392..750f124 100644
--- a/lisp/progmodes/icon.el
+++ b/lisp/progmodes/icon.el
@@ -1,6 +1,6 @@
 ;;; icon.el --- mode for editing Icon code
 
-;; Copyright (C) 1989, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1989, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Chris Smith <address@hidden>
 ;; Created: 15 Feb 89
diff --git a/lisp/progmodes/idlw-complete-structtag.el 
b/lisp/progmodes/idlw-complete-structtag.el
index 07c31e7..51c9117 100644
--- a/lisp/progmodes/idlw-complete-structtag.el
+++ b/lisp/progmodes/idlw-complete-structtag.el
@@ -1,6 +1,6 @@
 ;;; idlw-complete-structtag.el --- Completion of structure tags.
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <address@hidden>
 ;; Maintainer: J.D. Smith <address@hidden>
@@ -128,7 +128,7 @@ an up-to-date completion list."
           ;; x[i+4].name.g*.  But it is complicated because we would have
           ;; to really parse this expression.  For now, we allow only
           ;; substructures, like "aaa.bbb.ccc.ddd"
-         (skip-chars-backward "[a-zA-Z0-9._$]")
+         (skip-chars-backward "a-zA-Z0-9._$")
           (setq start (point)) ;; remember the start of the completion pos.
          (and (< (point) pos)
               (not (equal (char-before) ?!)) ; no sysvars
diff --git a/lisp/progmodes/idlw-help.el b/lisp/progmodes/idlw-help.el
index 54e740b..4588e93 100644
--- a/lisp/progmodes/idlw-help.el
+++ b/lisp/progmodes/idlw-help.el
@@ -1,6 +1,6 @@
 ;;; idlw-help.el --- HTML Help code for IDLWAVE
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 ;;
 ;; Authors: J.D. Smith <address@hidden>
 ;;          Carsten Dominik <address@hidden>
diff --git a/lisp/progmodes/idlw-shell.el b/lisp/progmodes/idlw-shell.el
index 46e2eca..a3b0798 100644
--- a/lisp/progmodes/idlw-shell.el
+++ b/lisp/progmodes/idlw-shell.el
@@ -1,6 +1,6 @@
 ;; idlw-shell.el --- run IDL as an inferior process of Emacs.  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Authors: J.D. Smith <address@hidden>
 ;;          Carsten Dominik <address@hidden>
diff --git a/lisp/progmodes/idlw-toolbar.el b/lisp/progmodes/idlw-toolbar.el
index 75f5582..d3b442c 100644
--- a/lisp/progmodes/idlw-toolbar.el
+++ b/lisp/progmodes/idlw-toolbar.el
@@ -1,6 +1,6 @@
 ;;; idlw-toolbar.el --- a debugging toolbar for IDLWAVE
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <address@hidden>
 ;; Maintainer: J.D. Smith <address@hidden>
diff --git a/lisp/progmodes/idlwave.el b/lisp/progmodes/idlwave.el
index f9ea14e..6f56ce0 100644
--- a/lisp/progmodes/idlwave.el
+++ b/lisp/progmodes/idlwave.el
@@ -1,6 +1,6 @@
 ;; idlwave.el --- IDL editing mode for GNU Emacs
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Authors: J.D. Smith <address@hidden>
 ;;          Carsten Dominik <address@hidden>
@@ -3690,7 +3690,7 @@ constants - a double quote followed by an octal digit."
    (save-excursion
      (forward-char)
      (re-search-backward (concat "\\(" idlwave-idl-keywords
-                                 "\\|[[(*+-/=,^><]\\)\\s-*\\*") limit t))))
+                                 "\\|[-[(*+/=,^><]\\)\\s-*\\*") limit t))))
 
 
 ;; Statement templates
@@ -5588,7 +5588,7 @@ be set to nil to disable library catalog scanning."
             (mapcar 'car idlwave-path-alist)))
          (old-libname "")
          dir-entry dir catalog all-routines)
-      (if message-base (message message-base))
+      (if message-base (message "%s" message-base))
       (while (setq dir (pop dirs))
        (catch 'continue
          (when (file-readable-p
@@ -5603,8 +5603,7 @@ be set to nil to disable library catalog scanning."
                     message-base
                     (not (string= idlwave-library-catalog-libname
                                   old-libname)))
-               (message "%s" (concat message-base
-                                     idlwave-library-catalog-libname))
+               (message "%s%s" message-base idlwave-library-catalog-libname)
                (setq old-libname idlwave-library-catalog-libname))
              (when idlwave-library-catalog-routines
                (setq all-routines
@@ -5618,7 +5617,7 @@ be set to nil to disable library catalog scanning."
                       (setq dir-entry (assoc dir idlwave-path-alist)))
              (idlwave-path-alist-add-flag dir-entry 'lib)))))
       (unless no-load (setq idlwave-library-catalog-routines all-routines))
-      (if message-base (message (concat message-base "done"))))))
+      (if message-base (message "%sdone" message-base)))))
 
 ;;----- Communicating with the Shell -------------------
 
@@ -6455,10 +6454,10 @@ ARROW:  Location of the arrow"
      ((string-match "\\`[ \t]*\\(pro\\|function\\)\\>"
                    match-string)
       nil)
-     ((string-match "OBJ_NEW([ \t]*['\"]\\([a-zA-Z0-9$_]*\\)?\\'"
+     ((string-match "OBJ_NEW([ \t]*['\"][a-zA-Z0-9$_]*\\'"
                    match-string)
       (setq cw 'class))
-     ((string-match "\\<inherits\\s-+\\([a-zA-Z0-9$_]*\\)?\\'"
+     ((string-match "\\<inherits\\s-+[a-zA-Z0-9$_]*\\'"
                    match-string)
       (setq cw 'class))
      ((and func
@@ -7591,7 +7590,7 @@ property indicating the link is added."
        (case-fold-search t))
     (cond ((save-excursion
             ;; Check if the context is right for system variable
-            (skip-chars-backward "[a-zA-Z0-9_$]")
+            (skip-chars-backward "a-zA-Z0-9_$")
             (equal (char-before) ?!))
           (setq idlwave-completion-help-info '(idlwave-complete-sysvar-help))
           (idlwave-complete-in-buffer 'sysvar 'sysvar
diff --git a/lisp/progmodes/inf-lisp.el b/lisp/progmodes/inf-lisp.el
index 55e5d0e..3476a7f 100644
--- a/lisp/progmodes/inf-lisp.el
+++ b/lisp/progmodes/inf-lisp.el
@@ -1,6 +1,6 @@
 ;;; inf-lisp.el --- an inferior-lisp mode
 
-;; Copyright (C) 1988, 1993-1994, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1988, 1993-1994, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Olin Shivers <address@hidden>
diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index cec48a8..a0adaa8 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -1,6 +1,6 @@
 ;;; js.el --- Major mode for editing JavaScript  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Karl Landstrom <address@hidden>
 ;;         Daniel Colascione <address@hidden>
@@ -45,14 +45,11 @@
 
 ;;; Code:
 
-
 (require 'cc-mode)
 (require 'newcomment)
-(require 'thingatpt)                    ; forward-symbol etc
 (require 'imenu)
 (require 'moz nil t)
-(require 'json nil t)
-(require 'sgml-mode)
+(require 'json)
 (require 'prog-mode)
 
 (eval-when-compile
@@ -68,7 +65,7 @@
 
 ;;; Constants
 
-(defconst js--name-start-re "[a-zA-Z_$]"
+(defconst js--name-start-re (concat "[[:alpha:]_$]")
   "Regexp matching the start of a JavaScript identifier, without grouping.")
 
 (defconst js--stmt-delim-chars "^;{}?:")
@@ -479,6 +476,7 @@ This applies to function movement, marking, and so on."
   "Align continuation of non-empty ([{ lines in `js-mode'."
   :version "26.1"
   :type 'boolean
+  :safe 'booleanp
   :group 'js)
 
 (defcustom js-comment-lineup-func #'c-lineup-C-comments
@@ -573,6 +571,119 @@ then the \".\"s will be lined up:
   :safe 'booleanp
   :group 'js)
 
+(defcustom js-jsx-detect-syntax t
+  "When non-nil, automatically detect whether JavaScript uses JSX.
+`js-jsx-syntax' (which see) may be made buffer-local and set to
+t.  The detection strategy can be customized by adding elements
+to `js-jsx-regexps', which see."
+  :version "27.1"
+  :type 'boolean
+  :safe 'booleanp
+  :group 'js)
+
+(defcustom js-jsx-syntax nil
+  "When non-nil, parse JavaScript with consideration for JSX syntax.
+
+This enables proper font-locking and indentation of code using
+Facebook’s “JSX” syntax extension for JavaScript, for use with
+Facebook’s “React” library.  Font-locking is like sgml-mode.
+Indentation is also like sgml-mode, although some indentation
+behavior may differ slightly to align more closely with the
+conventions of the React developer community.
+
+When `js-mode' is already enabled, you should call
+`js-jsx-enable' to set this variable.
+
+It is set to be buffer-local (and t) when in `js-jsx-mode'."
+  :version "27.1"
+  :type 'boolean
+  :safe 'booleanp
+  :group 'js)
+
+(defcustom js-jsx-align->-with-< t
+  "When non-nil, “>” will be indented to the opening “<” in JSX.
+
+When this is enabled, JSX indentation looks like this:
+
+  <element
+    attr=\"\"
+  >
+  </element>
+  <input
+  />
+
+When this is disabled, JSX indentation looks like this:
+
+  <element
+    attr=\"\"
+    >
+  </element>
+  <input
+    />"
+  :version "27.1"
+  :type 'boolean
+  :safe 'booleanp
+  :group 'js)
+
+(defcustom js-jsx-indent-level nil
+  "When non-nil, indent JSX by this value, instead of like JS.
+
+Let `js-indent-level' be 4.  When this variable is also set to
+nil, JSX indentation looks like this (consistent):
+
+  return (
+      <element>
+          <element>
+              Hello World!
+          </element>
+      </element>
+  )
+
+Alternatively, when this variable is also set to 2, JSX
+indentation looks like this (different):
+
+  return (
+      <element>
+        <element>
+          Hello World!
+        </element>
+      </element>
+  )"
+  :version "27.1"
+  :type 'integer
+  :safe (lambda (x) (or (null x) (integerp x)))
+  :group 'js)
+;; This is how indentation behaved out-of-the-box until Emacs 27.  JSX
+;; indentation was controlled with `sgml-basic-offset', which defaults
+;; to 2, whereas `js-indent-level' defaults to 4.  Users who had the
+;; same values configured for both their HTML and JS indentation would
+;; luckily get consistent JSX indentation; most others were probably
+;; unhappy.  I’d be surprised if anyone actually wants different
+;; indentation levels, but just in case, here’s a way back to that.
+
+(defcustom js-jsx-attribute-offset 0
+  "Specifies a delta for JSXAttribute indentation.
+
+Let `js-indent-level' be 2.  When this variable is also set to 0,
+JSXAttribute indentation looks like this:
+
+  <element
+    attribute=\"value\">
+  </element>
+
+Alternatively, when this variable is also set to 2, JSXAttribute
+indentation looks like this:
+
+  <element
+      attribute=\"value\">
+  </element>
+
+This variable is like `sgml-attribute-offset'."
+  :version "27.1"
+  :type 'integer
+  :safe 'integerp
+  :group 'js)
+
 ;;; KeyMap
 
 (defvar js-mode-map
@@ -623,12 +734,6 @@ then the \".\"s will be lined up:
   "Parse state at `js--last-parse-pos'.")
 (make-variable-buffer-local 'js--state-at-last-parse-pos)
 
-(defun js--flatten-list (list)
-  (cl-loop for item in list
-           nconc (cond ((consp item)
-                        (js--flatten-list item))
-                       (item (list item)))))
-
 (defun js--maybe-join (prefix separator suffix &rest list)
   "Helper function for `js--update-quick-match-re'.
 If LIST contains any element that is not nil, return its non-nil
@@ -636,7 +741,7 @@ elements, separated by SEPARATOR, prefixed by PREFIX, and 
ended
 with SUFFIX as with `concat'.  Otherwise, if LIST is empty, return
 nil.  If any element in LIST is itself a list, flatten that
 element."
-  (setq list (js--flatten-list list))
+  (setq list (flatten-tree list))
   (when list
     (concat prefix (mapconcat #'identity list separator) suffix)))
 
@@ -793,7 +898,6 @@ macro as normal text."
 (defun js--re-search-backward-inner (regexp &optional bound count)
   "Auxiliary function for `js--re-search-backward'."
   (let ((parse)
-        str-terminator
         (orig-macro-start
          (save-excursion
            (and (js--beginning-of-macro)
@@ -804,13 +908,7 @@ macro as normal text."
                  (save-excursion (backward-char) (looking-at "/[/*]")))
         (forward-char))
       (setq parse (syntax-ppss))
-      (cond ((setq str-terminator (nth 3 parse))
-             (when (eq str-terminator t)
-               (setq str-terminator ?/))
-             (re-search-backward
-              (concat "\\([^\\]\\|^\\)" (string str-terminator))
-              (point-at-bol) t))
-            ((nth 7 parse)
+      (cond ((nth 8 parse)
              (goto-char (nth 8 parse)))
             ((or (nth 4 parse)
                  (and (eq (char-before) ?/) (eq (char-after) ?*)))
@@ -1499,6 +1597,102 @@ point of view of font-lock.  It applies highlighting 
directly with
   ;; Matcher always "fails"
   nil)
 
+;; It wouldn’t be sufficient to font-lock JSX with mere regexps, since
+;; a JSXElement may be nested inside a JS expression within the
+;; boundaries of a parent JSXOpeningElement, and such a hierarchy
+;; ought to be fontified like JSX, JS, and JSX respectively:
+;;
+;;   <div attr={void(<div></div>) && void(0)}></div>
+;;
+;;   <div attr={           ← JSX
+;;          void(          ← JS
+;;            <div></div>  ← JSX
+;;          ) && void(0)   ← JS
+;;        }></div>         ← JSX
+;;
+;; `js-syntax-propertize' unambiguously identifies JSX syntax,
+;; including when it’s nested.
+;;
+;; Using a matcher function for each relevant part, retrieve match
+;; data recorded as syntax properties for fontification.
+
+(defconst js-jsx--font-lock-keywords
+  `((js-jsx--match-tag-name 0 font-lock-function-name-face t)
+    (js-jsx--match-attribute-name 0 font-lock-variable-name-face t)
+    (js-jsx--match-text 0 'default t) ; “Undo” keyword fontification.
+    (js-jsx--match-tag-beg)
+    (js-jsx--match-tag-end)
+    (js-jsx--match-expr))
+  "JSX font lock faces and multiline text properties.")
+
+(defun js-jsx--match-tag-name (limit)
+  "Match JSXBoundaryElement names, until LIMIT."
+  (when js-jsx-syntax
+    (let ((pos (next-single-char-property-change (point) 'js-jsx-tag-name nil 
limit))
+          value)
+      (when (and pos (> pos (point)))
+        (goto-char pos)
+        (or (and (setq value (get-text-property pos 'js-jsx-tag-name))
+                 (progn (set-match-data value) t))
+            (js-jsx--match-tag-name limit))))))
+
+(defun js-jsx--match-attribute-name (limit)
+  "Match JSXAttribute names, until LIMIT."
+  (when js-jsx-syntax
+    (let ((pos (next-single-char-property-change (point) 
'js-jsx-attribute-name nil limit))
+          value)
+      (when (and pos (> pos (point)))
+        (goto-char pos)
+        (or (and (setq value (get-text-property pos 'js-jsx-attribute-name))
+                 (progn (set-match-data value) t))
+            (js-jsx--match-attribute-name limit))))))
+
+(defun js-jsx--match-text (limit)
+  "Match JSXText, until LIMIT."
+  (when js-jsx-syntax
+    (let ((pos (next-single-char-property-change (point) 'js-jsx-text nil 
limit))
+          value)
+      (when (and pos (> pos (point)))
+        (goto-char pos)
+        (or (and (setq value (get-text-property pos 'js-jsx-text))
+                 (progn (set-match-data value)
+                        (put-text-property (car value) (cadr value) 
'font-lock-multiline t)
+                        t))
+            (js-jsx--match-text limit))))))
+
+(defun js-jsx--match-tag-beg (limit)
+  "Match JSXBoundaryElements from start, until LIMIT."
+  (when js-jsx-syntax
+    (let ((pos (next-single-char-property-change (point) 'js-jsx-tag-beg nil 
limit))
+          value)
+      (when (and pos (> pos (point)))
+        (goto-char pos)
+        (or (and (setq value (get-text-property pos 'js-jsx-tag-beg))
+                 (progn (put-text-property pos (cdr value) 
'font-lock-multiline t) t))
+            (js-jsx--match-tag-beg limit))))))
+
+(defun js-jsx--match-tag-end (limit)
+  "Match JSXBoundaryElements from end, until LIMIT."
+  (when js-jsx-syntax
+    (let ((pos (next-single-char-property-change (point) 'js-jsx-tag-end nil 
limit))
+          value)
+      (when (and pos (> pos (point)))
+        (goto-char pos)
+        (or (and (setq value (get-text-property pos 'js-jsx-tag-end))
+                 (progn (put-text-property value pos 'font-lock-multiline t) 
t))
+            (js-jsx--match-tag-end limit))))))
+
+(defun js-jsx--match-expr (limit)
+  "Match JSXExpressionContainers, until LIMIT."
+  (when js-jsx-syntax
+    (let ((pos (next-single-char-property-change (point) 'js-jsx-expr nil 
limit))
+          value)
+      (when (and pos (> pos (point)))
+        (goto-char pos)
+        (or (and (setq value (get-text-property pos 'js-jsx-expr))
+                 (progn (put-text-property pos value 'font-lock-multiline t) 
t))
+            (js-jsx--match-expr limit))))))
+
 (defconst js--font-lock-keywords-3
   `(
     ;; This goes before keywords-2 so it gets used preferentially
@@ -1610,7 +1804,10 @@ point of view of font-lock.  It applies highlighting 
directly with
                  (forward-symbol -1)
                (end-of-line))
             '(end-of-line)
-            '(0 font-lock-variable-name-face))))
+            '(0 font-lock-variable-name-face)))
+
+    ;; jsx (when enabled)
+    ,@js-jsx--font-lock-keywords)
   "Level three font lock for `js-mode'.")
 
 (defun js--inside-pitem-p (pitem)
@@ -1736,9 +1933,414 @@ This performs fontification according to 
`js--class-styles'."
                            'syntax-table (string-to-syntax "\"/"))
         (goto-char end)))))
 
+(defconst js--unary-keyword-re
+  (js--regexp-opt-symbol '("await" "delete" "typeof" "void" "yield"))
+  "Regexp matching unary operator keywords.")
+
+(defun js--unary-keyword-p (string)
+  "Check if STRING is a unary operator keyword in JavaScript."
+  (string-match-p js--unary-keyword-re string))
+
+;; Adding `syntax-multiline' text properties to JSX isn’t sufficient
+;; to identify multiline JSX when first typing it.  For instance, if
+;; the user is typing a JSXOpeningElement for the first time…
+;;
+;;   <div
+;;       ^ (point)
+;;
+;; …and the user inserts a line break after the tag name (before the
+;; JSXOpeningElement starting on that line has been unambiguously
+;; identified as such), then the `syntax-propertize' region won’t be
+;; extended backwards to the start of the JSXOpeningElement:
+;;
+;;   <div         ← This line wasn’t JSX when last edited.
+;;     attr="">   ← Despite completing the JSX, the next
+;;             ^    `syntax-propertize' region wouldn’t magically
+;;                  extend back a few lines.
+;;
+;; Therefore, to try and recover from this scenario, parse backward
+;; from “>” to try and find the start of JSXBoundaryElements, and
+;; extend the `syntax-propertize' region there.
+
+(defun js--syntax-propertize-extend-region (start end)
+  "Extend the START-END region for propertization, if necessary.
+For use by `syntax-propertize-extend-region-functions'."
+  (if js-jsx-syntax (js-jsx--syntax-propertize-extend-region start end)))
+
+(defun js-jsx--syntax-propertize-extend-region (start end)
+  "Extend the START-END region for propertization, if necessary.
+If any “>” in the region appears to be the end of a tag starting
+before the start of the region, extend region backwards to the
+start of that tag so parsing may proceed from that point.
+For use by `syntax-propertize-extend-region-functions'."
+  (let (new-start
+        forward-sexp-function ; Use the Lisp version.
+        parse-sexp-lookup-properties) ; Fix backward-sexp error here.
+    (catch 'stop
+      (goto-char start)
+      (while (re-search-forward ">" end t)
+        (catch 'continue
+          ;; Check if this is really a right shift bitwise operator
+          ;; (“>>” or “>>>”).
+          (unless (or (eq (char-before (1- (point))) ?>)
+                      (eq (char-after) ?>))
+            (save-excursion
+              (backward-char)
+              (while (progn (if (= (point) (point-min)) (throw 'continue nil))
+                            (/= (char-before) ?<))
+                (skip-chars-backward " \t\n")
+                (if (= (point) (point-min)) (throw 'continue nil))
+                (cond
+                 ((memq (char-before) '(?\" ?\' ?\` ?\}))
+                  (condition-case nil
+                      (backward-sexp)
+                    (scan-error (throw 'continue nil))))
+                 ((memq (char-before) '(?\/ ?\=)) (backward-char))
+                 ((looking-back js--dotted-name-re (line-beginning-position) t)
+                  (goto-char (match-beginning 0)))
+                 (t (throw 'continue nil))))
+              (when (< (point) start)
+                (setq new-start (1- (point)))
+                (throw 'stop nil)))))))
+    (if new-start (cons new-start end))))
+
+;; When applying syntax properties, since `js-syntax-propertize' uses
+;; `syntax-propertize-rules' to parse JSXBoundaryElements iteratively
+;; and statelessly, whenever we exit such an element, we need to
+;; determine the JSX depth.  If >0, then we know we to apply syntax
+;; properties to JSXText up until the next JSXBoundaryElement occurs.
+;; But if the JSX depth is 0, then—importantly—we know to NOT parse
+;; the following code as JSXText, rather propertize it as regular JS
+;; as long as warranted.
+;;
+;; Also, when indenting code, we need to know if the code we’re trying
+;; to indent is on the 2nd or later line of multiline JSX, in which
+;; case the code is indented according to XML-like JSX conventions.
+;;
+;; For the aforementioned reasons, we find ourselves needing to
+;; determine whether point is enclosed in JSX or not; and, if so,
+;; where the JSX is.  The following functions provide that knowledge.
+
+(defconst js-jsx--tag-start-re
+  (concat "\\(" js--dotted-name-re "\\)\\(?:"
+          ;; Whitespace is only necessary if an attribute implies JSX.
+          "\\(?:\\s-\\|\n\\)*[{/>]"
+          "\\|"
+          "\\(?:\\s-\\|\n\\)+" js--name-start-re
+          "\\)")
+  "Regexp unambiguously matching a JSXOpeningElement.")
+
+(defun js-jsx--matched-tag-type ()
+  "Determine if the last “<” was a JSXBoundaryElement and its type.
+Return `close' for a JSXClosingElement/JSXClosingFragment match,
+return `self-closing' for some self-closing JSXOpeningElements,
+else return `other'."
+  (cond
+   ((= (char-after) ?/) (forward-char) 'close) ; 
JSXClosingElement/JSXClosingFragment
+   ((= (char-after) ?>) (forward-char) 'other) ; JSXOpeningFragment
+   ((and (looking-at js-jsx--tag-start-re) ; JSXOpeningElement
+         (not (js--unary-keyword-p (match-string 1))))
+    (goto-char (match-end 0))
+    (if (= (char-before) ?/) 'self-closing 'other))))
+
+(defconst js-jsx--self-closing-re "/\\s-*>"
+  "Regexp matching the end of a self-closing JSXOpeningElement.")
+
+(defun js-jsx--matching-close-tag-pos ()
+  "Return position of the closer of the opener before point.
+Assuming a JSXOpeningElement or a JSXOpeningFragment is
+immediately before point, find a matching JSXClosingElement or
+JSXClosingFragment, skipping over any nested JSXElements to find
+the match.  Return nil if a match can’t be found."
+  (let ((tag-stack 1) tag-pos type last-pos pos)
+    (catch 'stop
+      (while (and (re-search-forward "<\\s-*" nil t) (not (eobp)))
+        (when (setq tag-pos (match-beginning 0)
+                    type (js-jsx--matched-tag-type))
+          (when last-pos
+            (setq pos (point))
+            (goto-char last-pos)
+            (while (re-search-forward js-jsx--self-closing-re pos 'move)
+              (setq tag-stack (1- tag-stack))))
+          (if (eq type 'close)
+              (progn
+                (setq tag-stack (1- tag-stack))
+                (when (= tag-stack 0)
+                  (throw 'stop tag-pos)))
+            ;; JSXOpeningElements that we know are self-closing aren’t
+            ;; added to the stack at all (because point is already
+            ;; past that syntax).
+            (unless (eq type 'self-closing)
+              (setq tag-stack (1+ tag-stack))))
+          (setq last-pos (point)))))))
+
+(defun js-jsx--enclosing-tag-pos ()
+  "Return beginning and end of a JSXElement about point.
+Look backward for a JSXElement that both starts before point and
+also ends at/after point.  That may be either a self-closing
+JSXElement or a JSXOpeningElement/JSXClosingElement pair."
+  (let ((start (point)) tag-beg tag-beg-pos tag-end-pos close-tag-pos)
+    (while
+        (and
+         (setq tag-beg (js--backward-text-property 'js-jsx-tag-beg))
+         (progn
+           (setq tag-beg-pos (point)
+                 tag-end-pos (cdr tag-beg))
+           (not
+            (or
+             (and (eq (car tag-beg) 'self-closing)
+                  (< start tag-end-pos))
+             (and (eq (car tag-beg) 'open)
+                  (or (< start tag-end-pos)
+                      (progn
+                        (unless
+                            ;; Try to read a cached close position,
+                            ;; but it might not be available yet.
+                            (setq close-tag-pos
+                                  (get-text-property (point) 
'js-jsx-close-tag-pos))
+                          (save-excursion
+                            (goto-char tag-end-pos)
+                            (setq close-tag-pos 
(js-jsx--matching-close-tag-pos)))
+                          (when close-tag-pos
+                            ;; Cache the close position to make future
+                            ;; searches faster.
+                            (put-text-property
+                             (point) (1+ (point))
+                             'js-jsx-close-tag-pos close-tag-pos)))
+                        ;; The JSXOpeningElement may be unclosed, else
+                        ;; the closure must occur at/after the start
+                        ;; point (otherwise, a miscellaneous previous
+                        ;; JSXOpeningElement has been found, so keep
+                        ;; looking backwards for an enclosing one).
+                        (or (not close-tag-pos) (<= start 
close-tag-pos)))))))))
+      ;; Don’t return the last tag pos, as it wasn’t enclosing.
+      (setq tag-beg nil close-tag-pos nil))
+    (and tag-beg (list tag-beg-pos tag-end-pos close-tag-pos))))
+
+(defun js-jsx--at-enclosing-tag-child-p ()
+  "Return t if point is at an enclosing tag’s child."
+  (let ((pos (save-excursion (js-jsx--enclosing-tag-pos))))
+    (and pos (>= (point) (nth 1 pos)))))
+
+;; We implement `syntax-propertize-function' logic fully parsing JSX
+;; in order to provide very accurate JSX indentation, even in the most
+;; complex cases (e.g. to indent JSX within a JS expression within a
+;; JSXAttribute…), as over the years users have requested this.  Since
+;; we find so much information during this parse, we later use some of
+;; the useful bits for font-locking, too.
+;;
+;; Some extra effort is devoted to ensuring that no code which could
+;; possibly be valid JS is ever misinterpreted as partial JSX, since
+;; that would be regressive.
+;;
+;; We first parse trying to find the minimum number of components
+;; necessary to unambiguously identify a JSXBoundaryElement, even if
+;; it is a partial one.  If a complete one is parsed, we move on to
+;; parse any JSXText.  When that’s terminated, we unwind back to the
+;; `syntax-propertize-rules' loop so the next JSXBoundaryElement can
+;; be parsed, if any, be it an opening or closing one.
+
+(defun js-jsx--put-syntax-table (start end value)
+  "Set syntax-table text property from START to END as VALUE.
+Redundantly set the value to two properties, syntax-table and
+js-jsx-syntax-table.  Derivative modes that remove syntax-table
+text properties may recover the value from the second property." ; i.e. 
js2-mode
+  (add-text-properties start end (list 'syntax-table value
+                                       'js-jsx-syntax-table value)))
+
+(defun js-jsx--text-range (beg end)
+  "Identify JSXText within a “>/{/}/<” pair."
+  (when (> (- end beg) 0)
+    (save-excursion
+      (goto-char beg)
+      (while (and (skip-chars-forward " \t\n" end) (< (point) end))
+        ;; Comments and string quotes don’t serve their usual
+        ;; syntactic roles in JSXText; make them plain punctuation to
+        ;; negate those roles.
+        (when (or (= (char-after) ?/) ; comment
+                  (= (syntax-class (syntax-after (point))) 7)) ; string quote
+          (js-jsx--put-syntax-table (point) (1+ (point)) '(1)))
+        (forward-char)))
+    ;; Mark JSXText so it can be font-locked as non-keywords.
+    (put-text-property beg (1+ beg) 'js-jsx-text (list beg end 
(current-buffer)))
+    ;; Ensure future propertization beginning from within the
+    ;; JSXText determines JSXText context from earlier lines.
+    (put-text-property beg end 'syntax-multiline t)))
+
+;; In order to respect the end boundary `syntax-propertize-function'
+;; sets, care is taken in the following functions to abort parsing
+;; whenever that boundary is reached.
+
+(defun js-jsx--syntax-propertize-tag-text (end)
+  "Determine if JSXText is before END and propertize it.
+Text within an open/close tag pair may be JSXText.  Temporarily
+interrupt JSXText by JSXExpressionContainers, and terminate
+JSXText when another JSXBoundaryElement is encountered.  Despite
+terminations, all JSXText will be identified once all the
+JSXBoundaryElements within an outermost JSXElement’s tree have
+been propertized."
+  (let ((text-beg (point))
+        forward-sexp-function) ; Use Lisp version.
+    (catch 'stop
+      (while (re-search-forward "[{<]" end t)
+        (js-jsx--text-range text-beg (1- (point)))
+        (cond
+         ((= (char-before) ?{)
+          (let (expr-beg expr-end)
+            (condition-case nil
+                (save-excursion
+                  (backward-char)
+                  (setq expr-beg (point))
+                  (forward-sexp)
+                  (setq expr-end (point)))
+              (scan-error nil))
+            ;; Recursively propertize the JSXExpressionContainer’s
+            ;; (possibly-incomplete) expression.
+            (js-syntax-propertize (1+ expr-beg) (if expr-end (min (1- 
expr-end) end) end))
+            ;; Ensure future propertization beginning from within the
+            ;; (possibly-incomplete) expression can determine JSXText
+            ;; context from earlier lines.
+            (put-text-property expr-beg (1+ expr-beg) 'js-jsx-expr (or 
expr-end end)) ; font-lock
+            (put-text-property expr-beg (if expr-end (min expr-end end) end) 
'syntax-multiline t) ; syntax-propertize
+            ;; Exit the JSXExpressionContainer if that’s possible,
+            ;; else move to the end of the propertized area.
+            (goto-char (if expr-end (min expr-end end) end))))
+         ((= (char-before) ?<)
+          (backward-char) ; Ensure the next tag can be propertized.
+          (throw 'stop nil)))
+        (setq text-beg (point))))))
+
+(defconst js-jsx--attribute-name-re (concat js--name-start-re
+                                            "\\(?:\\s_\\|\\sw\\|-\\)*")
+  "Like `js--name-re', but matches “-” as well.")
+
+(defun js-jsx--syntax-propertize-tag (end)
+  "Determine if a JSXBoundaryElement is before END and propertize it.
+Disambiguate JSX from inequality operators and arrow functions by
+testing for syntax only valid as JSX."
+  (let ((tag-beg (1- (point))) tag-end (type 'open)
+        name-beg name-match-data expr-attribute-beg unambiguous
+        forward-sexp-function) ; Use Lisp version.
+    (catch 'stop
+      (while (and (< (point) end)
+                  (progn (skip-chars-forward " \t\n" end)
+                         (< (point) end)))
+        (cond
+         ((= (char-after) ?>)
+          ;; Make the closing “>” a close parenthesis.
+          (js-jsx--put-syntax-table (point) (1+ (point)) '(5))
+          (forward-char)
+          (setq unambiguous t)
+          (throw 'stop nil))
+         ;; Handle a JSXSpreadChild (“<Foo {...bar}”) or a
+         ;; JSXExpressionContainer as a JSXAttribute value
+         ;; (“<Foo bar={…}”).  Check this early in case continuing a
+         ;; JSXAttribute parse.
+         ((or (and name-beg (= (char-after) ?{))
+              (setq expr-attribute-beg nil))
+          (setq unambiguous t) ; JSXExpressionContainer post tag name ⇒ JSX
+          (when expr-attribute-beg
+            ;; Remember that this JSXExpressionContainer is part of a
+            ;; JSXAttribute, as that can affect its expression’s
+            ;; indentation.
+            (put-text-property
+             (point) (1+ (point)) 'js-jsx-expr-attribute expr-attribute-beg)
+            (setq expr-attribute-beg nil))
+          (let (expr-end)
+            (condition-case nil
+                (save-excursion
+                  (forward-sexp)
+                  (setq expr-end (point)))
+              (scan-error nil))
+            (forward-char)
+            (if (>= (point) end) (throw 'stop nil))
+            (skip-chars-forward " \t\n" end)
+            (if (>= (point) end) (throw 'stop nil))
+            (if (= (char-after) ?}) (forward-char) ; Shortcut to bail.
+              ;; Recursively propertize the JSXExpressionContainer’s
+              ;; expression.
+              (js-syntax-propertize (point) (if expr-end (min (1- expr-end) 
end) end))
+              ;; Exit the JSXExpressionContainer if that’s possible,
+              ;; else move to the end of the propertized area.
+              (goto-char (if expr-end (min expr-end end) end)))))
+         ((= (char-after) ?/)
+          ;; Assume a tag is an open tag until a slash is found, then
+          ;; figure out what type it actually is.
+          (if (eq type 'open) (setq type (if name-beg 'self-closing 'close)))
+          (forward-char))
+         ((and (not name-beg) (looking-at js--dotted-name-re))
+          ;; Don’t match code like “if (i < await foo)”
+          (if (js--unary-keyword-p (match-string 0)) (throw 'stop nil))
+          ;; Save boundaries for later fontification after
+          ;; unambiguously determining the code is JSX.
+          (setq name-beg (match-beginning 0)
+                name-match-data (match-data))
+          (goto-char (match-end 0)))
+         ((and name-beg (looking-at js-jsx--attribute-name-re))
+          (setq unambiguous t) ; Non-unary name followed by 2nd name ⇒ JSX
+          ;; Save JSXAttribute’s name’s match data for font-locking later.
+          (put-text-property (match-beginning 0) (1+ (match-beginning 0))
+                             'js-jsx-attribute-name (match-data))
+          (goto-char (match-end 0))
+          (if (>= (point) end) (throw 'stop nil))
+          (skip-chars-forward " \t\n" end)
+          (if (>= (point) end) (throw 'stop nil))
+          ;; “=” is optional for null-valued JSXAttributes.
+          (when (= (char-after) ?=)
+            (forward-char)
+            (if (>= (point) end) (throw 'stop nil))
+            (skip-chars-forward " \t\n" end)
+            (if (>= (point) end) (throw 'stop nil))
+            ;; Skip over strings (if possible).  Any
+            ;; JSXExpressionContainer here will be parsed in the
+            ;; next iteration of the loop.
+            (if (memq (char-after) '(?\" ?\' ?\`))
+                (progn
+                  ;; Record the string’s position so derived modes
+                  ;; applying syntactic fontification atypically
+                  ;; (e.g. js2-mode) can recognize it as part of JSX.
+                  (put-text-property (point) (1+ (point)) 'js-jsx-string t)
+                  (condition-case nil
+                      (forward-sexp)
+                    (scan-error (throw 'stop nil))))
+              ;; Save JSXAttribute’s beginning in case we find a
+              ;; JSXExpressionContainer as the JSXAttribute’s value which
+              ;; we should associate with the JSXAttribute.
+              (setq expr-attribute-beg (match-beginning 0)))))
+         ;; There is nothing more to check; this either isn’t JSX, or
+         ;; the tag is incomplete.
+         (t (throw 'stop nil)))))
+    (when unambiguous
+      ;; Save JSXBoundaryElement’s name’s match data for font-locking.
+      (if name-beg (put-text-property name-beg (1+ name-beg) 'js-jsx-tag-name 
name-match-data))
+      ;; Make the opening “<” an open parenthesis.
+      (js-jsx--put-syntax-table tag-beg (1+ tag-beg) '(4))
+      ;; Prevent “out of range” errors when typing at the end of a buffer.
+      (setq tag-end (if (eobp) (1- (point)) (point)))
+      ;; Mark beginning and end of tag for font-locking.
+      (put-text-property tag-beg (1+ tag-beg) 'js-jsx-tag-beg (cons type 
tag-end))
+      (put-text-property tag-end (1+ tag-end) 'js-jsx-tag-end tag-beg)
+      ;; Use text properties to extend the syntax-propertize region
+      ;; backward to the beginning of the JSXBoundaryElement in the
+      ;; future.  Typically the closing angle bracket could suggest
+      ;; extending backward, but that would also involve more rigorous
+      ;; parsing, and the closing angle bracket may not even exist yet
+      ;; if the JSXBoundaryElement is still being typed.
+      (put-text-property tag-beg (1+ tag-end) 'syntax-multiline t))
+    (if (js-jsx--at-enclosing-tag-child-p) (js-jsx--syntax-propertize-tag-text 
end))))
+
+(defconst js-jsx--text-properties
+  (list
+   'js-jsx-tag-beg nil 'js-jsx-tag-end nil 'js-jsx-close-tag-pos nil
+   'js-jsx-tag-name nil 'js-jsx-attribute-name nil 'js-jsx-string nil
+   'js-jsx-text nil 'js-jsx-expr nil 'js-jsx-expr-attribute nil
+   'js-jsx-syntax-table nil)
+  "Plist of text properties added by `js-syntax-propertize'.")
+
 (defun js-syntax-propertize (start end)
   ;; JavaScript allows immediate regular expression objects, written /.../.
   (goto-char start)
+  (if js-jsx-syntax (remove-text-properties start end js-jsx--text-properties))
   (js-syntax-propertize-regexp end)
   (funcall
    (syntax-propertize-rules
@@ -1762,7 +2364,8 @@ This performs fontification according to 
`js--class-styles'."
            (put-text-property (match-beginning 1) (match-end 1)
                               'syntax-table (string-to-syntax "\"/"))
            (js-syntax-propertize-regexp end)))))
-    ("\\`\\(#\\)!" (1 "< b")))
+    ("\\`\\(#\\)!" (1 "< b"))
+    ("<" (0 (ignore (if js-jsx-syntax (js-jsx--syntax-propertize-tag end))))))
    (point) end))
 
 (defconst js--prettify-symbols-alist
@@ -1788,6 +2391,11 @@ This performs fontification according to 
`js--class-styles'."
           (js--regexp-opt-symbol '("in" "instanceof")))
   "Regexp matching operators that affect indentation of continued 
expressions.")
 
+(defun js-jsx--looking-at-start-tag-p ()
+  "Non-nil if a JSXOpeningElement immediately follows point."
+  (let ((tag-beg (get-text-property (point) 'js-jsx-tag-beg)))
+    (and tag-beg (memq (car tag-beg) '(open self-closing)))))
+
 (defun js--looking-at-operator-p ()
   "Return non-nil if point is on a JavaScript operator, other than a comma."
   (save-match-data
@@ -1810,7 +2418,9 @@ This performs fontification according to 
`js--class-styles'."
                  (js--backward-syntactic-ws)
                  ;; We might misindent some expressions that would
                  ;; return NaN anyway.  Shouldn't be a problem.
-                 (memq (char-before) '(?, ?} ?{))))))))
+                 (memq (char-before) '(?, ?} ?{)))))
+         ;; “<” isn’t necessarily an operator in JSX.
+         (not (and js-jsx-syntax (js-jsx--looking-at-start-tag-p))))))
 
 (defun js--find-newline-backward ()
   "Move backward to the nearest newline that is not in a block comment."
@@ -1830,6 +2440,10 @@ This performs fontification according to 
`js--class-styles'."
         (setq result nil)))
     result))
 
+(defun js-jsx--looking-back-at-end-tag-p ()
+  "Non-nil if a JSXClosingElement immediately precedes point."
+  (get-text-property (point) 'js-jsx-tag-end))
+
 (defun js--continued-expression-p ()
   "Return non-nil if the current line continues an expression."
   (save-excursion
@@ -1847,12 +2461,19 @@ This performs fontification according to 
`js--class-styles'."
       (and (js--find-newline-backward)
            (progn
              (skip-chars-backward " \t")
-             (or (bobp) (backward-char))
-             (and (> (point) (point-min))
-                  (save-excursion (backward-char) (not (looking-at "[/*]/")))
-                  (js--looking-at-operator-p)
-                  (and (progn (backward-char)
-                              (not (looking-at "+\\+\\|--\\|/[/*]"))))))))))
+             (and
+              ;; The “>” at the end of any JSXBoundaryElement isn’t
+              ;; part of a continued expression.
+              (not (and js-jsx-syntax (js-jsx--looking-back-at-end-tag-p)))
+              (progn
+                (or (bobp) (backward-char))
+                (and (> (point) (point-min))
+                     (save-excursion
+                       (backward-char)
+                       (not (looking-at "[/*]/\\|=>")))
+                     (js--looking-at-operator-p)
+                     (and (progn (backward-char)
+                                 (not (looking-at 
"\\+\\+\\|--\\|/[/*]"))))))))))))
 
 (defun js--skip-term-backward ()
   "Skip a term before point; return t if a term was skipped."
@@ -1922,7 +2543,7 @@ the same column as the current line."
     (save-match-data
       (when (looking-at "\\s-*\\_<while\\_>")
        (if (save-excursion
-             (skip-chars-backward "[ \t\n]*}")
+             (skip-chars-backward " \t\n}")
              (looking-at "[ \t\n]*}"))
            (save-excursion
              (backward-list) (forward-symbol -1) (looking-at "\\_<do\\_>"))
@@ -2078,6 +2699,183 @@ indentation is aligned to that column."
         (when comma-p
           (goto-char (1+ declaration-keyword-end))))))))
 
+(defconst js--line-terminating-arrow-re "=>\\s-*\\(/[/*]\\|$\\)"
+  "Regexp matching the last \"=>\" (arrow) token on a line.
+Whitespace and comments around the arrow are ignored.")
+
+(defun js--broken-arrow-terminates-line-p ()
+  "Helper function for `js--proper-indentation'.
+Return t if the last non-comment, non-whitespace token of the
+current line is the \"=>\" token (of an arrow function)."
+  (let ((from (point)))
+    (end-of-line)
+    (re-search-backward js--line-terminating-arrow-re from t)))
+
+;; When indenting, we want to know if the line is…
+;;
+;;   - within a multiline JSXElement, or
+;;   - within a string in a JSXBoundaryElement, or
+;;   - within JSXText, or
+;;   - within a JSXAttribute’s multiline JSXExpressionContainer.
+;;
+;; In these cases, special XML-like indentation rules for JSX apply.
+;; If JS is nested within JSX, then indentation calculations may be
+;; combined, such that JS indentation is “relative” to the JSX’s.
+;;
+;; Therefore, functions below provide such contextual information, and
+;; `js--proper-indentation' may call itself once recursively in order
+;; to finish calculating that “relative” JS+JSX indentation.
+
+(defun js-jsx--context ()
+  "Determine JSX context and move to enclosing JSX."
+  (let ((pos (point))
+        (parse-status (syntax-ppss))
+        (enclosing-tag-pos (js-jsx--enclosing-tag-pos)))
+    (when enclosing-tag-pos
+      (if (< pos (nth 1 enclosing-tag-pos))
+          (if (nth 3 parse-status)
+              (list 'string (nth 8 parse-status))
+            (list 'tag (nth 0 enclosing-tag-pos) (nth 1 enclosing-tag-pos)))
+        (list 'text (nth 0 enclosing-tag-pos) (nth 2 enclosing-tag-pos))))))
+
+(defun js-jsx--contextual-indentation (line context)
+  "Calculate indentation column for LINE from CONTEXT.
+The column calculation is based off of `sgml-calculate-indent'."
+  (pcase (nth 0 context)
+
+    ('string
+     ;; Go back to previous non-empty line.
+     (while (and (> (point) (nth 1 context))
+                (zerop (forward-line -1))
+                (looking-at "[ \t]*$")))
+     (if (> (point) (nth 1 context))
+        ;; Previous line is inside the string.
+        (current-indentation)
+       (goto-char (nth 1 context))
+       (1+ (current-column))))
+
+    ('tag
+     ;; Special JSX indentation rule: a “dangling” closing angle
+     ;; bracket on its own line is indented at the same level as the
+     ;; opening angle bracket of the JSXElement.  Otherwise, indent
+     ;; JSXAttribute space like SGML.
+     (if (and
+          js-jsx-align->-with-<
+          (progn
+            (goto-char (nth 2 context))
+            (and (= line (line-number-at-pos))
+                 (looking-back "^\\s-*/?>" (line-beginning-position)))))
+         (progn
+           (goto-char (nth 1 context))
+           (current-column))
+       ;; Indent JSXAttribute space like SGML.
+       (goto-char (nth 1 context))
+       ;; Skip tag name:
+       (skip-chars-forward " \t")
+       (skip-chars-forward "^ \t\n")
+       (skip-chars-forward " \t")
+       (if (not (eolp))
+          (current-column)
+         ;; This is the first attribute: indent.
+         (goto-char (+ (nth 1 context) js-jsx-attribute-offset))
+         (+ (current-column) (or js-jsx-indent-level js-indent-level)))))
+
+    ('text
+     ;; Indent to reflect nesting.
+     (goto-char (nth 1 context))
+     (+ (current-column)
+        ;; The last line isn’t nested, but the rest are.
+        (if (or (not (nth 2 context)) ; Unclosed.
+                (< line (line-number-at-pos (nth 2 context))))
+            (or js-jsx-indent-level js-indent-level)
+          0)))
+
+    ))
+
+(defun js-jsx--enclosing-curly-pos ()
+  "Return position of enclosing “{” in a “{/}” pair about point."
+  (let ((parens (reverse (nth 9 (syntax-ppss)))) paren-pos curly-pos)
+    (while
+        (and
+         (setq paren-pos (car parens))
+         (not (when (= (char-after paren-pos) ?{)
+                (setq curly-pos paren-pos)))
+         (setq parens (cdr parens))))
+    curly-pos))
+
+(defun js-jsx--goto-outermost-enclosing-curly (limit)
+  "Set point to enclosing “{” at or closest after LIMIT."
+  (let (pos)
+    (while
+        (and
+         (setq pos (js-jsx--enclosing-curly-pos))
+         (if (>= pos limit) (goto-char pos))
+         (> pos limit)))))
+
+(defun js-jsx--expr-attribute-pos (start limit)
+  "Look back from START to LIMIT for a JSXAttribute."
+  (save-excursion
+    (goto-char start) ; Skip the first curly.
+    ;; Skip any remaining enclosing curlies until the JSXElement’s
+    ;; beginning position; the last curly ought to be one of a
+    ;; JSXExpressionContainer, which may refer to its JSXAttribute’s
+    ;; beginning position (if it has one).
+    (js-jsx--goto-outermost-enclosing-curly limit)
+    (get-text-property (point) 'js-jsx-expr-attribute)))
+
+(defvar js-jsx--indent-col nil
+  "Baseline column for JS indentation within JSX.")
+
+(defvar js-jsx--indent-attribute-line nil
+  "Line relative to which indentation uses JSX as a baseline.")
+
+(defun js-jsx--expr-indentation (parse-status pos col)
+  "Indent using PARSE-STATUS; relative to POS, use base COL.
+To indent a JSXExpressionContainer’s expression, calculate the JS
+indentation, using JSX indentation as the base column when
+indenting relative to the beginning line of the
+JSXExpressionContainer’s JSXAttribute (if any)."
+  (let* ((js-jsx--indent-col col)
+         (js-jsx--indent-attribute-line
+          (if pos (line-number-at-pos pos))))
+    (js--proper-indentation parse-status)))
+
+(defun js-jsx--indentation (parse-status)
+  "Helper function for `js--proper-indentation'.
+Return the proper indentation of the current line if it is part
+of a JSXElement expression spanning multiple lines; otherwise,
+return nil."
+  (let ((current-line (line-number-at-pos))
+        (curly-pos (js-jsx--enclosing-curly-pos))
+        nth-context context expr-p beg-line col
+        forward-sexp-function) ; Use the Lisp version.
+    ;; Find the immediate context for indentation information, but
+    ;; keep going to determine that point is at the N+1th line of
+    ;; multiline JSX.
+    (save-excursion
+      (while
+          (and
+           (setq nth-context (js-jsx--context))
+           (progn
+             (unless context
+               (setq context nth-context)
+               (setq expr-p (and curly-pos (< (point) curly-pos))))
+             (setq beg-line (line-number-at-pos))
+             (and
+              (= beg-line current-line)
+              (or (not curly-pos) (> (point) curly-pos)))))))
+    ;; When on the second or later line of JSX, indent as JSX,
+    ;; possibly switching back to JS indentation within
+    ;; JSXExpressionContainers, possibly using the JSX as a base
+    ;; column while switching back to JS indentation.
+    (when (and context (> current-line beg-line))
+      (save-excursion
+        (setq col (js-jsx--contextual-indentation current-line context)))
+      (if expr-p
+          (js-jsx--expr-indentation
+           parse-status (js-jsx--expr-attribute-pos curly-pos (nth 1 context)) 
col)
+        col))))
+
 (defun js--proper-indentation (parse-status)
   "Return the proper indentation for the current line."
   (save-excursion
@@ -2085,6 +2883,8 @@ indentation is aligned to that column."
     (cond ((nth 4 parse-status)    ; inside comment
            (js--get-c-offset 'c (nth 8 parse-status)))
           ((nth 3 parse-status) 0) ; inside string
+          ((when (and js-jsx-syntax (not js-jsx--indent-col))
+             (save-excursion (js-jsx--indentation parse-status))))
           ((eq (char-after) ?#) 0)
           ((save-excursion (js--beginning-of-macro)) 4)
           ;; Indent array comprehension continuation lines specially.
@@ -2108,7 +2908,8 @@ indentation is aligned to that column."
                  (continued-expr-p (js--continued-expression-p)))
              (goto-char (nth 1 parse-status)) ; go to the opening char
              (if (or (not js-indent-align-list-continuation)
-                     (looking-at "[({[]\\s-*\\(/[/*]\\|$\\)"))
+                     (looking-at "[({[]\\s-*\\(/[/*]\\|$\\)")
+                     (save-excursion (forward-char) 
(js--broken-arrow-terminates-line-p)))
                  (progn ; nothing following the opening paren/bracket
                    (skip-syntax-backward " ")
                    (when (eq (char-before) ?\)) (backward-list))
@@ -2120,17 +2921,24 @@ indentation is aligned to that column."
                                              (and switch-keyword-p
                                                   in-switch-p)))
                           (indent
-                           (cond (same-indent-p
-                                  (current-column))
-                                 (continued-expr-p
-                                  (+ (current-column) (* 2 js-indent-level)
-                                     js-expr-indent-offset))
-                                 (t
-                                  (+ (current-column) js-indent-level
-                                     (pcase (char-after (nth 1 parse-status))
-                                       (?\( js-paren-indent-offset)
-                                       (?\[ js-square-indent-offset)
-                                       (?\{ js-curly-indent-offset)))))))
+                           (+
+                            (cond
+                             ((and js-jsx--indent-attribute-line
+                                   (eq js-jsx--indent-attribute-line
+                                       (line-number-at-pos)))
+                              js-jsx--indent-col)
+                             (t
+                              (current-column)))
+                            (cond (same-indent-p 0)
+                                  (continued-expr-p
+                                   (+ (* 2 js-indent-level)
+                                      js-expr-indent-offset))
+                                  (t
+                                   (+ js-indent-level
+                                      (pcase (char-after (nth 1 parse-status))
+                                        (?\( js-paren-indent-offset)
+                                        (?\[ js-square-indent-offset)
+                                        (?\{ js-curly-indent-offset))))))))
                      (if in-switch-p
                          (+ indent js-switch-indent-offset)
                        indent)))
@@ -2146,193 +2954,6 @@ indentation is aligned to that column."
            (+ js-indent-level js-expr-indent-offset))
           (t (prog-first-column)))))
 
-;;; JSX Indentation
-
-(defsubst js--jsx-find-before-tag ()
-  "Find where JSX starts.
-
-Assume JSX appears in the following instances:
-- Inside parentheses, when returned or as the first argument
-  to a function, and after a newline
-- When assigned to variables or object properties, but only
-  on a single line
-- As the N+1th argument to a function
-
-This is an optimized version of (re-search-backward \"[(,]\n\"
-nil t), except set point to the end of the match.  This logic
-executes up to the number of lines in the file, so it should be
-really fast to reduce that impact."
-  (let (pos)
-    (while (and (> (point) (point-min))
-                (not (progn
-                       (end-of-line 0)
-                       (when (or (eq (char-before) 40)   ; (
-                                 (eq (char-before) 44))  ; ,
-                         (setq pos (1- (point))))))))
-    pos))
-
-(defconst js--jsx-end-tag-re
-  (concat "</" sgml-name-re ">\\|/>")
-  "Find the end of a JSX element.")
-
-(defconst js--jsx-after-tag-re "[),]"
-  "Find where JSX ends.
-This complements the assumption of where JSX appears from
-`js--jsx-before-tag-re', which see.")
-
-(defun js--jsx-indented-element-p ()
-  "Determine if/how the current line should be indented as JSX.
-
-Return `first' for the first JSXElement on its own line.
-Return `nth' for subsequent lines of the first JSXElement.
-Return `expression' for an embedded JS expression.
-Return `after' for anything after the last JSXElement.
-Return nil for non-JSX lines.
-
-Currently, JSX indentation supports the following styles:
-
-- Single-line elements (indented like normal JS):
-
-  var element = <div></div>;
-
-- Multi-line elements (enclosed in parentheses):
-
-  function () {
-    return (
-      <div>
-        <div></div>
-      </div>
-    );
- }
-
-- Function arguments:
-
-  React.render(
-    <div></div>,
-    document.querySelector('.root')
-  );"
-  (let ((current-pos (point))
-        (current-line (line-number-at-pos))
-        last-pos
-        before-tag-pos before-tag-line
-        tag-start-pos tag-start-line
-        tag-end-pos tag-end-line
-        after-tag-line
-        parens paren type)
-    (save-excursion
-      (and
-       ;; Determine if we're inside a jsx element
-       (progn
-         (end-of-line)
-         (while (and (not tag-start-pos)
-                     (setq last-pos (js--jsx-find-before-tag)))
-           (while (forward-comment 1))
-           (when (= (char-after) 60) ; <
-             (setq before-tag-pos last-pos
-                   tag-start-pos (point)))
-           (goto-char last-pos))
-         tag-start-pos)
-       (progn
-         (setq before-tag-line (line-number-at-pos before-tag-pos)
-               tag-start-line (line-number-at-pos tag-start-pos))
-         (and
-          ;; A "before" line which also starts an element begins with js, so
-          ;; indent it like js
-          (> current-line before-tag-line)
-          ;; Only indent the jsx lines like jsx
-          (>= current-line tag-start-line)))
-       (cond
-        ;; Analyze bounds if there are any
-        ((progn
-           (while (and (not tag-end-pos)
-                       (setq last-pos (re-search-forward js--jsx-end-tag-re 
nil t)))
-             (while (forward-comment 1))
-             (when (looking-at js--jsx-after-tag-re)
-               (setq tag-end-pos last-pos)))
-           tag-end-pos)
-         (setq tag-end-line (line-number-at-pos tag-end-pos)
-               after-tag-line (line-number-at-pos after-tag-line))
-         (or (and
-              ;; Ensure we're actually within the bounds of the jsx
-              (<= current-line tag-end-line)
-              ;; An "after" line which does not end an element begins with
-              ;; js, so indent it like js
-              (<= current-line after-tag-line))
-             (and
-              ;; Handle another case where there could be e.g. comments after
-              ;; the element
-              (> current-line tag-end-line)
-              (< current-line after-tag-line)
-              (setq type 'after))))
-        ;; They may not be any bounds (yet)
-        (t))
-       ;; Check if we're inside an embedded multi-line js expression
-       (cond
-        ((not type)
-         (goto-char current-pos)
-         (end-of-line)
-         (setq parens (nth 9 (syntax-ppss)))
-         (while (and parens (not type))
-           (setq paren (car parens))
-           (cond
-            ((and (>= paren tag-start-pos)
-                  ;; Curly bracket indicates the start of an embedded 
expression
-                  (= (char-after paren) 123) ; {
-                  ;; The first line of the expression is indented like sgml
-                  (> current-line (line-number-at-pos paren))
-                  ;; Check if within a closing curly bracket (if any)
-                  ;; (exclusive, as the closing bracket is indented like sgml)
-                  (cond
-                   ((progn
-                      (goto-char paren)
-                      (ignore-errors (let (forward-sexp-function)
-                                       (forward-sexp))))
-                    (< current-line (line-number-at-pos)))
-                   (t)))
-             ;; Indicate this guy will be indented specially
-             (setq type 'expression))
-            (t (setq parens (cdr parens)))))
-         t)
-        (t))
-       (cond
-        (type)
-        ;; Indent the first jsx thing like js so we can indent future jsx 
things
-        ;; like sgml relative to the first thing
-        ((= current-line tag-start-line) 'first)
-        ('nth))))))
-
-(defmacro js--as-sgml (&rest body)
-  "Execute BODY as if in sgml-mode."
-  `(with-syntax-table sgml-mode-syntax-table
-     (let (forward-sexp-function
-           parse-sexp-lookup-properties)
-       ,@body)))
-
-(defun js--expression-in-sgml-indent-line ()
-  "Indent the current line as JavaScript or SGML (whichever is farther)."
-  (let* (indent-col
-         (savep (point))
-         ;; Don't whine about errors/warnings when we're indenting.
-         ;; This has to be set before calling parse-partial-sexp below.
-         (inhibit-point-motion-hooks t)
-         (parse-status (save-excursion
-                         (syntax-ppss (point-at-bol)))))
-    ;; Don't touch multiline strings.
-    (unless (nth 3 parse-status)
-      (setq indent-col (save-excursion
-                         (back-to-indentation)
-                         (if (>= (point) savep) (setq savep nil))
-                         (js--as-sgml (sgml-calculate-indent))))
-      (if (null indent-col)
-          'noindent
-        ;; Use whichever indentation column is greater, such that the sgml
-        ;; column is effectively a minimum
-        (setq indent-col (max (js--proper-indentation parse-status)
-                              (+ indent-col js-indent-level)))
-        (if savep
-            (save-excursion (indent-line-to indent-col))
-          (indent-line-to indent-col))))))
-
 (defun js-indent-line ()
   "Indent the current line as JavaScript."
   (interactive)
@@ -2344,23 +2965,9 @@ Currently, JSX indentation supports the following styles:
       (when (> offset 0) (forward-char offset)))))
 
 (defun js-jsx-indent-line ()
-  "Indent the current line as JSX (with SGML offsets).
-i.e., customize JSX element indentation with `sgml-basic-offset',
-`sgml-attribute-offset' et al."
+  "Indent the current line as JavaScript+JSX."
   (interactive)
-  (let ((indentation-type (js--jsx-indented-element-p)))
-    (cond
-     ((eq indentation-type 'expression)
-      (js--expression-in-sgml-indent-line))
-     ((or (eq indentation-type 'first)
-          (eq indentation-type 'after))
-      ;; Don't treat this first thing as a continued expression (often a "<" or
-      ;; ">" causes this misinterpretation)
-      (cl-letf (((symbol-function #'js--continued-expression-p) 'ignore))
-        (js-indent-line)))
-     ((eq indentation-type 'nth)
-      (js--as-sgml (sgml-indent-line)))
-     (t (js-indent-line)))))
+  (let ((js-jsx-syntax t)) (js-indent-line)))
 
 ;;; Filling
 
@@ -2766,8 +3373,8 @@ Otherwise, use the current value of `process-mark'."
   (with-current-buffer (process-buffer process)
     (cl-loop with start-pos = (or start
                                   (marker-position (process-mark process)))
-             with end-time = (+ (float-time) timeout)
-             for time-left = (- end-time (float-time))
+            with end-time = (time-add nil timeout)
+            for time-left = (float-time (time-subtract end-time nil))
              do (goto-char (point-max))
              if (looking-back regexp start-pos) return t
              while (> time-left 0)
@@ -3851,6 +4458,77 @@ If one hasn't been set, or if it's stale, prompt for a 
new one."
         (when temp-name
           (delete-file temp-name))))))
 
+;;; Syntax extensions
+
+(defvar js-syntactic-mode-name t
+  "If non-nil, print enabled syntaxes in the mode name.")
+
+(defun js--syntactic-mode-name-part ()
+  "Return a string like “[JSX]” when `js-jsx-syntax' is enabled."
+  (if js-syntactic-mode-name
+      (let (syntaxes)
+        (if js-jsx-syntax (push "JSX" syntaxes))
+        (if syntaxes
+            (concat "[" (mapconcat #'identity syntaxes ",") "]")
+          ""))
+    ""))
+
+(defun js-use-syntactic-mode-name ()
+  "Print enabled syntaxes if `js-syntactic-mode-name' is t.
+Modes deriving from `js-mode' should call this to ensure that
+their `mode-name' updates to show enabled syntax extensions."
+  (when (stringp mode-name)
+    (setq mode-name `(,mode-name (:eval (js--syntactic-mode-name-part))))))
+
+(defun js-jsx-enable ()
+  "Enable JSX in the current buffer."
+  (interactive)
+  (setq-local js-jsx-syntax t))
+
+;; To make discovering and using syntax extensions features easier for
+;; users (who might not read the docs), try to safely and
+;; automatically enable syntax extensions based on heuristics.
+
+(defvar js-jsx-regexps
+  (list "\\_<\\(?:var\\|let\\|const\\|import\\)\\_>.*?React")
+  "Regexps for detecting JSX in JavaScript buffers.
+When `js-jsx-detect-syntax' is non-nil and any of these regexps
+match text near the beginning of a JavaScript buffer,
+`js-jsx-syntax' (which see) will be made buffer-local and set to
+t.")
+
+(defun js-jsx--detect-and-enable (&optional arbitrarily)
+  "Detect if JSX is likely to be used, and enable it if so.
+Might make `js-jsx-syntax' buffer-local and set it to t.  Matches
+from the beginning of the buffer, unless optional arg ARBITRARILY
+is non-nil.  Return t after enabling, nil otherwise."
+  (when (or (and (buffer-file-name)
+                 (string-match-p "\\.jsx\\'" (buffer-file-name)))
+            (and js-jsx-detect-syntax
+                 (save-excursion
+                   (unless arbitrarily
+                     (goto-char (point-min)))
+                   (catch 'match
+                     (mapc
+                      (lambda (regexp)
+                        (if (re-search-forward regexp 4000 t) (throw 'match 
t)))
+                      js-jsx-regexps)
+                     nil))))
+    (js-jsx-enable)
+    t))
+
+(defun js-jsx--detect-after-change (beg end _len)
+  "Detect if JSX is likely to be used after a change.
+This function is intended for use in `after-change-functions'."
+  (when (<= end 4000)
+    (save-excursion
+      (goto-char beg)
+      (beginning-of-line)
+      (save-restriction
+        (narrow-to-region (point) end)
+        (when (js-jsx--detect-and-enable 'arbitrarily)
+          (remove-hook 'after-change-functions #'js-jsx--detect-after-change 
t))))))
+
 ;;; Main Function
 
 ;;;###autoload
@@ -3866,6 +4544,10 @@ If one hasn't been set, or if it's stale, prompt for a 
new one."
                     '(font-lock-syntactic-face-function
                       . js-font-lock-syntactic-face-function)))
   (setq-local syntax-propertize-function #'js-syntax-propertize)
+  (add-hook 'syntax-propertize-extend-region-functions
+            #'syntax-propertize-multiline 'append 'local)
+  (add-hook 'syntax-propertize-extend-region-functions
+            #'js--syntax-propertize-extend-region 'append 'local)
   (setq-local prettify-symbols-alist js--prettify-symbols-alist)
 
   (setq-local parse-sexp-ignore-comments t)
@@ -3873,6 +4555,7 @@ If one hasn't been set, or if it's stale, prompt for a 
new one."
 
   ;; Comments
   (setq-local comment-start "// ")
+  (setq-local comment-start-skip "\\(//+\\|/\\*+\\)\\s *")
   (setq-local comment-end "")
   (setq-local fill-paragraph-function #'js-fill-paragraph)
   (setq-local normal-auto-fill-function #'js-do-auto-fill)
@@ -3883,6 +4566,11 @@ If one hasn't been set, or if it's stale, prompt for a 
new one."
   ;; Frameworks
   (js--update-quick-match-re)
 
+  ;; Syntax extensions
+  (unless (js-jsx--detect-and-enable)
+    (add-hook 'after-change-functions #'js-jsx--detect-after-change nil t))
+  (js-use-syntactic-mode-name)
+
   ;; Imenu
   (setq imenu-case-fold-search nil)
   (setq imenu-create-index-function #'js--imenu-create-index)
@@ -3893,8 +4581,7 @@ If one hasn't been set, or if it's stale, prompt for a 
new one."
         c-paragraph-separate "$"
         c-block-comment-prefix "* "
         c-line-comment-starter "//"
-        c-comment-start-regexp "/[*/]\\|\\s!"
-        comment-start-skip "\\(//+\\|/\\*+\\)\\s *")
+        c-comment-start-regexp "/[*/]\\|\\s!")
   (setq-local comment-line-break-function #'c-indent-new-comment-line)
   (setq-local c-block-comment-start-regexp "/\\*")
   (setq-local comment-multi-line t)
@@ -3927,19 +4614,33 @@ If one hasn't been set, or if it's stale, prompt for a 
new one."
   ;;(syntax-propertize (point-max))
   )
 
-;;;###autoload
-(define-derived-mode js-jsx-mode js-mode "JSX"
-  "Major mode for editing JSX.
-
-To customize the indentation for this mode, set the SGML offset
-variables (`sgml-basic-offset', `sgml-attribute-offset' et al.)
-locally, like so:
+;; Since we made JSX support available and automatically-enabled in
+;; the base `js-mode' (for ease of use), now `js-jsx-mode' simply
+;; serves as one other interface to unconditionally enable JSX in
+;; buffers, mostly for backwards-compatibility.
+;;
+;; Since it is probably more common for packages to integrate with
+;; `js-mode' than with `js-jsx-mode', it is therefore probably
+;; slightly better for users to use one of the many other methods for
+;; enabling JSX syntax.  But using `js-jsx-mode' can’t be that bad
+;; either, so we won’t bother users with an obsoletion warning.
 
-  (defun set-jsx-indentation ()
-    (setq-local sgml-basic-offset js-indent-level))
-  (add-hook \\='js-jsx-mode-hook #\\='set-jsx-indentation)"
+;;;###autoload
+(define-derived-mode js-jsx-mode js-mode "JavaScript"
+  "Major mode for editing JavaScript+JSX.
+
+Simply makes `js-jsx-syntax' buffer-local and sets it to t.
+
+`js-mode' may detect and enable support for JSX automatically if
+it appears to be used in a JavaScript file.  You could also
+customize `js-jsx-regexps' to improve that detection; or, you
+could set `js-jsx-syntax' to t in your init file, or in a
+.dir-locals.el file, or using file variables; or, you could call
+`js-jsx-enable' in `js-mode-hook'.  You may be better served by
+one of the aforementioned options instead of using this mode."
   :group 'js
-  (setq-local indent-line-function #'js-jsx-indent-line))
+  (js-jsx-enable)
+  (js-use-syntactic-mode-name))
 
 ;;;###autoload (defalias 'javascript-mode 'js-mode)
 
diff --git a/lisp/progmodes/ld-script.el b/lisp/progmodes/ld-script.el
index f555155..6dafb64 100644
--- a/lisp/progmodes/ld-script.el
+++ b/lisp/progmodes/ld-script.el
@@ -1,6 +1,6 @@
 ;;; ld-script.el --- GNU linker script editing mode for Emacs
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Masatake YAMATO<address@hidden>
 ;; Keywords: languages, faces
diff --git a/lisp/progmodes/m4-mode.el b/lisp/progmodes/m4-mode.el
index 46568f1..98b812f 100644
--- a/lisp/progmodes/m4-mode.el
+++ b/lisp/progmodes/m4-mode.el
@@ -1,6 +1,6 @@
 ;;; m4-mode.el --- m4 code editing commands for Emacs
 
-;; Copyright (C) 1996-1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Andrew Csillag <address@hidden>
 ;; Keywords: languages, faces
@@ -65,7 +65,7 @@ If m4 is not in your PATH, set this to an absolute file name."
 (defvar m4-font-lock-keywords
   '(("\\(\\_<\\(m4_\\)?dnl\\_>\\).*$" . font-lock-comment-face)
     ("address@hidden" . font-lock-variable-name-face)
-    ("\\$\\@" . font-lock-variable-name-face)
+    ("\\$@" . font-lock-variable-name-face)
     ("\\$\\*" . font-lock-variable-name-face)
     
("\\_<\\(m4_\\)?\\(builtin\\|change\\(com\\|quote\\|word\\)\\|d\\(e\\(bug\\(file\\|mode\\)\\|cr\\|f\\(ine\\|n\\)\\)\\|iv\\(ert\\|num\\)\\|nl\\|umpdef\\)\\|e\\(rrprint\\|syscmd\\|val\\)\\|f\\(ile\\|ormat\\)\\|gnu\\|i\\(f\\(def\\|else\\)\\|n\\(c\\(lude\\|r\\)\\|d\\(ex\\|ir\\)\\)\\)\\|l\\(en\\|ine\\)\\|m\\(4\\(exit\\|wrap\\)\\|aketemp\\)\\|p\\(atsubst\\|opdef\\|ushdef\\)\\|regexp\\|s\\(hift\\|include\\|ubstr\\|ys\\(cmd\\|val\\)\\)\\|tra\\(ceo\\(ff\\|n\\)\\|nslit\\)\\|un\\(d\\(efine\\|iv
 [...]
   "Default `font-lock-keywords' for M4 mode.")
diff --git a/lisp/progmodes/make-mode.el b/lisp/progmodes/make-mode.el
index ed4e69d..cffb749 100644
--- a/lisp/progmodes/make-mode.el
+++ b/lisp/progmodes/make-mode.el
@@ -1,6 +1,6 @@
 ;;; make-mode.el --- makefile editing commands for Emacs -*- lexical-binding:t 
-*-
 
-;; Copyright (C) 1992, 1994, 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1994, 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Thomas Neumann <address@hidden>
 ;;     Eric S. Raymond <address@hidden>
diff --git a/lisp/progmodes/mantemp.el b/lisp/progmodes/mantemp.el
index 214aa39..4190a84 100644
--- a/lisp/progmodes/mantemp.el
+++ b/lisp/progmodes/mantemp.el
@@ -1,6 +1,6 @@
 ;;; mantemp.el --- create manual template instantiations from g++ 2.7.2 output
 
-;; Copyright (C) 1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Tom Houlder <address@hidden>
 ;; Created: 10 Dec 1996
@@ -89,7 +89,7 @@
   (save-excursion
     (goto-char (point-min))
     (message "Removing comments")
-    (while (re-search-forward "^[A-z.()+0-9: ]*`\\|'.*$" nil t)
+    (while (re-search-forward "^[a-zA-Z.()+0-9: ]*`\\|'.*$" nil t)
       (replace-match ""))))
 
 (defun mantemp-remove-memfuncs ()
@@ -99,14 +99,14 @@
     (goto-char (point-min))
     (message "Removing member function extensions")
     (while (re-search-forward
-           "^[A-z :&*<>~=,0-9+]*>::operator " nil t nil)
+           "^[a-zA-Z :&*<>~=,0-9+]*>::operator " nil t nil)
       (progn
        (backward-char 11)
        (delete-region (point) (line-end-position))))
     ;; Remove other member function extensions.
     (goto-char (point-min))
     (message "Removing member function extensions")
-    (while (re-search-forward "^[A-z :&*<>~=,0-9+]*>::" nil t nil)
+    (while (re-search-forward "^[a-zA-Z :&*<>~=,0-9+]*>::" nil t nil)
       (progn
        (backward-char 2)
        (delete-region (point) (line-end-position))))))
@@ -154,7 +154,7 @@ the lines."
     (goto-char (point-min))
     (message "Inserting 'template' for functions")
     (while (re-search-forward
-           "^template class [A-z :&*<>~=,0-9+!]*(" nil t nil)
+           "^template class [a-zA-Z :&*<>~=,0-9+!]*(" nil t nil)
       (progn
        (beginning-of-line)
        (forward-word-strictly 1)
diff --git a/lisp/progmodes/meta-mode.el b/lisp/progmodes/meta-mode.el
index e207d22..8d3745b 100644
--- a/lisp/progmodes/meta-mode.el
+++ b/lisp/progmodes/meta-mode.el
@@ -1,6 +1,6 @@
 ;;; meta-mode.el --- major mode for editing Metafont or MetaPost sources -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Ulrik Vieth <address@hidden>
 ;; Version: 1.0
@@ -666,7 +666,7 @@ If the list was changed, sort the list and remove 
duplicates first."
       (let ((count 0))
         (narrow-to-region
          (point) (save-excursion
-                   (re-search-forward "[^\\\\\"]%\\|\n\\|\\'" nil t)
+                   (re-search-forward "[^\\\"]%\\|\n\\|\\'" nil t)
                    (backward-char) (point)))
         (while (re-search-forward "\\<\\sw+\\>\\|(\\|)" nil t)
           (save-excursion
diff --git a/lisp/progmodes/mixal-mode.el b/lisp/progmodes/mixal-mode.el
index a8c5c39..a759709 100644
--- a/lisp/progmodes/mixal-mode.el
+++ b/lisp/progmodes/mixal-mode.el
@@ -1,6 +1,6 @@
 ;;; mixal-mode.el --- Major mode for the mix asm language.
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author: Pieter E.J. Pareit <address@hidden>
 ;; Maintainer: address@hidden
@@ -1044,7 +1044,7 @@ EXECUTION-TIME holds info about the time it takes, number 
or string.")
      . mixal-font-lock-operation-code-face)
     (,(regexp-opt mixal-assembly-pseudoinstructions 'words)
      . mixal-font-lock-assembly-pseudoinstruction-face)
-    ("^[A-Z0-9a-z]*[ \t]+[A-ZO-9a-z]+[ \t]+\\(=.*=\\)"
+    ("^[A-Z0-9a-z]*[ \t]+[A-Z0-9a-z]+[ \t]+\\(=.*=\\)"
      (1 font-lock-constant-face)))
   "Keyword highlighting specification for `mixal-mode'.")
 ;; (makunbound 'mixal-font-lock-keywords)
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
index 69cf600..52e5fd4 100644
--- a/lisp/progmodes/octave.el
+++ b/lisp/progmodes/octave.el
@@ -1,6 +1,6 @@
 ;;; octave.el --- editing octave source files under emacs  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Kurt Hornik <address@hidden>
 ;;        John Eaton <address@hidden>
diff --git a/lisp/progmodes/opascal.el b/lisp/progmodes/opascal.el
index 5d3aa3c..7d51816 100644
--- a/lisp/progmodes/opascal.el
+++ b/lisp/progmodes/opascal.el
@@ -1,6 +1,6 @@
 ;;; opascal.el --- major mode for editing Object Pascal source in Emacs  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1998-1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-1999, 2001-2019 Free Software Foundation, Inc.
 
 ;; Authors: Ray Blaak <address@hidden>,
 ;;          Simon South <address@hidden>
@@ -1519,7 +1519,7 @@ value of `opascal-tab-always-indents' and the current 
line position."
         (setq dir-name (match-string 1 dir-name)
               recurse t))
     ;; Ensure the trailing slash is removed.
-    (if (string-match "^\\(.+\\)[\\\\/]$" dir-name)
+    (if (string-match "^\\(.+\\)[\\/]$" dir-name)
         (setq dir-name (match-string 1 dir-name)))
     (opascal-search-directory unit dir-name recurse)))
 
diff --git a/lisp/progmodes/pascal.el b/lisp/progmodes/pascal.el
index 6d13d32..cae514a 100644
--- a/lisp/progmodes/pascal.el
+++ b/lisp/progmodes/pascal.el
@@ -1,6 +1,6 @@
 ;;; pascal.el --- major mode for editing pascal source in Emacs -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1993-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-2019 Free Software Foundation, Inc.
 
 ;; Author: Espen Skoglund <address@hidden>
 ;; Keywords: languages
@@ -117,7 +117,7 @@
 (defconst pascal-beg-block-re   "\\<\\(begin\\|case\\|record\\|repeat\\)\\>")
 (defconst pascal-end-block-re   "\\<\\(end\\|until\\)\\>")
 (defconst pascal-declaration-re "\\<\\(const\\|label\\|type\\|var\\)\\>")
-(defconst pascal-progbeg-re     "\\<\\program\\>")
+(defconst pascal-progbeg-re     "\\<program\\>")
 (defconst pascal-defun-re       "\\<\\(function\\|procedure\\|program\\)\\>")
 (defconst pascal-sub-block-re   "\\<\\(if\\|else\\|for\\|while\\|with\\)\\>")
 (defconst pascal-noindent-re    "\\<\\(begin\\|end\\|until\\|else\\)\\>")
diff --git a/lisp/progmodes/perl-mode.el b/lisp/progmodes/perl-mode.el
index a61d1ad..7cbd30a 100644
--- a/lisp/progmodes/perl-mode.el
+++ b/lisp/progmodes/perl-mode.el
@@ -1,6 +1,6 @@
 ;;; perl-mode.el --- Perl code editing commands for GNU Emacs  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1990, 1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990, 1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: William F. Mann
 ;; Maintainer: address@hidden
diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el
index b1a17df..2b05735 100644
--- a/lisp/progmodes/prog-mode.el
+++ b/lisp/progmodes/prog-mode.el
@@ -1,6 +1,6 @@
 ;;; prog-mode.el --- Generic major mode for programming  -*- lexical-binding: 
t -*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: internal
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index f3f29cb..11a2ef4 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1,6 +1,6 @@
 ;;; project.el --- Operations on the current project  -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -35,7 +35,7 @@
 ;; Infrastructure:
 ;;
 ;; Function `project-current', to determine the current project
-;; instance, and 3 (at the moment) generic functions that act on it.
+;; instance, and 5 (at the moment) generic functions that act on it.
 ;; This list is to be extended in future versions.
 ;;
 ;; Utils:
@@ -45,8 +45,9 @@
 ;;
 ;; Commands:
 ;;
-;; `project-find-regexp' and `project-or-external-find-regexp' use the
-;; current API, and thus will work in any project that has an adapter.
+;; `project-find-file', `project-find-regexp' and
+;; `project-or-external-find-regexp' use the current API, and thus
+;; will work in any project that has an adapter.
 
 ;;; TODO:
 
@@ -54,9 +55,6 @@
 ;;   filenotify.el (if supported) to invalidate.  And avoiding caching
 ;;   if it's not available (manual cache invalidation is not nice).
 ;;
-;; * Allow the backend to override the file-listing logic?  Maybe also
-;;   to delegate file name completion to an external tool.
-;;
 ;; * Build tool related functionality.  Start with a `project-build'
 ;;   command, which should provide completions on tasks to run, and
 ;;   maybe allow entering some additional arguments.  This might
@@ -148,6 +146,8 @@ Patterns can match both regular files and directories.
 To root an entry, start it with `./'.  To match directories only,
 end it with `/'.  DIR must be one of `project-roots' or
 `project-external-roots'."
+  ;; TODO: Document and support regexp ignores as used by Hg.
+  ;; TODO: Support whitelist entries.
   (require 'grep)
   (defvar grep-find-ignored-files)
   (nconc
@@ -162,29 +162,14 @@ end it with `/'.  DIR must be one of `project-roots' or
 DIRS is a list of absolute directories; it should be some
 subset of the project roots and external roots.
 
-The default implementation uses `find-program'.  PROJECT is used
-to find the list of ignores for each directory."
-  ;; FIXME: Uniquely abbreviate the roots?
-  (require 'xref)
-  (let ((all-files
-        (cl-mapcan
-         (lambda (dir)
-           (let ((command
-                  (format "%s %s %s -type f -print0"
-                          find-program
-                           (shell-quote-argument
-                            (expand-file-name dir))
-                          (xref--find-ignores-arguments
-                           (project-ignores project dir)
-                           (expand-file-name dir)))))
-             (split-string (shell-command-to-string command) "\0" t)))
-         dirs)))
+The default implementation delegates to `project-files'."
+  (let ((all-files (project-files project dirs)))
     (lambda (string pred action)
       (cond
        ((eq action 'metadata)
-       '(metadata . ((category . project-file))))
+        '(metadata . ((category . project-file))))
        (t
-       (complete-with-action action all-files string pred))))))
+        (complete-with-action action all-files string pred))))))
 
 (cl-defmethod project-roots ((project (head transient)))
   (list (cdr project)))
@@ -192,14 +177,49 @@ to find the list of ignores for each directory."
 (cl-defgeneric project-files (project &optional dirs)
   "Return a list of files in directories DIRS in PROJECT.
 DIRS is a list of absolute directories; it should be some
-subset of the project roots and external roots."
-  ;; This default implementation only works if project-file-completion-table
-  ;; returns a "flat" completion table.
-  ;; FIXME: Maybe we should do the reverse: implement the default
-  ;; `project-file-completion-table' on top of `project-files'.
-  (all-completions
-   "" (project-file-completion-table
-       project (or dirs (project-roots project)))))
+subset of the project roots and external roots.
+
+The default implementation uses `find-program'.  PROJECT is used
+to find the list of ignores for each directory."
+  (require 'xref)
+  (cl-mapcan
+   (lambda (dir)
+     (project--files-in-directory dir
+                                  (project--dir-ignores project dir)))
+   (or dirs (project-roots project))))
+
+(defun project--files-in-directory (dir ignores &optional files)
+  (require 'find-dired)
+  (defvar find-name-arg)
+  (let ((default-directory dir)
+        (command (format "%s %s %s -type f %s -print0"
+                         find-program
+                         (file-local-name dir)
+                         (xref--find-ignores-arguments
+                          ignores
+                          (expand-file-name dir))
+                         (if files
+                             (concat (shell-quote-argument "(")
+                                     " " find-name-arg " "
+                                     (mapconcat
+                                      #'shell-quote-argument
+                                      (split-string files)
+                                      (concat " -o " find-name-arg " "))
+                                     " "
+                                     (shell-quote-argument ")"))"")
+                         )))
+    (project--remote-file-names
+     (sort (split-string (shell-command-to-string command) "\0" t)
+           #'string<))))
+
+(defun project--remote-file-names (local-files)
+  "Return LOCAL-FILES as if they were on the system of `default-directory'."
+  (let ((remote-id (file-remote-p default-directory)))
+    (if (not remote-id)
+        local-files
+      (mapcar (lambda (file)
+                (concat remote-id file))
+              local-files))))
 
 (defgroup project-vc nil
   "Project implementation using the VC package."
@@ -276,7 +296,10 @@ backend implementation of `project-external-roots'.")
             entry))
         (vc-call-backend backend 'ignore-completion-table root)))
      (project--value-in-dir 'project-vc-ignores root)
-     (cl-call-next-method))))
+     (mapcar
+      (lambda (dir)
+        (concat dir "/"))
+      vc-directory-exclusion-list))))
 
 (defun project-combine-directories (&rest lists-of-dirs)
   "Return a sorted and culled list of directory names.
@@ -326,11 +349,27 @@ triggers completion when entering a pattern, including it
 requires quoting, e.g. `\\[quoted-insert]<space>'."
   (interactive (list (project--read-regexp)))
   (let* ((pr (project-current t))
-         (dirs (if current-prefix-arg
-                   (list (read-directory-name "Base directory: "
-                                              nil default-directory t))
-                 (project-roots pr))))
-    (project--find-regexp-in dirs regexp pr)))
+         (files
+          (if (not current-prefix-arg)
+              (project-files pr (project-roots pr))
+            (let ((dir (read-directory-name "Base directory: "
+                                            nil default-directory t)))
+              (project--files-in-directory dir
+                                           (project--dir-ignores pr dir)
+                                           (grep-read-files regexp))))))
+    (project--find-regexp-in-files regexp files)))
+
+(defun project--dir-ignores (project dir)
+  (let* ((roots (project-roots project))
+         (root (cl-find dir roots :test #'file-in-directory-p)))
+    (if (not root)
+        (project-ignores nil nil)       ;The defaults.
+      (let ((ignores (project-ignores project root)))
+        (if (file-equal-p root dir)
+            ignores
+          ;; FIXME: Update the "rooted" ignores to relate to DIR instead.
+          (cl-delete-if (lambda (str) (string-prefix-p "./" str))
+                        ignores))))))
 
 ;;;###autoload
 (defun project-or-external-find-regexp (regexp)
@@ -339,29 +378,76 @@ With \\[universal-argument] prefix, you can specify the 
file name
 pattern to search for."
   (interactive (list (project--read-regexp)))
   (let* ((pr (project-current t))
-         (dirs (append
-                (project-roots pr)
-                (project-external-roots pr))))
-    (project--find-regexp-in dirs regexp pr)))
+         (files
+          (project-files pr (append
+                             (project-roots pr)
+                             (project-external-roots pr)))))
+    (project--find-regexp-in-files regexp files)))
+
+(defun project--find-regexp-in-files (regexp files)
+  (pcase-let*
+      ((output (get-buffer-create " *project grep output*"))
+       (`(,grep-re ,file-group ,line-group . ,_) (car grep-regexp-alist))
+       (status nil)
+       (hits nil)
+       (xrefs nil)
+       (command (format "xargs -0 grep %s -nHE -e %s"
+                        (if (and case-fold-search
+                                 (isearch-no-upper-case-p regexp t))
+                            "-i"
+                          "")
+                        (shell-quote-argument (xref--regexp-to-extended 
regexp)))))
+    (with-current-buffer output
+      (erase-buffer)
+      (with-temp-buffer
+        (insert (mapconcat #'identity files "\0"))
+        (setq status
+              (project--process-file-region (point-min)
+                                            (point-max)
+                                            shell-file-name
+                                            output
+                                            nil
+                                            shell-command-switch
+                                            command)))
+      (goto-char (point-min))
+      (when (and (/= (point-min) (point-max))
+                 (not (looking-at grep-re))
+                 ;; TODO: Show these matches as well somehow?
+                 (not (looking-at "Binary file .* matches")))
+        (user-error "Search failed with status %d: %s" status
+                    (buffer-substring (point-min) (line-end-position))))
+      (while (re-search-forward grep-re nil t)
+        (push (list (string-to-number (match-string line-group))
+                    (match-string file-group)
+                    (buffer-substring-no-properties (point) 
(line-end-position)))
+              hits)))
+    (setq xrefs (xref--convert-hits (nreverse hits) regexp))
+    (unless xrefs
+      (user-error "No matches for: %s" regexp))
+    (xref--show-xrefs xrefs nil)))
+
+(defun project--process-file-region (start end program
+                                     &optional buffer display
+                                     &rest args)
+  ;; FIXME: This branching shouldn't be necessary, but
+  ;; call-process-region *is* measurably faster, even for a program
+  ;; doing some actual work (for a period of time). Even though
+  ;; call-process-region also creates a temp file internally
+  ;; (http://lists.gnu.org/archive/html/emacs-devel/2019-01/msg00211.html).
+  (if (not (file-remote-p default-directory))
+      (apply #'call-process-region
+             start end program nil buffer display args)
+    (let ((infile (make-temp-file "ppfr")))
+      (unwind-protect
+          (progn
+            (write-region start end infile nil 'silent)
+            (apply #'process-file program infile buffer display args))
+        (delete-file infile)))))
 
 (defun project--read-regexp ()
   (let ((id (xref-backend-identifier-at-point (xref-find-backend))))
     (read-regexp "Find regexp" (and id (regexp-quote id)))))
 
-(defun project--find-regexp-in (dirs regexp project)
-  (require 'grep)
-  (let* ((files (if current-prefix-arg
-                    (grep-read-files regexp)
-                  "*"))
-         (xrefs (cl-mapcan
-                 (lambda (dir)
-                   (xref-collect-matches regexp files dir
-                                         (project-ignores project dir)))
-                 dirs)))
-    (unless xrefs
-      (user-error "No matches for: %s" regexp))
-    (xref--show-xrefs xrefs nil)))
-
 ;;;###autoload
 (defun project-find-file ()
   "Visit a file (with completion) in the current project's roots.
@@ -401,48 +487,63 @@ recognized."
   ;; removing it when it has no matches.  Neither seems natural
   ;; enough.  Removal is confusing; early expansion makes the prompt
   ;; too long.
-  (let* (;; (initial-input
-         ;;  (let ((common-prefix (try-completion "" collection)))
-         ;;    (if (> (length common-prefix) 0)
-         ;;        (file-name-directory common-prefix))))
+  (let* ((common-parent-directory
+          (let ((common-prefix (try-completion "" collection)))
+            (if (> (length common-prefix) 0)
+                (file-name-directory common-prefix))))
+         (cpd-length (length common-parent-directory))
+         (prompt (if (zerop cpd-length)
+                     prompt
+                   (concat prompt (format " in %s" common-parent-directory))))
+         ;; XXX: This requires collection to be "flat" as well.
+         (substrings (mapcar (lambda (s) (substring s cpd-length))
+                             (all-completions "" collection)))
+         (new-collection
+          (lambda (string pred action)
+            (cond
+             ((eq action 'metadata)
+              (if (functionp collection) (funcall collection nil nil 
'metadata)))
+             (t
+             (complete-with-action action substrings string pred)))))
          (new-prompt (if default
                          (format "%s (default %s): " prompt default)
                        (format "%s: " prompt)))
          (res (completing-read new-prompt
-                               collection predicate t
+                               new-collection predicate t
                                nil ;; initial-input
                                hist default inherit-input-method)))
-    (if (and (equal res default)
-             (not (test-completion res collection predicate)))
-        (completing-read (format "%s: " prompt)
-                         collection predicate t res hist nil
-                         inherit-input-method)
-      res)))
+    (when (and (equal res default)
+               (not (test-completion res collection predicate)))
+      (setq res
+            (completing-read (format "%s: " prompt)
+                             new-collection predicate t res hist nil
+                             inherit-input-method)))
+    (concat common-parent-directory res)))
 
-(declare-function multifile-continue "multifile" ())
+(declare-function fileloop-continue "fileloop" ())
 
 ;;;###autoload
 (defun project-search (regexp)
   "Search for REGEXP in all the files of the project.
 Stops when a match is found.
-To continue searching for next match, use command \\[multifile-continue]."
+To continue searching for next match, use command \\[fileloop-continue]."
   (interactive "sSearch (regexp): ")
-  (multifile-initialize-search
+  (fileloop-initialize-search
    regexp (project-files (project-current t)) 'default)
-  (multifile-continue))
+  (fileloop-continue))
 
 ;;;###autoload
-(defun project-query-replace (from to)
+(defun project-query-replace-regexp (from to)
   "Search for REGEXP in all the files of the project.
 Stops when a match is found.
-To continue searching for next match, use command \\[multifile-continue]."
+To continue searching for next match, use command \\[fileloop-continue]."
   (interactive
    (pcase-let ((`(,from ,to)
                 (query-replace-read-args "Query replace (regexp)" t t)))
      (list from to)))
-  (multifile-initialize-replace
+  (fileloop-initialize-replace
    from to (project-files (project-current t)) 'default)
-  (multifile-continue))
+  (fileloop-continue))
 
 (provide 'project)
 ;;; project.el ends here
diff --git a/lisp/progmodes/prolog.el b/lisp/progmodes/prolog.el
index 6a81854..296a7ac 100644
--- a/lisp/progmodes/prolog.el
+++ b/lisp/progmodes/prolog.el
@@ -1,6 +1,6 @@
 ;;; prolog.el --- major mode for Prolog (and Mercury) -*- lexical-binding:t -*-
 
-;; Copyright (C) 1986-1987, 1997-1999, 2002-2003, 2011-2018 Free
+;; Copyright (C) 1986-1987, 1997-1999, 2002-2003, 2011-2019 Free
 ;; Software Foundation, Inc.
 
 ;; Authors: Emil Åström <emil_astrom(at)hotmail(dot)com>
@@ -2826,7 +2826,7 @@ STRING should be given if the last search was by 
`string-match' on STRING."
           (progn
             (if (and (eq prolog-system 'mercury)
                      (looking-at
-                      (format ":-[ \t]*\\(pred\\|mode\\)[ \t]+\\(%s+\\)"
+                      (format ":-[ \t]*\\(pred\\|mode\\)[ 
\t]+\\(\\(?:%s\\)+\\)"
                               prolog-atom-regexp)))
                 ;; Skip predicate declarations
                 (progn
@@ -2950,7 +2950,7 @@ objects (relevant only if `prolog-system' is set to 
`sicstus')."
            (predname
             (if (looking-at prolog-atom-char-regexp)
                 (progn
-                  (skip-chars-forward "^ (\\.")
+                  (skip-chars-forward "^ (.")
                   (buffer-substring op (point)))
               ""))
            (arity 0))
diff --git a/lisp/progmodes/ps-mode.el b/lisp/progmodes/ps-mode.el
index 5f29e26..d940627 100644
--- a/lisp/progmodes/ps-mode.el
+++ b/lisp/progmodes/ps-mode.el
@@ -1,6 +1,6 @@
 ;;; ps-mode.el --- PostScript mode for GNU Emacs
 
-;; Copyright (C) 1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author:     Peter Kleiweg <address@hidden>
 ;; Maintainer: Peter Kleiweg <address@hidden>
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 654a0d3..eb3e31c 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1,6 +1,6 @@
 ;;; python.el --- Python's flying circus support for Emacs -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author: Fabián E. Gallina <address@hidden>
 ;; URL: https://github.com/fgallina/python.el
@@ -438,7 +438,7 @@ It returns a file name which can be used directly as 
argument of
                                          (* ?\\ ?\\) (any ?\' ?\")))
                                 (* ?\\ ?\\)
                                 ;; Match single or triple quotes of any kind.
-                                (group (or  "\"" "\"\"\"" "'" "'''")))))
+                                (group (or  "\"\"\"" "\"" "'''" "'")))))
       (coding-cookie . ,(rx line-start ?# (* space)
                             (or
                              ;; # coding=<encoding name>
@@ -575,7 +575,7 @@ class declarations.")
            "reload" "unichr" "unicode" "xrange" "apply" "buffer" "coerce"
            "intern"
            ;; Python 3:
-           "ascii" "bytearray" "bytes" "exec"
+           "ascii" "breakpoint" "bytearray" "bytes" "exec"
            ;; Extra:
            "__all__" "__doc__" "__name__" "__package__")
           symbol-end) . font-lock-builtin-face))
@@ -675,7 +675,7 @@ Which one will be chosen depends on the value of
 
 (defconst python-syntax-propertize-function
   (syntax-propertize-rules
-   ((python-rx string-delimiter)
+   ((rx (or "\"\"\"" "'''"))
     (0 (ignore (python-syntax-stringify))))))
 
 (define-obsolete-variable-alias 'python--prettify-symbols-alist
@@ -701,35 +701,27 @@ is used to limit the scan."
 
 (defun python-syntax-stringify ()
   "Put `syntax-table' property correctly on single/triple quotes."
-  (let* ((num-quotes (length (match-string-no-properties 1)))
-         (ppss (prog2
-                   (backward-char num-quotes)
-                   (syntax-ppss)
-                 (forward-char num-quotes)))
-         (string-start (and (not (nth 4 ppss)) (nth 8 ppss)))
-         (quote-starting-pos (- (point) num-quotes))
-         (quote-ending-pos (point))
-         (num-closing-quotes
-          (and string-start
-               (python-syntax-count-quotes
-                (char-before) string-start quote-starting-pos))))
-    (cond ((and string-start (= num-closing-quotes 0))
-           ;; This set of quotes doesn't match the string starting
-           ;; kind. Do nothing.
+  (let* ((ppss (save-excursion (backward-char 3) (syntax-ppss)))
+         (string-start (and (eq t (nth 3 ppss)) (nth 8 ppss)))
+         (quote-starting-pos (- (point) 3))
+         (quote-ending-pos (point)))
+    (cond ((or (nth 4 ppss)             ;Inside a comment
+               (and string-start
+                    ;; Inside of a string quoted with different triple quotes.
+                    (not (eql (char-after string-start)
+                              (char-after quote-starting-pos)))))
+           ;; Do nothing.
            nil)
-          ((not string-start)
+          ((nth 5 ppss)
+           ;; The first quote is escaped, so it's not part of a triple quote!
+           (goto-char (1+ quote-starting-pos)))
+          ((null string-start)
            ;; This set of quotes delimit the start of a string.
            (put-text-property quote-starting-pos (1+ quote-starting-pos)
                               'syntax-table (string-to-syntax "|")))
-          ((= num-quotes num-closing-quotes)
+          (t
            ;; This set of quotes delimit the end of a string.
            (put-text-property (1- quote-ending-pos) quote-ending-pos
-                              'syntax-table (string-to-syntax "|")))
-          ((> num-quotes num-closing-quotes)
-           ;; This may only happen whenever a triple quote is closing
-           ;; a single quoted string. Add string delimiter syntax to
-           ;; all three quotes.
-           (put-text-property quote-starting-pos quote-ending-pos
                               'syntax-table (string-to-syntax "|"))))))
 
 (defvar python-mode-syntax-table
@@ -1334,16 +1326,17 @@ the line will be re-indented automatically if needed."
            (not (equal ?: (char-before (1- (point)))))
            (not (python-syntax-comment-or-string-p)))
       ;; Just re-indent dedenters
-      (let ((dedenter-pos (python-info-dedenter-statement-p))
-            (current-pos (point)))
+      (let ((dedenter-pos (python-info-dedenter-statement-p)))
         (when dedenter-pos
-          (save-excursion
-            (goto-char dedenter-pos)
-            (python-indent-line)
-            (unless (= (line-number-at-pos dedenter-pos)
-                       (line-number-at-pos current-pos))
-              ;; Reindent region if this is a multiline statement
-              (python-indent-region dedenter-pos current-pos)))))))))
+          (let ((start (copy-marker dedenter-pos))
+                (end (point-marker)))
+            (save-excursion
+              (goto-char start)
+              (python-indent-line)
+              (unless (= (line-number-at-pos start)
+                         (line-number-at-pos end))
+                ;; Reindent region if this is a multiline statement
+                (python-indent-region start end))))))))))
 
 
 ;;; Mark
@@ -2010,7 +2003,7 @@ position, else returns nil."
 It should not contain a caret (^) at the beginning."
   :type 'string)
 
-(defcustom python-shell-prompt-block-regexp "\\.\\.\\. "
+(defcustom python-shell-prompt-block-regexp "\\.\\.\\.:? "
   "Regular expression matching block input prompt of Python shell.
 It should not contain a caret (^) at the beginning."
   :type 'string)
@@ -2310,15 +2303,16 @@ detection and just returns nil."
                          ;; carriage returns in unbuffered mode.
                          (let ((inhibit-eol-conversion (getenv 
"PYTHONUNBUFFERED")))
                            (python-shell--save-temp-file code))))
-                    ;; Use `process-file' as it is remote-host friendly.
-                    (process-file
-                     interpreter
-                     code-file
-                     '(t nil)
-                     nil
-                     interpreter-arg)
-                    ;; Try to cleanup
-                    (delete-file code-file)))
+                    (unwind-protect
+                        ;; Use `process-file' as it is remote-host friendly.
+                        (process-file
+                         interpreter
+                         code-file
+                         '(t nil)
+                         nil
+                         interpreter-arg)
+                      ;; Try to cleanup
+                      (delete-file code-file))))
                 (buffer-string)))
              (prompts
               (catch 'prompts
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 2f68f00..4fceda8 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -1,6 +1,6 @@
 ;;; ruby-mode.el --- Major mode for editing Ruby files -*- lexical-binding: t 
-*-
 
-;; Copyright (C) 1994-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-2019 Free Software Foundation, Inc.
 
 ;; Authors: Yukihiro Matsumoto
 ;;     Nobuyoshi Nakada
@@ -108,7 +108,7 @@
   "Regexp to match the beginning of a heredoc.")
 
   (defconst ruby-expression-expansion-re
-    
"\\(?:[^\\]\\|\\=\\)\\(\\\\\\\\\\)*\\(#\\({[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\|\\$[^a-zA-Z
 \n]\\)\\)"))
+    
"\\(?:[^\\]\\|\\=\\)\\(\\\\\\\\\\)*\\(#\\({[^}\n\\]*\\(\\\\.[^}\n\\]*\\)*}\\|\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+\\|\\$[^a-zA-Z
 \n]\\)\\)"))
 
 (defun ruby-here-doc-end-match ()
   "Return a regexp to find the end of a heredoc.
@@ -517,6 +517,9 @@ It is used when `ruby-encoding-magic-comment-style' is set 
to `custom'."
              ((ruby-smie--opening-pipe-p) "opening-|")
              ((ruby-smie--closing-pipe-p) "closing-|")
              (t tok)))
+           ((string-match "\\`[^|]+|\\'" tok)
+            (forward-char -1)
+            (substring tok 0 -1))
            ((and (equal tok "") (looking-at "\\\\\n"))
             (goto-char (match-end 0)) (ruby-smie--forward-token))
            ((equal tok "do")
@@ -559,6 +562,7 @@ It is used when `ruby-encoding-magic-comment-style' is set 
to `custom'."
            ((ruby-smie--opening-pipe-p) "opening-|")
            ((ruby-smie--closing-pipe-p) "closing-|")
            (t tok)))
+         ((string-match-p "\\`[^|]+|\\'" tok) "closing-|")
          ((string-match-p "\\`|[*&]\\'" tok)
           (forward-char 1)
           (substring tok 1))
@@ -925,9 +929,9 @@ Can be one of `heredoc', `modifier', `expr-qstr', 
`expr-re'."
                    (goto-char (match-end 0))
                    (not (looking-at "\\s_")))
                   ((eq option 'expr-qstr)
-                   (looking-at "[a-zA-Z][a-zA-z0-9_]* +%[^ \t]"))
+                   (looking-at "[a-zA-Z][a-zA-Z0-9_]* +%[^ \t]"))
                   ((eq option 'expr-re)
-                   (looking-at "[a-zA-Z][a-zA-z0-9_]* +/[^ \t]"))
+                   (looking-at "[a-zA-Z][a-zA-Z0-9_]* +/[^ \t]"))
                   (t nil)))))))))
 
 (defun ruby-forward-string (term &optional end no-error expand)
@@ -1043,7 +1047,7 @@ delimiter."
        ((looking-at "\\?")              ;skip ?char
         (cond
          ((and (ruby-expr-beg)
-               (looking-at "?\\(\\\\C-\\|\\\\M-\\)*\\\\?."))
+               (looking-at "\\?\\(\\\\C-\\|\\\\M-\\)*\\\\?."))
           (goto-char (match-end 0)))
          (t
           (goto-char pnt))))
@@ -1486,7 +1490,7 @@ With ARG, do it many times.  Negative ARG means move 
backward."
             (cond ((looking-at "\\?\\(\\\\[CM]-\\)*\\\\?\\S ")
                    (goto-char (match-end 0)))
                   ((progn
-                     (skip-chars-forward ",.:;|&^~=!?\\+\\-\\*")
+                     (skip-chars-forward "-,.:;|&^~=!?+*")
                      (looking-at "\\s("))
                    (goto-char (scan-sexps (point) 1)))
                   ((and (looking-at (concat "\\<\\(" ruby-block-beg-re
@@ -1529,7 +1533,7 @@ With ARG, do it many times.  Negative ARG means move 
forward."
     (let ((i (or arg 1)))
       (condition-case nil
           (while (> i 0)
-            (skip-chars-backward " \t\n,.:;|&^~=!?\\+\\-\\*")
+            (skip-chars-backward "- \t\n,.:;|&^~=!?+*")
             (forward-char -1)
             (cond ((looking-at "\\s)")
                    (goto-char (scan-sexps (1+ (point)) -1))
@@ -1542,7 +1546,7 @@ With ARG, do it many times.  Negative ARG means move 
forward."
                   ((looking-at "\\s\"\\|\\\\\\S_")
                    (let ((c (char-to-string (char-before (match-end 0)))))
                      (while (and (search-backward c)
-                                (eq (logand (skip-chars-backward "\\") 1)
+                                (eq (logand (skip-chars-backward "\\\\") 1)
                                     1))))
                    nil)
                   ((looking-at "\\s.\\|\\s\\")
@@ -1610,7 +1614,7 @@ See `add-log-current-defun-function'."
                   (concat "^[ \t]*" re "[ \t]+"
                           "\\("
                           ;; \\. and :: for class methods
-                          "\\([A-Za-z_]" ruby-symbol-re "*\\|\\.\\|::" "\\)"
+                          "\\([A-Za-z_]" ruby-symbol-re "*[?!]?\\|\\.\\|::" 
"\\)"
                           "+\\)")))
                (definition-re (funcall make-definition-re ruby-defun-beg-re))
                (module-re (funcall make-definition-re "\\(class\\|module\\)")))
@@ -1790,8 +1794,8 @@ If the result is do-end block, it will always be 
multiline."
             (buffer-substring-no-properties (1+ min) (1- max))))
       (setq content
             (if (equal string-quote "'")
-                (replace-regexp-in-string "\\\\\"" "\"" 
(replace-regexp-in-string "\\(\\`\\|[^\\\\]\\)'" "\\1\\\\'" content))
-              (replace-regexp-in-string "\\\\'" "'" (replace-regexp-in-string 
"\\(\\`\\|[^\\\\]\\)\"" "\\1\\\\\"" content))))
+                (replace-regexp-in-string "\\\\\"" "\"" 
(replace-regexp-in-string "\\(\\`\\|[^\\]\\)'" "\\1\\\\'" content))
+              (replace-regexp-in-string "\\\\'" "'" (replace-regexp-in-string 
"\\(\\`\\|[^\\]\\)\"" "\\1\\\\\"" content))))
       (let ((orig-point (point)))
         (delete-region min max)
         (insert
@@ -1863,7 +1867,7 @@ It will be properly highlighted even when the call omits 
parens.")
       ("^[ \t]*def +\\(`\\)" (1 "_"))
       ;; Ternary operator colon followed by opening paren or bracket
       ;; (semi-important for indentation).
-      ("\\(:\\)\\(?:[\({]\\|\\[[^]]\\)"
+      ("\\(:\\)\\(?:[({]\\|\\[[^]]\\)"
        (1 (string-to-syntax ".")))
       ;; Regular expressions.  Start with matching unescaped slash.
       ("\\(?:\\=\\|[^\\]\\)\\(?:\\\\\\\\\\)*\\(/\\)"
@@ -2174,7 +2178,7 @@ It will be properly highlighted even when the call omits 
parens.")
           font-lock-constant-face)
         nil t))
     ;; Special globals.
-    (,(concat "\\$\\(?:[:\"!@;,/\\._><\\$?~=*&`'+0-9]\\|-[0adFiIlpvw]\\|"
+    (,(concat "\\$\\(?:[:\"!@;,/._><\\$?~=*&`'+0-9]\\|-[0adFiIlpvw]\\|"
               (regexp-opt '("LOAD_PATH" "LOADED_FEATURES" "PROGRAM_NAME"
                             "ERROR_INFO" "ERROR_POSITION"
                             "FS" "FIELD_SEPARATOR"
@@ -2284,7 +2288,7 @@ It will be properly highlighted even when the call omits 
parens.")
         :command command
         :sentinel
         (lambda (proc _event)
-          (when (eq 'exit (process-status proc))
+          (when (and (eq 'exit (process-status proc)) (buffer-live-p source))
             (unwind-protect
                 (if (with-current-buffer source (eq proc ruby--flymake-proc))
                     (with-current-buffer (process-buffer proc)
@@ -2297,7 +2301,10 @@ It will be properly highlighted even when the call omits 
parens.")
 
 (defcustom ruby-flymake-use-rubocop-if-available t
   "Non-nil to use the RuboCop Flymake backend.
-Only takes effect if RuboCop is installed."
+Only takes effect if RuboCop is installed.
+
+If there is no Rubocop config file, Rubocop will be passed a flag
+'--lint' to only show syntax errors and important problems."
   :version "26.1"
   :type 'boolean
   :safe 'booleanp)
@@ -2316,14 +2323,21 @@ Only takes effect if RuboCop is installed."
   (let ((command (list "rubocop" "--stdin" buffer-file-name "--format" "emacs"
                        "--cache" "false" ; Work around a bug in old version.
                        "--display-cop-names"))
+        (default-directory default-directory)
         config-dir)
     (when buffer-file-name
       (setq config-dir (locate-dominating-file buffer-file-name
                                                ruby-rubocop-config))
-      (when config-dir
+      (if (not config-dir)
+          (setq command (append command '("--lint")))
         (setq command (append command (list "--config"
                                             (expand-file-name 
ruby-rubocop-config
-                                                              config-dir)))))
+                                                              config-dir))))
+        (when (ruby-flymake-rubocop--use-bundler-p config-dir)
+          (setq command (append '("bundle" "exec") command))
+          ;; In case of a project with multiple nested subprojects,
+          ;; each one with a Gemfile.
+          (setq default-directory config-dir)))
 
       (ruby-flymake--helper
        "rubocop-flymake"
@@ -2361,6 +2375,13 @@ Only takes effect if RuboCop is installed."
           into diags
           finally (funcall report-fn diags)))))))
 
+(defun ruby-flymake-rubocop--use-bundler-p (dir)
+  (let ((file (expand-file-name "Gemfile" dir)))
+    (and (file-exists-p file)
+         (with-temp-buffer
+           (insert-file-contents file)
+           (re-search-forward "^ *gem ['\"]rubocop['\"]" nil t)))))
+
 (defun ruby-flymake-auto (report-fn &rest args)
   (apply
    (if (and ruby-flymake-use-rubocop-if-available
diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el
index c2be0b3..507a4c7 100644
--- a/lisp/progmodes/scheme.el
+++ b/lisp/progmodes/scheme.el
@@ -1,6 +1,6 @@
 ;;; scheme.el --- Scheme (and DSSSL) editing mode    -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 1986-1988, 1997-1998, 2001-2018 Free Software
+;; Copyright (C) 1986-1988, 1997-1998, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Bill Rozas <address@hidden>
@@ -433,7 +433,7 @@ that variable's value is a string."
               ;; (make-regexp '("case" "cond" "else" "if" "lambda"
               ;; "let" "let*" "letrec" "and" "or" "map" "with-mode"))
               "and\\|c\\(ase\\|ond\\)\\|else\\|if\\|"
-              "l\\(ambda\\|et\\(\\|*\\|rec\\)\\)\\|map\\|or\\|with-mode"
+              "l\\(ambda\\|et\\(\\|\\*\\|rec\\)\\)\\|map\\|or\\|with-mode"
               "\\)\\>")
       1)
      ;; DSSSL syntax
diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 6ec0529..853a350 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -1,6 +1,6 @@
 ;;; sh-script.el --- shell-script editing commands for Emacs  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1993-1997, 1999, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1993-1997, 1999, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Daniel Pfeiffer <address@hidden>
@@ -2905,8 +2905,7 @@ STRING         This is ignored for the purposes of 
calculating
                      (setq align-point (point))))
                (or (bobp)
                    (forward-char -1))
-                ;; FIXME: This charset looks too much like a regexp.  --Stef
-               (skip-chars-forward "[a-z0-9]*?")
+               (skip-chars-forward "*0-9?[]a-z")
                )
               ((string-match "[])}]" x)
                (setq x (sh-safe-forward-sexp -1))
diff --git a/lisp/progmodes/simula.el b/lisp/progmodes/simula.el
index 39d35cf..3bbf4e0 100644
--- a/lisp/progmodes/simula.el
+++ b/lisp/progmodes/simula.el
@@ -1,6 +1,6 @@
 ;;; simula.el --- SIMULA 87 code editing commands for Emacs
 
-;; Copyright (C) 1992, 1994, 1996, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1992, 1994, 1996, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Hans Henrik Eriksen <address@hidden>
diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el
index 51f78bd..2d33b31 100644
--- a/lisp/progmodes/sql.el
+++ b/lisp/progmodes/sql.el
@@ -1,6 +1,6 @@
 ;;; sql.el --- specialized comint.el for SQL interpreters  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Alex Schroeder <address@hidden>
 ;; Maintainer: Michael Mauger <address@hidden>
@@ -223,6 +223,7 @@
 ;; Simen Heggestøyl <address@hidden> -- Postgres database completion
 ;; Robert Cochran <address@hidden> -- MariaDB support
 ;; Alex Harsanyi <address@hidden> -- sql-indent package and support
+;; Roy Mathew <address@hidden> -- bug in `sql-send-string'
 ;;
 
 
@@ -237,6 +238,7 @@
 (require 'custom)
 (require 'thingatpt)
 (require 'view)
+(eval-when-compile (require 'subr-x))   ; string-empty-p
 
 (defvar font-lock-keyword-face)
 (defvar font-lock-set-defaults)
@@ -441,6 +443,7 @@ file.  Since that is a plaintext file, this could be 
dangerous."
      :sqli-login sql-ms-login-params
      :sqli-comint-func sql-comint-ms
      :prompt-regexp "^[0-9]*>"
+     :prompt-cont-regexp "^[0-9]*>"
      :prompt-length 5
      :syntax-alist ((?@ . "_"))
      :terminator ("^go" . "go"))
@@ -476,7 +479,7 @@ file.  Since that is a plaintext file, this could be 
dangerous."
      :prompt-cont-regexp "^\\(?:[ ][ ][1-9]\\|[ 
][1-9][0-9]\\|[1-9][0-9]\\{2\\}\\)[ ]\\{2\\}"
      :statement sql-oracle-statement-starters
      :syntax-alist ((?$ . "_") (?# . "_"))
-     :terminator ("\\(^/\\|;\\)$" . "/")
+     :terminator ("\\(^/\\|;\\)" . "/")
      :input-filter sql-placeholders-filter)
 
     (postgres
@@ -494,7 +497,7 @@ file.  Since that is a plaintext file, this could be 
dangerous."
      :prompt-length 5
      :prompt-cont-regexp "^[[:alnum:]_]*[-(][#>] "
      :input-filter sql-remove-tabs-filter
-     :terminator ("\\(^\\s-*\\\\g$\\|;\\)" . "\\g"))
+     :terminator ("\\(^\\s-*\\\\g\\|;\\)" . "\\g"))
 
     (solid
      :name "Solid"
@@ -519,8 +522,7 @@ file.  Since that is a plaintext file, this could be 
dangerous."
      :completion-object sql-sqlite-completion-object
      :prompt-regexp "^sqlite> "
      :prompt-length 8
-     :prompt-cont-regexp "^   \\.\\.\\.> "
-     :terminator ";")
+     :prompt-cont-regexp "^   \\.\\.\\.> ")
 
     (sybase
      :name "Sybase"
@@ -738,16 +740,131 @@ The package must be available to be loaded and 
activated."
   :type 'booleanp
   :version "27.1")
 
-(defun sql-is-indent-available ()
-  "Check if sql-indent module is available."
-  (when (locate-library "sql-indent")
-    (fboundp 'sqlind-minor-mode)))
-
 (defun sql-indent-enable ()
   "Enable `sqlind-minor-mode' if available and requested."
-  (when (sql-is-indent-available)
+  (when (fboundp 'sqlind-minor-mode)
     (sqlind-minor-mode (if sql-use-indent-support +1 -1))))
 
+;; Secure Password wallet
+
+(require 'auth-source)
+
+(defun sql-auth-source-search-wallet (wallet product user server database port)
+    "Read auth source WALLET to locate the USER secret.
+Sets `auth-sources' to WALLET and uses `auth-source-search' to locate the 
entry.
+The DATABASE and SERVER are concatenated with a slash between them as the
+host key."
+    (let* ((auth-sources wallet)
+           host
+           secret h-secret sd-secret)
+
+      ;; product
+      (setq product (symbol-name product))
+
+      ;; user
+      (setq user (unless (string-empty-p user) user))
+
+      ;; port
+      (setq port
+            (when (and port (numberp port) (not (zerop port)))
+              (number-to-string port)))
+
+      ;; server
+      (setq server (unless (string-empty-p server) server))
+
+      ;; database
+      (setq database (unless (string-empty-p database) database))
+
+      ;; host
+      (setq host (if server
+                     (if database
+                         (concat server "/" database)
+                       server)
+                   database))
+
+      ;; Perform search
+      (dolist (s (auth-source-search :max 1000))
+        (when (and
+               ;; Is PRODUCT specified, in the enty, and they are equal
+               (if product
+                   (if (plist-member s :product)
+                       (equal (plist-get s :product) product)
+                     t)
+                 t)
+               ;; Is USER specified, in the entry, and they are equal
+               (if user
+                   (if (plist-member s :user)
+                       (equal (plist-get s :user) user)
+                     t)
+                 t)
+               ;; Is PORT specified, in the entry, and they are equal
+               (if port
+                   (if (plist-member s :port)
+                       (equal (plist-get s :port) port)
+                     t)
+                 t))
+          ;; Is HOST specified, in the entry, and they are equal
+          ;; then the H-SECRET list
+          (if (and host
+                   (plist-member s :host)
+                   (equal (plist-get s :host) host))
+              (push s h-secret)
+            ;; Are SERVER and DATABASE specified, present, and equal
+            ;; then the SD-SECRET list
+            (if (and server
+                     (plist-member s :server)
+                     database
+                     (plist-member s :database)
+                     (equal (plist-get s :server) server)
+                     (equal (plist-get s :database) database))
+                (push s sd-secret)
+              ;; Is SERVER specified, in the entry, and they are equal
+              ;; then the base SECRET list
+              (if (and server
+                       (plist-member s :server)
+                       (equal (plist-get s :server) server))
+                  (push s secret)
+                ;; Is DATABASE specified, in the entry, and they are equal
+                ;; then the base SECRET list
+                (if (and database
+                         (plist-member s :database)
+                         (equal (plist-get s :database) database))
+                    (push s secret)))))))
+      (setq secret (or h-secret sd-secret secret))
+
+      ;; If we found a single secret, return the password
+      (when (= 1 (length secret))
+        (setq secret (car secret))
+        (if (plist-member secret :secret)
+            (plist-get secret :secret)
+          nil))))
+
+(defcustom sql-password-wallet
+  (let (wallet w)
+    (dolist (ext '(".json.gpg" ".gpg" ".json" "") wallet)
+      (unless wallet
+        (setq w (locate-user-emacs-file (concat "sql-wallet" ext)
+                                        (concat ".sql-wallet" ext)))
+        (when (file-exists-p w)
+          (setq wallet w)))))
+  "Identification of the password wallet.
+See `sql-password-search-wallet-function' to understand how this value
+is used to locate the password wallet."
+  :type `(plist-get (symbol-plist 'auth-sources) 'custom-type)
+  :group 'SQL
+  :version "27.1")
+
+(defvar sql-password-search-wallet-function #'sql-auth-source-search-wallet
+  "Function to handle the lookup of the database password.
+The specified function will be called as:
+  (wallet-func WALLET PRODUCT USER SERVER DATABASE PORT)
+
+It is expected to return either a string containing the password,
+a function returning the password, or nil, If you want to support
+another format of password file, then implement a different
+search wallet function and identify the location of the password
+store with `sql-password-wallet'.")
+
 ;; misc customization of sql.el behavior
 
 (defcustom sql-electric-stuff nil
@@ -804,7 +921,7 @@ Globally should be set to nil; it will be non-nil in 
`sql-mode',
 
 (defvaralias 'sql-pop-to-buffer-after-send-region 
'sql-display-sqli-buffer-function)
 
-(defcustom sql-display-sqli-buffer-function 'display-buffer
+(defcustom sql-display-sqli-buffer-function #'display-buffer
   "Function to be called to display a SQLi buffer after `sql-send-*'.
 
 When set to a function, it will be called to display the buffer.
@@ -1103,6 +1220,11 @@ Starts `sql-interactive-mode' after doing some setup."
 
 ;; Customization for Microsoft
 
+;; Microsoft documentation seems to indicate that ISQL and OSQL are
+;; going away and being replaced by SQLCMD.  If anyone has experience
+;; using SQLCMD, modified product configuration and feedback on its
+;; use would be greatly appreciated.
+
 (defcustom sql-ms-program "osql"
   "Command to start osql by Microsoft.
 
@@ -1301,6 +1423,15 @@ specified, it's `sql-product' or `sql-connection' must 
match."
                     (and (stringp connection)
                          (string= connection sql-connection))))))))
 
+(defun sql-is-sqli-buffer-p (buffer)
+  "Return non-nil if buffer is a SQLi buffer."
+  (when buffer
+    (setq buffer (get-buffer buffer))
+    (and buffer
+         (buffer-live-p buffer)
+         (with-current-buffer buffer
+           (derived-mode-p 'sql-interactive-mode)))))
+
 ;; Keymap for sql-interactive-mode.
 
 (defvar sql-interactive-mode-map
@@ -2609,7 +2740,7 @@ highlighting rules in SQL mode.")
              nil 'require-match
              init 'sql-product-history init))))
 
-(defun sql-add-product (product display &rest plist)
+(defun sql-add-product (product display &optional plist)
   "Add support for a database product in `sql-mode'.
 
 Add PRODUCT to `sql-product-alist' which enables `sql-mode' to
@@ -2666,15 +2797,38 @@ list.  See `sql-add-product' to add new products.  The 
FEATURE
 argument must be a plist keyword accepted by
 `sql-product-alist'."
 
-  (let* ((p (assoc product sql-product-alist))
-         (v (plist-get (cdr p) feature)))
+  (let* ((p (assoc product sql-product-alist))  ;; (PRODUCT :f v ...)
+         (v (plist-member (cdr p) feature)))    ;; (:FEATURE value ...) or null
+
     (if p
-        (if (and
-             (member feature sql-indirect-features)
-             (symbolp v))
-            (set v newvalue)
-          (setcdr p (plist-put (cdr p) feature newvalue)))
-      (error "`%s' is not a known product; use `sql-add-product' to add it 
first." product))))
+        (if (member feature sql-indirect-features) ; is indirect
+            (if v
+                (if (car (cdr v))
+                    (if (symbolp (car (cdr v)))
+                        ;; Indirect reference
+                        (set (car (cdr v)) newvalue)
+                      ;; indirect is not a symbol
+                      (error "The value of `%s' for `%s' is not a symbol" 
feature product))
+                  ;; keyword present, set the indirect variable name
+                  (if (symbolp newvalue)
+                      (if (cdr v)
+                          (setf (car (cdr v)) newvalue)
+                        (setf (cdr v) (list newvalue)))
+                    (error "The indirect variable of `%s' for `%s' must be a 
symbol" feature product)))
+              ;; not present; insert list
+              (setq v (list feature newvalue))
+              (setf (cdr (cdr v)) (cdr p))
+              (setf (cdr p) v))
+          ;; Not an indirect feature
+          (if v
+              (if (cdr v)
+                  (setf (car (cdr v)) newvalue)
+                (setf (cdr v) (list newvalue)))
+            ;; no value; insert into the list
+            (setq v (list feature newvalue))
+            (setf (cdr (cdr v)) (cdr p))
+            (setf (cdr p) v)))
+      (error "`%s' is not a known product; use `sql-add-product' to add it 
first" product))))
 
 (defun sql-get-product-feature (product feature &optional fallback 
not-indirect)
   "Lookup FEATURE associated with a SQL PRODUCT.
@@ -2702,7 +2856,7 @@ See `sql-product-alist' for a list of products and 
supported features."
                (member feature sql-indirect-features)
                (not not-indirect)
                (symbolp v))
-              (symbol-value v)
+              (eval v)
             v))
       (error "`%s' is not a known product; use `sql-add-product' to add it 
first." product)
       nil)))
@@ -2925,7 +3079,7 @@ displayed."
 ;;; Motion Functions
 
 (defun sql-statement-regexp (prod)
-  (let* ((ansi-stmt (sql-get-product-feature 'ansi :statement))
+  (let* ((ansi-stmt (or (sql-get-product-feature 'ansi :statement) "select"))
          (prod-stmt (sql-get-product-feature prod  :statement)))
     (concat "^\\<"
             (if prod-stmt
@@ -2966,7 +3120,7 @@ displayed."
 (defun sql-end-of-statement (arg)
   "Move to the end of the current SQL statement."
   (interactive "p")
-  (let ((term (sql-get-product-feature sql-product :terminator))
+  (let ((term (or (sql-get-product-feature sql-product :terminator) ";"))
         (re-search (if (> 0 arg) 're-search-backward 're-search-forward))
         (here (point))
         (n 0))
@@ -3086,11 +3240,11 @@ appended to the SQLi buffer without disturbing your SQL 
buffer.")
   "Return a docstring for `sql-help' listing loaded SQL products."
   (let ((doc sql--help-docstring))
     ;; Insert FREE software list
-    (when (string-match "^\\(\\s-*\\)[\\\\][\\\\]FREE\\s-*$" doc 0)
+    (when (string-match "^\\(\\s-*\\)[\\][\\]FREE\\s-*$" doc 0)
       (setq doc (replace-match (sql-help-list-products (match-string 1 doc) t)
                               t t doc 0)))
     ;; Insert non-FREE software list
-    (when (string-match "^\\(\\s-*\\)[\\\\][\\\\]NONFREE\\s-*$" doc 0)
+    (when (string-match "^\\(\\s-*\\)[\\][\\]NONFREE\\s-*$" doc 0)
       (setq doc (replace-match (sql-help-list-products (match-string 1 doc) 
nil)
                               t t doc 0)))
     doc))
@@ -3195,6 +3349,10 @@ symbol `password', for the server if it contains the 
symbol
 `database'.  The members of WHAT are processed in the order in
 which they are provided.
 
+If the `sql-password-wallet' is non-nil and WHAT contains the
+`password' token, then the `password' token will be pushed to the
+end to be sure that all of the values can be fed to the wallet.
+
 Each token may also be a list with the token in the car and a
 plist of options as the cdr.  The following properties are
 supported:
@@ -3206,6 +3364,15 @@ supported:
 
 In order to ask the user for username, password and database, call the
 function like this: (sql-get-login \\='user \\='password \\='database)."
+
+  ;; Push the password to the end if we have a wallet
+  (when (and sql-password-wallet
+             (fboundp sql-password-search-wallet-function)
+             (member 'password what))
+    (setq what (append (cl-delete 'password what)
+                       '(password))))
+
+  ;; Prompt for each parameter
   (dolist (w what)
     (let ((plist (cdr-safe w)))
       (pcase (or (car-safe w) w)
@@ -3214,7 +3381,19 @@ function like this: (sql-get-login \\='user \\='password 
\\='database)."
 
         ('password
          (setq-default sql-password
-                       (read-passwd "Password: " nil (sql-default-value 
'sql-password))))
+                       (if (and sql-password-wallet
+                                (fboundp sql-password-search-wallet-function))
+                           (let ((password (funcall 
sql-password-search-wallet-function
+                                                    sql-password-wallet
+                                                    sql-product
+                                                    sql-user
+                                                    sql-server
+                                                    sql-database
+                                                    sql-port)))
+                             (if password
+                                 password
+                               (read-passwd "Password: " nil 
(sql-default-value 'sql-password))))
+                         (read-passwd "Password: " nil (sql-default-value 
'sql-password)))))
 
         ('server
          (sql-get-login-ext 'sql-server "Server: " 'sql-server-history plist))
@@ -3380,24 +3559,29 @@ server/database name."
   "Generate a new, unique buffer name for a SQLi buffer.
 
 Append a sequence number until a unique name is found."
-  (let ((base-name (when (stringp base)
-                     (substring-no-properties
-                      (or base
-                          (sql-get-product-feature product :name)
+  (let ((base-name (substring-no-properties
+                    (if base
+                        (if (stringp base)
+                            base
+                          (format "%S" base))
+                      (or (sql-get-product-feature product :name)
                           (symbol-name product)))))
-        buf-fmt-1st buf-fmt-rest)
+        buf-fmt-1st
+        buf-fmt-rest)
 
     ;; Calculate buffer format
-    (if base-name
-        (setq buf-fmt-1st  (format "*SQL: %s*" base-name)
-              buf-fmt-rest (format "*SQL: %s-%%d*" base-name))
-      (setq buf-fmt-1st  "*SQL*"
-            buf-fmt-rest "*SQL-%d*"))
+    (if (string-blank-p base-name)
+        (setq buf-fmt-1st  "*SQL*"
+              buf-fmt-rest "*SQL-%d*")
+      (setq buf-fmt-1st  (format "*SQL: %s*" base-name)
+            buf-fmt-rest (format "*SQL: %s-%%d*" base-name)))
 
     ;; See if we can find an unused buffer
     (let ((buf-name buf-fmt-1st)
           (i 1))
-      (while (sql-buffer-live-p buf-name)
+      (while (if (sql-is-sqli-buffer-p buf-name)
+                 (comint-check-proc buf-name)
+               (buffer-live-p (get-buffer buf-name)))
         ;; Check a sequence number on the BASE
         (setq buf-name (format buf-fmt-rest i)
               i (1+ i)))
@@ -3476,12 +3660,16 @@ Inserts SELECT or commas if appropriate."
 Placeholders are words starting with an ampersand like &this."
 
   (when sql-oracle-scan-on
-    (while (string-match "&?&\\(\\(?:\\sw\\|\\s_\\)+\\)[.]?" string)
-      (setq string (replace-match
-                   (read-from-minibuffer
-                    (format "Enter value for %s: " (match-string 1 string))
-                    nil nil nil 'sql-placeholder-history)
-                   t t string))))
+    (let ((start 0)
+          (replacement ""))
+      (while (string-match "&?&\\(\\(?:\\sw\\|\\s_\\)+\\)[.]?" string start)
+        (setq replacement (read-from-minibuffer
+                          (format "Enter value for %s: "
+                                   (propertize (match-string 1 string)
+                                               'face 
'font-lock-variable-name-face))
+                          nil nil nil 'sql-placeholder-history)
+              string (replace-match replacement t t string)
+              start (+ (match-beginning 1) (length replacement))))))
   string)
 
 ;; Using DB2 interactively, newlines must be escaped with " \".
@@ -3531,8 +3719,8 @@ Allows the suppression of continuation prompts.")
 
     ;; Count how many newlines in the string
     (setq sql-output-newline-count
-          (apply #'+ (mapcar (lambda (ch)
-                                (if (eq ch ?\n) 1 0)) string)))
+          (apply #'+ (mapcar (lambda (ch) (if (eq ch ?\n) 1 0))
+                             string)))
 
     ;; Send the string
     (comint-simple-send proc string)))
@@ -3578,7 +3766,8 @@ to avoid deleting non-prompt output."
              (or (> (length (or sql-preoutput-hold "")) 0)
                  (> (or sql-output-newline-count 0) 0)
                  (not (or (string-match sql-prompt-regexp oline)
-                          (string-match sql-prompt-cont-regexp oline)))))
+                          (and sql-prompt-cont-regexp
+                               (string-match sql-prompt-cont-regexp oline))))))
 
     (save-match-data
       (let (prompt-found last-nl)
@@ -3630,6 +3819,8 @@ to avoid deleting non-prompt output."
   oline)
 
 ;;; Sending the region to the SQLi buffer.
+(defvar sql-debug-send nil
+  "Display text sent to SQL process pragmatically.")
 
 (defun sql-send-string (str)
   "Send the string STR to the SQL process."
@@ -3643,12 +3834,14 @@ to avoid deleting non-prompt output."
          (save-excursion
            ;; Set product context
            (with-current-buffer sql-buffer
+              (when sql-debug-send
+                (message ">>SQL> %S" s))
+
              ;; Send the string (trim the trailing whitespace)
-             (sql-input-sender (get-buffer-process sql-buffer) s)
+             (sql-input-sender (get-buffer-process (current-buffer)) s)
 
              ;; Send a command terminator if we must
-             (when sql-send-terminator
-               (sql-send-magic-terminator sql-buffer s sql-send-terminator))
+             (sql-send-magic-terminator sql-buffer s sql-send-terminator)
 
               (when sql-pop-to-buffer-after-send-region
                (message "Sent string to buffer %s" sql-buffer))))
@@ -3710,12 +3903,8 @@ to avoid deleting non-prompt output."
 
     ;; Check to see if the pattern is present in the str already sent
     (unless (and pat term
-                (string-match (concat pat "\\'") str))
-      (comint-simple-send (get-buffer-process buf) term)
-      (setq sql-output-newline-count
-            (if sql-output-newline-count
-                (1+ sql-output-newline-count)
-              1)))))
+                (string-match-p (concat pat "\\'") str))
+      (sql-input-sender (get-buffer-process buf) term))))
 
 (defun sql-remove-tabs-filter (str)
   "Replace tab characters with spaces."
@@ -4082,7 +4271,7 @@ must tell Emacs.  Here's how to do that in your init file:
   ;; Set syntax and font-face highlighting
   ;; Catch changes to sql-product and highlight accordingly
   (sql-set-product (or sql-product 'ansi)) ; Fixes bug#13591
-  (add-hook 'hack-local-variables-hook 'sql-highlight-product t t))
+  (add-hook 'hack-local-variables-hook #'sql-highlight-product t t))
 
 
 
@@ -4090,7 +4279,7 @@ must tell Emacs.  Here's how to do that in your init file:
 
 (put 'sql-interactive-mode 'mode-class 'special)
 (put 'sql-interactive-mode 'custom-mode-group 'SQL)
-
+;; FIXME: Why not use `define-derived-mode'?
 (defun sql-interactive-mode ()
   "Major mode to use a SQL interpreter interactively.
 
@@ -4152,13 +4341,15 @@ certain length.
 
 \(add-hook \\='sql-interactive-mode-hook
     (function (lambda ()
-        (setq comint-output-filter-functions \\='comint-truncate-buffer))))
+        (setq comint-output-filter-functions #\\='comint-truncate-buffer))))
 
 Here is another example.  It will always put point back to the statement
 you entered, right above the output it created.
 
 \(setq comint-output-filter-functions
        (function (lambda (STR) (comint-show-output))))"
+  ;; FIXME: The doc above uses `setq' on `comint-output-filter-functions',
+  ;; whereas hooks should be manipulated with things like `add/remove-hook'.
   (delay-mode-hooks (comint-mode))
 
   ;; Get the `sql-product' for this interactive session.
@@ -4189,7 +4380,8 @@ you entered, right above the output it created.
   (setq local-abbrev-table sql-mode-abbrev-table)
   (setq abbrev-all-caps 1)
   ;; Exiting the process will call sql-stop.
-  (set-process-sentinel (get-buffer-process (current-buffer)) 'sql-stop)
+  (let ((proc (get-buffer-process (current-buffer))))
+    (when proc (set-process-sentinel proc #'sql-stop)))
   ;; Save the connection and login params
   (set (make-local-variable 'sql-user)       sql-user)
   (set (make-local-variable 'sql-database)   sql-database)
@@ -4207,7 +4399,7 @@ you entered, right above the output it created.
        (sql-make-alternate-buffer-name))
   ;; User stuff.  Initialize before the hook.
   (set (make-local-variable 'sql-prompt-regexp)
-       (sql-get-product-feature sql-product :prompt-regexp))
+       (or (sql-get-product-feature sql-product :prompt-regexp) "^"))
   (set (make-local-variable 'sql-prompt-length)
        (sql-get-product-feature sql-product :prompt-length))
   (set (make-local-variable 'sql-prompt-cont-regexp)
@@ -4215,7 +4407,7 @@ you entered, right above the output it created.
   (make-local-variable 'sql-output-newline-count)
   (make-local-variable 'sql-preoutput-hold)
   (add-hook 'comint-preoutput-filter-functions
-            'sql-interactive-remove-continuation-prompt nil t)
+            #'sql-interactive-remove-continuation-prompt nil t)
   (make-local-variable 'sql-input-ring-separator)
   (make-local-variable 'sql-input-ring-file-name)
   ;; Run the mode hook (along with comint's hooks).
@@ -4223,12 +4415,12 @@ you entered, right above the output it created.
   ;; Set comint based on user overrides.
   (setq comint-prompt-regexp
         (if sql-prompt-cont-regexp
-            (concat "\\(" sql-prompt-regexp
-                    "\\|" sql-prompt-cont-regexp "\\)")
+            (concat "\\(?:\\(?:" sql-prompt-regexp "\\)"
+                    "\\|\\(?:" sql-prompt-cont-regexp "\\)\\)")
           sql-prompt-regexp))
-  (setq left-margin sql-prompt-length)
+  (setq left-margin (or sql-prompt-length 0))
   ;; Install input sender
-  (set (make-local-variable 'comint-input-sender) 'sql-input-sender)
+  (set (make-local-variable 'comint-input-sender) #'sql-input-sender)
   ;; People wanting a different history file for each
   ;; buffer/process/client/whatever can change separator and file-name
   ;; on the sql-interactive-mode-hook.
@@ -4264,8 +4456,7 @@ Sentinels will always get the two parameters PROCESS and 
EVENT."
   "Read a connection name."
   (let ((completion-ignore-case t))
     (completing-read prompt
-                     (mapcar (lambda (c) (car c))
-                             sql-connection-alist)
+                     (mapcar #'car sql-connection-alist)
                      nil t initial 'sql-connection-history default)))
 
 ;;;###autoload
@@ -4476,6 +4667,10 @@ the call to \\[sql-product-interactive] with
                                     (or sql-default-directory
                                         default-directory)))
 
+                ;; The password wallet returns a function which supplies the 
password.
+                (when (functionp sql-password)
+                  (setq sql-password (funcall sql-password)))
+
                 ;; Call the COMINT service
                 (funcall (sql-get-product-feature product :sqli-comint-func)
                          product
@@ -4489,13 +4684,13 @@ the call to \\[sql-product-interactive] with
                             (read-string
                              "Buffer name (\"*SQL: XXX*\"; enter `XXX'): "
                              (sql-make-alternate-buffer-name product))))
-                          ((or (string-prefix-p " " new-name)
-                               (string-match-p "\\`[*].*[*]\\'" new-name))
-                           new-name)
                           ((stringp new-name)
-                           (sql-generate-unique-sqli-buffer-name product 
new-name))
+                           (if (or (string-prefix-p " " new-name)
+                                   (string-match-p "\\`[*].*[*]\\'" new-name))
+                               new-name
+                             (sql-generate-unique-sqli-buffer-name product 
new-name)))
                           (t
-                           (sql-generate-unique-sqli-buffer-name product 
nil)))))
+                           (sql-generate-unique-sqli-buffer-name product 
new-name)))))
 
               ;; Set SQLi mode.
               (let ((sql-interactive-product product))
@@ -4518,7 +4713,8 @@ the call to \\[sql-product-interactive] with
               (let ((proc (get-buffer-process new-sqli-buffer))
                     (secs sql-login-delay)
                     (step 0.3))
-                (while (and (memq (process-status proc) '(open run))
+                (while (and proc
+                            (memq (process-status proc) '(open run))
                             (or (accept-process-output proc step)
                                 (<= 0.0 (setq secs (- secs step))))
                             (progn (goto-char (point-max))
@@ -5222,8 +5418,7 @@ The default comes from `process-coding-system-alist' and
 your might try undecided-dos as a coding system.  If this doesn't help,
 Try to set `comint-output-filter-functions' like this:
 
-\(setq comint-output-filter-functions (append comint-output-filter-functions
-                                            \\='(comint-strip-ctrl-m)))
+\(add-hook 'comint-output-filter-functions #\\='comint-strip-ctrl-m 'append)
 
 \(Type \\[describe-mode] in the SQL buffer for a list of commands.)"
   (interactive "P")
diff --git a/lisp/progmodes/subword.el b/lisp/progmodes/subword.el
index d5346d3..58a266c 100644
--- a/lisp/progmodes/subword.el
+++ b/lisp/progmodes/subword.el
@@ -1,6 +1,6 @@
 ;;; subword.el --- Handling capitalized subwords in a nomenclature -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Masatake YAMATO
 
diff --git a/lisp/progmodes/tcl.el b/lisp/progmodes/tcl.el
index 586d8cc..ffb3d41 100644
--- a/lisp/progmodes/tcl.el
+++ b/lisp/progmodes/tcl.el
@@ -1,6 +1,6 @@
 ;;; tcl.el --- Tcl code editing commands for Emacs
 
-;; Copyright (C) 1994, 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1998-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Author: Tom Tromey <address@hidden>
diff --git a/lisp/progmodes/vera-mode.el b/lisp/progmodes/vera-mode.el
index 6c40dc7..a03556e 100644
--- a/lisp/progmodes/vera-mode.el
+++ b/lisp/progmodes/vera-mode.el
@@ -1,6 +1,6 @@
 ;;; vera-mode.el --- major mode for editing Vera files
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
 ;; Author:      Reto Zimmermann <address@hidden>
 ;; Maintainer:  Reto Zimmermann <address@hidden>
diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el
index 509a1a2..e75e584 100644
--- a/lisp/progmodes/verilog-mode.el
+++ b/lisp/progmodes/verilog-mode.el
@@ -1,6 +1,6 @@
 ;;; verilog-mode.el --- major mode for editing verilog source in Emacs
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael McNamara <address@hidden>
 ;;    Wilson Snyder <address@hidden>
@@ -121,7 +121,7 @@
 ;;
 
 ;; This variable will always hold the version number of the mode
-(defconst verilog-mode-version "2018-11-26-bb3814b-vpo-GNU"
+(defconst verilog-mode-version "2019-04-02-5d62d3f-vpo-GNU"
   "Version of this Verilog mode.")
 (defconst verilog-mode-release-emacs t
   "If non-nil, this version of Verilog mode was released with Emacs itself.")
@@ -1285,6 +1285,13 @@ See the \\[verilog-faq] for examples on using this."
   :type '(choice (const nil) regexp))
 (put 'verilog-auto-input-ignore-regexp 'safe-local-variable 'stringp)
 
+(defcustom verilog-auto-reg-input-assigned-ignore-regexp nil
+  "If non-nil, when creating AUTOINPUTREG, ignore signals matching this 
regexp."
+  :version "27.1"
+  :group 'verilog-mode-auto
+  :type '(choice (const nil) regexp))
+(put 'verilog-auto-reg-input-assigned-ignore-regexp 'safe-local-variable 
'stringp)
+
 (defcustom verilog-auto-inout-ignore-regexp nil
   "If non-nil, when creating AUTOINOUT, ignore signals matching this regexp.
 See the \\[verilog-faq] for examples on using this."
@@ -2053,7 +2060,7 @@ find the errors."
       "`resetall" "`timescale" "`unconnected_drive" "`undef" "`undefineall"
       ;; compiler directives not covered by IEEE 1800
       "`case" "`default" "`endfor" "`endprotect" "`endswitch" "`endwhile" 
"`for"
-      "`format" "`if" "`let" "`protect" "`switch" "`timescale" "`time_scale"
+      "`format" "`if" "`let" "`protect" "`switch" "`time_scale"
       "`while"
       ))
   "List of Verilog compiler directives.")
@@ -2144,14 +2151,7 @@ find the errors."
        ) nil ) ) )
 
 (defconst verilog-vmm-statement-re
-  (eval-when-compile
-    (verilog-regexp-opt
-     '(
-       
"`vmm_\\(data\\|env\\|scenario\\|subenv\\|xactor\\)_member_\\(scalar\\|string\\|enum\\|vmm_data\\|channel\\|xactor\\|subenv\\|user_defined\\)\\(_array\\)?"
-       ;; "`vmm_xactor_member_enum_array"
-       ;; "`vmm_xactor_member_scalar_array"
-       ;; "`vmm_xactor_member_scalar"
-       ) nil )))
+  
"`vmm_\\(data\\|env\\|scenario\\|subenv\\|xactor\\)_member_\\(scalar\\|string\\|enum\\|vmm_data\\|channel\\|xactor\\|subenv\\|user_defined\\)\\(_array\\)?")
 
 (defconst verilog-ovm-statement-re
   (eval-when-compile
@@ -2414,9 +2414,7 @@ find the errors."
      '(
        ;; blocking assignment_operator
        "=" "+=" "-=" "*=" "/=" "%=" "&=" "|=" "^=" "<<=" ">>=" "<<<=" ">>>="
-       ;; non blocking assignment operator
-       "<="
-       ;; comparison
+       ;; comparison (also nonblocking assignment "<=")
        "==" "!=" "===" "!==" "<=" ">=" "==?" "!=?" "<->"
        ;; event_trigger
        "->" "->>"
@@ -2763,12 +2761,12 @@ find the errors."
 (defconst verilog-declaration-re-2-no-macro
   (concat "\\s-*" verilog-declaration-re
          "\\s-*\\(\\(" verilog-optional-signed-range-re "\\)\\|\\(" 
verilog-delay-re "\\)"
-         "\\)?"))
+         "\\)"))
 (defconst verilog-declaration-re-2-macro
   (concat "\\s-*" verilog-declaration-re
          "\\s-*\\(\\(" verilog-optional-signed-range-re "\\)\\|\\(" 
verilog-delay-re "\\)"
          "\\|\\(" verilog-macroexp-re "\\)"
-         "\\)?"))
+         "\\)"))
 (defconst verilog-declaration-re-1-macro
   (concat "^" verilog-declaration-re-2-macro))
 
@@ -2786,7 +2784,7 @@ find the errors."
 (defconst verilog-behavioral-block-beg-re
   (eval-when-compile (verilog-regexp-words '("initial" "final" "always" 
"always_comb" "always_latch" "always_ff"
                                              "function" "task"))))
-(defconst verilog-coverpoint-re 
"\\w+\\s*:\\s*\\(coverpoint\\|cross\\constraint\\)"  )
+(defconst verilog-coverpoint-re 
"\\w+\\s-*:\\s-*\\(coverpoint\\|cross\\|constraint\\)")
 (defconst verilog-in-constraint-re  ; keywords legal in constraint blocks 
starting a statement/block
   (eval-when-compile (verilog-regexp-words '("if" "else" "solve" "foreach"))))
 
@@ -2973,9 +2971,10 @@ find the errors."
      "\\<\\(`pragma\\)\\>\\s-+.+$"
      "\\)\\|\\(?:"
      ;; `timescale time_unit / time_precision
-     
"\\<\\(`timescale\\)\\>\\s-+10\\{0,2\\}\\s-*[munpf]?s\\s-*\\/\\s-*10\\{0,2\\}\\s-*[munpf]?s"
+     
"\\<\\(`timescale\\)\\>\\s-+10\\{0,2\\}\\s-*[munpf]?s\\s-*/\\s-*10\\{0,2\\}\\s-*[munpf]?s"
      "\\)\\|\\(?:"
-     ;; `define and `if can span multiple lines if line ends in '\'. NOTE: `if 
is not IEEE 1800-2012
+     ;; `define and `if can span multiple lines if line ends in '\'.
+     ;; NOTE: `if is not IEEE 1800-2012.
      ;; from http://www.emacswiki.org/emacs/MultilineRegexp
      (concat "\\<\\(`define\\|`if\\)\\>"  ; directive
              "\\s-+"  ; separator
@@ -6558,9 +6557,9 @@ Return >0 for nested struct."
                (t nil))))
     (skip-chars-forward " \t\n\f")
     (while
-       (cond
-        ((looking-at "\\/\\*")
-         (progn
+        (cond
+         ((looking-at "/\\*")
+          (progn
            (setq h (point))
            (goto-char (match-end 0))
            (if (search-forward "*/" nil t)
@@ -8515,21 +8514,23 @@ Return an array of [outputs inouts inputs wire reg 
assign const]."
          (forward-char 1)
          (when (< paren sig-paren)
            (setq expect-signal nil rvalue nil)))   ; ) that ends variables 
inside v2k arg list
-        ((looking-at "\\s-*\\(\\[[^]]+\\]\\)")
-         (goto-char (match-end 0))
+        ((looking-at "\\[")
+          (setq keywd (buffer-substring-no-properties
+                       (point)
+                       (progn (forward-sexp 1) (point))))
          (cond (newsig ; Memory, not just width.  Patch last signal added's 
memory (nth 3)
                 (setcar (cdr (cdr (cdr newsig)))
                         (if (verilog-sig-memory newsig)
                              (concat (verilog-sig-memory newsig)
-                                     (match-string-no-properties 1))
-                          (match-string-no-properties 1))))
+                                     keywd)
+                          keywd)))
                 (vec  ; Multidimensional
                 (setq multidim (cons vec multidim))
                 (setq vec (verilog-string-replace-matches
-                           "\\s-+" "" nil nil (match-string-no-properties 1))))
+                           "\\s-+" "" nil nil keywd)))
                 (t  ; Bit width
                 (setq vec (verilog-string-replace-matches
-                           "\\s-+" "" nil nil (match-string-no-properties 
1))))))
+                           "\\s-+" "" nil nil keywd)))))
         ;; Normal or escaped identifier -- note we remember the \ if escaped
         ((looking-at "\\s-*\\([a-zA-Z0-9`_$]+\\|\\\\[^ \t\n\f]+\\)")
          (goto-char (match-end 0))
@@ -8950,10 +8951,10 @@ Inserts the list of signals found."
               (forward-char 1)
               (or (search-forward "*)")
                   (error "%s: Unmatched (* *), at char %d" 
(verilog-point-text) (point))))
-             ;; On pins, parse and advance to next pin
-             ;; Looking at pin, but *not* an // Output comment, or ) to end 
the inst
-             ((looking-at "\\s-*[a-zA-Z0-9`_$({}\\\\][^,]*")
-              (goto-char (match-end 0))
+              ;; On pins, parse and advance to next pin
+              ;; Looking at pin, but *not* an // Output comment, or ) to end 
the inst
+              ((looking-at "\\s-*[a-zA-Z0-9`_$({}\\][^,]*")
+               (goto-char (match-end 0))
               (setq verilog-read-sub-decls-gate-ios (or (car iolist) "input")
                     iolist (cdr iolist))
               (verilog-read-sub-decls-expr
@@ -9354,10 +9355,10 @@ Returns REGEXP and list of ( (signal_name 
connection_name)... )."
                            templateno lineno)
                           tpl-sig-list))
               (goto-char (match-end 0)))
-             ;; Regexp form??
-             ((looking-at
-               ;; Regexp bug in XEmacs disallows ][ inside [], and wants + last
-               
"\\s-*\\.\\(\\(address@hidden|---]\\|[][]\\|\\\\[()|]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")
+              ;; Regexp form??
+              ((looking-at
+                ;; Regexp bug in XEmacs disallows ][ inside [], and wants + 
last
+                
"\\s-*\\.\\(\\(address@hidden|]\\|[][]\\|\\\\[()|0-9]\\)+\\)\\s-*(\\(.*\\))\\s-*\\(,\\|)\\s-*;\\)")
               (setq rep (match-string-no-properties 3))
               (goto-char (match-end 0))
               (setq tpl-wild-list
@@ -10492,7 +10493,7 @@ Presumes that any newlines end a list element."
                      (looking-at "[(,]")))
                (not (save-excursion  ; Not `endif, or user define
                      (backward-char 1)
-                     (skip-chars-backward "[a-zA-Z0-9_`]")
+                     (skip-chars-backward "a-zA-Z0-9_`")
                      (looking-at "`"))))
       (insert ","))))
 
@@ -10809,7 +10810,7 @@ Intended for internal use inside a 
`verilog-save-font-no-change-functions' block
                              'verilog-delete-auto-star-all)
   ;; Remove template comments ... anywhere in case was pasted after AUTOINST 
removed
   (goto-char (point-min))
-  (while (re-search-forward "\\s-*// \\(Templated\\|Implicit \\.\\*\\)\\([ 
\tLT0-9]*\\| LHS: .*\\)?$" nil t)
+  (while (re-search-forward "\\s-*// \\(Templated\\|Implicit \\.\\*\\)\\([ 
\tLT0-9]*\\| LHS: .*\\)$" nil t)
     (replace-match ""))
 
   ;; Final customize
@@ -11411,7 +11412,7 @@ If PAR-VALUES replace final strings with these 
parameter values."
     (when tpl-ass
       ;; Evaluate @"(lispcode)"
       (when (string-match "@\".*[^\\]\"" tpl-net)
-       (while (string-match "@\"\\(\\([^\\\"]*\\(\\\\.\\)*\\)*\\)\"" tpl-net)
+       (while (string-match "@\"\\(\\([^\\\"]\\|\\\\.\\)*\\)\"" tpl-net)
          (setq tpl-net
                (concat
                 (substring tpl-net 0 (match-beginning 0))
@@ -12078,15 +12079,18 @@ Typing \\[verilog-auto] will make this into:
 
 (defun verilog-auto-reg-input ()
   "Expand AUTOREGINPUT statements, as part of \\[verilog-auto].
-Make reg statements instantiation inputs that aren't already declared.
-This is useful for making a top level shell for testing the module that is
-to be instantiated.
+Make reg statements instantiation inputs that aren't already
+declared or assigned to.  This is useful for making a top level
+shell for testing the module that is to be instantiated.
 
 Limitations:
   This ONLY detects inputs of AUTOINSTants (see `verilog-read-sub-decls').
 
   This does NOT work on memories, declare those yourself.
 
+  Assignments cause the assigned-to variable not to be declared unless
+  the name matches `verilog-auto-reg-input-assigned-ignore-regexp'.
+
 An example (see `verilog-auto-inst' for what else is going on here):
 
        module ExampRegInput (o,i);
@@ -12124,7 +12128,9 @@ Typing \\[verilog-auto] will make this into:
                       (append (verilog-subdecls-get-inputs modsubdecls)
                               (verilog-subdecls-get-inouts modsubdecls))
                       (append (verilog-decls-get-signals moddecls)
-                              (verilog-decls-get-assigns moddecls))))))
+                               (verilog-signals-not-matching-regexp
+                                (verilog-decls-get-assigns moddecls)
+                                
verilog-auto-reg-input-assigned-ignore-regexp))))))
       (when sig-list
        (verilog-forward-or-insert-line)
        (verilog-insert-indent "// Beginning of automatic reg inputs (for 
undeclared instantiated-module inputs)\n")
@@ -14257,13 +14263,13 @@ and the case items."
 (defun verilog-sk-define-signal ()
   "Insert a definition of signal under point at top of module."
   (interactive "*")
-  (let* ((sig-re "[a-zA-Z0-9_]*")
+  (let* ((sig-chars "a-zA-Z0-9_")
         (v1 (buffer-substring
               (save-excursion
-                (skip-chars-backward sig-re)
+                (skip-chars-backward sig-chars)
                 (point))
               (save-excursion
-                (skip-chars-forward sig-re)
+                (skip-chars-forward sig-chars)
                 (point)))))
     (if (not (member v1 verilog-keywords))
        (save-excursion
diff --git a/lisp/progmodes/vhdl-mode.el b/lisp/progmodes/vhdl-mode.el
index e17b7f5..13d0cfa 100644
--- a/lisp/progmodes/vhdl-mode.el
+++ b/lisp/progmodes/vhdl-mode.el
@@ -1,6 +1,6 @@
 ;;; vhdl-mode.el --- major mode for editing VHDL code
 
-;; Copyright (C) 1992-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992-2019 Free Software Foundation, Inc.
 
 ;; Authors:     Reto Zimmermann <address@hidden>
 ;;              Rodney J. Whitby <address@hidden>
@@ -2474,7 +2474,7 @@ specified."
 
 (defun vhdl-resolve-env-variable (string)
   "Resolve environment variables in STRING."
-  (while (string-match "\\(.*\\)${?\\(\\(\\w\\|_\\)+\\)}?\\(.*\\)" string)
+  (while (string-match "\\(.*\\)\\${?\\(\\(\\w\\|_\\)+\\)}?\\(.*\\)" string)
     (setq string (concat (match-string 1 string)
                         (getenv (match-string 2 string))
                         (match-string 4 string))))
@@ -6699,7 +6699,7 @@ search, and an argument indicating an interactive call."
     (if (and interactive
             (or (nth 3 state)
                 (nth 4 state)
-                (looking-at (concat "[ \t]*" comment-start-skip))))
+                (looking-at (concat "[ \t]*\\(?:" comment-start-skip "\\)"))))
        (forward-sentence (- count))
       (while (> count 0)
        (vhdl-beginning-of-statement-1 lim)
@@ -7392,8 +7392,8 @@ only-lines."
 (defun vhdl-update-progress-info (string pos)
   "Update progress information."
   (when (and vhdl-progress-info (not noninteractive)
-            (< vhdl-progress-interval
-               (- (nth 1 (current-time)) (aref vhdl-progress-info 2))))
+            (time-less-p vhdl-progress-interval
+                         (time-since (aref vhdl-progress-info 2))))
     (let ((delta (- (aref vhdl-progress-info 1)
                     (aref vhdl-progress-info 0))))
       (message "%s... (%2d%%)" string
@@ -7401,7 +7401,7 @@ only-lines."
                   100
                  (floor (* 100.0 (- pos (aref vhdl-progress-info 0)))
                         delta))))
-    (aset vhdl-progress-info 2 (nth 1 (current-time)))))
+    (aset vhdl-progress-info 2 (encode-time nil 'integer))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Indentation commands
@@ -8142,12 +8142,12 @@ depending on parameter UPPER-CASE."
                 (upcase-word -1)
               (downcase-word -1)))
         (when (and count vhdl-progress-interval (not noninteractive)
-                   (< vhdl-progress-interval
-                      (- (nth 1 (current-time)) last-update)))
+                   (time-less-p vhdl-progress-interval
+                                (time-since last-update)))
           (message "Fixing case... (%2d%s)"
                    (+ (* count 20) (/ (* 20 (- (point) beg)) (- end beg)))
                    "%")
-          (setq last-update (nth 1 (current-time)))))
+          (setq last-update (encode-time nil 'integer))))
        (goto-char end)))))
 
 (defun vhdl-fix-case-region (beg end &optional arg)
@@ -15115,7 +15115,7 @@ otherwise use cached data."
 (defun vhdl-speedbar-expand-project (text token indent)
   "Expand/contract the project under the cursor."
   (cond
-   ((string-match "+" text)            ; expand project
+   ((string-match "\\+" text)          ; expand project
     (speedbar-change-expand-button-char ?-)
     (unless (member token vhdl-speedbar-shown-project-list)
       (setq vhdl-speedbar-shown-project-list
@@ -15137,7 +15137,7 @@ otherwise use cached data."
 (defun vhdl-speedbar-expand-entity (text token indent)
   "Expand/contract the entity under the cursor."
   (cond
-   ((string-match "+" text)            ; expand entity
+   ((string-match "\\+" text)          ; expand entity
     (let* ((key (vhdl-speedbar-line-key indent))
           (ent-alist (vhdl-aget vhdl-entity-alist key))
           (ent-entry (vhdl-aget ent-alist token))
@@ -15206,7 +15206,7 @@ otherwise use cached data."
 (defun vhdl-speedbar-expand-architecture (text token indent)
   "Expand/contract the architecture under the cursor."
   (cond
-   ((string-match "+" text)            ; expand architecture
+   ((string-match "\\+" text)          ; expand architecture
     (let* ((key (vhdl-speedbar-line-key (1- indent)))
           (ent-alist (vhdl-aget vhdl-entity-alist key))
           (conf-alist (vhdl-aget vhdl-config-alist key))
@@ -15266,7 +15266,7 @@ otherwise use cached data."
 (defun vhdl-speedbar-expand-config (text token indent)
   "Expand/contract the configuration under the cursor."
   (cond
-   ((string-match "+" text)            ; expand configuration
+   ((string-match "\\+" text)          ; expand configuration
     (let* ((key (vhdl-speedbar-line-key indent))
           (conf-alist (vhdl-aget vhdl-config-alist key))
           (conf-entry (vhdl-aget conf-alist token))
@@ -15324,7 +15324,7 @@ otherwise use cached data."
 (defun vhdl-speedbar-expand-package (text token indent)
   "Expand/contract the package under the cursor."
   (cond
-   ((string-match "+" text)            ; expand package
+   ((string-match "\\+" text)          ; expand package
     (let* ((key (vhdl-speedbar-line-key indent))
           (pack-alist (vhdl-aget vhdl-package-alist key))
           (pack-entry (vhdl-aget pack-alist token))
@@ -15729,7 +15729,7 @@ NO-POSITION non-nil means do not re-position cursor."
 
 (defun vhdl-speedbar-dired (text token indent)
   "Speedbar click handler for directory expand button in hierarchy mode."
-  (cond ((string-match "+" text)       ; we have to expand this dir
+  (cond ((string-match "\\+" text)     ; we have to expand this dir
         (setq speedbar-shown-directories
               (cons (expand-file-name
                      (concat (speedbar-line-directory indent) token "/"))
diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el
index 7604be0..564e0ff 100644
--- a/lisp/progmodes/which-func.el
+++ b/lisp/progmodes/which-func.el
@@ -1,6 +1,6 @@
 ;;; which-func.el --- print current function in mode line  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1994, 1997-1998, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1994, 1997-1998, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author:   Alex Rezinsky <address@hidden>
@@ -272,16 +272,21 @@ It calls them sequentially, and if any returns non-nil,
 
 (defun which-function ()
   "Return current function name based on point.
-Uses `which-func-functions', `imenu--index-alist'
-or `add-log-current-defun'.
+Uses `which-func-functions', `add-log-current-defun'.
+or `imenu--index-alist'
 If no function name is found, return nil."
   (let ((name
         ;; Try the `which-func-functions' functions first.
         (run-hook-with-args-until-success 'which-func-functions)))
-
+    ;; Try using add-log support.
+    (when (null name)
+      (setq name (add-log-current-defun)))
     ;; If Imenu is loaded, try to make an index alist with it.
     (when (and (null name)
-              (boundp 'imenu--index-alist) (null imenu--index-alist)
+              (boundp 'imenu--index-alist)
+               (or (null imenu--index-alist)
+                   ;; Update if outdated
+                   (/= (buffer-chars-modified-tick) 
imenu-menubar-modified-tick))
               (null which-function-imenu-failed))
       (ignore-errors (imenu--make-index-alist t))
       (unless imenu--index-alist
@@ -323,10 +328,6 @@ If no function name is found, return nil."
                              (funcall
                               which-func-imenu-joiner-function
                               (reverse (cons (car pair) namestack))))))))))))
-
-    ;; Try using add-log support.
-    (when (null name)
-      (setq name (add-log-current-defun)))
     ;; Filter the name if requested.
     (when name
       (if which-func-cleanup-function
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 3b449bf..e5e5972 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -1,6 +1,6 @@
 ;; xref.el --- Cross-referencing commands              -*-lexical-binding:t-*-
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -71,9 +71,6 @@
 (require 'ring)
 (require 'project)
 
-(eval-when-compile
-  (require 'semantic/symref)) ;; for hit-lines slot
-
 (defgroup xref nil "Cross-referencing commands"
   :version "25.1"
   :group 'tools)
@@ -451,6 +448,18 @@ If SELECT is non-nil, select the target window."
 (defconst xref-buffer-name "*xref*"
   "The name of the buffer to show xrefs.")
 
+(defface xref-file-header '((t :inherit compilation-info))
+  "Face used to highlight file header in the xref buffer."
+  :version "27.1")
+
+(defface xref-line-number '((t :inherit compilation-line-number))
+  "Face for displaying line numbers in the xref buffer."
+  :version "27.1")
+
+(defface xref-match '((t :inherit highlight))
+  "Face used to highlight matches in the xref buffer."
+  :version "27.1")
+
 (defmacro xref--with-dedicated-window (&rest body)
   `(let* ((xref-w (get-buffer-window xref-buffer-name))
           (xref-w-dedicated (window-dedicated-p xref-w)))
@@ -477,27 +486,17 @@ and finally return the window."
           (or (eq xref--original-window-intent 'frame)
               pop-up-frames))
          (action
-          (cond ((memq
-                  xref--original-window-intent
-                  '(window frame))
+          (cond ((eq xref--original-window-intent 'frame)
                  t)
+                ((eq xref--original-window-intent 'window)
+                 '(display-buffer-same-window))
                 ((and
                   (window-live-p xref--original-window)
                   (or (not (window-dedicated-p xref--original-window))
                       (eq (window-buffer xref--original-window) buf)))
-                 `(,(lambda (buf _alist)
-                      (set-window-buffer xref--original-window buf)
-                      xref--original-window))))))
-    (with-selected-window
-        (with-selected-window
-            ;; Just before `display-buffer', place ourselves in the
-            ;; original window to suggest preserving it. Of course, if
-            ;; user has deleted the original window, all bets are off,
-            ;; just use the selected one.
-            (or (and (window-live-p xref--original-window)
-                     xref--original-window)
-                (selected-window))
-          (display-buffer buf action))
+                 `((display-buffer-in-previous-window)
+                   (previous-window . ,xref--original-window))))))
+    (with-selected-window (display-buffer buf action)
       (xref--goto-char pos)
       (run-hooks 'xref-after-jump-hook)
       (let ((buf (current-buffer)))
@@ -554,9 +553,10 @@ SELECT is `quit', also quit the *xref* window."
 Non-interactively, non-nil QUIT means to first quit the *xref*
 buffer."
   (interactive)
-  (let ((buffer (current-buffer))
-        (xref (or (xref--item-at-point)
-                  (user-error "No reference at point"))))
+  (let* ((buffer (current-buffer))
+         (xref (or (xref--item-at-point)
+                   (user-error "No reference at point")))
+         (xref--current-item xref))
     (xref--show-location (xref-item-location xref) (if quit 'quit t))
     (next-error-found buffer (current-buffer))))
 
@@ -706,8 +706,10 @@ references displayed in the current *xref* buffer."
   (let ((backward (< n 0))
         (n (abs n))
         (xref nil))
-    (dotimes (_ n)
-      (setq xref (xref--search-property 'xref-item backward)))
+    (if (= n 0)
+        (setq xref (get-text-property (point) 'xref-item))
+      (dotimes (_ n)
+        (setq xref (xref--search-property 'xref-item backward))))
     (cond (xref
            ;; Save the current position (when the buffer is visible,
            ;; it gets reset to that window's point from time to time).
@@ -747,18 +749,17 @@ GROUP is a string for decoration purposes and XREF is an
            for line-format = (and max-line-width
                                   (format "%%%dd: " max-line-width))
            do
-           (xref--insert-propertized '(face compilation-info) group "\n")
+           (xref--insert-propertized '(face xref-file-header) group "\n")
            (cl-loop for (xref . more2) on xrefs do
                     (with-slots (summary location) xref
                       (let* ((line (xref-location-line location))
                              (prefix
                               (if line
                                   (propertize (format line-format line)
-                                              'face 'compilation-line-number)
+                                              'face 'xref-line-number)
                                 "  ")))
                         (xref--insert-propertized
                          (list 'xref-item xref
-                               ;; 'face 'font-lock-keyword-face
                                'mouse-face 'highlight
                                'keymap xref--button-map
                                'help-echo
@@ -807,6 +808,7 @@ Return an alist of the form ((FILENAME . (XREF ...)) ...)."
 (defvar xref--read-pattern-history nil)
 
 (defun xref--show-xrefs (xrefs display-action &optional always-show-list)
+  (unless (region-active-p) (push-mark nil t))
   (cond
    ((and (not (cdr xrefs)) (not always-show-list))
     (xref-push-marker-stack)
@@ -1168,7 +1170,7 @@ Such as the current syntax table and the applied syntax 
properties."
              (end-column (- (match-end 0) line-beg))
              (loc (xref-make-file-location file line beg-column))
              (summary (buffer-substring line-beg line-end)))
-        (add-face-text-property beg-column end-column 'highlight
+        (add-face-text-property beg-column end-column 'xref-match
                                 t summary)
         (push (xref-make-match summary loc (- end-column beg-column))
               matches)))
diff --git a/lisp/progmodes/xscheme.el b/lisp/progmodes/xscheme.el
index fa14e44..62c42d3 100644
--- a/lisp/progmodes/xscheme.el
+++ b/lisp/progmodes/xscheme.el
@@ -1,6 +1,6 @@
 ;;; xscheme.el --- run MIT Scheme under Emacs        -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 1986-1987, 1989-1990, 2001-2018 Free Software
+;; Copyright (C) 1986-1987, 1989-1990, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/ps-bdf.el b/lisp/ps-bdf.el
index f9632f0..be80b4a 100644
--- a/lisp/ps-bdf.el
+++ b/lisp/ps-bdf.el
@@ -1,6 +1,6 @@
 ;;; ps-bdf.el --- BDF font file handler for ps-print
 
-;; Copyright (C) 1998-1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-1999, 2001-2019 Free Software Foundation, Inc.
 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
 ;;   2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/lisp/ps-def.el b/lisp/ps-def.el
index d0cd762..2063133 100644
--- a/lisp/ps-def.el
+++ b/lisp/ps-def.el
@@ -1,6 +1,6 @@
 ;;; ps-def.el --- XEmacs and Emacs definitions for ps-print -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Vinicius Jose Latorre <address@hidden>
 ;;     Kenichi Handa <address@hidden> (multi-byte characters)
diff --git a/lisp/ps-mule.el b/lisp/ps-mule.el
index 2658aec..c88d6d2 100644
--- a/lisp/ps-mule.el
+++ b/lisp/ps-mule.el
@@ -1,6 +1,6 @@
 ;;; ps-mule.el --- provide multi-byte character facility to ps-print
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Vinicius Jose Latorre <address@hidden>
 ;;     Kenichi Handa <address@hidden> (multi-byte characters)
diff --git a/lisp/ps-print.el b/lisp/ps-print.el
index 7dd1103..647597c 100644
--- a/lisp/ps-print.el
+++ b/lisp/ps-print.el
@@ -1,6 +1,6 @@
 ;;; ps-print.el --- print text from the buffer as PostScript -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1993-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-2019 Free Software Foundation, Inc.
 
 ;; Author: Jim Thompson (was <address@hidden>)
 ;;     Jacques Duthen (was <address@hidden>)
diff --git a/lisp/ps-samp.el b/lisp/ps-samp.el
index bd5fff8..784b435 100644
--- a/lisp/ps-samp.el
+++ b/lisp/ps-samp.el
@@ -1,6 +1,6 @@
 ;;; ps-samp.el --- ps-print sample setup code
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Jim Thompson (was <address@hidden>)
 ;;     Jacques Duthen (was <address@hidden>)
@@ -76,8 +76,8 @@
       (concat "Subject: " (or (mail-fetch-field "Subject") "???")))))
 
 ;; Look in an article or mail message for the From: line.  Sorta-kinda
-;; understands RFC-822 addresses and can pull the real name out where
-;; it's provided.
+;; understands RFC 822 (or later) addresses and can pull the real name
+;; out where it's provided.
 (defun ps-article-author ()
   (save-excursion
     (save-restriction
diff --git a/lisp/recentf.el b/lisp/recentf.el
index e318486..9b70017 100644
--- a/lisp/recentf.el
+++ b/lisp/recentf.el
@@ -1,6 +1,6 @@
 ;;; recentf.el --- setup a menu of recently opened files
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: David Ponce <address@hidden>
 ;; Created: July 19 1999
diff --git a/lisp/rect.el b/lisp/rect.el
index 6b6906a..1790753 100644
--- a/lisp/rect.el
+++ b/lisp/rect.el
@@ -1,6 +1,6 @@
 ;;; rect.el --- rectangle functions for GNU Emacs  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1985, 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1999-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: Didier Verna <address@hidden>
 ;; Keywords: internal
diff --git a/lisp/register.el b/lisp/register.el
index e25f9fd..775e1a2 100644
--- a/lisp/register.el
+++ b/lisp/register.el
@@ -1,6 +1,6 @@
 ;;; register.el --- register commands for Emacs      -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 1985, 1993-1994, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1985, 1993-1994, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/registry.el b/lisp/registry.el
index c3184a8..8e2005b 100644
--- a/lisp/registry.el
+++ b/lisp/registry.el
@@ -1,6 +1,6 @@
 ;;; registry.el --- Track and remember data items by various fields
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Teodor Zlatanov <address@hidden>
 ;; Keywords: data
diff --git a/lisp/repeat.el b/lisp/repeat.el
index 578034f..8d902d9 100644
--- a/lisp/repeat.el
+++ b/lisp/repeat.el
@@ -1,6 +1,6 @@
 ;;; repeat.el --- convenient way to repeat the previous command  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Will Mengarini <address@hidden>
 ;; Created: Mo 02 Mar 98
diff --git a/lisp/replace.el b/lisp/replace.el
index ecb4793..9d1b7bf 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1,6 +1,6 @@
 ;;; replace.el --- replace commands for Emacs -*- lexical-binding: t -*-
 
-;; Copyright (C) 1985-1987, 1992, 1994, 1996-1997, 2000-2018 Free
+;; Copyright (C) 1985-1987, 1992, 1994, 1996-1997, 2000-2019 Free
 ;; Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
@@ -850,7 +850,6 @@ If nil, uses `regexp-history'."
 (defalias 'delete-matching-lines 'flush-lines)
 (defalias 'count-matches 'how-many)
 
-
 (defun keep-lines-read-args (prompt)
   "Read arguments for `keep-lines' and friends.
 Prompt for a regexp with PROMPT.
@@ -930,9 +929,8 @@ a previously found match."
   (set-marker rend nil)
   nil)
 
-
 (defun flush-lines (regexp &optional rstart rend interactive)
- "Delete lines containing matches for REGEXP.
+  "Delete lines containing matches for REGEXP.
 When called from Lisp (and usually when called interactively as
 well, see below), applies to the part of the buffer after point.
 The line point is in is deleted if and only if it contains a
@@ -953,7 +951,10 @@ a non-nil INTERACTIVE argument.
 
 If a match is split across lines, all the lines it lies in are deleted.
 They are deleted _before_ looking for the next match.  Hence, a match
-starting on the same line at which another match ended is ignored."
+starting on the same line at which another match ended is ignored.
+
+Return the number of deleted matching lines.  When called interactively,
+also print the number."
   (interactive
    (progn
      (barf-if-buffer-read-only)
@@ -968,7 +969,8 @@ starting on the same line at which another match ended is 
ignored."
       (setq rstart (point)
            rend (point-max-marker)))
     (goto-char rstart))
-  (let ((case-fold-search
+  (let ((count 0)
+        (case-fold-search
         (if (and case-fold-search search-upper-case)
             (isearch-no-upper-case-p regexp t)
           case-fold-search)))
@@ -978,10 +980,14 @@ starting on the same line at which another match ended is 
ignored."
        (delete-region (save-excursion (goto-char (match-beginning 0))
                                       (forward-line 0)
                                       (point))
-                      (progn (forward-line 1) (point))))))
-  (set-marker rend nil)
-  nil)
-
+                      (progn (forward-line 1) (point)))
+        (setq count (1+ count))))
+    (set-marker rend nil)
+    (when interactive (message (ngettext "Deleted %d matching line"
+                                        "Deleted %d matching lines"
+                                        count)
+                              count))
+    count))
 
 (defun how-many (regexp &optional rstart rend interactive)
   "Print and return number of matches for REGEXP following point.
@@ -1029,9 +1035,10 @@ a previously found match."
        (if (= opoint (point))
            (forward-char 1)
          (setq count (1+ count))))
-      (when interactive (message "%d occurrence%s"
-                                count
-                                (if (= count 1) "" "s")))
+      (when interactive (message (ngettext "%d occurrence"
+                                          "%d occurrences"
+                                          count)
+                                count))
       count)))
 
 
@@ -1614,11 +1621,12 @@ See also `multi-occur'."
                  (not (eq occur-excluded-properties t))))))
          (let* ((bufcount (length active-bufs))
                 (diff (- (length bufs) bufcount)))
-           (message "Searched %d buffer%s%s; %s match%s%s"
-                    bufcount (if (= bufcount 1) "" "s")
+           (message "Searched %d %s%s; %s %s%s"
+                    bufcount
+                    (ngettext "buffer" "buffers" bufcount)
                     (if (zerop diff) "" (format " (%d killed)" diff))
                     (if (zerop count) "no" (format "%d" count))
-                    (if (= count 1) "" "es")
+                    (ngettext "match" "matches" count)
                     ;; Don't display regexp if with remaining text
                     ;; it is longer than window-width.
                     (if (> (+ (length (or (get-text-property 0 'isearch-string 
regexp)
@@ -1657,7 +1665,10 @@ See also `multi-occur'."
                   (lines 0)               ; count of matching lines
                  (matches 0)             ; count of matches
                  (headerpt (with-current-buffer out-buf (point)))
-                  )
+                 (orig-line (if (not (overlayp boo))
+                                (line-number-at-pos)
+                              (line-number-at-pos
+                               (overlay-get boo 'occur--orig-point)))))
              (save-excursion
                 ;; begin searching in the buffer
                (goto-char (if (overlayp boo) (overlay-start boo) (point-min)))
@@ -1665,9 +1676,6 @@ See also `multi-occur'."
                (let* ((limit (if (overlayp boo) (overlay-end boo) (point-max)))
                        (start-line (line-number-at-pos))
                       (curr-line start-line) ; line count
-                      (orig-line (if (not (overlayp boo)) 1
-                                    (line-number-at-pos
-                                     (overlay-get boo 'occur--orig-point))))
                       (orig-line-shown-p)
                       (prev-line nil)        ; line number of prev match endpt
                       (prev-after-lines nil) ; context lines of prev match
@@ -1796,7 +1804,7 @@ See also `multi-occur'."
                                (setq orig-line-shown-p t)
                                (save-excursion
                                  (goto-char (point-min))
-                                 (forward-line (- orig-line start-line 1))
+                                 (forward-line (1- orig-line))
                                  (occur-engine-line (line-beginning-position)
                                                     (line-end-position) 
keep-props)))))
                        ;; Actually insert the match display data
@@ -1834,7 +1842,7 @@ See also `multi-occur'."
                    (let ((orig-line-str
                           (save-excursion
                             (goto-char (point-min))
-                            (forward-line (- orig-line start-line 1))
+                            (forward-line (1- orig-line))
                             (occur-engine-line (line-beginning-position)
                                                (line-end-position) 
keep-props))))
                      (add-face-text-property
@@ -1853,14 +1861,15 @@ See also `multi-occur'."
                  (let ((beg (point))
                        end)
                    (insert (propertize
-                            (format "%d match%s%s%s in buffer: %s%s\n"
-                                    matches (if (= matches 1) "" "es")
+                            (format "%d %s%s%s in buffer: %s%s\n"
+                                    matches
+                                    (ngettext "match" "matches" matches)
                                     ;; Don't display the same number of lines
                                     ;; and matches in case of 1 match per line.
                                     (if (= lines matches)
-                                        "" (format " in %d line%s"
+                                        "" (format " in %d %s"
                                                    lines
-                                                   (if (= lines 1) "" "s")))
+                                                   (ngettext "line" "lines" 
lines)))
                                     ;; Don't display regexp for multi-buffer.
                                     (if (> (length buffers) 1)
                                         "" (occur-regexp-descr regexp))
@@ -1886,13 +1895,15 @@ See also `multi-occur'."
        (goto-char (point-min))
        (let ((beg (point))
              end)
-         (insert (format "%d match%s%s total%s:\n"
-                         global-matches (if (= global-matches 1) "" "es")
+         (insert (format "%d %s%s total%s:\n"
+                         global-matches
+                         (ngettext "match" "matches" global-matches)
                          ;; Don't display the same number of lines
                          ;; and matches in case of 1 match per line.
                          (if (= global-lines global-matches)
-                             "" (format " in %d line%s"
-                                        global-lines (if (= global-lines 1) "" 
"s")))
+                             "" (format " in %d %s"
+                                        global-lines
+                                        (ngettext "line" "lines" 
global-lines)))
                          (occur-regexp-descr regexp)))
          (setq end (point))
          (when title-face
@@ -1907,10 +1918,8 @@ See also `multi-occur'."
       global-matches)))
 
 (defun occur-engine-line (beg end &optional keep-props)
-  (if (and keep-props (if (boundp 'jit-lock-mode) jit-lock-mode)
-          (text-property-not-all beg end 'fontified t))
-      (if (fboundp 'jit-lock-fontify-now)
-         (jit-lock-fontify-now beg end)))
+  (if (and keep-props font-lock-mode)
+      (font-lock-ensure beg end))
   (if (and keep-props (not (eq occur-excluded-properties t)))
       (let ((str (buffer-substring beg end)))
        (remove-list-of-text-properties
@@ -2634,22 +2643,24 @@ characters."
                  (setq def (lookup-key map key))
                  ;; Restore the match data while we process the command.
                  (cond ((eq def 'help)
-                        (with-output-to-temp-buffer "*Help*"
-                          (princ
-                           (concat "Query replacing "
-                                   (if backward "backward " "")
-                                   (if delimited-flag
-                                       (or (and (symbolp delimited-flag)
-                                                (get delimited-flag
-                                                      'isearch-message-prefix))
-                                           "word ") "")
-                                   (if regexp-flag "regexp " "")
-                                   from-string " with "
-                                   next-replacement ".\n\n"
-                                   (substitute-command-keys
-                                    query-replace-help)))
-                          (with-current-buffer standard-output
-                            (help-mode))))
+                        (let ((display-buffer-overriding-action
+                               '(nil (inhibit-same-window . t))))
+                          (with-output-to-temp-buffer "*Help*"
+                            (princ
+                             (concat "Query replacing "
+                                     (if backward "backward " "")
+                                     (if delimited-flag
+                                         (or (and (symbolp delimited-flag)
+                                                  (get delimited-flag
+                                                       
'isearch-message-prefix))
+                                             "word ") "")
+                                     (if regexp-flag "regexp " "")
+                                     from-string " with "
+                                     next-replacement ".\n\n"
+                                     (substitute-command-keys
+                                      query-replace-help)))
+                            (with-current-buffer standard-output
+                              (help-mode)))))
                        ((eq def 'exit)
                         (setq keep-going nil)
                         (setq done t))
@@ -2729,10 +2740,10 @@ characters."
                                            (1+ num-replacements))))))
                              (when (and (eq def 'undo-all)
                                         (null (zerop num-replacements)))
-                               (message "Undid %d %s" num-replacements
-                                        (if (= num-replacements 1)
-                                            "replacement"
-                                          "replacements"))
+                               (message (ngettext "Undid %d replacement"
+                                                  "Undid %d replacements"
+                                                  num-replacements)
+                                        num-replacements)
                                (ding 'no-terminate)
                                (sit-for 1)))
                           (setq replaced nil last-was-undo t 
last-was-act-and-show nil)))
@@ -2858,9 +2869,10 @@ characters."
                       last-was-act-and-show     nil))))))
       (replace-dehighlight))
     (or unread-command-events
-       (message "Replaced %d occurrence%s%s"
+       (message (ngettext "Replaced %d occurrence%s"
+                          "Replaced %d occurrences%s"
+                          replace-count)
                 replace-count
-                (if (= replace-count 1) "" "s")
                 (if (> (+ skip-read-only-count
                           skip-filtered-count
                           skip-invisible-count)
diff --git a/lisp/reposition.el b/lisp/reposition.el
index 146fa9a..22f9986 100644
--- a/lisp/reposition.el
+++ b/lisp/reposition.el
@@ -1,6 +1,6 @@
 ;;; reposition.el --- center a Lisp function or comment on the screen
 
-;; Copyright (C) 1991, 1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1991, 1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael D. Ernst <address@hidden>
 ;; Created: Jan 1991
diff --git a/lisp/reveal.el b/lisp/reveal.el
index a3ecfc4..67740c8 100644
--- a/lisp/reveal.el
+++ b/lisp/reveal.el
@@ -1,6 +1,6 @@
 ;;; reveal.el --- Automatically reveal hidden text at point -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords: outlines
diff --git a/lisp/rfn-eshadow.el b/lisp/rfn-eshadow.el
index d6e9a1e..d0a022a 100644
--- a/lisp/rfn-eshadow.el
+++ b/lisp/rfn-eshadow.el
@@ -1,6 +1,6 @@
 ;;; rfn-eshadow.el --- Highlight `shadowed' part of read-file-name input text
 ;;
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Miles Bader <address@hidden>
 ;; Keywords: convenience minibuffer
diff --git a/lisp/rot13.el b/lisp/rot13.el
index c1de71f..8f4044d 100644
--- a/lisp/rot13.el
+++ b/lisp/rot13.el
@@ -1,6 +1,6 @@
 ;;; rot13.el --- display a buffer in ROT13  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1988, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Howard Gayle
 ;; Maintainer: address@hidden
diff --git a/lisp/rtree.el b/lisp/rtree.el
index fe24cd1..9a0a649 100644
--- a/lisp/rtree.el
+++ b/lisp/rtree.el
@@ -1,6 +1,6 @@
 ;;; rtree.el --- functions for manipulating range trees  -*- lexical-binding:t 
-*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 
diff --git a/lisp/ruler-mode.el b/lisp/ruler-mode.el
index 709599b..c5c88d0 100644
--- a/lisp/ruler-mode.el
+++ b/lisp/ruler-mode.el
@@ -1,6 +1,6 @@
 ;;; ruler-mode.el --- display a ruler in the header line
 
-;; Copyright (C) 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Ponce <address@hidden>
 ;; Maintainer: David Ponce <address@hidden>
diff --git a/lisp/savehist.el b/lisp/savehist.el
index 329929b..1eab18e 100644
--- a/lisp/savehist.el
+++ b/lisp/savehist.el
@@ -1,6 +1,6 @@
 ;;; savehist.el --- Save minibuffer history
 
-;; Copyright (C) 1997, 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2005-2019 Free Software Foundation, Inc.
 
 ;; Author: Hrvoje Niksic <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/saveplace.el b/lisp/saveplace.el
index f8f15ca..730d31e 100644
--- a/lisp/saveplace.el
+++ b/lisp/saveplace.el
@@ -1,6 +1,6 @@
 ;;; saveplace.el --- automatically save place in files
 
-;; Copyright (C) 1993-1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Karl Fogel <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/sb-image.el b/lisp/sb-image.el
index f467948..f44f2ed 100644
--- a/lisp/sb-image.el
+++ b/lisp/sb-image.el
@@ -1,6 +1,6 @@
 ;;; sb-image --- Image management for speedbar
 
-;; Copyright (C) 1999-2003, 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2003, 2005-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: file, tags, tools
diff --git a/lisp/scroll-all.el b/lisp/scroll-all.el
index c32960e..78a05b5 100644
--- a/lisp/scroll-all.el
+++ b/lisp/scroll-all.el
@@ -1,6 +1,6 @@
 ;;; scroll-all.el --- scroll all buffers together minor mode
 
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Gary D. Foster <address@hidden>
 ;; Keywords: convenience scroll lock
diff --git a/lisp/scroll-bar.el b/lisp/scroll-bar.el
index 7efbfc7..dc0df7a 100644
--- a/lisp/scroll-bar.el
+++ b/lisp/scroll-bar.el
@@ -1,6 +1,6 @@
 ;;; scroll-bar.el --- window system-independent scroll bar support
 
-;; Copyright (C) 1993-1995, 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1995, 1999-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: hardware
diff --git a/lisp/scroll-lock.el b/lisp/scroll-lock.el
index 123fbb2..8281edb 100644
--- a/lisp/scroll-lock.el
+++ b/lisp/scroll-lock.el
@@ -1,6 +1,6 @@
 ;;; scroll-lock.el --- Scroll lock scrolling.
 
-;; Copyright (C) 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005-2019 Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/select.el b/lisp/select.el
index bd7fd0c..c79e923 100644
--- a/lisp/select.el
+++ b/lisp/select.el
@@ -1,6 +1,6 @@
 ;;; select.el --- lisp portion of standard selection support  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1993-1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: internal
diff --git a/lisp/server.el b/lisp/server.el
index 28e789a..1e5c57a 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -1,6 +1,6 @@
 ;;; server.el --- Lisp code for GNU Emacs running as server process -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1986-1987, 1992, 1994-2018 Free Software Foundation,
+;; Copyright (C) 1986-1987, 1992, 1994-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: William Sommerfeld <address@hidden>
@@ -270,7 +270,14 @@ been consumed.")
     "server")
   "The name of the Emacs server, if this Emacs process creates one.
 The command `server-start' makes use of this.  It should not be
-changed while a server is running."
+changed while a server is running.
+If this is a file name with no leading directories, Emacs will
+create a socket file by that name under `server-socket-dir'
+if `server-use-tcp' is nil, else under `server-auth-dir'.
+If this is an absolute file name, it specifies where the socket
+file will be created.  To have emacsclient connect to the same
+socket, use the \"-s\" switch for local non-TCP sockets, and
+the \"-f\" switch otherwise."
   :group 'server
   :type 'string
   :version "23.1")
@@ -800,7 +807,7 @@ Server mode runs a process that accepts commands from the
   ;; intended it to interrupt us rather than interrupt whatever Emacs
   ;; was doing before it started handling the process filter.
   ;; Hence `with-local-quit' (bug#6585).
-  (let ((v (with-local-quit (eval (car (read-from-string expr))))))
+  (let ((v (with-local-quit (eval (car (read-from-string expr)) t))))
     (when proc
       (with-temp-buffer
         (let ((standard-output (current-buffer)))
@@ -1322,7 +1329,7 @@ The following commands are accepted by the client:
                                                (find-file-noselect 
initial-buffer-choice))
                                               ((functionp 
initial-buffer-choice)
                                                (funcall 
initial-buffer-choice)))))
-                                   (if (buffer-live-p buf) buf 
(get-buffer-create "*scratch*")))))
+                                   (if (buffer-live-p buf) buf 
(startup--get-buffer-create-scratch)))))
                ;; Set current buffer so that newly created tty frames
                ;; show the correct buffer initially.
                (frame (with-current-buffer (or (car buffers)
@@ -1737,7 +1744,7 @@ returns the process ID of the Emacs instance running 
\"server\"."
                                   (server-quote-arg (format "%S" form))
                                   "\n"))
       (while (memq (process-status process) '(open run))
-       (accept-process-output process 0 10))
+       (accept-process-output process 0.01))
       (goto-char (point-min))
       ;; If the result is nil, there's nothing in the buffer.  If the
       ;; result is non-nil, it's after "-print ".
diff --git a/lisp/ses.el b/lisp/ses.el
index 1608d56..73157d6 100644
--- a/lisp/ses.el
+++ b/lisp/ses.el
@@ -1,6 +1,6 @@
 ;;; ses.el -- Simple Emacs Spreadsheet  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Jonathan Yavner <address@hidden>
 ;; Maintainer: Vincent Belaïche  <address@hidden>
@@ -837,7 +837,7 @@ updated again."
 (defmacro ses--time-check (format &rest args)
   "If `ses-start-time' is more than a second ago, call `message' with FORMAT
 and ARGS and reset `ses-start-time' to the current time."
-  `(when (> (- (float-time) ses-start-time) 1.0)
+  `(when (time-less-p 1 (time-since ses-start-time))
      (message ,format ,@args)
      (setq ses-start-time (float-time))))
 
diff --git a/lisp/shadowfile.el b/lisp/shadowfile.el
index 180d502..07e7850 100644
--- a/lisp/shadowfile.el
+++ b/lisp/shadowfile.el
@@ -1,6 +1,6 @@
 ;;; shadowfile.el --- automatic file copying
 
-;; Copyright (C) 1993-1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Boris Goldowsky <address@hidden>
 ;; Keywords: comm files
diff --git a/lisp/shell.el b/lisp/shell.el
index 16aeffc..5357027 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -1,6 +1,6 @@
 ;;; shell.el --- specialized comint.el for running the shell -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1988, 1993-1997, 2000-2018 Free Software Foundation,
+;; Copyright (C) 1988, 1993-1997, 2000-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Olin Shivers <address@hidden>
@@ -99,6 +99,7 @@
 
 (require 'comint)
 (require 'pcomplete)
+(eval-when-compile (require 'files-x)) ;with-connection-local-variables
 
 ;;; Customization and Buffer Variables
 
@@ -487,7 +488,7 @@ Shell buffers.  It implements `shell-completion-execonly' 
for
   ;; Don't use pcomplete's defaulting mechanism, rely on
   ;; shell-dynamic-complete-functions instead.
   (set (make-local-variable 'pcomplete-default-completion-function) #'ignore)
-  (setq comint-input-autoexpand shell-input-autoexpand)
+  (setq-local comint-input-autoexpand shell-input-autoexpand)
   ;; Not needed in shell-mode because it's inherited from comint-mode, but
   ;; placed here for read-shell-command.
   (add-hook 'completion-at-point-functions #'comint-completion-at-point nil t))
@@ -720,43 +721,37 @@ Otherwise, one argument `-i' is passed to the shell.
                  (current-buffer)))
 
   (with-current-buffer buffer
-    (when (file-remote-p default-directory)
-      ;; Apply connection-local variables.
-      (hack-connection-local-variables-apply
-       `(:application tramp
-         :protocol ,(file-remote-p default-directory 'method)
-         :user ,(file-remote-p default-directory 'user)
-         :machine ,(file-remote-p default-directory 'host)))
-
-      ;; On remote hosts, the local `shell-file-name' might be useless.
-      (if (and (called-interactively-p 'any)
-               (null explicit-shell-file-name)
-               (null (getenv "ESHELL")))
-          (set (make-local-variable 'explicit-shell-file-name)
-               (file-local-name
-               (expand-file-name
-                 (read-file-name
-                  "Remote shell path: " default-directory shell-file-name
-                  t shell-file-name)))))))
-
-  ;; The buffer's window must be correctly set when we call comint
-  ;; (so that comint sets the COLUMNS env var properly).
-  (pop-to-buffer buffer)
-  ;; Rain or shine, BUFFER must be current by now.
-  (unless (comint-check-proc buffer)
-    (let* ((prog (or explicit-shell-file-name
-                     (getenv "ESHELL") shell-file-name))
-           (name (file-name-nondirectory prog))
-           (startfile (concat "~/.emacs_" name))
-           (xargs-name (intern-soft (concat "explicit-" name "-args"))))
-      (unless (file-exists-p startfile)
-        (setq startfile (concat user-emacs-directory "init_" name ".sh")))
-      (apply #'make-comint-in-buffer "shell" buffer prog
-             (if (file-exists-p startfile) startfile)
-             (if (and xargs-name (boundp xargs-name))
-                 (symbol-value xargs-name)
-               '("-i")))
-      (shell-mode)))
+    (with-connection-local-variables
+     ;; On remote hosts, the local `shell-file-name' might be useless.
+     (when (file-remote-p default-directory)
+       (if (and (called-interactively-p 'any)
+                (null explicit-shell-file-name)
+                (null (getenv "ESHELL")))
+           (set (make-local-variable 'explicit-shell-file-name)
+                (file-local-name
+                (expand-file-name
+                  (read-file-name
+                   "Remote shell path: " default-directory shell-file-name
+                   t shell-file-name))))))
+
+     ;; The buffer's window must be correctly set when we call comint
+     ;; (so that comint sets the COLUMNS env var properly).
+     (pop-to-buffer buffer)
+     ;; Rain or shine, BUFFER must be current by now.
+     (unless (comint-check-proc buffer)
+       (let* ((prog (or explicit-shell-file-name
+                        (getenv "ESHELL") shell-file-name))
+              (name (file-name-nondirectory prog))
+              (startfile (concat "~/.emacs_" name))
+              (xargs-name (intern-soft (concat "explicit-" name "-args"))))
+         (unless (file-exists-p startfile)
+           (setq startfile (concat user-emacs-directory "init_" name ".sh")))
+         (apply #'make-comint-in-buffer "shell" buffer prog
+                (if (file-exists-p startfile) startfile)
+                (if (and xargs-name (boundp xargs-name))
+                    (symbol-value xargs-name)
+                  '("-i")))
+         (shell-mode)))))
   buffer)
 
 ;;; Directory tracking
diff --git a/lisp/simple.el b/lisp/simple.el
index db59b9f..5660f65 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1,6 +1,6 @@
 ;;; simple.el --- basic editing commands for Emacs  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1985-1987, 1993-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1987, 1993-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: internal
@@ -110,6 +110,15 @@ If non-nil, the value is passed directly to `recenter'."
   :type 'hook
   :group 'next-error)
 
+(defcustom next-error-verbose t
+  "If non-nil, `next-error' always outputs the current error buffer.
+If nil, the message is output only when the error buffer
+changes."
+  :group 'next-error
+  :type 'boolean
+  :safe #'booleanp
+  :version "27.1")
+
 (defvar next-error-highlight-timer nil)
 
 (defvar next-error-overlay-arrow-position nil)
@@ -312,21 +321,27 @@ To control which errors are matched, customize the 
variable
       ;; We know here that next-error-function is a valid symbol we can funcall
       (with-current-buffer buffer
         (funcall next-error-function (prefix-numeric-value arg) reset)
-        (next-error-found buffer (current-buffer))
-        (message "%s locus from %s"
-                 (cond (reset                             "First")
-                       ((eq (prefix-numeric-value arg) 0) "Current")
-                       ((< (prefix-numeric-value arg) 0)  "Previous")
-                       (t                                 "Next"))
-                 next-error-last-buffer)))))
+        (let ((prev next-error-last-buffer))
+          (next-error-found buffer (current-buffer))
+          (when (or next-error-verbose
+                    (not (eq prev next-error-last-buffer)))
+            (message "%s locus from %s"
+                     (cond (reset                             "First")
+                           ((eq (prefix-numeric-value arg) 0) "Current")
+                           ((< (prefix-numeric-value arg) 0)  "Previous")
+                           (t                                 "Next"))
+                     next-error-last-buffer)))))))
 
 (defun next-error-internal ()
   "Visit the source code corresponding to the `next-error' message at point."
   (let ((buffer (current-buffer)))
     ;; We know here that next-error-function is a valid symbol we can funcall
     (funcall next-error-function 0 nil)
-    (next-error-found buffer (current-buffer))
-    (message "Current locus from %s" next-error-last-buffer)))
+    (let ((prev next-error-last-buffer))
+      (next-error-found buffer (current-buffer))
+      (when (or next-error-verbose
+                (not (eq prev next-error-last-buffer)))
+        (message "Current locus from %s" next-error-last-buffer)))))
 
 (defun next-error-found (&optional from-buffer to-buffer)
   "Function to call when the next locus is found and displayed.
@@ -383,13 +398,11 @@ backwards, if negative).
 Finds and highlights the source line like \\[next-error], but does not
 select the source buffer."
   (interactive "p")
-  (let ((next-error-highlight next-error-highlight-no-select))
-    (next-error n))
-  (let ((display-buffer-overriding-action '(display-buffer-reuse-window)))
-    ;; Override user customization such as display-buffer-same-window
-    ;; and use display-buffer-reuse-window to ensure next-error-last-buffer
-    ;; is displayed somewhere, not necessarily in the same window (bug#32607).
-    (pop-to-buffer next-error-last-buffer)))
+  (save-selected-window
+    (let ((next-error-highlight next-error-highlight-no-select)
+          (display-buffer-overriding-action
+           '(nil (inhibit-same-window . t))))
+      (next-error n))))
 
 (defun previous-error-no-select (&optional n)
   "Move point to the previous error in the `next-error' buffer and highlight 
match.
@@ -595,25 +608,43 @@ When called from Lisp code, ARG may be a prefix string to 
copy."
     (indent-to col 0)
     (goto-char pos)))
 
-(defun delete-indentation (&optional arg)
+(defun delete-indentation (&optional arg beg end)
   "Join this line to previous and fix up whitespace at join.
-If there is a fill prefix, delete it from the beginning of this line.
-With argument, join this line to following line."
-  (interactive "*P")
-  (beginning-of-line)
-  (if arg (forward-line 1))
-  (if (eq (preceding-char) ?\n)
-      (progn
-       (delete-region (point) (1- (point)))
-       ;; If the second line started with the fill prefix,
-       ;; delete the prefix.
-       (if (and fill-prefix
-                (<= (+ (point) (length fill-prefix)) (point-max))
-                (string= fill-prefix
-                         (buffer-substring (point)
-                                           (+ (point) (length fill-prefix)))))
-           (delete-region (point) (+ (point) (length fill-prefix))))
-       (fixup-whitespace))))
+If there is a fill prefix, delete it from the beginning of this
+line.
+With prefix ARG, join the current line to the following line.
+When BEG and END are non-nil, join all lines in the region they
+define.  Interactively, BEG and END are, respectively, the start
+and end of the region if it is active, else nil.  (The region is
+ignored if prefix ARG is given.)"
+  (interactive
+   (progn (barf-if-buffer-read-only)
+          (cons current-prefix-arg
+                (and (use-region-p)
+                     (list (region-beginning) (region-end))))))
+  ;; Consistently deactivate mark even when no text is changed.
+  (setq deactivate-mark t)
+  (if (and beg (not arg))
+      ;; Region is active.  Go to END, but only if region spans
+      ;; multiple lines.
+      (and (goto-char beg)
+           (> end (line-end-position))
+           (goto-char end))
+    ;; Region is inactive.  Set a loop sentinel
+    ;; (subtracting 1 in order to compare less than BOB).
+    (setq beg (1- (line-beginning-position (and arg 2))))
+    (when arg (forward-line)))
+  (let ((prefix (and (> (length fill-prefix) 0)
+                     (regexp-quote fill-prefix))))
+    (while (and (> (line-beginning-position) beg)
+                (forward-line 0)
+                (= (preceding-char) ?\n))
+      (delete-char -1)
+      ;; If the appended line started with the fill prefix,
+      ;; delete the prefix.
+      (if (and prefix (looking-at prefix))
+          (replace-match "" t t))
+      (fixup-whitespace))))
 
 (defalias 'join-line #'delete-indentation) ; easier to find
 
@@ -1615,12 +1646,14 @@ this command arranges for all errors to enter the 
debugger."
          (eval-expression-get-print-arguments current-prefix-arg)))
 
   (if (null eval-expression-debug-on-error)
-      (push (eval exp lexical-binding) values)
+      (push (eval (let ((lexical-binding t)) (macroexpand-all exp)) t)
+            values)
     (let ((old-value (make-symbol "t")) new-value)
       ;; Bind debug-on-error to something unique so that we can
       ;; detect when evalled code changes it.
       (let ((debug-on-error old-value))
-       (push (eval (macroexpand-all exp) lexical-binding) values)
+       (push (eval (let ((lexical-binding t)) (macroexpand-all exp)) t)
+              values)
        (setq new-value debug-on-error))
       ;; If evalled code has changed the value of debug-on-error,
       ;; propagate that change to the global binding.
@@ -1841,9 +1874,11 @@ invoking, give a prefix argument to 
`execute-extended-command'."
             ;; If this command displayed something in the echo area;
             ;; wait a few seconds, then display our suggestion message.
             ;; FIXME: Wait *after* running post-command-hook!
-            ;; FIXME: Don't wait if execute-extended-command--shorter won't
-            ;; find a better answer anyway!
-            (when suggest-key-bindings
+            ;; FIXME: If execute-extended-command--shorter were
+            ;; faster, we could compute the result here first too.
+            (when (and suggest-key-bindings
+                       (or binding
+                           (and extended-command-suggest-shorter typed)))
               (sit-for (cond
                         ((zerop (length (current-message))) 0)
                         ((numberp suggest-key-bindings) suggest-key-bindings)
@@ -2172,7 +2207,11 @@ next element of the minibuffer history in the 
minibuffer."
         (prompt-end (minibuffer-prompt-end))
         (old-column (unless (and (eolp) (> (point) prompt-end))
                       (if (= (line-number-at-pos) 1)
-                          (max (- (current-column) (1- prompt-end)) 0)
+                          (max (- (current-column)
+                                  (save-excursion
+                                    (goto-char (1- prompt-end))
+                                    (current-column)))
+                               0)
                         (current-column)))))
     (condition-case nil
        (with-no-warnings
@@ -2191,7 +2230,10 @@ next element of the minibuffer history in the 
minibuffer."
        (goto-char (point-max))
        (when old-column
         (if (= (line-number-at-pos) 1)
-            (move-to-column (+ old-column (1- (minibuffer-prompt-end))))
+            (move-to-column (+ old-column
+                               (save-excursion
+                                 (goto-char (1- (minibuffer-prompt-end)))
+                                 (current-column))))
           (move-to-column old-column)))))))
 
 (defun previous-line-or-history-element (&optional arg)
@@ -2206,7 +2248,11 @@ previous element of the minibuffer history in the 
minibuffer."
         (prompt-end (minibuffer-prompt-end))
         (old-column (unless (and (eolp) (> (point) prompt-end))
                       (if (= (line-number-at-pos) 1)
-                          (max (- (current-column) (1- prompt-end)) 0)
+                          (max (- (current-column)
+                                  (save-excursion
+                                    (goto-char (1- prompt-end))
+                                    (current-column)))
+                               0)
                         (current-column)))))
     (condition-case nil
        (with-no-warnings
@@ -2225,7 +2271,10 @@ previous element of the minibuffer history in the 
minibuffer."
        (goto-char (minibuffer-prompt-end))
        (if old-column
           (if (= (line-number-at-pos) 1)
-              (move-to-column (+ old-column (1- (minibuffer-prompt-end))))
+              (move-to-column (+ old-column
+                                 (save-excursion
+                                   (goto-char (1- (minibuffer-prompt-end)))
+                                   (current-column))))
             (move-to-column old-column))
         ;; Put the cursor at the end of the visual line instead of the
         ;; logical line, so the next `previous-line-or-history-element'
@@ -3304,6 +3353,16 @@ is output."
   :group 'shell
   :version "26.1")
 
+(defcustom shell-command-width nil
+  "Number of display columns available for asynchronous shell command output.
+If nil, use the shell default number (usually 80 columns).
+If a positive integer, tell the shell to use that number of columns for
+command output."
+  :type '(choice (const :tag "Use system limit" nil)
+                 (integer :tag "Fixed width" :value 80))
+  :group 'shell
+  :version "27.1")
+
 (defcustom shell-command-dont-erase-buffer nil
   "If non-nil, output buffer is not erased between shell commands.
 Also, a non-nil value sets the point in the output buffer
@@ -3567,8 +3626,13 @@ impose the use of a shell (with its need to quote 
arguments)."
                (with-current-buffer buffer
                   (shell-command--save-pos-or-erase)
                  (setq default-directory directory)
-                  (setq proc
-                        (start-process-shell-command "Shell" buffer command))
+                 (let ((process-environment
+                        (if (natnump shell-command-width)
+                            (cons (format "COLUMNS=%d" shell-command-width)
+                                  process-environment)
+                          process-environment)))
+                   (setq proc
+                         (start-process-shell-command "Shell" buffer command)))
                  (setq mode-line-process '(":%s"))
                  (require 'shell) (shell-mode)
                   (set-process-sentinel proc #'shell-command-sentinel)
@@ -3878,18 +3942,21 @@ interactively, this is t."
       (shell-command command t))))
 
 (defun process-file (program &optional infile buffer display &rest args)
-  "Process files synchronously in a separate process.
-Similar to `call-process', but may invoke a file handler based on
+  "Process files synchronously in a separate process that runs PROGRAM.
+Similar to `call-process', but may invoke a file name handler based on
 `default-directory'.  The current working directory of the
 subprocess is `default-directory'.
 
+If PROGRAM is a remote file name, it should be processed
+by `file-local-name' before passing it to this function.
+
 File names in INFILE and BUFFER are handled normally, but file
 names in ARGS should be relative to `default-directory', as they
 are passed to the process verbatim.  (This is a difference to
-`call-process' which does not support file handlers for INFILE
+`call-process' which does not support file name handlers for INFILE
 and BUFFER.)
 
-Some file handlers might not support all variants, for example
+Some file name handlers might not support all variants, for example
 they might behave as if DISPLAY was nil, regardless of the actual
 value passed."
   (let ((fh (find-file-name-handler default-directory 'process-file))
@@ -3913,7 +3980,7 @@ value passed."
 
 By default, this variable is always set to t, meaning that a
 call of `process-file' could potentially change any file on a
-remote host.  When set to nil, a file handler could optimize
+remote host.  When set to nil, a file name handler could optimize
 its behavior with respect to remote file attribute caching.
 
 You should only ever change this variable with a let-binding;
@@ -3922,17 +3989,20 @@ never with `setq'.")
 (defun start-file-process (name buffer program &rest program-args)
   "Start a program in a subprocess.  Return the process object for it.
 
-Similar to `start-process', but may invoke a file handler based on
+Similar to `start-process', but may invoke a file name handler based on
 `default-directory'.  See Info node `(elisp)Magic File Names'.
 
 This handler ought to run PROGRAM, perhaps on the local host,
 perhaps on a remote host that corresponds to `default-directory'.
-In the latter case, the local part of `default-directory' becomes
-the working directory of the process.
+In the latter case, the local part of `default-directory', the one
+produced from it by `file-local-name', becomes the working directory
+of the process on the remote host.
 
 PROGRAM and PROGRAM-ARGS might be file names.  They are not
-objects of file handler invocation.  File handlers might not
-support pty association, if PROGRAM is nil."
+objects of file name handler invocation, so they need to be obtained
+by calling `file-local-name', in case they are remote file names.
+
+File name handlers might not support pty association, if PROGRAM is nil."
   (let ((fh (find-file-name-handler default-directory 'start-file-process)))
     (if fh (apply fh 'start-file-process name buffer program program-args)
       (apply 'start-process name buffer program program-args))))
@@ -7814,7 +7884,7 @@ appears to have customizations applying to the old 
default,
   "If the buffer starts with a mail header, move point to the header's end.
 Otherwise, moves to `point-min'.
 The end of the header is the start of the next line, if there is one,
-else the end of the last line.  This function obeys RFC822."
+else the end of the last line.  This function obeys RFC 822 (or later)."
   (goto-char (point-min))
   (when (re-search-forward
         "^\\([:\n]\\|[^: \t\n]+[ \t\n]\\)" nil 'move)
@@ -8168,6 +8238,9 @@ CHOICE - the string to insert in the buffer,
 BUFFER - the buffer in which the choice should be inserted,
 BASE-POSITION - where to insert the completion.
 
+Functions should also accept and ignore a potential fourth
+argument, passed for backwards compatibility.
+
 If a function in the list returns non-nil, that function is supposed
 to have inserted the CHOICE in the BUFFER, and possibly exited
 the minibuffer; no further functions will be called.
@@ -8652,7 +8725,7 @@ call `normal-erase-is-backspace-mode' (which see) 
instead."
                (and (not noninteractive)
                     (or (memq system-type '(ms-dos windows-nt))
                        (memq window-system '(w32 ns))
-                        (and (memq window-system '(x))
+                        (and (eq window-system 'x)
                              (fboundp 'x-backspace-delete-keys-p)
                              (x-backspace-delete-keys-p))
                         ;; If the terminal Emacs is running on has erase char
@@ -8663,6 +8736,8 @@ call `normal-erase-is-backspace-mode' (which see) 
instead."
              normal-erase-is-backspace)
            1 0)))))
 
+(declare-function display-symbol-keys-p "frame" (&optional display))
+
 (define-minor-mode normal-erase-is-backspace-mode
   "Toggle the Erase and Delete mode of the Backspace and Delete keys.
 
@@ -8698,8 +8773,7 @@ See also `normal-erase-is-backspace'."
   (let ((enabled (eq 1 (terminal-parameter
                         nil 'normal-erase-is-backspace))))
 
-    (cond ((or (memq window-system '(x w32 ns pc))
-              (memq system-type '(ms-dos windows-nt)))
+    (cond ((display-symbol-keys-p)
           (let ((bindings
                  '(([M-delete] [M-backspace])
                    ([C-M-delete] [C-M-backspace])
diff --git a/lisp/skeleton.el b/lisp/skeleton.el
index e7ac2ea..bce73d6 100644
--- a/lisp/skeleton.el
+++ b/lisp/skeleton.el
@@ -1,6 +1,6 @@
 ;;; skeleton.el --- Lisp language extension for writing statement skeletons
 
-;; Copyright (C) 1993-1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1996, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Daniel Pfeiffer <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/sort.el b/lisp/sort.el
index 3929f19..6ea1c44 100644
--- a/lisp/sort.el
+++ b/lisp/sort.el
@@ -1,6 +1,6 @@
 ;;; sort.el --- commands to sort text in an Emacs buffer -*- lexical-binding: 
t -*-
 
-;; Copyright (C) 1986-1987, 1994-1995, 2001-2018 Free Software
+;; Copyright (C) 1986-1987, 1994-1995, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Howie Kaye
diff --git a/lisp/soundex.el b/lisp/soundex.el
index 036ce5c..1f1f9ca 100644
--- a/lisp/soundex.el
+++ b/lisp/soundex.el
@@ -1,6 +1,6 @@
 ;;; soundex.el --- implement Soundex algorithm -*- lexical-binding: t -*-
 
-;; Copyright (C) 1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Christian Plaunt <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/speedbar.el b/lisp/speedbar.el
index f3ea048..4823e4b 100644
--- a/lisp/speedbar.el
+++ b/lisp/speedbar.el
@@ -1,6 +1,6 @@
 ;;; speedbar --- quick access to files and tags in a frame
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 ;; Keywords: file, tags, tools
@@ -647,9 +647,9 @@ speedbar is loaded.  You may place anything you like in 
this list
 before speedbar has been loaded."
   :group 'speedbar
   :type '(repeat (regexp :tag "Directory Regexp"))
-  :set (lambda (_sym val)
-        (setq speedbar-ignored-directory-expressions val
-              speedbar-ignored-directory-regexp
+  :set (lambda (sym val)
+        (set sym val)
+         (setq speedbar-ignored-directory-regexp
               (speedbar-extension-list-to-regex val))))
 
 (defcustom speedbar-directory-unshown-regexp "^\\(\\..*\\)\\'"
@@ -701,9 +701,9 @@ need to also modify `completion-ignored-extension' which 
will also help
 file completion."
   :group 'speedbar
   :type '(repeat (regexp :tag "Extension Regexp"))
-  :set (lambda (_sym val)
-        (set 'speedbar-supported-extension-expressions val)
-        (set 'speedbar-file-regexp (speedbar-extension-list-to-regex val))))
+  :set (lambda (sym val)
+        (set sym val)
+        (setq speedbar-file-regexp (speedbar-extension-list-to-regex val))))
 
 (setq speedbar-file-regexp
       (speedbar-extension-list-to-regex 
speedbar-supported-extension-expressions))
@@ -972,9 +972,8 @@ supported at a time.
   (interactive "P")
   ;; Get the buffer to play with
   (if (not (buffer-live-p speedbar-buffer))
-      (save-excursion
-       (setq speedbar-buffer (get-buffer-create " SPEEDBAR"))
-       (set-buffer speedbar-buffer)
+      (with-current-buffer
+          (setq speedbar-buffer (get-buffer-create " SPEEDBAR"))
        (speedbar-mode)))
   ;; Do the frame thing
   (dframe-frame-mode arg
@@ -1476,57 +1475,59 @@ instead of reading it from the speedbar buffer."
 Return nil if not applicable."
   (save-excursion
     (beginning-of-line)
-    (if (re-search-forward " [-+=]?> \\([^\n]+\\)" (line-end-position) t)
-       (let* ((tag (match-string 1))
-             (attr (speedbar-line-token))
-             (item nil)
-             (semantic-tagged (if (fboundp 'semantic-tag-p)
-                                  (semantic-tag-p attr))))
-         (if semantic-tagged
-           (with-no-warnings
-             (save-excursion
-               (when (and (semantic-tag-overlay attr)
-                          (semantic-tag-buffer attr))
-                 (set-buffer (semantic-tag-buffer attr)))
-               (dframe-message
-                (funcall semantic-sb-info-format-tag-function attr)
-                )))
-           (looking-at "\\([0-9]+\\):")
-           (setq item (file-name-nondirectory (speedbar-line-directory)))
-           (dframe-message "Tag: %s  in %s" tag item)))
-      (if (re-search-forward "{[+-]} \\([^\n]+\\)$" (line-end-position) t)
-         (dframe-message "Group of tags \"%s\"" (match-string 1))
-       (if (re-search-forward " [+-]?[()|@] \\([^\n]+\\)$" nil t)
-           (let* ((detailtext (match-string 1))
-                  (detail (or (speedbar-line-token) detailtext))
-                  (parent (save-excursion
-                            (beginning-of-line)
-                            (let ((dep (if (looking-at "[0-9]+:")
-                                           (1- (string-to-number (match-string 
0)))
-                                         0)))
-                              (re-search-backward (concat "^"
-                              (int-to-string dep)
-                              ":")
-                                                  nil t))
-                            (if (looking-at "[0-9]+: +[-+=>]> \\([^\n]+\\)$")
-                                (speedbar-line-token)
-                              nil))))
-             (if (featurep 'semantic)
-                 (with-no-warnings
-                   (if (semantic-tag-p detail)
-                       (dframe-message
-                        (funcall semantic-sb-info-format-tag-function detail 
parent))
-                     (if parent
-                         (dframe-message "Detail: %s of tag %s" detail
-                                           (if (semantic-tag-p parent)
-                                               (semantic-format-tag-name 
parent nil t)
-                                             parent))
-                       (dframe-message "Detail: %s" detail))))
-               ;; Not using `semantic':
-               (if parent
-                   (dframe-message "Detail: %s of tag %s" detail parent)
-                 (dframe-message "Detail: %s" detail))))
-         nil)))))
+    (cond
+     ((re-search-forward " [-+=]?> \\([^\n]+\\)" (line-end-position) t)
+      (let* ((tag (match-string 1))
+             (attr (speedbar-line-token))
+             (item nil)
+             (semantic-tagged (if (fboundp 'semantic-tag-p)
+                                  (semantic-tag-p attr))))
+        (if semantic-tagged
+            (with-no-warnings
+              (save-excursion
+                (when (and (semantic-tag-overlay attr)
+                           (semantic-tag-buffer attr))
+                  (set-buffer (semantic-tag-buffer attr)))
+                (dframe-message
+                 (funcall semantic-sb-info-format-tag-function attr)
+                 )))
+          (looking-at "\\([0-9]+\\):")
+          (setq item (file-name-nondirectory (speedbar-line-directory)))
+          (dframe-message "Tag: %s  in %s" tag item))))
+     ((re-search-forward "{[+-]} \\([^\n]+\\)$" (line-end-position) t)
+      (dframe-message "Group of tags \"%s\"" (match-string 1)))
+     ((re-search-forward " [+-]?[()|@] \\([^\n]+\\)$" nil t)
+      (let* ((detailtext (match-string 1))
+             (detail (or (speedbar-line-token) detailtext))
+             (parent (save-excursion
+                       (beginning-of-line)
+                       (let ((dep (if (looking-at "[0-9]+:")
+                                      (1- (string-to-number (match-string 0)))
+                                    0)))
+                         (re-search-backward (concat "^"
+                                                     (int-to-string dep)
+                                                     ":")
+                                             nil t))
+                       (if (looking-at "[0-9]+: +[-+=>]> \\([^\n]+\\)$")
+                           (speedbar-line-token)
+                         nil))))
+        (cond
+         ((featurep 'semantic)
+          (with-no-warnings
+            (if (semantic-tag-p detail)
+                (dframe-message
+                 (funcall semantic-sb-info-format-tag-function detail parent))
+              (if parent
+                  (dframe-message "Detail: %s of tag %s" detail
+                                  (if (semantic-tag-p parent)
+                                      (semantic-format-tag-name parent nil t)
+                                    parent))
+                (dframe-message "Detail: %s" detail)))))
+         ;; Not using `semantic':
+         (parent
+          (dframe-message "Detail: %s of tag %s" detail parent))
+         (t
+          (dframe-message "Detail: %s" detail))))))))
 
 (defun speedbar-files-item-info ()
   "Display info in the minibuffer about the button the mouse is over."
@@ -2848,7 +2849,7 @@ indicator, then do not add a space."
        (progn
          (goto-char speedbar-ro-to-do-point)
          (while (and (not (input-pending-p))
-                     (re-search-forward "^\\([0-9]+\\):\\s-*[[<][+-?][]>] "
+                     (re-search-forward "^\\([0-9]+\\):\\s-*[[<][+?-][]>] "
                                         nil t))
            (setq speedbar-ro-to-do-point (point))
            (let ((f (speedbar-line-file)))
@@ -2899,7 +2900,7 @@ to add more types of version control systems."
        (progn
          (goto-char speedbar-vc-to-do-point)
          (while (and (not (input-pending-p))
-                     (re-search-forward "^\\([0-9]+\\):\\s-*\\[[+-?]\\] "
+                     (re-search-forward "^\\([0-9]+\\):\\s-*\\[[+?-]\\] "
                                         nil t))
            (setq speedbar-vc-to-do-point (point))
            (if (speedbar-check-vc-this-line (match-string 1))
@@ -3353,7 +3354,7 @@ Handles end-of-sublist smartly."
 Clicking this button expands or contracts a directory.  TEXT is the
 button clicked which has either a + or -.  TOKEN is the directory to be
 expanded.  INDENT is the current indentation level."
-  (cond ((string-match "+" text)       ;we have to expand this dir
+  (cond ((string-match "\\+" text)     ;we have to expand this dir
         (setq speedbar-shown-directories
               (cons (expand-file-name
                      (concat (speedbar-line-directory indent) token "/"))
@@ -3388,9 +3389,7 @@ expanded.  INDENT is the current indentation level."
   "Speedbar click handler for default directory buttons.
 TEXT is the button clicked on.  TOKEN is the directory to follow.
 INDENT is the current indentation level and is unused."
-  (if (string-match "^[A-z]:$" token)
-      (setq default-directory (concat token "/"))
-    (setq default-directory token))
+  (setq default-directory (file-name-as-directory token))
   ;; Because we leave speedbar as the current buffer,
   ;; update contents will change directory without
   ;; having to touch the attached frame.
@@ -3402,7 +3401,7 @@ INDENT is the current indentation level and is unused."
 The parameter TEXT and TOKEN are required, where TEXT is the button
 clicked, and TOKEN is the file to expand.  INDENT is the current
 indentation level."
-  (cond ((string-match "+" text)       ;we have to expand this file
+  (cond ((string-match "\\+" text)     ;we have to expand this file
         (let* ((fn (expand-file-name (concat (speedbar-line-directory indent)
                                              token)))
                (lst (speedbar-fetch-dynamic-tags fn)))
@@ -3443,7 +3442,7 @@ INDENT is the current indentation level."
   "Expand a tag sublist.  Imenu will return sub-lists of specialized tag types.
 Etags does not support this feature.  TEXT will be the button string.
 TOKEN will be the list, and INDENT is the current indentation level."
-  (cond ((string-match "+" text)       ;we have to expand this file
+  (cond ((string-match "\\+" text)     ;we have to expand this file
         (speedbar-change-expand-button-char ?-)
         (speedbar-with-writable
           (save-excursion
@@ -3964,7 +3963,7 @@ TEXT is the buffer's name, TOKEN and INDENT are unused."
   (speedbar-unhighlight-one-tag-line)
   (setq speedbar-highlight-one-tag-line
        (speedbar-make-overlay (line-beginning-position)
-                              (1+ (line-end-position))))
+                              (line-beginning-position 2)))
   (speedbar-overlay-put speedbar-highlight-one-tag-line 'face
                        'speedbar-highlight-face)
   (add-hook 'pre-command-hook 'speedbar-unhighlight-one-tag-line))
diff --git a/lisp/startup.el b/lisp/startup.el
index a7b40b7..421a6ea 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -1,6 +1,6 @@
 ;;; startup.el --- process Emacs shell arguments  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1985-1986, 1992, 1994-2018 Free Software Foundation,
+;; Copyright (C) 1985-1986, 1992, 1994-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Maintainer: address@hidden
@@ -60,8 +60,7 @@ string or function value that this variable has."
          (const     :tag "Remember Mode notes buffer" remember-notes)
          (function  :tag "Function")
          (const     :tag "Lisp scratch buffer" t))
-  :version "23.1"
-  :group 'initialization)
+  :version "23.1")
 
 (defvaralias 'inhibit-splash-screen 'inhibit-startup-screen)
 (defvaralias 'inhibit-startup-message 'inhibit-startup-screen)
@@ -71,8 +70,7 @@ string or function value that this variable has."
 
 This is for use in your personal init file (but NOT site-start.el),
 once you are familiar with the contents of the startup screen."
-  :type 'boolean
-  :group 'initialization)
+  :type 'boolean)
 
 (defvar startup-screen-inhibit-startup-screen nil)
 
@@ -101,18 +99,15 @@ instead:
 Thus, someone else using a copy of your init file will see the
 startup message unless he personally acts to inhibit it."
   :type '(choice (const :tag "Don't inhibit")
-                (string :tag "Enter your user name, to inhibit"))
-  :group 'initialization)
+                (string :tag "Enter your user name, to inhibit")))
 
 (defcustom inhibit-default-init nil
   "Non-nil inhibits loading the `default' library."
-  :type 'boolean
-  :group 'initialization)
+  :type 'boolean)
 
 (defcustom inhibit-startup-buffer-menu nil
   "Non-nil inhibits display of buffer list when more than 2 files are loaded."
-  :type 'boolean
-  :group 'initialization)
+  :type 'boolean)
 
 (defvar command-switch-alist nil
   "Alist of command-line switches.
@@ -336,8 +331,7 @@ is due to historical reasons, and does not reflect its 
purpose very well.)")
 
 (defcustom initial-major-mode 'lisp-interaction-mode
   "Major mode command symbol to use for the initial `*scratch*' buffer."
-  :type 'function
-  :group 'initialization)
+  :type 'function)
 
 (defvar init-file-user nil
   "Identity of user whose init file is or was read.
@@ -376,7 +370,6 @@ it visible in the relevant context.  However, actually 
customizing it
 is not allowed, since it would not work anyway.  The only way to set
 this variable usefully is to set it while building and dumping Emacs."
   :type '(choice (const :tag "none" nil) string)
-  :group 'initialization
   :initialize #'custom-initialize-default
   :set (lambda (_variable _value)
          (error "Customizing `site-run-file' does not work")))
@@ -886,7 +879,7 @@ If STYLE is nil, display appropriately for the terminal."
           (when standard-display-table
             (aset standard-display-table char nil)))))))
 
-(defun load-user-init-file
+(defun startup--load-user-init-file
     (filename-function &optional alternate-filename-function load-defaults)
   "Load a user init-file.
 FILENAME-FUNCTION is called with no arguments and should return
@@ -913,11 +906,17 @@ init-file, or to a default value if loading is not 
possible."
               ;; the name of the file that it loads into
               ;; `user-init-file'.
               (setq user-init-file t)
-              (load init-file-name 'noerror 'nomessage)
+              (load (if (equal (file-name-extension init-file-name)
+                               "el")
+                        (file-name-sans-extension init-file-name)
+                      init-file-name)
+                    'noerror 'nomessage)
 
               (when (and (eq user-init-file t) alternate-filename-function)
-                (load (funcall alternate-filename-function)
-                      'noerror 'nomessage))
+                (let ((alt-file (funcall alternate-filename-function)))
+                  (and (equal (file-name-extension alt-file) "el")
+                       (setq alt-file (file-name-sans-extension alt-file)))
+                  (load alt-file 'noerror 'nomessage)))
 
               ;; If we did not find the user's init file, set
               ;; user-init-file conclusively.  Don't let it be
@@ -1056,7 +1055,8 @@ please check its value")
       (let* ((longopts '(("--no-init-file") ("--no-site-file")
                          ("--no-x-resources") ("--debug-init")
                          ("--user") ("--iconic") ("--icon-type") ("--quick")
-                        ("--no-blinking-cursor") ("--basic-display")))
+                        ("--no-blinking-cursor") ("--basic-display")
+                         ("--dump-file") ("--temacs")))
              (argi (pop args))
              (orig-argi argi)
              argval)
@@ -1108,6 +1108,9 @@ please check its value")
          (push '(visibility . icon) initial-frame-alist))
         ((member argi '("-nbc" "-no-blinking-cursor"))
          (setq no-blinking-cursor t))
+         ((member argi '("-dump-file" "-temacs"))  ; Handled in C
+          (or argval (pop args))
+          (setq argval nil))
         ;; Push the popped arg back on the list of arguments.
         (t
           (push argi args)
@@ -1160,10 +1163,14 @@ please check its value")
                          :error))))
 
   ;; Load the early init file, if found.
-  (load-user-init-file
+  (startup--load-user-init-file
    (lambda ()
      (expand-file-name
-      "early-init"
+      ;; We use an explicit .el extension here to force
+      ;; startup--load-user-init-file to set user-init-file to "early-init.el",
+      ;; with the .el extension, if the file doesn't exist, not just
+      ;; "early-init" without an extension, as it does for ".emacs".
+      "early-init.el"
       (file-name-as-directory
        (concat "~" init-file-user "/.emacs.d")))))
   (setq early-init-file user-init-file)
@@ -1300,7 +1307,7 @@ please check its value")
          (load site-run-file t t)))
 
     ;; Load that user's init file, or the default one, or none.
-    (load-user-init-file
+    (startup--load-user-init-file
      (lambda ()
        (cond
         ((eq system-type 'ms-dos)
@@ -1371,7 +1378,8 @@ please check its value")
   (if (get-buffer "*scratch*")
       (with-current-buffer "*scratch*"
        (if (eq major-mode 'fundamental-mode)
-           (funcall initial-major-mode))))
+           (funcall initial-major-mode))
+        (setq-local lexical-binding t)))
 
   ;; Load library for our terminal type.
   ;; User init file can set term-file-prefix to nil to prevent this.
@@ -1473,8 +1481,7 @@ settings will be marked as \"CHANGED outside of 
Customize\"."
   "Initial documentation displayed in *scratch* buffer at startup.
 If this is nil, no message will be displayed."
   :type '(choice (text :tag "Message")
-                (const :tag "none" nil))
-  :group 'initialization)
+                (const :tag "none" nil)))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1628,13 +1635,13 @@ Each element in the list should be a list of strings or 
pairs
 
 
 (defgroup fancy-splash-screen ()
+  ;; FIXME: Do we really need this group with a single custom var?
   "Fancy splash screen when Emacs starts."
   :version "21.1"
   :group 'initialization)
 
 (defcustom fancy-splash-image nil
   "The image to show in the splash screens, or nil for defaults."
-  :group 'fancy-splash-screen
   :type '(choice (const :tag "Default" nil)
                 (file :tag "File")))
 
@@ -2118,7 +2125,7 @@ If you have no Meta key, you may instead type ESC 
followed by the character.)"))
   (insert "\t\t")
   (insert-button "Open *scratch* buffer"
                 'action (lambda (_button) (switch-to-buffer
-                                       (get-buffer-create "*scratch*")))
+                                       (startup--get-buffer-create-scratch)))
                 'follow-link t)
   (insert "\n")
   (insert "\n" (emacs-version) "\n" emacs-copyright "\n")
@@ -2244,6 +2251,13 @@ A fancy display is used on graphic displays, normal 
otherwise."
 (defalias 'about-emacs 'display-about-screen)
 (defalias 'display-splash-screen 'display-startup-screen)
 
+(defun startup--get-buffer-create-scratch ()
+  (or (get-buffer "*scratch*")
+      (with-current-buffer (get-buffer-create "*scratch*")
+        (set-buffer-major-mode (current-buffer))
+        (setq-local lexical-binding t)
+        (current-buffer))))
+
 (defun command-line-1 (args-left)
   "A subroutine of `command-line'."
   (display-startup-echo-area-message)
@@ -2393,7 +2407,7 @@ nil default-directory" name)
                        (unless (= end (length str-expr))
                          (error "Trailing garbage following expression: %s"
                                 (substring str-expr end)))
-                       (eval expr)))
+                       (eval expr t)))
 
                     ((member argi '("-L" "-directory"))
                      ;; -L :/foo adds /foo to the _end_ of load-path.
@@ -2508,7 +2522,7 @@ nil default-directory" name)
     (when (eq initial-buffer-choice t)
       ;; When `initial-buffer-choice' equals t make sure that *scratch*
       ;; exists.
-      (get-buffer-create "*scratch*"))
+      (startup--get-buffer-create-scratch))
 
     ;; If *scratch* exists and is empty, insert initial-scratch-message.
     ;; Do this before switching to *scratch* below to handle bug#9605.
@@ -2532,7 +2546,7 @@ nil default-directory" name)
                   ((functionp initial-buffer-choice)
                    (funcall initial-buffer-choice))
                    ((eq initial-buffer-choice t)
-                    (get-buffer-create "*scratch*"))
+                    (startup--get-buffer-create-scratch))
                    (t
                     (error "`initial-buffer-choice' must be a string, a 
function, or t")))))
         (unless (buffer-live-p buf)
diff --git a/lisp/strokes.el b/lisp/strokes.el
index d5c287c..9265b8a 100644
--- a/lisp/strokes.el
+++ b/lisp/strokes.el
@@ -1,6 +1,6 @@
 ;;; strokes.el --- control Emacs through mouse strokes
 
-;; Copyright (C) 1997, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: David Bakhash <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/subr.el b/lisp/subr.el
index d3bc007..f68f9dd 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1,6 +1,6 @@
 ;;; subr.el --- basic lisp subroutines for Emacs  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1985-1986, 1992, 1994-1995, 1999-2018 Free Software
+;; Copyright (C) 1985-1986, 1992, 1994-1995, 1999-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
@@ -118,6 +118,33 @@ BODY should be a list of Lisp expressions.
   ;; depend on backquote.el.
   (list 'function (cons 'lambda cdr)))
 
+(defmacro prog2 (form1 form2 &rest body)
+  "Eval FORM1, FORM2 and BODY sequentially; return value from FORM2.
+The value of FORM2 is saved during the evaluation of the
+remaining args, whose values are discarded."
+  (declare (indent 2) (debug t))
+  `(progn ,form1 (prog1 ,form2 ,@body)))
+
+(defmacro setq-default (&rest args)
+  "Set the default value of variable VAR to VALUE.
+VAR, the variable name, is literal (not evaluated);
+VALUE is an expression: it is evaluated and its value returned.
+The default value of a variable is seen in buffers
+that do not have their own values for the variable.
+
+More generally, you can use multiple variables and values, as in
+  (setq-default VAR VALUE VAR VALUE...)
+This sets each VAR's default value to the corresponding VALUE.
+The VALUE for the Nth VAR can refer to the new default values
+of previous VARs.
+
+\(fn [VAR VALUE]...)"
+  (declare (debug setq))
+  (let ((exps nil))
+    (while args
+      (push `(set-default ',(pop args) ,(pop args)) exps))
+    `(progn . ,(nreverse exps))))
+
 (defmacro setq-local (var val)
   "Set variable VAR to value VAL in current buffer."
   ;; Can't use backquote here, it's too early in the bootstrap.
@@ -553,6 +580,7 @@ i.e., subtract 2 * most-negative-fixnum from VALUE before 
shifting it."
 If LIST is nil, return nil.
 If N is non-nil, return the Nth-to-last link of LIST.
 If N is bigger than the length of LIST, return LIST."
+  (declare (side-effect-free t))
   (if n
       (and (>= n 0)
            (let ((m (safe-length list)))
@@ -564,6 +592,7 @@ If N is bigger than the length of LIST, return LIST."
   "Return a copy of LIST with the last N elements removed.
 If N is omitted or nil, the last element is removed from the
 copy."
+  (declare (side-effect-free t))
   (if (and n (<= n 0)) list
     (nbutlast (copy-sequence list) n)))
 
@@ -577,6 +606,11 @@ If N is omitted or nil, remove the last element."
           (if (> n 0) (setcdr (nthcdr (- (1- m) n) list) nil))
           list))))
 
+;; The function's definition was moved to fns.c,
+;; but it's easier to set properties here.
+(put 'proper-list-p 'pure t)
+(put 'proper-list-p 'side-effect-free 'error-free)
+
 (defun delete-dups (list)
   "Destructively remove `equal' duplicates from LIST.
 Store the result in LIST and return it.  LIST must be a proper list.
@@ -694,6 +728,7 @@ If that is non-nil, the element matches; then 
`assoc-default'
 
 If no element matches, the value is nil.
 If TEST is omitted or nil, `equal' is used."
+  (declare (side-effect-free t))
   (let (found (tail alist) value)
     (while (and tail (not found))
       (let ((elt (car tail)))
@@ -707,6 +742,7 @@ If TEST is omitted or nil, `equal' is used."
 ELT must be a string.  Upper-case and lower-case letters are treated as equal.
 Unibyte strings are converted to multibyte for comparison.
 Non-strings in LIST are ignored."
+  (declare (side-effect-free t))
   (while (and list
              (not (and (stringp (car list))
                        (eq t (compare-strings elt 0 nil (car list) 0 nil t)))))
@@ -752,13 +788,35 @@ Elements of ALIST that are not conses are ignored."
   alist)
 
 (defun alist-get (key alist &optional default remove testfn)
-  "Return the value associated with KEY in ALIST.
+  "Find the first element of ALIST whose `car' equals KEY and return its `cdr'.
 If KEY is not found in ALIST, return DEFAULT.
-Use TESTFN to lookup in the alist if non-nil.  Otherwise, use `assq'.
+Equality with KEY is tested by TESTFN, defaulting to `eq'.
+
+You can use `alist-get' in PLACE expressions.  This will modify
+an existing association (more precisely, the first one if
+multiple exist), or add a new element to the beginning of ALIST,
+destructively modifying the list stored in ALIST.
+
+Example:
+
+   (setq foo '((a . 0)))
+   (setf (alist-get 'a foo) 1
+         (alist-get 'b foo) 2)
+
+   foo => ((b . 2) (a . 1))
+
 
-This is a generalized variable suitable for use with `setf'.
 When using it to set a value, optional argument REMOVE non-nil
-means to remove KEY from ALIST if the new value is `eql' to DEFAULT."
+means to remove KEY from ALIST if the new value is `eql' to
+DEFAULT (more precisely the first found association will be
+deleted from the alist).
+
+Example:
+
+  (setq foo '((a . 1) (b . 2)))
+  (setf (alist-get 'b foo nil 'remove) nil)
+
+  foo => ((a . 1))"
   (ignore remove) ;;Silence byte-compiler.
   (let ((x (if (not testfn)
                (assq key alist)
@@ -768,6 +826,7 @@ means to remove KEY from ALIST if the new value is `eql' to 
DEFAULT."
 (defun remove (elt seq)
   "Return a copy of SEQ with all occurrences of ELT removed.
 SEQ must be a list, vector, or string.  The comparison is done with `equal'."
+  (declare (side-effect-free t))
   (if (nlistp seq)
       ;; If SEQ isn't a list, there's no need to copy SEQ because
       ;; `delete' will return a new object.
@@ -778,6 +837,7 @@ SEQ must be a list, vector, or string.  The comparison is 
done with `equal'."
   "Return LIST with all occurrences of ELT removed.
 The comparison is done with `eq'.  Contrary to `delq', this does not use
 side-effects, and the argument LIST is not modified."
+  (declare (side-effect-free t))
   (while (and (eq elt (car list)) (setq list (cdr list))))
   (if (memq elt list)
       (delq elt (copy-sequence list))
@@ -1511,6 +1571,8 @@ be a list of the form returned by `event-start' and 
`event-end'."
 (make-obsolete-variable 'x-gtk-use-window-move nil "26.1")
 
 (defvaralias 'messages-buffer-max-lines 'message-log-max)
+(define-obsolete-variable-alias 'inhibit-null-byte-detection
+  'inhibit-nul-byte-detection "27.1")
 
 ;;;; Alternate names for functions - these are not being phased out.
 
@@ -3185,11 +3247,12 @@ discouraged."
   "Start a program in a subprocess.  Return the process object for it.
 Similar to `start-process-shell-command', but calls `start-file-process'."
   (declare (advertised-calling-convention (name buffer command) "23.1"))
-  (start-file-process
-   name buffer
-   (if (file-remote-p default-directory) "/bin/sh" shell-file-name)
-   (if (file-remote-p default-directory) "-c" shell-command-switch)
-   (mapconcat 'identity args " ")))
+  ;; On remote hosts, the local `shell-file-name' might be useless.
+  (with-connection-local-variables
+   (start-file-process
+    name buffer
+    shell-file-name shell-command-switch
+    (mapconcat 'identity args " "))))
 
 (defun call-process-shell-command (command &optional infile buffer display
                                           &rest args)
@@ -3230,11 +3293,11 @@ discouraged."
 Similar to `call-process-shell-command', but calls `process-file'."
   (declare (advertised-calling-convention
             (command &optional infile buffer display) "24.5"))
-  (process-file
-   (if (file-remote-p default-directory) "/bin/sh" shell-file-name)
-   infile buffer display
-   (if (file-remote-p default-directory) "-c" shell-command-switch)
-   (mapconcat 'identity (cons command args) " ")))
+  ;; On remote hosts, the local `shell-file-name' might be useless.
+  (with-connection-local-variables
+   (process-file
+    shell-file-name infile buffer display shell-command-switch
+    (mapconcat 'identity (cons command args) " "))))
 
 (defun call-shell-region (start end command &optional delete buffer)
   "Send text from START to END as input to an inferior shell running COMMAND.
@@ -3685,7 +3748,7 @@ the specified region.  It must not change
 `before-change-functions' or `after-change-functions'.
 
 Additionally, the buffer modifications of BODY are recorded on
-the buffer's undo list as a single \(apply ...) entry containing
+the buffer's undo list as a single (apply ...) entry containing
 the function `undo--wrap-and-run-primitive-undo'."
   (let ((old-bul buffer-undo-list)
        (end-marker (copy-marker end t))
@@ -3698,7 +3761,14 @@ the function `undo--wrap-and-run-primitive-undo'."
        (if (eq buffer-undo-list t)
            (setq result (funcall body))
          (let (;; (inhibit-modification-hooks t)
-                before-change-functions after-change-functions)
+                (before-change-functions
+                 ;; Ugly Hack: if the body uses syntax-ppss/syntax-propertize
+                 ;; (e.g. via a regexp-search or sexp-movement trigerring
+                 ;; on-the-fly syntax-propertize), make sure that this gets
+                 ;; properly refreshed after subsequent changes.
+                 (if (memq #'syntax-ppss-flush-cache before-change-functions)
+                     '(syntax-ppss-flush-cache)))
+                after-change-functions)
            (setq result (funcall body)))
          (let ((ap-elt
                 (list 'apply
@@ -3834,6 +3904,7 @@ Zero means the entire text matched by the whole regexp or 
whole string.
 STRING should be given if the last search was by `string-match' on STRING.
 If STRING is nil, the current buffer should be the same buffer
 the search/match was performed in."
+  (declare (side-effect-free t))
   (if (match-beginning num)
       (if string
          (substring string (match-beginning num) (match-end num))
@@ -3847,6 +3918,7 @@ Zero means the entire text matched by the whole regexp or 
whole string.
 STRING should be given if the last search was by `string-match' on STRING.
 If STRING is nil, the current buffer should be the same buffer
 the search/match was performed in."
+  (declare (side-effect-free t))
   (if (match-beginning num)
       (if string
          (substring-no-properties string (match-beginning num)
@@ -5035,7 +5107,7 @@ NEW-MESSAGE, if non-nil, sets a new message for the 
reporter."
         (enough-time-passed
          ;; See if enough time has passed since the last update.
          (or (not update-time)
-             (when (>= (float-time) update-time)
+             (when (time-less-p update-time nil)
                ;; Calculate time for the next update
                (aset parameters 0 (+ update-time (aref parameters 5)))))))
     (cond ((and min-value max-value)
@@ -5448,5 +5520,26 @@ This function is called from lisp/Makefile and 
leim/Makefile."
     (setq file (concat (substring file 1 2) ":" (substring file 2))))
   file)
 
+(defun flatten-tree (tree)
+  "Return a \"flattened\" copy of TREE.
+In other words, return a list of the non-nil terminal nodes, or
+leaves, of the tree of cons cells rooted at TREE.  Leaves in the
+returned list are in the same order as in TREE.
+
+\(flatten-tree \\='(1 (2 . 3) nil (4 5 (6)) 7))
+=> (1 2 3 4 5 6 7)"
+  (let (elems)
+    (while (consp tree)
+      (let ((elem (pop tree)))
+        (while (consp elem)
+          (push (cdr elem) tree)
+          (setq elem (car elem)))
+        (if elem (push elem elems))))
+    (if tree (push tree elems))
+    (nreverse elems)))
+
+;; Technically, `flatten-list' is a misnomer, but we provide it here
+;; for discoverability:
+(defalias 'flatten-list 'flatten-tree)
 
 ;;; subr.el ends here
diff --git a/lisp/svg.el b/lisp/svg.el
index 1178905..291b9a1 100644
--- a/lisp/svg.el
+++ b/lisp/svg.el
@@ -1,6 +1,6 @@
 ;;; svg.el --- SVG image creation functions -*- lexical-binding: t -*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: image
diff --git a/lisp/t-mouse.el b/lisp/t-mouse.el
index 3ad719d..14b292d 100644
--- a/lisp/t-mouse.el
+++ b/lisp/t-mouse.el
@@ -4,7 +4,7 @@
 ;; Maintainer: address@hidden
 ;; Keywords: mouse gpm linux
 
-;; Copyright (C) 1994-1995, 1998, 2006-2018 Free Software Foundation,
+;; Copyright (C) 1994-1995, 1998, 2006-2019 Free Software Foundation,
 ;; Inc.
 
 ;; This file is part of GNU Emacs.
diff --git a/lisp/tabify.el b/lisp/tabify.el
index 57eafc6..37cd8fb 100644
--- a/lisp/tabify.el
+++ b/lisp/tabify.el
@@ -1,6 +1,6 @@
 ;;; tabify.el --- tab conversion commands for Emacs
 
-;; Copyright (C) 1985, 1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Package: emacs
diff --git a/lisp/talk.el b/lisp/talk.el
index f6aae28..0b7d5db 100644
--- a/lisp/talk.el
+++ b/lisp/talk.el
@@ -1,6 +1,6 @@
 ;;; talk.el --- allow several users to talk to each other through Emacs
 
-;; Copyright (C) 1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: comm, frames
diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el
index cf4e53a..599da9a 100644
--- a/lisp/tar-mode.el
+++ b/lisp/tar-mode.el
@@ -1,6 +1,6 @@
 ;;; tar-mode.el --- simple editing of tar files from GNU Emacs
 
-;; Copyright (C) 1990-1991, 1993-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1990-1991, 1993-2019 Free Software Foundation, Inc.
 
 ;; Author: Jamie Zawinski <address@hidden>
 ;; Maintainer: address@hidden
@@ -95,6 +95,7 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl-lib))
+(require 'arc-mode)
 
 (defgroup tar nil
   "Simple editing of tar files."
@@ -931,6 +932,7 @@ actually appear on disk when you save the tar-file's 
buffer."
         (setq buffer-file-name new-buffer-file-name)
         (setq buffer-file-truename
               (abbreviate-file-name buffer-file-name))
+        (archive-try-jka-compr)       ;Pretty ugly hack :-(
         ;; Force buffer-file-coding-system to what
         ;; decode-coding-region actually used.
         (set-buffer-file-coding-system last-coding-system-used t)
diff --git a/lisp/tempo.el b/lisp/tempo.el
index 5d4dea5..28afbec 100644
--- a/lisp/tempo.el
+++ b/lisp/tempo.el
@@ -1,6 +1,6 @@
 ;;; tempo.el --- Flexible template insertion
 
-;; Copyright (C) 1994-1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: David Kågedal <address@hidden>
 ;; Created: 16 Feb 1994
diff --git a/lisp/term.el b/lisp/term.el
index 9f8f1f7..586a887 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -1,6 +1,6 @@
 ;;; term.el --- general command interpreter in a window stuff -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1988, 1990, 1992, 1994-1995, 2001-2018 Free Software
+;; Copyright (C) 1988, 1990, 1992, 1994-1995, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Per Bothner <address@hidden>
@@ -284,17 +284,6 @@
 ;; merge them into the master source.
 ;;     - Per Bothner (address@hidden)
 
-;; This file defines a general command-interpreter-in-a-buffer package
-;; (term mode).  The idea is that you can build specific process-in-a-buffer
-;; modes on top of term mode -- e.g., lisp, shell, scheme, T, soar, ....
-;; This way, all these specific packages share a common base functionality,
-;; and a common set of bindings, which makes them easier to use (and
-;; saves code, implementation time, etc., etc.).
-
-;; For hints on converting existing process modes (e.g., tex-mode,
-;; background, dbx, gdb, kermit, prolog, telnet) to use term-mode
-;; instead of shell-mode, see the notes at the end of this file.
-
 
 ;; Brief Command Documentation:
 ;;============================================================================
@@ -406,7 +395,9 @@ This emulates (more or less) the behavior of xterm.")
 (defvar term-pager-count nil
   "Number of lines before we need to page; if nil, paging is disabled.")
 (defvar term-saved-cursor nil)
-(defvar term-command-hook)
+(define-obsolete-variable-alias 'term-command-hook
+  'term-command-function "27.1")
+(defvar term-command-function #'term-command-hook)
 (defvar term-log-buffer nil)
 (defvar term-scroll-with-delete nil
   "If t, forward scrolling should be implemented by delete to
@@ -545,6 +536,8 @@ This means text can automatically reflow if the window is 
resized."
   :version "24.4"
   :type 'boolean
   :group 'term)
+(make-obsolete-variable 'term-suppress-hard-newline nil
+                        "27.1")
 
 ;; Where gud-display-frame should put the debugging arrow.  This is
 ;; set by the marker-filter, which scans the debugger's output for
@@ -579,7 +572,7 @@ These functions get one argument, a string containing the 
text to send.
 
 This variable is buffer-local.")
 
-(defvar term-input-sender (function term-simple-send)
+(defvar term-input-sender #'term-simple-send
   "Function to actually send to PROCESS the STRING submitted by user.
 Usually this is just `term-simple-send', but if your mode needs to
 massage the input string, this is your hook.  This is called from
@@ -1036,8 +1029,6 @@ Entry to this mode runs the hooks on `term-mode-hook'."
   (set (make-local-variable 'term-last-input-start) (make-marker))
   (set (make-local-variable 'term-last-input-end) (make-marker))
   (set (make-local-variable 'term-last-input-match) "")
-  (set (make-local-variable 'term-command-hook)
-       (symbol-function 'term-command-hook))
 
   ;; These local variables are set to their local values:
   (make-local-variable 'term-saved-home-marker)
@@ -1091,21 +1082,18 @@ Entry to this mode runs the hooks on `term-mode-hook'."
   (make-local-variable 'term-pager-old-local-map)
   (make-local-variable 'term-old-mode-map)
   (make-local-variable 'term-insert-mode)
-  (make-local-variable 'term-dynamic-complete-functions)
   (make-local-variable 'term-completion-fignore)
   (make-local-variable 'term-get-old-input)
   (make-local-variable 'term-matching-input-from-input-string)
   (make-local-variable 'term-input-autoexpand)
   (make-local-variable 'term-input-ignoredups)
   (make-local-variable 'term-delimiter-argument-list)
-  (make-local-variable 'term-input-filter-functions)
   (make-local-variable 'term-input-filter)
   (make-local-variable 'term-input-sender)
   (make-local-variable 'term-eol-on-send)
   (make-local-variable 'term-scroll-to-bottom-on-output)
   (make-local-variable 'term-scroll-show-maximum-output)
   (make-local-variable 'term-ptyp)
-  (make-local-variable 'term-exec-hook)
   (set (make-local-variable 'term-vertical-motion) 'vertical-motion)
   (set (make-local-variable 'term-pending-delete-marker) (make-marker))
   (make-local-variable 'term-current-face)
@@ -1117,6 +1105,9 @@ Entry to this mode runs the hooks on `term-mode-hook'."
   (set (make-local-variable 'font-lock-defaults) '(nil t))
 
   (add-function :filter-return
+                (local 'filter-buffer-substring-function)
+                #'term--filter-buffer-substring)
+  (add-function :filter-return
                 (local 'window-adjust-process-window-size-function)
                 (lambda (size)
                   (when size
@@ -1132,9 +1123,51 @@ Entry to this mode runs the hooks on `term-mode-hook'."
       (setq term-input-ring (make-ring term-input-ring-size)))
   (term-update-mode-line))
 
+(defun term--remove-fake-newlines ()
+  (goto-char (point-min))
+  (let (fake-newline)
+    (while (setq fake-newline (next-single-property-change (point)
+                                                           'term-line-wrap))
+      (goto-char fake-newline)
+      (cl-assert (eq ?\n (char-after)))
+      (let ((inhibit-read-only t))
+        (delete-char 1)))))
+
+(defun term--filter-buffer-substring (content)
+  (with-temp-buffer
+    (insert content)
+    (term--remove-fake-newlines)
+    (buffer-string)))
+
+(defun term--unwrap-visible-long-lines (width)
+  ;; Unwrap lines longer than width using fake newlines.  Only do it
+  ;; for lines that are currently visible (i.e. following the home
+  ;; marker).  Invisible lines don't have to be unwrapped since they
+  ;; are unreachable using the cursor movement anyway.  Not having to
+  ;; unwrap the entire buffer means the runtime of this function is
+  ;; bounded by the size of the screen instead of the buffer size.
+
+  (save-excursion
+    ;; We will just assume that our accounting for the home marker is
+    ;; correct, i.e. programs will not try to reach any position
+    ;; earlier than this marker.
+    (goto-char term-home-marker)
+
+    (move-to-column width)
+    (while (not (eobp))
+      (if (eolp)
+          (forward-char)
+        (let ((inhibit-read-only t))
+          (term-unwrap-line)))
+      (move-to-column width))))
+
 (defun term-reset-size (height width)
   (when (or (/= height term-height)
             (/= width term-width))
+    ;; Delete all newlines used for wrapping
+    (when (/= width term-width)
+      (save-excursion
+        (term--remove-fake-newlines)))
     (let ((point (point)))
       (setq term-height height)
       (setq term-width width)
@@ -1147,7 +1180,8 @@ Entry to this mode runs the hooks on `term-mode-hook'."
       (setq term-start-line-column nil)
       (setq term-current-row nil)
       (setq term-current-column nil)
-      (goto-char point))))
+      (goto-char point))
+    (term--unwrap-visible-long-lines width)))
 
 ;; Recursive routine used to check if any string in term-kill-echo-list
 ;; matches part of the buffer before point.
@@ -1280,16 +1314,14 @@ intervention from Emacs, except for the escape 
character (usually C-c)."
     (add-hook 'post-command-hook #'term-goto-process-mark-maybe nil t)
 
     ;; Send existing partial line to inferior (without newline).
-    (let ((pmark (process-mark (get-buffer-process (current-buffer))))
-         (save-input-sender term-input-sender))
+    (let ((pmark (process-mark (get-buffer-process (current-buffer)))))
       (when (> (point) pmark)
        (unwind-protect
            (progn
-             (setq term-input-sender
-                   (symbol-function 'term-send-string))
+             (add-function :override term-input-sender #'term-send-string)
              (end-of-line)
              (term-send-input))
-         (setq term-input-sender save-input-sender))))
+         (remove-function term-input-sender #'term-send-string))))
     (term-update-mode-line)))
 
 (defun term-line-mode  ()
@@ -1419,8 +1451,8 @@ buffer.  The hook `term-exec-hook' is run after each 
exec."
       ;; Jump to the end, and set the process mark.
       (goto-char (point-max))
       (set-marker (process-mark proc) (point))
-      (set-process-filter proc 'term-emulate-terminal)
-      (set-process-sentinel proc 'term-sentinel)
+      (set-process-filter proc #'term-emulate-terminal)
+      (set-process-sentinel proc #'term-sentinel)
       ;; Feed it the startfile.
       (when startfile
         ;;This is guaranteed to wait long enough
@@ -1549,7 +1581,7 @@ Nil if unknown.")
     (when (term--bash-needs-EMACSp)
       (push (format "EMACS=%s (term:%s)" emacs-version term-protocol-version)
             process-environment))
-    (apply 'start-process name buffer
+    (apply #'start-process name buffer
           "/bin/sh" "-c"
           (format "stty -nl echo rows %d columns %d sane 2>/dev/null;\
 if [ $1 = .. ]; then shift; fi; exec \"address@hidden""
@@ -1952,8 +1984,8 @@ A useful command to bind to SPC.  See 
`term-replace-by-expanded-history'."
 (defun term-within-quotes (beg end)
   "Return t if the number of quotes between BEG and END is odd.
 Quotes are single and double."
-  (let ((countsq (term-how-many-region "\\(^\\|[^\\\\]\\)'" beg end))
-       (countdq (term-how-many-region "\\(^\\|[^\\\\]\\)\"" beg end)))
+  (let ((countsq (term-how-many-region "\\(^\\|[^\\]\\)'" beg end))
+       (countdq (term-how-many-region "\\(^\\|[^\\]\\)\"" beg end)))
     (or (= (mod countsq 2) 1) (= (mod countdq 2) 1))))
 
 (defun term-how-many-region (regexp beg end)
@@ -2043,7 +2075,7 @@ Argument 0 is the command name."
     (let ((n (or nth (1- count)))
          (m (if mth (1- (- count mth)) 0)))
       (mapconcat
-       (function (lambda (a) a)) (nthcdr n (nreverse (nthcdr m args))) " "))))
+       #'identity (nthcdr n (nreverse (nthcdr m args))) " "))))
 
 ;;;
 ;;; Input processing stuff [line mode]
@@ -2123,10 +2155,7 @@ Similarly for Soar, Scheme, etc."
                       (not (string-equal (ring-ref term-input-ring 0)
                                          history))))
          (ring-insert term-input-ring history))
-       (let ((functions term-input-filter-functions))
-         (while functions
-           (funcall (car functions) (concat input "\n"))
-           (setq functions (cdr functions))))
+        (run-hook-with-args 'term-input-filter-functions (concat input "\n"))
        (setq term-input-ring-index nil)
 
        ;; Update the markers before we send the input
@@ -2906,6 +2935,7 @@ See `term-prompt-regexp'."
                       (delete-region (point) (line-end-position))
                       (term-down 1 t)
                       (term-move-columns (- (term-current-column)))
+                      (put-text-property (1- (point)) (point) 'term-line-wrap 
t)
                       (setq decoded-substring
                             (substring decoded-substring (- term-width 
old-column)))
                       (setq old-column 0)))
@@ -2960,7 +2990,7 @@ See `term-prompt-regexp'."
                 (?\C-g                  ;; (terminfo: bel)
                  (beep t))
                 (?\032 ; Emacs specific control sequence.
-                 (funcall term-command-hook
+                 (funcall term-command-function
                           (decode-coding-string
                            (substring str (1+ i)
                                       (- ctl-end
@@ -3054,8 +3084,10 @@ See `term-prompt-regexp'."
                         (setq term-terminal-undecoded-bytes (substring str (1- 
i)))
                         (aset term-terminal-undecoded-bytes 0 ?\r))
                       (goto-char (point-max)))
+                    ;; FIXME: Use (add-function :override (process-filter proc)
                     (make-local-variable 'term-pager-old-filter)
                     (setq term-pager-old-filter (process-filter proc))
+                    ;; FIXME: Where is `term-pager-filter' set to a function?!
                     (set-process-filter proc term-pager-filter)
                     (setq i str-length))
                 (setq i ctl-end)))))
@@ -3437,7 +3469,7 @@ The top-most line is line 0."
 ;;     (setq term-current-row 0)
 ;;     (term-goto row col))))
 
-;; Default value for the symbol term-command-hook.
+;; Default value for the symbol term-command-function.
 
 (defun term-command-hook (string)
   (cond ((equal string "")
@@ -3719,7 +3751,10 @@ all pending output has been dealt with."))
 ;; if the line above point wraps around, add a ?\n to undo the wrapping.
 ;; FIXME:  Probably should be called more than it is.
 (defun term-unwrap-line ()
-  (when (not (bolp)) (insert-before-markers ?\n)))
+  (when (not (bolp))
+    (let ((old-point (point)))
+      (insert-before-markers ?\n)
+      (put-text-property old-point (point) 'term-line-wrap t))))
 
 (defun term-erase-in-line (kind)
   (when (= kind 1) ;; erase left of point
@@ -3988,9 +4023,7 @@ Calls the functions in `term-dynamic-complete-functions' 
to perform
 completion until a function returns non-nil, at which point completion is
 assumed to have occurred."
   (interactive)
-  (let ((functions term-dynamic-complete-functions))
-    (while (and functions (null (funcall (car functions))))
-      (setq functions (cdr functions)))))
+  (run-hook-with-args-until-success 'term-dynamic-complete-functions))
 
 
 (defun term-dynamic-complete-filename ()
@@ -4090,7 +4123,6 @@ Returns `listed' if a completion listing was shown.
 See also `term-dynamic-complete-filename'."
   (declare (obsolete completion-in-region "23.2"))
   (let* ((completion-ignore-case nil)
-        (candidates (mapcar (function (lambda (x) (list x))) candidates))
         (completions (all-completions stub candidates)))
     (cond ((null completions)
           (message "No completions of %s" stub)
@@ -4315,9 +4347,9 @@ well as the newer ports COM10 and higher."
       (setq serial-name-history file-name-history))
     (when (or (null x) (and (stringp x) (zerop (length x))))
       (error "No serial port selected"))
-    (when (and (not (serial-port-is-file-p))
-               (not (string-match "\\\\" x)))
-      (set 'x (concat "\\\\.\\" x)))
+    (when (not (or (serial-port-is-file-p)
+                   (string-match "\\\\" x)))
+      (setq x (concat "\\\\.\\" x)))
     x))
 
 (defun serial-read-speed ()
@@ -4371,8 +4403,8 @@ use in that buffer.
       (term-char-mode)
       (goto-char (point-max))
       (set-marker (process-mark process) (point))
-      (set-process-filter process 'term-emulate-terminal)
-      (set-process-sentinel process 'term-sentinel))
+      (set-process-filter process #'term-emulate-terminal)
+      (set-process-sentinel process #'term-sentinel))
     (switch-to-buffer buffer)
     buffer))
 
@@ -4509,27 +4541,19 @@ The return value may be nil for a special serial port."
 ;; term-mode will take care of it.  The following example, from shell.el,
 ;; is typical:
 ;;
-;; (defvar shell-mode-map '())
-;; (cond ((not shell-mode-map)
-;;        (setq shell-mode-map (copy-keymap term-mode-map))
-;;        (define-key shell-mode-map "\C-c\C-f" 'shell-forward-command)
-;;        (define-key shell-mode-map "\C-c\C-b" 'shell-backward-command)
-;;        (define-key shell-mode-map "\t" 'term-dynamic-complete)
-;;        (define-key shell-mode-map "\M-?"
-;;          'term-dynamic-list-filename-completions)))
-;;
-;; (defun shell-mode ()
-;;   (interactive)
-;;   (term-mode)
-;;   (setq term-prompt-regexp shell-prompt-pattern)
-;;   (setq major-mode 'shell-mode)
-;;   (setq mode-name "Shell")
-;;   (use-local-map shell-mode-map)
-;;   (make-local-variable 'shell-directory-stack)
-;;   (setq shell-directory-stack nil)
-;;   (add-hook 'term-input-filter-functions 'shell-directory-tracker)
-;;   (run-mode-hooks 'shell-mode-hook))
+;; (defvar shell-mode-map
+;;   (let ((map (make-sparse-keymap)))
+;;     (define-key map "\C-c\C-f" 'shell-forward-command)
+;;     (define-key map "\C-c\C-b" 'shell-backward-command)
+;;     (define-key map "\t" 'term-dynamic-complete)
+;;     (define-key map "\M-?"
+;;       'term-dynamic-list-filename-completions)))
 ;;
+;; (define-derived-mode shell-mode term-mode "Shell"
+;;   "A shell mode."
+;;   (setq-local term-prompt-regexp shell-prompt-pattern)
+;;   (setq-local shell-directory-stack nil)
+;;   (add-hook 'term-input-filter-functions #'shell-directory-tracker nil t))
 ;;
 ;; Completion for term-mode users
 ;;
diff --git a/lisp/term/AT386.el b/lisp/term/AT386.el
index cc6c5ca..b0cb953 100644
--- a/lisp/term/AT386.el
+++ b/lisp/term/AT386.el
@@ -1,6 +1,6 @@
 ;;; AT386.el --- terminal support package for IBM AT keyboards
 
-;; Copyright (C) 1992, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric S. Raymond <address@hidden>
 ;; Keywords: terminals
diff --git a/lisp/term/README b/lisp/term/README
index 4ab1a43..a9b131c 100644
--- a/lisp/term/README
+++ b/lisp/term/README
@@ -1,4 +1,4 @@
-Copyright (C) 1993, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1993, 2001-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 
diff --git a/lisp/term/common-win.el b/lisp/term/common-win.el
index a482067..b7a778f 100644
--- a/lisp/term/common-win.el
+++ b/lisp/term/common-win.el
@@ -1,6 +1,6 @@
 ;;; common-win.el --- common part of handling window systems
 
-;; Copyright (C) 1993-1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: terminals
diff --git a/lisp/term/internal.el b/lisp/term/internal.el
index 0cdf0c1..396521d 100644
--- a/lisp/term/internal.el
+++ b/lisp/term/internal.el
@@ -1,6 +1,6 @@
 ;;; internal.el --- support for PC internal terminal
 
-;; Copyright (C) 1993-1994, 1998-1999, 2001-2018 Free Software
+;; Copyright (C) 1993-1994, 1998-1999, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Morten Welinder <address@hidden>
diff --git a/lisp/term/iris-ansi.el b/lisp/term/iris-ansi.el
index eb882da..23c6768 100644
--- a/lisp/term/iris-ansi.el
+++ b/lisp/term/iris-ansi.el
@@ -1,6 +1,6 @@
 ;;; iris-ansi.el --- configure Emacs for SGI xwsh and winterm apps
 
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Dan Nicolaescu <address@hidden>
 
diff --git a/lisp/term/konsole.el b/lisp/term/konsole.el
index 86a2150..f2186ae 100644
--- a/lisp/term/konsole.el
+++ b/lisp/term/konsole.el
@@ -1,5 +1,5 @@
 ;;; konsole.el --- terminal initialization for konsole
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 (require 'term/xterm)
 
diff --git a/lisp/term/news.el b/lisp/term/news.el
index 7cbbde4..7ef80a5 100644
--- a/lisp/term/news.el
+++ b/lisp/term/news.el
@@ -1,6 +1,6 @@
 ;;; news.el --- keypad and function key bindings for the Sony NEWS keyboard
 
-;; Copyright (C) 1989, 1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1989, 1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: FSF
 ;; Keywords: terminals
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el
index 09bbc7b..6a668b2 100644
--- a/lisp/term/ns-win.el
+++ b/lisp/term/ns-win.el
@@ -1,6 +1,6 @@
 ;;; ns-win.el --- lisp side of interface with NeXT/Open/GNUstep/macOS window 
system  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1993-1994, 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1994, 2005-2019 Free Software Foundation, Inc.
 
 ;; Authors: Carl Edman
 ;;     Christian Limpach
@@ -501,48 +501,38 @@ unless the current buffer is a scratch buffer."
       (find-file f)))))
 
 
-(defun ns-drag-n-drop (event &optional new-frame force-text)
+(defun ns-drag-n-drop (event)
   "Edit the files listed in the drag-n-drop EVENT.
-Switch to a buffer editing the last file dropped."
+Switch to a buffer editing the last file dropped, or insert the
+string dropped into the current buffer."
   (interactive "e")
   (let* ((window (posn-window (event-start event)))
          (arg (car (cdr (cdr event))))
          (type (car arg))
-         (data (car (cdr arg)))
-         (url-or-string (cond ((eq type 'file)
-                               (concat "file:" data))
-                              (t data))))
+         (operations (car (cdr arg)))
+         (objects (cdr (cdr arg)))
+         (string (mapconcat 'identity objects "\n")))
     (set-frame-selected-window nil window)
-    (when new-frame
-      (select-frame (make-frame)))
     (raise-frame)
     (setq window (selected-window))
-    (if force-text
-        (dnd-insert-text window 'private data)
-      (dnd-handle-one-url window 'private url-or-string))))
-
-
-(defun ns-drag-n-drop-other-frame (event)
-  "Edit the files listed in the drag-n-drop EVENT, in other frames.
-May create new frames, or reuse existing ones.  The frame editing
-the last file dropped is selected."
-  (interactive "e")
-  (ns-drag-n-drop event t))
-
-(defun ns-drag-n-drop-as-text (event)
-  "Drop the data in EVENT as text."
-  (interactive "e")
-  (ns-drag-n-drop event nil t))
-
-(defun ns-drag-n-drop-as-text-other-frame (event)
-  "Drop the data in EVENT as text in a new frame."
-  (interactive "e")
-  (ns-drag-n-drop event t t))
+    (cond ((memq 'ns-drag-operation-generic operations)
+           ;; Perform the default action for the type.
+           (if (eq type 'file)
+               (dolist (data objects)
+                 (dnd-handle-one-url window 'private (concat "file:" data)))
+             (dnd-insert-text window 'private string)))
+          ((memq 'ns-drag-operation-copy operations)
+           ;; Try to open the file/URL.  If type is nil, try to open
+           ;; it as a URL anyway.
+           (dolist (data objects)
+             (dnd-handle-one-url window 'private (if (eq type 'file)
+                                                     (concat "file:" data)
+                                                   data))))
+          (t
+           ;; Insert the text as is.
+           (dnd-insert-text window 'private string)))))
 
 (global-set-key [drag-n-drop] 'ns-drag-n-drop)
-(global-set-key [C-drag-n-drop] 'ns-drag-n-drop-other-frame)
-(global-set-key [M-drag-n-drop] 'ns-drag-n-drop-as-text)
-(global-set-key [C-M-drag-n-drop] 'ns-drag-n-drop-as-text-other-frame)
 
 ;;;; Frame-related functions.
 
diff --git a/lisp/term/pc-win.el b/lisp/term/pc-win.el
index e0e412e..0927599 100644
--- a/lisp/term/pc-win.el
+++ b/lisp/term/pc-win.el
@@ -1,6 +1,6 @@
 ;;; pc-win.el --- setup support for `PC windows' (whatever that is)  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1994, 1996-1997, 1999, 2001-2018 Free Software
+;; Copyright (C) 1994, 1996-1997, 1999, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Morten Welinder <address@hidden>
diff --git a/lisp/term/rxvt.el b/lisp/term/rxvt.el
index 870282a..8376e5a 100644
--- a/lisp/term/rxvt.el
+++ b/lisp/term/rxvt.el
@@ -1,6 +1,6 @@
 ;;; rxvt.el --- define function key sequences and standard colors for rxvt
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Eli Zaretskii
 ;; Keywords: terminals
diff --git a/lisp/term/screen.el b/lisp/term/screen.el
index dffcb0b..bb74901 100644
--- a/lisp/term/screen.el
+++ b/lisp/term/screen.el
@@ -1,5 +1,5 @@
 ;;; screen.el --- terminal initialization for screen and tmux  -*- 
lexical-binding: t -*-
-;; Copyright (C) 1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 2001-2019 Free Software Foundation, Inc.
 
 (require 'term/xterm)
 
diff --git a/lisp/term/sun.el b/lisp/term/sun.el
index 34ed492..c9f531e 100644
--- a/lisp/term/sun.el
+++ b/lisp/term/sun.el
@@ -1,6 +1,6 @@
 ;;; sun.el --- keybinding for standard default sunterm keys
 
-;; Copyright (C) 1987, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1987, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Jeff Peck <address@hidden>
 ;; Keywords: terminals
diff --git a/lisp/term/tmux.el b/lisp/term/tmux.el
index ca21d5e..c6c2244 100644
--- a/lisp/term/tmux.el
+++ b/lisp/term/tmux.el
@@ -1,5 +1,5 @@
 ;;; tmux.el --- terminal initialization for tmux  -*- lexical-binding: t -*-
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 (require 'term/xterm)
 
diff --git a/lisp/term/tty-colors.el b/lisp/term/tty-colors.el
index d9b2726..307586f 100644
--- a/lisp/term/tty-colors.el
+++ b/lisp/term/tty-colors.el
@@ -1,6 +1,6 @@
 ;;; tty-colors.el --- color support for character terminals
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Eli Zaretskii
 ;; Maintainer: address@hidden
diff --git a/lisp/term/tvi970.el b/lisp/term/tvi970.el
index 0c4b0ae..3b74848 100644
--- a/lisp/term/tvi970.el
+++ b/lisp/term/tvi970.el
@@ -1,6 +1,6 @@
 ;;; tvi970.el --- terminal support for the Televideo 970
 
-;; Copyright (C) 1992, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Jim Blandy <address@hidden>
 ;; Keywords: terminals
diff --git a/lisp/term/vt100.el b/lisp/term/vt100.el
index b61e557..81843ce 100644
--- a/lisp/term/vt100.el
+++ b/lisp/term/vt100.el
@@ -1,6 +1,6 @@
 ;;; vt100.el --- define VT100 function key sequences in function-key-map
 
-;; Copyright (C) 1989, 1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1989, 1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: FSF
 ;; Keywords: terminals
diff --git a/lisp/term/w32-win.el b/lisp/term/w32-win.el
index dc57160..beb7425 100644
--- a/lisp/term/w32-win.el
+++ b/lisp/term/w32-win.el
@@ -1,6 +1,6 @@
 ;;; w32-win.el --- parse switches controlling interface with W32 window system 
-*- lexical-binding: t -*-
 
-;; Copyright (C) 1993-1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Kevin Gallo
 ;; Keywords: terminals
diff --git a/lisp/term/w32console.el b/lisp/term/w32console.el
index 75d68f8..fe75145 100644
--- a/lisp/term/w32console.el
+++ b/lisp/term/w32console.el
@@ -1,6 +1,6 @@
 ;;; w32console.el -- Setup w32 console keys and colors.
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: FSF
 ;; Keywords: terminals
diff --git a/lisp/term/wyse50.el b/lisp/term/wyse50.el
index 7e29828..17f87eb 100644
--- a/lisp/term/wyse50.el
+++ b/lisp/term/wyse50.el
@@ -1,6 +1,6 @@
 ;;; wyse50.el --- terminal support code for Wyse 50
 
-;; Copyright (C) 1989, 1993-1994, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1989, 1993-1994, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Daniel Pfeiffer <address@hidden>,
diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el
index f169b27..5606137 100644
--- a/lisp/term/x-win.el
+++ b/lisp/term/x-win.el
@@ -1,6 +1,6 @@
 ;;; x-win.el --- parse relevant switches and set up for X  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1993-1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: FSF
 ;; Keywords: terminals, i18n
diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el
index 00747af..c4b0a8f 100644
--- a/lisp/term/xterm.el
+++ b/lisp/term/xterm.el
@@ -1,6 +1,6 @@
 ;;; xterm.el --- define function key sequences and standard colors for xterm  
-*- lexical-binding: t -*-
 
-;; Copyright (C) 1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: FSF
 ;; Keywords: terminals
@@ -767,13 +767,15 @@ Can be nil to mean \"no timeout\".")
 By not redisplaying right away for xterm queries, we can avoid
 unsightly flashing during initialization. Give up and redisplay
 anyway if we've been waiting a little while."
-  (let ((start-time (float-time)))
+  (let ((start-time (current-time)))
     (or (let ((inhibit-redisplay t))
           (read-event nil nil xterm-query-redisplay-timeout))
         (read-event nil nil
                     (and xterm-query-timeout
-                         (max 0 (+ start-time xterm-query-timeout
-                                   (- (float-time)))))))))
+                        (max 0 (float-time
+                                (time-subtract
+                                 xterm-query-timeout
+                                 (time-since start-time)))))))))
 
 (defun xterm--query (query handlers &optional no-async)
   "Send QUERY string to the terminal and watch for a response.
diff --git a/lisp/textmodes/artist.el b/lisp/textmodes/artist.el
index 940a78a..e9b1779 100644
--- a/lisp/textmodes/artist.el
+++ b/lisp/textmodes/artist.el
@@ -1,6 +1,6 @@
 ;;; artist.el --- draw ascii graphics with your mouse
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author:       Tomas Abrahamsson <address@hidden>
 ;; Maintainer:   Tomas Abrahamsson <address@hidden>
@@ -2895,7 +2895,7 @@ Returns a list of strings."
        dir-list)
       (mapcar
        (lambda (file)
-         (replace-regexp-in-string "\.flf\\'" "" file))
+         (replace-regexp-in-string "\\.flf\\'" "" file))
        result))))
 
 (defun artist-figlet-choose-font ()
diff --git a/lisp/textmodes/bib-mode.el b/lisp/textmodes/bib-mode.el
index 403d00f..7a5d3ef 100644
--- a/lisp/textmodes/bib-mode.el
+++ b/lisp/textmodes/bib-mode.el
@@ -1,6 +1,6 @@
 ;;; bib-mode.el --- major mode for editing bib files
 
-;; Copyright (C) 1989, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1989, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Henry Kautz
 ;; (according to authors.el)
@@ -198,7 +198,7 @@ named by variable `unread-bib-file'."
 
 (defvar bib-capitalize-title-stop-words
    (concat
-      "the\\|and\\|of\\|is\\|a\\|an\\|of\\|for\\|in\\|to\\|in\\|on\\|at\\|"
+      "the\\|and\\|of\\|is\\|a\\|an\\|for\\|in\\|to\\|on\\|at\\|"
       "by\\|with\\|that\\|its")
    "Words not to be capitalized in a title (unless the first word).")
 
diff --git a/lisp/textmodes/bibtex-style.el b/lisp/textmodes/bibtex-style.el
index 9515c39..badbb2a 100644
--- a/lisp/textmodes/bibtex-style.el
+++ b/lisp/textmodes/bibtex-style.el
@@ -1,6 +1,6 @@
 ;;; bibtex-style.el --- Major mode for BibTeX Style files -*- lexical-binding: 
t -*-
 
-;; Copyright (C) 2005, 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords: tex
diff --git a/lisp/textmodes/bibtex.el b/lisp/textmodes/bibtex.el
index eec4042..a560c2b 100644
--- a/lisp/textmodes/bibtex.el
+++ b/lisp/textmodes/bibtex.el
@@ -1,6 +1,6 @@
 ;;; bibtex.el --- BibTeX mode for GNU Emacs -*- lexical-binding: t -*-
 
-;; Copyright (C) 1992, 1994-1999, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1992, 1994-1999, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Stefan Schoef <address@hidden>
diff --git a/lisp/textmodes/conf-mode.el b/lisp/textmodes/conf-mode.el
index 0363b92..ad9f60f 100644
--- a/lisp/textmodes/conf-mode.el
+++ b/lisp/textmodes/conf-mode.el
@@ -1,6 +1,6 @@
-;;; conf-mode.el --- Simple major mode for editing conf/ini/properties files
+;;; conf-mode.el --- Simple major mode for editing conf/ini/properties files  
-*- lexical-binding: t; -*-
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Daniel Pfeiffer <address@hidden>
 ;; Keywords: conf ini windows java
@@ -281,10 +281,10 @@ whitespace.")
 ;; If anybody can figure out how to get the same effect by configuring
 ;; `align', I'd be glad to hear.
 (defun conf-align-assignments (&optional arg)
-  (interactive "P")
   "Align the assignments in the buffer or active region.
 In Transient Mark mode, if the mark is active, operate on the
 contents of the region.  Otherwise, operate on the whole buffer."
+  (interactive "P")
   (setq arg (if arg
                (prefix-numeric-value arg)
              conf-assignment-column))
@@ -323,7 +323,7 @@ contents of the region.  Otherwise, operate on the whole 
buffer."
 
 (defun conf-quote-normal (arg)
   "Set the syntax of \\=' and \" to punctuation.
-With prefix arg, only do it for \\=' if 1, or only for \" if 2.
+With prefix ARG, only do it for \\=' if 1, or only for \" if 2.
 This only affects the current buffer.  Some conf files use quotes
 to delimit strings, while others allow quotes as simple parts of
 the assigned value.  In those files font locking will be wrong,
@@ -442,7 +442,7 @@ See also `conf-space-mode', `conf-colon-mode', 
`conf-javaprop-mode',
     (run-mode-hooks 'conf-mode-hook)))
 
 (defun conf-mode-initialize (comment &optional font-lock)
-  "Initializations for sub-modes of conf-mode.
+  "Initializations for sub-modes of `conf-mode'.
 COMMENT initializes `comment-start' and `comment-start-skip'.
 The optional arg FONT-LOCK is the value for FONT-LOCK-KEYWORDS."
   (set (make-local-variable 'comment-start) comment)
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el
index f87d621..11a77b5 100644
--- a/lisp/textmodes/css-mode.el
+++ b/lisp/textmodes/css-mode.el
@@ -1,6 +1,6 @@
 ;;; css-mode.el --- Major mode to edit CSS files  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Maintainer: Simen Heggestøyl <address@hidden>
@@ -892,7 +892,7 @@ cannot be completed sensibly: `custom-ident',
     (,(concat "@" css-ident-re) (0 font-lock-builtin-face))
     ;; Selectors.
     ;; Allow plain ":root" as a selector.
-    ("^[ \t]*\\(:root\\)\\(?:[\n \t]*\\)*{" (1 'css-selector keep))
+    ("^[ \t]*\\(:root\\)[\n \t]*{" (1 'css-selector keep))
     ;; FIXME: attribute selectors don't work well because they may contain
     ;; strings which have already been highlighted as f-l-string-face and
     ;; thus prevent this highlighting from being applied (actually now that
@@ -915,7 +915,7 @@ cannot be completed sensibly: `custom-ident',
        "\\(?:\\(:" (regexp-opt (append css-pseudo-class-ids
                                        css-pseudo-element-ids)
                                t)
-       "\\|\\::" (regexp-opt css-pseudo-element-ids t) "\\)"
+       "\\|::" (regexp-opt css-pseudo-element-ids t) "\\)"
        "\\(?:([^)]+)\\)?"
        (if (not sassy)
            "[^:{}()\n]*"
@@ -1557,7 +1557,7 @@ rgb()/rgba()."
         (prev nil))
     (dolist (sel selectors)
       (cond
-       ((seq-contains sel ?&)
+       ((seq-contains-p sel ?&)
         (setq sel (replace-regexp-in-string "&" prev sel))
         (pop processed))
        ;; Unless this is the first selector, separate this one and the
diff --git a/lisp/textmodes/dns-mode.el b/lisp/textmodes/dns-mode.el
index 87ae35d..1dbc7bd 100644
--- a/lisp/textmodes/dns-mode.el
+++ b/lisp/textmodes/dns-mode.el
@@ -1,6 +1,6 @@
 ;;; dns-mode.el --- a mode for viewing/editing Domain Name System master files
 
-;; Copyright (C) 2000-2001, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2001, 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <address@hidden>
 ;; Keywords: DNS master zone file SOA comm
@@ -114,9 +114,9 @@
                        "26.1" 'set)
 
 (defcustom dns-mode-font-lock-keywords
-  `((,(concat "^$" (regexp-opt dns-mode-control-entities))
+  `((,(concat "^\\$" (regexp-opt dns-mode-control-entities))
      0 ,dns-mode-control-entity-face)
-    ("^$[a-z0-9A-Z]+" 0 ,dns-mode-bad-control-entity-face)
+    ("^\\$[a-z0-9A-Z]+" 0 ,dns-mode-bad-control-entity-face)
     (,(regexp-opt dns-mode-classes) 0 ,dns-mode-class-face)
     (,(regexp-opt dns-mode-types) 0 ,dns-mode-type-face))
   "Font lock keywords used to highlight text in DNS master file mode."
@@ -292,9 +292,9 @@ Examples:
   (skip-syntax-backward " ")
   (skip-syntax-backward "w_.")
   (re-search-forward "\\([[:xdigit:]:]+\\)\\(/-?[0-9]\\{2,3\\}\\)?")
-  (kill-new (match-string 0))
   (let ((address (match-string 1))
         (prefix-length (match-string 2)))
+    (kill-new (match-string 0))
     (when prefix-length
       (setq prefix-length (string-to-number (substring prefix-length 1)))
       (if negate-prefix
diff --git a/lisp/textmodes/enriched.el b/lisp/textmodes/enriched.el
index f2065cb..e89ffea 100644
--- a/lisp/textmodes/enriched.el
+++ b/lisp/textmodes/enriched.el
@@ -1,6 +1,6 @@
 ;;; enriched.el --- read and save files in text/enriched format
 
-;; Copyright (C) 1994-1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1996, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Boris Goldowsky <address@hidden>
 ;; Keywords: wp, faces
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index 08e975f..c285491 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -1,6 +1,6 @@
 ;;; fill.el --- fill commands for Emacs
 
-;; Copyright (C) 1985-1986, 1992, 1994-1997, 1999, 2001-2018 Free
+;; Copyright (C) 1985-1986, 1992, 1994-1997, 1999, 2001-2019 Free
 ;; Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el
index 37f2245..d18916d 100644
--- a/lisp/textmodes/flyspell.el
+++ b/lisp/textmodes/flyspell.el
@@ -1,6 +1,6 @@
 ;;; flyspell.el --- On-the-fly spell checker  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Manuel Serrano <address@hidden>
 ;; Maintainer: address@hidden
@@ -929,7 +929,7 @@ Mostly we check word delimiters."
                           (or (string= "" ispell-otherchars)
                               (not (looking-at ispell-otherchars)))
                           (or flyspell-consider-dash-as-word-delimiter-flag
-                              (not (looking-at "\\-")))
+                              (not (looking-at "-")))
                           2)))))
        (format "  because    : %S\n"
                (cond
@@ -947,7 +947,7 @@ Mostly we check word delimiters."
                             (or (string= "" ispell-otherchars)
                                 (not (looking-at ispell-otherchars)))
                             (or flyspell-consider-dash-as-word-delimiter-flag
-                                (not (looking-at "\\-")))))))
+                                (not (looking-at "-")))))))
                  ;; Yes because we have reached or typed a word delimiter.
                  'separator)
                 ((not (integerp flyspell-delay))
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 6408f38..6553a27 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -1,6 +1,6 @@
 ;;; ispell.el --- interface to spell checkers  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1994-1995, 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1995, 1997-2019 Free Software Foundation, Inc.
 
 ;; Author:           Ken Stevens <address@hidden>
 
@@ -726,6 +726,7 @@ Otherwise returns the library directory name, if that is 
defined."
        ;; Make sure these variables are (re-)initialized to the default value
        (setq ispell-really-aspell nil
               ispell-really-hunspell nil
+              ispell-really-enchant nil
              ispell-encoding8-command nil)
 
        (goto-char (point-min))
@@ -1106,12 +1107,19 @@ dictionary from that list was found."
                                 null-device
                                 t
                                 nil
+                                 "-D"
+                                 ;; Use -a to prevent Hunspell from
+                                 ;; trying to initialize its
+                                 ;; curses/termcap UI, which causes it
+                                 ;; to crash or fail to start in some
+                                 ;; MS-Windows ports.
+                                 "-a"
                                  ;; Hunspell 1.7.0 (and later?) won't
                                  ;; show LOADED DICTIONARY unless
                                  ;; there's at least one file argument
                                  ;; on the command line.  So we feed
                                  ;; it with the null device.
-                                "-D" null-device)
+                                null-device)
            (buffer-string))
          "[\n\r]+"
          t))
@@ -1265,7 +1273,6 @@ aspell is used along with Emacs).")
 (defun ispell-set-spellchecker-params ()
   "Initialize some spellchecker parameters when changed or first used."
   (unless (eq ispell-last-program-name ispell-program-name)
-    (setq ispell-last-program-name ispell-program-name)
     (ispell-kill-ispell t)
     (if (and (condition-case ()
                 (progn
@@ -1380,7 +1387,8 @@ aspell is used along with Emacs).")
                            (nth 7 adict)))
                       adict)
                     tmp-dicts-alist :test #'equal))
-      (setq ispell-dictionary-alist tmp-dicts-alist))))
+      (setq ispell-dictionary-alist tmp-dicts-alist)))
+      (setq ispell-last-program-name ispell-program-name))
 
 (defun ispell-valid-dictionary-list ()
   "Return a list of valid dictionaries.
@@ -1782,11 +1790,15 @@ You can set this variable in hooks in your init file -- 
eg:
 
 
 (defun ispell-accept-output (&optional timeout-secs timeout-msecs)
-  "Wait for output from Ispell process, or TIMEOUT-SECS and TIMEOUT-MSECS.
+  "Wait for output from Ispell process, or for TIMEOUT-SECS + TIMEOUT-MSECS.
+\(The TIMEOUT-MSECS argument is obsolete and should be avoided.)
 If asynchronous subprocesses are not supported, call function `ispell-filter'
 and pass it the output of the last Ispell invocation."
   (if ispell-async-processp
-      (accept-process-output ispell-process timeout-secs timeout-msecs)
+      (let ((timeout (if timeout-msecs
+                        (+ (or timeout-secs 0) (/ timeout-msecs 1000.0))
+                      timeout-secs)))
+       (accept-process-output ispell-process timeout))
     (if (null ispell-process)
        (error "No Ispell process to read output from!")
       (let ((buf ispell-output-buffer)
@@ -3463,7 +3475,7 @@ Returns the sum SHIFT due to changes in word 
replacements."
             ;; Error in tex mode when a potential math mode change exists.
             (if (and replace (listp replace) (= 2 (length replace)))
                 (if (and (eq ispell-parser 'tex)
-                         (string-match "[\\\\][]()[]\\|\\\\begin\\|\\$"
+                         (string-match "[\\][]()[]\\|\\\\begin\\|\\$"
                                        (regexp-quote string)))
                     (error
                      "Don't start query replace on a line with math characters"
diff --git a/lisp/textmodes/less-css-mode.el b/lisp/textmodes/less-css-mode.el
index 1f9b24d..4077789 100644
--- a/lisp/textmodes/less-css-mode.el
+++ b/lisp/textmodes/less-css-mode.el
@@ -1,6 +1,6 @@
 ;;; less-css-mode.el --- Major mode for editing Less CSS files  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Steve Purcell <address@hidden>
 ;; Maintainer: Simen Heggestøyl <address@hidden>
@@ -194,10 +194,10 @@ directory by default."
 ;; - custom faces.
 (defconst less-css-font-lock-keywords
   '(;; Variables
-    ("@[a-z_-][a-z-_0-9]*" . font-lock-variable-name-face)
+    ("@[a-z_-][a-z_0-9-]*" . font-lock-variable-name-face)
     ("&" . font-lock-preprocessor-face)
     ;; Mixins
-    ("\\(?:[ \t{;]\\|^\\)\\(\\.[a-z_-][a-z-_0-9]*\\)[ \t]*;" .
+    ("\\(?:[ \t{;]\\|^\\)\\(\\.[a-z_-][a-z_0-9-]*\\)[ \t]*;" .
      (1 font-lock-keyword-face))))
 
 (defvar less-css-mode-syntax-table
diff --git a/lisp/textmodes/makeinfo.el b/lisp/textmodes/makeinfo.el
index 99654a2..ff3d242 100644
--- a/lisp/textmodes/makeinfo.el
+++ b/lisp/textmodes/makeinfo.el
@@ -1,6 +1,6 @@
 ;;; makeinfo.el --- run makeinfo conveniently
 
-;; Copyright (C) 1991, 1993, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1991, 1993, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Robert J. Chassell
 ;; Maintainer: address@hidden
diff --git a/lisp/textmodes/mhtml-mode.el b/lisp/textmodes/mhtml-mode.el
index 552fcd3..7de24c7 100644
--- a/lisp/textmodes/mhtml-mode.el
+++ b/lisp/textmodes/mhtml-mode.el
@@ -1,6 +1,6 @@
 ;;; mhtml-mode.el --- HTML editing mode that handles CSS and JS -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Keywords: wp, hypermedia, comm, languages
 
@@ -23,12 +23,10 @@
 
 (eval-and-compile
   (require 'cl-lib)
-  (require 'flyspell)
   (require 'sgml-mode))
 (require 'js)
 (require 'css-mode)
 (require 'prog-mode)
-(require 'font-lock)
 
 (defcustom mhtml-tag-relative-indent t
   "How <script> and <style> bodies are indented relative to the tag.
@@ -350,6 +348,8 @@ This is used by `mhtml--pre-command'.")
       ;; HTML.
       (sgml-indent-line))))
 
+(declare-function flyspell-generic-progmode-verify "flyspell")
+
 (defun mhtml--flyspell-check-word ()
   (let ((submode (get-text-property (point) 'mhtml-submode)))
     (if submode
diff --git a/lisp/textmodes/nroff-mode.el b/lisp/textmodes/nroff-mode.el
index 51a9f58..f33d4df 100644
--- a/lisp/textmodes/nroff-mode.el
+++ b/lisp/textmodes/nroff-mode.el
@@ -1,6 +1,6 @@
 ;;; nroff-mode.el --- GNU Emacs major mode for editing nroff source
 
-;; Copyright (C) 1985-1986, 1994-1995, 1997, 2001-2018 Free Software
+;; Copyright (C) 1985-1986, 1994-1995, 1997, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/textmodes/page-ext.el b/lisp/textmodes/page-ext.el
index 92fce4d..23e2d28 100644
--- a/lisp/textmodes/page-ext.el
+++ b/lisp/textmodes/page-ext.el
@@ -1,6 +1,6 @@
 ;;; page-ext.el --- extended page handling commands  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1990-1991, 1993-1994, 2001-2018 Free Software
+;; Copyright (C) 1990-1991, 1993-1994, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Robert J. Chassell <address@hidden>
diff --git a/lisp/textmodes/page.el b/lisp/textmodes/page.el
index cbd9168..220ef2d 100644
--- a/lisp/textmodes/page.el
+++ b/lisp/textmodes/page.el
@@ -1,6 +1,6 @@
 ;;; page.el --- page motion commands for Emacs
 
-;; Copyright (C) 1985, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: wp convenience
diff --git a/lisp/textmodes/paragraphs.el b/lisp/textmodes/paragraphs.el
index ee81256..92a6b90 100644
--- a/lisp/textmodes/paragraphs.el
+++ b/lisp/textmodes/paragraphs.el
@@ -1,6 +1,6 @@
 ;;; paragraphs.el --- paragraph and sentence parsing
 
-;; Copyright (C) 1985-1987, 1991, 1994-1997, 1999-2018 Free Software
+;; Copyright (C) 1985-1987, 1991, 1994-1997, 1999-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/textmodes/picture.el b/lisp/textmodes/picture.el
index 6836fd0..b520849 100644
--- a/lisp/textmodes/picture.el
+++ b/lisp/textmodes/picture.el
@@ -1,6 +1,6 @@
 ;;; picture.el --- "Picture mode" -- editing using quarter-plane screen model
 
-;; Copyright (C) 1985, 1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: K. Shane Hartman
 ;; Maintainer: address@hidden
@@ -387,7 +387,8 @@ Interactively, ARG is the numeric argument, and defaults to 
1."
 \\[picture-set-tab-stops] and \\[picture-tab-search].
 The syntax for this variable is like the syntax used inside of `[...]'
 in a regular expression--but without the `[' and the `]'.
-It is NOT a regular expression, any regexp special characters will be quoted.
+It is NOT a regular expression, and should follow the usual
+rules for the contents of a character alternative.
 It defines a set of \"interesting characters\" to look for when setting
 \(or searching for) tab stops, initially \"!-~\" (all printing characters).
 For example, suppose that you are editing a table which is formatted thus:
@@ -425,7 +426,7 @@ stops computed are displayed in the minibuffer with `:' at 
each stop."
       (if arg
          (setq tabs (or (default-value 'tab-stop-list)
                         (indent-accumulate-tab-stops (window-width))))
-       (let ((regexp (concat "[ \t]+[" (regexp-quote picture-tab-chars) "]")))
+       (let ((regexp (concat "[ \t]+[" picture-tab-chars "]")))
          (beginning-of-line)
          (let ((bol (point)))
            (end-of-line)
@@ -433,8 +434,8 @@ stops computed are displayed in the minibuffer with `:' at 
each stop."
              (skip-chars-forward " \t")
              (setq tabs (cons (current-column) tabs)))
            (if (null tabs)
-               (error "No characters in set %s on this line"
-                      (regexp-quote picture-tab-chars))))))
+               (error "No characters in set [%s] on this line"
+                      picture-tab-chars)))))
       (setq tab-stop-list tabs)
       (let ((blurb (make-string (1+ (nth (1- (length tabs)) tabs)) ?\ )))
        (while tabs
@@ -455,12 +456,13 @@ If no such character is found, move to beginning of line."
               (progn
                 (beginning-of-line)
                 (skip-chars-backward
-                 (concat "^" (regexp-quote picture-tab-chars))
+                 (concat "^" (replace-regexp-in-string
+                              "\\\\" "\\\\" picture-tab-chars nil t))
                  (point-min))
                 (not (bobp))))
          (move-to-column target))
       (if (re-search-forward
-          (concat "[ \t]+[" (regexp-quote picture-tab-chars) "]")
+          (concat "[ \t]+[" picture-tab-chars "]")
           (line-end-position)
           'move)
          (setq target (1- (current-column)))
diff --git a/lisp/textmodes/po.el b/lisp/textmodes/po.el
index 27c5fb7..100ce95 100644
--- a/lisp/textmodes/po.el
+++ b/lisp/textmodes/po.el
@@ -1,6 +1,6 @@
 ;;; po.el --- basic support of PO translation files
 
-;; Copyright (C) 1995-1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-1998, 2000-2019 Free Software Foundation, Inc.
 
 ;; Authors: François Pinard <address@hidden>,
 ;;          Greg McGary <address@hidden>,
diff --git a/lisp/textmodes/refbib.el b/lisp/textmodes/refbib.el
index 98ba123..3ba52e6 100644
--- a/lisp/textmodes/refbib.el
+++ b/lisp/textmodes/refbib.el
@@ -1,6 +1,6 @@
 ;;; refbib.el --- convert refer-style references to ones usable by Latex bib
 
-;; Copyright (C) 1989, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1989, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Henry Kautz <address@hidden>
 ;; Maintainer: address@hidden
@@ -137,7 +137,7 @@ This is in addition to the 
`r2b-capitalize-title-stop-words'.")
 
 (defvar r2b-capitalize-title-stop-words
    (concat
-      "the\\|and\\|of\\|is\\|a\\|an\\|of\\|for\\|in\\|to\\|in\\|on\\|at\\|"
+      "the\\|and\\|of\\|is\\|a\\|an\\|for\\|in\\|to\\|on\\|at\\|"
       "by\\|with\\|that\\|its")
    "Words not to be capitalized in a title (unless the first word).")
 
diff --git a/lisp/textmodes/refer.el b/lisp/textmodes/refer.el
index f378e64..f13e1d7 100644
--- a/lisp/textmodes/refer.el
+++ b/lisp/textmodes/refer.el
@@ -1,6 +1,6 @@
 ;;; refer.el --- look up references in bibliography files
 
-;; Copyright (C) 1992, 1996, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1996, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Ashwin Ram <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/textmodes/refill.el b/lisp/textmodes/refill.el
index 06709a8..5c69fdc 100644
--- a/lisp/textmodes/refill.el
+++ b/lisp/textmodes/refill.el
@@ -1,6 +1,6 @@
 ;;; refill.el --- `auto-fill' by refilling paragraphs on changes
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Love <address@hidden>
 ;; Maintainer: Miles Bader <address@hidden>
diff --git a/lisp/textmodes/reftex-auc.el b/lisp/textmodes/reftex-auc.el
index d1b78ff..e9f9885 100644
--- a/lisp/textmodes/reftex-auc.el
+++ b/lisp/textmodes/reftex-auc.el
@@ -1,6 +1,6 @@
 ;;; reftex-auc.el --- RefTeX's interface to AUCTeX
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/textmodes/reftex-cite.el b/lisp/textmodes/reftex-cite.el
index fd229a6..5b42b25 100644
--- a/lisp/textmodes/reftex-cite.el
+++ b/lisp/textmodes/reftex-cite.el
@@ -1,6 +1,6 @@
 ;;; reftex-cite.el --- creating citations with RefTeX
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <address@hidden>
 ;; Maintainer: address@hidden
@@ -172,7 +172,7 @@ If RETURN is non-nil, just return the entry and restore 
point."
         (if item
             (progn (end-of-line)
                    (re-search-forward
-                    "\\\\bibitem\\|\\end{thebibliography}")
+                    "\\\\bibitem\\|\\\\end{thebibliography}")
                    (1- (match-beginning 0)))
           (progn (forward-list 1) (point)))
       (error (min (point-max) (+ 300 (point)))))))
@@ -447,7 +447,7 @@ If FIELD is empty try \"editor\" field."
         (setq names (reftex-get-bib-field "editor" entry)))
     (while (string-match "\\band\\b[ \t]*" names)
       (setq names (replace-match "\n" nil t names)))
-    (while (string-match "[\\.a-zA-Z\\-]+\\.[ \t]*\\|,.*\\|[{}]+" names)
+    (while (string-match "[-.a-zA-Z]+\\.[ \t]*\\|,.*\\|[{}]+" names)
       (setq names (replace-match "" nil t names)))
     (while (string-match "^[ \t]+\\|[ \t]+$" names)
       (setq names (replace-match "" nil t names)))
diff --git a/lisp/textmodes/reftex-dcr.el b/lisp/textmodes/reftex-dcr.el
index 74a5e63..8973e5d 100644
--- a/lisp/textmodes/reftex-dcr.el
+++ b/lisp/textmodes/reftex-dcr.el
@@ -1,6 +1,6 @@
 ;;; reftex-dcr.el --- viewing cross references and citations with RefTeX
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/textmodes/reftex-global.el b/lisp/textmodes/reftex-global.el
index c234247..cdff2f4 100644
--- a/lisp/textmodes/reftex-global.el
+++ b/lisp/textmodes/reftex-global.el
@@ -1,6 +1,6 @@
 ;;; reftex-global.el --- operations on entire documents with RefTeX
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/textmodes/reftex-index.el b/lisp/textmodes/reftex-index.el
index 781e3e9..9f5242a 100644
--- a/lisp/textmodes/reftex-index.el
+++ b/lisp/textmodes/reftex-index.el
@@ -1,6 +1,6 @@
 ;;; reftex-index.el --- index support with RefTeX
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/textmodes/reftex-parse.el b/lisp/textmodes/reftex-parse.el
index 492f546..005816e 100644
--- a/lisp/textmodes/reftex-parse.el
+++ b/lisp/textmodes/reftex-parse.el
@@ -1,6 +1,6 @@
 ;;; reftex-parse.el --- parser functions for RefTeX
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <address@hidden>
 ;; Maintainer: address@hidden
@@ -1000,7 +1000,7 @@ OPT-ARGS is a list of argument numbers which are 
optional."
                     (eq (following-char) ?\{))
           (cl-incf cnt)))
       (if (and (= n cnt)
-               (> (skip-chars-forward "{\\[") 0))
+               (> (skip-chars-forward "{[") 0))
           (reftex-context-substring)
         nil))))
 
diff --git a/lisp/textmodes/reftex-ref.el b/lisp/textmodes/reftex-ref.el
index eb8d98c..3ec96aa 100644
--- a/lisp/textmodes/reftex-ref.el
+++ b/lisp/textmodes/reftex-ref.el
@@ -1,6 +1,6 @@
 ;;; reftex-ref.el --- code to create labels and references with RefTeX
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <address@hidden>
 ;; Maintainer: address@hidden
@@ -308,7 +308,7 @@ also applies `reftex-translate-to-ascii-function' to the 
string."
   ;; Replace %escapes in a label prefix
   (save-match-data
     (let (letter (num 0) replace)
-      (while (string-match "\\%\\([a-zA-Z]\\)" prefix num)
+      (while (string-match "%\\([a-zA-Z]\\)" prefix num)
         (setq letter (match-string 1 prefix))
         (setq replace
               (save-match-data
diff --git a/lisp/textmodes/reftex-sel.el b/lisp/textmodes/reftex-sel.el
index f9e2cf8..1a605ec 100644
--- a/lisp/textmodes/reftex-sel.el
+++ b/lisp/textmodes/reftex-sel.el
@@ -1,6 +1,6 @@
 ;;; reftex-sel.el --- the selection modes for RefTeX
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/textmodes/reftex-toc.el b/lisp/textmodes/reftex-toc.el
index 9c158a5..30e4c45 100644
--- a/lisp/textmodes/reftex-toc.el
+++ b/lisp/textmodes/reftex-toc.el
@@ -1,6 +1,6 @@
 ;;; reftex-toc.el --- RefTeX's table of contents mode
 
-;; Copyright (C) 1997-2000, 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2000, 2003-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/textmodes/reftex-vars.el b/lisp/textmodes/reftex-vars.el
index e7fe8ff..88ad447 100644
--- a/lisp/textmodes/reftex-vars.el
+++ b/lisp/textmodes/reftex-vars.el
@@ -1,6 +1,6 @@
 ;;; reftex-vars.el --- configuration variables for RefTeX
 
-;; Copyright (C) 1997-1999, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1999, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <address@hidden>
 ;; Maintainer: address@hidden
@@ -891,21 +891,58 @@ DOWNCASE    t:   Downcase words before using them."
     ;; so this list mustn't get any more items.
     (defconst reftex-label-regexps '("\\\\label{\\([^}]*\\)}"))
   (defcustom reftex-label-regexps
-    '(;; Normal \\label{foo} labels
+    `(;; Normal \\label{foo} labels
       "\\\\label{\\(?1:[^}]*\\)}"
       ;; keyvals [..., label = {foo}, ...] forms used by ctable,
-      ;; listings, minted, ...
-      
"\\[[^][]\\{0,2000\\}\\<label[[:space:]]*=[[:space:]]*{?\\(?1:[^],}]+\\)}?")
+      ;; listings, breqn, ...
+      ,(concat
+        ;; Make sure we search only for optional arguments of
+        ;; environments/macros and don't match any other [.  ctable
+        ;; provides a macro called \ctable, listings/breqn have
+        ;; environments.  Start with a backslash and a group for names
+        "\\\\\\(?:"
+        ;; begin, optional spaces and opening brace
+        "begin[[:space:]]*{"
+        ;; Build a regexp for env names
+        (regexp-opt '("lstlisting" "dmath" "dseries" "dgroup" "darray"))
+        ;; closing brace, optional spaces
+        "}[[:space:]]*"
+        ;; Now for macros
+        "\\|"
+        ;; Build a regexp for macro names; currently only \ctable
+        (regexp-opt '("ctable"))
+        ;; Close the group for names
+        "\\)"
+        ;; Match the opening [ and the following chars
+        "\\[[^][]*"
+        ;; Allow nested levels of chars enclosed in braces
+        "\\(?:{[^}{]*"
+          "\\(?:{[^}{]*"
+            "\\(?:{[^}{]*}[^}{]*\\)*"
+          "}[^}{]*\\)*"
+        "}[^][]*\\)*"
+        ;; Match the label key
+        "\\<label[[:space:]]*=[[:space:]]*"
+        ;; Match the label value; braces around the value are
+        ;; optional.
+        "{?\\(?1:[^] ,}\r\n\t%]+\\)}?"
+        ;; We are done.  Just search until the next closing bracket
+        "[^]]*\\]"))
     "List of regexps matching \\label definitions.
 The default value matches usual \\label{...} definitions and
-keyval style [..., label = {...}, ...] label definitions.  It is
-assumed that the regexp group 1 matches the label text, so you
-have to define it using \\(?1:...\\) when adding new regexps.
+keyval style [..., label = {...}, ...] label definitions.  The
+regexp for keyval style explicitly looks for environments
+provided by the packages \"listings\" (\"lstlisting\"),
+\"breqn\" (\"dmath\", \"dseries\", \"dgroup\", \"darray\") and
+the macro \"\\ctable\" provided by the package of the same name.
+
+It is assumed that the regexp group 1 matches the label text, so
+you have to define it using \\(?1:...\\) when adding new regexps.
 
 When changed from Lisp, make sure to call
 `reftex-compile-variables' afterwards to make the change
 effective."
-    :version "25.1"
+    :version "27.1"
     :set (lambda (symbol value)
           (set symbol value)
           (when (fboundp 'reftex-compile-variables)
diff --git a/lisp/textmodes/reftex.el b/lisp/textmodes/reftex.el
index ea28e09..d763769 100644
--- a/lisp/textmodes/reftex.el
+++ b/lisp/textmodes/reftex.el
@@ -1,5 +1,5 @@
 ;;; reftex.el --- minor mode for doing \label, \ref, \cite, \index in LaTeX
-;; Copyright (C) 1997-2000, 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2000, 2003-2019 Free Software Foundation, Inc.
 
 ;; Author: Carsten Dominik <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/textmodes/remember.el b/lisp/textmodes/remember.el
index 83bfc79..67ecd3c 100644
--- a/lisp/textmodes/remember.el
+++ b/lisp/textmodes/remember.el
@@ -1,6 +1,6 @@
 ;;; remember --- a mode for quickly jotting down things to remember
 
-;; Copyright (C) 1999-2001, 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2001, 2003-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/textmodes/rst.el b/lisp/textmodes/rst.el
index 126804f..ba5d7e4 100644
--- a/lisp/textmodes/rst.el
+++ b/lisp/textmodes/rst.el
@@ -1,6 +1,6 @@
 ;;; rst.el --- Mode for viewing and editing reStructuredText-documents  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: Stefan Merten <stefan at merten-home dot de>
 ;; Author: Stefan Merten <stefan at merten-home dot de>,
@@ -225,7 +225,7 @@ and before TAIL-RE and DELIM-RE in VAR or DEFAULT for no 
match."
   "The SVN revision of this file.
 SVN revision is the upstream (docutils) revision.")
 (defconst rst-svn-timestamp
-  (rst-extract-version "\\$" "LastChangedDate: " ".+?+" " "
+  (rst-extract-version "\\$" "LastChangedDate: " ".+" " "
                       "$LastChangedDate: 2017-01-08 10:54:35 +0100 (Sun, 08 
Jan 2017) $")
   "The SVN time stamp of this file.")
 
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index 21b7082..9e3be99 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -1,6 +1,6 @@
 ;;; sgml-mode.el --- SGML- and HTML-editing modes -*- lexical-binding:t -*-
 
-;; Copyright (C) 1992, 1995-1996, 1998, 2001-2018 Free Software
+;; Copyright (C) 1992, 1995-1996, 1998, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: James Clark <address@hidden>
@@ -46,8 +46,7 @@
 
 (defcustom sgml-basic-offset 2
   "Specifies the basic indentation level for `sgml-indent-line'."
-  :type 'integer
-  :group 'sgml)
+  :type 'integer)
 
 (defcustom sgml-attribute-offset 0
   "Specifies a delta for attribute indentation in `sgml-indent-line'.
@@ -65,16 +64,14 @@ When 2, attribute indentation looks like this:
   </element>"
   :version "25.1"
   :type 'integer
-  :safe 'integerp
-  :group 'sgml)
+  :safe 'integerp)
 
 (defcustom sgml-xml-mode nil
   "When non-nil, tag insertion functions will be XML-compliant.
 It is set to be buffer-local when the file has
 a DOCTYPE or an XML declaration."
   :type 'boolean
-  :version "22.1"
-  :group 'sgml)
+  :version "22.1")
 
 (defvaralias 'sgml-transformation 'sgml-transformation-function)
 
@@ -89,8 +86,7 @@ a DOCTYPE or an XML declaration."
                    (and (derived-mode-p 'sgml-mode)
                         (not sgml-xml-mode)
                         (setq skeleton-transformation-function val))))
-               (buffer-list)))
-  :group 'sgml)
+               (buffer-list))))
 
 (put 'sgml-transformation-function 'variable-interactive
      "aTransformation function: ")
@@ -98,7 +94,6 @@ a DOCTYPE or an XML declaration."
 (defcustom sgml-mode-hook nil
   "Hook run by command `sgml-mode'.
 `text-mode-hook' is run first."
-  :group 'sgml
   :type 'hook)
 
 ;; As long as Emacs's syntax can't be complemented with predicates to context
@@ -211,8 +206,7 @@ This takes effect when first loading the `sgml-mode' 
library.")
 
 (defcustom sgml-name-8bit-mode nil
   "When non-nil, insert non-ASCII characters as named entities."
-  :type 'boolean
-  :group 'sgml)
+  :type 'boolean)
 
 (defvar sgml-char-names
   [nil nil nil nil nil nil nil nil
@@ -282,8 +276,7 @@ Currently, only Latin-1 characters are supported.")
 The file name of current buffer file name will be appended to this,
 separated by a space."
   :type 'string
-  :version "21.1"
-  :group 'sgml)
+  :version "21.1")
 
 (defvar sgml-saved-validate-command nil
   "The command last used to validate in this buffer.")
@@ -292,8 +285,7 @@ separated by a space."
 ;; so use a small distance here.
 (defcustom sgml-slash-distance 1000
   "If non-nil, is the maximum distance to search for matching `/'."
-  :type '(choice (const nil) integer)
-  :group 'sgml)
+  :type '(choice (const nil) integer))
 
 (defconst sgml-namespace-re "[_[:alpha:]][-_.[:alnum:]]*")
 (defconst sgml-name-re "[_:[:alpha:]][-_.:[:alnum:]]*")
@@ -305,8 +297,7 @@ Any terminating `>' or `/' is not matched.")
 
 (defface sgml-namespace
   '((t (:inherit font-lock-builtin-face)))
-  "`sgml-mode' face used to highlight the namespace part of identifiers."
-  :group 'sgml)
+  "`sgml-mode' face used to highlight the namespace part of identifiers.")
 (defvar sgml-namespace-face 'sgml-namespace)
 
 ;; internal
@@ -352,12 +343,21 @@ Any terminating `>' or `/' is not matched.")
      ("--[ \t\n]*\\(>\\)" (1 "> b"))
      ("\\(<\\)[?!]" (1 (prog1 "|>"
                          (sgml-syntax-propertize-inside end))))
-     ;; Double quotes outside of tags should not introduce strings.
-     ;; Be careful to call `syntax-ppss' on a position before the one we're
-     ;; going to change, so as not to need to flush the data we just computed.
-     ("\"" (0 (if (prog1 (zerop (car (syntax-ppss (match-beginning 0))))
-                    (goto-char (match-end 0)))
-                  (string-to-syntax ".")))))))
+     ;; Double quotes outside of tags should not introduce strings which end up
+     ;; hiding tags.  We used to test every double quote and mark it as "."
+     ;; if it's outside of tags, but there are too many double quotes and
+     ;; the resulting number of calls to syntax-ppss made it too slow
+     ;; (bug#33887), so we're now careful to leave alone any pair
+     ;; of quotes that doesn't hold a < or > char, which is the vast majority.
+     ("\\(\"\\)[^\"<>]*[<>\"]"
+      (1 (unless (eq ?\" (char-before))
+           ;; Be careful to call `syntax-ppss' on a position before the one
+           ;; we're going to change, so as not to need to flush the data we
+           ;; just computed.
+           (if (prog1 (zerop (car (syntax-ppss (match-beginning 0))))
+                 (goto-char (1- (match-end 0))))
+               (string-to-syntax ".")))))
+     )))
 
 (defun sgml-syntax-propertize (start end)
   "Syntactic keywords for `sgml-mode'."
@@ -421,8 +421,7 @@ The attribute alist is made up as
 ATTRIBUTERULE is a list of optionally t (no value when no input) followed by
 an optional alist of possible values."
   :type '(repeat (cons (string :tag "Tag Name")
-                      (repeat :tag "Tag Rule" sexp)))
-  :group 'sgml)
+                      (repeat :tag "Tag Rule" sexp))))
 (put 'sgml-tag-alist 'risky-local-variable t)
 
 (defcustom sgml-tag-help
@@ -434,8 +433,7 @@ an optional alist of possible values."
     ("!entity" . "Entity (macro) declaration"))
   "Alist of tag name and short description."
   :type '(repeat (cons (string :tag "Tag Name")
-                      (string :tag "Description")))
-  :group 'sgml)
+                      (string :tag "Description"))))
 
 (defvar sgml-empty-tags nil
   "List of tags whose !ELEMENT definition says EMPTY.")
@@ -461,7 +459,7 @@ an optional alist of possible values."
               nil t)
          (string-match "X\\(HT\\)?ML" (match-string 3))))))
 
-(defvar v2)                            ; free for skeleton
+(with-no-warnings (defvar v2))                         ; free for skeleton
 
 (defun sgml-comment-indent-new-line (&optional soft)
   (let ((comment-start "-- ")
@@ -896,7 +894,7 @@ Return non-nil if we skipped over matched tags."
   (condition-case err
   (save-excursion
     (goto-char end)
-    (skip-chars-backward "[:alnum:]-_.:")
+    (skip-chars-backward "-[:alnum:]_.:")
     (if (and ;; (<= (point) beg) ; This poses problems for downcase-word.
              (or (eq (char-before) ?<)
                  (and (eq (char-before) ?/)
@@ -904,7 +902,7 @@ Return non-nil if we skipped over matched tags."
              (null (get-char-property (point) 'text-clones)))
         (let* ((endp (eq (char-before) ?/))
                (cl-start (point))
-               (cl-end (progn (skip-chars-forward "[:alnum:]-_.:") (point)))
+              (cl-end (progn (skip-chars-forward "-[:alnum:]_.:") (point)))
                (match
                 (if endp
                     (when (sgml-skip-tag-backward 1) (forward-char 1) t)
@@ -921,7 +919,8 @@ Return non-nil if we skipped over matched tags."
                      (equal (buffer-substring cl-start cl-end)
                             (buffer-substring (point)
                                               (save-excursion
-                                                (skip-chars-forward 
"[:alnum:]-_.:")
+                                               (skip-chars-forward
+                                                "-[:alnum:]_.:")
                                                 (point))))
                      (or (not endp) (eq (char-after cl-end) ?>)))
             (when clones
@@ -1722,7 +1721,6 @@ Currently just returns (EMPTY-TAGS UNCLOSED-TAGS)."
 (defcustom html-mode-hook nil
   "Hook run by command `html-mode'.
 `text-mode-hook' and `sgml-mode-hook' are run first."
-  :group 'sgml
   :type 'hook
   :options '(html-autoview-mode))
 
@@ -2381,10 +2379,9 @@ HTML Autoview mode is a buffer-local minor mode for use 
with
 `html-mode'.  If enabled, saving the file automatically runs
 `browse-url-of-buffer' to view it."
   nil nil nil
-  :group 'sgml
   (if html-autoview-mode
-      (add-hook 'after-save-hook 'browse-url-of-buffer nil t)
-    (remove-hook 'after-save-hook 'browse-url-of-buffer t)))
+      (add-hook 'after-save-hook #'browse-url-of-buffer nil t)
+    (remove-hook 'after-save-hook #'browse-url-of-buffer t)))
 
 
 (define-skeleton html-href-anchor
diff --git a/lisp/textmodes/table.el b/lisp/textmodes/table.el
index 49d1fc2..bed8b2f 100644
--- a/lisp/textmodes/table.el
+++ b/lisp/textmodes/table.el
@@ -1,6 +1,6 @@
 ;;; table.el --- create and edit WYSIWYG text based embedded tables  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Keywords: wp, convenience
 ;; Author: Takaaki Ota <address@hidden>
diff --git a/lisp/textmodes/tex-mode.el b/lisp/textmodes/tex-mode.el
index 63437af..9c91d27 100644
--- a/lisp/textmodes/tex-mode.el
+++ b/lisp/textmodes/tex-mode.el
@@ -1,6 +1,6 @@
 ;;; tex-mode.el --- TeX, LaTeX, and SliTeX mode commands  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1985-1986, 1989, 1992, 1994-1999, 2001-2018 Free
+;; Copyright (C) 1985-1986, 1989, 1992, 1994-1999, 2001-2019 Free
 ;; Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/textmodes/texinfmt.el b/lisp/textmodes/texinfmt.el
index e89da65..4bfecb4 100644
--- a/lisp/textmodes/texinfmt.el
+++ b/lisp/textmodes/texinfmt.el
@@ -1,6 +1,6 @@
 ;;; texinfmt.el --- format Texinfo files into Info files
 
-;; Copyright (C) 1985-1986, 1988, 1990-1998, 2000-2018 Free Software
+;; Copyright (C) 1985-1986, 1988, 1990-1998, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: Robert J. Chassell <address@hidden>
@@ -552,13 +552,7 @@ if large.  You can use `Info-split' to do this manually."
 
 (defvar texinfo-accent-commands
   (concat
-   "@^\\|"
-   "@`\\|"
-   "@'\\|"
-   "@\"\\|"
-   "@,\\|"
-   "@=\\|"
-   "@~\\|"
+   "@[\"',=^`~]\\|"
    "@OE{\\|"
    "@oe{\\|"
    "@AA{\\|"
diff --git a/lisp/textmodes/texinfo.el b/lisp/textmodes/texinfo.el
index ff723a4..71cdcab 100644
--- a/lisp/textmodes/texinfo.el
+++ b/lisp/textmodes/texinfo.el
@@ -1,6 +1,6 @@
 ;;; texinfo.el --- major mode for editing Texinfo files
 
-;; Copyright (C) 1985, 1988-1993, 1996-1997, 2000-2018 Free Software
+;; Copyright (C) 1985, 1988-1993, 1996-1997, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Robert J. Chassell
@@ -470,6 +470,7 @@ Subexpression 1 is what goes into the corresponding 
address@hidden' statement.")
     (define-key map "\C-c\C-cu"    'address@hidden)
     (define-key map "\C-c\C-ct"    'address@hidden)
     (define-key map "\C-c\C-cs"    'address@hidden)
+    (define-key map "\C-c\C-cr"    'address@hidden)
     (define-key map "\C-c\C-cq"    'address@hidden)
     (define-key map "\C-c\C-co"    'address@hidden)
     (define-key map "\C-c\C-cn"    'address@hidden)
@@ -825,6 +826,38 @@ Leave point after address@hidden'."
   "Insert the string address@hidden' in a Texinfo buffer."
   \n "@quotation" \n _ \n)
 
+(define-skeleton address@hidden
+  "Insert appropriate address@hidden', address@hidden', or address@hidden' 
command.
+
+Looks at text around point to decide what to insert; an unclosed
+preceding open parenthesis results in '@pxref{}', point at the
+beginning of a sentence or at (point-min) yields '@xref{}', any
+other location (including inside a word), will result in '@ref{}'
+at the nearest previous whitespace or beginning-of-line.  A
+numeric argument says how many words the braces should surround.
+The default is not to surround any existing words with the
+braces."
+  nil
+  (cond
+   ;; parenthesis
+   ((looking-back "([^)]*" (point-at-bol 0))
+    "@pxref{")
+   ;; beginning of sentence or buffer
+   ((or (looking-back (sentence-end) (point-at-bol 0))
+        (= (point) (point-min)))
+    "@xref{")
+   ;; bol or eol
+   ((looking-at "^\\|$")
+    "@ref{")
+   ;; inside word
+   ((not (eq (char-syntax (char-after)) ? ))
+    (skip-syntax-backward "^ " (point-at-bol))
+    "@ref{")
+   ;; everything else
+   (t
+    "@ref{"))
+  _ "}")
+
 (define-skeleton address@hidden
   "Insert a address@hidden' command in a Texinfo buffer.
 A numeric argument says how many words the braces should surround.
diff --git a/lisp/textmodes/texnfo-upd.el b/lisp/textmodes/texnfo-upd.el
index a41042d..e960e99 100644
--- a/lisp/textmodes/texnfo-upd.el
+++ b/lisp/textmodes/texnfo-upd.el
@@ -1,6 +1,6 @@
 ;;; texnfo-upd.el --- utilities for updating nodes and menus in Texinfo files
 
-;; Copyright (C) 1989-1992, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1989-1992, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Robert J. Chassell
 ;; Maintainer: address@hidden
@@ -642,7 +642,7 @@ appears in the texinfo file."
   "Return description field of old menu line as string.
 Point must be located just after the node name.  Point left before description.
 Single argument, END-OF-MENU, is position limiting search."
-  (skip-chars-forward "[:.,\t\n ]+")
+  (skip-chars-forward ":.,\t\n ")
   ;; don't copy a carriage return at line beginning with asterisk!
   ;; don't copy @detailmenu or @end menu or @ignore as descriptions!
   ;; do copy a description that begins with an `@'!
diff --git a/lisp/textmodes/text-mode.el b/lisp/textmodes/text-mode.el
index 8dd4682..e676a5d 100644
--- a/lisp/textmodes/text-mode.el
+++ b/lisp/textmodes/text-mode.el
@@ -1,6 +1,6 @@
-;;; text-mode.el --- text mode, and its idiosyncratic commands
+;;; text-mode.el --- text mode, and its idiosyncratic commands  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1985, 1992, 1994, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1985, 1992, 1994, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Maintainer: address@hidden
@@ -38,8 +38,8 @@
   :group 'text)
 
 (defvar text-mode-variant nil
-  "Non-nil if this buffer's major mode is a variant of Text mode.
-Use (derived-mode-p \\='text-mode) instead.")
+  "Non-nil if this buffer's major mode is a variant of Text mode.")
+(make-obsolete-variable 'text-mode-variant 'derived-mode-p "27.1")
 
 (defvar text-mode-syntax-table
   (let ((st (make-syntax-table)))
@@ -104,10 +104,8 @@ You can thus get the full benefit of adaptive filling
  (see the variable `adaptive-fill-mode').
 \\{text-mode-map}
 Turning on Text mode runs the normal hook `text-mode-hook'."
-  (set (make-local-variable 'text-mode-variant) t)
-  (set (make-local-variable 'require-final-newline)
-       mode-require-final-newline)
-  (set (make-local-variable 'indent-line-function) 'indent-relative))
+  (setq-local text-mode-variant t)
+  (setq-local require-final-newline mode-require-final-newline))
 
 (define-derived-mode paragraph-indent-text-mode text-mode "Parindent"
   "Major mode for editing text, with leading spaces starting a paragraph.
@@ -131,14 +129,12 @@ Turning on Paragraph-Indent minor mode runs the normal 
hook
   :initial-value nil
   ;; Change the definition of a paragraph start.
   (let ((ps-re "[ \t\n\f]\\|"))
-    (if (eq t (compare-strings ps-re nil nil
-                               paragraph-start nil (length ps-re)))
+    (if (string-prefix-p ps-re paragraph-start)
         (if (not paragraph-indent-minor-mode)
-            (set (make-local-variable 'paragraph-start)
-                 (substring paragraph-start (length ps-re))))
+            (setq-local paragraph-start
+                        (substring paragraph-start (length ps-re))))
       (if paragraph-indent-minor-mode
-          (set (make-local-variable 'paragraph-start)
-               (concat ps-re paragraph-start)))))
+          (setq-local paragraph-start (concat ps-re paragraph-start)))))
   ;; Change the indentation function.
   (if paragraph-indent-minor-mode
       (add-function :override (local 'indent-line-function)
@@ -154,7 +150,7 @@ Turning on Paragraph-Indent minor mode runs the normal hook
 (defun text-mode-hook-identify ()
   "Mark that this mode has run `text-mode-hook'.
 This is how `toggle-text-mode-auto-fill' knows which buffers to operate on."
-  (set (make-local-variable 'text-mode-variant) t))
+  (setq-local text-mode-variant t))
 
 (defun toggle-text-mode-auto-fill ()
   "Toggle whether to use Auto Fill in Text mode and related modes.
@@ -163,8 +159,8 @@ both existing buffers and buffers that you subsequently 
create."
   (interactive)
   (let ((enable-mode (not (memq 'turn-on-auto-fill text-mode-hook))))
     (if enable-mode
-       (add-hook 'text-mode-hook 'turn-on-auto-fill)
-      (remove-hook 'text-mode-hook 'turn-on-auto-fill))
+        (add-hook 'text-mode-hook #'turn-on-auto-fill)
+      (remove-hook 'text-mode-hook #'turn-on-auto-fill))
     (dolist (buffer (buffer-list))
       (with-current-buffer buffer
        (if (or (derived-mode-p 'text-mode) text-mode-variant)
@@ -214,15 +210,14 @@ The argument NLINES says how many lines to center."
   (while (not (eq nlines 0))
     (save-excursion
       (let ((lm (current-left-margin))
-           line-length)
+            space)
        (beginning-of-line)
        (delete-horizontal-space)
        (end-of-line)
        (delete-horizontal-space)
-       (setq line-length (current-column))
-       (if (> (- fill-column lm line-length) 0)
-           (indent-line-to
-            (+ lm (/ (- fill-column lm line-length) 2))))))
+        (setq space (- fill-column lm (current-column)))
+        (if (> space 0)
+            (indent-line-to (+ lm (/ space 2))))))
     (cond ((null nlines)
           (setq nlines 0))
          ((> nlines 0)
diff --git a/lisp/textmodes/tildify.el b/lisp/textmodes/tildify.el
index 613d78d..cf33d44 100644
--- a/lisp/textmodes/tildify.el
+++ b/lisp/textmodes/tildify.el
@@ -1,6 +1,6 @@
 ;;; tildify.el --- adding hard spaces into texts -*- lexical-binding: t -*-
 
-;; Copyright (C) 1997-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-2019 Free Software Foundation, Inc.
 
 ;; Author:     Milan Zamazal <address@hidden>
 ;;             Michal Nazarewicz <address@hidden>
diff --git a/lisp/textmodes/two-column.el b/lisp/textmodes/two-column.el
index d27abb4..e1ebf1a 100644
--- a/lisp/textmodes/two-column.el
+++ b/lisp/textmodes/two-column.el
@@ -1,6 +1,6 @@
 ;;; two-column.el --- minor mode for editing of two-column text
 
-;; Copyright (C) 1992-1995, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992-1995, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Daniel Pfeiffer <address@hidden>
 ;; Adapted-By: ESR, Daniel Pfeiffer
diff --git a/lisp/textmodes/underline.el b/lisp/textmodes/underline.el
index 8b4ac2f..e0bfd24 100644
--- a/lisp/textmodes/underline.el
+++ b/lisp/textmodes/underline.el
@@ -1,6 +1,6 @@
 ;;; underline.el --- insert/remove underlining (done by overstriking) in Emacs
 
-;; Copyright (C) 1985, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 2001-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: wp
diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el
index 5f9de9a..26e0843 100644
--- a/lisp/thingatpt.el
+++ b/lisp/thingatpt.el
@@ -1,6 +1,6 @@
 ;;; thingatpt.el --- get the `thing' at point  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1991-1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1991-1998, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Mike Williams <address@hidden>
 ;; Maintainer: address@hidden
@@ -466,11 +466,14 @@ looks like an email address, \"ftp://\"; if it starts with
      (while htbs
        (setq htb (car htbs) htbs (cdr htbs))
        (ignore-errors
-        ;; errs: htb symbol may be unbound, or not a hash-table.
-        ;; gnus-gethash is just a macro for intern-soft.
-        (and (symbol-value htb)
-             (intern-soft string (symbol-value htb))
-             (setq ret string htbs nil))
+         (setq htb (symbol-value htb))
+        (when (cond ((obarrayp htb)
+                     (intern-soft string htb))
+                     ((listp htb)
+                      (member string htb))
+                     ((hash-table-p htb)
+                      (gethash string htb)))
+          (setq ret string htbs nil))
         ;; If we made it this far, gnus is running, so ignore "heads":
         (setq heads nil)))
      (or ret (not heads)
diff --git a/lisp/thread.el b/lisp/thread.el
index 7974a26..e8f3cc7 100644
--- a/lisp/thread.el
+++ b/lisp/thread.el
@@ -1,6 +1,6 @@
 ;;; thread.el --- Thread support in Emacs Lisp -*- lexical-binding: t -*-
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; Author: Gemini Lasswell <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/thumbs.el b/lisp/thumbs.el
index 067a32b..6a17a75 100644
--- a/lisp/thumbs.el
+++ b/lisp/thumbs.el
@@ -1,6 +1,6 @@
 ;;; thumbs.el --- Thumbnails previewer for images files
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Jean-Philippe Theberge <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/time-stamp.el b/lisp/time-stamp.el
index 4e7f5ef..91e02be 100644
--- a/lisp/time-stamp.el
+++ b/lisp/time-stamp.el
@@ -1,6 +1,6 @@
 ;;; time-stamp.el --- Maintain last change time stamps in files edited by Emacs
 
-;; Copyright (C) 1989, 1993-1995, 1997, 2000-2018 Free Software
+;; Copyright (C) 1989, 1993-1995, 1997, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
diff --git a/lisp/time.el b/lisp/time.el
index bfecba9..35157c5 100644
--- a/lisp/time.el
+++ b/lisp/time.el
@@ -1,6 +1,6 @@
 ;;; time.el --- display time, load and mail indicator in mode line of Emacs
 
-;; Copyright (C) 1985-1987, 1993-1994, 1996, 2000-2018 Free Software
+;; Copyright (C) 1985-1987, 1993-1994, 1996, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
@@ -434,16 +434,17 @@ update which can wait for the next redisplay."
                ((and (stringp mail-spool-file)
                      (or (null display-time-server-down-time)
                          ;; If have been down for 20 min, try again.
-                         (< 1200 (- (float-time now)
-                                    display-time-server-down-time))))
-                (let ((start-time (float-time)))
+                         (time-less-p 1200 (time-since
+                                            display-time-server-down-time))))
+                (let ((start-time (current-time)))
                   (prog1
                       (display-time-file-nonempty-p mail-spool-file)
                     ;; Record whether mail file is accessible.
                     (setq display-time-server-down-time
-                          (let ((end-time (float-time)))
-                            (and (< 20 (- end-time start-time))
-                                 end-time))))))))
+                          (let ((end-time (current-time)))
+                            (and (time-less-p 20 (time-subtract
+                                                  end-time start-time))
+                                 (float-time end-time)))))))))
          (24-hours (substring time 11 13))
          (hour (string-to-number 24-hours))
          (12-hours (int-to-string (1+ (% (+ hour 11) 12))))
@@ -571,8 +572,9 @@ For example, the Unix uptime command format is \"%D, 
%z%2h:%.2m\"."
   (interactive)
   (let ((str
          (format-seconds (or format "%Y, %D, %H, %M, %z%S")
-                         (float-time
-                          (time-subtract nil before-init-time)))))
+                        (encode-time
+                         (time-since before-init-time)
+                         'integer))))
     (if (called-interactively-p 'interactive)
         (message "%s" str)
       str)))
@@ -582,7 +584,7 @@ For example, the Unix uptime command format is \"%D, 
%z%2h:%.2m\"."
   "Return a string giving the duration of the Emacs initialization."
   (interactive)
   (let ((str
-        (format "%.1f seconds"
+        (format "%s seconds"
                 (float-time
                  (time-subtract after-init-time before-init-time)))))
     (if (called-interactively-p 'interactive)
diff --git a/lisp/timezone.el b/lisp/timezone.el
index ee83d3a..621f024 100644
--- a/lisp/timezone.el
+++ b/lisp/timezone.el
@@ -1,6 +1,6 @@
 ;;; timezone.el --- time zone package for GNU Emacs
 
-;; Copyright (C) 1990-1993, 1996, 1999, 2001-2018 Free Software
+;; Copyright (C) 1990-1993, 1996, 1999, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Masanobu Umeda
diff --git a/lisp/tmm.el b/lisp/tmm.el
index 4e3f254..44f04ea 100644
--- a/lisp/tmm.el
+++ b/lisp/tmm.el
@@ -1,6 +1,6 @@
 ;;; tmm.el --- text mode access to menu-bar  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1994-1996, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1996, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Ilya Zakharevich <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/tool-bar.el b/lisp/tool-bar.el
index e2242cf..4be16b2 100644
--- a/lisp/tool-bar.el
+++ b/lisp/tool-bar.el
@@ -1,6 +1,6 @@
 ;;; tool-bar.el --- setting up the tool bar
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Love <address@hidden>
 ;; Keywords: mouse frames
diff --git a/lisp/tooltip.el b/lisp/tooltip.el
index 384d3d1..b1c69ae 100644
--- a/lisp/tooltip.el
+++ b/lisp/tooltip.el
@@ -1,6 +1,6 @@
 ;;; tooltip.el --- show tooltip windows
 
-;; Copyright (C) 1997, 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Gerd Moellmann <address@hidden>
 ;; Keywords: help c mouse tools
@@ -201,7 +201,8 @@ This might return nil if the event did not occur over a 
buffer."
 (defun tooltip-delay ()
   "Return the delay in seconds for the next tooltip."
   (if (and tooltip-hide-time
-           (< (- (float-time) tooltip-hide-time) tooltip-recent-seconds))
+          (time-less-p (time-since tooltip-hide-time)
+                       tooltip-recent-seconds))
       tooltip-short-delay
     tooltip-delay))
 
diff --git a/lisp/tree-widget.el b/lisp/tree-widget.el
index 2346035..61bfacd 100644
--- a/lisp/tree-widget.el
+++ b/lisp/tree-widget.el
@@ -1,6 +1,6 @@
 ;;; tree-widget.el --- Tree widget
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: David Ponce <address@hidden>
 ;; Maintainer: David Ponce <address@hidden>
diff --git a/lisp/tutorial.el b/lisp/tutorial.el
index e3fbdf0..37ebb5c 100644
--- a/lisp/tutorial.el
+++ b/lisp/tutorial.el
@@ -1,6 +1,6 @@
 ;;; tutorial.el --- tutorial for Emacs
 
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: help, internal
diff --git a/lisp/type-break.el b/lisp/type-break.el
index c7cdc46..0ad79dd 100644
--- a/lisp/type-break.el
+++ b/lisp/type-break.el
@@ -1,6 +1,6 @@
 ;;; type-break.el --- encourage rests from typing at appropriate intervals  
-*- lexical-binding: t -*-
 
-;; Copyright (C) 1994-1995, 1997, 2000-2018 Free Software Foundation,
+;; Copyright (C) 1994-1995, 1997, 2000-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Noah Friedman
@@ -460,8 +460,7 @@ the variable of the same name."
              ))))))
 
 (defun timep (time)
-  "If TIME is in the format returned by `current-time' then
-return TIME, else return nil."
+  "If TIME is a Lisp time value then return TIME, else return nil."
   (condition-case nil
       (and (float-time time) time)
     (error nil)))
@@ -481,8 +480,7 @@ return TIME, else return nil."
 
 (defun type-break-get-previous-time ()
   "Get previous break time from `type-break-file-name'.
-Returns nil if the file is missing or if the time breaks with the
-`current-time' format."
+Return nil if the file is missing or if the time is not a Lisp time value."
   (let ((file (type-break-choose-file)))
     (if file
         (timep ;; returns expected format, else nil
@@ -808,7 +806,7 @@ this or ask the user to start one right now."
    ((and (car type-break-keystroke-threshold)
          (< type-break-keystroke-count (car type-break-keystroke-threshold))))
    ((> type-break-time-warning-count 0)
-    (let ((timeleft (type-break-time-difference (current-time)
+    (let ((timeleft (type-break-time-difference nil
                                                 type-break-time-next-break)))
       (setq type-break-warning-countdown-string (number-to-string timeleft))
       (cond
@@ -905,8 +903,8 @@ Current keystroke count     : %s"
                                (current-time-string type-break-time-next-break)
                                (type-break-format-time
                                 (type-break-time-difference
-                                (current-time)
-                                type-break-time-next-break)))
+                                nil
+                                type-break-time-next-break)))
                      "none scheduled")
                    (or (car type-break-keystroke-threshold) "none")
                    (or (cdr type-break-keystroke-threshold) "none")
@@ -1090,7 +1088,7 @@ With optional non-nil ALL, force redisplay of all 
mode-lines."
             (erase-buffer)
             (setq elapsed (type-break-time-difference
                            type-break-time-last-break
-                           (current-time)))
+                          nil))
             (let ((good-interval (or type-break-good-rest-interval
                                      type-break-good-break-interval)))
               (cond
diff --git a/lisp/uniquify.el b/lisp/uniquify.el
index 9cc7b00..3dd9e34 100644
--- a/lisp/uniquify.el
+++ b/lisp/uniquify.el
@@ -1,6 +1,6 @@
 ;;; uniquify.el --- unique buffer names dependent on file name -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1989, 1995-1997, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1989, 1995-1997, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Dick King <address@hidden>
diff --git a/lisp/url/ChangeLog.1 b/lisp/url/ChangeLog.1
index fb9dbaa..828c9b1 100644
--- a/lisp/url/ChangeLog.1
+++ b/lisp/url/ChangeLog.1
@@ -3068,7 +3068,7 @@
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 1999, 2001-2002, 2004-2018 Free Software Foundation,
+  Copyright (C) 1999, 2001-2002, 2004-2019 Free Software Foundation,
   Inc.
 
   This file is part of GNU Emacs.
diff --git a/lisp/url/url-about.el b/lisp/url/url-about.el
index a9c7e86..e9d9d63 100644
--- a/lisp/url/url-about.el
+++ b/lisp/url/url-about.el
@@ -1,6 +1,6 @@
 ;;; url-about.el --- Show internal URLs
 
-;; Copyright (C) 2001, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes, hypermedia
 
diff --git a/lisp/url/url-auth.el b/lisp/url/url-auth.el
index 401baec..0746cfd 100644
--- a/lisp/url/url-auth.el
+++ b/lisp/url/url-auth.el
@@ -1,6 +1,6 @@
 ;;; url-auth.el --- Uniform Resource Locator authorization modules -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1996-1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes, hypermedia
 
@@ -192,8 +192,7 @@ key cache `url-digest-auth-storage'."
 (defun url-digest-auth-make-cnonce ()
   "Compute a new unique client nonce value."
   (base64-encode-string
-   (apply #'format "%016x%08x%08x" (random)
-         (read (format-time-string "(%s %N)")))
+   (format "%016x%016x" (random) (car (encode-time nil t)))
    t))
 
 (defun url-digest-auth-nonce-count (_nonce)
diff --git a/lisp/url/url-cache.el b/lisp/url/url-cache.el
index 3765d9d..b306082 100644
--- a/lisp/url/url-cache.el
+++ b/lisp/url/url-cache.el
@@ -1,6 +1,6 @@
 ;;; url-cache.el --- Uniform Resource Locator retrieval tool
 
-;; Copyright (C) 1996-1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes, hypermedia
 
@@ -205,7 +205,7 @@ If `url-standalone-mode' is non-nil, cached items never 
expire."
          (time-less-p
           (time-add
            cache-time
-           (seconds-to-time (or expire-time url-cache-expire-time)))
+           (or expire-time url-cache-expire-time))
           nil)))))
 
 (defun url-cache-prune-cache (&optional directory)
@@ -227,7 +227,7 @@ considered \"expired\"."
           ((time-less-p
             (time-add
              (file-attribute-modification-time (file-attributes file))
-             (seconds-to-time url-cache-expire-time))
+             url-cache-expire-time)
             now)
            (delete-file file)
            (setq deleted-files (1+ deleted-files))))))
diff --git a/lisp/url/url-cid.el b/lisp/url/url-cid.el
index 1422da2..0c1924f 100644
--- a/lisp/url/url-cid.el
+++ b/lisp/url/url-cid.el
@@ -1,6 +1,6 @@
 ;;; url-cid.el --- Content-ID URL loader
 
-;; Copyright (C) 1998-1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes
 
diff --git a/lisp/url/url-cookie.el b/lisp/url/url-cookie.el
index 3adca26..31fc3e7 100644
--- a/lisp/url/url-cookie.el
+++ b/lisp/url/url-cookie.el
@@ -1,6 +1,6 @@
 ;;; url-cookie.el --- URL cookie support  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1996-1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes, hypermedia
 
@@ -105,11 +105,10 @@ i.e. 1970-1-1) are loaded as expiring one year from now 
instead."
                    ;; away, make it expire a year from now
                    (expires (format-time-string
                              "%d %b %Y %T [GMT]"
-                             (seconds-to-time
-                              (let ((s (string-to-number (nth 4 fields))))
-                                (if (and (= s 0) long-session)
-                                    (seconds-to-time (+ (* 365 24 60 60) 
(float-time)))
-                                  s)))))
+                             (let ((s (string-to-number (nth 4 fields))))
+                               (if (and (zerop s) long-session)
+                                   (time-add nil (* 365 24 60 60))
+                                 s))))
                    (key (nth 5 fields))
                    (val (nth 6 fields)))
                (cl-incf n)
diff --git a/lisp/url/url-dav.el b/lisp/url/url-dav.el
index 1402432..a4cf0f0 100644
--- a/lisp/url/url-dav.el
+++ b/lisp/url/url-dav.el
@@ -1,6 +1,6 @@
 ;;; url-dav.el --- WebDAV support
 
-;; Copyright (C) 2001, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Bill Perry <address@hidden>
 ;; Maintainer: address@hidden
@@ -146,7 +146,7 @@ Returns nil if WebDAV is not supported."
       (setq time (parse-time-string date-string)))
 
     (if time
-       (setq time (apply 'encode-time time))
+       (setq time (encode-time time))
       (url-debug 'dav "Unable to decode date (%S) (%s)"
                 (xml-node-name node) date-string))
     time))
diff --git a/lisp/url/url-dired.el b/lisp/url/url-dired.el
index 50d84f7..a665db8 100644
--- a/lisp/url/url-dired.el
+++ b/lisp/url/url-dired.el
@@ -1,6 +1,6 @@
 ;;; url-dired.el --- URL Dired minor mode
 
-;; Copyright (C) 1996-1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, files
 
diff --git a/lisp/url/url-domsuf.el b/lisp/url/url-domsuf.el
index fe8ce6c..151b57f 100644
--- a/lisp/url/url-domsuf.el
+++ b/lisp/url/url-domsuf.el
@@ -1,6 +1,6 @@
 ;;; url-domsuf.el --- Say what domain names can have cookies set.
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 
diff --git a/lisp/url/url-expand.el b/lisp/url/url-expand.el
index 86df7ad..f937a22 100644
--- a/lisp/url/url-expand.el
+++ b/lisp/url/url-expand.el
@@ -1,6 +1,6 @@
 ;;; url-expand.el --- expand-file-name for URLs -*- lexical-binding: t -*-
 
-;; Copyright (C) 1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes
 
diff --git a/lisp/url/url-file.el b/lisp/url/url-file.el
index 02542cc..b953ce7 100644
--- a/lisp/url/url-file.el
+++ b/lisp/url/url-file.el
@@ -1,6 +1,6 @@
 ;;; url-file.el --- File retrieval code  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1996-1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes
 
diff --git a/lisp/url/url-ftp.el b/lisp/url/url-ftp.el
index 7661294..8e64e67 100644
--- a/lisp/url/url-ftp.el
+++ b/lisp/url/url-ftp.el
@@ -1,6 +1,6 @@
 ;;; url-ftp.el --- FTP wrapper
 
-;; Copyright (C) 1996-1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes
 
diff --git a/lisp/url/url-future.el b/lisp/url/url-future.el
index 03de150..3a0c712 100644
--- a/lisp/url/url-future.el
+++ b/lisp/url/url-future.el
@@ -1,6 +1,6 @@
 ;;; url-future.el --- general futures facility for url.el -*- lexical-binding: 
t -*-
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Teodor Zlatanov <address@hidden>
 ;; Keywords: data
diff --git a/lisp/url/url-gw.el b/lisp/url/url-gw.el
index 0fc7200..5436084 100644
--- a/lisp/url/url-gw.el
+++ b/lisp/url/url-gw.el
@@ -1,6 +1,6 @@
 ;;; url-gw.el --- Gateway munging for URL loading
 
-;; Copyright (C) 1997-1998, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Bill Perry <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/url/url-handlers.el b/lisp/url/url-handlers.el
index 3802c39..e35d999 100644
--- a/lisp/url/url-handlers.el
+++ b/lisp/url/url-handlers.el
@@ -1,6 +1,6 @@
 ;;; url-handlers.el --- file-name-handler stuff for URL loading  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1996-1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes, hypermedia
 
@@ -44,7 +44,7 @@
 (declare-function mail-content-type-get "mail-parse" (ct attribute))
 ;; mm-decode loads mm-bodies, which loads mm-util.
 (declare-function mm-charset-to-coding-system "mm-util"
-                 (charset &optional lbt allow-override silent))
+                  (charset &optional lbt allow-override silent))
 
 ;; Implementation status
 ;; ---------------------
@@ -260,15 +260,15 @@ the arguments that would have been passed to OPERATION."
 ;; The actual implementation
 ;;;###autoload
 (defun url-copy-file (url newname &optional ok-if-already-exists
-                         _keep-time _preserve-uid-gid)
+                          _keep-time _preserve-uid-gid _preserve-permissions)
   "Copy URL to NEWNAME.  Both args must be strings.
-Signals a `file-already-exists' error if file NEWNAME already exists,
+Signal a `file-already-exists' error if file NEWNAME already exists,
 unless a third argument OK-IF-ALREADY-EXISTS is supplied and non-nil.
 A number as third arg means request confirmation if NEWNAME already exists.
 This is what happens in interactive use with M-x.
 Fourth arg KEEP-TIME non-nil means give the new file the same
 last-modified time as the old one.  (This works on only some systems.)
-Fifth arg PRESERVE-UID-GID is ignored.
+Args PRESERVE-UID-GID and PRESERVE-PERMISSIONS are ignored.
 A prefix arg makes KEEP-TIME non-nil."
   (if (and (file-exists-p newname)
           (not ok-if-already-exists))
@@ -351,7 +351,7 @@ if it had been inserted from a file named URL."
     (unless buffer (signal 'file-error (list url "No Data")))
     (with-current-buffer buffer
       ;; XXX: This is HTTP/S specific and should be moved to url-http
-      ;; instead.  See https://debbugs.gnu.org/17549.
+      ;; instead.  See bug#17549.
       (when (bound-and-true-p url-http-response-status)
         ;; Don't signal an error if VISIT is non-nil, because
         ;; 'insert-file-contents' doesn't.  This is required to
@@ -364,7 +364,7 @@ if it had been inserted from a file named URL."
                          (< url-http-response-status 300)))
           (let ((desc (nth 2 (assq url-http-response-status url-http-codes))))
             (kill-buffer buffer)
-            ;; Signal file-error per https://debbugs.gnu.org/16733.
+            ;; Signal file-error per bug#16733.
             (signal 'file-error (list url desc))))))
     (url-insert-buffer-contents buffer url visit beg end replace)))
 
diff --git a/lisp/url/url-history.el b/lisp/url/url-history.el
index 37425c8..d043114 100644
--- a/lisp/url/url-history.el
+++ b/lisp/url/url-history.el
@@ -1,6 +1,6 @@
 ;;; url-history.el --- Global history tracking for URL package  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1996-1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes, hypermedia
 
diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el
index 036ff80..662b666 100644
--- a/lisp/url/url-http.el
+++ b/lisp/url/url-http.el
@@ -1,6 +1,6 @@
 ;;; url-http.el --- HTTP retrieval routines  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999, 2001, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2001, 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Bill Perry <address@hidden>
 ;; Maintainer: address@hidden
@@ -150,15 +150,6 @@ request.")
 ;; These routines will allow us to implement persistent HTTP
 ;; connections.
 (defsubst url-http-debug (&rest args)
-  (if quit-flag
-      (let ((proc (get-buffer-process (current-buffer))))
-       ;; The user hit C-g, honor it!  Some things can get in an
-       ;; incredibly tight loop (chunked encoding)
-       (if proc
-           (progn
-             (set-process-sentinel proc nil)
-             (set-process-filter proc nil)))
-       (error "Transfer interrupted!")))
   (apply 'url-debug 'http args))
 
 (defun url-http-mark-connection-as-busy (host port proc)
@@ -513,11 +504,11 @@ Return the number of characters removed."
   (url-http-debug "url-http-parse-response called in (%s)" (buffer-name))
   (goto-char (point-min))
   (skip-chars-forward " \t\n")         ; Skip any blank crap
-  (skip-chars-forward "HTTP/")         ; Skip HTTP Version
+  (skip-chars-forward "/HPT")          ; Skip HTTP Version "HTTP/".
   (setq url-http-response-version
        (buffer-substring (point)
                          (progn
-                           (skip-chars-forward "[0-9].")
+                           (skip-chars-forward "0-9.")
                            (point))))
   (setq url-http-response-status (read (current-buffer))))
 
@@ -939,7 +930,8 @@ should be shown to the user."
     (goto-char (point-min))
     success))
 
-(declare-function zlib-decompress-region "decompress.c" (start end))
+(declare-function zlib-decompress-region "decompress.c"
+                  (start end &optional allow-partial))
 
 (defun url-handle-content-transfer-encoding ()
   (let ((encoding (mail-fetch-field "content-encoding")))
@@ -951,7 +943,7 @@ should be shown to the user."
        (widen)
        (goto-char (point-min))
        (when (search-forward "\n\n")
-         (zlib-decompress-region (point) (point-max)))))))
+         (zlib-decompress-region (point) (point-max) t))))))
 
 ;; Miscellaneous
 (defun url-http-activate-callback ()
diff --git a/lisp/url/url-imap.el b/lisp/url/url-imap.el
index 9d3232b..2fb1880 100644
--- a/lisp/url/url-imap.el
+++ b/lisp/url/url-imap.el
@@ -1,6 +1,6 @@
 ;;; url-imap.el --- IMAP retrieval routines
 
-;; Copyright (C) 1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Simon Josefsson <address@hidden>
 ;; Keywords: comm, data, processes
diff --git a/lisp/url/url-irc.el b/lisp/url/url-irc.el
index 818002b..27b05fc 100644
--- a/lisp/url/url-irc.el
+++ b/lisp/url/url-irc.el
@@ -1,6 +1,6 @@
 ;;; url-irc.el --- IRC URL interface
 
-;; Copyright (C) 1996-1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes
 
diff --git a/lisp/url/url-ldap.el b/lisp/url/url-ldap.el
index b60b304..1c73a66 100644
--- a/lisp/url/url-ldap.el
+++ b/lisp/url/url-ldap.el
@@ -1,6 +1,6 @@
 ;;; url-ldap.el --- LDAP Uniform Resource Locator retrieval code
 
-;; Copyright (C) 1998-1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes
 
diff --git a/lisp/url/url-mailto.el b/lisp/url/url-mailto.el
index 3a09ba7..e35a032 100644
--- a/lisp/url/url-mailto.el
+++ b/lisp/url/url-mailto.el
@@ -1,6 +1,6 @@
 ;;; url-mail.el --- Mail Uniform Resource Locator retrieval code
 
-;; Copyright (C) 1996-1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes
 
diff --git a/lisp/url/url-methods.el b/lisp/url/url-methods.el
index b728212..1c0c5af 100644
--- a/lisp/url/url-methods.el
+++ b/lisp/url/url-methods.el
@@ -1,6 +1,6 @@
 ;;; url-methods.el --- Load URL schemes as needed
 
-;; Copyright (C) 1996-1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes, hypermedia
 
diff --git a/lisp/url/url-misc.el b/lisp/url/url-misc.el
index e794786..aa44ea7 100644
--- a/lisp/url/url-misc.el
+++ b/lisp/url/url-misc.el
@@ -1,6 +1,6 @@
 ;;; url-misc.el --- Misc Uniform Resource Locator retrieval code
 
-;; Copyright (C) 1996-1999, 2002, 2004-2018 Free Software Foundation,
+;; Copyright (C) 1996-1999, 2002, 2004-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Keywords: comm, data, processes
@@ -88,7 +88,7 @@
        (encoding "8bit")
        (data nil))
     (save-excursion
-      (if (not (string-match "\\([^,]*\\)?," desc))
+      (if (not (string-match "\\([^,]*\\)," desc))
          (error "Malformed data URL: %s" desc)
        (setq mediatype (match-string 1 desc)
              data (url-unhex-string (substring desc (match-end 0))))
diff --git a/lisp/url/url-news.el b/lisp/url/url-news.el
index ef3842d..750b1be 100644
--- a/lisp/url/url-news.el
+++ b/lisp/url/url-news.el
@@ -1,6 +1,6 @@
 ;;; url-news.el --- News Uniform Resource Locator retrieval code
 
-;; Copyright (C) 1996-1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes
 
diff --git a/lisp/url/url-nfs.el b/lisp/url/url-nfs.el
index c25dc27..36535a0 100644
--- a/lisp/url/url-nfs.el
+++ b/lisp/url/url-nfs.el
@@ -1,6 +1,6 @@
 ;;; url-nfs.el --- NFS URL interface
 
-;; Copyright (C) 1996-1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes
 
diff --git a/lisp/url/url-ns.el b/lisp/url/url-ns.el
index b97f7a7..733f3a9 100644
--- a/lisp/url/url-ns.el
+++ b/lisp/url/url-ns.el
@@ -1,6 +1,6 @@
 ;;; url-ns.el --- Various netscape-ish functions for proxy definitions
 
-;; Copyright (C) 1997-1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes, hypermedia
 
diff --git a/lisp/url/url-parse.el b/lisp/url/url-parse.el
index 9cd5c0d..1f72f51 100644
--- a/lisp/url/url-parse.el
+++ b/lisp/url/url-parse.el
@@ -1,6 +1,6 @@
 ;;; url-parse.el --- Uniform Resource Locator parser -*- lexical-binding: t -*-
 
-;; Copyright (C) 1996-1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes
 
@@ -209,7 +209,7 @@ parses to
            ;; 3.3. Path
            (skip-chars-forward "^?#")
            ;; 3.4. Query
-           (when (looking-at "?")
+           (when (looking-at "\\?")
              (skip-chars-forward "^#"))
            (setq file (buffer-substring save-pos (point)))
            ;; 3.5 Fragment
diff --git a/lisp/url/url-privacy.el b/lisp/url/url-privacy.el
index 9edca7e..ef9ff84 100644
--- a/lisp/url/url-privacy.el
+++ b/lisp/url/url-privacy.el
@@ -1,6 +1,6 @@
 ;;; url-privacy.el --- Global history tracking for URL package
 
-;; Copyright (C) 1996-1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes, hypermedia
 
diff --git a/lisp/url/url-proxy.el b/lisp/url/url-proxy.el
index cd9f74b..c62b75a 100644
--- a/lisp/url/url-proxy.el
+++ b/lisp/url/url-proxy.el
@@ -1,6 +1,6 @@
 ;;; url-proxy.el --- Proxy server support
 
-;; Copyright (C) 1999, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2004-2019 Free Software Foundation, Inc.
 
 ;; Keywords: comm, data, processes, hypermedia
 
diff --git a/lisp/url/url-queue.el b/lisp/url/url-queue.el
index cfa8e9a..9bf1bca 100644
--- a/lisp/url/url-queue.el
+++ b/lisp/url/url-queue.el
@@ -1,6 +1,6 @@
 ;;; url-queue.el --- Fetching web pages in parallel   -*- lexical-binding: t 
-*-
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <address@hidden>
 ;; Keywords: comm
@@ -162,8 +162,8 @@ The variable `url-queue-timeout' sets a timeout."
     (dolist (job url-queue)
       ;; Kill jobs that have lasted longer than the timeout.
       (when (and (url-queue-start-time job)
-                (> (- (float-time) (url-queue-start-time job))
-                   url-queue-timeout))
+                (time-less-p url-queue-timeout
+                             (time-since (url-queue-start-time job))))
        (push job dead-jobs)))
     (dolist (job dead-jobs)
       (url-queue-kill-job job)
diff --git a/lisp/url/url-tramp.el b/lisp/url/url-tramp.el
index 5c2e574..305635c 100644
--- a/lisp/url/url-tramp.el
+++ b/lisp/url/url-tramp.el
@@ -1,6 +1,6 @@
 ;;; url-tramp.el --- file-name-handler magic invoking Tramp for some protocols
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 ;; Keywords: comm, data, processes, hypermedia
diff --git a/lisp/url/url-util.el b/lisp/url/url-util.el
index ffae984..5b83506 100644
--- a/lisp/url/url-util.el
+++ b/lisp/url/url-util.el
@@ -1,6 +1,6 @@
 ;;; url-util.el --- Miscellaneous helper routines for URL library -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1996-1999, 2001, 2004-2018 Free Software Foundation,
+;; Copyright (C) 1996-1999, 2001, 2004-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Bill Perry <address@hidden>
@@ -61,8 +61,6 @@ If a list, it is a list of the types of messages to be 
logged."
 
 ;;;###autoload
 (defun url-debug (tag &rest args)
-  (if quit-flag
-      (error "Interrupted!"))
   (if (or (eq url-debug t)
          (numberp url-debug)
          (and (listp url-debug) (memq tag url-debug)))
@@ -74,7 +72,8 @@ If a list, it is a list of the types of messages to be 
logged."
 
 ;;;###autoload
 (defun url-parse-args (str &optional nodowncase)
-  ;; Return an assoc list of attribute/value pairs from an RFC822-type string
+  ;; Return an assoc list of attribute/value pairs from a string
+  ;; that uses RFC 822 (or later) format.
   (let (
        name                            ; From name=
        value                           ; its value
@@ -182,7 +181,7 @@ Will not do anything if `url-show-status' is nil."
          (null url-show-status)
          (active-minibuffer-window)
          (= url-lazy-message-time
-            (setq url-lazy-message-time (nth 1 (current-time)))))
+            (setq url-lazy-message-time (encode-time nil 'integer))))
       nil
     (apply 'message args)))
 
@@ -502,7 +501,7 @@ WIDTH defaults to the current frame width."
         (urlobj nil))
     ;; The first thing that can go are the search strings
     (if (and (>= str-width fr-width)
-            (string-match "?" url))
+            (string-match "\\?" url))
        (setq url (concat (substring url 0 (match-beginning 0)) "?...")
              str-width (length url)))
     (if (< str-width fr-width)
diff --git a/lisp/url/url-vars.el b/lisp/url/url-vars.el
index ef990a7..ae1d6e5 100644
--- a/lisp/url/url-vars.el
+++ b/lisp/url/url-vars.el
@@ -1,6 +1,6 @@
 ;;; url-vars.el --- Variables for Uniform Resource Locator tool
 
-;; Copyright (C) 1996-1999, 2001, 2004-2018 Free Software Foundation,
+;; Copyright (C) 1996-1999, 2001, 2004-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Keywords: comm, data, processes, hypermedia
diff --git a/lisp/url/url.el b/lisp/url/url.el
index ea58101..ed09477 100644
--- a/lisp/url/url.el
+++ b/lisp/url/url.el
@@ -1,6 +1,6 @@
 ;;; url.el --- Uniform Resource Locator retrieval tool  -*- lexical-binding: t 
-*-
 
-;; Copyright (C) 1996-1999, 2001, 2004-2018 Free Software Foundation,
+;; Copyright (C) 1996-1999, 2001, 2004-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Bill Perry <address@hidden>
@@ -259,8 +259,7 @@ how long to wait for a response before giving up."
        ;; process output.
        (while (and (not retrieval-done)
                     (or (not timeout)
-                        (< (float-time (time-subtract nil start-time))
-                           timeout)))
+                       (time-less-p (time-since start-time) timeout)))
          (url-debug 'retrieval
                     "Spinning in url-retrieve-synchronously: %S (%S)"
                     retrieval-done asynch-buffer)
diff --git a/lisp/userlock.el b/lisp/userlock.el
index 73bb0d2..f077bc9 100644
--- a/lisp/userlock.el
+++ b/lisp/userlock.el
@@ -1,6 +1,6 @@
 ;;; userlock.el --- handle file access contention between multiple users
 
-;; Copyright (C) 1985-1986, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1986, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Richard King
 ;; (according to authors.el)
@@ -174,7 +174,9 @@ really edit the buffer? (y, n, r or C-h) "
 
 (defun ask-user-about-supersession-help ()
   (with-output-to-temp-buffer "*Help*"
-    (princ "You want to modify a buffer whose disk file has changed
+    (princ
+     (substitute-command-keys
+      "You want to modify a buffer whose disk file has changed
 since you last read it in or saved it with this buffer.
 
 If you say `y' to go ahead and modify this buffer,
@@ -184,7 +186,7 @@ from the file on disk.
 If you say `n', the change you started to make will be aborted.
 
 Usually, you should type `n' and then `\\[revert-buffer]',
-to get the latest version of the file, then make the change again.")
+to get the latest version of the file, then make the change again."))
     (with-current-buffer standard-output
       (help-mode))))
 
diff --git a/lisp/vc/add-log.el b/lisp/vc/add-log.el
index d6e8540..f9efd44 100644
--- a/lisp/vc/add-log.el
+++ b/lisp/vc/add-log.el
@@ -1,6 +1,6 @@
 ;;; add-log.el --- change log maintenance commands for Emacs
 
-;; Copyright (C) 1985-1986, 1988, 1993-1994, 1997-1998, 2000-2018 Free
+;; Copyright (C) 1985-1986, 1988, 1993-1994, 1997-1998, 2000-2019 Free
 ;; Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
@@ -239,7 +239,7 @@ a case simply use the directory containing the changed 
file."
     ;; wrongly with a non-date line existing as a random note.  In
     ;; addition, using any kind of fixed setting like this doesn't
     ;; work if a user customizes add-log-time-format.
-    ("^[0-9-]+ +\\|^ \\{11,\\}\\|^\t 
\\{3,\\}\\|^\\(Sun\\|Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\) [A-z][a-z][a-z] 
[0-9:+ ]+"
+    ("^[0-9-]+ +\\|^ \\{11,\\}\\|^\t 
\\{3,\\}\\|^\\(Sun\\|Mon\\|Tue\\|Wed\\|Thu\\|Fri\\|Sat\\) [A-Z][a-z][a-z] 
[0-9:+ ]+"
      (0 'change-log-date)
      ;; Name and e-mail; some people put e-mail in parens, not angles.
      ("\\([^<(]+?\\)[ \t]*[(<]\\(address@hidden)[>)]" nil nil
diff --git a/lisp/vc/compare-w.el b/lisp/vc/compare-w.el
index 4151063..02c08af 100644
--- a/lisp/vc/compare-w.el
+++ b/lisp/vc/compare-w.el
@@ -1,6 +1,6 @@
 ;;; compare-w.el --- compare text between windows for Emacs
 
-;; Copyright (C) 1986, 1989, 1993, 1997, 2001-2018 Free Software
+;; Copyright (C) 1986, 1989, 1993, 1997, 2001-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/vc/cvs-status.el b/lisp/vc/cvs-status.el
index b65b91c..ccc8e5f 100644
--- a/lisp/vc/cvs-status.el
+++ b/lisp/vc/cvs-status.el
@@ -1,6 +1,6 @@
 ;;; cvs-status.el --- major mode for browsing `cvs status' output -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords: pcl-cvs cvs status tree vc tools
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index 4adef02..a26e9ee 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -1,6 +1,6 @@
 ;;; diff-mode.el --- a mode for viewing/editing context diffs -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords: convenience patch diff vc
@@ -56,6 +56,7 @@
 (eval-when-compile (require 'cl-lib))
 
 (autoload 'vc-find-revision "vc")
+(autoload 'vc-find-revision-no-save "vc")
 (defvar vc-find-revision-no-save)
 (defvar add-log-buffer-file-name-function)
 
@@ -93,22 +94,59 @@ when editing big diffs)."
   :type 'hook
   :options '(diff-delete-empty-files diff-make-unified))
 
-(defcustom diff-font-lock-refine t
-  "If non-nil, font-lock highlighting includes hunk refinement."
+(defcustom diff-refine 'font-lock
+  "If non-nil, enable hunk refinement.
+
+The value `font-lock' means to refine during font-lock.
+The value `navigation' means to refine each hunk as you visit it
+with `diff-hunk-next' or `diff-hunk-prev'.
+
+You can always manually refine a hunk with `diff-refine-hunk'."
   :version "27.1"
-  :type 'boolean)
+  :type '(choice (const :tag "Don't refine hunks" nil)
+                 (const :tag "Refine hunks during font-lock" font-lock)
+                 (const :tag "Refine hunks during navigation" navigation)))
 
 (defcustom diff-font-lock-prettify nil
   "If non-nil, font-lock will try and make the format prettier."
   :version "27.1"
   :type 'boolean)
 
+(defcustom diff-font-lock-syntax t
+  "If non-nil, diff hunk font-lock includes source language syntax 
highlighting.
+This highlighting is the same as added by `font-lock-mode'
+when corresponding source files are visited normally.
+Syntax highlighting is added over diff-mode's own highlighted changes.
+
+If t, the default, highlight syntax only in Diff buffers created by Diff
+commands that compare files or by VC commands that compare revisions.
+These provide all necessary context for reliable highlighting.  This value
+requires support from a VC backend to find the files being compared.
+For diffs against the working-tree version of a file, the highlighting is
+based on the current file contents.  File-based fontification tries to
+infer fontification from the compared files.
+
+If `hunk-only' fontification is based on hunk alone, without full source.
+It tries to highlight hunks without enough context that sometimes might result
+in wrong fontification.  This is the fastest option, but less reliable.
+
+If `hunk-also', use reliable file-based syntax highlighting when available
+and hunk-based syntax highlighting otherwise as a fallback."
+  :version "27.1"
+  :type '(choice (const :tag "Don't highlight syntax" nil)
+                 (const :tag "Hunk-based only" hunk-only)
+                 (const :tag "Highlight syntax" t)
+                 (const :tag "Allow hunk-based fallback" hunk-also)))
+
 (defvar diff-vc-backend nil
   "The VC backend that created the current Diff buffer, if any.")
 
 (defvar diff-vc-revisions nil
   "The VC revisions compared in the current Diff buffer, if any.")
 
+(defvar-local diff-default-directory nil
+  "The default directory where the current Diff buffer was created.")
+
 (defvar diff-outline-regexp
   "\\([*+][*+][*+] [^0-9]\\|@@ ...\\|\\*\\*\\* [0-9].\\|--- [0-9]..\\)")
 
@@ -224,16 +262,22 @@ when editing big diffs)."
   "Keymap for `diff-minor-mode'.  See also `diff-mode-shared-map'.")
 
 (define-minor-mode diff-auto-refine-mode
-  "Toggle automatic diff hunk highlighting (Diff Auto Refine mode).
+  "Toggle automatic diff hunk finer highlighting (Diff Auto Refine mode).
 
 Diff Auto Refine mode is a buffer-local minor mode used with
 `diff-mode'.  When enabled, Emacs automatically highlights
 changes in detail as the user visits hunks.  When transitioning
 from disabled to enabled, it tries to refine the current hunk, as
 well."
-  :group 'diff-mode :init-value t :lighter nil ;; " Auto-Refine"
-  (when diff-auto-refine-mode
-    (condition-case-unless-debug nil (diff-refine-hunk) (error nil))))
+  :group 'diff-mode :init-value nil :lighter nil ;; " Auto-Refine"
+  (if diff-auto-refine-mode
+      (progn
+        (customize-set-variable 'diff-refine 'navigation)
+        (condition-case-unless-debug nil (diff-refine-hunk) (error nil)))
+    (customize-set-variable 'diff-refine nil)))
+(make-obsolete 'diff-auto-refine-mode "set `diff-refine' instead." "27.1")
+(make-obsolete-variable 'diff-auto-refine-mode
+                        "set `diff-refine' instead." "27.1")
 
 ;;;;
 ;;;; font-lock support
@@ -241,7 +285,7 @@ well."
 
 (defface diff-header
   '((((class color) (min-colors 88) (background light))
-     :background "grey80")
+     :background "grey85")
     (((class color) (min-colors 88) (background dark))
      :background "grey45")
     (((class color))
@@ -251,7 +295,7 @@ well."
 
 (defface diff-file-header
   '((((class color) (min-colors 88) (background light))
-     :background "grey70" :weight bold)
+     :background "grey75" :weight bold)
     (((class color) (min-colors 88) (background dark))
      :background "grey60" :weight bold)
     (((class color))
@@ -271,7 +315,7 @@ well."
   '((default
      :inherit diff-changed)
     (((class color) (min-colors 88) (background light))
-     :background "#ffdddd")
+     :background "#ffeeee")
     (((class color) (min-colors 88) (background dark))
      :background "#553333")
     (((class color))
@@ -282,7 +326,7 @@ well."
   '((default
      :inherit diff-changed)
     (((class color) (min-colors 88) (background light))
-     :background "#ddffdd")
+     :background "#eeffee")
     (((class color) (min-colors 88) (background dark))
      :background "#335533")
     (((class color))
@@ -295,19 +339,25 @@ well."
   :version "25.1")
 
 (defface diff-indicator-removed
-  '((t :inherit diff-removed))
+  '((default :inherit diff-removed)
+    (((class color) (min-colors 88))
+     :foreground "#aa2222"))
   "`diff-mode' face used to highlight indicator of removed lines (-, <)."
   :version "22.1")
 (defvar diff-indicator-removed-face 'diff-indicator-removed)
 
 (defface diff-indicator-added
-  '((t :inherit diff-added))
+  '((default :inherit diff-added)
+    (((class color) (min-colors 88))
+     :foreground "#22aa22"))
   "`diff-mode' face used to highlight indicator of added lines (+, >)."
   :version "22.1")
 (defvar diff-indicator-added-face 'diff-indicator-added)
 
 (defface diff-indicator-changed
-  '((t :inherit diff-changed))
+  '((default :inherit diff-changed)
+    (((class color) (min-colors 88))
+     :foreground "#aaaa22"))
   "`diff-mode' face used to highlight indicator of changed lines."
   :version "22.1")
 (defvar diff-indicator-changed-face 'diff-indicator-changed)
@@ -317,10 +367,7 @@ well."
   "`diff-mode' face used to highlight function names produced by \"diff -p\".")
 
 (defface diff-context
-  '((((class color grayscale) (min-colors 88) (background light))
-     :foreground "#333333")
-    (((class color grayscale) (min-colors 88) (background dark))
-     :foreground "#dddddd"))
+  '((t nil))
   "`diff-mode' face used to highlight context and other side-information."
   :version "25.1")
 
@@ -401,11 +448,15 @@ and the face `diff-added' for added lines.")
                'diff-removed))))))
     ("^\\(?:Index\\|revno\\): \\(.+\\).*\n"
      (0 'diff-header) (1 'diff-index prepend))
+    ("^\\(?:index .*\\.\\.\\|diff \\).*\n" . 'diff-header)
+    ("^\\(?:new\\|deleted\\) file mode .*\n" . 'diff-header)
     ("^Only in .*\n" . 'diff-nonexistent)
+    ("^Binary files .* differ\n" . 'diff-file-header)
     ("^\\(#\\)\\(.*\\)"
      (1 font-lock-comment-delimiter-face)
      (2 font-lock-comment-face))
     ("^[^-=+*!<>#].*\n" (0 'diff-context))
+    (,#'diff--font-lock-syntax)
     (,#'diff--font-lock-prettify)
     (,#'diff--font-lock-refined)))
 
@@ -481,7 +532,8 @@ See 
https://lists.gnu.org/r/emacs-devel/2007-11/msg01990.html";)
                                      "^[^-+# \\\n]\\|" "^[^-+# \\]\\|")
                                  ;; A `unified' header is ambiguous.
                                  diff-file-header-re))
-                        ('context "^[^-+#! \\]")
+                        ('context (if diff-valid-unified-empty-line
+                                      "^[^-+#! \n\\]" "^[^-+#! \\]"))
                         ('normal "^[^<>#\\]")
                         (_ "^[^-+#!<> \\]"))
                       nil t)
@@ -585,7 +637,7 @@ next hunk if TRY-HARDER is non-nil; otherwise signal an 
error."
 ;; Define diff-{hunk,file}-{prev,next}
 (easy-mmode-define-navigation
  diff-hunk diff-hunk-header-re "hunk" diff-end-of-hunk diff-restrict-view
- (when diff-auto-refine-mode
+ (when (and (eq diff-refine 'navigation) (called-interactively-p 'interactive))
    (unless (prog1 diff--auto-refine-data
              (setq diff--auto-refine-data
                    (cons (current-buffer) (point-marker))))
@@ -1013,7 +1065,7 @@ else cover the whole buffer."
                             " ----\n" hunk))
                  ;;(goto-char (point-min))
                  (forward-line 1)
-                 (if (not (save-excursion (re-search-forward "^+" nil t)))
+                 (if (not (save-excursion (re-search-forward "^\\+" nil t)))
                      (delete-region (point) (point-max))
                    (let ((modif nil) (delete nil))
                      (if (save-excursion (re-search-forward "^\\+.*\n-"
@@ -1348,6 +1400,7 @@ See `after-change-functions' for the meaning of BEG, END 
and LEN."
 
 (defun diff--font-lock-cleanup ()
   (remove-overlays nil nil 'diff-mode 'fine)
+  (remove-overlays nil nil 'diff-mode 'syntax)
   (when font-lock-mode
     (make-local-variable 'font-lock-extra-managed-props)
     ;; Added when diff--font-lock-prettify is non-nil!
@@ -1420,7 +1473,7 @@ a diff with \\[diff-reverse-direction].
        (lambda () (diff-find-file-name nil 'noprompt)))
   (add-function :filter-return (local 'filter-buffer-substring-function)
                 #'diff--filter-substring)
-  (unless (buffer-file-name)
+  (unless buffer-file-name
     (hack-dir-local-variables-non-file-buffer)))
 
 ;;;###autoload
@@ -1661,10 +1714,11 @@ char-offset in TEXT."
              (delete-region divider-pos (point-max)))
            (delete-region (point-min) keep))
          ;; Remove line-prefix characters, and unneeded lines (unified diffs).
-         (let ((kill-char (if destp ?- ?+)))
+          ;; Also skip lines like "\ No newline at end of file"
+         (let ((kill-chars (list (if destp ?- ?+) ?\\)))
            (goto-char (point-min))
            (while (not (eobp))
-             (if (eq (char-after) kill-char)
+             (if (memq (char-after) kill-chars)
                  (delete-region (point) (progn (forward-line 1) (point)))
                (delete-char num-pfx-chars)
                (forward-line 1)))))
@@ -1748,7 +1802,7 @@ NOPROMPT, if non-nil, means not to prompt the user."
                                 (vc-working-revision file)))))
           (buf (if revision
                     (let ((vc-find-revision-no-save t))
-                      (vc-find-revision file revision diff-vc-backend))
+                      (vc-find-revision (expand-file-name file) revision 
diff-vc-backend))
                   (find-file-noselect file))))
       ;; Update the user preference if he so wished.
       (when (> (prefix-numeric-value other-file) 8)
@@ -1987,7 +2041,7 @@ For use in `add-log-current-defun-function'."
   '((default
      :inherit diff-refine-changed)
     (((class color) (min-colors 88) (background light))
-     :background "#ffbbbb")
+     :background "#ffcccc")
     (((class color) (min-colors 88) (background dark))
      :background "#aa2222"))
   "Face used for removed characters shown by `diff-refine-hunk'."
@@ -1997,7 +2051,7 @@ For use in `add-log-current-defun-function'."
   '((default
      :inherit diff-refine-changed)
     (((class color) (min-colors 88) (background light))
-     :background "#aaffaa")
+     :background "#bbffbb")
     (((class color) (min-colors 88) (background dark))
      :background "#22aa22"))
   "Face used for added characters shown by `diff-refine-hunk'."
@@ -2062,7 +2116,7 @@ Return new point, if it was moved."
              (smerge-refine-regions beg-del beg-add beg-add end-add
                                     nil #'diff-refine-preproc props-r 
props-a)))))
       ('context
-       (let* ((middle (save-excursion (re-search-forward "^---")))
+       (let* ((middle (save-excursion (re-search-forward "^---" end)))
               (other middle))
          (while (re-search-forward "^\\(?:!.*\n\\)+" middle t)
            (smerge-refine-regions (match-beginning 0) (match-end 0)
@@ -2084,9 +2138,29 @@ Return new point, if it was moved."
                                   (match-end 0) end
                                   nil #'diff-refine-preproc props-r 
props-a)))))))
 
+(defun diff--iterate-hunks (max fun)
+  "Iterate over all hunks between point and MAX.
+Call FUN with two args (BEG and END) for each hunk."
+  (save-excursion
+    (let* ((beg (or (ignore-errors (diff-beginning-of-hunk))
+                    (ignore-errors (diff-hunk-next) (point))
+                    max)))
+      (while (< beg max)
+        (goto-char beg)
+        (cl-assert (looking-at diff-hunk-header-re))
+        (let ((end
+               (save-excursion (diff-end-of-hunk) (point))))
+          (cl-assert (< beg end))
+          (funcall fun beg end)
+          (goto-char end)
+          (setq beg (if (looking-at diff-hunk-header-re)
+                        end
+                      (or (ignore-errors (diff-hunk-next) (point))
+                          max))))))))
+
 (defun diff--font-lock-refined (max)
   "Apply hunk refinement from font-lock."
-  (when diff-font-lock-refine
+  (when (eq diff-refine 'font-lock)
     (when (get-char-property (point) 'diff--font-lock-refined)
       ;; Refinement works over a complete hunk, whereas font-lock limits itself
       ;; to highlighting smallish chunks between point..max, so we may be
@@ -2099,27 +2173,19 @@ Return new point, if it was moved."
       ;; same hunk.
       (goto-char (next-single-char-property-change
                   (point) 'diff--font-lock-refined nil max)))
-    (let* ((min (point))
-           (beg (or (ignore-errors (diff-beginning-of-hunk))
-                    (ignore-errors (diff-hunk-next) (point))
-                    max)))
-      (while (< beg max)
-        (let ((end
-               (save-excursion (goto-char beg) (diff-end-of-hunk) (point))))
-          (if (< end min) (setq beg min))
-          (unless (or (< end beg)
-                      (get-char-property beg 'diff--font-lock-refined))
-            (diff--refine-hunk beg end)
-            (let ((ol (make-overlay beg end)))
-              (overlay-put ol 'diff--font-lock-refined t)
-              (overlay-put ol 'diff-mode 'fine)
-              (overlay-put ol 'evaporate t)
-              (overlay-put ol 'modification-hooks
-                           '(diff--font-lock-refine--refresh))))
-          (goto-char (max beg end))
-          (setq beg (or (ignore-errors (diff-hunk-next) (point)) max)))))))
-
-(defun diff--font-lock-refine--refresh (ol _after _beg _end &optional _len)
+    (diff--iterate-hunks
+     max
+     (lambda (beg end)
+       (unless (get-char-property beg 'diff--font-lock-refined)
+         (diff--refine-hunk beg end)
+         (let ((ol (make-overlay beg end)))
+           (overlay-put ol 'diff--font-lock-refined t)
+           (overlay-put ol 'diff-mode 'fine)
+           (overlay-put ol 'evaporate t)
+           (overlay-put ol 'modification-hooks
+                        '(diff--overlay-auto-delete))))))))
+
+(defun diff--overlay-auto-delete (ol _after _beg _end &optional _len)
   (delete-overlay ol))
 
 (defun diff-undo (&optional arg)
@@ -2146,7 +2212,7 @@ I.e. like `add-change-log-entry-other-window' but applied 
to all hunks."
                  ;; `add-change-log-entry-other-window' works better in
                  ;; that case.
                  (re-search-forward
-                  (concat "\n[!+-<>]"
+                 (concat "\n[!+<>-]"
                           ;; If the hunk is a context hunk with an empty first
                           ;; half, recognize the "--- NNN,MMM ----" line
                           "\\(-- [0-9]+\\(,[0-9]+\\)? ----\n"
@@ -2284,9 +2350,9 @@ fixed, visit it in a buffer."
       ;; FIXME: Include the first space for context-style hunks!
       (while (re-search-forward "^[-+! ]" limit t)
         (let ((spec (alist-get (char-before)
-                               '((?+ . (left-fringe diff-fringe-add 
diff-added))
-                                 (?- . (left-fringe diff-fringe-del 
diff-removed))
-                                 (?! . (left-fringe diff-fringe-rep 
diff-changed))
+                               '((?+ . (left-fringe diff-fringe-add 
diff-indicator-added))
+                                 (?- . (left-fringe diff-fringe-del 
diff-indicator-removed))
+                                 (?! . (left-fringe diff-fringe-rep 
diff-indicator-changed))
                                  (?\s . (left-fringe diff-fringe-nul))))))
           (put-text-property (match-beginning 0) (match-end 0) 'display 
spec))))
     ;; Mimicks the output of Magit's diff.
@@ -2316,6 +2382,225 @@ fixed, visit it in a buffer."
                              'display "")))))
   nil)
 
+;;; Syntax highlighting from font-lock
+
+(defun diff--font-lock-syntax (max)
+  "Apply source language syntax highlighting from font-lock.
+Calls `diff-syntax-fontify' on every hunk found between point
+and the position in MAX."
+  (when diff-font-lock-syntax
+    (when (get-char-property (point) 'diff--font-lock-syntax)
+      (goto-char (next-single-char-property-change
+                  (point) 'diff--font-lock-syntax nil max)))
+    (diff--iterate-hunks
+     max
+     (lambda (beg end)
+       (unless (get-char-property beg 'diff--font-lock-syntax)
+         (diff-syntax-fontify beg end)
+         (let ((ol (make-overlay beg end)))
+           (overlay-put ol 'diff--font-lock-syntax t)
+           (overlay-put ol 'diff-mode 'syntax)
+           (overlay-put ol 'evaporate t)
+           (overlay-put ol 'modification-hooks
+                        '(diff--overlay-auto-delete))))))))
+
+(defun diff-syntax-fontify (beg end)
+  "Highlight source language syntax in diff hunk between BEG and END."
+  (remove-overlays beg end 'diff-mode 'syntax)
+  (save-excursion
+    (diff-syntax-fontify-hunk beg end t)
+    (diff-syntax-fontify-hunk beg end nil)))
+
+(eval-when-compile (require 'subr-x)) ; for string-trim-right
+
+(defvar-local diff--syntax-file-attributes nil)
+(put 'diff--syntax-file-attributes 'permanent-local t)
+
+(defun diff-syntax-fontify-hunk (beg end old)
+  "Highlight source language syntax in diff hunk between BEG and END.
+When OLD is non-nil, highlight the hunk from the old source."
+  (goto-char beg)
+  (let* ((hunk (buffer-substring-no-properties beg end))
+         ;; Trim a trailing newline to find hunk in diff-syntax-fontify-props
+         ;; in diffs that have no newline at end of diff file.
+         (text (string-trim-right
+                (or (with-demoted-errors (diff-hunk-text hunk (not old) nil))
+                    "")))
+        (line (if (looking-at "\\(?:\\*\\{15\\}.*\n\\)address@hidden 
]*\\([0-9,]+\\)\\([ acd+]+\\([0-9,]+\\)\\)?")
+                  (if old (match-string 1)
+                    (if (match-end 3) (match-string 3) (match-string 1)))))
+         (line-nb (when line
+                    (if (string-match "\\([0-9]+\\),\\([0-9]+\\)" line)
+                        (list (string-to-number (match-string 1 line))
+                              (string-to-number (match-string 2 line)))
+                      (list (string-to-number line) 1)))) ; One-line diffs
+         (props
+          (or
+           (when (and diff-vc-backend
+                      (not (eq diff-font-lock-syntax 'hunk-only)))
+             (let* ((file (diff-find-file-name old t))
+                    (file (and file (expand-file-name file)))
+                    (revision (and file (if (not old) (nth 1 diff-vc-revisions)
+                                          (or (nth 0 diff-vc-revisions)
+                                              (vc-working-revision file))))))
+               (when file
+                 (if (not revision)
+                     ;; Get properties from the current working revision
+                     (when (and (not old) (file-readable-p file)
+                                (file-regular-p file))
+                       (let ((buf (get-file-buffer file)))
+                         ;; Try to reuse an existing buffer
+                         (if buf
+                             (with-current-buffer buf
+                               (diff-syntax-fontify-props nil text line-nb))
+                           ;; Get properties from the file.
+                           (with-current-buffer (get-buffer-create
+                                                 " *diff-syntax-file*")
+                             (let ((attrs (file-attributes file)))
+                               (if (equal diff--syntax-file-attributes attrs)
+                                   ;; Same file as last-time, unmodified.
+                                   ;; Reuse buffer as-is.
+                                   (setq file nil)
+                                 (erase-buffer)
+                                 (insert-file-contents file)
+                                 (setq diff--syntax-file-attributes attrs)))
+                             (diff-syntax-fontify-props file text line-nb)))))
+                   ;; Get properties from a cached revision
+                   (let* ((buffer-name (format " *diff-syntax:%s.~%s~*"
+                                               file revision))
+                          (buffer (get-buffer buffer-name)))
+                     (if buffer
+                         ;; Don't re-initialize the buffer (which would throw
+                         ;; away the previous fontification work).
+                         (setq file nil)
+                       (setq buffer (ignore-errors
+                                      (vc-find-revision-no-save
+                                       file revision
+                                       diff-vc-backend
+                                       (get-buffer-create buffer-name)))))
+                     (when buffer
+                       (with-current-buffer buffer
+                         (diff-syntax-fontify-props file text line-nb))))))))
+           (let ((file (car (diff-hunk-file-names old))))
+             (cond
+              ((and file diff-default-directory
+                    (not (eq diff-font-lock-syntax 'hunk-only))
+                    (not diff-vc-backend)
+                    (file-readable-p file) (file-regular-p file))
+               ;; Try to get full text from the file.
+               (with-temp-buffer
+                 (insert-file-contents file)
+                 (diff-syntax-fontify-props file text line-nb)))
+              ;; Otherwise, get properties from the hunk alone
+              ((memq diff-font-lock-syntax '(hunk-also hunk-only))
+               (with-temp-buffer
+                 (insert text)
+                 (diff-syntax-fontify-props file text line-nb t))))))))
+
+    ;; Put properties over the hunk text
+    (goto-char beg)
+    (when (and props (eq (diff-hunk-style) 'unified))
+      (while (< (progn (forward-line 1) (point)) end)
+        ;; Skip the "\ No newline at end of file" lines as well as the lines
+        ;; corresponding to the "other" version.
+        (unless (looking-at-p (if old "[+>\\]" "[-<\\]"))
+          (if (and old (not (looking-at-p "[-<]")))
+              ;; Fontify context lines only from new source,
+              ;; don't refontify context lines from old source.
+              (pop props)
+            (let ((line-props (pop props))
+                  (bol (1+ (point))))
+              (dolist (prop line-props)
+                ;; Ideally, we'd want to use text-properties as in:
+                ;;
+                ;;     (add-face-text-property
+                ;;      (+ bol (nth 0 prop)) (+ bol (nth 1 prop))
+                ;;      (nth 2 prop) 'append)
+                ;;
+                ;; rather than overlays here, but they'd get removed by later
+                ;; font-locking.
+                ;; This is because we also apply faces outside of the
+                ;; beg...end chunk currently font-locked and when font-lock
+                ;; later comes to handle the rest of the hunk that we already
+                ;; handled we don't (want to) redo it (we work at
+                ;; hunk-granularity rather than font-lock's own chunk
+                ;; granularity).
+                ;; I see two ways to fix this:
+                ;; - don't immediately apply the props that fall outside of
+                ;;   font-lock's chunk but stash them somewhere (e.g. in 
another
+                ;;   text property) and only later when font-lock comes back
+                ;;   move them to `face'.
+                ;; - change the code so work at font-lock's chunk granularity
+                ;;   (this seems doable without too much extra overhead,
+                ;;   contrary to the refine highlighting, which inherently
+                ;;   works at a different granularity).
+                (let ((ol (make-overlay (+ bol (nth 0 prop))
+                                        (+ bol (nth 1 prop))
+                                        nil 'front-advance nil)))
+                  (overlay-put ol 'diff-mode 'syntax)
+                  (overlay-put ol 'evaporate t)
+                  (overlay-put ol 'face (nth 2 prop)))))))))))
+
+(defun diff-syntax-fontify-props (file text line-nb &optional hunk-only)
+  "Get font-lock properties from the source code.
+FILE is the name of the source file.  If non-nil, it requests initialization
+of the mode according to FILE.
+TEXT is the literal source text from hunk.
+LINE-NB is a pair of numbers: start line number and the number of
+lines in the hunk.
+When HUNK-ONLY is non-nil, then don't verify the existence of the
+hunk text in the source file.  Otherwise, don't highlight the hunk if the
+hunk text is not found in the source file."
+  (when file
+    ;; When initialization is requested, we should be in a brand new
+    ;; temp buffer.
+    (cl-assert (null buffer-file-name))
+    (let ((enable-local-variables :safe) ;; to find `mode:'
+          (buffer-file-name file))
+      (set-auto-mode)
+      ;; FIXME: Is this really worth the trouble?
+      (when (and (fboundp 'generic-mode-find-file-hook)
+                 (memq #'generic-mode-find-file-hook
+                       ;; There's no point checking the buffer-local value,
+                       ;; we're in a fresh new buffer.
+                       (default-value 'find-file-hook)))
+        (generic-mode-find-file-hook))))
+
+  (let ((font-lock-defaults (or font-lock-defaults '(nil t)))
+        props beg end)
+    (goto-char (point-min))
+    (if hunk-only
+        (setq beg (point-min) end (point-max))
+      (forward-line (1- (nth 0 line-nb)))
+      ;; non-regexp looking-at to compare hunk text for verification
+      (if (search-forward text (+ (point) (length text)) t)
+          (setq beg (- (point) (length text)) end (point))
+        (goto-char (point-min))
+        (if (search-forward text nil t)
+            (setq beg (- (point) (length text)) end (point)))))
+
+    (when (and beg end)
+      (goto-char beg)
+      (font-lock-ensure beg end)
+
+      (while (< (point) end)
+        (let* ((bol (point))
+               (eol (line-end-position))
+               line-props
+               (searching t)
+               (from (point)) to
+               (val (get-text-property from 'face)))
+          (while searching
+            (setq to (next-single-property-change from 'face nil eol))
+            (when val (push (list (- from bol) (- to bol) val) line-props))
+            (setq val (get-text-property to 'face) from to)
+            (unless (< to eol) (setq searching nil)))
+          (when val (push (list from eol val) line-props))
+          (push (nreverse line-props) props))
+        (forward-line 1)))
+    (nreverse props)))
+
+
 (defun diff--filter-substring (str)
   (when diff-font-lock-prettify
     ;; Strip the `display' properties added by diff-font-lock-prettify,
diff --git a/lisp/vc/diff.el b/lisp/vc/diff.el
index ac94586..523be87 100644
--- a/lisp/vc/diff.el
+++ b/lisp/vc/diff.el
@@ -1,6 +1,6 @@
 ;;; diff.el --- run `diff'  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1992, 1994, 1996, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1992, 1994, 1996, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Frank Bresz
@@ -121,6 +121,8 @@ Possible values are:
   nil   -- no, it does not
   check -- try to probe whether it does")
 
+(defvar diff-default-directory)
+
 (defun diff-no-select (old new &optional switches no-async buf)
   ;; Noninteractive helper for creating and reverting diff buffers
   (unless (bufferp new) (setq new (expand-file-name new)))
@@ -165,6 +167,7 @@ Possible values are:
            (lambda (_ignore-auto _noconfirm)
              (diff-no-select old new switches no-async (current-buffer))))
       (setq default-directory thisdir)
+      (setq diff-default-directory default-directory)
       (let ((inhibit-read-only t))
        (insert command "\n"))
       (if (and (not no-async) (fboundp 'make-process))
diff --git a/lisp/vc/ediff-diff.el b/lisp/vc/ediff-diff.el
index 3441092..a1d27af 100644
--- a/lisp/vc/ediff-diff.el
+++ b/lisp/vc/ediff-diff.el
@@ -1,6 +1,6 @@
 ;;; ediff-diff.el --- diff-related utilities
 
-;; Copyright (C) 1994-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <address@hidden>
 ;; Package: ediff
diff --git a/lisp/vc/ediff-help.el b/lisp/vc/ediff-help.el
index 0c8b840..11c8b35 100644
--- a/lisp/vc/ediff-help.el
+++ b/lisp/vc/ediff-help.el
@@ -1,6 +1,6 @@
 ;;; ediff-help.el --- Code related to the contents of Ediff help buffers
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <address@hidden>
 ;; Package: ediff
diff --git a/lisp/vc/ediff-hook.el b/lisp/vc/ediff-hook.el
index 9b697c8..8412215 100644
--- a/lisp/vc/ediff-hook.el
+++ b/lisp/vc/ediff-hook.el
@@ -1,6 +1,6 @@
 ;;; ediff-hook.el --- setup for Ediff's menus and autoloads
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <address@hidden>
 ;; Package: ediff
diff --git a/lisp/vc/ediff-init.el b/lisp/vc/ediff-init.el
index ee36a82..a74d6a8 100644
--- a/lisp/vc/ediff-init.el
+++ b/lisp/vc/ediff-init.el
@@ -1,6 +1,6 @@
 ;;; ediff-init.el --- Macros, variables, and defsubsts used by Ediff
 
-;; Copyright (C) 1994-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <address@hidden>
 ;; Package: ediff
diff --git a/lisp/vc/ediff-merg.el b/lisp/vc/ediff-merg.el
index b67f520..a511f44 100644
--- a/lisp/vc/ediff-merg.el
+++ b/lisp/vc/ediff-merg.el
@@ -1,6 +1,6 @@
 ;;; ediff-merg.el --- merging utilities
 
-;; Copyright (C) 1994-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <address@hidden>
 ;; Package: ediff
diff --git a/lisp/vc/ediff-mult.el b/lisp/vc/ediff-mult.el
index 342e91d..21f8916 100644
--- a/lisp/vc/ediff-mult.el
+++ b/lisp/vc/ediff-mult.el
@@ -1,6 +1,6 @@
 ;;; ediff-mult.el --- support for multi-file/multi-buffer processing in Ediff
 
-;; Copyright (C) 1995-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <address@hidden>
 ;; Package: ediff
diff --git a/lisp/vc/ediff-ptch.el b/lisp/vc/ediff-ptch.el
index 03f5421..4178b5a 100644
--- a/lisp/vc/ediff-ptch.el
+++ b/lisp/vc/ediff-ptch.el
@@ -1,6 +1,6 @@
 ;;; ediff-ptch.el --- Ediff's  patch support
 
-;; Copyright (C) 1996-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <address@hidden>
 ;; Package: ediff
@@ -681,7 +681,7 @@ optional argument, then use it."
        (error
         "Ediff doesn't take the -V option in `ediff-patch-options'--sorry"))
 
-    ;; Make a temp file, if source-filename has a magic file handler (or if
+    ;; Make a temp file, if source-filename has a magic file name handler (or 
if
     ;; it is handled via auto-mode-alist and similar magic).
     ;; Check if there is a buffer visiting source-filename and if they are in
     ;; sync; arrange for the deletion of temp file.
@@ -691,7 +691,7 @@ optional argument, then use it."
     ;; Check if source file name has triggered black magic, such as file name
     ;; handlers or auto mode alist, and make a note of it.
     ;; true-source-filename should be either the original name or a
-    ;; temporary file where we put the after-product of the file handler.
+    ;; temporary file where we put the after-product of the file name handler.
     (setq file-name-magic-p (not (equal (file-truename true-source-filename)
                                        (file-truename source-filename))))
 
diff --git a/lisp/vc/ediff-util.el b/lisp/vc/ediff-util.el
index b1652e7..6e282a4 100644
--- a/lisp/vc/ediff-util.el
+++ b/lisp/vc/ediff-util.el
@@ -1,6 +1,6 @@
 ;;; ediff-util.el --- the core commands and utilities of ediff  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1994-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <address@hidden>
 ;; Package: ediff
@@ -3221,9 +3221,9 @@ Hit \\[ediff-recenter] to reset the windows afterward."
          short-f (concat ediff-temp-file-prefix short-p)
          f (cond (given-file)
                  ((find-file-name-handler f 'insert-file-contents)
-                  ;; to thwart file handlers in write-region, e.g., if file
-                  ;; name ends with .Z or .gz
-                  ;; This is needed so that patches produced by ediff will
+                  ;; to thwart file name handlers in write-region,
+                  ;; e.g., if file name ends with .Z or .gz
+                   ;; This is needed so that patches produced by ediff will
                   ;; have more meaningful names
                   (ediff-make-empty-tmp-file short-f))
                  (prefix
diff --git a/lisp/vc/ediff-vers.el b/lisp/vc/ediff-vers.el
index d3f918c..664ae5a 100644
--- a/lisp/vc/ediff-vers.el
+++ b/lisp/vc/ediff-vers.el
@@ -1,6 +1,6 @@
 ;;; ediff-vers.el --- version control interface to Ediff
 
-;; Copyright (C) 1995-1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995-1997, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <address@hidden>
 ;; Package: ediff
diff --git a/lisp/vc/ediff-wind.el b/lisp/vc/ediff-wind.el
index 0535aa6..492ddd3 100644
--- a/lisp/vc/ediff-wind.el
+++ b/lisp/vc/ediff-wind.el
@@ -1,6 +1,6 @@
 ;;; ediff-wind.el --- window manipulation utilities
 
-;; Copyright (C) 1994-1997, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-1997, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <address@hidden>
 ;; Package: ediff
diff --git a/lisp/vc/ediff.el b/lisp/vc/ediff.el
index f424fdb..0dfbe2e 100644
--- a/lisp/vc/ediff.el
+++ b/lisp/vc/ediff.el
@@ -1,6 +1,6 @@
 ;;; ediff.el --- a comprehensive visual interface to diff & patch
 
-;; Copyright (C) 1994-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Kifer <address@hidden>
 ;; Created: February 2, 1994
diff --git a/lisp/vc/log-edit.el b/lisp/vc/log-edit.el
index d407aab..91e18c1 100644
--- a/lisp/vc/log-edit.el
+++ b/lisp/vc/log-edit.el
@@ -1,6 +1,6 @@
 ;;; log-edit.el --- Major mode for editing CVS commit messages -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords: pcl-cvs cvs commit log vc
@@ -350,7 +350,7 @@ The first subexpression is the actual text of the field.")
 (defun log-edit-goto-eoh ()             ;FIXME: Almost rfc822-goto-eoh!
   (goto-char (point-min))
   (when (re-search-forward
-        "^\\([^[:alpha:]]\\|[[:alnum:]-]+[^[:alnum:]-:]\\)" nil 'move)
+        "^\\([^[:alpha:]]\\|[[:alnum:]-]+[^[:alnum:]-]\\)" nil 'move)
     (goto-char (match-beginning 0))))
 
 (defun log-edit--match-first-line (limit)
@@ -754,7 +754,9 @@ regardless of user name or time."
             (log-edit-insert-changelog-entries (log-edit-files)))))
       (log-edit-set-common-indentation)
       ;; Add an Author: field if appropriate.
-      (when author (log-edit-add-field "Author" (car author)))
+      (when author
+        (log-edit-add-field "Author" (car author))
+        (log-edit-add-field "Summary" ""))
       ;; Add a Fixes: field if applicable.
       (when (consp log-edit-rewrite-fixes)
        (rfc822-goto-eoh)
@@ -1085,6 +1087,22 @@ line of MSG."
       (if summary (insert summary "\n\n"))
       (cons (buffer-string) res))))
 
+(defun log-edit--toggle-amend (last-msg-fn)
+  (when (log-edit-toggle-header "Amend" "yes")
+    (goto-char (point-max))
+    (unless (bolp) (insert "\n"))
+    (insert (funcall last-msg-fn))
+    (save-excursion
+      (rfc822-goto-eoh)
+      (forward-line 1)
+      (let ((pt (point)))
+        (and (zerop (forward-line 1))
+             (looking-at "\n\\|\\'")
+             (let ((summary (buffer-substring-no-properties pt (1- (point)))))
+               (skip-chars-forward " \n")
+               (delete-region pt (point))
+               (log-edit-set-header "Summary" summary)))))))
+
 (provide 'log-edit)
 
 ;;; log-edit.el ends here
diff --git a/lisp/vc/log-view.el b/lisp/vc/log-view.el
index e3ae8fa..e47fad8 100644
--- a/lisp/vc/log-view.el
+++ b/lisp/vc/log-view.el
@@ -1,6 +1,6 @@
 ;;; log-view.el --- Major mode for browsing revision log histories -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords: tools, vc
diff --git a/lisp/vc/pcvs-defs.el b/lisp/vc/pcvs-defs.el
index 362498d..7065b8d 100644
--- a/lisp/vc/pcvs-defs.el
+++ b/lisp/vc/pcvs-defs.el
@@ -1,6 +1,6 @@
 ;;; pcvs-defs.el --- variable definitions for PCL-CVS
 
-;; Copyright (C) 1991-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1991-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords: pcl-cvs
diff --git a/lisp/vc/pcvs-info.el b/lisp/vc/pcvs-info.el
index 7609f98..224bab3 100644
--- a/lisp/vc/pcvs-info.el
+++ b/lisp/vc/pcvs-info.el
@@ -1,6 +1,6 @@
 ;;; pcvs-info.el --- internal representation of a fileinfo entry
 
-;; Copyright (C) 1991-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1991-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords: pcl-cvs
diff --git a/lisp/vc/pcvs-parse.el b/lisp/vc/pcvs-parse.el
index dbd25d9..0596ccb 100644
--- a/lisp/vc/pcvs-parse.el
+++ b/lisp/vc/pcvs-parse.el
@@ -1,6 +1,6 @@
 ;;; pcvs-parse.el --- the CVS output parser
 
-;; Copyright (C) 1991-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1991-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords: pcl-cvs
diff --git a/lisp/vc/pcvs-util.el b/lisp/vc/pcvs-util.el
index 5edd886..55da04f 100644
--- a/lisp/vc/pcvs-util.el
+++ b/lisp/vc/pcvs-util.el
@@ -1,6 +1,6 @@
 ;;; pcvs-util.el --- utility functions for PCL-CVS  -*- byte-compile-dynamic: 
t -*-
 
-;; Copyright (C) 1991-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1991-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords: pcl-cvs
diff --git a/lisp/vc/pcvs.el b/lisp/vc/pcvs.el
index 9933e36..4679996 100644
--- a/lisp/vc/pcvs.el
+++ b/lisp/vc/pcvs.el
@@ -1,6 +1,6 @@
 ;;; pcvs.el --- a front-end to CVS  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1991-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1991-2019 Free Software Foundation, Inc.
 
 ;; Author: The PCL-CVS Trust <address@hidden>
 ;;     Per Cederqvist <address@hidden>
diff --git a/lisp/vc/smerge-mode.el b/lisp/vc/smerge-mode.el
index fd655e4..6b1df66 100644
--- a/lisp/vc/smerge-mode.el
+++ b/lisp/vc/smerge-mode.el
@@ -1,6 +1,6 @@
 ;;; smerge-mode.el --- Minor mode to resolve diff3 conflicts -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords: vc, tools, revision control, merge, diff3, cvs, conflict
@@ -44,7 +44,7 @@
 ;;; Code:
 
 (eval-when-compile (require 'cl-lib))
-(require 'diff-mode)                    ;For diff-auto-refine-mode.
+(require 'diff-mode)                    ;For diff-refine.
 (require 'newcomment)
 
 ;;; The real definition comes later.
@@ -264,7 +264,7 @@ Can be nil if the style is undecided, or else:
 
 ;; Define smerge-next and smerge-prev
 (easy-mmode-define-navigation smerge smerge-begin-re "conflict" nil nil
-  (if diff-auto-refine-mode
+  (if diff-refine
       (condition-case nil (smerge-refine) (error nil))))
 
 (defconst smerge-match-names ["conflict" "upper" "base" "lower"])
@@ -1432,6 +1432,40 @@ If no conflict maker is found, turn off `smerge-mode'."
         (smerge-next))
     (error (smerge-auto-leave))))
 
+(defcustom smerge-change-buffer-confirm t
+  "If non-nil, request confirmation before moving to another buffer."
+  :type 'boolean)
+
+(defun smerge-vc-next-conflict ()
+  "Go to next conflict, possibly in another file.
+First tries to go to the next conflict in the current buffer, and if not
+found, uses VC to try and find the next file with conflict."
+  (interactive)
+  (let ((buffer (current-buffer)))
+    (condition-case nil
+        ;; FIXME: Try again from BOB before moving to the next file.
+        (smerge-next)
+      (error
+       (if (and (or smerge-change-buffer-confirm
+                    (and (buffer-modified-p) buffer-file-name))
+                (not (or (eq last-command this-command)
+                         (eq ?\r last-command-event)))) ;Called via M-x!?
+           ;; FIXME: Don't emit this message if `vc-find-conflicted-file' won't
+           ;; go to another file anyway (because there are no more conflicted
+           ;; files).
+           (message (if (buffer-modified-p)
+                        "No more conflicts here.  Repeat to save and go to 
next buffer"
+                      "No more conflicts here.  Repeat to go to next buffer"))
+         (if (and (buffer-modified-p) buffer-file-name)
+             (save-buffer))
+         (vc-find-conflicted-file)
+         (if (eq buffer (current-buffer))
+             ;; Do nothing: presumably `vc-find-conflicted-file' already
+             ;; emitted a message explaining there aren't any more conflicts.
+             nil
+           (goto-char (point-min))
+           (smerge-next)))))))
+
 (provide 'smerge-mode)
 
 ;;; smerge-mode.el ends here
diff --git a/lisp/vc/vc-annotate.el b/lisp/vc/vc-annotate.el
index 5ee3ac8..8483813 100644
--- a/lisp/vc/vc-annotate.el
+++ b/lisp/vc/vc-annotate.el
@@ -1,6 +1,6 @@
 ;;; vc-annotate.el --- VC Annotate Support  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1997-1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author:     Martin Lorentzson  <address@hidden>
 ;; Maintainer: address@hidden
@@ -541,7 +541,9 @@ Return a cons (REV . FILENAME)."
        (setq prev-rev
              (vc-call-backend vc-annotate-backend 'previous-revision
                                fname rev))
-       (vc-annotate-warp-revision prev-rev fname)))))
+       (if (not prev-rev)
+            (message "No previous revisions")
+          (vc-annotate-warp-revision prev-rev fname))))))
 
 (defvar log-view-vc-backend)
 (defvar log-view-vc-fileset)
diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el
index d5ed590..ab5a449 100644
--- a/lisp/vc/vc-bzr.el
+++ b/lisp/vc/vc-bzr.el
@@ -1,6 +1,6 @@
 ;;; vc-bzr.el --- VC backend for the bzr revision control system  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Dave Love <address@hidden>
 ;;        Riccardo Murri <address@hidden>
@@ -332,7 +332,7 @@ in the repository root directory of FILE."
          (file-relative-name filename* rootdir))))
 
 (defvar vc-bzr-error-regexp-alist
-  '(("^\\( M[* ]\\|+N \\|-D \\|\\|  \\*\\|R[M ] \\) \\(.+\\)" 2 nil nil 1)
+  '(("^\\( M[* ]\\|\\+N \\|-D \\|\\|  \\*\\|R[M ] \\) \\(.+\\)" 2 nil nil 1)
     ("^C  \\(.+\\)" 2)
     ("^Text conflict in \\(.+\\)" 1 nil nil 2)
     ("^Using saved parent location: \\(.+\\)" 1 nil nil 0))
diff --git a/lisp/vc/vc-cvs.el b/lisp/vc/vc-cvs.el
index ac98d99..626e190 100644
--- a/lisp/vc/vc-cvs.el
+++ b/lisp/vc/vc-cvs.el
@@ -1,6 +1,6 @@
 ;;; vc-cvs.el --- non-resident support for CVS version-control  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1995, 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1998-2019 Free Software Foundation, Inc.
 
 ;; Author:      FSF (see vc.el for full credits)
 ;; Maintainer:  address@hidden
@@ -650,7 +650,7 @@ Optional arg REVISION is a revision to annotate from."
   "Return the current time, based at midnight of the current day, and
 encoded as fractional days."
   (vc-annotate-convert-time
-   (apply 'encode-time 0 0 0 (nthcdr 3 (decode-time)))))
+   (apply #'encode-time 0 0 0 (nthcdr 3 (decode-time)))))
 
 (defun vc-cvs-annotate-time ()
   "Return the time of the next annotation (as fraction of days)
@@ -910,7 +910,7 @@ essential information. Note that this can never set the 
`ignored'
 state."
   (let (file status missing)
     (goto-char (point-min))
-    (while (looking-at "? \\(.*\\)")
+    (while (looking-at "\\? \\(.*\\)")
       (setq file (expand-file-name (match-string 1)))
       (vc-file-setprop file 'vc-state 'unregistered)
       (forward-line 1))
@@ -1087,7 +1087,7 @@ CVS/Entries should only be accessed through this 
function."
   ;; an uppercase or lowercase letter and can contain uppercase and
   ;; lowercase letters, digits, `-', and `_'.
   (and (string-match "^[a-zA-Z]" tag)
-       (not (string-match "[^a-z0-9A-Z-_]" tag))))
+       (not (string-match "[^a-z0-9A-Z_-]" tag))))
 
 (defun vc-cvs-valid-revision-number-p (tag)
   "Return non-nil if TAG is a valid revision number."
@@ -1184,9 +1184,8 @@ is non-nil."
                   (car parsed-time)
                   ;; Compare just the seconds part of the file time,
                   ;; since CVS file time stamp resolution is just 1 second.
-                  (let ((ptime (apply 'encode-time parsed-time)))
-                    (and (eq (car mtime) (car ptime))
-                         (eq (cadr mtime) (cadr ptime)))))
+                 (= (encode-time mtime 'integer)
+                    (encode-time parsed-time 'integer)))
              (vc-file-setprop file 'vc-checkout-time mtime)
              (if set-state (vc-file-setprop file 'vc-state 'up-to-date)))
             (t
diff --git a/lisp/vc/vc-dav.el b/lisp/vc/vc-dav.el
index 4ce1a7f..d0b202c 100644
--- a/lisp/vc/vc-dav.el
+++ b/lisp/vc/vc-dav.el
@@ -1,6 +1,6 @@
 ;;; vc-dav.el --- vc.el support for WebDAV
 
-;; Copyright (C) 2001, 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Bill Perry <address@hidden>
 ;; Maintainer: Bill Perry <address@hidden>
diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el
index 18da6e3..75697e3 100644
--- a/lisp/vc/vc-dir.el
+++ b/lisp/vc/vc-dir.el
@@ -1,6 +1,6 @@
 ;;; vc-dir.el --- Directory status display under VC  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author:   Dan Nicolaescu <address@hidden>
 ;; Keywords: vc tools
diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el
index da9d346..edbb83f 100644
--- a/lisp/vc/vc-dispatcher.el
+++ b/lisp/vc/vc-dispatcher.el
@@ -1,6 +1,6 @@
 ;;; vc-dispatcher.el -- generic command-dispatcher facility.  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author:     FSF (see below for full credits)
 ;; Maintainer: address@hidden
diff --git a/lisp/vc/vc-filewise.el b/lisp/vc/vc-filewise.el
index bc74fa4..f05e8ef 100644
--- a/lisp/vc/vc-filewise.el
+++ b/lisp/vc/vc-filewise.el
@@ -1,6 +1,6 @@
 ;;; vc-filewise.el --- common functions for file-oriented back ends.
 
-;; Copyright (C) 1992-1996, 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992-1996, 1998-2019 Free Software Foundation, Inc.
 
 ;; Author:     FSF (see vc.el for full credits)
 ;; Maintainer: address@hidden
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index f317400..192e6cf 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1,6 +1,6 @@
 ;;; vc-git.el --- VC backend for the git version control system -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Alexandre Julliard <address@hidden>
 ;; Keywords: vc tools
@@ -101,6 +101,7 @@
 
 (eval-when-compile
   (require 'cl-lib)
+  (require 'subr-x) ; for string-trim-right
   (require 'vc)
   (require 'vc-dir))
 
@@ -253,7 +254,7 @@ The following place holders should be present in the string:
                        ;; Git for Windows appends ".windows.N" to the
                        ;; numerical version reported by Git.
                        (string-match
-                        "git version \\([0-9.]+\\)\\(\.windows.[0-9]+\\)?$"
+                        "git version \\([0-9.]+\\)\\(\\.windows\\.[0-9]+\\)?$"
                         version-string))
                   (match-string 1 version-string)
                 "0")))))
@@ -749,7 +750,7 @@ The car of the list is the current branch."
 (declare-function log-edit-mode "log-edit" ())
 (declare-function log-edit-toggle-header "log-edit" (header value))
 (declare-function log-edit-extract-headers "log-edit" (headers string))
-(declare-function log-edit-set-header "log-edit" (header value &optional 
toggle))
+(declare-function log-edit--toggle-amend "log-edit" (last-msg-fn))
 
 (defun vc-git-log-edit-toggle-signoff ()
   "Toggle whether to add the \"Signed-off-by\" line at the end of
@@ -757,31 +758,26 @@ the commit message."
   (interactive)
   (log-edit-toggle-header "Sign-Off" "yes"))
 
+(defun vc-git-log-edit-toggle-no-verify ()
+  "Toggle whether to bypass the pre-commit and commit-msg hooks."
+  (interactive)
+  (log-edit-toggle-header "No-Verify" "yes"))
+
 (defun vc-git-log-edit-toggle-amend ()
   "Toggle whether this will amend the previous commit.
 If toggling on, also insert its message into the buffer."
   (interactive)
-  (when (log-edit-toggle-header "Amend" "yes")
-    (goto-char (point-max))
-    (unless (bolp) (insert "\n"))
-    (insert (with-output-to-string
-              (vc-git-command
-               standard-output 1 nil
-               "log" "--max-count=1" "--pretty=format:%B" "HEAD")))
-    (save-excursion
-      (rfc822-goto-eoh)
-      (forward-line 1)
-      (let ((pt (point)))
-        (and (zerop (forward-line 1))
-             (looking-at "\n\\|\\'")
-             (let ((summary (buffer-substring-no-properties pt (1- (point)))))
-               (skip-chars-forward " \n")
-               (delete-region pt (point))
-               (log-edit-set-header "Summary" summary)))))))
+  (log-edit--toggle-amend
+   (lambda ()
+     (with-output-to-string
+       (vc-git-command
+        standard-output 1 nil
+        "log" "--max-count=1" "--pretty=format:%B" "HEAD")))))
 
 (defvar vc-git-log-edit-mode-map
   (let ((map (make-sparse-keymap "Git-Log-Edit")))
     (define-key map "\C-c\C-s" 'vc-git-log-edit-toggle-signoff)
+    (define-key map "\C-c\C-n" 'vc-git-log-edit-toggle-no-verify)
     (define-key map "\C-c\C-e" 'vc-git-log-edit-toggle-amend)
     map))
 
@@ -825,6 +821,7 @@ It is based on `log-edit-mode', and has Git-specific 
extensions.")
                             `(("Author" . "--author")
                               ("Date" . "--date")
                               ("Amend" . ,(boolean-arg-fn "--amend"))
+                              ("No-Verify" . ,(boolean-arg-fn "--no-verify"))
                               ("Sign-Off" . ,(boolean-arg-fn "--signoff")))
                             comment)))
                       (when msg-file
@@ -1010,7 +1007,8 @@ This prompts for a branch to merge from."
 If SHORTLOG is non-nil, use a short format based on `vc-git-root-log-format'.
 \(This requires at least Git version 1.5.6, for the --graph option.)
 If START-REVISION is non-nil, it is the newest revision to show.
-If LIMIT is non-nil, show no more than this many entries."
+If LIMIT is a number, show no more than this many entries.
+If LIMIT is a revision string, use it as an end-revision."
   (let ((coding-system-for-read
          (or coding-system-for-read vc-git-log-output-coding-system)))
     ;; `vc-do-command' creates the buffer, but we need it before running
@@ -1038,8 +1036,14 @@ If LIMIT is non-nil, show no more than this many 
entries."
                     ,(format "--pretty=tformat:%s"
                             (car vc-git-root-log-format))
                    "--abbrev-commit"))
-               (when limit (list "-n" (format "%s" limit)))
-               (when start-revision (list start-revision))
+               (when (numberp limit)
+                  (list "-n" (format "%s" limit)))
+               (when start-revision
+                  (if (and limit (not (numberp limit)))
+                      (list (concat start-revision ".." (if (equal limit "")
+                                                            "HEAD"
+                                                          limit)))
+                    (list start-revision)))
                '("--")))))))
 
 (defun vc-git-log-outgoing (buffer remote-location)
@@ -1070,6 +1074,10 @@ If LIMIT is non-nil, show no more than this many 
entries."
                        "@{upstream}"
                      remote-location))))
 
+(defun vc-git-mergebase (rev1 &optional rev2)
+  (unless rev2 (setq rev2 "HEAD"))
+  (string-trim-right (vc-git--run-command-string nil "merge-base" rev1 rev2)))
+
 (defvar log-view-message-re)
 (defvar log-view-file-re)
 (defvar log-view-font-lock-keywords)
@@ -1086,7 +1094,7 @@ If LIMIT is non-nil, show no more than this many entries."
           (cadr vc-git-root-log-format)
         "^commit *\\([0-9a-z]+\\)"))
   ;; Allow expanding short log entries.
-  (when (memq vc-log-view-type '(short log-outgoing log-incoming))
+  (when (memq vc-log-view-type '(short log-outgoing log-incoming mergebase))
     (setq truncate-lines t)
     (set (make-local-variable 'log-view-expanded-log-entry-function)
         'vc-git-expanded-log-entry))
@@ -1534,10 +1542,7 @@ This command shares argument histories with \\[rgrep] 
and \\[grep]."
   "Create a stash with the current tree state."
   (interactive)
   (vc-git--call nil "stash" "save"
-               (let ((ct (current-time)))
-                 (concat
-                  (format-time-string "Snapshot on %Y-%m-%d" ct)
-                  (format-time-string " at %H:%M" ct))))
+               (format-time-string "Snapshot on %Y-%m-%d at %H:%M"))
   (vc-git-command "*vc-git-stash*" 0 nil "stash" "apply" "-q" "address@hidden")
   (vc-resynch-buffer (vc-git-root default-directory) t t))
 
@@ -1625,9 +1630,9 @@ The difference to vc-do-command is that this function 
always invokes
 (defun vc-git--call (buffer command &rest args)
   ;; We don't need to care the arguments.  If there is a file name, it
   ;; is always a relative one.  This works also for remote
-  ;; directories.  We enable `inhibit-null-byte-detection', otherwise
+  ;; directories.  We enable `inhibit-nul-byte-detection', otherwise
   ;; Tramp's eol conversion might be confused.
-  (let ((inhibit-null-byte-detection t)
+  (let ((inhibit-nul-byte-detection t)
        (coding-system-for-read
          (or coding-system-for-read vc-git-log-output-coding-system))
        (coding-system-for-write
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index d6227d6..d3f132d 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -1,6 +1,6 @@
 ;;; vc-hg.el --- VC backend for the mercurial version control system  -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; Author: Ivan Kanis
 ;; Maintainer: address@hidden
@@ -145,6 +145,15 @@ switches."
   :version "25.1"
   :group 'vc-hg)
 
+(defcustom vc-hg-revert-switches nil
+  "String or list of strings specifying switches for hg revert
+under VC."
+  :type '(choice (const :tag "None" nil)
+                (string :tag "Argument String")
+                (repeat :tag "Argument List" :value ("") string))
+  :version "27.1"
+  :group 'vc-hg)
+
 (defcustom vc-hg-program "hg"
   "Name of the Mercurial executable (excluding any arguments)."
   :type 'string
@@ -914,9 +923,6 @@ FILENAME must be the file's true absolute name."
       (setf ignored (string-match (pop patterns) filename)))
     ignored))
 
-(defun vc-hg--time-to-integer (ts)
-  (+ (* 65536 (car ts)) (cadr ts)))
-
 (defvar vc-hg--cached-ignore-patterns nil
   "Cached pre-parsed hg ignore patterns.")
 
@@ -1037,8 +1043,9 @@ hg binary."
                (let ((vc-hg-size (nth 2 dirstate-entry))
                      (vc-hg-mtime (nth 3 dirstate-entry))
                      (fs-size (file-attribute-size stat))
-                     (fs-mtime (vc-hg--time-to-integer
-                               (file-attribute-modification-time stat))))
+                    (fs-mtime (encode-time
+                               (file-attribute-modification-time stat)
+                               'integer)))
                  (if (and (eql vc-hg-size fs-size) (eql vc-hg-mtime fs-mtime))
                      'up-to-date
                    'edited)))
@@ -1097,15 +1104,42 @@ hg binary."
   (vc-hg-command nil 0 file "forget"))
 
 (declare-function log-edit-extract-headers "log-edit" (headers string))
+(declare-function log-edit-mode "log-edit" ())
+(declare-function log-edit--toggle-amend "log-edit" (last-msg-fn))
+
+(defun vc-hg-log-edit-toggle-amend ()
+  "Toggle whether this will amend the previous commit.
+If toggling on, also insert its message into the buffer."
+  (interactive)
+  (log-edit--toggle-amend
+   (lambda ()
+     (with-output-to-string
+       (vc-hg-command
+        standard-output 1 nil
+        "log" "--limit=1" "--template" "{desc}")))))
+
+(defvar vc-hg-log-edit-mode-map
+  (let ((map (make-sparse-keymap "Hg-Log-Edit")))
+    (define-key map "\C-c\C-e" 'vc-hg-log-edit-toggle-amend)
+    map))
+
+(define-derived-mode vc-hg-log-edit-mode log-edit-mode "Log-Edit/hg"
+  "Major mode for editing Hg log messages.
+It is based on `log-edit-mode', and has Hg-specific extensions.")
 
 (defun vc-hg-checkin (files comment &optional _rev)
   "Hg-specific version of `vc-backend-checkin'.
 REV is ignored."
-  (apply 'vc-hg-command nil 0 files
-         (nconc (list "commit" "-m")
-                (log-edit-extract-headers '(("Author" . "--user")
-                                           ("Date" . "--date"))
-                                          comment))))
+  (let ((amend-extract-fn
+         (lambda (value)
+           (when (equal value "yes")
+             (list "--amend")))))
+    (apply 'vc-hg-command nil 0 files
+           (nconc (list "commit" "-m")
+                  (log-edit-extract-headers `(("Author" . "--user")
+                                              ("Date" . "--date")
+                                              ("Amend" . ,amend-extract-fn))
+                                            comment)))))
 
 (defun vc-hg-find-revision (file rev buffer)
   (let ((coding-system-for-read 'binary)
@@ -1161,7 +1195,11 @@ REV is the revision to check out into WORKFILE."
 ;; Modeled after the similar function in vc-bzr.el
 (defun vc-hg-revert (file &optional contents-done)
   (unless contents-done
-    (with-temp-buffer (vc-hg-command t 0 file "revert"))))
+    (with-temp-buffer
+      (apply #'vc-hg-command
+             t 0 file
+             "revert"
+             (append (vc-switches 'hg 'revert))))))
 
 ;;; Hg specific functionality.
 
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index 84e11f2..07b3d86 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -1,6 +1,6 @@
-;;; vc-hooks.el --- resident support for version-control
+;;; vc-hooks.el --- resident support for version-control  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1992-1996, 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992-1996, 1998-2019 Free Software Foundation, Inc.
 
 ;; Author:     FSF (see vc.el for full credits)
 ;; Maintainer: address@hidden
@@ -173,9 +173,9 @@ Otherwise, not displayed."
 (make-variable-buffer-local 'vc-mode)
 (put 'vc-mode 'permanent-local t)
 
-;;; We signal this error when we try to do something a VC backend
-;;; doesn't support.  Two arguments: the method that's not supported
-;;; and the backend
+;; We signal this error when we try to do something a VC backend
+;; doesn't support.  Two arguments: the method that's not supported
+;; and the backend
 (define-error 'vc-not-supported "VC method not implemented for backend")
 
 (defun vc-mode (&optional _arg)
@@ -243,12 +243,12 @@ if that doesn't exist either, return nil."
   "Call for BACKEND the implementation of FUNCTION-NAME with the given ARGS.
 Calls
 
-    (apply \\='vc-BACKEND-FUN ARGS)
+    (apply #\\='vc-BACKEND-FUN ARGS)
 
 if vc-BACKEND-FUN exists (after trying to find it in vc-BACKEND.el)
 and else calls
 
-    (apply \\='vc-default-FUN BACKEND ARGS)
+    (apply #\\='vc-default-FUN BACKEND ARGS)
 
 It is usually called via the `vc-call' macro."
   (let ((f (assoc function-name (get backend 'vc-functions))))
@@ -603,7 +603,7 @@ a regexp for matching all such backup files, regardless of 
the version."
   "Delete all existing automatic version backups for FILE."
   (condition-case nil
       (mapc
-       'delete-file
+       #'delete-file
        (directory-files (or (file-name-directory file) default-directory) t
                        (vc-version-backup-file-name file nil nil t)))
     ;; Don't fail when the directory doesn't exist.
@@ -811,7 +811,7 @@ In the latter case, VC mode is deactivated for this buffer."
   (when buffer-file-name
     (vc-file-clearprops buffer-file-name)
     ;; FIXME: Why use a hook?  Why pass it buffer-file-name?
-    (add-hook 'vc-mode-line-hook 'vc-mode-line nil t)
+    (add-hook 'vc-mode-line-hook #'vc-mode-line nil t)
     (let (backend)
       (cond
         ((setq backend (with-demoted-errors (vc-backend buffer-file-name)))
@@ -862,13 +862,13 @@ In the latter case, VC mode is deactivated for this 
buffer."
                   )))))))))
 
 (add-hook 'find-file-hook #'vc-refresh-state)
-(define-obsolete-function-alias 'vc-find-file-hook 'vc-refresh-state "25.1")
+(define-obsolete-function-alias 'vc-find-file-hook #'vc-refresh-state "25.1")
 
 (defun vc-kill-buffer-hook ()
   "Discard VC info about a file when we kill its buffer."
   (when buffer-file-name (vc-file-clearprops buffer-file-name)))
 
-(add-hook 'kill-buffer-hook 'vc-kill-buffer-hook)
+(add-hook 'kill-buffer-hook #'vc-kill-buffer-hook)
 
 ;; Now arrange for (autoloaded) bindings of the main package.
 ;; Bindings for this have to go in the global map, as we'll often
@@ -890,6 +890,8 @@ In the latter case, VC mode is deactivated for this buffer."
     (define-key map "L" 'vc-print-root-log)
     (define-key map "I" 'vc-log-incoming)
     (define-key map "O" 'vc-log-outgoing)
+    (define-key map "ML" 'vc-log-mergebase)
+    (define-key map "MD" 'vc-diff-mergebase)
     (define-key map "m" 'vc-merge)
     (define-key map "r" 'vc-retrieve-tag)
     (define-key map "s" 'vc-create-tag)
@@ -950,8 +952,7 @@ In the latter case, VC mode is deactivated for this buffer."
     (bindings--define-key map [separator2] menu-bar-separator)
     (bindings--define-key map [vc-insert-header]
       '(menu-item "Insert Header" vc-insert-headers
-                 :help "Insert headers into a file for use with a version 
control system.
-"))
+                 :help "Insert headers into a file for use with a version 
control system."))
     (bindings--define-key map [vc-revert]
       '(menu-item "Revert to Base Version" vc-revert
                  :help "Revert working copies of the selected file set to 
their repository contents"))
diff --git a/lisp/vc/vc-mtn.el b/lisp/vc/vc-mtn.el
index efb141b..f0b1248 100644
--- a/lisp/vc/vc-mtn.el
+++ b/lisp/vc/vc-mtn.el
@@ -1,6 +1,6 @@
 ;;; vc-mtn.el --- VC backend for Monotone  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2007-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords: vc
diff --git a/lisp/vc/vc-rcs.el b/lisp/vc/vc-rcs.el
index 7970fce..598e982 100644
--- a/lisp/vc/vc-rcs.el
+++ b/lisp/vc/vc-rcs.el
@@ -1,6 +1,6 @@
 ;;; vc-rcs.el --- support for RCS version-control  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1992-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992-2019 Free Software Foundation, Inc.
 
 ;; Author:     FSF (see vc.el for full credits)
 ;; Maintainer: address@hidden
diff --git a/lisp/vc/vc-sccs.el b/lisp/vc/vc-sccs.el
index 4ca89da..4e9f5a0 100644
--- a/lisp/vc/vc-sccs.el
+++ b/lisp/vc/vc-sccs.el
@@ -1,6 +1,6 @@
 ;;; vc-sccs.el --- support for SCCS version-control  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1992-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992-2019 Free Software Foundation, Inc.
 
 ;; Author:     FSF (see vc.el for full credits)
 ;; Maintainer: address@hidden
diff --git a/lisp/vc/vc-src.el b/lisp/vc/vc-src.el
index 58d4dec..f847592 100644
--- a/lisp/vc/vc-src.el
+++ b/lisp/vc/vc-src.el
@@ -1,6 +1,6 @@
 ;;; vc-src.el --- support for SRC version-control  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1992-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992-2019 Free Software Foundation, Inc.
 
 ;; Author:     FSF (see vc.el for full credits)
 ;; Maintainer: address@hidden
diff --git a/lisp/vc/vc-svn.el b/lisp/vc/vc-svn.el
index 4b1a34b..3c50c8f 100644
--- a/lisp/vc/vc-svn.el
+++ b/lisp/vc/vc-svn.el
@@ -1,6 +1,6 @@
 ;;; vc-svn.el --- non-resident support for Subversion version-control  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author:      FSF (see vc.el for full credits)
 ;; Maintainer:  Stefan Monnier <address@hidden>
@@ -759,7 +759,7 @@ Set file properties accordingly.  If FILENAME is non-nil, 
return its status."
   ;; an uppercase or lowercase letter and can contain uppercase and
   ;; lowercase letters, digits, `-', and `_'.
   (and (string-match "^[a-zA-Z]" tag)
-       (not (string-match "[^a-z0-9A-Z-_]" tag))))
+       (not (string-match "[^a-z0-9A-Z_-]" tag))))
 
 (defun vc-svn-valid-revision-number-p (tag)
   "Return non-nil if TAG is a valid revision number."
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index dbbc3e2..b992a8e 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -1,6 +1,6 @@
 ;;; vc.el --- drive a version-control system from within Emacs  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1992-1998, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1992-1998, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author:     FSF (see below for full credits)
 ;; Maintainer: address@hidden
@@ -429,6 +429,10 @@
 ;; - region-history-mode ()
 ;;
 ;;   Major mode to use for the output of `region-history'.
+;;
+;; - mergebase (rev1 &optional rev2)
+;;
+;;   Return the common ancestor between REV1 and REV2 revisions.
 
 ;; TAG SYSTEM
 ;;
@@ -736,8 +740,7 @@ These are passed to the checkin program by \\[vc-checkin]."
                 (string :tag "Argument String")
                 (repeat :tag "Argument List"
                         :value ("")
-                        string))
-  :group 'vc)
+                        string)))
 
 (defcustom vc-checkout-switches nil
   "A string or list of strings specifying extra switches for checkout.
@@ -746,8 +749,7 @@ These are passed to the checkout program by 
\\[vc-checkout]."
                 (string :tag "Argument String")
                 (repeat :tag "Argument List"
                         :value ("")
-                        string))
-  :group 'vc)
+                        string)))
 
 (defcustom vc-register-switches nil
   "A string or list of strings; extra switches for registering a file.
@@ -756,8 +758,7 @@ These are passed to the checkin program by \\[vc-register]."
                 (string :tag "Argument String")
                 (repeat :tag "Argument List"
                         :value ("")
-                        string))
-  :group 'vc)
+                        string)))
 
 (defcustom vc-diff-switches nil
   "A string or list of strings specifying switches for diff under VC.
@@ -772,7 +773,6 @@ not specific to any particular backend."
                 (const :tag "None" t)
                 (string :tag "Argument String")
                 (repeat :tag "Argument List" :value ("") string))
-  :group 'vc
   :version "21.1")
 
 (defcustom vc-annotate-switches nil
@@ -792,15 +792,13 @@ for the backend you use."
                 (const :tag "None" t)
                 (string :tag "Argument String")
                 (repeat :tag "Argument List" :value ("") string))
-  :group 'vc
   :version "25.1")
 
 (defcustom vc-log-show-limit 2000
   "Limit the number of items shown by the VC log commands.
 Zero means unlimited.
 Not all VC backends are able to support this feature."
-  :type 'integer
-  :group 'vc)
+  :type 'integer)
 
 (defcustom vc-allow-async-revert nil
   "Specifies whether the diff during \\[vc-revert] may be asynchronous.
@@ -808,7 +806,6 @@ Enabling this option means that you can confirm a revert 
operation even
 if the local changes in the file have not been found and displayed yet."
   :type '(choice (const :tag "No" nil)
                  (const :tag "Yes" t))
-  :group 'vc
   :version "22.1")
 
 ;;;###autoload
@@ -816,7 +813,6 @@ if the local changes in the file have not been found and 
displayed yet."
   "Normal hook (list of functions) run after checking out a file.
 See `run-hooks'."
   :type 'hook
-  :group 'vc
   :version "21.1")
 
 ;;;###autoload
@@ -824,26 +820,22 @@ See `run-hooks'."
   "Normal hook (list of functions) run after commit or file checkin.
 See also `log-edit-done-hook'."
   :type 'hook
-  :options '(log-edit-comment-to-change-log)
-  :group 'vc)
+  :options '(log-edit-comment-to-change-log))
 
 ;;;###autoload
 (defcustom vc-before-checkin-hook nil
   "Normal hook (list of functions) run before a commit or a file checkin.
 See `run-hooks'."
-  :type 'hook
-  :group 'vc)
+  :type 'hook)
 
 (defcustom vc-retrieve-tag-hook nil
   "Normal hook (list of functions) run after retrieving a tag."
   :type 'hook
-  :group 'vc
   :version "27.1")
 
 (defcustom vc-revert-show-diff t
   "If non-nil, `vc-revert' shows a `vc-diff' buffer before querying."
   :type 'boolean
-  :group 'vc
   :version "24.1")
 
 ;; Header-insertion hair
@@ -856,8 +848,7 @@ A %s in the template is replaced with the first string 
associated with
 the file's version control type in `vc-BACKEND-header'."
   :type '(repeat (cons :format "%v"
                       (regexp :tag "File Type")
-                      (string :tag "Header String")))
-  :group 'vc)
+                      (string :tag "Header String"))))
 
 (defcustom vc-comment-alist
   '((nroff-mode ".\\\"" ""))
@@ -868,13 +859,11 @@ is sensitive to blank lines."
   :type '(repeat (list :format "%v"
                       (symbol :tag "Mode")
                       (string :tag "Comment Start")
-                      (string :tag "Comment End")))
-  :group 'vc)
+                      (string :tag "Comment End"))))
 
 (defcustom vc-find-revision-no-save nil
   "If non-nil, `vc-find-revision' doesn't write the created buffer to file."
   :type 'boolean
-  :group 'vc
   :version "27.1")
 
 
@@ -940,7 +929,7 @@ use."
             ;; 'create-repo method.
             (completing-read
              (format "%s is not in a version controlled directory.\nUse VC 
backend: " file)
-             (mapcar 'symbol-name possible-backends) nil t)))
+             (mapcar #'symbol-name possible-backends) nil t)))
           (repo-dir
            (let ((def-dir (file-name-directory file)))
              ;; read the directory where to create the
@@ -1109,7 +1098,7 @@ BEWARE: this function may change the current buffer."
 
 (defun vc-read-backend (prompt)
   (intern
-   (completing-read prompt (mapcar 'symbol-name vc-handled-backends)
+   (completing-read prompt (mapcar #'symbol-name vc-handled-backends)
                     nil 'require-match)))
 
 ;; Here's the major entry point.
@@ -1367,7 +1356,7 @@ first backend that could register the file is used."
              (set-buffer-modified-p t))
            (vc-buffer-sync)))))
     (message "Registering %s... " files)
-    (mapc 'vc-file-clearprops files)
+    (mapc #'vc-file-clearprops files)
     (vc-call-backend backend 'register files comment)
     (mapc
      (lambda (file)
@@ -1569,7 +1558,7 @@ Runs the normal hooks `vc-before-checkin-hook' and 
`vc-checkin-hook'."
        ;; not a well-defined concept for filesets.
        (progn
          (vc-call-backend backend 'checkin files comment rev)
-         (mapc 'vc-delete-automatic-version-backups files))
+         (mapc #'vc-delete-automatic-version-backups files))
        `((vc-state . up-to-date)
          (vc-checkout-time . ,(file-attribute-modification-time
                               (file-attributes file)))
@@ -1727,7 +1716,7 @@ Return t if the buffer had changes, nil otherwise."
                 (error "No revisions of %s exist" file)
               ;; We regard this as "changed".
               ;; Diff it against /dev/null.
-              (apply 'vc-do-command buffer
+              (apply #'vc-do-command buffer
                      (if async 'async 1) "diff" file
                      (append (vc-switches nil 'diff) '("/dev/null"))))))
         (setq files (nreverse filtered))))
@@ -1777,9 +1766,9 @@ Return t if the buffer had changes, nil otherwise."
                          nil nil initial-input 'vc-revision-history default)
       (read-string prompt initial-input nil default))))
 
-(defun vc-diff-build-argument-list-internal ()
+(defun vc-diff-build-argument-list-internal (&optional fileset)
   "Build argument list for calling internal diff functions."
-  (let* ((vc-fileset (vc-deduce-fileset t)) ;FIXME: why t?  --Stef
+  (let* ((vc-fileset (or fileset (vc-deduce-fileset t))) ;FIXME: why t?  --Stef
          (files (cadr vc-fileset))
          (backend (car vc-fileset))
          (first (car files))
@@ -1817,7 +1806,12 @@ Return t if the buffer had changes, nil otherwise."
 
 ;;;###autoload
 (defun vc-version-diff (_files rev1 rev2)
-  "Report diffs between revisions of the fileset in the repository history."
+  "Report diffs between revisions REV1 and REV2 in the repository history.
+This compares two revisions of the current fileset.
+If REV1 is nil, it defaults to the current revision, i.e. revision
+of the last commit.
+If REV2 is nil, it defaults to the work tree, i.e. the current
+state of each file in the fileset."
   (interactive (vc-diff-build-argument-list-internal))
   ;; All that was just so we could do argument completion!
   (when (and (not rev1) rev2)
@@ -1828,6 +1822,32 @@ Return t if the buffer had changes, nil otherwise."
                    (called-interactively-p 'interactive)))
 
 ;;;###autoload
+(defun vc-root-version-diff (_files rev1 rev2)
+  "Report diffs between REV1 and REV2 revisions of the whole tree."
+  (interactive
+   (vc-diff-build-argument-list-internal
+    (or (ignore-errors (vc-deduce-fileset t))
+        (let ((backend (or (vc-deduce-backend) (vc-responsible-backend 
default-directory))))
+          (list backend (list (vc-call-backend backend 'root 
default-directory)))))))
+  ;; This is a mix of `vc-root-diff' and `vc-version-diff'
+  (when (and (not rev1) rev2)
+    (error "Not a valid revision range"))
+  (let ((backend (vc-deduce-backend))
+        (default-directory default-directory)
+        rootdir)
+    (if backend
+        (setq rootdir (vc-call-backend backend 'root default-directory))
+      (setq rootdir (read-directory-name "Directory for VC root-diff: "))
+      (setq backend (vc-responsible-backend rootdir))
+      (if backend
+          (setq default-directory rootdir)
+        (error "Directory is not version controlled")))
+    (let ((default-directory rootdir))
+      (vc-diff-internal
+       t (list backend (list rootdir)) rev1 rev2
+       (called-interactively-p 'interactive)))))
+
+;;;###autoload
 (defun vc-diff (&optional historic not-urgent)
   "Display diffs between file revisions.
 Normally this compares the currently selected fileset with their
@@ -1843,14 +1863,47 @@ saving the buffer."
     (vc-diff-internal t (vc-deduce-fileset t) nil nil
                      (called-interactively-p 'interactive))))
 
+;;;###autoload
+(defun vc-diff-mergebase (_files rev1 rev2)
+  "Report diffs between the merge base of REV1 and REV2 revisions.
+The merge base is a common ancestor between REV1 and REV2 revisions."
+  (interactive
+   (vc-diff-build-argument-list-internal
+    (or (ignore-errors (vc-deduce-fileset t))
+        (let ((backend (or (vc-deduce-backend) (vc-responsible-backend 
default-directory))))
+          (list backend (list (vc-call-backend backend 'root 
default-directory)))))))
+  (when (and (not rev1) rev2)
+    (error "Not a valid revision range"))
+  (let ((backend (vc-deduce-backend))
+        (default-directory default-directory)
+        rootdir)
+    (if backend
+        (setq rootdir (vc-call-backend backend 'root default-directory))
+      (setq rootdir (read-directory-name "Directory for VC root-diff: "))
+      (setq backend (vc-responsible-backend rootdir))
+      (if backend
+          (setq default-directory rootdir)
+        (error "Directory is not version controlled")))
+    (let ((default-directory rootdir)
+          (rev1 (vc-call-backend backend 'mergebase rev1 rev2)))
+      (vc-diff-internal
+       t (list backend (list rootdir)) rev1 rev2
+       (called-interactively-p 'interactive)))))
+
 (declare-function ediff-load-version-control "ediff" (&optional silent))
 (declare-function ediff-vc-internal "ediff-vers"
                   (rev1 rev2 &optional startup-hooks))
 
 ;;;###autoload
 (defun vc-version-ediff (files rev1 rev2)
-  "Show differences between revisions of the fileset in the
-repository history using ediff."
+  "Show differences between REV1 and REV2 of FILES using ediff.
+This compares two revisions of the files in FILES.  Currently,
+only a single file's revisions can be compared, i.e. FILES can
+specify only one file name.
+If REV1 is nil, it defaults to the current revision, i.e. revision
+of the last commit.
+If REV2 is nil, it defaults to the work tree, i.e. the current
+state of each file in FILES."
   (interactive (vc-diff-build-argument-list-internal))
   ;; All that was just so we could do argument completion!
   (when (and (not rev1) rev2)
@@ -1900,10 +1953,8 @@ The optional argument NOT-URGENT non-nil means it is ok 
to say no to
 saving the buffer."
   (interactive (list current-prefix-arg t))
   (if historic
-      ;; FIXME: this does not work right, `vc-version-diff' ends up
-      ;; calling `vc-deduce-fileset' to find the files to diff, and
-      ;; that's not what we want here, we want the diff for the VC root dir.
-      (call-interactively 'vc-version-diff)
+      ;; We want the diff for the VC root dir.
+      (call-interactively 'vc-root-version-diff)
     (when buffer-file-name (vc-buffer-sync not-urgent))
     (let ((backend (vc-deduce-backend))
          (default-directory default-directory)
@@ -1976,10 +2027,13 @@ Saves the buffer to the file."
        (with-current-buffer filebuf
          (let ((failed t))
            (unwind-protect
-               (let ((coding-system-for-read 'no-conversion)
-                     (coding-system-for-write 'no-conversion))
+               (let ((coding-system-for-read 'no-conversion))
                  (with-temp-file filename
                    (let ((outbuf (current-buffer)))
+                      ;; We will read the backend's output with no
+                      ;; conversions, so we should also save the
+                      ;; temporary file with no encoding conversions.
+                      (setq buffer-file-coding-system 'no-conversion)
                      ;; Change buffer to get local value of
                      ;; vc-checkout-switches.
                      (with-current-buffer filebuf
@@ -2013,20 +2067,25 @@ Unlike `vc-find-revision-save', doesn't save the buffer 
to the file."
       (with-current-buffer filebuf
        (let ((failed t))
          (unwind-protect
-             (let ((coding-system-for-read 'no-conversion)
-                    (coding-system-for-write 'no-conversion))
-               (with-current-buffer (or buffer (create-file-buffer filename))
-                  (unless buffer (setq buffer-file-name filename))
-                 (let ((outbuf (current-buffer)))
-                   (with-current-buffer filebuf
-                     (if backend
-                         (vc-call-backend backend 'find-revision file revision 
outbuf)
-                       (vc-call find-revision file revision outbuf))))
-                  (goto-char (point-min))
-                  (if buffer (let ((buffer-file-name file)) (normal-mode)) 
(normal-mode))
-                 (set-buffer-modified-p nil)
-                  (setq buffer-read-only t))
-               (setq failed nil))
+             (with-current-buffer (or buffer (create-file-buffer filename))
+                (unless buffer (setq buffer-file-name filename))
+               (let ((outbuf (current-buffer)))
+                 (with-current-buffer filebuf
+                   (if backend
+                       (vc-call-backend backend 'find-revision file revision 
outbuf)
+                     (vc-call find-revision file revision outbuf))))
+                (decode-coding-inserted-region (point-min) (point-max) file)
+                (after-insert-file-set-coding (- (point-max) (point-min)))
+                (goto-char (point-min))
+                (if buffer
+                    ;; For non-interactive, skip any questions
+                    (let ((enable-local-variables :safe) ;; to find `mode:'
+                          (buffer-file-name file))
+                      (ignore-errors (set-auto-mode)))
+                  (normal-mode))
+               (set-buffer-modified-p nil)
+                (setq buffer-read-only t))
+               (setq failed nil)
            (when (and failed (unless buffer (get-file-buffer filename)))
              (with-current-buffer (get-file-buffer filename)
                (set-buffer-modified-p nil))
@@ -2144,6 +2203,7 @@ changes from the current branch."
 ;; `default-next-file' variable for its default file (M-n), and
 ;; we could then set it upon mark-resolve, so C-x C-s C-x C-f M-n would
 ;; automatically offer the next conflicted file.
+;;;###autoload
 (defun vc-find-conflicted-file ()
   "Visit the next conflicted file in the current project."
   (interactive)
@@ -2467,6 +2527,28 @@ When called interactively with a prefix argument, prompt 
for REMOTE-LOCATION."
                                    "*vc-outgoing*" 'log-outgoing)))
 
 ;;;###autoload
+(defun vc-log-mergebase (_files rev1 rev2)
+  "Show a log of changes between the merge base of REV1 and REV2 revisions.
+The merge base is a common ancestor between REV1 and REV2 revisions."
+  (interactive
+   (vc-diff-build-argument-list-internal
+    (or (ignore-errors (vc-deduce-fileset t))
+        (let ((backend (or (vc-deduce-backend) (vc-responsible-backend 
default-directory))))
+          (list backend (list (vc-call-backend backend 'root 
default-directory)))))))
+  (let ((backend (vc-deduce-backend))
+       (default-directory default-directory)
+       rootdir)
+    (if backend
+       (setq rootdir (vc-call-backend backend 'root default-directory))
+      (setq rootdir (read-directory-name "Directory for VC root-log: "))
+      (setq backend (vc-responsible-backend rootdir))
+      (unless backend
+        (error "Directory is not version controlled")))
+    (setq default-directory rootdir)
+    (setq rev1 (vc-call-backend backend 'mergebase rev1 rev2))
+    (vc-print-log-internal backend (list rootdir) rev1 t (or rev2 ""))))
+
+;;;###autoload
 (defun vc-region-history (from to)
   "Show the history of the region between FROM and TO.
 
@@ -2744,7 +2826,8 @@ If called interactively, read FILE, defaulting to the 
current
 buffer's file name if it's under version control."
   (interactive (list (read-file-name "VC delete file: " nil
                                      (when (vc-backend buffer-file-name)
-                                       buffer-file-name) t)))
+                                       buffer-file-name)
+                                     t)))
   (setq file (expand-file-name file))
   (let ((buf (get-file-buffer file))
         (backend (vc-backend file)))
diff --git a/lisp/vcursor.el b/lisp/vcursor.el
index ce7a895..3e8b6ee 100644
--- a/lisp/vcursor.el
+++ b/lisp/vcursor.el
@@ -1,6 +1,6 @@
 ;;; vcursor.el --- manipulate an alternative ("virtual") cursor
 
-;; Copyright (C) 1994, 1996, 1998, 2001-2018 Free Software Foundation,
+;; Copyright (C) 1994, 1996, 1998, 2001-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author:   Peter Stephenson <address@hidden>
diff --git a/lisp/version.el b/lisp/version.el
index c72164c..d13d8c3 100644
--- a/lisp/version.el
+++ b/lisp/version.el
@@ -1,6 +1,6 @@
 ;;; version.el --- record version number of Emacs
 
-;; Copyright (C) 1985, 1992, 1994-1995, 1999-2018 Free Software
+;; Copyright (C) 1985, 1992, 1994-1995, 1999-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
diff --git a/lisp/view.el b/lisp/view.el
index 56f98a6..e74ce1e 100644
--- a/lisp/view.el
+++ b/lisp/view.el
@@ -1,6 +1,6 @@
 ;;; view.el --- peruse file or buffer without editing
 
-;; Copyright (C) 1985, 1989, 1994-1995, 1997, 2000-2018 Free Software
+;; Copyright (C) 1985, 1989, 1994-1995, 1997, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: K. Shane Hartman
diff --git a/lisp/vt-control.el b/lisp/vt-control.el
index 50e86f4..7175095 100644
--- a/lisp/vt-control.el
+++ b/lisp/vt-control.el
@@ -1,6 +1,6 @@
 ;;; vt-control.el --- Common VTxxx control functions
 
-;; Copyright (C) 1993-1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1993-1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Rob Riepel <address@hidden>
 ;; Maintainer: Rob Riepel <address@hidden>
diff --git a/lisp/vt100-led.el b/lisp/vt100-led.el
index 55ed896..d7b5f0a 100644
--- a/lisp/vt100-led.el
+++ b/lisp/vt100-led.el
@@ -1,6 +1,6 @@
 ;;; vt100-led.el --- functions for LED control on VT-100 terminals & clones
 
-;; Copyright (C) 1988, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Howard Gayle
 ;; Maintainer: address@hidden
diff --git a/lisp/w32-fns.el b/lisp/w32-fns.el
index 91fe518..8762fe7 100644
--- a/lisp/w32-fns.el
+++ b/lisp/w32-fns.el
@@ -1,6 +1,6 @@
 ;;; w32-fns.el --- Lisp routines for 32-bit Windows
 
-;; Copyright (C) 1994, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Geoff Voelker <address@hidden>
 ;; Keywords: internal
diff --git a/lisp/w32-vars.el b/lisp/w32-vars.el
index 44f9b76..2861a35 100644
--- a/lisp/w32-vars.el
+++ b/lisp/w32-vars.el
@@ -1,6 +1,6 @@
 ;;; w32-vars.el --- MS-Windows specific user options
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; Author: Jason Rumney <address@hidden>
 ;; Keywords: internal
diff --git a/lisp/wdired.el b/lisp/wdired.el
index 3157e88..d2a298b 100644
--- a/lisp/wdired.el
+++ b/lisp/wdired.el
@@ -1,6 +1,6 @@
 ;;; wdired.el --- Rename files editing their names in dired buffers -*- 
coding: utf-8; -*-
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Filename: wdired.el
 ;; Author: Juan León Lahoz García <address@hidden>
@@ -612,14 +612,23 @@ Optional arguments are ignored."
         (when (re-search-forward
                directory-listing-before-filename-regexp lep t)
           (setq beg (point)
-                ;; If the file is a symlink, put the dired-filename
-                ;; property only on the link name.  (Using
-                ;; (file-symlink-p (dired-get-filename)) fails in
-                ;; wdired-mode, bug#32673.)
-                end (if (and (re-search-backward
-                              dired-permission-flags-regexp nil t)
-                             (looking-at "l")
-                             (search-forward " -> " lep t))
+                end (if (or
+                         ;; If the file is a symlink, put the
+                         ;; dired-filename property only on the link
+                         ;; name.  (Using (file-symlink-p
+                         ;; (dired-get-filename)) fails in
+                         ;; wdired-mode, bug#32673.)
+                         (and (re-search-backward
+                               dired-permission-flags-regexp nil t)
+                              (looking-at "l")
+                              (search-forward " -> " lep t))
+                         ;; When dired-listing-switches includes "F"
+                         ;; or "classify", don't treat appended
+                         ;; indicator characters as part of the file
+                         ;; name (bug#34915).
+                         (and (dired-check-switches dired-actual-switches
+                                                    "F" "classify")
+                              (re-search-forward "[*/@|=>]$" lep t)))
                         (goto-char (match-beginning 0))
                       lep))
           (put-text-property beg end 'dired-filename t))))))
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index af06f7c..2463e65 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -1,6 +1,6 @@
 ;;; whitespace.el --- minor mode to visualize TAB, (HARD) SPACE, NEWLINE -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Vinicius Jose Latorre <address@hidden>
 ;; Maintainer: Vinicius Jose Latorre <address@hidden>
diff --git a/lisp/wid-browse.el b/lisp/wid-browse.el
index d86e9cd..dbc4100 100644
--- a/lisp/wid-browse.el
+++ b/lisp/wid-browse.el
@@ -1,6 +1,6 @@
 ;;; wid-browse.el --- functions for browsing widgets
 ;;
-;; Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Per Abrahamsen <address@hidden>
 ;; Keywords: extensions
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index bee7f80..b9f98cd 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -1,6 +1,6 @@
 ;;; wid-edit.el --- Functions for creating and using widgets 
-*-byte-compile-dynamic: t; lexical-binding:t -*-
 ;;
-;; Copyright (C) 1996-1997, 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1997, 1999-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Per Abrahamsen <address@hidden>
 ;; Maintainer: address@hidden
@@ -1163,8 +1163,9 @@ When not inside a field, signal an error."
 
 (defun widget-at (&optional pos)
   "The button or field at POS (default, point)."
-  (or (get-char-property (or pos (point)) 'button)
-      (widget-field-at pos)))
+  (let ((widget (or (get-char-property (or pos (point)) 'button)
+                    (widget-field-at pos))))
+    (and (widgetp widget) widget)))
 
 ;;;###autoload
 (defun widget-setup ()
@@ -2746,7 +2747,7 @@ Return an alist of (TYPE MATCH)."
   "A widget which groups other widgets inside."
   :convert-widget 'widget-types-convert-widget
   :copy 'widget-types-copy
-  :format "%v"
+  :format ":\n%v"
   :value-create 'widget-group-value-create
   :value-get 'widget-editable-list-value-get
   :default-get 'widget-group-default-get
diff --git a/lisp/widget.el b/lisp/widget.el
index 6b1e233..4028fa1 100644
--- a/lisp/widget.el
+++ b/lisp/widget.el
@@ -1,6 +1,6 @@
 ;;; widget.el --- a library of user interface components
 ;;
-;; Copyright (C) 1996-1997, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1997, 2001-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Per Abrahamsen <address@hidden>
 ;; Keywords: help, extensions, faces, hypermedia
diff --git a/lisp/windmove.el b/lisp/windmove.el
index 6d61806..ab47565 100644
--- a/lisp/windmove.el
+++ b/lisp/windmove.el
@@ -1,6 +1,6 @@
 ;;; windmove.el --- directional window-selection routines  -*- 
lexical-binding:t -*-
 ;;
-;; Copyright (C) 1998-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Hovav Shacham (address@hidden)
 ;; Created: 17 October 1998
@@ -168,8 +168,7 @@ placement bugs in old versions of Emacs."
   :type 'number
   :group 'windmove)
 
-
-
+
 ;; Implementation overview:
 ;;
 ;; The conceptual framework behind this code is all fairly simple.  We
@@ -468,6 +467,7 @@ movement is relative to."
                windmove-window-distance-delta))) ; (x, y1+d-1)
      (t (error "Invalid direction of movement: %s" dir)))))
 
+
 ;; Rewritten on 2013-12-13 using `window-in-direction'.  After the
 ;; pixelwise change the old approach didn't work any more.  martin
 (defun windmove-find-other-window (dir &optional arg window)
@@ -497,9 +497,9 @@ in direction DIR instead."
           (t
            (select-window other-window)))))
 
-
-;;; end-user functions
-;; these are all simple interactive wrappers to
+
+;;; End-user functions
+;; These are all simple interactive wrappers to
 ;; `windmove-do-window-select', meant to be bound to keys.
 
 ;;;###autoload
@@ -571,6 +571,7 @@ Default value of MODIFIERS is `shift'."
   (global-set-key (vector (append modifiers '(up)))    'windmove-up)
   (global-set-key (vector (append modifiers '(down)))  'windmove-down))
 
+
 ;;; Directional window display and selection
 
 (defcustom windmove-display-no-select nil
@@ -588,17 +589,32 @@ By default, select the window with a displayed buffer.
 If prefix ARG is `C-u', reselect a previously selected window.
 If `windmove-display-no-select' is non-nil, this command doesn't
 select the window with a displayed buffer, and the meaning of
-the prefix argument is reversed."
+the prefix argument is reversed.
+When `switch-to-buffer-obey-display-actions' is non-nil,
+`switch-to-buffer' commands are also supported."
   (let* ((no-select (not (eq (consp arg) windmove-display-no-select))) ; xor
          (old-window (or (minibuffer-selected-window) (selected-window)))
          (new-window)
          (minibuffer-depth (minibuffer-depth))
-         (action display-buffer-overriding-action)
+         (action (lambda (buffer alist)
+                   (unless (> (minibuffer-depth) minibuffer-depth)
+                     (let ((window (if (eq dir 'same-window)
+                                       (selected-window)
+                                     (window-in-direction
+                                      dir nil nil
+                                      (and arg (prefix-numeric-value arg))
+                                      windmove-wrap-around)))
+                           (type 'reuse))
+                       (unless window
+                         (setq window (split-window nil nil dir) type 'window))
+                       (setq new-window (window--display-buffer buffer window
+                                                                type 
alist))))))
          (command this-command)
          (clearfun (make-symbol "clear-display-buffer-overriding-action"))
          (exitfun
           (lambda ()
-            (setq display-buffer-overriding-action action)
+            (setq display-buffer-overriding-action
+                  (delq action display-buffer-overriding-action))
             (when (window-live-p (if no-select old-window new-window))
               (select-window (if no-select old-window new-window)))
             (remove-hook 'post-command-hook clearfun))))
@@ -613,19 +629,7 @@ the prefix argument is reversed."
                     (eq this-command command))
               (funcall exitfun))))
     (add-hook 'post-command-hook clearfun)
-    (push (lambda (buffer alist)
-           (unless (> (minibuffer-depth) minibuffer-depth)
-             (let ((window (if (eq dir 'same-window)
-                               (selected-window)
-                              (window-in-direction
-                               dir nil nil
-                               (and arg (prefix-numeric-value arg))
-                               windmove-wrap-around)))
-                    (type 'reuse))
-                (unless window
-                  (setq window (split-window nil nil dir) type 'window))
-               (setq new-window (window--display-buffer buffer window type 
alist)))))
-          display-buffer-overriding-action)
+    (push action display-buffer-overriding-action)
     (message "[display-%s]" dir)))
 
 ;;;###autoload
@@ -678,11 +682,13 @@ Default value of MODIFIERS is `shift-meta'."
   (global-set-key (vector (append modifiers '(down)))  'windmove-display-down)
   (global-set-key (vector (append modifiers '(?0)))    
'windmove-display-same-window))
 
+
 ;;; Directional window deletion
 
 (defun windmove-delete-in-direction (dir &optional arg)
   "Delete the window at direction DIR.
-If prefix ARG is `C-u', delete the selected window and
+If prefix ARG is `\\[universal-argument]', also kill the buffer in that window.
+With `M-0' prefix, delete the selected window and
 select the window at direction DIR.
 When `windmove-wrap-around' is non-nil, takes the window
 from the opposite side of the frame."
@@ -691,7 +697,9 @@ from the opposite side of the frame."
     (cond ((null other-window)
            (user-error "No window %s from selected window" dir))
           (t
-           (if (not (consp arg))
+           (when (equal arg '(4))
+             (kill-buffer (window-buffer other-window)))
+           (if (not (equal arg 0))
                (delete-window other-window)
              (delete-window (selected-window))
              (select-window other-window))))))
@@ -745,6 +753,60 @@ a single modifier.  Default value of PREFIX is `C-x' and 
MODIFIERS is `shift'."
   (global-set-key (vector prefix (append modifiers '(up)))    
'windmove-delete-up)
   (global-set-key (vector prefix (append modifiers '(down)))  
'windmove-delete-down))
 
+
+;;; Directional window swap states
+
+(defun windmove-swap-states-in-direction (dir)
+  "Swap the states of the selected window and the window at direction DIR.
+When `windmove-wrap-around' is non-nil, takes the window
+from the opposite side of the frame."
+  (let ((other-window (window-in-direction dir nil nil nil
+                                           windmove-wrap-around t)))
+    (cond ((or (null other-window) (window-minibuffer-p other-window))
+           (user-error "No window %s from selected window" dir))
+          (t
+           (window-swap-states nil other-window)))))
+
+;;;###autoload
+(defun windmove-swap-states-left ()
+  "Swap the states with the window on the left from the current one."
+  (interactive)
+  (windmove-swap-states-in-direction 'left))
+
+;;;###autoload
+(defun windmove-swap-states-up ()
+  "Swap the states with the window above from the current one."
+  (interactive)
+  (windmove-swap-states-in-direction 'up))
+
+;;;###autoload
+(defun windmove-swap-states-down ()
+  "Swap the states with the window below from the current one."
+  (interactive)
+  (windmove-swap-states-in-direction 'down))
+
+;;;###autoload
+(defun windmove-swap-states-right ()
+  "Swap the states with the window on the right from the current one."
+  (interactive)
+  (windmove-swap-states-in-direction 'right))
+
+;;;###autoload
+(defun windmove-swap-states-default-keybindings (&optional modifiers)
+  "Set up keybindings for directional window swap states.
+Keys are bound to commands that swap the states of the selected window
+with the window in the specified direction.  Keybindings are of the form
+MODIFIERS-{left,right,up,down}, where MODIFIERS is either a list of modifiers
+or a single modifier.  Default value of MODIFIERS is `shift-super'."
+  (interactive)
+  (unless modifiers (setq modifiers '(shift super)))
+  (unless (listp modifiers) (setq modifiers (list modifiers)))
+  (global-set-key (vector (append modifiers '(left)))  
'windmove-swap-states-left)
+  (global-set-key (vector (append modifiers '(right))) 
'windmove-swap-states-right)
+  (global-set-key (vector (append modifiers '(up)))    
'windmove-swap-states-up)
+  (global-set-key (vector (append modifiers '(down)))  
'windmove-swap-states-down))
+
+
 (provide 'windmove)
 
 ;;; windmove.el ends here
diff --git a/lisp/window.el b/lisp/window.el
index 25a599f..b4f5ac5 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -1,6 +1,6 @@
 ;;; window.el --- GNU Emacs window commands aside from those written in C  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 1985, 1989, 1992-1994, 2000-2018 Free Software
+;; Copyright (C) 1985, 1989, 1992-1994, 2000-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Maintainer: address@hidden
@@ -509,11 +509,14 @@ child if WINDOW is a horizontal combination."
       (window-left-child window)
     (window-top-child window)))
 
-(defun window-combinations (window &optional horizontal)
+(defun window-combinations (window &optional horizontal ignore-fixed)
   "Return largest number of windows vertically arranged within WINDOW.
 WINDOW must be a valid window and defaults to the selected one.
 If HORIZONTAL is non-nil, return the largest number of
-windows horizontally arranged within WINDOW."
+windows horizontally arranged within WINDOW.
+
+Optional argument IGNORE-FIXED, if non-nil, means to ignore
+fixed-size windows in the calculation."
   (setq window (window-normalize-window window))
   (cond
    ((window-live-p window)
@@ -527,9 +530,10 @@ windows horizontally arranged within WINDOW."
     (let ((child (window-child window))
          (count 0))
       (while child
-       (setq count
-             (+ (window-combinations child horizontal)
-                count))
+       (unless (and ignore-fixed (window-size-fixed-p child horizontal))
+         (setq count
+               (+ (window-combinations child horizontal ignore-fixed)
+                  count)))
        (setq child (window-right child)))
       count))
    (t
@@ -538,9 +542,10 @@ windows horizontally arranged within WINDOW."
     (let ((child (window-child window))
          (count 1))
       (while child
-       (setq count
-             (max (window-combinations child horizontal)
-                  count))
+       (unless (and ignore-fixed (window-size-fixed-p child horizontal))
+         (setq count
+               (max (window-combinations child horizontal ignore-fixed)
+                    count)))
        (setq child (window-right child)))
       count))))
 
@@ -571,23 +576,25 @@ FRAME.
 
 Optional argument MINIBUF t means run FUN on FRAME's minibuffer
 window even if it isn't active.  MINIBUF nil or omitted means run
-FUN on FRAME's minibuffer window only if it's active.  In both
-cases the minibuffer window must be part of FRAME.  MINIBUF
+FUN on FRAME's minibuffer window only if it's active.  In either
+case the minibuffer window must be part of FRAME.  MINIBUF
 neither nil nor t means never run FUN on the minibuffer window.
 
 This function performs a pre-order, depth-first traversal of the
 window tree.  If FUN changes the window tree, the result is
 unpredictable."
-  (setq frame (window-normalize-frame frame))
-  (walk-window-tree-1 fun (frame-root-window frame) any)
-  (when (memq minibuf '(nil t))
+  (let ((root (frame-root-window frame))
+        (mini (minibuffer-window frame)))
+    (setq frame (window-normalize-frame frame))
+    (unless (eq root mini)
+      (walk-window-tree-1 fun root any))
     ;; Run FUN on FRAME's minibuffer window if requested.
-    (let ((minibuffer-window (minibuffer-window frame)))
-      (when (and (window-live-p minibuffer-window)
-                (eq (window-frame minibuffer-window) frame)
-                (or (eq minibuf t)
-                    (minibuffer-window-active-p minibuffer-window)))
-       (funcall fun minibuffer-window)))))
+    (when (and (window-live-p mini)
+              (eq (window-frame mini) frame)
+              (or (eq minibuf t)
+                  (and (not minibuf)
+                        (minibuffer-window-active-p mini))))
+       (funcall fun mini))))
 
 (defun walk-window-subtree (fun &optional window any)
   "Run function FUN on the subtree of windows rooted at WINDOW.
@@ -700,8 +707,7 @@ failed."
        (set-window-parameter window 'window-atom 'main))
       (set-window-parameter new 'window-atom side)
       ;; Display BUFFER in NEW and return NEW.
-      (window--display-buffer
-       buffer new 'window alist display-buffer-mark-dedicated))))
+      (window--display-buffer buffer new 'window alist))))
 
 (defun window--atom-check-1 (window)
   "Subroutine of `window--atom-check'."
@@ -958,7 +964,11 @@ and may be called only if no window on SIDE exists yet."
         ;; window and not make a new parent window unless needed.
         (window-combination-resize 'side)
         (window-combination-limit nil)
-        (window (split-window-no-error next-to nil on-side)))
+        (window (split-window-no-error next-to nil on-side))
+         (alist (if (assq 'dedicated alist)
+                    alist
+                  (cons `(dedicated . ,(or display-buffer-mark-dedicated 
'side))
+                        alist))))
     (when window
       ;; Initialize `window-side' parameter of new window to SIDE and
       ;; make that parameter persistent.
@@ -985,7 +995,7 @@ and may be called only if no window on SIDE exists yet."
       (with-current-buffer buffer
         (setq window--sides-shown t))
       ;; Install BUFFER in new window and return WINDOW.
-      (window--display-buffer buffer window 'window alist 'side))))
+      (window--display-buffer buffer window 'window alist))))
 
 (defun display-buffer-in-side-window (buffer alist)
   "Display BUFFER in a side window of the selected frame.
@@ -1019,10 +1029,7 @@ nor installs any other window parameters unless they 
have been
 explicitly provided via a `window-parameters' entry in ALIST."
   (let* ((side (or (cdr (assq 'side alist)) 'bottom))
          (slot (or (cdr (assq 'slot alist)) 0))
-         (left-or-right (memq side '(left right)))
-         ;; Softly dedicate window to BUFFER unless
-         ;; `display-buffer-mark-dedicated' already asks for it.
-         (dedicated (or display-buffer-mark-dedicated 'side)))
+         (left-or-right (memq side '(left right))))
     (cond
      ((not (memq side '(top bottom left right)))
       (error "Invalid side %s specified" side))
@@ -1055,7 +1062,11 @@ explicitly provided via a `window-parameters' entry in 
ALIST."
                  ((eq side 'bottom) 3))
                 window-sides-slots))
            (window--sides-inhibit-check t)
-          window this-window this-slot prev-window next-window
+           (alist (if (assq 'dedicated alist)
+                      alist
+                    (cons `(dedicated . ,(or display-buffer-mark-dedicated 
'side))
+                          alist)))
+           window this-window this-slot prev-window next-window
           best-window best-slot abs-slot)
 
       (cond
@@ -1113,8 +1124,7 @@ explicitly provided via a `window-parameters' entry in 
ALIST."
                 ;; Reuse `this-window'.
                  (with-current-buffer buffer
                    (setq window--sides-shown t))
-                (window--display-buffer
-                  buffer this-window 'reuse alist dedicated))
+                (window--display-buffer buffer this-window 'reuse alist))
            (and (or (not max-slots) (< slots max-slots))
                 (or (and next-window
                          ;; Make new window before `next-window'.
@@ -1131,8 +1141,7 @@ explicitly provided via a `window-parameters' entry in 
ALIST."
                   (set-window-parameter window 'window-slot slot)
                    (with-current-buffer buffer
                      (setq window--sides-shown t))
-                  (window--display-buffer
-                    buffer window 'window alist dedicated))
+                  (window--display-buffer buffer window 'window alist))
            (and best-window
                 ;; Reuse `best-window'.
                 (progn
@@ -1141,7 +1150,7 @@ explicitly provided via a `window-parameters' entry in 
ALIST."
                    (with-current-buffer buffer
                      (setq window--sides-shown t))
                    (window--display-buffer
-                   buffer best-window 'reuse alist dedicated)))))))))
+                    buffer best-window 'reuse alist)))))))))
 
 (defun window-toggle-side-windows (&optional frame)
   "Toggle display of side windows on specified FRAME.
@@ -2041,6 +2050,8 @@ doc-string of `window-resizable'."
 ;; Aliases of functions defined in window.c.
 (defalias 'window-height 'window-total-height)
 (defalias 'window-width 'window-body-width)
+(defalias 'window-pixel-width-before-size-change 'window-old-pixel-width)
+(defalias 'window-pixel-height-before-size-change 'window-old-pixel-height)
 
 (defun window-full-height-p (&optional window)
   "Return t if WINDOW is as high as its containing frame.
@@ -2742,7 +2753,7 @@ as small) as possible, but don't signal an error."
       ;; Sanitize DELTA.
       (cond
        ((<= (+ height delta) 0)
-       (setq delta (- (frame-char-height (window-frame window)) height)))
+       (setq delta (- (frame-char-height frame) height)))
        ((> delta min-delta)
        (setq delta min-delta)))
 
@@ -2757,8 +2768,7 @@ as small) as possible, but don't signal an error."
        ;; The following routine catches the case where we want to resize
        ;; a minibuffer-only frame.
        (when (resize-mini-window-internal window)
-         (window--pixel-to-total frame)
-         (run-window-configuration-change-hook frame))))))
+         (window--pixel-to-total frame))))))
 
 (defun window--resize-apply-p (frame &optional horizontal)
   "Return t when a window on FRAME shall be resized vertically.
@@ -2770,7 +2780,7 @@ shall be resized horizontally."
        (unless (= (window-new-pixel window)
                  (window-size window horizontal t))
         (throw 'apply t)))
-     frame t)
+     frame t t)
     nil))
 
 (defun window-resize (window delta &optional horizontal ignore pixelwise)
@@ -2856,9 +2866,7 @@ instead."
        (window--resize-siblings window delta horizontal ignore))
       (when (window--resize-apply-p frame horizontal)
        (if (window-resize-apply frame horizontal)
-           (progn
-             (window--pixel-to-total frame horizontal)
-             (run-window-configuration-change-hook frame))
+           (window--pixel-to-total frame horizontal)
          (error "Failed to apply resizing %s" window))))
      (t
       (error "Cannot resize window %s" window)))))
@@ -3373,6 +3381,12 @@ routines."
         pixel-delta
        (/ pixel-delta (frame-char-height frame)))))
 
+(defun window--resize-mini-frame (frame)
+  "Resize minibuffer-only frame FRAME."
+  (if (functionp resize-mini-frames)
+      (funcall resize-mini-frames frame)
+    (fit-frame-to-buffer frame)))
+
 (defun window--sanitize-window-sizes (horizontal)
   "Assert that all windows on selected frame are large enough.
 If necessary and possible, make sure that every window on frame
@@ -3392,7 +3406,8 @@ may happen when the FRAME is not large enough to 
accommodate it."
         (when (> delta 0)
           (if (window-resizable-p window delta horizontal nil t)
               (window-resize window delta horizontal nil t)
-            (setq value nil))))))
+            (setq value nil)))))
+     nil nil 'nomini)
     value))
 
 (defun adjust-window-trailing-edge (window delta &optional horizontal 
pixelwise)
@@ -3577,9 +3592,7 @@ move it as far as possible in the desired direction."
        ;; Don't report an error in the standard case.
        (when (window--resize-apply-p frame horizontal)
          (if (window-resize-apply frame horizontal)
-             (progn
-               (window--pixel-to-total frame horizontal)
-               (run-window-configuration-change-hook frame))
+             (window--pixel-to-total frame horizontal)
            ;; But do report an error if applying the changes fails.
            (error "Failed adjusting window %s" window))))))))
 
@@ -4110,7 +4123,6 @@ that is its frame's root window."
          ;; `delete-window-internal' has selected a window that should
          ;; not be selected, fix this here.
          (other-window -1 frame))
-       (run-window-configuration-change-hook frame)
        (window--check frame)
        ;; Always return nil.
        nil))))
@@ -4173,7 +4185,8 @@ any window whose `no-delete-other-windows' parameter is 
non-nil."
                        (and (not (window-parameter other 'window-side))
                             (window-parameter
                              other 'no-delete-other-windows)))
-               (throw 'tag nil))))
+               (throw 'tag nil)))
+           nil nil 'nomini)
           t)
         (setq main (window-main-window frame)))
        (t
@@ -4196,7 +4209,6 @@ any window whose `no-delete-other-windows' parameter is 
non-nil."
       ;; If WINDOW is the main window of its frame do nothing.
       (unless (eq window main)
        (delete-other-windows-internal window main)
-       (run-window-configuration-change-hook frame)
        (window--check frame))
       ;; Always return nil.
       nil)))
@@ -4278,7 +4290,7 @@ WINDOW must be a live window and defaults to the selected 
one."
                        (list (copy-marker start)
                              (copy-marker
                               ;; Preserve window-point-insertion-type
-                              ;; (Bug#12588).
+                              ;; (Bug#12855).
                               point window-point-insertion-type)))))
          (set-window-prev-buffers
           window (cons entry (window-prev-buffers window)))))
@@ -4691,6 +4703,8 @@ displayed there."
 BUFFER-OR-NAME may be a buffer or the name of an existing buffer
 and defaults to the current buffer.
 
+Interactively, prompt for the buffer.
+
 The following non-nil values of the optional argument FRAME
 have special meanings:
 
@@ -4707,10 +4721,26 @@ have special meanings:
 Any other value of FRAME means consider all windows on all
 frames.
 
-When a window showing BUFFER-OR-NAME is dedicated and the only
-window of its frame, that frame is deleted when there are other
-frames left."
-  (interactive "BDelete windows on (buffer):\nP")
+Interactively, FRAME is the prefix argument, so you can
+use \\[universal-argument] 0 to specify all windows only on
+the current terminal's frames.
+
+If a frame's root window shows the buffer specified by
+BUFFER-OR-NAME and is dedicated to that buffer and that frame
+does not host the active minibuffer window and there is at least
+one other frame on that frame's terminal, delete that frame.
+Otherwise, do not delete a frame's root window if it shows the
+buffer specified by BUFFER-OR-NAME and do not delete any frame's
+main window showing that buffer either.  Rather, in any such
+case, call `switch-to-prev-buffer' to show another buffer in that
+window and make sure the window is no more dedicated to its
+buffer.
+
+If the buffer specified by BUFFER-OR-NAME is shown in a
+minibuffer window, do nothing for that window.  For any window
+that does not show that buffer, remove the buffer from that
+window's lists of previous and next buffers."
+  (interactive "bDelete windows on (buffer):\nP")
   (let ((buffer (window-normalize-buffer buffer-or-name))
        ;; Handle the "inverted" meaning of the FRAME argument wrt other
        ;; `window-list-1' based function.
@@ -4893,7 +4923,7 @@ BUFFER-OR-NAME.  Optional argument FRAME is handled as by
 
 This function calls `quit-window' on all candidate windows
 showing BUFFER-OR-NAME."
-  (interactive "BQuit windows on (buffer):\nP")
+  (interactive "bQuit windows on (buffer):\nP")
   (let ((buffer (window-normalize-buffer buffer-or-name))
        ;; Handle the "inverted" meaning of the FRAME argument wrt other
        ;; `window-list-1' based function.
@@ -4904,6 +4934,24 @@ showing BUFFER-OR-NAME."
        ;; If a window doesn't show BUFFER, unrecord BUFFER in it.
        (unrecord-window-buffer window buffer)))))
 
+(defun window--combination-resizable (parent &optional horizontal)
+  "Return number of pixels recoverable from height of window PARENT.
+PARENT must be a vertical (horizontal if HORIZONTAL is non-nil)
+window combination.  The return value is the sum of the pixel
+heights of all non-fixed height child windows of PARENT divided
+by their number plus 1.  If HORIZONTAL is non-nil, return the sum
+of the pixel widths of all non-fixed width child windows of
+PARENT divided by their number plus 1."
+  (let ((sibling (window-child parent))
+       (number 0)
+       (size 0))
+    (while sibling
+      (unless (window-size-fixed-p sibling horizontal)
+       (setq number (1+ number))
+       (setq size (+ (window-size sibling horizontal t) size)))
+      (setq sibling (window-next-sibling sibling)))
+    (/ size (1+ number))))
+
 (defun split-window (&optional window size side pixelwise)
   "Make a new window adjacent to WINDOW.
 WINDOW must be a valid window and defaults to the selected one.
@@ -5041,8 +5089,7 @@ frame.  The selected window is not changed by this 
function."
                    ;; average size of a window in its combination.
                    (max (min (- parent-pixel-size
                                 (window-min-size parent horizontal nil t))
-                             (/ parent-pixel-size
-                                (1+ (window-combinations parent horizontal))))
+                             (window--combination-resizable parent horizontal))
                         (window-min-pixel-size))
                  ;; Else try to give the new window half the size
                  ;; of WINDOW (plus an eventual odd pixel).
@@ -5127,7 +5174,7 @@ frame.  The selected window is not changed by this 
function."
               (pixel-size (/ (float new-pixel-size)
                              (if new-parent old-pixel-size parent-pixel-size)))
               (new-parent 0.5)
-              (resize (/ 1.0 (1+ (window-combinations parent horizontal))))
+              (resize (/ 1.0 (1+ (window-combinations parent horizontal t))))
               (t (/ (window-normal-size window horizontal) 2.0))))
 
        (if resize
@@ -5184,7 +5231,6 @@ frame.  The selected window is not changed by this 
function."
          (unless size
             (window--sanitize-window-sizes horizontal))
 
-         (run-window-configuration-change-hook frame)
          (run-window-scroll-functions new)
          (window--check frame)
          ;; Always return the new window.
@@ -5415,15 +5461,13 @@ window."
     (balance-windows-1 window)
     (when (window--resize-apply-p frame)
       (window-resize-apply frame)
-      (window--pixel-to-total frame)
-      (run-window-configuration-change-hook frame))
+      (window--pixel-to-total frame))
     ;; Balance horizontally.
     (window--resize-reset (window-frame window) t)
     (balance-windows-1 window t)
     (when (window--resize-apply-p frame t)
       (window-resize-apply frame t)
-      (window--pixel-to-total frame t)
-      (run-window-configuration-change-hook frame))))
+      (window--pixel-to-total frame t))))
 
 (defun window-fixed-size-p (&optional window direction)
   "Return t if WINDOW cannot be resized in DIRECTION.
@@ -6073,23 +6117,26 @@ not resized by this function."
 
 (defun display-buffer-record-window (type window buffer)
   "Record information for window used by `display-buffer'.
+WINDOW is the window used for or created by a buffer display
+action function.  BUFFER is the buffer to display.  Note that
+this function must be called before BUFFER is explicitly made
+WINDOW's buffer (although WINDOW may show BUFFER already).
+
 TYPE specifies the type of the calling operation and must be one
-of the symbols `reuse' (when WINDOW existed already and was
-reused for displaying BUFFER), `window' (when WINDOW was created
-on an already existing frame), or `frame' (when WINDOW was
-created on a new frame).  WINDOW is the window used for or created
-by the `display-buffer' routines.  BUFFER is the buffer that
-shall be displayed.
-
-This function installs or updates the quit-restore parameter of
-WINDOW.  The quit-restore parameter is a list of four elements:
-The first element is one of the symbols `window', `frame', `same' or
-`other'.  The second element is either one of the symbols `window'
-or `frame' or a list whose elements are the buffer previously
-shown in the window, that buffer's window start and window point,
-and the window's height.  The third element is the window
-selected at the time the parameter was created.  The fourth
-element is BUFFER."
+of the symbols 'reuse' (meaning that WINDOW exists already and
+will be used for displaying BUFFER), 'window' (WINDOW was created
+on an already existing frame) or 'frame' (WINDOW was created on a
+new frame).
+
+This function installs or updates the 'quit-restore' parameter of
+WINDOW.  The 'quit-restore' parameter is a list of four elements:
+The first element is one of the symbols 'window', 'frame', 'same'
+or 'other'.  The second element is either one of the symbols
+'window' or 'frame' or a list whose elements are the buffer
+previously shown in the window, that buffer's window start and
+window point, and the window's height.  The third element is the
+window selected at the time the parameter was created.  The
+fourth element is BUFFER."
   (cond
    ((eq type 'reuse)
     (if (eq (window-buffer window) buffer)
@@ -6110,7 +6157,7 @@ element is BUFFER."
         (list 'other
               ;; A quadruple of WINDOW's buffer, start, point and height.
               (list (current-buffer) (window-start window)
-                    ;; Preserve window-point-insertion-type (Bug#12588).
+                    ;; Preserve window-point-insertion-type (Bug#12855).
                     (copy-marker
                      (window-point window) window-point-insertion-type)
                     (if (window-combined-p window)
@@ -6658,7 +6705,7 @@ split."
                                   (unless (or (eq w window)
                                               (window-dedicated-p w))
                                     (throw 'done nil)))
-                                frame)
+                                frame nil 'nomini)
               t)))
         (not (window-minibuffer-p window))
         (let ((split-height-threshold 0))
@@ -6748,20 +6795,51 @@ window is larger than WINDOW."
            (/ (- (window-total-height window) (window-total-height)) 2))
         (error nil))))))
 
-(defun window--display-buffer (buffer window type &optional alist dedicated)
+(defun window--display-buffer (buffer window type &optional alist)
   "Display BUFFER in WINDOW.
-TYPE must be one of the symbols `reuse', `window' or `frame' and
-is passed unaltered to `display-buffer-record-window'.  ALIST is
-the alist argument of `display-buffer'.  Set `window-dedicated-p'
-to DEDICATED if non-nil.  Return WINDOW if BUFFER and WINDOW are
-live."
+WINDOW must be a live window chosen by a buffer display action
+function for showing BUFFER.  TYPE tells whether WINDOW existed
+already before that action function was called or is a new window
+created by that function.  ALIST is a buffer display action alist
+as compiled by `display-buffer'.
+
+TYPE must be one of the following symbols: 'reuse' (which means
+WINDOW existed before the call of `display-buffer' and may
+already show BUFFER or not), 'window' (WINDOW was created on an
+existing frame) or 'frame' (WINDOW was created on a new frame).
+TYPE is passed unaltered to `display-buffer-record-window'.
+
+Handle WINDOW's dedicated flag as follows: If WINDOW already
+shows BUFFER, leave it alone.  Otherwise, if ALIST contains a
+'dedicated' entry and WINDOW is either new or that entry's value
+equals 'side', set WINDOW's dedicated flag to the value of that
+entry.  Otherwise, if WINDOW is new and the value of
+'display-buffer-mark-dedicated' is non-nil, set WINDOW's
+dedicated flag to that value.  In any other case, reset WINDOW's
+dedicated flag to nil.
+
+Return WINDOW if BUFFER and WINDOW are live."
   (when (and (buffer-live-p buffer) (window-live-p window))
     (display-buffer-record-window type window buffer)
     (unless (eq buffer (window-buffer window))
+      ;; Unless WINDOW already shows BUFFER reset its dedicated flag.
       (set-window-dedicated-p window nil)
       (set-window-buffer window buffer))
-    (when dedicated
-      (set-window-dedicated-p window dedicated))
+    (let ((alist-dedicated (assq 'dedicated alist)))
+      ;; Maybe dedicate WINDOW to BUFFER if asked for.
+      (cond
+       ;; Don't dedicate WINDOW if it is dedicated because it shows
+       ;; BUFFER already or it is reused and is not a side window.
+       ((or (window-dedicated-p window)
+            (and (eq type 'reuse) (not (eq (cdr alist-dedicated) 'side)))))
+       ;; Otherwise, if ALIST contains a 'dedicated' entry, use that
+       ;; entry's value (which may be nil).
+       (alist-dedicated
+        (set-window-dedicated-p window (cdr alist-dedicated)))
+       ;; Otherwise, if 'display-buffer-mark-dedicated' is non-nil,
+       ;; use that.
+       (display-buffer-mark-dedicated
+        (set-window-dedicated-p window display-buffer-mark-dedicated))))
     (when (memq type '(window frame))
       (set-window-prev-buffers window nil))
     (let ((quit-restore (window-parameter window 'quit-restore))
@@ -7156,7 +7234,7 @@ on all the frames on the current terminal, skipping the 
selected
 window; if that fails, it pops up a new frame.
 This uses the function `display-buffer' as a subroutine; see
 its documentation for additional customization information."
-  (interactive "BDisplay buffer in other frame: ")
+  (interactive "bDisplay buffer in other frame: ")
   (display-buffer buffer display-buffer--other-frame-action t))
 
 ;;; `display-buffer' action functions:
@@ -7182,9 +7260,7 @@ that allows the selected frame)."
           (or (cdr (assq 'frame-predicate alist))
               (lambda (frame)
                 (and (not (eq frame (selected-frame)))
-                     (not (window-dedicated-p
-                           (or (get-lru-window frame)
-                               (frame-first-window frame))))))))
+                     (get-lru-window frame)))))
          (frame (car (filtered-frame-list predicate)))
          (window
           (and frame
@@ -7192,8 +7268,7 @@ that allows the selected frame)."
                 frame nil (cdr (assq 'inhibit-same-window alist))))))
     (when window
       (prog1
-          (window--display-buffer
-           buffer window 'frame alist display-buffer-mark-dedicated)
+          (window--display-buffer buffer window 'reuse alist)
         (unless (cdr (assq 'inhibit-switch-frame alist))
           (window--maybe-raise-frame frame))))))
 
@@ -7358,8 +7433,7 @@ new frame."
               (with-current-buffer buffer
                 (setq frame (funcall fun)))
               (setq window (frame-selected-window frame)))
-      (prog1 (window--display-buffer
-             buffer window 'frame alist display-buffer-mark-dedicated)
+      (prog1 (window--display-buffer buffer window 'frame alist)
        (unless (cdr (assq 'inhibit-switch-frame alist))
          (window--maybe-raise-frame frame))))))
 
@@ -7388,8 +7462,7 @@ raising the frame."
                                (window--try-to-split-window
                                 (get-lru-window frame t) alist))))
 
-      (prog1 (window--display-buffer
-             buffer window 'window alist display-buffer-mark-dedicated)
+      (prog1 (window--display-buffer buffer window 'window alist)
        (unless (cdr (assq 'inhibit-switch-frame alist))
          (window--maybe-raise-frame (window-frame window)))))))
 
@@ -7437,7 +7510,7 @@ be added to ALIST."
         (parent (or (assq 'parent-frame parameters)
                      (selected-frame)))
          (share (assq 'share-child-frame parameters))
-         share1 frame window)
+         share1 frame window type)
     (with-current-buffer buffer
       (when (frame-live-p parent)
         (catch 'frame
@@ -7450,12 +7523,14 @@ be added to ALIST."
                 (throw 'frame t))))))
 
       (if frame
-          (setq window (frame-selected-window frame))
+          (progn
+            (setq window (frame-selected-window frame))
+            (setq type 'reuse))
         (setq frame (make-frame parameters))
-        (setq window (frame-selected-window frame))))
+        (setq window (frame-selected-window frame))
+        (setq type 'frame)))
 
-    (prog1 (window--display-buffer
-           buffer window 'frame alist display-buffer-mark-dedicated)
+    (prog1 (window--display-buffer buffer window type alist)
       (unless (cdr (assq 'inhibit-switch-frame alist))
        (window--maybe-raise-frame frame)))))
 
@@ -7494,16 +7569,14 @@ must also contain a 'window-height' entry with the same 
value."
                   split-width-threshold)
                (setq window (window--try-to-split-window
                              (selected-window) alist)))
-             (window--display-buffer
-              buffer window 'window alist display-buffer-mark-dedicated))
+             (window--display-buffer buffer window 'window alist))
        (and (setq window (window-in-direction 'below))
              (not (window-dedicated-p window))
             (or (not (numberp min-height))
                 ;; A window that showed another buffer before cannot
                 ;; be resized.
                 (>= (window-height window) min-height))
-            (window--display-buffer
-              buffer window 'reuse alist display-buffer-mark-dedicated)))))
+            (window--display-buffer buffer window 'reuse alist)))))
 
 (defun display-buffer--maybe-at-bottom (buffer alist)
   (let ((alist (append alist `(,(if temp-buffer-resize-mode
@@ -7535,21 +7608,13 @@ selected frame."
         (setq bottom-window window))))
      nil nil 'nomini)
     (or (and bottom-window-shows-buffer
-            (window--display-buffer
-             buffer bottom-window 'reuse alist display-buffer-mark-dedicated))
-       (and (not (frame-parameter nil 'unsplittable))
-            (let (split-width-threshold)
-              (setq window (window--try-to-split-window bottom-window alist)))
-            (window--display-buffer
-             buffer window 'window alist display-buffer-mark-dedicated))
+            (window--display-buffer buffer bottom-window 'reuse alist))
        (and (not (frame-parameter nil 'unsplittable))
             (setq window (split-window-no-error (window-main-window)))
-            (window--display-buffer
-             buffer window 'window alist display-buffer-mark-dedicated))
+            (window--display-buffer buffer window 'window alist))
        (and (setq window bottom-window)
             (not (window-dedicated-p window))
-            (window--display-buffer
-             buffer window 'reuse alist display-buffer-mark-dedicated)))))
+            (window--display-buffer buffer window 'reuse alist)))))
 
 (defun display-buffer-in-previous-window (buffer alist)
   "Display BUFFER in a window previously showing it.
@@ -7598,7 +7663,8 @@ above, even if that window never showed BUFFER before."
     ;; anything we found so far.
     (when (and (setq window (cdr (assq 'previous-window alist)))
               (window-live-p window)
-              (not (window-dedicated-p window)))
+              (or (eq buffer (window-buffer window))
+                   (not (window-dedicated-p window))))
       (if (eq window (selected-window))
          (unless inhibit-same-window
            (setq second-best-window window))
@@ -7768,7 +7834,9 @@ position in the selected window.
 
 This variable is ignored if the buffer is already displayed in
 the selected window or never appeared in it before, or if
-`switch-to-buffer' calls `pop-to-buffer' to display the buffer."
+`switch-to-buffer' calls `pop-to-buffer' to display the buffer,
+or non-nil `switch-to-buffer-obey-display-actions' displays it
+in another window."
   :type '(choice
          (const :tag "Never" nil)
          (const :tag "If already displayed elsewhere" already-displayed)
@@ -7803,6 +7871,16 @@ FORCE-SAME-WINDOW is non-nil."
   :group 'windows
   :version "25.1")
 
+(defcustom switch-to-buffer-obey-display-actions nil
+  "If non-nil, `switch-to-buffer' runs `pop-to-buffer-same-window' instead.
+This means that when switching the buffer it respects display actions
+specified by `display-buffer-overriding-action', `display-buffer-alist'
+and other display related variables.  So `switch-to-buffer' will display
+the buffer in the window specified by the rules from these variables."
+  :type 'boolean
+  :group 'windows
+  :version "27.1")
+
 (defun switch-to-buffer (buffer-or-name &optional norecord force-same-window)
   "Display buffer BUFFER-OR-NAME in the selected window.
 
@@ -7835,59 +7913,83 @@ displaying it the most recently selected one.
 If optional argument FORCE-SAME-WINDOW is non-nil, the buffer
 must be displayed in the selected window when called
 non-interactively; if that is impossible, signal an error rather
-than calling `pop-to-buffer'.
+than calling `pop-to-buffer'.  It has no effect when the option
+`switch-to-buffer-obey-display-actions' is non-nil.
 
 The option `switch-to-buffer-preserve-window-point' can be used
 to make the buffer appear at its last position in the selected
 window.
 
+If the option `switch-to-buffer-obey-display-actions' is non-nil,
+run the function `pop-to-buffer-same-window' instead.
+This may display the buffer in another window as specified by
+`display-buffer-overriding-action', `display-buffer-alist' and
+other display related variables.  If this results in displaying
+the buffer in the selected window, window start and point are adjusted
+as prescribed by the option `switch-to-buffer-preserve-window-point'.
+Otherwise, these are left alone.
+
 Return the buffer switched to."
   (interactive
    (let ((force-same-window
-          (cond
-           ((window-minibuffer-p) nil)
-           ((not (eq (window-dedicated-p) t)) 'force-same-window)
-           ((pcase switch-to-buffer-in-dedicated-window
-              ('nil (user-error
-                     "Cannot switch buffers in a dedicated window"))
-              ('prompt
-               (if (y-or-n-p
-                    (format "Window is dedicated to %s; undedicate it"
-                            (window-buffer)))
-                   (progn
-                     (set-window-dedicated-p nil nil)
-                     'force-same-window)
-                 (user-error
-                  "Cannot switch buffers in a dedicated window")))
-              ('pop nil)
-              (_ (set-window-dedicated-p nil nil) 'force-same-window))))))
+          (unless switch-to-buffer-obey-display-actions
+            (cond
+             ((window-minibuffer-p) nil)
+             ((not (eq (window-dedicated-p) t)) 'force-same-window)
+             ((pcase switch-to-buffer-in-dedicated-window
+                ('nil (user-error
+                       "Cannot switch buffers in a dedicated window"))
+                ('prompt
+                 (if (y-or-n-p
+                      (format "Window is dedicated to %s; undedicate it"
+                              (window-buffer)))
+                     (progn
+                       (set-window-dedicated-p nil nil)
+                       'force-same-window)
+                   (user-error
+                    "Cannot switch buffers in a dedicated window")))
+                ('pop nil)
+                (_ (set-window-dedicated-p nil nil) 'force-same-window)))))))
      (list (read-buffer-to-switch "Switch to buffer: ") nil 
force-same-window)))
-  (let ((buffer (window-normalize-buffer-to-switch-to buffer-or-name)))
+  (let ((buffer (window-normalize-buffer-to-switch-to buffer-or-name))
+        (set-window-start-and-point (not 
switch-to-buffer-obey-display-actions)))
     (cond
      ;; Don't call set-window-buffer if it's not needed since it
      ;; might signal an error (e.g. if the window is dedicated).
-     ((eq buffer (window-buffer)))
-     ((window-minibuffer-p)
+     ((and (eq buffer (window-buffer))
+           ;; pop-to-buffer-same-window might decide to display
+           ;; the same buffer in another window
+           (not switch-to-buffer-obey-display-actions)))
+     ((and (window-minibuffer-p)
+           (not switch-to-buffer-obey-display-actions))
       (if force-same-window
           (user-error "Cannot switch buffers in minibuffer window")
         (pop-to-buffer buffer norecord)))
-     ((eq (window-dedicated-p) t)
+     ((and (eq (window-dedicated-p) t)
+           (not switch-to-buffer-obey-display-actions))
       (if force-same-window
           (user-error "Cannot switch buffers in a dedicated window")
         (pop-to-buffer buffer norecord)))
      (t
-      (let* ((entry (assq buffer (window-prev-buffers)))
-            (displayed (and (eq switch-to-buffer-preserve-window-point
-                                'already-displayed)
-                            (get-buffer-window buffer 0))))
-       (set-window-buffer nil buffer)
-       (when (and entry
-                  (or (eq switch-to-buffer-preserve-window-point t)
-                      displayed))
-         ;; Try to restore start and point of buffer in the selected
-         ;; window (Bug#4041).
-         (set-window-start (selected-window) (nth 1 entry) t)
-         (set-window-point nil (nth 2 entry))))))
+      (when switch-to-buffer-obey-display-actions
+        (let ((selected-window (selected-window)))
+          (pop-to-buffer-same-window buffer norecord)
+          (when (eq (selected-window) selected-window)
+            (setq set-window-start-and-point t))))
+
+      (when set-window-start-and-point
+        (let* ((entry (assq buffer (window-prev-buffers)))
+              (displayed (and (eq switch-to-buffer-preserve-window-point
+                                  'already-displayed)
+                              (get-buffer-window buffer 0))))
+         (set-window-buffer nil buffer)
+         (when (and entry
+                    (or (eq switch-to-buffer-preserve-window-point t)
+                        displayed))
+           ;; Try to restore start and point of buffer in the selected
+           ;; window (Bug#4041).
+           (set-window-start (selected-window) (nth 1 entry) t)
+           (set-window-point nil (nth 2 entry)))))))
 
     (unless norecord
       (select-window (selected-window)))
@@ -8141,10 +8243,13 @@ Return 0 otherwise."
 (defun fit-frame-to-buffer (&optional frame max-height min-height max-width 
min-width only)
   "Adjust size of FRAME to display the contents of its buffer exactly.
 FRAME can be any live frame and defaults to the selected one.
-Fit only if FRAME's root window is live.  MAX-HEIGHT, MIN-HEIGHT,
-MAX-WIDTH and MIN-WIDTH specify bounds on the new total size of
-FRAME's root window.  MIN-HEIGHT and MIN-WIDTH default to the values of
-`window-min-height' and `window-min-width' respectively.
+Fit only if FRAME's root window is live.
+
+MAX-HEIGHT, MIN-HEIGHT, MAX-WIDTH and MIN-WIDTH specify bounds on
+the new total size of FRAME's root window.  MIN-HEIGHT and
+MIN-WIDTH default to the values of `window-min-height' and
+`window-min-width' respectively.  These arguments are specified
+in the canonical character width and height of FRAME.
 
 If the optional argument ONLY is `vertically', resize the frame
 vertically only.  If ONLY is `horizontally', resize the frame
@@ -9209,6 +9314,8 @@ is active.  This function is run by 
`mouse-autoselect-window-timer'."
      ;; autoselection.
      (mouse-autoselect-window-start mouse-position window)))))
 
+(declare-function display-multi-frame-p "frame" (&optional display))
+
 (defun handle-select-window (event)
   "Handle select-window events."
   (interactive "^e")
@@ -9246,7 +9353,7 @@ is active.  This function is run by 
`mouse-autoselect-window-timer'."
       ;; we might get two windows with an active cursor.
       (select-window window)
       (cond
-       ((or (not (memq (window-system frame) '(x w32 ns)))
+       ((or (not (display-multi-frame-p))
             (not focus-follows-mouse)
             ;; Focus FRAME if it's either a child frame or an ancestor
             ;; of the frame switched from.
@@ -9377,15 +9484,7 @@ displaying that processes's buffer."
               (when size
                 (set-process-window-size process (cdr size) (car size))))))))))
 
-;; Remove the following call in Emacs 27, running
-;; 'window-size-change-functions' should suffice.
 (add-hook 'window-configuration-change-hook 'window--adjust-process-windows)
-
-;; Catch any size changes not handled by
-;; 'window-configuration-change-hook' (Bug#32720, "another issue" in
-;; Bug#33230).
-(add-hook 'window-size-change-functions (lambda (_frame)
-                                          (window--adjust-process-windows)))
 
 ;; Some of these are in tutorial--default-keys, so update that if you
 ;; change these.
diff --git a/lisp/winner.el b/lisp/winner.el
index 5e13a37..7a5f0df 100644
--- a/lisp/winner.el
+++ b/lisp/winner.el
@@ -1,6 +1,6 @@
 ;;; winner.el --- Restore old window configurations
 
-;; Copyright (C) 1997-1998, 2001-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2001-2019 Free Software Foundation, Inc.
 
 ;; Author: Ivar Rummelhoff <address@hidden>
 ;; Created: 27 Feb 1997
diff --git a/lisp/woman.el b/lisp/woman.el
index 238a7d3..39d9b80 100644
--- a/lisp/woman.el
+++ b/lisp/woman.el
@@ -1,6 +1,6 @@
 ;;; woman.el --- browse UN*X manual pages `wo (without) man'
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Francis J. Wright <address@hidden>
 ;; Maintainer: address@hidden
@@ -2010,10 +2010,8 @@ Optional argument REDRAW, if non-nil, forces mode line 
to be updated."
 ;;   (after Man-bgproc-sentinel-advice activate)
 ;;   ;; Terminates man processing
 ;;   "Report formatting time."
-;;   (let* ((time (current-time))
-;;      (time (+ (* (- (car time) (car WoMan-Man-start-time)) 65536)
-;;               (- (cadr time) (cadr WoMan-Man-start-time)))))
-;;     (message "Man formatting done in %d seconds" time)))
+;;   (message "Man formatting done in %s seconds"
+;;            (float-time (time-since WoMan-Man-start-time))))
 
 
 ;;; Buffer handling:
@@ -2078,7 +2076,7 @@ alist in `woman-buffer-alist' and return nil."
   (char-to-string woman-escaped-escape-char)
   "Internal string representation of escaped escape characters.")
 
-(defconst woman-unpadded-space-char ?\^]
+(defconst woman-unpadded-space-char ?\^\]
   ;; An arbitrary unused control character
   "Internal character representation of unpadded space characters.")
 (defconst woman-unpadded-space-string
@@ -2626,7 +2624,7 @@ If DELETE is non-nil then delete from point."
        (t                              ; Ignore -- leave in buffer
         ;; This does not work too well, but it's only for debugging!
         (skip-chars-forward "^ \t")
-        (if (looking-at "[ \t]*\\{") (search-forward "\\}"))
+        (if (looking-at "[ \t]*{") (search-forward "}"))
         (forward-line 1))))
 
 ;; request is not used dynamically by any callees.
@@ -2638,7 +2636,7 @@ If DELETE is non-nil then delete from point."
     ;; Ignore -- leave in buffer
     ;; This does not work too well, but it's only for debugging!
     (skip-chars-forward "^ \t")
-    (if (looking-at "[ \t]*\\{") (search-forward "\\}"))
+    (if (looking-at "[ \t]*{") (search-forward "}"))
     (forward-line 1)))
 
 (defun woman0-so ()
@@ -3270,7 +3268,7 @@ If optional arg CONCAT is non-nil then join arguments."
     (while
        ;; Find font requests, paragraph macros and font escapes:
        (re-search-forward
-        "^[.'][ \t]*\\(\\(\\ft\\)\\|\\(.P\\)\\)\\|\\(\\\\f\\)" nil 1)
+        "^[.'][ \t]*\\(\\(ft\\)\\|\\(.P\\)\\)\\|\\(\\\\f\\)" nil 1)
       (let (font beg notfont fescape)
        ;; Match font indicator and leave point at end of sequence:
        (cond ((match-beginning 2)
@@ -3513,7 +3511,7 @@ The expression may be an argument in quotes."
   (let ((value (if (looking-at "[+-]") 0 (woman-parse-numeric-value)))
        op)
     (while (cond
-           ((looking-at "[+-/*%]")     ; arithmetic operators
+           ((looking-at "[+/*%-]")     ; arithmetic operators
             (forward-char)
             (setq op (intern-soft (match-string 0)))
             (setq value (funcall op value (woman-parse-numeric-value))))
diff --git a/lisp/x-dnd.el b/lisp/x-dnd.el
index 080cd4d..e4e2dec 100644
--- a/lisp/x-dnd.el
+++ b/lisp/x-dnd.el
@@ -1,6 +1,6 @@
 ;;; x-dnd.el --- drag and drop support for X
 
-;; Copyright (C) 2004-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 ;; Author: Jan Djärv <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/lisp/xdg.el b/lisp/xdg.el
index f818324..e5a3de4 100644
--- a/lisp/xdg.el
+++ b/lisp/xdg.el
@@ -1,6 +1,6 @@
 ;;; xdg.el --- XDG specification and standard support -*- lexical-binding: t 
-*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Mark Oteiza <address@hidden>
 ;; Created: 27 January 2017
@@ -117,7 +117,7 @@ file:///foo/bar.jpg"
 (defun xdg--substitute-home-env (str)
   (if (file-name-absolute-p str) str
     (save-match-data
-      (and (string-match "^$HOME/" str)
+      (and (string-match "^\\$HOME/" str)
            (replace-match "~/" t nil str 0)))))
 
 (defun xdg--user-dirs-parse-line ()
diff --git a/lisp/xml.el b/lisp/xml.el
index 6ce944c..1f3c05f 100644
--- a/lisp/xml.el
+++ b/lisp/xml.el
@@ -1,6 +1,6 @@
 ;;; xml.el --- XML parser -*- lexical-binding: t -*-
 
-;; Copyright (C) 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Emmanuel Briot  <address@hidden>
 ;; Maintainer: Mark A. Hershberger <address@hidden>
@@ -176,11 +176,11 @@ See also `xml-get-attribute-or-nil'."
 
 ;; [4] NameStartChar
 ;; See the definition of word syntax in `xml-syntax-table'.
-(defconst xml-name-start-char-re (concat "[[:word:]:_]"))
+(defconst xml-name-start-char-re "[[:word:]:_]")
 
 ;; [4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7
 ;;                 | [#x0300-#x036F] | [#x203F-#x2040]
-(defconst xml-name-char-re (concat "[-0-9.[:word:]:_·̀-ͯ‿-⁀]"))
+(defconst xml-name-char-re "[[:word:]:_.0-9\u00B7\u0300-\u036F\u203F\u2040-]")
 
 ;; [5] Name     ::= NameStartChar (NameChar)*
 (defconst xml-name-re (concat xml-name-start-char-re xml-name-char-re "*"))
@@ -245,7 +245,6 @@ See also `xml-get-attribute-or-nil'."
 ;; [54] AttType    ::= StringType | TokenizedType | EnumeratedType
 ;; [55] StringType ::= 'CDATA'
 (defconst xml-att-type-re (concat "\\(?:CDATA\\|" xml-tokenized-type-re
-                                 "\\|" xml-notation-type-re
                                  "\\|" xml-enumerated-type-re "\\)"))
 
 ;; [60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue)
@@ -718,10 +717,10 @@ This follows the rule [28] in the XML specifications."
     (cond ((looking-at "PUBLIC\\s-+")
           (goto-char (match-end 0))
           (unless (or (re-search-forward
-                       
"\\=\"\\([[:space:][:alnum:]-'()+,./:=?;address@hidden)\""
+                       
"\\=\"\\([[:space:][:alnum:]'()+,./:=?;address@hidden)\""
                        nil t)
                       (re-search-forward
-                       "\\='\\([[:space:][:alnum:]-()+,./:=?;address@hidden)'"
+                       "\\='\\([[:space:][:alnum:]()+,./:=?;address@hidden)'"
                        nil t))
             (error "XML: Missing Public ID"))
           (let ((pubid (match-string-no-properties 1)))
diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el
index da4af32..5ff7182 100644
--- a/lisp/xt-mouse.el
+++ b/lisp/xt-mouse.el
@@ -1,6 +1,6 @@
 ;;; xt-mouse.el --- support the mouse when emacs run in an xterm -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 1994, 2000-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 2000-2019 Free Software Foundation, Inc.
 
 ;; Author: Per Abrahamsen <address@hidden>
 ;; Keywords: mouse, terminals
@@ -123,20 +123,7 @@ http://invisible-island.net/xterm/ctlseqs/ctlseqs.html)."
                      (terminal-parameter nil 'xterm-mouse-y))))
   pos)
 
-(defun xterm-mouse-truncate-wrap (f)
-  "Truncate with wrap-around."
-  (condition-case nil
-      ;; First try the built-in truncate, in case there's no overflow.
-      (truncate f)
-    ;; In case of overflow, do wraparound by hand.
-    (range-error
-     ;; In our case, we wrap around every 3 days or so, so if we assume
-     ;; a maximum of 65536 wraparounds, we're safe for a couple years.
-     ;; Using a power of 2 makes rounding errors less likely.
-     (let* ((maxwrap (* 65536 2048))
-            (dbig (truncate (/ f maxwrap)))
-            (fdiff (- f (* 1.0 maxwrap dbig))))
-       (+ (truncate fdiff) (* maxwrap dbig))))))
+(define-obsolete-function-alias 'xterm-mouse-truncate-wrap 'truncate "27.1")
 
 (defcustom xterm-mouse-utf-8 nil
   "Non-nil if UTF-8 coordinates should be used to read mouse coordinates.
@@ -256,18 +243,17 @@ which is the \"1006\" extension implemented in Xterm >= 
277."
              (y    (nth 2 click))
              ;; Emulate timestamp information.  This is accurate enough
              ;; for default value of mouse-1-click-follows-link (450msec).
-             (timestamp (xterm-mouse-truncate-wrap
-                         (* 1000
-                            (- (float-time)
-                               (or xt-mouse-epoch
-                                   (setq xt-mouse-epoch (float-time)))))))
+            (timestamp (if (not xt-mouse-epoch)
+                           (progn (setq xt-mouse-epoch (float-time)) 0)
+                         (car (encode-time (time-since xt-mouse-epoch)
+                                           1000))))
              (w (window-at x y))
              (ltrb (window-edges w))
              (left (nth 0 ltrb))
              (top (nth 1 ltrb))
              (posn (if w
-                                (posn-at-x-y (- x left) (- y top) w t)
-                              (append (list nil 'menu-bar)
+                      (posn-at-x-y (- x left) (- y top) w t)
+                    (append (list nil 'menu-bar)
                              (nthcdr 2 (posn-at-x-y x y)))))
              (event (list type posn)))
         (setcar (nthcdr 3 posn) timestamp)
diff --git a/lisp/xwidget.el b/lisp/xwidget.el
index 3bf65d0..662a854 100644
--- a/lisp/xwidget.el
+++ b/lisp/xwidget.el
@@ -1,6 +1,6 @@
 ;;; xwidget.el --- api functions for xwidgets  -*- lexical-binding: t -*-
 ;;
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 ;;
 ;; Author: Joakim Verona (address@hidden)
 ;;
diff --git a/lwlib/ChangeLog.1 b/lwlib/ChangeLog.1
index 375ab2e..e8f2210 100644
--- a/lwlib/ChangeLog.1
+++ b/lwlib/ChangeLog.1
@@ -1964,7 +1964,7 @@
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 1995-1999, 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 1995-1999, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/lwlib/Makefile.in b/lwlib/Makefile.in
index ed71270..e1d9287 100644
--- a/lwlib/Makefile.in
+++ b/lwlib/Makefile.in
@@ -1,7 +1,7 @@
 ### @configure_input@
 
 # Copyright (C) 1992, 1993 Lucid, Inc.
-# Copyright (C) 1994, 2001-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994, 2001-2019 Free Software Foundation, Inc.
 #
 # This file is part of the Lucid Widget Library.
 #
diff --git a/lwlib/deps.mk b/lwlib/deps.mk
index 675832e..f5097ea 100644
--- a/lwlib/deps.mk
+++ b/lwlib/deps.mk
@@ -1,7 +1,7 @@
 ### deps.mk --- lwlib/Makefile fragment for GNU Emacs
 
 # Copyright (C) 1992, 1993 Lucid, Inc.
-# Copyright (C) 1994, 2001-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994, 2001-2019 Free Software Foundation, Inc.
 #
 # This file is part of the Lucid Widget Library.
 #
diff --git a/lwlib/lwlib-Xaw.c b/lwlib/lwlib-Xaw.c
index bc1c18d..0801c94 100644
--- a/lwlib/lwlib-Xaw.c
+++ b/lwlib/lwlib-Xaw.c
@@ -1,7 +1,7 @@
 /* The lwlib interface to Athena widgets.
 
 Copyright (C) 1993 Chuck Thompson <address@hidden>
-Copyright (C) 1994, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1994, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of the Lucid Widget Library.
 
@@ -50,8 +50,13 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #include <X11/Xatom.h>
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
+#ifdef USE_CAIRO
+#include <stdlib.h>
+#include "lwlib-utils.h"
+#else  /* HAVE_XFT */
 #include <X11/Xft/Xft.h>
+#endif
 
 struct widget_xft_data
 {
@@ -79,7 +84,7 @@ lw_xaw_widget_p (Widget widget)
 }
 
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
 static void
 fill_xft_data (struct widget_xft_data *data, Widget widget, XftFont *font)
 {
@@ -113,6 +118,23 @@ fill_xft_data (struct widget_xft_data *data, Widget 
widget, XftFont *font)
   data->p_width = data->p_height = 0;
 }
 
+static void
+destroy_xft_data (Widget widget, XtPointer closure, XtPointer call_data)
+{
+  struct widget_xft_data *xft_data = closure;
+
+  for (int i = 0; xft_data[i].widget; ++i)
+    {
+      if (xft_data[i].xft_draw)
+       XftDrawDestroy (xft_data[i].xft_draw);
+      if (xft_data[i].p != None)
+       XFreePixmap (XtDisplay (widget), xft_data[i].p);
+    }
+  if (xft_data[0].xft_font)
+    XftFontClose (XtDisplay (widget), xft_data[0].xft_font);
+  xfree (xft_data);
+}
+
 static XftFont*
 openFont (Widget widget, char *name)
 {
@@ -154,7 +176,7 @@ get_text_width_and_height (Widget widget, char *text,
                           &gi);
       bp = cp ? cp + 1 : NULL;
       h += xft_font->height;
-      if (w < gi.width) w = gi.width;
+      if (w < gi.xOff) w = gi.xOff;
     }
 
   *height = h;
@@ -170,11 +192,12 @@ draw_text (struct widget_xft_data *data, char *lbl, int 
inverse)
   int x = inverse ? 0 : 2;
   char *bp = lbl;
 
-  data->xft_draw = XftDrawCreate (XtDisplay (data->widget),
-                                  data->p,
-                                  DefaultVisual (XtDisplay (data->widget),
-                                                 screen),
-                                  DefaultColormapOfScreen (sc));
+  if (!data->xft_draw)
+    data->xft_draw = XftDrawCreate (XtDisplay (data->widget),
+                                   data->p,
+                                   DefaultVisual (XtDisplay (data->widget),
+                                                  screen),
+                                   DefaultColormapOfScreen (sc));
   XftDrawRect (data->xft_draw,
                inverse ? &data->xft_fg : &data->xft_bg,
                0, 0, data->p_width, data->p_height);
@@ -192,6 +215,9 @@ draw_text (struct widget_xft_data *data, char *lbl, int 
inverse)
       /* 1.2 gives reasonable line spacing.  */
       y += data->xft_font->height * 1.2;
     }
+#ifdef USE_CAIRO
+  cairo_surface_flush (cairo_get_target (data->xft_draw));
+#endif
 
 }
 
@@ -229,7 +255,7 @@ find_xft_data (Widget widget)
     }
   if (!inst || !inst->xft_data || !inst->xft_data[0].xft_font) return 0;
 
-  for (nr = 0; data == NULL && nr < inst->nr_xft_data; ++nr)
+  for (nr = 0; data == NULL && inst->xft_data[nr].widget; ++nr)
     {
       if (inst->xft_data[nr].widget == widget)
         data = &inst->xft_data[nr];
@@ -289,7 +315,7 @@ xaw_update_one_widget (widget_instance *instance,
   if (XtIsSubclass (widget, dialogWidgetClass))
     {
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
       if (instance->xft_data && instance->xft_data[0].xft_font)
         {
           set_text (&instance->xft_data[0], instance->parent,
@@ -321,15 +347,15 @@ xaw_update_one_widget (widget_instance *instance,
       XtSetArg (al[ac], XtNlabel, val->value);ac++;
       /* Force centered button text.  Se above. */
       XtSetArg (al[ac], XtNjustify, XtJustifyCenter);ac++;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
       if (instance->xft_data && instance->xft_data[0].xft_font)
         {
           int th;
           int nr;
-          for (nr = 0; nr < instance->nr_xft_data; ++nr)
+          for (nr = 0; instance->xft_data[nr].widget; ++nr)
             if (instance->xft_data[nr].widget == widget)
               break;
-          if (nr < instance->nr_xft_data)
+          if (instance->xft_data[nr].widget)
             {
               set_text (&instance->xft_data[nr], instance->parent,
                         val->value, 6);
@@ -360,28 +386,6 @@ xaw_update_one_value (widget_instance *instance,
 void
 xaw_destroy_instance (widget_instance *instance)
 {
-#ifdef HAVE_XFT
-  if (instance->xft_data)
-    {
-      int i;
-      for (i = 0; i < instance->nr_xft_data; ++i)
-        {
-          if (instance->xft_data[i].xft_draw)
-            XftDrawDestroy (instance->xft_data[i].xft_draw);
-          if (instance->xft_data[i].p != None)
-            {
-              XtVaSetValues (instance->xft_data[i].widget, XtNbitmap, None,
-                             NULL);
-              XFreePixmap (XtDisplay (instance->widget),
-                           instance->xft_data[i].p);
-            }
-        }
-      if (instance->xft_data[0].xft_font)
-        XftFontClose (XtDisplay (instance->widget),
-                      instance->xft_data[0].xft_font);
-      xfree (instance->xft_data);
-    }
-#endif
   if (XtIsSubclass (instance->widget, dialogWidgetClass))
     /* Need to destroy the Shell too. */
     XtDestroyWidget (XtParent (instance->widget));
@@ -477,7 +481,7 @@ static XtActionsRec xaw_actions [] = {
 };
 static Boolean actions_initted = False;
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
 static XtActionsRec button_actions[] =
   {
     { "my_reset", command_reset },
@@ -510,7 +514,7 @@ make_dialog (char* name,
   Widget dialog;
   Widget button;
   XtTranslations override;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   XftFont *xft_font = 0;
   XtTranslations button_override;
 #endif
@@ -525,7 +529,7 @@ make_dialog (char* name,
       XtAppContext app = XtWidgetToApplicationContext (parent);
       XtAppAddActions (app, xaw_actions,
                       sizeof (xaw_actions) / sizeof (xaw_actions[0]));
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
       XtAppAddActions (app, button_actions,
                       sizeof (button_actions) / sizeof (button_actions[0]));
 #endif
@@ -550,7 +554,7 @@ make_dialog (char* name,
   override = XtParseTranslationTable (dialogOverride);
   XtOverrideTranslations (dialog, override);
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   {
     int num;
     Widget *ch = NULL;
@@ -568,7 +572,6 @@ make_dialog (char* name,
           }
       }
     instance->xft_data = 0;
-    instance->nr_xft_data = 0;
     if (w)
       {
         XtResource rec[] =
@@ -588,11 +591,13 @@ make_dialog (char* name,
 
         if (xft_font)
           {
-            instance->nr_xft_data = left_buttons + right_buttons + 1;
-            instance->xft_data = calloc (instance->nr_xft_data,
+            int nr_xft_data = left_buttons + right_buttons + 1;
+            instance->xft_data = calloc (nr_xft_data + 1,
                                          sizeof(*instance->xft_data));
 
             fill_xft_data (&instance->xft_data[0], w, xft_font);
+           XtAddCallback (dialog, XtNdestroyCallback, destroy_xft_data,
+                          instance->xft_data);
           }
       }
 
@@ -621,7 +626,7 @@ make_dialog (char* name,
       sprintf (button_name, "button%d", ++bc);
       button = XtCreateManagedWidget (button_name, commandWidgetClass,
                                      dialog, av, ac);
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
       if (xft_font)
         {
           fill_xft_data (&instance->xft_data[bc], button, xft_font);
@@ -654,7 +659,7 @@ make_dialog (char* name,
       sprintf (button_name, "button%d", ++bc);
       button = XtCreateManagedWidget (button_name, commandWidgetClass,
                                      dialog, av, ac);
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
       if (xft_font)
         {
           fill_xft_data (&instance->xft_data[bc], button, xft_font);
diff --git a/lwlib/lwlib-Xlw.c b/lwlib/lwlib-Xlw.c
index bcbc7e9..621d1e7 100644
--- a/lwlib/lwlib-Xlw.c
+++ b/lwlib/lwlib-Xlw.c
@@ -1,7 +1,7 @@
 /* The lwlib interface to "xlwmenu" menus.
 
 Copyright (C) 1992 Lucid, Inc.
-Copyright (C) 1994, 2000-2018 Free Software Foundation, Inc.
+Copyright (C) 1994, 2000-2019 Free Software Foundation, Inc.
 
 This file is part of the Lucid Widget Library.
 
diff --git a/lwlib/lwlib-Xm.c b/lwlib/lwlib-Xm.c
index 43db998..b6d21a6 100644
--- a/lwlib/lwlib-Xm.c
+++ b/lwlib/lwlib-Xm.c
@@ -1,6 +1,6 @@
 /* The lwlib interface to Motif widgets.
 
-Copyright (C) 1994-1997, 1999-2018 Free Software Foundation, Inc.
+Copyright (C) 1994-1997, 1999-2019 Free Software Foundation, Inc.
 Copyright (C) 1992 Lucid, Inc.
 
 This file is part of the Lucid Widget Library.
diff --git a/lwlib/lwlib-int.h b/lwlib/lwlib-int.h
index 73c9a88..9f788e7 100644
--- a/lwlib/lwlib-int.h
+++ b/lwlib/lwlib-int.h
@@ -1,6 +1,6 @@
 /*
 Copyright (C) 1992 Lucid, Inc.
-Copyright (C) 2000-2018 Free Software Foundation, Inc.
+Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 This file is part of the Lucid Widget Library.
 
@@ -30,9 +30,8 @@ typedef struct _widget_instance
   Widget               widget;
   Widget               parent;
   Boolean              pop_up_p;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   struct widget_xft_data *xft_data;
-  int                   nr_xft_data;
 #endif
   struct _widget_info*         info;
   struct _widget_instance*     next;
diff --git a/lwlib/lwlib-utils.c b/lwlib/lwlib-utils.c
index 5e579d1..2c0a931 100644
--- a/lwlib/lwlib-utils.c
+++ b/lwlib/lwlib-utils.c
@@ -1,7 +1,7 @@
 /* Defines some widget utility functions.
 
 Copyright (C) 1992 Lucid, Inc.
-Copyright (C) 1994, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1994, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of the Lucid Widget Library.
 
@@ -137,3 +137,143 @@ XtWidgetBeingDestroyedP (Widget widget)
 {
   return widget->core.being_destroyed;
 }
+
+#ifdef USE_CAIRO
+/* Xft emulation on cairo.  */
+#include <math.h>
+#include <cairo-ft.h>
+#include <cairo-xlib.h>
+
+XftFont *
+crxft_font_open_name (Display *dpy, int screen, const char *name)
+{
+  XftFont *pub = NULL;
+  FcPattern *pattern = FcNameParse ((FcChar8 *) name);
+  if (pattern)
+    {
+      FcConfigSubstitute (NULL, pattern, FcMatchPattern);
+      double dpi;
+      if (FcPatternGetDouble (pattern, FC_DPI, 0, &dpi) == FcResultNoMatch)
+       {
+         char *v = XGetDefault (dpy, "Xft", FC_DPI);
+         if (v == NULL || sscanf (v, "%lf", &dpi) != 1)
+           dpi = ((DisplayHeight (dpy, screen) * 25.4)
+                  / DisplayHeightMM (dpy, screen));
+         FcPatternAddDouble (pattern, FC_DPI, dpi);
+       }
+      FcDefaultSubstitute (pattern);
+      cairo_font_face_t *font_face
+       = cairo_ft_font_face_create_for_pattern (pattern);
+      if (font_face)
+       {
+         double pixel_size;
+         if ((FcPatternGetDouble (pattern, FC_PIXEL_SIZE, 0, &pixel_size)
+              != FcResultMatch)
+             || pixel_size < 1)
+           pixel_size = 10;
+
+         pub = xmalloc (sizeof (*pub));
+         cairo_matrix_t font_matrix, ctm;
+         cairo_matrix_init_scale (&font_matrix, pixel_size, pixel_size);
+         cairo_matrix_init_identity (&ctm);
+         cairo_font_options_t *options = cairo_font_options_create ();
+         cairo_ft_font_options_substitute (options, pattern);
+         pub->scaled_font = cairo_scaled_font_create (font_face, &font_matrix,
+                                                      &ctm, options);
+         cairo_font_face_destroy (font_face);
+         cairo_font_options_destroy (options);
+
+         cairo_font_extents_t extents;
+         cairo_scaled_font_extents (pub->scaled_font, &extents);
+         pub->ascent = lround (extents.ascent);
+         pub->descent = lround (extents.descent);
+         pub->height = lround (extents.height);
+         pub->max_advance_width = lround (extents.max_x_advance);
+       }
+      FcPatternDestroy (pattern);
+    }
+  return pub;
+}
+
+void
+crxft_font_close (XftFont *pub)
+{
+  cairo_scaled_font_destroy (pub->scaled_font);
+  xfree (pub);
+}
+
+cairo_t *
+crxft_draw_create (Display *dpy, Drawable drawable, Visual *visual)
+{
+  cairo_t *cr = NULL;
+  Window root;
+  int x, y;
+  unsigned int width, height, border_width, depth;
+
+  if (!XGetGeometry (dpy, drawable, &root, &x, &y, &width, &height,
+                    &border_width, &depth))
+    return NULL;
+
+  cairo_surface_t *surface = cairo_xlib_surface_create (dpy, drawable, visual,
+                                                       width, height);
+  if (surface)
+    {
+      cr = cairo_create (surface);
+      cairo_surface_destroy (surface);
+    }
+
+  return cr;
+}
+
+static void
+crxft_set_source_color (cairo_t *cr, const XftColor *color)
+{
+  cairo_set_source_rgba (cr, color->color.red / 65535.0,
+                        color->color.green / 65535.0,
+                        color->color.blue / 65535.0,
+                        color->color.alpha / 65535.0);
+}
+
+void
+crxft_draw_rect (cairo_t *cr, const XftColor *color, int x, int y,
+                unsigned int width, unsigned int height)
+{
+  crxft_set_source_color (cr, color);
+  cairo_rectangle (cr, x, y, width, height);
+  cairo_fill (cr);
+}
+
+void
+crxft_draw_string (cairo_t *cr, const XftColor *color, XftFont *pub,
+                  int x, int y, const FcChar8 *string, int len)
+{
+  char *buf = xmalloc (len + 1);
+  memcpy (buf, string, len);
+  buf[len] = '\0';
+  crxft_set_source_color (cr, color);
+  cairo_set_scaled_font (cr, pub->scaled_font);
+  cairo_move_to (cr, x, y);
+  cairo_show_text (cr, buf);
+  xfree (buf);
+}
+
+void
+crxft_text_extents (XftFont *pub, const FcChar8 *string, int len,
+                   XGlyphInfo *extents)
+{
+  char *buf = xmalloc (len + 1);
+  memcpy (buf, string, len);
+  buf[len] = '\0';
+  cairo_text_extents_t text_extents;
+  cairo_scaled_font_text_extents (pub->scaled_font, buf, &text_extents);
+  xfree (buf);
+  extents->x = ceil (- text_extents.x_bearing);
+  extents->y = ceil (- text_extents.y_bearing);
+  extents->width = (ceil (text_extents.x_bearing + text_extents.width)
+                   + extents->x);
+  extents->height = (ceil (text_extents.y_bearing + text_extents.height)
+                    + extents->y);
+  extents->xOff = lround (text_extents.x_advance);
+  extents->yOff = lround (text_extents.y_advance);
+}
+#endif /* USE_CAIRO */
diff --git a/lwlib/lwlib-utils.h b/lwlib/lwlib-utils.h
index ec3daab..64372f1 100644
--- a/lwlib/lwlib-utils.h
+++ b/lwlib/lwlib-utils.h
@@ -15,4 +15,49 @@ Widget *XtCompositeChildren (Widget, unsigned int *);
 Boolean
 XtWidgetBeingDestroyedP (Widget widget);
 
+#ifdef USE_CAIRO
+
+#include <cairo.h>
+#include <fontconfig/fontconfig.h>
+
+typedef struct {
+  cairo_scaled_font_t *scaled_font;
+  int ascent, descent, height, max_advance_width;
+} XftFont;
+
+typedef cairo_t XftDraw;
+
+typedef struct {
+  unsigned long pixel;
+  struct {unsigned short red, green, blue, alpha;} color;
+} XftColor;
+
+#ifdef HAVE_XRENDER
+#include <X11/extensions/Xrender.h>
+#else
+typedef struct {
+  unsigned short width, height;
+  short x, y, xOff, yOff;
+} XGlyphInfo;
+#endif
+
+#define XftFontOpenName crxft_font_open_name
+extern XftFont *crxft_font_open_name (Display *, int, const char *);
+#define XftFontClose(dpy, pub) crxft_font_close (pub)
+extern void crxft_font_close (XftFont *);
+#define XftDrawCreate(dpy, drawable, visual, colormap) \
+  crxft_draw_create (dpy, drawable, visual)
+extern cairo_t *crxft_draw_create (Display *, Drawable, Visual *);
+#define XftDrawDestroy cairo_destroy
+#define XftDrawRect crxft_draw_rect
+extern void crxft_draw_rect (cairo_t *, const XftColor *, int, int,
+                            unsigned int, unsigned int);
+#define XftDrawStringUtf8 crxft_draw_string
+extern void crxft_draw_string (cairo_t *, const XftColor *, XftFont *,
+                              int, int, const FcChar8 *, int);
+#define XftTextExtentsUtf8(dpy, pub, string, len, extents) \
+  crxft_text_extents (pub, string, len, extents)
+extern void crxft_text_extents (XftFont *, const FcChar8 *, int, XGlyphInfo *);
+
+#endif /* USE_CAIRO */
 #endif /* _LWLIB_UTILS_H_ */
diff --git a/lwlib/lwlib-widget.h b/lwlib/lwlib-widget.h
index 6805d68..4b842d5 100644
--- a/lwlib/lwlib-widget.h
+++ b/lwlib/lwlib-widget.h
@@ -1,6 +1,6 @@
 /*
 Copyright (C) 1992, 1993 Lucid, Inc.
-Copyright (C) 1994, 1999-2018 Free Software Foundation, Inc.
+Copyright (C) 1994, 1999-2019 Free Software Foundation, Inc.
 
 This file is part of the Lucid Widget Library.
 
diff --git a/lwlib/lwlib.c b/lwlib/lwlib.c
index 4bb5e4a..8142d92 100644
--- a/lwlib/lwlib.c
+++ b/lwlib/lwlib.c
@@ -1,7 +1,7 @@
 /* A general interface to the widgets of different toolkits.
 
 Copyright (C) 1992, 1993 Lucid, Inc.
-Copyright (C) 1994-1996, 1999-2018 Free Software Foundation, Inc.
+Copyright (C) 1994-1996, 1999-2019 Free Software Foundation, Inc.
 
 This file is part of the Lucid Widget Library.
 
diff --git a/lwlib/lwlib.h b/lwlib/lwlib.h
index 41d3e01..c0f20ae 100644
--- a/lwlib/lwlib.h
+++ b/lwlib/lwlib.h
@@ -1,6 +1,6 @@
 /*
 Copyright (C) 1992, 1993 Lucid, Inc.
-Copyright (C) 1994, 1999-2018 Free Software Foundation, Inc.
+Copyright (C) 1994, 1999-2019 Free Software Foundation, Inc.
 
 This file is part of the Lucid Widget Library.
 
diff --git a/lwlib/xlwmenu.c b/lwlib/xlwmenu.c
index 20a868d..6292c84 100644
--- a/lwlib/xlwmenu.c
+++ b/lwlib/xlwmenu.c
@@ -1,7 +1,7 @@
 /* Implements a lightweight menubar widget.
 
 Copyright (C) 1992 Lucid, Inc.
-Copyright (C) 1994-1995, 1997, 1999-2018 Free Software Foundation, Inc.
+Copyright (C) 1994-1995, 1997, 1999-2019 Free Software Foundation, Inc.
 
 This file is part of the Lucid Widget Library.
 
@@ -107,7 +107,7 @@ xlwMenuResources[] =
   {XtNfontSet,  XtCFontSet, XtRFontSet, sizeof(XFontSet),
      offset(menu.fontSet), XtRFontSet, NULL},
 #endif
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
 #define DEFAULT_FONTNAME "Sans-10"
 #else
 #define DEFAULT_FONTNAME "XtDefaultFont"
@@ -325,14 +325,14 @@ string_width (XlwMenuWidget mw, char *s)
 {
   XCharStruct xcs;
   int drop;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   if (mw->menu.xft_font)
     {
       XGlyphInfo gi;
       XftTextExtentsUtf8 (XtDisplay (mw), mw->menu.xft_font,
                           (FcChar8 *) s,
                           strlen (s), &gi);
-      return gi.width;
+      return gi.xOff;
     }
 #endif
 #ifdef HAVE_X_I18N
@@ -349,7 +349,7 @@ string_width (XlwMenuWidget mw, char *s)
 
 }
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
 #define MENU_FONT_HEIGHT(mw)                                    \
   ((mw)->menu.xft_font != NULL                                  \
    ? (mw)->menu.xft_font->height                                \
@@ -965,7 +965,7 @@ display_menu_item (XlwMenuWidget mw,
   int width;
   enum menu_separator separator;
   int separator_p = lw_separator_p (val->name, &separator, 0);
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   XftColor *xftfg;
 #endif
 
@@ -1005,7 +1005,7 @@ display_menu_item (XlwMenuWidget mw,
       else
        text_gc = mw->menu.disabled_gc;
       deco_gc = mw->menu.foreground_gc;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
       xftfg = val->enabled ? &mw->menu.xft_fg : &mw->menu.xft_disabled_fg;
 #endif
 
@@ -1032,10 +1032,13 @@ display_menu_item (XlwMenuWidget mw,
            x_offset += ws->button_width;
 
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
           if (ws->xft_draw)
             {
               int draw_y = y + v_spacing + shadow;
+#ifdef USE_CAIRO
+             cairo_surface_mark_dirty (cairo_get_target (ws->xft_draw));
+#endif
               XftDrawStringUtf8 (ws->xft_draw, xftfg,
                                  mw->menu.xft_font,
                                  x_offset, draw_y + font_ascent,
@@ -1078,7 +1081,7 @@ display_menu_item (XlwMenuWidget mw,
                }
              else if (val->key)
                {
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
                   if (ws->xft_draw)
                     {
                       int draw_x = ws->width - ws->max_rest_width
@@ -1119,6 +1122,10 @@ display_menu_item (XlwMenuWidget mw,
              draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height,
                                     True, False);
            }
+#ifdef USE_CAIRO
+         if (ws->xft_draw)
+           cairo_surface_flush (cairo_get_target (ws->xft_draw));
+#endif
 
          if (highlighted_p)
            draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height, False,
@@ -1320,7 +1327,7 @@ make_windows_if_needed (XlwMenuWidget mw, int n)
      XtAddEventHandler (windows [i].w, ExposureMask, False, expose_cb, mw);
      windows [i].window = XtWindow (windows [i].w);
      windows [i].pixmap = None;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
      windows [i].xft_draw = 0;
 #endif
      set_window_type (windows [i].w, mw);
@@ -1411,7 +1418,7 @@ create_pixmap_for_menu (window_state* ws, XlwMenuWidget 
mw)
   ws->pixmap = XCreatePixmap (XtDisplay (ws->w), ws->window,
                               ws->width, ws->height,
                               DefaultDepthOfScreen (XtScreen (ws->w)));
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   if (ws->xft_draw)
     XftDrawDestroy (ws->xft_draw);
   if (mw->menu.xft_font)
@@ -1831,7 +1838,7 @@ release_shadow_gcs (XlwMenuWidget mw)
   XtReleaseGC ((Widget) mw, mw->menu.shadow_bottom_gc);
 }
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
 static XftFont *
 getDefaultXftFont (XlwMenuWidget mw)
 {
@@ -1887,7 +1894,7 @@ XlwMenuInitialize (Widget request, Widget w, ArgList 
args, Cardinal *num_args)
                                   gray_width, gray_height,
                                   (unsigned long)1, (unsigned long)0, 1);
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   if (openXftFont (mw))
     ;
   else
@@ -1933,7 +1940,7 @@ XlwMenuInitialize (Widget request, Widget w, ArgList 
args, Cardinal *num_args)
   mw->menu.windows [0].height = 0;
   mw->menu.windows [0].max_rest_width = 0;
   mw->menu.windows [0].pixmap = None;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   mw->menu.windows [0].xft_draw = 0;
 #endif
   size_menu (mw, 0);
@@ -1981,7 +1988,7 @@ XlwMenuRealize (Widget w, Mask *valueMask, 
XSetWindowAttributes *attributes)
   set_window_type (mw->menu.windows [0].w, mw);
   create_pixmap_for_menu (&mw->menu.windows [0], mw);
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   if (mw->menu.xft_font)
     {
       XColor colors[3];
@@ -2078,7 +2085,7 @@ XlwMenuDestroy (Widget w)
   if (mw->menu.font)
     XFreeFont (XtDisplay (mw), mw->menu.font);
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   if (mw->menu.windows [0].xft_draw)
     XftDrawDestroy (mw->menu.windows [0].xft_draw);
   if (mw->menu.xft_font)
@@ -2092,7 +2099,7 @@ XlwMenuDestroy (Widget w)
     {
       if (mw->menu.windows [i].pixmap != None)
         XFreePixmap (XtDisplay (mw), mw->menu.windows [i].pixmap);
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
       if (mw->menu.windows [i].xft_draw)
         XftDrawDestroy (mw->menu.windows [i].xft_draw);
 #endif
@@ -2102,7 +2109,7 @@ XlwMenuDestroy (Widget w)
     XtFree ((char *) mw->menu.windows);
 }
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
 static int
 fontname_changed (XlwMenuWidget newmw,
                   XlwMenuWidget oldmw)
@@ -2134,7 +2141,7 @@ XlwMenuSetValues (Widget current, Widget request, Widget 
new,
 
   if (newmw->core.background_pixel != oldmw->core.background_pixel
       || newmw->menu.foreground != oldmw->menu.foreground
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
       || fontname_changed (newmw, oldmw)
 #endif
 #ifdef HAVE_X_I18N
@@ -2170,7 +2177,7 @@ XlwMenuSetValues (Widget current, Widget request, Widget 
new,
          }
     }
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   if (fontname_changed (newmw, oldmw))
     {
       int i;
diff --git a/lwlib/xlwmenu.h b/lwlib/xlwmenu.h
index a5cea0c..c37c83a 100644
--- a/lwlib/xlwmenu.h
+++ b/lwlib/xlwmenu.h
@@ -1,6 +1,6 @@
 /* Interface of a lightweight menubar widget.
 
-Copyright (C) 2002-2018 Free Software Foundation, Inc.
+Copyright (C) 2002-2019 Free Software Foundation, Inc.
 Copyright (C) 1992 Lucid, Inc.
 
 This file is part of the Lucid Widget Library.
diff --git a/lwlib/xlwmenuP.h b/lwlib/xlwmenuP.h
index 4f35d60..2a05d99 100644
--- a/lwlib/xlwmenuP.h
+++ b/lwlib/xlwmenuP.h
@@ -1,6 +1,6 @@
 /* Internals of a lightweight menubar widget.
 
-Copyright (C) 2002-2018 Free Software Foundation, Inc.
+Copyright (C) 2002-2019 Free Software Foundation, Inc.
 Copyright (C) 1992 Lucid, Inc.
 
 This file is part of the Lucid Widget Library.
@@ -23,9 +23,13 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #include "xlwmenu.h"
 #include <X11/CoreP.h>
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
+#ifdef USE_CAIRO
+#include "lwlib-utils.h"
+#else  /* HAVE_XFT */
 #include <X11/Xft/Xft.h>
 #endif
+#endif
 
 /* Elements in the stack arrays. */
 typedef struct _window_state
@@ -42,7 +46,7 @@ typedef struct _window_state
 
   /* Width of toggle buttons or radio buttons.  */
   Dimension     button_width;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   XftDraw*      xft_draw;
 #endif
 } window_state;
@@ -56,7 +60,7 @@ typedef struct _XlwMenu_part
   XFontSet     fontSet;
   XFontSetExtents *font_extents;
 #endif
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   int           default_face;
   XftFont*      xft_font;
   XftColor      xft_fg, xft_bg, xft_disabled_fg;
diff --git a/m4/00gnulib.m4 b/m4/00gnulib.m4
index bd24796..e3e0fb6 100644
--- a/m4/00gnulib.m4
+++ b/m4/00gnulib.m4
@@ -1,5 +1,5 @@
 # 00gnulib.m4 serial 3
-dnl Copyright (C) 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/__inline.m4 b/m4/__inline.m4
index 3d0c479..e1aa310 100644
--- a/m4/__inline.m4
+++ b/m4/__inline.m4
@@ -1,5 +1,5 @@
 # Test for __inline keyword
-dnl Copyright 2017-2018 Free Software Foundation, Inc.
+dnl Copyright 2017-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/absolute-header.m4 b/m4/absolute-header.m4
index 4e67e5f..a8f2cba 100644
--- a/m4/absolute-header.m4
+++ b/m4/absolute-header.m4
@@ -1,5 +1,5 @@
 # absolute-header.m4 serial 16
-dnl Copyright (C) 2006-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2006-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/acl.m4 b/m4/acl.m4
index b64aa84..5234a80 100644
--- a/m4/acl.m4
+++ b/m4/acl.m4
@@ -1,7 +1,7 @@
 # acl.m4 - check for access control list (ACL) primitives
 # serial 23
 
-# Copyright (C) 2002, 2004-2018 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2004-2019 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
diff --git a/m4/alloca.m4 b/m4/alloca.m4
index b9d94e8..29bd289 100644
--- a/m4/alloca.m4
+++ b/m4/alloca.m4
@@ -1,5 +1,5 @@
-# alloca.m4 serial 14
-dnl Copyright (C) 2002-2004, 2006-2007, 2009-2018 Free Software Foundation,
+# alloca.m4 serial 15
+dnl Copyright (C) 2002-2004, 2006-2007, 2009-2019 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -37,6 +37,13 @@ AC_DEFUN([gl_FUNC_ALLOCA],
   fi
   AC_SUBST([ALLOCA_H])
   AM_CONDITIONAL([GL_GENERATE_ALLOCA_H], [test -n "$ALLOCA_H"])
+
+  if test $ac_cv_working_alloca_h = yes; then
+    HAVE_ALLOCA_H=1
+  else
+    HAVE_ALLOCA_H=0
+  fi
+  AC_SUBST([HAVE_ALLOCA_H])
 ])
 
 # Prerequisites of lib/alloca.c.
diff --git a/m4/builtin-expect.m4 b/m4/builtin-expect.m4
index a1eaf96..b65fbf8 100644
--- a/m4/builtin-expect.m4
+++ b/m4/builtin-expect.m4
@@ -1,6 +1,6 @@
 dnl Check for __builtin_expect.
 
-dnl Copyright 2016-2018 Free Software Foundation, Inc.
+dnl Copyright 2016-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/byteswap.m4 b/m4/byteswap.m4
index c64238f..05fc6cd 100644
--- a/m4/byteswap.m4
+++ b/m4/byteswap.m4
@@ -1,5 +1,5 @@
 # byteswap.m4 serial 4
-dnl Copyright (C) 2005, 2007, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2005, 2007, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/c-strtod.m4 b/m4/c-strtod.m4
deleted file mode 100644
index 9282cee..0000000
--- a/m4/c-strtod.m4
+++ /dev/null
@@ -1,76 +0,0 @@
-# c-strtod.m4 serial 16
-
-# Copyright (C) 2004-2006, 2009-2018 Free Software Foundation, Inc.
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# Written by Paul Eggert.
-
-AC_DEFUN([gl_C99_STRTOLD],
-[
-  AC_CACHE_CHECK([whether strtold conforms to C99],
-    [gl_cv_func_c99_strtold],
-    [AC_LINK_IFELSE(
-       [AC_LANG_PROGRAM(
-          [[/* On HP-UX before 11.23, strtold returns a struct instead of
-                long double.  Reject implementations like that, by requiring
-                compatibility with the C99 prototype.  */
-             #include <stdlib.h>
-             static long double (*p) (char const *, char **) = strtold;
-             static long double
-             test (char const *nptr, char **endptr)
-             {
-               long double r;
-               r = strtold (nptr, endptr);
-               return r;
-             }]],
-           [[return test ("1.0", NULL) != 1 || p ("1.0", NULL) != 1;]])],
-       [gl_cv_func_c99_strtold=yes],
-       [gl_cv_func_c99_strtold=no])])
-  if test $gl_cv_func_c99_strtold = yes; then
-    AC_DEFINE([HAVE_C99_STRTOLD], [1], [Define to 1 if strtold conforms to 
C99.])
-  fi
-])
-
-dnl Prerequisites of lib/c-strtod.c.
-AC_DEFUN([gl_C_STRTOD],
-[
-  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
-
-  AC_CHECK_HEADERS_ONCE([xlocale.h])
-  dnl We can't use AC_CHECK_FUNC here, because strtod_l() is defined as a
-  dnl static inline function when compiling for Android 7.1 or older.
-  AC_CACHE_CHECK([for strtod_l], [gl_cv_func_strtod_l],
-    [AC_LINK_IFELSE(
-       [AC_LANG_PROGRAM(
-          [[#include <stdlib.h>
-            #include <locale.h>
-            #if HAVE_XLOCALE_H
-            # include <xlocale.h>
-            #endif
-            locale_t loc;
-          ]],
-          [[char *end;
-            return strtod_l("0",&end,loc) < 0.0;
-          ]])
-       ],
-       [gl_cv_func_strtod_l=yes],
-       [gl_cv_func_strtod_l=no])
-    ])
-  if test $gl_cv_func_strtod_l = yes; then
-    HAVE_STRTOD_L=1
-  else
-    HAVE_STRTOD_L=0
-  fi
-  AC_DEFINE_UNQUOTED([HAVE_STRTOD_L], [$HAVE_STRTOD_L],
-    [Define to 1 if the system has the 'strtod_l' function.])
-])
-
-dnl Prerequisites of lib/c-strtold.c.
-AC_DEFUN([gl_C_STRTOLD],
-[
-  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
-  AC_REQUIRE([gl_C99_STRTOLD])
-  AC_CHECK_FUNCS([strtold_l])
-])
diff --git a/m4/clock_time.m4 b/m4/clock_time.m4
index 47791f9..8f7a7fc 100644
--- a/m4/clock_time.m4
+++ b/m4/clock_time.m4
@@ -1,5 +1,5 @@
 # clock_time.m4 serial 10
-dnl Copyright (C) 2002-2006, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2006, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/close-stream.m4 b/m4/close-stream.m4
index c9bf62e..5d31221 100644
--- a/m4/close-stream.m4
+++ b/m4/close-stream.m4
@@ -1,5 +1,5 @@
 #serial 4
-dnl Copyright (C) 2006-2007, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2006-2007, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/count-leading-zeros.m4 b/m4/count-leading-zeros.m4
index 99ffdb2..efe31f9 100644
--- a/m4/count-leading-zeros.m4
+++ b/m4/count-leading-zeros.m4
@@ -1,5 +1,5 @@
 # count-leading-zeros.m4 serial 2
-dnl Copyright (C) 2012-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2012-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/count-one-bits.m4 b/m4/count-one-bits.m4
index dead235..b4721b5 100644
--- a/m4/count-one-bits.m4
+++ b/m4/count-one-bits.m4
@@ -1,5 +1,5 @@
 # count-one-bits.m4 serial 3
-dnl Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/count-trailing-zeros.m4 b/m4/count-trailing-zeros.m4
index 2bb9767..94a8f7f 100644
--- a/m4/count-trailing-zeros.m4
+++ b/m4/count-trailing-zeros.m4
@@ -1,5 +1,5 @@
 # count-trailing-zeros.m4
-dnl Copyright (C) 2013-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2013-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/d-type.m4 b/m4/d-type.m4
index ab6463d..4ca56d6 100644
--- a/m4/d-type.m4
+++ b/m4/d-type.m4
@@ -5,7 +5,7 @@ dnl
 dnl Check whether struct dirent has a member named d_type.
 dnl
 
-# Copyright (C) 1997, 1999-2004, 2006, 2009-2018 Free Software Foundation, Inc.
+# Copyright (C) 1997, 1999-2004, 2006, 2009-2019 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
diff --git a/m4/dirent_h.m4 b/m4/dirent_h.m4
index b054a92..732aa55 100644
--- a/m4/dirent_h.m4
+++ b/m4/dirent_h.m4
@@ -1,5 +1,5 @@
 # dirent_h.m4 serial 16
-dnl Copyright (C) 2008-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2008-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/dirfd.m4 b/m4/dirfd.m4
index 48589b9..5c75869 100644
--- a/m4/dirfd.m4
+++ b/m4/dirfd.m4
@@ -2,7 +2,7 @@
 
 dnl Find out how to get the file descriptor associated with an open DIR*.
 
-# Copyright (C) 2001-2006, 2008-2018 Free Software Foundation, Inc.
+# Copyright (C) 2001-2006, 2008-2019 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
diff --git a/m4/dup2.m4 b/m4/dup2.m4
index c785d37..b314247 100644
--- a/m4/dup2.m4
+++ b/m4/dup2.m4
@@ -1,5 +1,5 @@
 #serial 25
-dnl Copyright (C) 2002, 2005, 2007, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2005, 2007, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/eealloc.m4 b/m4/eealloc.m4
index a5a4e26..2a4b120 100644
--- a/m4/eealloc.m4
+++ b/m4/eealloc.m4
@@ -1,5 +1,5 @@
 # eealloc.m4 serial 3
-dnl Copyright (C) 2003, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2003, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/environ.m4 b/m4/environ.m4
index acee536..c1a6fa3 100644
--- a/m4/environ.m4
+++ b/m4/environ.m4
@@ -1,5 +1,5 @@
 # environ.m4 serial 7
-dnl Copyright (C) 2001-2004, 2006-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2001-2004, 2006-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/errno_h.m4 b/m4/errno_h.m4
index e1ae295..2388854 100644
--- a/m4/errno_h.m4
+++ b/m4/errno_h.m4
@@ -1,5 +1,5 @@
 # errno_h.m4 serial 13
-dnl Copyright (C) 2004, 2006, 2008-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2004, 2006, 2008-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/euidaccess.m4 b/m4/euidaccess.m4
index 8a56282..8e840e6 100644
--- a/m4/euidaccess.m4
+++ b/m4/euidaccess.m4
@@ -1,5 +1,5 @@
 # euidaccess.m4 serial 15
-dnl Copyright (C) 2002-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/execinfo.m4 b/m4/execinfo.m4
index c39231d..b291c0a 100644
--- a/m4/execinfo.m4
+++ b/m4/execinfo.m4
@@ -1,6 +1,6 @@
 # Check for GNU-style execinfo.h.
 
-dnl Copyright 2012-2018 Free Software Foundation, Inc.
+dnl Copyright 2012-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/explicit_bzero.m4 b/m4/explicit_bzero.m4
index ba0eefe..1357b59 100644
--- a/m4/explicit_bzero.m4
+++ b/m4/explicit_bzero.m4
@@ -1,4 +1,4 @@
-dnl Copyright 2017-2018 Free Software Foundation, Inc.
+dnl Copyright 2017-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/extensions.m4 b/m4/extensions.m4
index 71a854f..fd1ce81 100644
--- a/m4/extensions.m4
+++ b/m4/extensions.m4
@@ -1,7 +1,7 @@
 # serial 18  -*- Autoconf -*-
 # Enable extensions on systems that normally disable them.
 
-# Copyright (C) 2003, 2006-2018 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2006-2019 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
diff --git a/m4/extern-inline.m4 b/m4/extern-inline.m4
index 3661cbd..ec9f221 100644
--- a/m4/extern-inline.m4
+++ b/m4/extern-inline.m4
@@ -1,6 +1,6 @@
 dnl 'extern inline' a la ISO C99.
 
-dnl Copyright 2012-2018 Free Software Foundation, Inc.
+dnl Copyright 2012-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/faccessat.m4 b/m4/faccessat.m4
index eb6df9a..6c7d79b 100644
--- a/m4/faccessat.m4
+++ b/m4/faccessat.m4
@@ -1,7 +1,7 @@
 # serial 8
 # See if we need to provide faccessat replacement.
 
-dnl Copyright (C) 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/fcntl.m4 b/m4/fcntl.m4
index 46b2445..e409e96 100644
--- a/m4/fcntl.m4
+++ b/m4/fcntl.m4
@@ -1,5 +1,5 @@
 # fcntl.m4 serial 9
-dnl Copyright (C) 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/fcntl_h.m4 b/m4/fcntl_h.m4
index 9fd3ab1..a86fdae 100644
--- a/m4/fcntl_h.m4
+++ b/m4/fcntl_h.m4
@@ -1,6 +1,6 @@
 # serial 15
 # Configure fcntl.h.
-dnl Copyright (C) 2006-2007, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2006-2007, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/fdopendir.m4 b/m4/fdopendir.m4
index df44d5e..b2b3b03 100644
--- a/m4/fdopendir.m4
+++ b/m4/fdopendir.m4
@@ -1,7 +1,7 @@
-# serial 10
+# serial 11
 # See if we need to provide fdopendir.
 
-dnl Copyright (C) 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -45,10 +45,12 @@ DIR *fdopendir (int);
          [gl_cv_func_fdopendir_works=yes],
          [gl_cv_func_fdopendir_works=no],
          [case "$host_os" in
-                    # Guess yes on glibc systems.
-            *-gnu*) gl_cv_func_fdopendir_works="guessing yes" ;;
-                    # If we don't know, assume the worst.
-            *)      gl_cv_func_fdopendir_works="guessing no" ;;
+                     # Guess yes on glibc systems.
+            *-gnu*)  gl_cv_func_fdopendir_works="guessing yes" ;;
+                     # Guess yes on musl systems.
+            *-musl*) gl_cv_func_fdopendir_works="guessing yes" ;;
+                     # If we don't know, assume the worst.
+            *)       gl_cv_func_fdopendir_works="guessing no" ;;
           esac
          ])])
     case "$gl_cv_func_fdopendir_works" in
diff --git a/m4/filemode.m4 b/m4/filemode.m4
index dd649a4..c086c68 100644
--- a/m4/filemode.m4
+++ b/m4/filemode.m4
@@ -1,5 +1,5 @@
 # filemode.m4 serial 8
-dnl Copyright (C) 2002, 2005-2006, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2005-2006, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/flexmember.m4 b/m4/flexmember.m4
index db93cf3..1347068 100644
--- a/m4/flexmember.m4
+++ b/m4/flexmember.m4
@@ -1,7 +1,7 @@
 # serial 5
 # Check for flexible array member support.
 
-# Copyright (C) 2006, 2009-2018 Free Software Foundation, Inc.
+# Copyright (C) 2006, 2009-2019 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
diff --git a/m4/fpending.m4 b/m4/fpending.m4
index c897073..402ec40 100644
--- a/m4/fpending.m4
+++ b/m4/fpending.m4
@@ -1,6 +1,6 @@
 # serial 22
 
-# Copyright (C) 2000-2001, 2004-2018 Free Software Foundation, Inc.
+# Copyright (C) 2000-2001, 2004-2019 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
diff --git a/m4/fpieee.m4 b/m4/fpieee.m4
index b58840f..ea1d5da 100644
--- a/m4/fpieee.m4
+++ b/m4/fpieee.m4
@@ -1,5 +1,5 @@
 # fpieee.m4 serial 2  -*- coding: utf-8 -*-
-dnl Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/fstatat.m4 b/m4/fstatat.m4
index ac353bf..489a55a 100644
--- a/m4/fstatat.m4
+++ b/m4/fstatat.m4
@@ -1,5 +1,5 @@
 # fstatat.m4 serial 4
-dnl Copyright (C) 2004-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2004-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/fsusage.m4 b/m4/fsusage.m4
index c3ba439..a283f64 100644
--- a/m4/fsusage.m4
+++ b/m4/fsusage.m4
@@ -1,7 +1,7 @@
 # serial 34
 # Obtaining file system usage information.
 
-# Copyright (C) 1997-1998, 2000-2001, 2003-2018 Free Software Foundation, Inc.
+# Copyright (C) 1997-1998, 2000-2001, 2003-2019 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
diff --git a/m4/fsync.m4 b/m4/fsync.m4
index d7fa8cc..1b94a25 100644
--- a/m4/fsync.m4
+++ b/m4/fsync.m4
@@ -1,5 +1,5 @@
 # fsync.m4 serial 2
-dnl Copyright (C) 2008-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2008-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/getdtablesize.m4 b/m4/getdtablesize.m4
index 4cc1a8f..96aa241 100644
--- a/m4/getdtablesize.m4
+++ b/m4/getdtablesize.m4
@@ -1,5 +1,5 @@
 # getdtablesize.m4 serial 7
-dnl Copyright (C) 2008-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2008-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/getgroups.m4 b/m4/getgroups.m4
index 8cddb6c..c93447b 100644
--- a/m4/getgroups.m4
+++ b/m4/getgroups.m4
@@ -1,9 +1,9 @@
-# serial 21
+# serial 22
 
 dnl From Jim Meyering.
 dnl A wrapper around AC_FUNC_GETGROUPS.
 
-# Copyright (C) 1996-1997, 1999-2004, 2008-2018 Free Software Foundation, Inc.
+# Copyright (C) 1996-1997, 1999-2004, 2008-2019 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -42,6 +42,8 @@ AC_DEFUN([AC_FUNC_GETGROUPS],
          [case "$host_os" in # ((
                            # Guess yes on glibc systems.
             *-gnu* | gnu*) ac_cv_func_getgroups_works="guessing yes" ;;
+                           # Guess yes on musl systems.
+            *-musl*)       ac_cv_func_getgroups_works="guessing yes" ;;
                            # If we don't know, assume the worst.
             *)             ac_cv_func_getgroups_works="guessing no" ;;
           esac
@@ -95,6 +97,8 @@ AC_DEFUN([gl_FUNC_GETGROUPS],
           [case "$host_os" in
                             # Guess yes on glibc systems.
              *-gnu* | gnu*) gl_cv_func_getgroups_works="guessing yes" ;;
+                            # Guess yes on musl systems.
+             *-musl*)       gl_cv_func_getgroups_works="guessing yes" ;;
                             # If we don't know, assume the worst.
              *)             gl_cv_func_getgroups_works="guessing no" ;;
            esac
diff --git a/m4/getloadavg.m4 b/m4/getloadavg.m4
index c9f5a6d..333ced7 100644
--- a/m4/getloadavg.m4
+++ b/m4/getloadavg.m4
@@ -1,6 +1,6 @@
 # Check for getloadavg.
 
-# Copyright (C) 1992-1996, 1999-2000, 2002-2003, 2006, 2008-2018 Free Software
+# Copyright (C) 1992-1996, 1999-2000, 2002-2003, 2006, 2008-2019 Free Software
 # Foundation, Inc.
 
 # This file is free software; the Free Software Foundation
diff --git a/m4/getopt.m4 b/m4/getopt.m4
index 0496250..5991bf8 100644
--- a/m4/getopt.m4
+++ b/m4/getopt.m4
@@ -1,5 +1,5 @@
 # getopt.m4 serial 46
-dnl Copyright (C) 2002-2006, 2008-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2006, 2008-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/gettime.m4 b/m4/gettime.m4
index 671b70d..60d8ea1 100644
--- a/m4/gettime.m4
+++ b/m4/gettime.m4
@@ -1,5 +1,5 @@
 # gettime.m4 serial 9
-dnl Copyright (C) 2002, 2004-2006, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2004-2006, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/gettimeofday.m4 b/m4/gettimeofday.m4
index 198695e..5e2ef6f 100644
--- a/m4/gettimeofday.m4
+++ b/m4/gettimeofday.m4
@@ -1,6 +1,6 @@
-# serial 25
+# serial 26
 
-# Copyright (C) 2001-2003, 2005, 2007, 2009-2018 Free Software Foundation, Inc.
+# Copyright (C) 2001-2003, 2005, 2007, 2009-2019 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -105,6 +105,8 @@ AC_DEFUN([gl_FUNC_GETTIMEOFDAY_CLOBBER],
       case "$host_os" in
                        # Guess all is fine on glibc systems.
         *-gnu* | gnu*) gl_cv_func_gettimeofday_clobber="guessing no" ;;
+                       # Guess all is fine on musl systems.
+        *-musl*)       gl_cv_func_gettimeofday_clobber="guessing no" ;;
                        # Guess no on native Windows.
         mingw*)        gl_cv_func_gettimeofday_clobber="guessing no" ;;
                        # If we don't know, assume the worst.
diff --git a/m4/glibc21.m4 b/m4/glibc21.m4
index 126aa1a..0ab0f23 100644
--- a/m4/glibc21.m4
+++ b/m4/glibc21.m4
@@ -1,5 +1,5 @@
 # glibc21.m4 serial 5
-dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2018 Free Software Foundation,
+dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2019 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index 2b253da..57b94ed 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -1,5 +1,5 @@
-# gnulib-common.m4 serial 41
-dnl Copyright (C) 2007-2018 Free Software Foundation, Inc.
+# gnulib-common.m4 serial 44
+dnl Copyright (C) 2007-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -17,10 +17,13 @@ AC_DEFUN([gl_COMMON_BODY], [
   AH_VERBATIM([_Noreturn],
 [/* The _Noreturn keyword of C11.  */
 #ifndef _Noreturn
-# if 201103 <= (defined __cplusplus ? __cplusplus : 0)
+# if (defined __cplusplus \
+      && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
+          || (defined _MSC_VER && 1900 <= _MSC_VER)))
 #  define _Noreturn [[noreturn]]
-# elif (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \
-        || 4 < __GNUC__ + (7 <= __GNUC_MINOR__))
+# elif ((!defined __cplusplus || defined __clang__) \
+        && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0)  \
+            || 4 < __GNUC__ + (7 <= __GNUC_MINOR__)))
    /* _Noreturn works as-is.  */
 # elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
 #  define _Noreturn __attribute__ ((__noreturn__))
@@ -85,6 +88,33 @@ AC_DEFUN([gl_COMMON_BODY], [
 # define _GL_ATTRIBUTE_MALLOC /* empty */
 #endif
 ])
+  AH_VERBATIM([async_safe],
+[/* The _GL_ASYNC_SAFE marker should be attached to functions that are
+   signal handlers (for signals other than SIGABRT, SIGPIPE) or can be
+   invoked from such signal handlers.  Such functions have some restrictions:
+     * All functions that it calls should be marked _GL_ASYNC_SAFE as well,
+       or should be listed as async-signal-safe in POSIX
+       
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_04>
+       section 2.4.3.  Note that malloc(), sprintf(), and fwrite(), in
+       particular, are NOT async-signal-safe.
+     * All memory locations (variables and struct fields) that these functions
+       access must be marked 'volatile'.  This holds for both read and write
+       accesses.  Otherwise the compiler might optimize away stores to and
+       reads from such locations that occur in the program, depending on its
+       data flow analysis.  For example, when the program contains a loop
+       that is intended to inspect a variable set from within a signal handler
+           while (!signal_occurred)
+             ;
+       the compiler is allowed to transform this into an endless loop if the
+       variable 'signal_occurred' is not declared 'volatile'.
+   Additionally, recall that:
+     * A signal handler should not modify errno (except if it is a handler
+       for a fatal signal and ends by raising the same signal again, thus
+       provoking the termination of the process).  If it invokes a function
+       that may clobber errno, it needs to save and restore the value of
+       errno.  */
+#define _GL_ASYNC_SAFE
+])
   dnl Preparation for running test programs:
   dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not
   dnl to /dev/tty, so they can be redirected to log files.  Such diagnostics
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index d31dd5d..f648b7a 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -1,5 +1,5 @@
 # DO NOT EDIT! GENERATED AUTOMATICALLY!
-# Copyright (C) 2002-2018 Free Software Foundation, Inc.
+# Copyright (C) 2002-2019 Free Software Foundation, Inc.
 #
 # 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
@@ -113,6 +113,7 @@ AC_DEFUN([gl_EARLY],
   # Code from module localtime-buffer:
   # Code from module lstat:
   # Code from module manywarnings:
+  # Code from module memmem-simple:
   # Code from module memrchr:
   # Code from module minmax:
   # Code from module mkostemp:
@@ -195,6 +196,7 @@ AC_DEFUN([gl_INIT],
   gl_source_base='lib'
   gl_FUNC_ACL
   gl_FUNC_ALLOCA
+  gl___BUILTIN_EXPECT
   gl_BYTESWAP
   AC_CHECK_FUNCS_ONCE([readlinkat])
   gl_CLOCK_TIME
@@ -209,7 +211,6 @@ AC_DEFUN([gl_INIT],
   gl_SHA512
   gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE
   gl_DIRENT_H
-  AC_REQUIRE([gl_C99_STRTOLD])
   gl_FUNC_DUP2
   if test $HAVE_DUP2 = 0 || test $REPLACE_DUP2 = 1; then
     AC_LIBOBJ([dup2])
@@ -303,6 +304,11 @@ AC_DEFUN([gl_INIT],
     gl_PREREQ_LSTAT
   fi
   gl_SYS_STAT_MODULE_INDICATOR([lstat])
+  gl_FUNC_MEMMEM_SIMPLE
+  if test $HAVE_MEMMEM = 0 || test $REPLACE_MEMMEM = 1; then
+    AC_LIBOBJ([memmem])
+  fi
+  gl_STRING_MODULE_INDICATOR([memmem])
   gl_FUNC_MEMRCHR
   if test $ac_cv_func_memrchr = no; then
     AC_LIBOBJ([memrchr])
@@ -427,7 +433,6 @@ AC_DEFUN([gl_INIT],
   gl_UTIMENS
   AC_C_VARARRAYS
   gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=false
-  gl_gnulib_enabled_37f71b604aa9c54446783d80f42fe547=false
   gl_gnulib_enabled_cloexec=false
   gl_gnulib_enabled_dirfd=false
   gl_gnulib_enabled_euidaccess=false
@@ -451,13 +456,6 @@ AC_DEFUN([gl_INIT],
       func_gl_gnulib_m4code_open
     fi
   }
-  func_gl_gnulib_m4code_37f71b604aa9c54446783d80f42fe547 ()
-  {
-    if ! $gl_gnulib_enabled_37f71b604aa9c54446783d80f42fe547; then
-      gl___BUILTIN_EXPECT
-      gl_gnulib_enabled_37f71b604aa9c54446783d80f42fe547=true
-    fi
-  }
   func_gl_gnulib_m4code_cloexec ()
   {
     if ! $gl_gnulib_enabled_cloexec; then
@@ -654,9 +652,6 @@ AC_DEFUN([gl_INIT],
     func_gl_gnulib_m4code_03e0aaad4cb89ca757653bd367a6ccb7
   fi
   if test $ac_use_included_regex = yes; then
-    func_gl_gnulib_m4code_37f71b604aa9c54446783d80f42fe547
-  fi
-  if test $ac_use_included_regex = yes; then
     func_gl_gnulib_m4code_21ee726a3540c09237a8e70c0baf7467
   fi
   if { test $HAVE_DECL_STRTOIMAX = 0 || test $REPLACE_STRTOIMAX = 1; } && test 
$ac_cv_type_long_long_int = yes; then
@@ -667,7 +662,6 @@ AC_DEFUN([gl_INIT],
   fi
   m4_pattern_allow([^gl_GNULIB_ENABLED_])
   AM_CONDITIONAL([gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b], 
[$gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b])
-  AM_CONDITIONAL([gl_GNULIB_ENABLED_37f71b604aa9c54446783d80f42fe547], 
[$gl_gnulib_enabled_37f71b604aa9c54446783d80f42fe547])
   AM_CONDITIONAL([gl_GNULIB_ENABLED_cloexec], [$gl_gnulib_enabled_cloexec])
   AM_CONDITIONAL([gl_GNULIB_ENABLED_dirfd], [$gl_gnulib_enabled_dirfd])
   AM_CONDITIONAL([gl_GNULIB_ENABLED_euidaccess], 
[$gl_gnulib_enabled_euidaccess])
@@ -917,6 +911,7 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/lstat.c
   lib/md5.c
   lib/md5.h
+  lib/memmem.c
   lib/memrchr.c
   lib/minmax.h
   lib/mkostemp.c
@@ -960,6 +955,7 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/stdio.in.h
   lib/stdlib.in.h
   lib/stpcpy.c
+  lib/str-two-way.h
   lib/strftime.h
   lib/string.in.h
   lib/strtoimax.c
@@ -999,7 +995,6 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/alloca.m4
   m4/builtin-expect.m4
   m4/byteswap.m4
-  m4/c-strtod.m4
   m4/clock_time.m4
   m4/close-stream.m4
   m4/count-leading-zeros.m4
@@ -1051,6 +1046,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/manywarnings.m4
   m4/mbstate_t.m4
   m4/md5.m4
+  m4/memmem.m4
   m4/memrchr.m4
   m4/minmax.m4
   m4/mkostemp.m4
diff --git a/m4/group-member.m4 b/m4/group-member.m4
index 2a14dcf..77d389d 100644
--- a/m4/group-member.m4
+++ b/m4/group-member.m4
@@ -1,6 +1,6 @@
 # serial 14
 
-# Copyright (C) 1999-2001, 2003-2007, 2009-2018 Free Software Foundation, Inc.
+# Copyright (C) 1999-2001, 2003-2007, 2009-2019 Free Software Foundation, Inc.
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
diff --git a/m4/ieee754-h.m4 b/m4/ieee754-h.m4
index bf7c332..b8b9d5d 100644
--- a/m4/ieee754-h.m4
+++ b/m4/ieee754-h.m4
@@ -1,6 +1,6 @@
 # Configure ieee754-h module
 
-dnl Copyright 2018 Free Software Foundation, Inc.
+dnl Copyright 2018-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/include_next.m4 b/m4/include_next.m4
index a363cb0..86eb2c9 100644
--- a/m4/include_next.m4
+++ b/m4/include_next.m4
@@ -1,5 +1,5 @@
 # include_next.m4 serial 24
-dnl Copyright (C) 2006-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2006-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/inttypes.m4 b/m4/inttypes.m4
index d756f01..c58a1be 100644
--- a/m4/inttypes.m4
+++ b/m4/inttypes.m4
@@ -1,5 +1,5 @@
 # inttypes.m4 serial 27
-dnl Copyright (C) 2006-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2006-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/largefile.m4 b/m4/largefile.m4
index bec7cd1..1938188 100644
--- a/m4/largefile.m4
+++ b/m4/largefile.m4
@@ -1,6 +1,6 @@
 # Enable large files on systems where this is not the default.
 
-# Copyright 1992-1996, 1998-2018 Free Software Foundation, Inc.
+# Copyright 1992-1996, 1998-2019 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
diff --git a/m4/limits-h.m4 b/m4/limits-h.m4
index 3a2cd91..68f724c 100644
--- a/m4/limits-h.m4
+++ b/m4/limits-h.m4
@@ -1,6 +1,6 @@
 dnl Check whether limits.h has needed features.
 
-dnl Copyright 2016-2018 Free Software Foundation, Inc.
+dnl Copyright 2016-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/localtime-buffer.m4 b/m4/localtime-buffer.m4
index 4b3ec57..6d99828 100644
--- a/m4/localtime-buffer.m4
+++ b/m4/localtime-buffer.m4
@@ -1,5 +1,5 @@
 # localtime-buffer.m4 serial 1
-dnl Copyright (C) 2017-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2017-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/longlong.m4 b/m4/longlong.m4
index 582af53..08d0e36 100644
--- a/m4/longlong.m4
+++ b/m4/longlong.m4
@@ -1,5 +1,5 @@
 # longlong.m4 serial 18
-dnl Copyright (C) 1999-2007, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 1999-2007, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/lstat.m4 b/m4/lstat.m4
index 3694e4c..ace1638 100644
--- a/m4/lstat.m4
+++ b/m4/lstat.m4
@@ -1,6 +1,6 @@
 # serial 32
 
-# Copyright (C) 1997-2001, 2003-2018 Free Software Foundation, Inc.
+# Copyright (C) 1997-2001, 2003-2019 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4
index d831ed2..e0488a5 100644
--- a/m4/manywarnings.m4
+++ b/m4/manywarnings.m4
@@ -1,5 +1,5 @@
 # manywarnings.m4 serial 17
-dnl Copyright (C) 2008-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2008-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/mbstate_t.m4 b/m4/mbstate_t.m4
index 004aa0d..f669753 100644
--- a/m4/mbstate_t.m4
+++ b/m4/mbstate_t.m4
@@ -1,5 +1,5 @@
 # mbstate_t.m4 serial 13
-dnl Copyright (C) 2000-2002, 2008-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2000-2002, 2008-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/md5.m4 b/m4/md5.m4
index 5f64f6e..59140f5 100644
--- a/m4/md5.m4
+++ b/m4/md5.m4
@@ -1,5 +1,5 @@
 # md5.m4 serial 14
-dnl Copyright (C) 2002-2006, 2008-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2006, 2008-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/memmem.m4 b/m4/memmem.m4
new file mode 100644
index 0000000..af2d5bb
--- /dev/null
+++ b/m4/memmem.m4
@@ -0,0 +1,154 @@
+# memmem.m4 serial 25
+dnl Copyright (C) 2002-2004, 2007-2019 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Check that memmem is present and functional.
+AC_DEFUN([gl_FUNC_MEMMEM_SIMPLE],
+[
+  dnl Persuade glibc <string.h> to declare memmem().
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+  AC_CHECK_FUNCS([memmem])
+  if test $ac_cv_func_memmem = yes; then
+    HAVE_MEMMEM=1
+  else
+    HAVE_MEMMEM=0
+  fi
+  AC_CHECK_DECLS_ONCE([memmem])
+  if test $ac_cv_have_decl_memmem = no; then
+    HAVE_DECL_MEMMEM=0
+  else
+    dnl Detect https://sourceware.org/bugzilla/show_bug.cgi?id=12092.
+    dnl Also check that we handle empty needles correctly.
+    AC_CACHE_CHECK([whether memmem works],
+      [gl_cv_func_memmem_works_always],
+      [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#include <string.h> /* for memmem */
+#define P "_EF_BF_BD"
+#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P
+#define NEEDLE P P P P P
+]], [[
+    int result = 0;
+    if (memmem (HAYSTACK, strlen (HAYSTACK), NEEDLE, strlen (NEEDLE)))
+      result |= 1;
+    /* Check for empty needle behavior.  */
+    {
+      const char *haystack = "AAA";
+      if (memmem (haystack, 3, NULL, 0) != haystack)
+        result |= 2;
+    }
+    return result;
+    ]])],
+        [gl_cv_func_memmem_works_always=yes],
+        [gl_cv_func_memmem_works_always=no],
+        [dnl glibc 2.9..2.12 and cygwin 1.7.7 have issue #12092 above.
+         dnl Also empty needles work on glibc >= 2.1 and cygwin >= 1.7.0.
+         dnl uClibc is not affected, since it uses different source code.
+         dnl Assume that it works on all other platforms (even if not linear).
+         AC_EGREP_CPP([Lucky user],
+           [
+#ifdef __GNU_LIBRARY__
+ #include <features.h>
+ #if ((__GLIBC__ == 2 && ((__GLIBC_MINOR > 0 && __GLIBC_MINOR__ < 9) \
+                          || __GLIBC_MINOR__ > 12)) \
+      || (__GLIBC__ > 2)) \
+     || defined __UCLIBC__
+  Lucky user
+ #endif
+#elif defined __CYGWIN__
+ #include <cygwin/version.h>
+ #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7)
+  Lucky user
+ #endif
+#else
+  Lucky user
+#endif
+           ],
+           [gl_cv_func_memmem_works_always="guessing yes"],
+           [gl_cv_func_memmem_works_always="guessing no"])
+        ])
+      ])
+    case "$gl_cv_func_memmem_works_always" in
+      *yes) ;;
+      *)
+        REPLACE_MEMMEM=1
+        ;;
+    esac
+  fi
+  gl_PREREQ_MEMMEM
+]) # gl_FUNC_MEMMEM_SIMPLE
+
+dnl Additionally, check that memmem has linear performance characteristics
+AC_DEFUN([gl_FUNC_MEMMEM],
+[
+  AC_REQUIRE([gl_FUNC_MEMMEM_SIMPLE])
+  if test $HAVE_DECL_MEMMEM = 1 && test $REPLACE_MEMMEM = 0; then
+    AC_CACHE_CHECK([whether memmem works in linear time],
+      [gl_cv_func_memmem_works_fast],
+      [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#include <signal.h> /* for signal */
+#include <string.h> /* for memmem */
+#include <stdlib.h> /* for malloc */
+#include <unistd.h> /* for alarm */
+static void quit (int sig) { _exit (sig + 128); }
+]], [[
+    int result = 0;
+    size_t m = 1000000;
+    char *haystack = (char *) malloc (2 * m + 1);
+    char *needle = (char *) malloc (m + 1);
+    /* Failure to compile this test due to missing alarm is okay,
+       since all such platforms (mingw) also lack memmem.  */
+    signal (SIGALRM, quit);
+    alarm (5);
+    /* Check for quadratic performance.  */
+    if (haystack && needle)
+      {
+        memset (haystack, 'A', 2 * m);
+        haystack[2 * m] = 'B';
+        memset (needle, 'A', m);
+        needle[m] = 'B';
+        if (!memmem (haystack, 2 * m + 1, needle, m + 1))
+          result |= 1;
+      }
+    /* Free allocated memory, in case some sanitizer is watching.  */
+    free (haystack);
+    free (needle);
+    return result;
+    ]])],
+        [gl_cv_func_memmem_works_fast=yes], [gl_cv_func_memmem_works_fast=no],
+        [dnl Only glibc >= 2.9 and cygwin > 1.7.0 are known to have a
+         dnl memmem that works in linear time.
+         AC_EGREP_CPP([Lucky user],
+           [
+#include <features.h>
+#ifdef __GNU_LIBRARY__
+ #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 9) || (__GLIBC__ > 2)) \
+     && !defined __UCLIBC__
+  Lucky user
+ #endif
+#endif
+#ifdef __CYGWIN__
+ #include <cygwin/version.h>
+ #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 0)
+  Lucky user
+ #endif
+#endif
+           ],
+           [gl_cv_func_memmem_works_fast="guessing yes"],
+           [gl_cv_func_memmem_works_fast="guessing no"])
+        ])
+      ])
+    case "$gl_cv_func_memmem_works_fast" in
+      *yes) ;;
+      *)
+        REPLACE_MEMMEM=1
+        ;;
+    esac
+  fi
+]) # gl_FUNC_MEMMEM
+
+# Prerequisites of lib/memmem.c.
+AC_DEFUN([gl_PREREQ_MEMMEM], [:])
diff --git a/m4/memrchr.m4 b/m4/memrchr.m4
index a036b39..e907590 100644
--- a/m4/memrchr.m4
+++ b/m4/memrchr.m4
@@ -1,5 +1,5 @@
 # memrchr.m4 serial 10
-dnl Copyright (C) 2002-2003, 2005-2007, 2009-2018 Free Software Foundation,
+dnl Copyright (C) 2002-2003, 2005-2007, 2009-2019 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
diff --git a/m4/minmax.m4 b/m4/minmax.m4
index 5e88508..1e0d30b 100644
--- a/m4/minmax.m4
+++ b/m4/minmax.m4
@@ -1,5 +1,5 @@
 # minmax.m4 serial 4
-dnl Copyright (C) 2005, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2005, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/mkostemp.m4 b/m4/mkostemp.m4
index 245598e..56f566c 100644
--- a/m4/mkostemp.m4
+++ b/m4/mkostemp.m4
@@ -1,5 +1,5 @@
 # mkostemp.m4 serial 2
-dnl Copyright (C) 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/mktime.m4 b/m4/mktime.m4
index 4b3e399..a86e1ee 100644
--- a/m4/mktime.m4
+++ b/m4/mktime.m4
@@ -1,5 +1,5 @@
 # serial 30
-dnl Copyright (C) 2002-2003, 2005-2007, 2009-2018 Free Software Foundation,
+dnl Copyright (C) 2002-2003, 2005-2007, 2009-2019 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
diff --git a/m4/mode_t.m4 b/m4/mode_t.m4
index 83e276c..ba840dc 100644
--- a/m4/mode_t.m4
+++ b/m4/mode_t.m4
@@ -1,5 +1,5 @@
 # mode_t.m4 serial 2
-dnl Copyright (C) 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/multiarch.m4 b/m4/multiarch.m4
index 38a11cc..d48316e 100644
--- a/m4/multiarch.m4
+++ b/m4/multiarch.m4
@@ -1,5 +1,5 @@
 # multiarch.m4 serial 7
-dnl Copyright (C) 2008-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2008-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/nocrash.m4 b/m4/nocrash.m4
index 4914007..4d9f022 100644
--- a/m4/nocrash.m4
+++ b/m4/nocrash.m4
@@ -1,5 +1,5 @@
 # nocrash.m4 serial 5
-dnl Copyright (C) 2005, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2005, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/nstrftime.m4 b/m4/nstrftime.m4
index bbb1f05..546c240 100644
--- a/m4/nstrftime.m4
+++ b/m4/nstrftime.m4
@@ -1,6 +1,6 @@
 # serial 34
 
-# Copyright (C) 1996-1997, 1999-2007, 2009-2018 Free Software Foundation, Inc.
+# Copyright (C) 1996-1997, 1999-2007, 2009-2019 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
diff --git a/m4/off_t.m4 b/m4/off_t.m4
index f4d5787..711a2d4 100644
--- a/m4/off_t.m4
+++ b/m4/off_t.m4
@@ -1,5 +1,5 @@
 # off_t.m4 serial 1
-dnl Copyright (C) 2012-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2012-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/open-cloexec.m4 b/m4/open-cloexec.m4
index a272784..52498d9 100644
--- a/m4/open-cloexec.m4
+++ b/m4/open-cloexec.m4
@@ -1,6 +1,6 @@
 # Test whether O_CLOEXEC is defined.
 
-dnl Copyright 2017-2018 Free Software Foundation, Inc.
+dnl Copyright 2017-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/open.m4 b/m4/open.m4
index 8b3d402..5d73f4d 100644
--- a/m4/open.m4
+++ b/m4/open.m4
@@ -1,5 +1,5 @@
 # open.m4 serial 15
-dnl Copyright (C) 2007-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2007-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/pipe2.m4 b/m4/pipe2.m4
index c081b44..03008eb 100644
--- a/m4/pipe2.m4
+++ b/m4/pipe2.m4
@@ -1,5 +1,5 @@
 # pipe2.m4 serial 2
-dnl Copyright (C) 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/pselect.m4 b/m4/pselect.m4
index 5cd1e04..5c72b69 100644
--- a/m4/pselect.m4
+++ b/m4/pselect.m4
@@ -1,5 +1,5 @@
 # pselect.m4 serial 7
-dnl Copyright (C) 2011-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2011-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/pthread_sigmask.m4 b/m4/pthread_sigmask.m4
index 585b80a..cadc239 100644
--- a/m4/pthread_sigmask.m4
+++ b/m4/pthread_sigmask.m4
@@ -1,5 +1,5 @@
 # pthread_sigmask.m4 serial 16
-dnl Copyright (C) 2011-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2011-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/putenv.m4 b/m4/putenv.m4
index f2a76b2..342ba26 100644
--- a/m4/putenv.m4
+++ b/m4/putenv.m4
@@ -1,5 +1,5 @@
-# putenv.m4 serial 22
-dnl Copyright (C) 2002-2018 Free Software Foundation, Inc.
+# putenv.m4 serial 23
+dnl Copyright (C) 2002-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -36,6 +36,8 @@ AC_DEFUN([gl_FUNC_PUTENV],
              [case "$host_os" in
                                # Guess yes on glibc systems.
                 *-gnu* | gnu*) gl_cv_func_svid_putenv="guessing yes" ;;
+                               # Guess yes on musl systems.
+                *-musl*)       gl_cv_func_svid_putenv="guessing yes" ;;
                                # Guess no on native Windows.
                 mingw*)        gl_cv_func_svid_putenv="guessing no" ;;
                                # If we don't know, assume the worst.
diff --git a/m4/readlink.m4 b/m4/readlink.m4
index 4d0ab48..2d76815 100644
--- a/m4/readlink.m4
+++ b/m4/readlink.m4
@@ -1,5 +1,5 @@
 # readlink.m4 serial 14
-dnl Copyright (C) 2003, 2007, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2003, 2007, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/readlinkat.m4 b/m4/readlinkat.m4
index b3e447c..b63f213 100644
--- a/m4/readlinkat.m4
+++ b/m4/readlinkat.m4
@@ -1,7 +1,7 @@
 # serial 5
 # See if we need to provide readlinkat replacement.
 
-dnl Copyright (C) 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/regex.m4 b/m4/regex.m4
index 055d71b..35119c5 100644
--- a/m4/regex.m4
+++ b/m4/regex.m4
@@ -1,6 +1,6 @@
-# serial 67
+# serial 68
 
-# Copyright (C) 1996-2001, 2003-2018 Free Software Foundation, Inc.
+# Copyright (C) 1996-2001, 2003-2019 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -213,6 +213,17 @@ AC_DEFUN([gl_REGEX],
             if (! REG_STARTEND)
               result |= 64;
 
+            /* Matching with the compiled form of this regexp would provoke
+               an assertion failure prior to glibc-2.28:
+                 regexec.c:1375: pop_fail_stack: Assertion 'num >= 0' failed
+               With glibc-2.28, compilation fails and reports the invalid
+               back reference.  */
+            re_set_syntax (RE_SYNTAX_POSIX_EGREP);
+            memset (&regex, 0, sizeof regex);
+            s = re_compile_pattern ("0|()0|\\1|0", 10, &regex);
+            if (!s || strcmp (s, "Invalid back reference"))
+              result |= 64;
+
 #if 0
             /* It would be nice to reject hosts whose regoff_t values are too
                narrow (including glibc on hosts with 64-bit ptrdiff_t and
diff --git a/m4/sha1.m4 b/m4/sha1.m4
index 99006f7..bb74fc7 100644
--- a/m4/sha1.m4
+++ b/m4/sha1.m4
@@ -1,5 +1,5 @@
 # sha1.m4 serial 12
-dnl Copyright (C) 2002-2006, 2008-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2006, 2008-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/sha256.m4 b/m4/sha256.m4
index cdc656a..929583d 100644
--- a/m4/sha256.m4
+++ b/m4/sha256.m4
@@ -1,5 +1,5 @@
 # sha256.m4 serial 8
-dnl Copyright (C) 2005, 2008-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2005, 2008-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/sha512.m4 b/m4/sha512.m4
index ac5257c..d5f5594 100644
--- a/m4/sha512.m4
+++ b/m4/sha512.m4
@@ -1,5 +1,5 @@
 # sha512.m4 serial 9
-dnl Copyright (C) 2005-2006, 2008-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2005-2006, 2008-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/sig2str.m4 b/m4/sig2str.m4
index b175706..0474d51 100644
--- a/m4/sig2str.m4
+++ b/m4/sig2str.m4
@@ -1,5 +1,5 @@
 # serial 7
-dnl Copyright (C) 2002, 2005-2006, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2005-2006, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/signal_h.m4 b/m4/signal_h.m4
index 394b91d..3acec64 100644
--- a/m4/signal_h.m4
+++ b/m4/signal_h.m4
@@ -1,5 +1,5 @@
 # signal_h.m4 serial 18
-dnl Copyright (C) 2007-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2007-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/socklen.m4 b/m4/socklen.m4
index fa79b07..deb5135 100644
--- a/m4/socklen.m4
+++ b/m4/socklen.m4
@@ -1,5 +1,5 @@
 # socklen.m4 serial 11
-dnl Copyright (C) 2005-2007, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2005-2007, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/ssize_t.m4 b/m4/ssize_t.m4
index 0977f20..38bcee1 100644
--- a/m4/ssize_t.m4
+++ b/m4/ssize_t.m4
@@ -1,5 +1,5 @@
 # ssize_t.m4 serial 5 (gettext-0.18.2)
-dnl Copyright (C) 2001-2003, 2006, 2010-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2001-2003, 2006, 2010-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/st_dm_mode.m4 b/m4/st_dm_mode.m4
index 0fa7afa..283981f 100644
--- a/m4/st_dm_mode.m4
+++ b/m4/st_dm_mode.m4
@@ -1,6 +1,6 @@
 # serial 6
 
-# Copyright (C) 1998-1999, 2001, 2009-2018 Free Software Foundation, Inc.
+# Copyright (C) 1998-1999, 2001, 2009-2019 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
diff --git a/m4/stat-time.m4 b/m4/stat-time.m4
index d0d17ed..1685788 100644
--- a/m4/stat-time.m4
+++ b/m4/stat-time.m4
@@ -1,6 +1,6 @@
 # Checks for stat-related time functions.
 
-# Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009-2018 Free Software
+# Copyright (C) 1998-1999, 2001, 2003, 2005-2007, 2009-2019 Free Software
 # Foundation, Inc.
 
 # This file is free software; the Free Software Foundation
diff --git a/m4/std-gnu11.m4 b/m4/std-gnu11.m4
index bae4ed1..23e7f75 100644
--- a/m4/std-gnu11.m4
+++ b/m4/std-gnu11.m4
@@ -7,7 +7,7 @@
 # or later is installed everywhere a Gnulib program might be developed.
 
 
-# Copyright (C) 2001-2018 Free Software Foundation, Inc.
+# Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 # 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
diff --git a/m4/stdalign.m4 b/m4/stdalign.m4
index c74fe9b..601fd21 100644
--- a/m4/stdalign.m4
+++ b/m4/stdalign.m4
@@ -1,6 +1,6 @@
 # Check for stdalign.h that conforms to C11.
 
-dnl Copyright 2011-2018 Free Software Foundation, Inc.
+dnl Copyright 2011-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/stddef_h.m4 b/m4/stddef_h.m4
index 07b040a..979e3cf 100644
--- a/m4/stddef_h.m4
+++ b/m4/stddef_h.m4
@@ -1,6 +1,6 @@
 dnl A placeholder for <stddef.h>, for platforms that have issues.
 # stddef_h.m4 serial 6
-dnl Copyright (C) 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/stdint.m4 b/m4/stdint.m4
index 81d065f..11d8e8e 100644
--- a/m4/stdint.m4
+++ b/m4/stdint.m4
@@ -1,5 +1,5 @@
 # stdint.m4 serial 53
-dnl Copyright (C) 2001-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2001-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4
index 0debe69..6c9c104 100644
--- a/m4/stdio_h.m4
+++ b/m4/stdio_h.m4
@@ -1,5 +1,5 @@
 # stdio_h.m4 serial 49
-dnl Copyright (C) 2007-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2007-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4
index 49dc5d5..6121602 100644
--- a/m4/stdlib_h.m4
+++ b/m4/stdlib_h.m4
@@ -1,5 +1,5 @@
-# stdlib_h.m4 serial 45
-dnl Copyright (C) 2007-2018 Free Software Foundation, Inc.
+# stdlib_h.m4 serial 48
+dnl Copyright (C) 2007-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -23,10 +23,10 @@ AC_DEFUN([gl_STDLIB_H],
 # include <random.h>
 #endif
     ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt
-    initstate initstate_r mkdtemp mkostemp mkostemps mkstemp mkstemps
+    initstate initstate_r mbtowc mkdtemp mkostemp mkostemps mkstemp mkstemps
     posix_openpt ptsname ptsname_r qsort_r random random_r reallocarray
     realpath rpmatch secure_getenv setenv setstate setstate_r srandom
-    srandom_r strtod strtoll strtoull unlockpt unsetenv])
+    srandom_r strtod strtold strtoll strtoull unlockpt unsetenv])
 ])
 
 AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
@@ -68,6 +68,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   GNULIB_SECURE_GETENV=0; AC_SUBST([GNULIB_SECURE_GETENV])
   GNULIB_SETENV=0;        AC_SUBST([GNULIB_SETENV])
   GNULIB_STRTOD=0;        AC_SUBST([GNULIB_STRTOD])
+  GNULIB_STRTOLD=0;       AC_SUBST([GNULIB_STRTOLD])
   GNULIB_STRTOLL=0;       AC_SUBST([GNULIB_STRTOLL])
   GNULIB_STRTOULL=0;      AC_SUBST([GNULIB_STRTOULL])
   GNULIB_SYSTEM_POSIX=0;  AC_SUBST([GNULIB_SYSTEM_POSIX])
@@ -81,7 +82,9 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   HAVE_DECL_GETLOADAVG=1;    AC_SUBST([HAVE_DECL_GETLOADAVG])
   HAVE_GETSUBOPT=1;          AC_SUBST([HAVE_GETSUBOPT])
   HAVE_GRANTPT=1;            AC_SUBST([HAVE_GRANTPT])
+  HAVE_INITSTATE=1;          AC_SUBST([HAVE_INITSTATE])
   HAVE_DECL_INITSTATE=1;     AC_SUBST([HAVE_DECL_INITSTATE])
+  HAVE_MBTOWC=1;             AC_SUBST([HAVE_MBTOWC])
   HAVE_MKDTEMP=1;            AC_SUBST([HAVE_MKDTEMP])
   HAVE_MKOSTEMP=1;           AC_SUBST([HAVE_MKOSTEMP])
   HAVE_MKOSTEMPS=1;          AC_SUBST([HAVE_MKOSTEMPS])
@@ -100,8 +103,10 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   HAVE_SECURE_GETENV=1;      AC_SUBST([HAVE_SECURE_GETENV])
   HAVE_SETENV=1;             AC_SUBST([HAVE_SETENV])
   HAVE_DECL_SETENV=1;        AC_SUBST([HAVE_DECL_SETENV])
+  HAVE_SETSTATE=1;           AC_SUBST([HAVE_SETSTATE])
   HAVE_DECL_SETSTATE=1;      AC_SUBST([HAVE_DECL_SETSTATE])
   HAVE_STRTOD=1;             AC_SUBST([HAVE_STRTOD])
+  HAVE_STRTOLD=1;            AC_SUBST([HAVE_STRTOLD])
   HAVE_STRTOLL=1;            AC_SUBST([HAVE_STRTOLL])
   HAVE_STRTOULL=1;           AC_SUBST([HAVE_STRTOULL])
   HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA])
@@ -110,6 +115,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   HAVE_DECL_UNSETENV=1;      AC_SUBST([HAVE_DECL_UNSETENV])
   REPLACE_CALLOC=0;          AC_SUBST([REPLACE_CALLOC])
   REPLACE_CANONICALIZE_FILE_NAME=0;  AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME])
+  REPLACE_INITSTATE=0;       AC_SUBST([REPLACE_INITSTATE])
   REPLACE_MALLOC=0;          AC_SUBST([REPLACE_MALLOC])
   REPLACE_MBTOWC=0;          AC_SUBST([REPLACE_MBTOWC])
   REPLACE_MKSTEMP=0;         AC_SUBST([REPLACE_MKSTEMP])
@@ -117,11 +123,14 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   REPLACE_PTSNAME_R=0;       AC_SUBST([REPLACE_PTSNAME_R])
   REPLACE_PUTENV=0;          AC_SUBST([REPLACE_PUTENV])
   REPLACE_QSORT_R=0;         AC_SUBST([REPLACE_QSORT_R])
+  REPLACE_RANDOM=0;          AC_SUBST([REPLACE_RANDOM])
   REPLACE_RANDOM_R=0;        AC_SUBST([REPLACE_RANDOM_R])
   REPLACE_REALLOC=0;         AC_SUBST([REPLACE_REALLOC])
   REPLACE_REALPATH=0;        AC_SUBST([REPLACE_REALPATH])
   REPLACE_SETENV=0;          AC_SUBST([REPLACE_SETENV])
+  REPLACE_SETSTATE=0;        AC_SUBST([REPLACE_SETSTATE])
   REPLACE_STRTOD=0;          AC_SUBST([REPLACE_STRTOD])
+  REPLACE_STRTOLD=0;         AC_SUBST([REPLACE_STRTOLD])
   REPLACE_UNSETENV=0;        AC_SUBST([REPLACE_UNSETENV])
   REPLACE_WCTOMB=0;          AC_SUBST([REPLACE_WCTOMB])
 ])
diff --git a/m4/stpcpy.m4 b/m4/stpcpy.m4
index e431fd8..7af2e81 100644
--- a/m4/stpcpy.m4
+++ b/m4/stpcpy.m4
@@ -1,5 +1,5 @@
 # stpcpy.m4 serial 8
-dnl Copyright (C) 2002, 2007, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2007, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/string_h.m4 b/m4/string_h.m4
index 97c80dc..0c0e3a7 100644
--- a/m4/string_h.m4
+++ b/m4/string_h.m4
@@ -1,6 +1,6 @@
 # Configure a GNU-like replacement for <string.h>.
 
-# Copyright (C) 2007-2018 Free Software Foundation, Inc.
+# Copyright (C) 2007-2019 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
diff --git a/m4/strtoimax.m4 b/m4/strtoimax.m4
index d3259f3..9632279 100644
--- a/m4/strtoimax.m4
+++ b/m4/strtoimax.m4
@@ -1,5 +1,5 @@
 # strtoimax.m4 serial 15
-dnl Copyright (C) 2002-2004, 2006, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2004, 2006, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/strtoll.m4 b/m4/strtoll.m4
index 5f34852..3ba7e22 100644
--- a/m4/strtoll.m4
+++ b/m4/strtoll.m4
@@ -1,5 +1,5 @@
 # strtoll.m4 serial 7
-dnl Copyright (C) 2002, 2004, 2006, 2008-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2004, 2006, 2008-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/symlink.m4 b/m4/symlink.m4
index afaa941..508e94d 100644
--- a/m4/symlink.m4
+++ b/m4/symlink.m4
@@ -1,7 +1,7 @@
 # serial 8
 # See if we need to provide symlink replacement.
 
-dnl Copyright (C) 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/sys_select_h.m4 b/m4/sys_select_h.m4
index 8e9eff4..918212a 100644
--- a/m4/sys_select_h.m4
+++ b/m4/sys_select_h.m4
@@ -1,5 +1,5 @@
 # sys_select_h.m4 serial 20
-dnl Copyright (C) 2006-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2006-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/sys_socket_h.m4 b/m4/sys_socket_h.m4
index f210378..1ea7b0b 100644
--- a/m4/sys_socket_h.m4
+++ b/m4/sys_socket_h.m4
@@ -1,5 +1,5 @@
 # sys_socket_h.m4 serial 23
-dnl Copyright (C) 2005-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2005-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/sys_stat_h.m4 b/m4/sys_stat_h.m4
index 52f06aa..361ac3f 100644
--- a/m4/sys_stat_h.m4
+++ b/m4/sys_stat_h.m4
@@ -1,5 +1,5 @@
 # sys_stat_h.m4 serial 31   -*- Autoconf -*-
-dnl Copyright (C) 2006-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2006-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/sys_time_h.m4 b/m4/sys_time_h.m4
index d7e9268..3d9233a 100644
--- a/m4/sys_time_h.m4
+++ b/m4/sys_time_h.m4
@@ -1,7 +1,7 @@
 # Configure a replacement for <sys/time.h>.
 # serial 9
 
-# Copyright (C) 2007, 2009-2018 Free Software Foundation, Inc.
+# Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
diff --git a/m4/sys_types_h.m4 b/m4/sys_types_h.m4
index 2debfb0..be06559 100644
--- a/m4/sys_types_h.m4
+++ b/m4/sys_types_h.m4
@@ -1,5 +1,5 @@
 # sys_types_h.m4 serial 9
-dnl Copyright (C) 2011-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2011-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/tempname.m4 b/m4/tempname.m4
index ed813f1..664a632 100644
--- a/m4/tempname.m4
+++ b/m4/tempname.m4
@@ -1,6 +1,6 @@
 #serial 5
 
-# Copyright (C) 2006-2007, 2009-2018 Free Software Foundation, Inc.
+# Copyright (C) 2006-2007, 2009-2019 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
diff --git a/m4/time_h.m4 b/m4/time_h.m4
index ad6f2f5..f08f29b 100644
--- a/m4/time_h.m4
+++ b/m4/time_h.m4
@@ -1,6 +1,6 @@
 # Configure a more-standard replacement for <time.h>.
 
-# Copyright (C) 2000-2001, 2003-2007, 2009-2018 Free Software Foundation, Inc.
+# Copyright (C) 2000-2001, 2003-2007, 2009-2019 Free Software Foundation, Inc.
 
 # serial 11
 
diff --git a/m4/time_r.m4 b/m4/time_r.m4
index daf4bba..5caeca7 100644
--- a/m4/time_r.m4
+++ b/m4/time_r.m4
@@ -1,6 +1,6 @@
 dnl Reentrant time functions: localtime_r, gmtime_r.
 
-dnl Copyright (C) 2003, 2006-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2003, 2006-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/time_rz.m4 b/m4/time_rz.m4
index 5555706..5564559 100644
--- a/m4/time_rz.m4
+++ b/m4/time_rz.m4
@@ -1,6 +1,6 @@
 dnl Time zone functions: tzalloc, localtime_rz, etc.
 
-dnl Copyright (C) 2015-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2015-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/timegm.m4 b/m4/timegm.m4
index 46f599c..d9d40de 100644
--- a/m4/timegm.m4
+++ b/m4/timegm.m4
@@ -1,5 +1,5 @@
 # timegm.m4 serial 12
-dnl Copyright (C) 2003, 2007, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2003, 2007, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/timer_time.m4 b/m4/timer_time.m4
index d5c35c5..2c9b93c 100644
--- a/m4/timer_time.m4
+++ b/m4/timer_time.m4
@@ -1,5 +1,5 @@
 # timer_time.m4 serial 3
-dnl Copyright (C) 2011-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2011-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/timespec.m4 b/m4/timespec.m4
index accabf9..3db9943 100644
--- a/m4/timespec.m4
+++ b/m4/timespec.m4
@@ -1,6 +1,6 @@
 #serial 15
 
-# Copyright (C) 2000-2001, 2003-2007, 2009-2018 Free Software Foundation, Inc.
+# Copyright (C) 2000-2001, 2003-2007, 2009-2019 Free Software Foundation, Inc.
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
diff --git a/m4/tm_gmtoff.m4 b/m4/tm_gmtoff.m4
index 56c48a6..31b841f 100644
--- a/m4/tm_gmtoff.m4
+++ b/m4/tm_gmtoff.m4
@@ -1,5 +1,5 @@
 # tm_gmtoff.m4 serial 3
-dnl Copyright (C) 2002, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4
index 3ba64da..a04055d 100644
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -1,5 +1,5 @@
 # unistd_h.m4 serial 74
-dnl Copyright (C) 2006-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2006-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/unlocked-io.m4 b/m4/unlocked-io.m4
index 7e46367..ea55a1a 100644
--- a/m4/unlocked-io.m4
+++ b/m4/unlocked-io.m4
@@ -1,6 +1,6 @@
 # unlocked-io.m4 serial 15
 
-# Copyright (C) 1998-2006, 2009-2018 Free Software Foundation, Inc.
+# Copyright (C) 1998-2006, 2009-2019 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
diff --git a/m4/utimbuf.m4 b/m4/utimbuf.m4
deleted file mode 100644
index a014351..0000000
--- a/m4/utimbuf.m4
+++ /dev/null
@@ -1,39 +0,0 @@
-# serial 9
-
-# Copyright (C) 1998-2001, 2003-2004, 2007, 2009-2018 Free Software
-# Foundation, Inc.
-#
-# This file is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-dnl From Jim Meyering
-
-dnl Define HAVE_STRUCT_UTIMBUF if 'struct utimbuf' is declared --
-dnl usually in <utime.h>.
-dnl Some systems have utime.h but don't declare the struct anywhere.
-
-AC_DEFUN([gl_CHECK_TYPE_STRUCT_UTIMBUF],
-[
-  AC_CHECK_HEADERS_ONCE([sys/time.h utime.h])
-  AC_CACHE_CHECK([for struct utimbuf], [gl_cv_sys_struct_utimbuf],
-    [AC_COMPILE_IFELSE(
-       [AC_LANG_PROGRAM(
-          [[#if HAVE_SYS_TIME_H
-             #include <sys/time.h>
-            #endif
-            #include <time.h>
-            #ifdef HAVE_UTIME_H
-             #include <utime.h>
-            #endif
-          ]],
-          [[static struct utimbuf x; x.actime = x.modtime;]])],
-       [gl_cv_sys_struct_utimbuf=yes],
-       [gl_cv_sys_struct_utimbuf=no])])
-
-  if test $gl_cv_sys_struct_utimbuf = yes; then
-    AC_DEFINE([HAVE_STRUCT_UTIMBUF], [1],
-      [Define if struct utimbuf is declared -- usually in <utime.h>.
-       Some systems have utime.h but don't declare the struct anywhere. ])
-  fi
-])
diff --git a/m4/utimens.m4 b/m4/utimens.m4
index 9a4db07..dda86b0 100644
--- a/m4/utimens.m4
+++ b/m4/utimens.m4
@@ -1,4 +1,4 @@
-dnl Copyright (C) 2003-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2003-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/utimes.m4 b/m4/utimes.m4
index f62d5f8..5806d8f 100644
--- a/m4/utimes.m4
+++ b/m4/utimes.m4
@@ -1,7 +1,7 @@
 # Detect some bugs in glibc's implementation of utimes.
-# serial 5
+# serial 6
 
-dnl Copyright (C) 2003-2005, 2009-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2003-2005, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -143,9 +143,11 @@ main ()
        [gl_cv_func_working_utimes=yes],
        [gl_cv_func_working_utimes=no],
        [case "$host_os" in
-                  # Guess no on native Windows.
-          mingw*) gl_cv_func_working_utimes="guessing no" ;;
-          *)      gl_cv_func_working_utimes="guessing no" ;;
+                   # Guess yes on musl systems.
+          *-musl*) gl_cv_func_working_utimes="guessing yes" ;;
+                   # Guess no on native Windows.
+          mingw*)  gl_cv_func_working_utimes="guessing no" ;;
+          *)       gl_cv_func_working_utimes="guessing no" ;;
         esac
        ])
     ])
diff --git a/m4/vararrays.m4 b/m4/vararrays.m4
index 17563b5..98a4ef0 100644
--- a/m4/vararrays.m4
+++ b/m4/vararrays.m4
@@ -4,7 +4,7 @@
 
 # From Paul Eggert
 
-# Copyright (C) 2001, 2009-2018 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2009-2019 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
diff --git a/m4/warnings.m4 b/m4/warnings.m4
index 07edda1..235cac6 100644
--- a/m4/warnings.m4
+++ b/m4/warnings.m4
@@ -1,5 +1,5 @@
 # warnings.m4 serial 14
-dnl Copyright (C) 2008-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2008-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/wchar_t.m4 b/m4/wchar_t.m4
index 83bc3d5..5db5815 100644
--- a/m4/wchar_t.m4
+++ b/m4/wchar_t.m4
@@ -1,5 +1,5 @@
 # wchar_t.m4 serial 4 (gettext-0.18.2)
-dnl Copyright (C) 2002-2003, 2008-2018 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2003, 2008-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/make-dist b/make-dist
index bafcae3..7466003 100755
--- a/make-dist
+++ b/make-dist
@@ -1,7 +1,7 @@
 #!/bin/sh
 ### make-dist: create an Emacs distribution tar file from current srcdir
 
-## Copyright (C) 1995, 1997-1998, 2000-2018 Free Software Foundation,
+## Copyright (C) 1995, 1997-1998, 2000-2019 Free Software Foundation,
 ## Inc.
 
 ## This file is part of GNU Emacs.
@@ -222,18 +222,23 @@ if [ $check = yes ]; then
 
   error=no
 
+  temp_el=/tmp/make-dist.tmp.$$
+  temp_elc=$temp_el.1
+  temp_elelc=$temp_el.2
+  temp_elcel=$temp_el.3
+
   ls -1 lisp/[a-zA-Z]*.el lisp/[a-z]*/[a-zA-Z0-9]*.el \
        lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el \
-       lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el > /tmp/el
+       lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.el > $temp_el
 
   ls -1 lisp/[a-zA-Z]*.elc lisp/[a-z]*/[a-zA-Z0-9]*.elc \
        lisp/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc \
-       lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc > /tmp/elc
+       lisp/[a-z]*/[a-z]*/[a-z]*/[a-zA-Z0-9]*.elc > $temp_elc
 
   ## Check for .elc files with no corresponding .el file.
-  sed 's/\.el$/.elc/' /tmp/el > /tmp/elelc
+  sed 's/\.el$/.elc/' $temp_el > $temp_elelc
 
-  bogosities=`comm -13 /tmp/elelc /tmp/elc`
+  bogosities=`comm -13 $temp_elelc $temp_elc`
   if [ x"${bogosities}" != x"" ]; then
     error=yes
     echo "The following .elc files have no corresponding .el files:"
@@ -241,15 +246,15 @@ if [ $check = yes ]; then
   fi
 
   ### Check for .el files with no corresponding .elc file.
-  sed 's/\.elc$/.el/' /tmp/elc > /tmp/elcel
-  losers=`comm -23 /tmp/el /tmp/elcel`
+  sed 's/\.elc$/.el/' $temp_elc > $temp_elcel
+  losers=`comm -23 $temp_el $temp_elcel`
 
   bogosities=
   while read elc; do
       el=`echo $elc | sed 's/c$//'`
       [ -r $el ] || continue
       [ $elc -nt $el ] || bogosities="$bogosities $elc"
-  done < /tmp/elc
+  done < $temp_elc
 
   if [ x"${bogosities}" != x"" ]; then
       error=yes
@@ -257,11 +262,11 @@ if [ $check = yes ]; then
       echo "${bogosities}"
   fi
 
-  rm -f /tmp/el /tmp/elc /tmp/elcel /tmp/elelc
+  rm -f $temp_el*
 
   bogosities=
   for file in $losers; do
-    grep -q "no-byte-compile: t" $file && continue
+    grep -q "^;.*no-byte-compile: t" $file && continue
     case $file in
       site-init.el | site-load.el | site-start.el | default.el) continue ;;
     esac
@@ -278,7 +283,7 @@ if [ $check = yes ]; then
 
   ## This is only a crude check, eg it does not handle .info
   ## files with multiple .texi source files.
-  find doc -name '*.texi' > /tmp/el
+  find doc -name '*.texi' > $temp_el
 
   bogosities=
   while read texi; do
@@ -287,9 +292,9 @@ if [ $check = yes ]; then
       info=info/$info
       [ -r $info ] || continue
       [ $info -nt $texi ] || bogosities="$bogosities $info"
-  done < /tmp/el
+  done < $temp_el
 
-  rm -f /tmp/el
+  rm -f $temp_el
 
   if [ x"${bogosities}" != x"" ]; then
     error=yes
@@ -334,10 +339,6 @@ if [ $update = yes ]; then
   echo "Running autoreconf"
   autoreconf -i -I m4 || { x=$?; echo Autoreconf FAILED! >&2; exit $x; }
 
-  ## Make sure src/stamp-h.in is newer than configure.ac.
-  rm -f src/stamp-h.in
-  echo timestamp > src/stamp-h.in
-
   if [ "$make_info" = yes ] ; then
     echo "Updating Info files"
     make info
@@ -353,11 +354,60 @@ if [ $update = yes ]; then
   $EMACS -batch -f batch-byte-recompile-directory lisp
 fi                              # $update = yes
 
+if [ "$changelog" = yes ] && [ -r .git ]; then
+  top_level_ChangeLog=ChangeLog
+else
+  top_level_ChangeLog=
+fi
+
+# Files to distribute that might not be under version control.
+# Don't distribute site-init.el, site-load.el, or default.el.
+possibly_non_vc_files="
+  $top_level_ChangeLog
+  MANIFEST aclocal.m4 configure
+  admin/charsets/jisx2131-filter
+  src/config.in src/emacs-module.h
+"$(
+  find admin doc etc lisp \
+    \( -name '*.el' -o -name '*.elc' -o -name '*.map' -o -name '*.stamp' \
+       -o -name '*.texi' -o -name '*.tex' -o -name '*.txt' \) \
+    ! -name 'site-init*' ! -name 'site-load*' ! -name 'default*'
+) || exit
+
+if [ $with_info = yes ]; then
+  info_files="info/dir $(echo info/*.info)" || exit
+else
+  info_files=
+fi
+
 echo "Creating staging directory: '${tempparent}'"
 
 mkdir ${tempparent} || exit
 tempdir="${tempparent}/${emacsname}"
 
+manifest=MANIFEST
+
+[ -f $manifest ] || manifest=${tempparent}/MANIFEST
+
+# If Git is in use update the file MANIFEST, which can substitute for
+# 'git ls-files' later (e.g., after extraction from a tarball).
+# Otherwise, rely on the existing MANIFEST, which should be maintained some
+# other way when adding or deleting a distributed file while not using Git.
+# TODO: maybe this should ignore $update, and always update MANIFEST
+# if .git is present.
+if ( [ $update = yes ] || [ ! -f $manifest ] ) && [ -r .git ]; then
+  echo "Updating $manifest"
+  if [ $with_tests = yes ]; then
+    git ls-files > $manifest
+  else
+    git ls-files | grep -v '^test' >$manifest
+  fi || exit
+  printf '%s\n' $possibly_non_vc_files $info_files >>$manifest || exit
+  sort -u -o $manifest $manifest || exit
+fi
+
+<$manifest || exit
+
 ### This trap ensures that the staging directory will be cleaned up even
 ### when the script is interrupted in mid-career.
 if [ "${clean_up}" = yes ]; then
@@ -365,304 +415,66 @@ if [ "${clean_up}" = yes ]; then
 fi
 
 echo "Creating top directory: '${tempdir}'"
-mkdir ${tempdir} || exit
+if [ $verbose = yes ] && (mkdir --verbose ${tempdir}) >/dev/null 2>&1; then
+  mkdir_verbose='mkdir --verbose'
+else
+  mkdir $tempdir || exit
+  mkdir_verbose=mkdir
+fi
+
+# file_to_skip is normally empty to link every file,
+# but it can be 'ChangeLog' if we do not want to link the
+# top-level ChangeLog.
+file_to_skip=
 
-top_level_ChangeLog=
 if [ "$changelog" = yes ]; then
   if test -r .git; then
     ## When making a release or pretest the ChangeLog should already
     ## have been created and edited as needed.  Don't ignore it.
-    if test -r ChangeLog; then
+    if [ -r ChangeLog ] && [ ! -L ChangeLog ]; then
       echo "Using existing top-level ChangeLog"
-      top_level_ChangeLog=ChangeLog
     else
       echo "Making top-level ChangeLog"
       make ChangeLog CHANGELOG=${tempdir}/ChangeLog || \
         { x=$?; echo "make ChangeLog FAILED (try --no-changelog?)" >&2; exit 
$x; }
+      file_to_skip=ChangeLog
     fi
   else
     echo "No repository, so omitting top-level ChangeLog"
   fi
 fi
 
-### We copy in the top-level files before creating the subdirectories in
-### hopes that this will make the top-level files appear first in the
-### tar file; this means that people can start reading the INSTALL and
-### README while the rest of the tar file is still unpacking.  Whoopee.
-echo "Making links to top-level files"
-top_level='
-  INSTALL README BUGS
-  ChangeLog.*[0-9] Makefile.in autogen.sh configure configure.ac
-  config.bat make-dist .dir-locals.el
-  aclocal.m4 CONTRIBUTE
-'
-ln $top_level $top_level_ChangeLog $tempdir || exit
-
 echo "Creating subdirectories"
-for subdir in site-lisp \
-             leim leim/CXTERM-DIC leim/MISC-DIC leim/SKK-DIC \
-             build-aux \
-             src src/bitmaps lib lib-src oldXMenu lwlib \
-             nt nt/inc nt/inc/sys nt/inc/arpa nt/inc/netinet nt/icons \
-             `find etc lisp admin test -type d` \
-             doc doc/emacs doc/misc doc/man doc/lispref doc/lispintro \
-             info m4 modules msdos \
-             nextstep nextstep/templates \
-             nextstep/Cocoa nextstep/Cocoa/Emacs.base \
-             nextstep/Cocoa/Emacs.base/Contents \
-             nextstep/Cocoa/Emacs.base/Contents/Resources \
-             nextstep/GNUstep \
-             nextstep/GNUstep/Emacs.base \
-             nextstep/GNUstep/Emacs.base/Resources
-do
-
-  if [ "$with_tests" != "yes" ]; then
-    case $subdir in
-        test*) continue ;;
-    esac
-  fi
-
-  ## site-lisp for in-place installs (?).
-  [ "$subdir" = "site-lisp" ] || [ -d "$subdir" ] || \
-      echo "WARNING: $subdir not found, making anyway"
-  [ "$verbose" = "yes" ] && echo "  ${tempdir}/${subdir}"
-  mkdir ${tempdir}/${subdir} || exit
-done
-
-echo "Making links to 'lisp' and its subdirectories"
-files=`find lisp \( -name '*.el' -o -name '*.elc' -o -name 'ChangeLog*' \
- -o -name 'README' \)` || exit
+MANIFEST_subdir_sed='
+  $a\
+'$tempdir'/info\
+'$tempdir'/site-lisp
+  s,[^/]*$,,
+  s,/$,,
+  /^$/d
+  s,^,'$tempdir'/,
+'
+tempsubdirs=$(sed "$MANIFEST_subdir_sed" $manifest | sort -u)
+$mkdir_verbose -p $tempsubdirs || exit
 
-### Don't distribute site-init.el, site-load.el, or default.el.
-for file in lisp/Makefile.in $files; do
+echo "Making links to files"
+while read file; do
   case $file in
-    */site-init*|*/site-load*|*/default*) continue ;;
-  esac
-  ln $file $tempdir/$file || exit
-done
-
-echo "Making links to 'leim' and its subdirectories"
-(cd leim &&
- ln ChangeLog.*[0-9] README ../${tempdir}/leim &&
- ln CXTERM-DIC/README CXTERM-DIC/*.tit ../${tempdir}/leim/CXTERM-DIC &&
- ln SKK-DIC/README SKK-DIC/SKK-JISYO.L ../${tempdir}/leim/SKK-DIC &&
- ln MISC-DIC/README MISC-DIC/*.* ../${tempdir}/leim/MISC-DIC &&
- ln Makefile.in ../${tempdir}/leim/Makefile.in &&
- ln leim-ext.el ../${tempdir}/leim/leim-ext.el &&
-:) || exit
-
-## FIXME Can we not just use the "find -type f" method for this one?
-echo "Making links to 'build-aux'"
-(cd build-aux &&
- ln config.guess config.sub msys-to-w32 ../${tempdir}/build-aux &&
- ln gitlog-to-changelog gitlog-to-emacslog ../${tempdir}/build-aux &&
- ln install-sh move-if-change ../${tempdir}/build-aux &&
- ln update-copyright update-subdirs ../${tempdir}/build-aux &&
- ln dir_top make-info-dir ../${tempdir}/build-aux &&
-:) || exit
-
-echo "Making links to 'src'"
-### Don't distribute the configured versions of
-### config.in, paths.in, buildobj.h, or Makefile.in.
-(cd src &&
- ln [a-zA-Z]*.[chm] ../${tempdir}/src &&
- ln [a-zA-Z]*.in ../${tempdir}/src &&
- ln deps.mk ../${tempdir}/src &&
- ln README ChangeLog.*[0-9] ../${tempdir}/src &&
- ln .gdbinit .dbxinit ../${tempdir}/src &&
- cd ../${tempdir}/src &&
- rm -f globals.h config.h epaths.h Makefile buildobj.h &&
-:) || exit
-
-echo "Making links to 'src/bitmaps'"
-(cd src/bitmaps &&
- ln README *.xbm ../../${tempdir}/src/bitmaps &&
-:) || exit
-
-echo "Making links to 'lib'"
-(cd lib &&
- ln [a-zA-Z_]*.[ch] ../${tempdir}/lib &&
- ln gnulib.mk.in Makefile.in ../${tempdir}/lib &&
- cd ../${tempdir}/lib &&
- script='/[*]/d; s/\.in\.h$/.h/' &&
- rm -f `ls *.in.h | sed "$script"` &&
-:) || exit
-
-echo "Making links to 'lib-src'"
-(cd lib-src &&
- ln [a-zA-Z]*.[ch] ../${tempdir}/lib-src &&
- ln ChangeLog.*[0-9] Makefile.in README ../${tempdir}/lib-src &&
- ln rcs2log ../${tempdir}/lib-src &&
-:) || exit
-
-echo "Making links to 'm4'"
-(cd m4 &&
- ln *.m4 ../${tempdir}/m4 &&
-:) || exit
-
-echo "Making links to 'modules'"
-(cd modules &&
- ln *.py ../${tempdir}/modules &&
-:) || exit
-
-echo "Making links to 'nt'"
-(cd nt &&
- ln emacs-x86.manifest emacs-x64.manifest ../${tempdir}/nt &&
- ln [a-z]*.bat [a-z]*.[ch] ../${tempdir}/nt &&
- ln *.in gnulib-cfg.mk ../${tempdir}/nt &&
- ln mingw-cfg.site epaths.nt INSTALL.W64 ../${tempdir}/nt &&
- ln ChangeLog.*[0-9] INSTALL README README.W32 ../${tempdir}/nt &&
-:) || exit
-
-echo "Making links to 'nt/inc' and its subdirectories"
-for f in `find nt/inc -type f -name '[a-z]*.h'`; do
-  ln $f $tempdir/$f || exit
-done
-
-echo "Making links to 'nt/icons'"
-(cd nt/icons &&
- ln README [a-z]*.ico ../../${tempdir}/nt/icons &&
- ln [a-z]*.cur ../../${tempdir}/nt/icons &&
-:) || exit
-
-echo "Making links to 'msdos'"
-(cd msdos &&
- ln ChangeLog.*[0-9] INSTALL README emacs.ico emacs.pif ../${tempdir}/msdos &&
- ln depfiles.bat inttypes.h ../${tempdir}/msdos &&
- ln mainmake.v2 sed*.inp ../${tempdir}/msdos &&
-:) || exit
-
-echo "Making links to 'nextstep'"
-(cd nextstep &&
- ln ChangeLog.*[0-9] README INSTALL Makefile.in ../${tempdir}/nextstep &&
-:) || exit
-
-echo "Making links to 'nextstep/templates'"
-(cd nextstep/templates &&
- ln Emacs.desktop.in Info-gnustep.plist.in Info.plist.in InfoPlist.strings.in \
-   ../../${tempdir}/nextstep/templates &&
-:) || exit
-
-echo "Making links to 'nextstep/Cocoa/Emacs.base/Contents'"
-(cd nextstep/Cocoa/Emacs.base/Contents &&
- ln PkgInfo ../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents &&
-:) || exit
-
-echo "Making links to 'nextstep/Cocoa/Emacs.base/Contents/Resources'"
-(cd nextstep/Cocoa/Emacs.base/Contents/Resources &&
- ln Credits.html *.icns \
-   ../../../../../${tempdir}/nextstep/Cocoa/Emacs.base/Contents/Resources &&
-:) || exit
-
-echo "Making links to 'nextstep/GNUstep/Emacs.base/Resources'"
-(cd nextstep/GNUstep/Emacs.base/Resources &&
- ln README emacs.tiff \
-   ../../../../${tempdir}/nextstep/GNUstep/Emacs.base/Resources &&
-:) || exit
-
-echo "Making links to 'oldXMenu'"
-(cd oldXMenu &&
- ln *.[ch] *.in *.mk ../${tempdir}/oldXMenu &&
- ln README ChangeLog.*[0-9] ../${tempdir}/oldXMenu &&
-:) || exit
-
-echo "Making links to 'lwlib'"
-(cd lwlib &&
- ln *.[ch] *.in *.mk ../${tempdir}/lwlib &&
- ln README ChangeLog.*[0-9] ../${tempdir}/lwlib &&
-:) || exit
-
-## It is important to distribute admin/ because it contains sources
-## for generated lisp/international/uni-*.el files.
-echo "Making links to 'admin' and its subdirectories"
-for f in `find admin -type f`; do
-  case $f in
-    */Makefile) [ -f $f.in ] && continue ;;
-  esac
-  ln $f $tempdir/$f || exit
-done
-
-if [ "$with_tests" = "yes" ]; then
-  echo "Making links to 'test' and its subdirectories"
-  for f in `find test -type f ! -name '*.log' ! -name a.out \
-             ! -name '*.so' ! -name '*.dll' ! -name '*.o'
-  `; do
-    case $f in
-        */Makefile) [ -f $f.in ] && continue ;;
-    esac
-    ln $f $tempdir/$f || exit
-  done
-fi
-
-echo "Making links to 'etc' and its subdirectories"
-for f in `find etc -type f`; do
-  case $f in
-    etc/DOC*|etc/*.pyc) continue ;;
-    ## Arguably we should not exclude *.ps.
-    etc/refcards/*.aux|etc/refcards/*.dvi|etc/refcards/*.log|etc/refcards/*.ps)
-      continue ;;
+    MANIFEST) ln $manifest $tempdir/MANIFEST || exit ;;
+    $file_to_skip) continue ;;
+    *) ln $file $tempdir/$file || exit ;;
   esac
-  ln $f $tempdir/$f || exit
-done
-
-if [ "$with_info" = "yes" ]; then
-  echo "Making links to 'info'"
-  ln `find info -type f -print` ${tempdir}/info || exit
-fi
-
-echo "Making links to 'doc/emacs'"
-(cd doc/emacs &&
- ln *.texi *.in ChangeLog.*[0-9] ../../${tempdir}/doc/emacs &&
-:) || exit
-
-echo "Making links to 'doc/misc'"
-(cd doc/misc &&
- ln *.texi *.tex *.in gnus-news.el ChangeLog.*[0-9] \
-   ../../${tempdir}/doc/misc &&
-:) || exit
-
-echo "Making links to 'doc/lispref'"
-(cd doc/lispref &&
- ln *.texi *.in README ChangeLog.*[0-9] ../../${tempdir}/doc/lispref &&
- ln spellfile ../../${tempdir}/doc/lispref &&
- ln two-volume.make two-volume-cross-refs.txt ../../${tempdir}/doc/lispref &&
-:) || exit
-
-echo "Making links to 'doc/lispintro'"
-(cd doc/lispintro &&
- ln *.texi *.in *.eps *.pdf ../../${tempdir}/doc/lispintro &&
- ln README ChangeLog.*[0-9] ../../${tempdir}/doc/lispintro &&
- cd ../../${tempdir}/doc/lispintro &&
-:) || exit
-
-echo "Making links to 'doc/man'"
-(cd doc/man &&
- ln *.*[0-9] *.in ../../${tempdir}/doc/man &&
- cd ../../${tempdir}/doc/man &&
- rm -f emacs.1 &&
-:) || exit
-
-### It would be nice if they could all be symlinks to top-level copy, but
-### you're not supposed to have any symlinks in distribution tar files.
-echo "Making sure copying notices are all copies of 'COPYING'"
-for subdir in . etc leim lib lib-src lisp lwlib msdos nt src; do
-  rm -f ${tempdir}/${subdir}/COPYING || exit
-  cp COPYING ${tempdir}/${subdir} || exit
-done
+done <$manifest
 
 if [ "${newer}" ]; then
   printf '%s\n' "Removing files older than $newer"
   ## We remove .elc files unconditionally, on the theory that anyone picking
   ## up an incremental distribution already has a running Emacs to byte-compile
   ## them with.
-  find ${tempparent} \( -name '*.elc' -o ! -newer ${newer} \) \
+  find ${tempdir} \( -name '*.elc' -o ! -newer ${newer} \) \
     -exec rm -f {} \; || exit
 fi
 
-## Don't distribute backups, autosaves, etc.
-echo "Removing unwanted files"
-find ${tempparent} \( -name '*~' -o -name '#*#' -o -name '.*ignore' -o -name 
'=*' -o -name 'TAGS' \) -exec rm -f {} \; || exit
-
 if [ "${make_tar}" = yes ]; then
   echo "Looking for $default_gzip"
   found=0
@@ -685,7 +497,7 @@ if [ "${make_tar}" = yes ]; then
   esac
   echo "Creating tar file"
   taropt='--numeric-owner --owner=0 --group=0 --mode=go+u,go-w'
-  tar --sort=name -cf /dev/null $tempparent/$emacsname/src/lisp.h 2>/tmp/out &&
+  tar --sort=name -cf /dev/null $tempdir/src/lisp.h 2>/dev/null &&
     taropt="$taropt --sort=name"
   [ "$verbose" = "yes" ] && taropt="$taropt --verbose"
 
@@ -693,7 +505,7 @@ if [ "${make_tar}" = yes ]; then
    case $default_gzip in
      cat) tar $taropt -cf - $emacsname;;
      *) if tar $taropt -cf /dev/null --use-compress-program="$default_gzip" \
-              $emacsname/src/lisp.h
+              $emacsname/src/lisp.h > /dev/null 2>&1
        then
          tar $taropt -cf - --use-compress-program="$default_gzip" $emacsname
        else
@@ -704,9 +516,12 @@ if [ "${make_tar}" = yes ]; then
   ) >$emacsname.tar$gzip_extension || exit
 fi
 
+## Why are we deleting the staging directory if clean_up is no?
 if [ "${clean_up}" != yes ]; then
   (cd ${tempparent} && mv ${emacsname} ..) &&
   rm -rf ${tempparent}
 fi
 
-### make-dist ends here
+# Local Variables:
+# sh-basic-offset: 2
+# End:
diff --git a/modules/modhelp.py b/modules/modhelp.py
index f307dd4..e1c5a91 100755
--- a/modules/modhelp.py
+++ b/modules/modhelp.py
@@ -2,7 +2,7 @@
 
 # Module helper script.
 
-# Copyright 2015-2018 Free Software Foundation, Inc.
+# Copyright 2015-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
diff --git a/msdos/ChangeLog.1 b/msdos/ChangeLog.1
index 603f507..fa3477f 100644
--- a/msdos/ChangeLog.1
+++ b/msdos/ChangeLog.1
@@ -1550,7 +1550,7 @@
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 1994-1999, 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 1994-1999, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/msdos/INSTALL b/msdos/INSTALL
index 3707f43..daae992 100644
--- a/msdos/INSTALL
+++ b/msdos/INSTALL
@@ -1,6 +1,6 @@
 GNU Emacs Installation Guide for the DJGPP (a.k.a. MS-DOS) port
 
-Copyright (C) 1992, 1994, 1996-1997, 2000-2018 Free Software Foundation,
+Copyright (C) 1992, 1994, 1996-1997, 2000-2019 Free Software Foundation,
 Inc.
 See the end of the file for license conditions.
 
diff --git a/msdos/README b/msdos/README
index d1c2fda..75ae2c0 100644
--- a/msdos/README
+++ b/msdos/README
@@ -1,4 +1,4 @@
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 
@@ -10,7 +10,7 @@ The files emacs.ico and emacs.pif are for using the DJGPP 
version on
 Windows 3.X.  Since these are binary files, their copyright notice is
 reproduced here:
 
-# Copyright (C) 1993, 2002-2018 Free Software Foundation, Inc.
+# Copyright (C) 1993, 2002-2019 Free Software Foundation, Inc.
 #
 # This file is part of GNU Emacs.
 #
diff --git a/msdos/autogen/Makefile.in b/msdos/autogen/Makefile.in
index dae66e8..5d6ff70 100644
--- a/msdos/autogen/Makefile.in
+++ b/msdos/autogen/Makefile.in
@@ -1,7 +1,7 @@
 # Makefile.in generated by automake 1.11.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2009, 2013-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994-2009, 2013-2019 Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -13,7 +13,7 @@
 
 @SET_MAKE@
 
-# Copyright (C) 2002-2018 Free Software Foundation, Inc.
+# Copyright (C) 2002-2019 Free Software Foundation, Inc.
 #
 # 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
@@ -36,7 +36,7 @@
 # Generated by gnulib-tool.
 # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib 
--m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux 
--avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix 
--avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die 
--avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select 
--avoid=sigprocmask --avoid=sys_types --avoid=threadlib 
--makefile-name=gnulib.mk --conditional-dependencies --no-libtool 
--macro-prefix=gl [...]
 
-# Copyright (C) 2002-2018 Free Software Foundation, Inc.
+# Copyright (C) 2002-2019 Free Software Foundation, Inc.
 #
 # 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
diff --git a/msdos/autogen/config.in b/msdos/autogen/config.in
index 3784897..6a18ff9 100644
--- a/msdos/autogen/config.in
+++ b/msdos/autogen/config.in
@@ -2,7 +2,7 @@
 
 /* GNU Emacs site configuration template file.
 
-Copyright (C) 1988, 1993-1994, 1999-2002, 2004-2018 Free Software
+Copyright (C) 1988, 1993-1994, 1999-2002, 2004-2019 Free Software
 Foundation, Inc.
 
 This file is part of GNU Emacs.
diff --git a/msdos/depfiles.bat b/msdos/depfiles.bat
index 5330f2b..e99c967 100644
--- a/msdos/depfiles.bat
+++ b/msdos/depfiles.bat
@@ -1,7 +1,7 @@
 @echo off
 rem   ----------------------------------------------------------------------
 rem   Auxiliary script for MSDOS, run by ../config.bat
-rem   Copyright (C) 2011-2018 Free Software Foundation, Inc.
+rem   Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 rem   This file is part of GNU Emacs.
 
diff --git a/msdos/inttypes.h b/msdos/inttypes.h
index 7df4f6f..5c073fc 100644
--- a/msdos/inttypes.h
+++ b/msdos/inttypes.h
@@ -1,6 +1,6 @@
 /* Replacement inttypes.h file for building GNU Emacs on MS-DOS with DJGPP.
 
-Copyright (C) 2011-2018 Free Software Foundation, Inc.
+Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/msdos/mainmake.v2 b/msdos/mainmake.v2
index 9be2f6e..08086d6 100644
--- a/msdos/mainmake.v2
+++ b/msdos/mainmake.v2
@@ -1,6 +1,6 @@
 # Top-level Makefile for Emacs under MS-DOS/DJGPP v2.0 or higher. 
-*-makefile-*-
 
-# Copyright (C) 1996-2018 Free Software Foundation, Inc.
+# Copyright (C) 1996-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
diff --git a/msdos/sed1v2.inp b/msdos/sed1v2.inp
index 8505656..9edd4d4 100644
--- a/msdos/sed1v2.inp
+++ b/msdos/sed1v2.inp
@@ -2,7 +2,7 @@
 # Configuration script for src/Makefile under DJGPP v2.x
 # ----------------------------------------------------------------------
 #
-# Copyright (C) 1996-1997, 1999-2018 Free Software Foundation, Inc.
+# Copyright (C) 1996-1997, 1999-2019 Free Software Foundation, Inc.
 #
 # This file is part of GNU Emacs.
 #
diff --git a/msdos/sed1x.inp b/msdos/sed1x.inp
index 14d0e48..23aa28e 100644
--- a/msdos/sed1x.inp
+++ b/msdos/sed1x.inp
@@ -2,7 +2,7 @@
 # Extra configuration script for src/makefile for DesqView/X
 # ----------------------------------------------------------------------
 #
-# Copyright (C) 1994-1997, 1999-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994-1997, 1999-2019 Free Software Foundation, Inc.
 #
 # This file is part of GNU Emacs.
 #
diff --git a/msdos/sed2v2.inp b/msdos/sed2v2.inp
index d654405..39cffdb 100644
--- a/msdos/sed2v2.inp
+++ b/msdos/sed2v2.inp
@@ -2,7 +2,7 @@
 # Configuration script for src/config.h under DJGPP v2.x
 # ----------------------------------------------------------------------
 #
-# Copyright (C) 1993-1997, 1999-2000, 2002-2018 Free Software
+# Copyright (C) 1993-1997, 1999-2000, 2002-2019 Free Software
 # Foundation, Inc.
 #
 # This file is part of GNU Emacs.
@@ -27,7 +27,7 @@
 #ifndef MSDOS\
 #define MSDOS\
 #endif
-/^#undef COPYRIGHT *$/s/^.*$/#define COPYRIGHT "Copyright (C) 2018 Free 
Software Foundation, Inc."/
+/^#undef COPYRIGHT *$/s/^.*$/#define COPYRIGHT "Copyright (C) 2019 Free 
Software Foundation, Inc."/
 /^#undef DIRECTORY_SEP *$/s!^.*$!#define DIRECTORY_SEP '/'!
 /^#undef DOS_NT *$/s/^.*$/#define DOS_NT/
 /^#undef FLOAT_CHECK_DOMAIN *$/s/^.*$/#define FLOAT_CHECK_DOMAIN/
diff --git a/msdos/sed2x.inp b/msdos/sed2x.inp
index 7b0f706..695c0b2 100644
--- a/msdos/sed2x.inp
+++ b/msdos/sed2x.inp
@@ -2,7 +2,7 @@
 # Extra configuration script for src/config.h for DesqView/X
 # ----------------------------------------------------------------------
 #
-# Copyright (C) 1994, 2001-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994, 2001-2019 Free Software Foundation, Inc.
 #
 # This file is part of GNU Emacs.
 #
diff --git a/msdos/sed3v2.inp b/msdos/sed3v2.inp
index 8311d08..952481f 100644
--- a/msdos/sed3v2.inp
+++ b/msdos/sed3v2.inp
@@ -2,7 +2,7 @@
 # Configuration script for lib-src/makefile under DJGPP v2
 # ----------------------------------------------------------------------
 #
-# Copyright (C) 1996, 1998, 2000-2018 Free Software Foundation, Inc.
+# Copyright (C) 1996, 1998, 2000-2019 Free Software Foundation, Inc.
 #
 # This file is part of GNU Emacs.
 #
diff --git a/msdos/sed4.inp b/msdos/sed4.inp
index 8e96168..520df66 100644
--- a/msdos/sed4.inp
+++ b/msdos/sed4.inp
@@ -2,7 +2,7 @@
 # Configuration script for src/paths.h
 # ----------------------------------------------------------------------
 #
-# Copyright (C) 1994, 2001-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994, 2001-2019 Free Software Foundation, Inc.
 #
 # This file is part of GNU Emacs.
 #
diff --git a/msdos/sed5x.inp b/msdos/sed5x.inp
index 5d99006..bb8fe9b 100644
--- a/msdos/sed5x.inp
+++ b/msdos/sed5x.inp
@@ -2,7 +2,7 @@
 # Configuration script for oldxmenu/makefile for DesqView/X
 # ----------------------------------------------------------------------
 #
-# Copyright (C) 1994, 2001-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994, 2001-2019 Free Software Foundation, Inc.
 #
 # This file is part of GNU Emacs.
 #
diff --git a/msdos/sed6.inp b/msdos/sed6.inp
index 1dbb2df..c1b5b16 100644
--- a/msdos/sed6.inp
+++ b/msdos/sed6.inp
@@ -3,7 +3,7 @@
 # doc/lispintro/Makefile, and doc/misc/Makefile under DJGPP v2.x
 # ---------------------------------------------------------------------------
 #
-# Copyright (C) 1997, 2000-2018 Free Software Foundation, Inc.
+# Copyright (C) 1997, 2000-2019 Free Software Foundation, Inc.
 #
 # This file is part of GNU Emacs.
 #
diff --git a/msdos/sedadmin.inp b/msdos/sedadmin.inp
index 111b5e2..bd63fe5 100644
--- a/msdos/sedadmin.inp
+++ b/msdos/sedadmin.inp
@@ -2,7 +2,7 @@
 # Configuration script for admin/unidata/Makefile under DJGPP v2.x
 # ----------------------------------------------------------------------
 #
-# Copyright (C) 2014-2018 Free Software Foundation, Inc.
+# Copyright (C) 2014-2019 Free Software Foundation, Inc.
 #
 # This file is part of GNU Emacs.
 #
diff --git a/msdos/sedalloc.inp b/msdos/sedalloc.inp
index cdd1d56..6721196 100644
--- a/msdos/sedalloc.inp
+++ b/msdos/sedalloc.inp
@@ -2,7 +2,7 @@
 # Configuration script for SYSTEM_MALLOC/REL_ALLOC in src/config.h
 # ----------------------------------------------------------------------
 #
-# Copyright (C) 2008-2018 Free Software Foundation, Inc.
+# Copyright (C) 2008-2019 Free Software Foundation, Inc.
 #
 # This file is part of GNU Emacs.
 #
diff --git a/msdos/sedleim.inp b/msdos/sedleim.inp
index 8435432..9384eca 100644
--- a/msdos/sedleim.inp
+++ b/msdos/sedleim.inp
@@ -2,7 +2,7 @@
 # Configuration script for leim/Makefile under DJGPP v2.x
 # ----------------------------------------------------------------------
 #
-# Copyright (C) 1999-2018 Free Software Foundation, Inc.
+# Copyright (C) 1999-2019 Free Software Foundation, Inc.
 #
 # This file is part of GNU Emacs.
 #
diff --git a/msdos/sedlibcf.inp b/msdos/sedlibcf.inp
index c743159..5785a61 100644
--- a/msdos/sedlibcf.inp
+++ b/msdos/sedlibcf.inp
@@ -5,7 +5,7 @@
 # files whose names are invalid on DOS 8+3 filesystems.
 # ----------------------------------------------------------------------
 #
-# Copyright (C) 2011-2018 Free Software Foundation, Inc.
+# Copyright (C) 2011-2019 Free Software Foundation, Inc.
 #
 # This file is part of GNU Emacs.
 #
diff --git a/msdos/sedlibmk.inp b/msdos/sedlibmk.inp
index 9b66a4c..df9e8d3 100644
--- a/msdos/sedlibmk.inp
+++ b/msdos/sedlibmk.inp
@@ -2,7 +2,7 @@
 # Configuration script for lib/Makefile under DJGPP v2.x
 # ----------------------------------------------------------------------
 #
-# Copyright (C) 2011-2018 Free Software Foundation, Inc.
+# Copyright (C) 2011-2019 Free Software Foundation, Inc.
 #
 # This file is part of GNU Emacs.
 #
diff --git a/msdos/sedlisp.inp b/msdos/sedlisp.inp
index 0fcef03..dc17740 100644
--- a/msdos/sedlisp.inp
+++ b/msdos/sedlisp.inp
@@ -2,7 +2,7 @@
 # Configuration script for lisp/Makefile under DJGPP v2.x
 # ----------------------------------------------------------------------
 #
-# Copyright (C) 2000-2018 Free Software Foundation, Inc.
+# Copyright (C) 2000-2019 Free Software Foundation, Inc.
 #
 # This file is part of GNU Emacs.
 #
diff --git a/nextstep/ChangeLog.1 b/nextstep/ChangeLog.1
index af3680c..dbbe23f 100644
--- a/nextstep/ChangeLog.1
+++ b/nextstep/ChangeLog.1
@@ -312,7 +312,7 @@
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 2008-2018 Free Software Foundation, Inc.
+  Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/nextstep/INSTALL b/nextstep/INSTALL
index 726a897..f287eb7 100644
--- a/nextstep/INSTALL
+++ b/nextstep/INSTALL
@@ -1,4 +1,4 @@
-Copyright (C) 2008-2018 Free Software Foundation, Inc.
+Copyright (C) 2008-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 
diff --git a/nextstep/Makefile.in b/nextstep/Makefile.in
index cb69898..08e2e51 100644
--- a/nextstep/Makefile.in
+++ b/nextstep/Makefile.in
@@ -1,6 +1,6 @@
 ### @configure_input@
 
-## Copyright (C) 2012-2018 Free Software Foundation, Inc.
+## Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ## This file is part of GNU Emacs.
 
@@ -44,7 +44,7 @@ ns_check_file = @ns_appdir@/@ns_check_file@
 
 .PHONY: all
 
-all: ${ns_appdir} ${ns_appbindir}/Emacs
+all: ${ns_appdir} ${ns_appbindir}/Emacs ${ns_appbindir}/Emacs.pdmp
 
 ${ns_check_file} ${ns_appdir}: ${srcdir}/${ns_appsrc} ${ns_appsrc}
        rm -rf ${ns_appdir}
@@ -63,6 +63,10 @@ ${ns_appbindir}/Emacs: ${ns_appdir} ${ns_check_file} 
../src/emacs${EXEEXT}
        ${MKDIR_P} ${ns_appbindir}
        cp -f ../src/emacs${EXEEXT} $@
 
+${ns_appbindir}/Emacs.pdmp: ${ns_appdir} ${ns_check_file} 
../src/emacs${EXEEXT}.pdmp
+       ${MKDIR_P} ${ns_appbindir}
+       cp -f ../src/emacs${EXEEXT}.pdmp $@
+
 .PHONY: FORCE
 
 ../src/emacs${EXEEXT}: FORCE
@@ -81,6 +85,7 @@ links: ../src/emacs${EXEEXT}
        ln -s $(top_srcdir_abs)/info ${ns_appdir}/Contents/Resources
        ${MKDIR_P} ${ns_appbindir}
        ln -s $(abs_top_builddir)/src/emacs${EXEEXT} ${ns_appbindir}/Emacs
+       ln -s $(abs_top_builddir)/src/emacs${EXEEXT}.pdmp 
${ns_appbindir}/Emacs.pdmp
        ln -s $(abs_top_builddir)/lib-src ${ns_appbindir}/bin
        ln -s $(abs_top_builddir)/lib-src ${ns_appbindir}/libexec
        ${MKDIR_P} ${ns_appdir}/Contents/Resources/etc
diff --git a/nextstep/README b/nextstep/README
index 66426f7..83e21e6 100644
--- a/nextstep/README
+++ b/nextstep/README
@@ -105,7 +105,7 @@ future development.
 
 
 ----------------------------------------------------------------------
-Copyright 2008-2018 Free Software Foundation, Inc.
+Copyright 2008-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/nextstep/templates/Info.plist.in b/nextstep/templates/Info.plist.in
index 406d6f7..c1e50a8 100644
--- a/nextstep/templates/Info.plist.in
+++ b/nextstep/templates/Info.plist.in
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-Copyright (C) 2008-2018 Free Software Foundation, Inc.
+Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/nt/ChangeLog.1 b/nt/ChangeLog.1
index 48171af..59b3822 100644
--- a/nt/ChangeLog.1
+++ b/nt/ChangeLog.1
@@ -3548,7 +3548,7 @@
 ;; add-log-time-zone-rule: t
 ;; End:
 
-  Copyright (C) 1995-1999, 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 1995-1999, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/nt/INSTALL b/nt/INSTALL
index 6706942..3e617f2 100644
--- a/nt/INSTALL
+++ b/nt/INSTALL
@@ -1,7 +1,7 @@
                    Building and Installing Emacs on MS-Windows
                           using the MSYS and MinGW tools
 
-  Copyright (C) 2013-2018 Free Software Foundation, Inc.
+  Copyright (C) 2013-2019 Free Software Foundation, Inc.
   See the end of the file for license conditions.
 
 The MSYS/MinGW build described here is supported on versions of
diff --git a/nt/INSTALL.W64 b/nt/INSTALL.W64
index c3aa85e..994c567 100644
--- a/nt/INSTALL.W64
+++ b/nt/INSTALL.W64
@@ -1,7 +1,7 @@
          Building and Installing Emacs on 64-bit MS-Windows
                      using MSYS2 and MinGW-w64
 
-  Copyright (c) 2015-2018 Free Software Foundation, Inc.
+  Copyright (c) 2015-2019 Free Software Foundation, Inc.
   See the end of the file for license conditions.
 
 This document describes how to compile a 64-bit GNU Emacs using MSYS2
diff --git a/nt/Makefile.in b/nt/Makefile.in
index 0b2e72e..36e5243 100644
--- a/nt/Makefile.in
+++ b/nt/Makefile.in
@@ -1,6 +1,6 @@
 ### @configure_input@
 
-# Copyright (C) 2013-2018 Free Software Foundation, Inc.
+# Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
diff --git a/nt/README b/nt/README
index c75e369..de68162 100644
--- a/nt/README
+++ b/nt/README
@@ -1,6 +1,6 @@
             Emacs for Windows NT/2000 and Windows 95/98/ME
 
-  Copyright (C) 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 2001-2019 Free Software Foundation, Inc.
   See the end of the file for license conditions.
 
   This directory contains support for compiling and running GNU Emacs on
diff --git a/nt/README.W32 b/nt/README.W32
index f0147b4..c04f1a6 100644
--- a/nt/README.W32
+++ b/nt/README.W32
@@ -1,4 +1,4 @@
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
                Emacs version 27.0.50 for MS-Windows
@@ -24,7 +24,7 @@ See the end of the file for license conditions.
 * Preliminaries
 
   There are two binary distributions named
-  emacs-VER-x86_64-w64-mingw32.zip and emacs-VER-i686-w64-mingw32.zip,
+  emacs-VER-x86_64.zip and emacs-VER-i686.zip,
   where VER is the Emacs version.  These are 64-bit and 32-bit builds,
   respectively.  If you are running a 32-bit version of MS-Windows,
   you need to install the 32-bit build; users of 64-bit Windows can
@@ -45,29 +45,14 @@ See the end of the file for license conditions.
   action, by default this will be in a top-level directory with the
   same name as the zip file.
 
-  We also provide a set of optional dependencies, in
-  emacs-MVER-x86_64-deps.zip or emacs-MVER-i686-deps.zip respectively,
-  where MVER is the major Emacs version that should use these
-  libraries.  These provide Emacs with a number of additional optional
-  capabilities, described in detail below.  To use these, unpack them
-  directly over the emacs directory structure.  Note that, if
-  extracting with the Windows Explorer, you will have to override the
-  directory where it wants to put the file with the same directory
-  where you extracted the Emacs binary package.
-
-  Finally, and also optionally, you can run the program addpm.exe in
-  the bin subdirectory which will place an icon for Emacs on the start
-  page.  (This is no longer needed in latest versions of Emacs, so we
-  recommend you not do that, as running addpm.exe will insert entries
-  into the Registry which might get in the way if you upgrade to later
-  versions without updating those entries, or would like to uninstall
-  Emacs.)
-
   Emacs is completely portable.  You can create your own shortcut to
   runemacs.exe and place this wherever you find it convenient (the
   desktop and/or the Taskbar), or run it from a USB or network drive
   without copying or installing anything on the machine itself.
 
+  It is also possible, although not recommended to use the program
+  bin/addpm.exe which will place an icon for Emacs on the start page.
+
 * Prerequisites for Windows 9X
 
   The 32-bit build supports MS-Windows 9X (Windows 95/98/Me).  To run
@@ -151,48 +136,41 @@ See the end of the file for license conditions.
   + update-game-score.exe - A utility for updating the score files of
     Emacs games.
 
-* Optional dependency libraries
+* Emacs without optional dependencies
 
-  Emacs has built in support for XBM and PPM/PGM/PBM images, and the
-  libXpm library is bundled, providing XPM support (required for color
-  toolbar icons and splash screen).  Source for libXpm should be
-  available from the same place from which you got this binary
-  distribution.
+  The files emacs-VER-x86_64.zip and emacs-VER-i686.zip contain a
+  large number of optional dependencies for Emacs.
 
-  Emacs has a number of optional features which need additional
-  libraries.  These are provided in a separate bundle of dependencies,
-  as described above, and enable support for the following:
+  Emacs has a number of optional features which use these additional
+  dependencies.  They enable support for the following:
 
   - displaying inline images of many types (PNG, JPEG, GIF, TIFF, SVG)
   - SSL/TLS secure network communications (HTTPS, IMAPS, etc.)
   - HTML and XML parsing (necessary for the built-in EWW browser)
   - built-in decompression of compressed text
 
-  The optional dependency libraries are in emacs-MVER-x86_64-deps.zip
-  (64-bit) and emacs-MVER-i686-deps.zip (32-bit), and their sources
-  are in emacs-MVER-deps-mingw-w64-src.zip, where MVER is the major
-  version of Emacs that should use these dependencies.  Note that a
-  64-bit Emacs will only work with the 64-bit dependencies, and the
-  32-bit Emacs only with the 32-bit dependencies.
-
-  Newer/updated builds for these optional libraries are available at
-  http://msys2.github.io/ and
-  http://sourceforge.net/projects/ezwinports/files/ (but you shouldn't
-  need these except in emergencies).
+  If you do not want these files (if you have them already for
+  instance, or you want the smallest possible Emacs), then you may use
+  the files emacs-VER-x86_64-no-deps.zip or
+  emacs-VER-i686-no-deps.zip. The dependency files are also available
+  as emacs-MVER-x86_64-no-deps.zip and emacs-MVER-i686-deps.zip. Source
+  code for these dependencies is available as
+  emacs-26-deps-mingw-w64-src.zip.
 
-  If you install the libraries in a directory different from where you
-  have the Emacs executable programs, we recommend to add the
-  directory with DLLs to your Path, so that Emacs will be able to find
-  those DLLs when needed.
+  All distributions of Emacs have built in support for XBM and
+  PPM/PGM/PBM images, and the libXpm library is bundled, providing XPM
+  support (required for color toolbar icons and splash screen).
+  Source for libXpm should be available from the same place from which
+  you got this binary distribution.
 
 * Installing Emacs with an existing MSYS2 installation
 
-  You may also use Emacs with an existing MSYS2 installation by simply
-  unpacking the Emacs distribution over MSYS2.  You can then use the
-  'pacman' utility to install dependencies.  You should not use the
-  optional dependencies bundle from this site, as this will overwrite
-  MSYS2 files (the dependency bundle derives from MSYS2, but may be a
-  different version).
+  You may also use Emacs with an existing MSYS2 installation by
+  unpacking the emacs-VER-x86_64-no-deps.zip over the MSYS2
+  distribution. You should not use the emacs-VER-x86_64.zip from this
+  site, as this will overwrite MSYS2 files (the dependency bundle
+  derives from MSYS2, but will be from a different version). You can
+  then use the 'pacman' utility to install dependencies.
 
   Some of the optional libraries need to be of certain versions to
   work with your Emacs binary.  Make sure you install those versions
@@ -218,6 +196,7 @@ See the end of the file for license conditions.
     mingw-w64-x86_64-libtiff
     mingw-w64-x86_64-libxml2
     mingw-w64-x86_64-xpm-nox
+    mingw-w64-x86_64-lcms2
 
   You can type any subset of this list.  When asked whether to proceed
   with installation, answer Y.
diff --git a/nt/addpm.c b/nt/addpm.c
index 2132020..f71ce5f 100644
--- a/nt/addpm.c
+++ b/nt/addpm.c
@@ -1,5 +1,5 @@
 /* Add entries to the GNU Emacs Program Manager folder.
-   Copyright (C) 1995, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1995, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/nt/cmdproxy.c b/nt/cmdproxy.c
index 82d3d8b..0b72bcd 100644
--- a/nt/cmdproxy.c
+++ b/nt/cmdproxy.c
@@ -1,5 +1,5 @@
 /* Proxy shell designed for use with Emacs on Windows 95 and NT.
-   Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 
    Accepts subset of Unix sh(1) command-line options, for compatibility
    with elisp code written for Unix.  When possible, executes external
diff --git a/nt/configure.bat b/nt/configure.bat
index 708ff43..09a3594 100755
--- a/nt/configure.bat
+++ b/nt/configure.bat
@@ -1,7 +1,7 @@
 @echo off
 rem   ----------------------------------------------------------------------
 rem   This was the old configuration script for MS Windows operating systems
-rem   Copyright (C) 1999-2018 Free Software Foundation, Inc.
+rem   Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 rem   This file is part of GNU Emacs.
 
diff --git a/nt/ddeclient.c b/nt/ddeclient.c
index 221e182..e441700 100644
--- a/nt/ddeclient.c
+++ b/nt/ddeclient.c
@@ -1,5 +1,5 @@
 /* Simple client interface to DDE servers.
-   Copyright (C) 1998, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/nt/emacs.rc.in b/nt/emacs.rc.in
index 1cf40ba..71346db 100644
--- a/nt/emacs.rc.in
+++ b/nt/emacs.rc.in
@@ -31,7 +31,7 @@ BEGIN
            VALUE "FileDescription", "GNU Emacs: The extensible 
self-documenting text editor\0"
            VALUE "FileVersion", "@address@hidden"
            VALUE "InternalName", "Emacs\0"
-           VALUE "LegalCopyright", "Copyright (C) 2001-2018\0"
+           VALUE "LegalCopyright", "Copyright (C) 2001-2019\0"
            VALUE "OriginalFilename", "emacs.exe"
            VALUE "ProductName", "Emacs\0"
            VALUE "ProductVersion", "@address@hidden"
diff --git a/nt/emacsclient.rc.in b/nt/emacsclient.rc.in
index 770f665..fac7f66 100644
--- a/nt/emacsclient.rc.in
+++ b/nt/emacsclient.rc.in
@@ -25,7 +25,7 @@ BEGIN
            VALUE "FileDescription", "GNU EmacsClient: Client for the 
extensible self-documenting text editor\0"
            VALUE "FileVersion", "@address@hidden"
            VALUE "InternalName", "EmacsClient\0"
-           VALUE "LegalCopyright", "Copyright (C) 2001-2018\0"
+           VALUE "LegalCopyright", "Copyright (C) 2001-2019\0"
            VALUE "OriginalFilename", "emacsclientw.exe"
            VALUE "ProductName", "EmacsClient\0"
            VALUE "ProductVersion", "@address@hidden"
diff --git a/nt/epaths.nt b/nt/epaths.nt
index 393af21..152184c 100644
--- a/nt/epaths.nt
+++ b/nt/epaths.nt
@@ -12,7 +12,7 @@
    the host system (e.g., i686-pc-mingw32), and @SRC@ by the root of
    the Emacs source tree used to build Emacs.  */
 /*
-Copyright (C) 1993, 1995, 1997, 1999, 2001-2018 Free Software
+Copyright (C) 1993, 1995, 1997, 1999, 2001-2019 Free Software
 Foundation, Inc.
 
 This file is part of GNU Emacs.
diff --git a/nt/gnulib-cfg.mk b/nt/gnulib-cfg.mk
index 21d4233..09cd582 100644
--- a/nt/gnulib-cfg.mk
+++ b/nt/gnulib-cfg.mk
@@ -1,6 +1,6 @@
 # Configurations for ../lib/gnulib.mk.
 #
-# Copyright 2017-2018 Free Software Foundation, Inc.
+# Copyright 2017-2019 Free Software Foundation, Inc.
 #
 # 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
diff --git a/nt/icons/README b/nt/icons/README
index a82e04f..86765f9 100644
--- a/nt/icons/README
+++ b/nt/icons/README
@@ -2,13 +2,13 @@ COPYRIGHT AND LICENSE INFORMATION FOR IMAGE FILES
 
 File: emacs.ico
 Author: Kentaro Ohkouchi <address@hidden>
-Copyright (C) 2008-2018 Free Software Foundation, Inc.
+Copyright (C) 2008-2019 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later
 
 
 File: emacs22.ico
 Author: Andrew Zhilin
-Copyright (C) 2005-2018 Free Software Foundation, Inc.
+Copyright (C) 2005-2019 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
 
 
@@ -17,7 +17,7 @@ Files: gnu2a32.ico gnu2a32t.ico gnu2b48.ico gnu2b48t.ico
        gnu5w32.ico gnu5w32t.ico gnu6w48.ico gnu6w48t.ico
        gnu7.ico    gnu8.ico     gnu9.ico
 Author: Rob Davenport <rgd at bigfoot.com>
-Copyright (C) 1999, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1999, 2001-2019 Free Software Foundation, Inc.
 License: GNU General Public License version 3 or later (see COPYING)
 
   <http://users.adelphia.net/~rob.davenport/gnuicons.html>
diff --git a/nt/inc/grp.h b/nt/inc/grp.h
index db40862..e78a63e 100644
--- a/nt/inc/grp.h
+++ b/nt/inc/grp.h
@@ -1,6 +1,6 @@
 /* Replacement grp.h file for building GNU Emacs on Windows.
 
-Copyright (C) 2003-2018 Free Software Foundation, Inc.
+Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/nt/inc/inttypes.h b/nt/inc/inttypes.h
index ac09ae5..ae76b8c 100644
--- a/nt/inc/inttypes.h
+++ b/nt/inc/inttypes.h
@@ -1,6 +1,6 @@
 /* Replacement inttypes.h file for building GNU Emacs on Windows with MSVC.
 
-Copyright (C) 2011-2018 Free Software Foundation, Inc.
+Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/nt/inc/langinfo.h b/nt/inc/langinfo.h
index 99773a2..6c4959e 100644
--- a/nt/inc/langinfo.h
+++ b/nt/inc/langinfo.h
@@ -1,6 +1,6 @@
 /* Replacement langinfo.h file for building GNU Emacs on Windows.
 
-Copyright (C) 2006-2018 Free Software Foundation, Inc.
+Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -27,6 +27,7 @@ enum {
   DAY_1, DAY_2, DAY_3, DAY_4, DAY_5, DAY_6, DAY_7,
   MON_1, MON_2, MON_3, MON_4, MON_5, MON_6, MON_7, MON_8, MON_9, MON_10,
   MON_11, MON_12,
+  _NL_PAPER_WIDTH, _NL_PAPER_HEIGHT,
 
   /* Number of enumerated values.  */
   _NL_NUM
@@ -55,6 +56,9 @@ enum {
 #define MON_11 MON_11
 #define MON_12 MON_12
 
+#define _NL_PAPER_WIDTH  _NL_PAPER_WIDTH
+#define _NL_PAPER_HEIGHT _NL_PAPER_HEIGHT
+
 extern char *nl_langinfo (nl_item);
 
 #endif /* _LANGINFO_H */
diff --git a/nt/inc/ms-w32.h b/nt/inc/ms-w32.h
index df35dff..7de94ca 100644
--- a/nt/inc/ms-w32.h
+++ b/nt/inc/ms-w32.h
@@ -1,6 +1,6 @@
 /* System description file for Windows NT.
 
-Copyright (C) 1993-1995, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1993-1995, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/nt/inc/nl_types.h b/nt/inc/nl_types.h
index 38082d9..a13309b 100644
--- a/nt/inc/nl_types.h
+++ b/nt/inc/nl_types.h
@@ -1,6 +1,6 @@
 /* Replacement nl_types.h file for building GNU Emacs on Windows.
 
-Copyright (C) 2006-2018 Free Software Foundation, Inc.
+Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/nt/inc/stdint.h b/nt/inc/stdint.h
index 38fd4d0..cb7b9f7 100644
--- a/nt/inc/stdint.h
+++ b/nt/inc/stdint.h
@@ -1,6 +1,6 @@
 /* Replacement stdint.h file for building GNU Emacs on Windows.
 
-Copyright (C) 2011-2018 Free Software Foundation, Inc.
+Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/nt/inc/sys/resource.h b/nt/inc/sys/resource.h
index 5c4f792..c565055 100644
--- a/nt/inc/sys/resource.h
+++ b/nt/inc/sys/resource.h
@@ -1,6 +1,6 @@
 /* A limited emulation of sys/resource.h.
 
-Copyright (C) 2016-2018 Free Software Foundation, Inc.
+Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/nt/inc/sys/socket.h b/nt/inc/sys/socket.h
index de282c4..6d26ff9 100644
--- a/nt/inc/sys/socket.h
+++ b/nt/inc/sys/socket.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 2001-2018 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/nt/inc/sys/stat.h b/nt/inc/sys/stat.h
index 0b1f9bc..31ad872 100644
--- a/nt/inc/sys/stat.h
+++ b/nt/inc/sys/stat.h
@@ -1,7 +1,7 @@
 /* sys/stat.h supplied with MSVCRT uses too narrow data types for
    inode and user/group id, so we replace them with our own.
 
-Copyright (C) 2008-2018 Free Software Foundation, Inc.
+Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/nt/inc/sys/wait.h b/nt/inc/sys/wait.h
index 9c86eb8..0b756a3 100644
--- a/nt/inc/sys/wait.h
+++ b/nt/inc/sys/wait.h
@@ -1,6 +1,6 @@
 /* A limited emulation of sys/wait.h on Posix systems.
 
-Copyright (C) 2012-2018 Free Software Foundation, Inc.
+Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/nt/mingw-cfg.site b/nt/mingw-cfg.site
index d9a8240..4df2049 100644
--- a/nt/mingw-cfg.site
+++ b/nt/mingw-cfg.site
@@ -109,6 +109,7 @@ gl_cv_func_pthread_sigmask_return_works=yes
 gl_cv_func_pthread_sigmask_unblock_works="not relevant"
 # Implemented in w32proc.c
 emacs_cv_langinfo_codeset=yes
+emacs_cv_langinfo__nl_paper_width=yes
 # Declared in ms-w32.h
 ac_cv_have_decl_alarm=yes
 # Avoid including the gnulib dup2 module
diff --git a/nt/preprep.c b/nt/preprep.c
index 8979e33..f0f6273 100644
--- a/nt/preprep.c
+++ b/nt/preprep.c
@@ -1,5 +1,5 @@
 /* Pre-process emacs.exe for profiling by MSVC.
-   Copyright (C) 1999, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/nt/runemacs.c b/nt/runemacs.c
index 46e467e..34833e9 100644
--- a/nt/runemacs.c
+++ b/nt/runemacs.c
@@ -1,6 +1,6 @@
 /* runemacs --- Simple program to start Emacs with its console window hidden.
 
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/oldXMenu/Activate.c b/oldXMenu/Activate.c
index 8a35e6e..a0d1f70 100644
--- a/oldXMenu/Activate.c
+++ b/oldXMenu/Activate.c
@@ -3,7 +3,7 @@
 #include "copyright.h"
 
 /*
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 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
diff --git a/oldXMenu/ChangeLog.1 b/oldXMenu/ChangeLog.1
index 44387d1..0e76897 100644
--- a/oldXMenu/ChangeLog.1
+++ b/oldXMenu/ChangeLog.1
@@ -712,7 +712,7 @@
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 1993-1999, 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 1993-1999, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/oldXMenu/Create.c b/oldXMenu/Create.c
index c60bc5f..58d1782 100644
--- a/oldXMenu/Create.c
+++ b/oldXMenu/Create.c
@@ -3,7 +3,7 @@
 #include "copyright.h"
 
 /*
-Copyright (C) 1993-1994, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1993-1994, 2001-2019 Free Software Foundation, Inc.
 
 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
@@ -87,7 +87,7 @@ along with this program.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #define XASSOC_TABLE_SIZE      64
 
-char *x_get_resource_string (char const *, char const *);
+const char *x_get_resource_string (char const *, char const *);
 
 
 
@@ -107,7 +107,7 @@ XMenuCreate(Display *display, Window parent, register char 
const *def_env)
                                /* Window ID of the menu's parent window. */
                                /* X Defaults program environment name. */
 {
-  register char *def_val;      /* X Default value temp variable. */
+  register const char *def_val;        /* X Default value temp variable. */
 
   register XMenu *menu;                /* Pointer to the new menu. */
   XMStyle menu_style;          /* Menu display style. */
diff --git a/oldXMenu/FindSel.c b/oldXMenu/FindSel.c
index 2b3d281..af08410 100644
--- a/oldXMenu/FindSel.c
+++ b/oldXMenu/FindSel.c
@@ -3,7 +3,7 @@
 #include "copyright.h"
 
 /*
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 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
diff --git a/oldXMenu/Internal.c b/oldXMenu/Internal.c
index 912cb7d..074e4f9 100644
--- a/oldXMenu/Internal.c
+++ b/oldXMenu/Internal.c
@@ -3,7 +3,7 @@
 #include "copyright.h"
 
 /*
-Copyright (C) 1993, 1996, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1993, 1996, 2001-2019 Free Software Foundation, Inc.
 
 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
diff --git a/oldXMenu/Makefile.in b/oldXMenu/Makefile.in
index 211bac9..db76e74 100644
--- a/oldXMenu/Makefile.in
+++ b/oldXMenu/Makefile.in
@@ -15,7 +15,7 @@
 ## without express or implied warranty.
 
 
-## Copyright (C) 2001-2018 Free Software Foundation, Inc.
+## Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ## 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
diff --git a/oldXMenu/deps.mk b/oldXMenu/deps.mk
index 55d0243..f5e3a25 100644
--- a/oldXMenu/deps.mk
+++ b/oldXMenu/deps.mk
@@ -15,7 +15,7 @@
 ## without express or implied warranty.
 
 
-## Copyright (C) 2001-2018 Free Software Foundation, Inc.
+## Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 ## 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
diff --git a/oldXMenu/insque.c b/oldXMenu/insque.c
index 1a77906..4732bce 100644
--- a/oldXMenu/insque.c
+++ b/oldXMenu/insque.c
@@ -1,5 +1,5 @@
 /*
-Copyright (C) 1993-1998, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1993-1998, 2001-2019 Free Software Foundation, Inc.
 
 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
diff --git a/src/.gdbinit b/src/.gdbinit
index ae6f13a..b8b3031 100644
--- a/src/.gdbinit
+++ b/src/.gdbinit
@@ -1,4 +1,4 @@
-# Copyright (C) 1992-1998, 2000-2018 Free Software Foundation, Inc.
+# Copyright (C) 1992-1998, 2000-2019 Free Software Foundation, Inc.
 #
 # This file is part of GNU Emacs.
 #
@@ -1219,24 +1219,12 @@ show environment TERM
 # terminate_due_to_signal when an assertion failure is non-fatal.
 break terminate_due_to_signal
 
-# x_error_quitter is defined only on X.  But window-system is set up
-# only at run time, during Emacs startup, so we need to defer setting
-# the breakpoint.  init_sys_modes is the first function called on
-# every platform after init_display, where window-system is set.
-tbreak init_sys_modes
-commands
-  silent
-  xsymname globals.f_Vinitial_window_system
-  xgetptr $symname
-  set $tem = (struct Lisp_String *) $ptr
-  set $tem = (char *) $tem->u.s.data
-  # If we are running in synchronous mode, we want a chance to look
-  # around before Emacs exits.  Perhaps we should put the break
-  # somewhere else instead...
-  if $tem[0] == 'x' && $tem[1] == '\0'
-    break x_error_quitter
-  end
-  continue
+# x_error_quitter is defined only if defined_HAVE_X_WINDOWS.
+# If we are running in synchronous mode, we want a chance to look
+# around before Emacs exits.  Perhaps we should put the break
+# somewhere else instead...
+if defined_HAVE_X_WINDOWS
+  break x_error_quitter
 end
 
 
diff --git a/src/ChangeLog.1 b/src/ChangeLog.1
index a4271ef..171ce7b 100644
--- a/src/ChangeLog.1
+++ b/src/ChangeLog.1
@@ -3521,7 +3521,7 @@
        * minibuf.c: Don't allow entry to minibuffer
        while minibuffer is selected.
 
-    Copyright (C) 1985-1986, 2001-2018 Free Software Foundation, Inc.
+    Copyright (C) 1985-1986, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/src/ChangeLog.10 b/src/ChangeLog.10
index a0b718f..cab6101 100644
--- a/src/ChangeLog.10
+++ b/src/ChangeLog.10
@@ -27912,7 +27912,7 @@ See ChangeLog.9 for earlier changes.
 ;; add-log-time-zone-rule: t
 ;; End:
 
-    Copyright (C) 2001-2018 Free Software Foundation, Inc.
+    Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/src/ChangeLog.11 b/src/ChangeLog.11
index 3c028ca..46ab8b9 100644
--- a/src/ChangeLog.11
+++ b/src/ChangeLog.11
@@ -23186,7 +23186,7 @@
        Delete argument prop_index.
        (font_property_table): Change arguments to validator.  Change Callers.
        (font_lispy_object): Delete.
-       (font_at): Use font_find_object instead fo font_lispy_object.
+       (font_at): Use font_find_object instead of font_lispy_object.
 
 2008-02-01  Kenichi Handa  <address@hidden>
 
@@ -31385,7 +31385,7 @@ See ChangeLog.10 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 2007-2018 Free Software Foundation, Inc.
+  Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/src/ChangeLog.12 b/src/ChangeLog.12
index e7a313a..3b39728 100644
--- a/src/ChangeLog.12
+++ b/src/ChangeLog.12
@@ -22936,7 +22936,7 @@ See ChangeLog.11 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 2011-2018 Free Software Foundation, Inc.
+  Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/src/ChangeLog.13 b/src/ChangeLog.13
index 31e0130..4d7dab5 100644
--- a/src/ChangeLog.13
+++ b/src/ChangeLog.13
@@ -17905,7 +17905,7 @@ See ChangeLog.12 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 2011-2018 Free Software Foundation, Inc.
+  Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/src/ChangeLog.2 b/src/ChangeLog.2
index 18cd95f..8199351 100644
--- a/src/ChangeLog.2
+++ b/src/ChangeLog.2
@@ -4771,7 +4771,7 @@
 
 See ChangeLog.1 for earlier changes.
 
-    Copyright (C) 1986-1988, 2001-2018 Free Software Foundation, Inc.
+    Copyright (C) 1986-1988, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/src/ChangeLog.3 b/src/ChangeLog.3
index c232ee0..051c70f 100644
--- a/src/ChangeLog.3
+++ b/src/ChangeLog.3
@@ -16503,7 +16503,7 @@ See ChangeLog.2 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 1993, 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 1993, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/src/ChangeLog.4 b/src/ChangeLog.4
index adc29b2..ab2807c 100644
--- a/src/ChangeLog.4
+++ b/src/ChangeLog.4
@@ -5135,7 +5135,7 @@
        (BSTRING): Deleted because they are stubs to the memory funcs.
        (memmove): Defined as safe_bcopy since memcpy is not safe.
        (HAVE_X_WINDOWS): Does not conditionally define anything any more.
-       Added support fo the GNU C compiler bundled with R3V7.
+       Added support for the GNU C compiler bundled with R3V7.
 
 1993-07-26  Richard Stallman  (address@hidden)
 
@@ -6906,7 +6906,7 @@ See ChangeLog.3 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 1993-1994, 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 1993-1994, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/src/ChangeLog.5 b/src/ChangeLog.5
index 4fa493e..1ab7773 100644
--- a/src/ChangeLog.5
+++ b/src/ChangeLog.5
@@ -7148,7 +7148,7 @@ See ChangeLog.4 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 1994-1995, 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 1994-1995, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/src/ChangeLog.6 b/src/ChangeLog.6
index 0a9417df..fdaa010 100644
--- a/src/ChangeLog.6
+++ b/src/ChangeLog.6
@@ -5358,7 +5358,7 @@ See ChangeLog.5 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 1995-1996, 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 1995-1996, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/src/ChangeLog.7 b/src/ChangeLog.7
index cef477a..50c7480 100644
--- a/src/ChangeLog.7
+++ b/src/ChangeLog.7
@@ -11091,7 +11091,7 @@ See ChangeLog.6 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 1997-1998, 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 1997-1998, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/src/ChangeLog.8 b/src/ChangeLog.8
index be2791c..e1a45b0 100644
--- a/src/ChangeLog.8
+++ b/src/ChangeLog.8
@@ -13979,7 +13979,7 @@
 
 See ChangeLog.7 for earlier changes.
 
-  Copyright (C) 1999, 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 1999, 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/src/ChangeLog.9 b/src/ChangeLog.9
index 71aba18..fbc1fd1 100644
--- a/src/ChangeLog.9
+++ b/src/ChangeLog.9
@@ -13294,7 +13294,7 @@ See ChangeLog.8 for earlier changes.
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 2001-2018 Free Software Foundation, Inc.
+  Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/src/Makefile.in b/src/Makefile.in
index a8fa5c3..5127388 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1,6 +1,6 @@
 ### @configure_input@
 
-# Copyright (C) 1985, 1987-1988, 1993-1995, 1999-2018 Free Software
+# Copyright (C) 1985, 1987-1988, 1993-1995, 1999-2019 Free Software
 # Foundation, Inc.
 
 # This file is part of GNU Emacs.
@@ -54,8 +54,6 @@ lwlibdir = ../lwlib
 # Configuration files for .o files to depend on.
 config_h = config.h $(srcdir)/conf_post.h
 
-bootstrap_exe = ../src/bootstrap-emacs$(EXEEXT)
-
 ## ns-app if HAVE_NS, else empty.
 OTHER_FILES = @OTHER_FILES@
 
@@ -127,7 +125,8 @@ address@hidden@ @LIBJPEG@ @LIBPNG@ @LIBGIF@ @LIBXPM@
 
 address@hidden@
 address@hidden@
-LIBX_EXTRA=-lX11 $(XCB_LIBS) $(XFT_LIBS)
address@hidden@
+LIBX_EXTRA=-lX11 $(XCB_LIBS) $(XFT_LIBS) $(XRENDER_LIBS)
 
 FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
 FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
@@ -333,7 +332,9 @@ BUILD_DETAILS = @BUILD_DETAILS@
 
 UNEXEC_OBJ = @UNEXEC_OBJ@
 
address@hidden@
address@hidden@
+CHECK_STRUCTS = @CHECK_STRUCTS@
+HAVE_PDUMPER = @HAVE_PDUMPER@
 
 # 'make' verbosity.
 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
@@ -358,6 +359,15 @@ am__v_at_ = $(address@hidden@)
 am__v_at_0 = @
 am__v_at_1 =
 
+bootstrap_exe = ../src/bootstrap-emacs$(EXEEXT)
+ifeq ($(DUMPING),pdumper)
+bootstrap_pdmp := bootstrap-emacs.pdmp # Keep in sync with loadup.el
+pdmp := emacs.pdmp
+else
+bootstrap_pdmp :=
+pdmp :=
+endif
+
 # Flags that might be in WARN_CFLAGS but are not valid for Objective C.
 NON_OBJC_CFLAGS = -Wignored-attributes -Wignored-qualifiers -Wopenmp-simd
 
@@ -396,7 +406,7 @@ base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o 
$(XMENU_OBJ) window.o \
        bignum.o buffer.o filelock.o insdel.o marker.o \
        minibuf.o fileio.o dired.o \
        cmds.o casetab.o casefiddle.o indent.o search.o regex-emacs.o undo.o \
-       alloc.o data.o doc.o editfns.o callint.o \
+       alloc.o pdumper.o data.o doc.o editfns.o callint.o \
        eval.o floatfns.o fns.o font.o print.o lread.o $(MODULES_OBJ) \
        syntax.o $(UNEXEC_OBJ) bytecode.o \
        process.o gnutls.o callproc.o \
@@ -447,9 +457,19 @@ address@hidden@
 ALLOBJS = $(FIRSTFILE_OBJ) $(VMLIMIT_OBJ) $(obj) $(otherobj)
 
 # Must be first, before dep inclusion!
-all: emacs$(EXEEXT) $(OTHER_FILES)
+all: emacs$(EXEEXT) $(pdmp) $(OTHER_FILES)
 .PHONY: all
 
+dmpstruct_headers=$(srcdir)/lisp.h $(srcdir)/buffer.h \
+       $(srcdir)/intervals.h $(srcdir)/charset.h $(srcdir)/bignum.h
+ifeq ($(CHECK_STRUCTS),true)
+pdumper.o: dmpstruct.h
+endif
+dmpstruct.h: $(srcdir)/dmpstruct.awk
+dmpstruct.h: $(libsrc)/make-fingerprint$(EXEEXT) $(dmpstruct_headers)
+       $(AM_V_GEN)POSIXLY_CORRECT=1 awk -f $(srcdir)/dmpstruct.awk \
+               $(dmpstruct_headers) > $@
+
 AUTO_DEPEND = @AUTO_DEPEND@
 DEPDIR = deps
 ifeq ($(AUTO_DEPEND),yes)
@@ -507,12 +527,12 @@ LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(LIBX_BASE) 
$(LIBIMAGE) \
    $(NOTIFY_LIBS) $(LIB_MATH) $(LIBZ) $(LIBMODULES) $(LIBSYSTEMD_LIBS) \
    $(JSON_LIBS) $(GMP_LIB)
 
-## FORCE it so that admin/unidata can decide whether these files
-## are up-to-date.  Although since charprop depends on bootstrap-emacs,
-## and emacs (which recreates bootstrap-emacs) depends on charprop,
-## in practice this rule was always run anyway.
-$(srcdir)/macuvs.h $(lispsource)/international/charprop.el: \
-  bootstrap-emacs$(EXEEXT) FORCE
+## FORCE it so that admin/unidata can decide whether this file is
+## up-to-date.  Although since charprop depends on bootstrap-emacs,
+## and emacs depends on charprop, in practice this rule was always run
+## anyway.
+$(lispsource)/international/charprop.el: \
+  FORCE | bootstrap-emacs$(EXEEXT) $(bootstrap_pdmp)
        $(MAKE) -C ../admin/unidata all EMACS="../$(bootstrap_exe)"
 
 ## We require charprop.el to exist before ucs-normalize.el is
@@ -527,7 +547,7 @@ ${lispintdir}/cp51932.el ${lispintdir}/eucjp-ms.el: FORCE
 
 charsets = ${top_srcdir}/admin/charsets/charsets.stamp
 ${charsets}: FORCE
-       ${MAKE} -C ../admin/charsets all
+       $(MAKE) -C ../admin/charsets all
 
 charscript = ${lispintdir}/charscript.el
 ${charscript}: FORCE
@@ -543,14 +563,20 @@ ${lispintdir}/characters.elc: ${charscript:.el=.elc}
 emacs$(EXEEXT): temacs$(EXEEXT) \
                 lisp.mk $(etc)/DOC $(lisp) \
                 $(lispsource)/international/charprop.el ${charsets}
-ifeq ($(CANNOT_DUMP),yes)
-       ln -f temacs$(EXEEXT) $@
-else
-       LC_ALL=C $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup dump
+ifeq ($(DUMPING),unexec)
+       LC_ALL=C $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup --temacs=dump
   ifneq ($(PAXCTL_dumped),)
-       $(PAXCTL_dumped) $@
+             $(PAXCTL_dumped) emacs$(EXEEXT)
   endif
-       ln -f $@ bootstrap-emacs$(EXEEXT)
+       cp -f $@ bootstrap-emacs$(EXEEXT)
+else
+       rm -f $@ && cp -f temacs$(EXEEXT) $@
+endif
+
+ifeq ($(DUMPING),pdumper)
+$(pdmp): emacs$(EXEEXT)
+       LC_ALL=C $(RUN_TEMACS) -batch $(BUILD_DETAILS) -l loadup --temacs=pdump
+       cp -f $@ $(bootstrap_pdmp)
 endif
 
 ## We run make-docfile twice because the command line may get too long
@@ -572,8 +598,9 @@ $(etc)/DOC: lisp.mk $(libsrc)/make-docfile$(EXEEXT) $(obj) 
$(lisp)
        $(AM_V_at)$(libsrc)/make-docfile -a $(etc)/DOC -d $(lispsource) \
          $(shortlisp)
 
-$(libsrc)/make-docfile$(EXEEXT): $(lib)/libgnu.a
-       $(MAKE) -C $(libsrc) make-docfile$(EXEEXT)
+$(libsrc)/make-docfile$(EXEEXT) $(libsrc)/make-fingerprint$(EXEEXT): \
+  $(lib)/libgnu.a
+       $(MAKE) -C $(dir $@) $(notdir $@)
 
 buildobj.h: Makefile
        $(AM_V_GEN)for i in $(ALLOBJS); do \
@@ -601,18 +628,29 @@ $(ALLOBJS): globals.h
 LIBEGNU_ARCHIVE = $(lib)/lib$(if $(HYBRID_MALLOC),e)gnu.a
 
 $(LIBEGNU_ARCHIVE): $(config_h)
-       $(MAKE) -C $(lib) all
+       $(MAKE) -C $(dir $@) all
+
+ifeq ($(HAVE_PDUMPER),yes)
+  MAKE_PDUMPER_FINGERPRINT = $(libsrc)/make-fingerprint$(EXEEXT)
+else
+  MAKE_PDUMPER_FINGERPRINT =
+endif
 
 ## We have to create $(etc) here because init_cmdargs tests its
 ## existence when setting Vinstallation_directory (FIXME?).
 ## This goes on to affect various things, and the emacs binary fails
 ## to start if Vinstallation_directory has the wrong value.
-temacs$(EXEEXT): $(LIBXMENU) $(ALLOBJS) \
-                $(LIBEGNU_ARCHIVE) $(EMACSRES) ${charsets} ${charscript}
-       $(AM_V_CCLD)$(CC) $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \
-         -o temacs $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(W32_RES_LINK) $(LIBES)
+temacs$(EXEEXT): $(LIBXMENU) $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(EMACSRES) \
+  $(charsets) $(charscript) $(MAKE_PDUMPER_FINGERPRINT)
+       $(AM_V_CCLD)$(CC) -o address@hidden \
+         $(ALL_CFLAGS) $(TEMACS_LDFLAGS) $(LDFLAGS) \
+         $(ALLOBJS) $(LIBEGNU_ARCHIVE) $(W32_RES_LINK) $(LIBES)
+ifeq ($(HAVE_PDUMPER),yes)
+       $(AM_V_at)$(MAKE_PDUMPER_FINGERPRINT) address@hidden
+endif
+       $(AM_V_at)mv address@hidden $@
        $(MKDIR_P) $(etc)
-ifneq ($(CANNOT_DUMP),yes)
+ifeq ($(DUMPING),unexec)
   ifneq ($(PAXCTL_notdumped),)
        $(PAXCTL_notdumped) $@
   endif
@@ -621,15 +659,15 @@ endif
 ## The following oldxmenu-related rules are only (possibly) used if
 ## HAVE_X11 && !USE_GTK, but there is no harm in always defining them.
 $(lwlibdir)/liblw.a: $(config_h) globals.h lisp.h FORCE
-       $(MAKE) -C $(lwlibdir) liblw.a
+       $(MAKE) -C $(dir $@) $(notdir $@)
 $(oldXMenudir)/libXMenu11.a: FORCE
-       $(MAKE) -C $(oldXMenudir) libXMenu11.a
+       $(MAKE) -C $(dir $@) $(notdir $@)
 FORCE:
 .PHONY: FORCE
 
 .PRECIOUS: ../config.status Makefile
 ../config.status: $(top_srcdir)/configure.ac $(top_srcdir)/m4/*.m4
-       $(MAKE) -C .. $(notdir $@)
+       $(MAKE) -C $(dir $@) $(notdir $@)
 Makefile: ../config.status $(srcdir)/Makefile.in
        $(MAKE) -C .. src/$@
 
@@ -639,7 +677,7 @@ emacs.res: FORCE
        $(MAKE) -C ../nt ../src/emacs.res
 
 .PHONY: ns-app
-ns-app: emacs$(EXEEXT)
+ns-app: emacs$(EXEEXT) $(pdmp)
        $(MAKE) -C ../nextstep all
 
 .PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean
@@ -647,13 +685,17 @@ ns-app: emacs$(EXEEXT)
 
 mostlyclean:
        rm -f temacs$(EXEEXT) core ./*.core \#* ./*.o
+       rm -f dmpstruct.h
+       rm -f emacs.pdmp
        rm -f ../etc/DOC
-       rm -f bootstrap-emacs$(EXEEXT) emacs-$(version)$(EXEEXT)
+       rm -f bootstrap-emacs$(EXEEXT) $(bootstrap_pdmp)
+       rm -f emacs-$(version)$(EXEEXT)
        rm -f buildobj.h
        rm -f globals.h gl-stamp
        rm -f ./*.res ./*.tmp
 clean: mostlyclean
-       rm -f emacs-*.*.*[0-9]$(EXEEXT) emacs$(EXEEXT) $(DEPDIR)/*
+       rm -f emacs-*.*.*[0-9]$(EXEEXT) emacs-*.*.*[0-9].pdmp
+       rm -f emacs$(EXEEXT) $(DEPDIR)/*
 
 ## bootstrap-clean is used to clean up just before a bootstrap.
 ## It should remove all files generated during a compilation/bootstrap,
@@ -681,9 +723,11 @@ extraclean: distclean
 ETAGS = ../lib-src/etags${EXEEXT}
 
 ${ETAGS}: FORCE
-       ${MAKE} -C ../lib-src $(notdir $@)
+       $(MAKE) -C $(dir $@) $(notdir $@)
 
-ctagsfiles1 = $(wildcard ${srcdir}/*.[hc])
+# Remove macuvs.h since it'd cause `src/emacs`
+# to be built before we can get TAGS.
+ctagsfiles1 = $(filter-out ${srcdir}/macuvs.h, $(wildcard ${srcdir}/*.[hc]))
 ctagsfiles2 = $(wildcard ${srcdir}/*.m)
 
 ## In out-of-tree builds, TAGS are generated in the build dir, like
@@ -703,11 +747,8 @@ TAGS: ${ETAGS} $(ctagsfiles1) $(ctagsfiles2)
 
 ## Arrange to make tags tables for ../lisp and ../lwlib,
 ## which the above TAGS file for the C files includes by reference.
-../lisp/TAGS: FORCE
-       $(MAKE) -C ../lisp TAGS ETAGS="$(ETAGS)"
-
-$(lwlibdir)/TAGS: FORCE
-       $(MAKE) -C $(lwlibdir) TAGS ETAGS="$(ETAGS)"
+../lisp/TAGS $(lwlibdir)/TAGS: FORCE
+       $(MAKE) -C $(dir $@) $(notdir $@) ETAGS="$(ETAGS)"
 
 tags: TAGS ../lisp/TAGS $(lwlibdir)/TAGS
 .PHONY: tags
@@ -733,7 +774,7 @@ tags: TAGS ../lisp/TAGS $(lwlibdir)/TAGS
 ## but now that we require GNU make, we can simply specify
 ## bootstrap-emacs$(EXEEXT) as an order-only prerequisite.
 
-%.elc: %.el | bootstrap-emacs$(EXEEXT)
+%.elc: %.el | bootstrap-emacs$(EXEEXT) $(bootstrap_pdmp)
        @$(MAKE) -C ../lisp EMACS="$(bootstrap_exe)" THEFILE=$< $<c
 
 ## VCSWITNESS points to the file that holds info about the current checkout.
@@ -741,24 +782,35 @@ tags: TAGS ../lisp/TAGS $(lwlibdir)/TAGS
 ## If empty it is ignored; the parent makefile can set it to some other value.
 VCSWITNESS =
 
-$(lispsource)/loaddefs.el: $(VCSWITNESS) | bootstrap-emacs$(EXEEXT)
+$(lispsource)/loaddefs.el: $(VCSWITNESS) | \
+               bootstrap-emacs$(EXEEXT) $(bootstrap_pdmp)
        $(MAKE) -C ../lisp autoloads EMACS="$(bootstrap_exe)"
 
 ## Dump an Emacs executable named bootstrap-emacs containing the
 ## files from loadup.el in source form.
+
 bootstrap-emacs$(EXEEXT): temacs$(EXEEXT)
        $(MAKE) -C ../lisp update-subdirs
-ifeq ($(CANNOT_DUMP),yes)
-       ln -f temacs$(EXEEXT) $@
-else
-       $(RUN_TEMACS) --batch $(BUILD_DETAILS) --load loadup bootstrap
+ifeq ($(DUMPING),unexec)
+       $(RUN_TEMACS) --batch $(BUILD_DETAILS) -l loadup --temacs=bootstrap
   ifneq ($(PAXCTL_dumped),)
        $(PAXCTL_dumped) emacs$(EXEEXT)
   endif
-       mv -f emacs$(EXEEXT) $@
+       mv -f emacs$(EXEEXT) bootstrap-emacs$(EXEEXT)
+       @: Compile some files earlier to speed up further compilation.
+       $(MAKE) -C ../lisp compile-first EMACS="$(bootstrap_exe)"
+else
+       @: In the pdumper case, make compile-first after the dump
+       cp -f temacs$(EXEEXT) bootstrap-emacs$(EXEEXT)
 endif
+
+ifeq ($(DUMPING),pdumper)
+$(bootstrap_pdmp): bootstrap-emacs$(EXEEXT)
+       rm -f $@
+       $(RUN_TEMACS) --batch $(BUILD_DETAILS) -l loadup --temacs=pbootstrap
        @: Compile some files earlier to speed up further compilation.
        $(MAKE) -C ../lisp compile-first EMACS="$(bootstrap_exe)"
+endif
 
 ### Flymake support (for C only)
 check-syntax:
diff --git a/src/README b/src/README
index 9ac9216..9a267af 100644
--- a/src/README
+++ b/src/README
@@ -1,4 +1,4 @@
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 
diff --git a/src/alloc.c b/src/alloc.c
index 503ef98..948a0e8 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -1,6 +1,6 @@
 /* Storage allocation and gc for GNU Emacs Lisp interpreter.
 
-Copyright (C) 1985-1986, 1988, 1993-1995, 1997-2018 Free Software
+Copyright (C) 1985-1986, 1988, 1993-1995, 1997-2019 Free Software
 Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -21,6 +21,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include <config.h>
 
 #include <errno.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <limits.h>            /* For CHAR_BIT.  */
@@ -44,6 +45,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "keyboard.h"
 #include "frame.h"
 #include "blockinput.h"
+#include "pdumper.h"
 #include "termhooks.h"         /* For struct terminal.  */
 #ifdef HAVE_WINDOW_SYSTEM
 #include TERM_HEADER
@@ -65,16 +67,13 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 # include <malloc.h>
 #endif
 
-#if (defined ENABLE_CHECKING                   \
-     && defined HAVE_VALGRIND_VALGRIND_H       \
-     && !defined USE_VALGRIND)
+#if defined HAVE_VALGRIND_VALGRIND_H && !defined USE_VALGRIND
 # define USE_VALGRIND 1
 #endif
 
 #if USE_VALGRIND
 #include <valgrind/valgrind.h>
 #include <valgrind/memcheck.h>
-static bool valgrind_p;
 #endif
 
 /* GC_CHECK_MARKED_OBJECTS means do sanity checks on allocated objects.
@@ -105,24 +104,12 @@ static bool valgrind_p;
 #include "w32heap.h"   /* for sbrk */
 #endif
 
-#if defined GNU_LINUX && !defined CANNOT_DUMP
-/* The address where the heap starts.  */
-void *
-my_heap_start (void)
-{
-  static void *start;
-  if (! start)
-    start = sbrk (0);
-  return start;
-}
-#endif
-
 #ifdef DOUG_LEA_MALLOC
 
 /* Specify maximum number of areas to mmap.  It would be nice to use a
    value that explicitly means "no limit".  */
 
-#define MMAP_MAX_AREAS 100000000
+# define MMAP_MAX_AREAS 100000000
 
 /* A pointer to the memory allocated that copies that static data
    inside glibc's malloc.  */
@@ -138,9 +125,9 @@ malloc_initialize_hook (void)
 
   if (! initialized)
     {
-#ifdef GNU_LINUX
+# ifdef GNU_LINUX
       my_heap_start ();
-#endif
+# endif
       malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL;
     }
   else
@@ -165,9 +152,7 @@ malloc_initialize_hook (void)
 
       if (malloc_set_state (malloc_state_ptr) != 0)
        emacs_abort ();
-# ifndef XMALLOC_OVERRUN_CHECK
       alloc_unexec_post ();
-# endif
     }
 }
 
@@ -182,7 +167,7 @@ voidfuncptr __MALLOC_HOOK_VOLATILE __malloc_initialize_hook 
EXTERNALLY_VISIBLE
 
 #endif
 
-#if defined DOUG_LEA_MALLOC || !defined CANNOT_DUMP
+#if defined DOUG_LEA_MALLOC || defined HAVE_UNEXEC
 
 /* Allocator-related actions to do just before and after unexec.  */
 
@@ -194,9 +179,6 @@ alloc_unexec_pre (void)
   if (!malloc_state_ptr)
     fatal ("malloc_get_state: %s", strerror (errno));
 # endif
-# ifdef HYBRID_MALLOC
-  bss_sbrk_did_unexec = true;
-# endif
 }
 
 void
@@ -205,22 +187,33 @@ alloc_unexec_post (void)
 # ifdef DOUG_LEA_MALLOC
   free (malloc_state_ptr);
 # endif
-# ifdef HYBRID_MALLOC
-  bss_sbrk_did_unexec = false;
-# endif
 }
+
+# ifdef GNU_LINUX
+
+/* The address where the heap starts.  */
+void *
+my_heap_start (void)
+{
+  static void *start;
+  if (! start)
+    start = sbrk (0);
+  return start;
+}
+# endif
+
 #endif
 
 /* Mark, unmark, query mark bit of a Lisp string.  S must be a pointer
    to a struct Lisp_String.  */
 
-#define MARK_STRING(S)         ((S)->u.s.size |= ARRAY_MARK_FLAG)
-#define UNMARK_STRING(S)       ((S)->u.s.size &= ~ARRAY_MARK_FLAG)
-#define STRING_MARKED_P(S)     (((S)->u.s.size & ARRAY_MARK_FLAG) != 0)
+#define XMARK_STRING(S)                ((S)->u.s.size |= ARRAY_MARK_FLAG)
+#define XUNMARK_STRING(S)      ((S)->u.s.size &= ~ARRAY_MARK_FLAG)
+#define XSTRING_MARKED_P(S)    (((S)->u.s.size & ARRAY_MARK_FLAG) != 0)
 
-#define VECTOR_MARK(V)         ((V)->header.size |= ARRAY_MARK_FLAG)
-#define VECTOR_UNMARK(V)       ((V)->header.size &= ~ARRAY_MARK_FLAG)
-#define VECTOR_MARKED_P(V)     (((V)->header.size & ARRAY_MARK_FLAG) != 0)
+#define XMARK_VECTOR(V)                ((V)->header.size |= ARRAY_MARK_FLAG)
+#define XUNMARK_VECTOR(V)      ((V)->header.size &= ~ARRAY_MARK_FLAG)
+#define XVECTOR_MARKED_P(V)    (((V)->header.size & ARRAY_MARK_FLAG) != 0)
 
 /* Default value of gc_cons_threshold (see below).  */
 
@@ -231,26 +224,40 @@ struct emacs_globals globals;
 
 /* Number of bytes of consing done since the last gc.  */
 
-EMACS_INT consing_since_gc;
+byte_ct consing_since_gc;
 
 /* Similar minimum, computed from Vgc_cons_percentage.  */
 
-EMACS_INT gc_relative_threshold;
-
-/* Minimum number of bytes of consing since GC before next GC,
-   when memory is full.  */
+byte_ct gc_relative_threshold;
 
-EMACS_INT memory_full_cons_threshold;
+#ifdef HAVE_PDUMPER
+/* Number of finalizers run: used to loop over GC until we stop
+   generating garbage.  */
+int number_finalizers_run;
+#endif
 
 /* True during GC.  */
 
 bool gc_in_progress;
 
+/* Type of object counts reported by GC.  Unlike byte_ct, this can be
+   signed, e.g., it is less than 2**31 on a typical 32-bit machine.  */
+
+typedef intptr_t object_ct;
+
 /* Number of live and free conses etc.  */
 
-static EMACS_INT total_conses, total_symbols, total_buffers;
-static EMACS_INT total_free_conses, total_free_symbols;
-static EMACS_INT total_free_floats, total_floats;
+static struct gcstat
+{
+  object_ct total_conses, total_free_conses;
+  object_ct total_symbols, total_free_symbols;
+  object_ct total_strings, total_free_strings;
+  byte_ct total_string_bytes;
+  object_ct total_vectors, total_vector_slots, total_free_vector_slots;
+  object_ct total_floats, total_free_floats;
+  object_ct total_intervals, total_free_intervals;
+  object_ct total_buffers;
+} gcstat;
 
 /* Points to memory space allocated as "spare", to be freed if we run
    out of memory.  We keep one large block, four cons-blocks, and
@@ -370,6 +377,27 @@ static void compact_small_strings (void);
 static void free_large_strings (void);
 extern Lisp_Object which_symbols (Lisp_Object, EMACS_INT) EXTERNALLY_VISIBLE;
 
+/* Forward declare mark accessor functions: they're used all over the
+   place.  */
+
+inline static bool vector_marked_p (const struct Lisp_Vector *v);
+inline static void set_vector_marked (struct Lisp_Vector *v);
+
+inline static bool vectorlike_marked_p (const union vectorlike_header *v);
+inline static void set_vectorlike_marked (union vectorlike_header *v);
+
+inline static bool cons_marked_p (const struct Lisp_Cons *c);
+inline static void set_cons_marked (struct Lisp_Cons *c);
+
+inline static bool string_marked_p (const struct Lisp_String *s);
+inline static void set_string_marked (struct Lisp_String *s);
+
+inline static bool symbol_marked_p (const struct Lisp_Symbol *s);
+inline static void set_symbol_marked (struct Lisp_Symbol *s);
+
+inline static bool interval_marked_p (INTERVAL i);
+inline static void set_interval_marked (INTERVAL i);
+
 /* When scanning the C stack for live Lisp objects, Emacs keeps track of
    what memory allocated via lisp_malloc and lisp_align_malloc is intended
    for what purpose.  This enumeration specifies the type of memory.  */
@@ -395,7 +423,10 @@ enum mem_type
 /* A unique object in pure space used to make some Lisp objects
    on free lists recognizable in O(1).  */
 
-static Lisp_Object Vdead;
+#ifndef ENABLE_CHECKING
+static
+#endif
+Lisp_Object Vdead;
 #define DEADP(x) EQ (x, Vdead)
 
 #ifdef GC_MALLOC_CHECK
@@ -473,30 +504,21 @@ static struct mem_node *mem_find (void *);
 #endif
 
 /* Addresses of staticpro'd variables.  Initialize it to a nonzero
-   value; otherwise some compilers put it into BSS.  */
+   value if we might unexec; otherwise some compilers put it into
+   BSS.  */
 
-enum { NSTATICS = 2048 };
-static Lisp_Object *staticvec[NSTATICS] = {&Vpurify_flag};
+Lisp_Object const *staticvec[NSTATICS]
+#ifdef HAVE_UNEXEC
+= {&Vpurify_flag}
+#endif
+  ;
 
 /* Index of next unused slot in staticvec.  */
 
-static int staticidx;
+int staticidx;
 
 static void *pure_alloc (size_t, int);
 
-/* True if N is a power of 2.  N should be positive.  */
-
-#define POWER_OF_2(n) (((n) & ((n) - 1)) == 0)
-
-/* Return X rounded to the next multiple of Y.  Y should be positive,
-   and Y - 1 + X should not overflow.  Arguments should not have side
-   effects, as they are evaluated more than once.  Tune for Y being a
-   power of 2.  */
-
-#define ROUNDUP(x, y) (POWER_OF_2 (y)                                  \
-                      ? ((y) - 1 + (x)) & ~ ((y) - 1)                  \
-                      : ((y) - 1 + (x)) - ((y) - 1 + (x)) % (y))
-
 /* Return PTR rounded up to the next multiple of ALIGNMENT.  */
 
 static void *
@@ -505,46 +527,16 @@ pointer_align (void *ptr, int alignment)
   return (void *) ROUNDUP ((uintptr_t) ptr, alignment);
 }
 
-/* Define PNTR_ADD and XPNTR as functions, which are cleaner and can
-   be used in debuggers.  Also, define them as macros if
-   DEFINE_KEY_OPS_AS_MACROS, for performance in that case.
-   The macro_* macros are private to this section of code.  */
-
-/* Add a pointer P to an integer I without gcc -fsanitize complaining
-   about the result being out of range of the underlying array.  */
-
-#define macro_PNTR_ADD(p, i) ((p) + (i))
-
-static ATTRIBUTE_NO_SANITIZE_UNDEFINED ATTRIBUTE_UNUSED char *
-PNTR_ADD (char *p, EMACS_UINT i)
-{
-  return macro_PNTR_ADD (p, i);
-}
-
-#if DEFINE_KEY_OPS_AS_MACROS
-# define PNTR_ADD(p, i) macro_PNTR_ADD (p, i)
-#endif
-
 /* Extract the pointer hidden within O.  */
 
-#define macro_XPNTR(o)                                                 \
-  ((void *) \
-   (SYMBOLP (o)                                                               \
-    ? PNTR_ADD ((char *) lispsym,                                     \
-               (XLI (o)                                                \
-                - ((EMACS_UINT) Lisp_Symbol << (USE_LSB_TAG ? 0 : VALBITS)))) \
-    : (char *) XLP (o) - (XLI (o) & ~VALMASK)))
-
-static ATTRIBUTE_UNUSED void *
+static ATTRIBUTE_NO_SANITIZE_UNDEFINED void *
 XPNTR (Lisp_Object a)
 {
-  return macro_XPNTR (a);
+  return (SYMBOLP (a)
+         ? (char *) lispsym + (XLI (a) - LISP_WORD_TAG (Lisp_Symbol))
+         : (char *) XLP (a) - (XLI (a) & ~VALMASK));
 }
 
-#if DEFINE_KEY_OPS_AS_MACROS
-# define XPNTR(a) macro_XPNTR (a)
-#endif
-
 static void
 XFLOAT_INIT (Lisp_Object f, double n)
 {
@@ -566,18 +558,18 @@ mmap_lisp_allowed_p (void)
      over our address space.  We also can't use mmap for lisp objects
      if we might dump: unexec doesn't preserve the contents of mmapped
      regions.  */
-  return pointers_fit_in_lispobj_p () && !might_dump;
+  return pointers_fit_in_lispobj_p () && !will_dump_with_unexec_p ();
 }
 #endif
 
 /* Head of a circularly-linked list of extant finalizers. */
-static struct Lisp_Finalizer finalizers;
+struct Lisp_Finalizer finalizers;
 
 /* Head of a circularly-linked list of finalizers that must be invoked
    because we deemed them unreachable.  This list must be global, and
    not a local inside garbage_collect_1, in case we GC again while
    running finalizers.  */
-static struct Lisp_Finalizer doomed_finalizers;
+struct Lisp_Finalizer doomed_finalizers;
 
 
 /************************************************************************
@@ -658,171 +650,6 @@ verify (LISP_ALIGNMENT % GCALIGNMENT == 0);
    it never does anything that requires an alignment of 16.  */
 enum { MALLOC_IS_LISP_ALIGNED = alignof (max_align_t) % LISP_ALIGNMENT == 0 };
 
-#ifndef XMALLOC_OVERRUN_CHECK
-#define XMALLOC_OVERRUN_CHECK_OVERHEAD 0
-#else
-
-/* Check for overrun in malloc'ed buffers by wrapping a header and trailer
-   around each block.
-
-   The header consists of XMALLOC_OVERRUN_CHECK_SIZE fixed bytes
-   followed by XMALLOC_OVERRUN_SIZE_SIZE bytes containing the original
-   block size in little-endian order.  The trailer consists of
-   XMALLOC_OVERRUN_CHECK_SIZE fixed bytes.
-
-   The header is used to detect whether this block has been allocated
-   through these functions, as some low-level libc functions may
-   bypass the malloc hooks.  */
-
-#define XMALLOC_OVERRUN_CHECK_SIZE 16
-#define XMALLOC_OVERRUN_CHECK_OVERHEAD \
-  (2 * XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE)
-
-/* Define XMALLOC_OVERRUN_SIZE_SIZE so that (1) it's large enough to
-   hold a size_t value and (2) the header size is a multiple of the
-   alignment that Emacs needs for C types and for USE_LSB_TAG.  */
-#define XMALLOC_OVERRUN_SIZE_SIZE                              \
-   (((XMALLOC_OVERRUN_CHECK_SIZE + sizeof (size_t)             \
-      + LISP_ALIGNMENT - 1)                                    \
-     / LISP_ALIGNMENT * LISP_ALIGNMENT)                                \
-    - XMALLOC_OVERRUN_CHECK_SIZE)
-
-static char const xmalloc_overrun_check_header[XMALLOC_OVERRUN_CHECK_SIZE] =
-  { '\x9a', '\x9b', '\xae', '\xaf',
-    '\xbf', '\xbe', '\xce', '\xcf',
-    '\xea', '\xeb', '\xec', '\xed',
-    '\xdf', '\xde', '\x9c', '\x9d' };
-
-static char const xmalloc_overrun_check_trailer[XMALLOC_OVERRUN_CHECK_SIZE] =
-  { '\xaa', '\xab', '\xac', '\xad',
-    '\xba', '\xbb', '\xbc', '\xbd',
-    '\xca', '\xcb', '\xcc', '\xcd',
-    '\xda', '\xdb', '\xdc', '\xdd' };
-
-/* Insert and extract the block size in the header.  */
-
-static void
-xmalloc_put_size (unsigned char *ptr, size_t size)
-{
-  int i;
-  for (i = 0; i < XMALLOC_OVERRUN_SIZE_SIZE; i++)
-    {
-      *--ptr = size & ((1 << CHAR_BIT) - 1);
-      size >>= CHAR_BIT;
-    }
-}
-
-static size_t
-xmalloc_get_size (unsigned char *ptr)
-{
-  size_t size = 0;
-  int i;
-  ptr -= XMALLOC_OVERRUN_SIZE_SIZE;
-  for (i = 0; i < XMALLOC_OVERRUN_SIZE_SIZE; i++)
-    {
-      size <<= CHAR_BIT;
-      size += *ptr++;
-    }
-  return size;
-}
-
-
-/* Like malloc, but wraps allocated block with header and trailer.  */
-
-static void *
-overrun_check_malloc (size_t size)
-{
-  register unsigned char *val;
-  if (SIZE_MAX - XMALLOC_OVERRUN_CHECK_OVERHEAD < size)
-    emacs_abort ();
-
-  val = malloc (size + XMALLOC_OVERRUN_CHECK_OVERHEAD);
-  if (val)
-    {
-      memcpy (val, xmalloc_overrun_check_header, XMALLOC_OVERRUN_CHECK_SIZE);
-      val += XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE;
-      xmalloc_put_size (val, size);
-      memcpy (val + size, xmalloc_overrun_check_trailer,
-             XMALLOC_OVERRUN_CHECK_SIZE);
-    }
-  return val;
-}
-
-
-/* Like realloc, but checks old block for overrun, and wraps new block
-   with header and trailer.  */
-
-static void *
-overrun_check_realloc (void *block, size_t size)
-{
-  register unsigned char *val = (unsigned char *) block;
-  if (SIZE_MAX - XMALLOC_OVERRUN_CHECK_OVERHEAD < size)
-    emacs_abort ();
-
-  if (val
-      && memcmp (xmalloc_overrun_check_header,
-                val - XMALLOC_OVERRUN_CHECK_SIZE - XMALLOC_OVERRUN_SIZE_SIZE,
-                XMALLOC_OVERRUN_CHECK_SIZE) == 0)
-    {
-      size_t osize = xmalloc_get_size (val);
-      if (memcmp (xmalloc_overrun_check_trailer, val + osize,
-                 XMALLOC_OVERRUN_CHECK_SIZE))
-       emacs_abort ();
-      memset (val + osize, 0, XMALLOC_OVERRUN_CHECK_SIZE);
-      val -= XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE;
-      memset (val, 0, XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE);
-    }
-
-  val = realloc (val, size + XMALLOC_OVERRUN_CHECK_OVERHEAD);
-
-  if (val)
-    {
-      memcpy (val, xmalloc_overrun_check_header, XMALLOC_OVERRUN_CHECK_SIZE);
-      val += XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE;
-      xmalloc_put_size (val, size);
-      memcpy (val + size, xmalloc_overrun_check_trailer,
-             XMALLOC_OVERRUN_CHECK_SIZE);
-    }
-  return val;
-}
-
-/* Like free, but checks block for overrun.  */
-
-static void
-overrun_check_free (void *block)
-{
-  unsigned char *val = (unsigned char *) block;
-
-  if (val
-      && memcmp (xmalloc_overrun_check_header,
-                val - XMALLOC_OVERRUN_CHECK_SIZE - XMALLOC_OVERRUN_SIZE_SIZE,
-                XMALLOC_OVERRUN_CHECK_SIZE) == 0)
-    {
-      size_t osize = xmalloc_get_size (val);
-      if (memcmp (xmalloc_overrun_check_trailer, val + osize,
-                 XMALLOC_OVERRUN_CHECK_SIZE))
-       emacs_abort ();
-#ifdef XMALLOC_CLEAR_FREE_MEMORY
-      val -= XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE;
-      memset (val, 0xff, osize + XMALLOC_OVERRUN_CHECK_OVERHEAD);
-#else
-      memset (val + osize, 0, XMALLOC_OVERRUN_CHECK_SIZE);
-      val -= XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE;
-      memset (val, 0, XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE);
-#endif
-    }
-
-  free (val);
-}
-
-#undef malloc
-#undef realloc
-#undef free
-#define malloc overrun_check_malloc
-#define realloc overrun_check_realloc
-#define free overrun_check_free
-#endif
-
 /* If compiled with XMALLOC_BLOCK_INPUT_CHECK, define a symbol
    BLOCK_INPUT_IN_MEMORY_ALLOCATORS that is visible to the debugger.
    If that variable is set, block input while in one of Emacs's memory
@@ -896,7 +723,7 @@ xzalloc (size_t size)
   return val;
 }
 
-/* Like realloc but check for no memory and block interrupt input..  */
+/* Like realloc but check for no memory and block interrupt input.  */
 
 void *
 xrealloc (void *block, size_t size)
@@ -926,6 +753,8 @@ xfree (void *block)
 {
   if (!block)
     return;
+  if (pdumper_object_p (block))
+    return;
   MALLOC_BLOCK_INPUT;
   free (block);
   MALLOC_UNBLOCK_INPUT;
@@ -1148,6 +977,9 @@ lisp_malloc (size_t nbytes, enum mem_type type)
 static void
 lisp_free (void *block)
 {
+  if (pdumper_object_p (block))
+    return;
+
   MALLOC_BLOCK_INPUT;
   free (block);
 #ifndef GC_MALLOC_CHECK
@@ -1167,9 +999,9 @@ verify (POWER_OF_2 (BLOCK_ALIGN));
 
 /* Use aligned_alloc if it or a simple substitute is available.
    Aligned allocation is incompatible with unexmacosx.c, so don't use
-   it on Darwin unless CANNOT_DUMP.  */
+   it on Darwin if HAVE_UNEXEC.  */
 
-#if !defined DARWIN_OS || defined CANNOT_DUMP
+#if ! (defined DARWIN_OS && defined HAVE_UNEXEC)
 # if (defined HAVE_ALIGNED_ALLOC                                       \
       || (defined HYBRID_MALLOC                                                
\
          ? defined HAVE_POSIX_MEMALIGN                                 \
@@ -1513,10 +1345,6 @@ static struct interval_block *interval_block;
 
 static int interval_block_index = INTERVAL_BLOCK_SIZE;
 
-/* Number of free and live intervals.  */
-
-static EMACS_INT total_free_intervals, total_intervals;
-
 /* List of free intervals.  */
 
 static INTERVAL interval_free_list;
@@ -1545,7 +1373,7 @@ make_interval (void)
          newi->next = interval_block;
          interval_block = newi;
          interval_block_index = 0;
-         total_free_intervals += INTERVAL_BLOCK_SIZE;
+         gcstat.total_free_intervals += INTERVAL_BLOCK_SIZE;
        }
       val = &interval_block->intervals[interval_block_index++];
     }
@@ -1554,7 +1382,7 @@ make_interval (void)
 
   consing_since_gc += sizeof (struct interval);
   intervals_consed++;
-  total_free_intervals--;
+  gcstat.total_free_intervals--;
   RESET_INTERVAL (val);
   val->gcmarkbit = 0;
   return val;
@@ -1564,22 +1392,23 @@ make_interval (void)
 /* Mark Lisp objects in interval I.  */
 
 static void
-mark_interval (INTERVAL i, void *dummy)
+mark_interval_tree_1 (INTERVAL i, void *dummy)
 {
   /* Intervals should never be shared.  So, if extra internal checking is
      enabled, GC aborts if it seems to have visited an interval twice.  */
-  eassert (!i->gcmarkbit);
-  i->gcmarkbit = 1;
+  eassert (!interval_marked_p (i));
+  set_interval_marked (i);
   mark_object (i->plist);
 }
 
 /* Mark the interval tree rooted in I.  */
 
-#define MARK_INTERVAL_TREE(i)                                  \
-  do {                                                         \
-    if (i && !i->gcmarkbit)                                    \
-      traverse_intervals_noorder (i, mark_interval, NULL);     \
-  } while (0)
+static void
+mark_interval_tree (INTERVAL i)
+{
+  if (i && !interval_marked_p (i))
+    traverse_intervals_noorder (i, mark_interval_tree_1, NULL);
+}
 
 /***********************************************************************
                          String Allocation
@@ -1729,14 +1558,6 @@ static struct string_block *string_blocks;
 
 static struct Lisp_String *string_free_list;
 
-/* Number of live and free Lisp_Strings.  */
-
-static EMACS_INT total_strings, total_free_strings;
-
-/* Number of bytes used by live strings.  */
-
-static EMACS_INT total_string_bytes;
-
 /* Given a pointer to a Lisp_String S which is on the free-list
    string_free_list, return a pointer to its successor in the
    free-list.  */
@@ -1754,16 +1575,15 @@ static EMACS_INT total_string_bytes;
 
 #ifdef GC_CHECK_STRING_OVERRUN
 
-/* We check for overrun in string data blocks by appending a small
+/* Check for overrun in string data blocks by appending a small
    "cookie" after each allocated string data block, and check for the
    presence of this cookie during GC.  */
-
-#define GC_STRING_OVERRUN_COOKIE_SIZE  4
+# define GC_STRING_OVERRUN_COOKIE_SIZE ROUNDUP (4, alignof (sdata))
 static char const string_overrun_cookie[GC_STRING_OVERRUN_COOKIE_SIZE] =
-  { '\xde', '\xad', '\xbe', '\xef' };
+  { '\xde', '\xad', '\xbe', '\xef', /* Perhaps some zeros here.  */ };
 
 #else
-#define GC_STRING_OVERRUN_COOKIE_SIZE 0
+# define GC_STRING_OVERRUN_COOKIE_SIZE 0
 #endif
 
 /* Value is the size of an sdata structure large enough to hold NBYTES
@@ -1793,17 +1613,16 @@ static char const 
string_overrun_cookie[GC_STRING_OVERRUN_COOKIE_SIZE] =
 #endif /* not GC_CHECK_STRING_BYTES */
 
 /* Extra bytes to allocate for each string.  */
-
-#define GC_STRING_EXTRA (GC_STRING_OVERRUN_COOKIE_SIZE)
+#define GC_STRING_EXTRA GC_STRING_OVERRUN_COOKIE_SIZE
 
 /* Exact bound on the number of bytes in a string, not counting the
-   terminating null.  A string cannot contain more bytes than
+   terminating NUL.  A string cannot contain more bytes than
    STRING_BYTES_BOUND, nor can it be so long that the size_t
    arithmetic in allocate_string_data would overflow while it is
    calculating a value to be passed to malloc.  */
 static ptrdiff_t const STRING_BYTES_MAX =
   min (STRING_BYTES_BOUND,
-       ((SIZE_MAX - XMALLOC_OVERRUN_CHECK_OVERHEAD
+       ((SIZE_MAX
         - GC_STRING_EXTRA
         - offsetof (struct sblock, data)
         - SDATA_DATA_OFFSET)
@@ -1815,7 +1634,9 @@ static void
 init_strings (void)
 {
   empty_unibyte_string = make_pure_string ("", 0, 0, 0);
+  staticpro (&empty_unibyte_string);
   empty_multibyte_string = make_pure_string ("", 0, 0, 1);
+  staticpro (&empty_multibyte_string);
 }
 
 
@@ -1832,7 +1653,7 @@ string_bytes (struct Lisp_String *s)
   ptrdiff_t nbytes =
     (s->u.s.size_byte < 0 ? s->u.s.size & ~ARRAY_MARK_FLAG : s->u.s.size_byte);
 
-  if (!PURE_P (s) && s->u.s.data
+  if (!PURE_P (s) && !pdumper_object_p (s) && s->u.s.data
       && nbytes != SDATA_NBYTES (SDATA_OF_STRING (s)))
     emacs_abort ();
   return nbytes;
@@ -1944,7 +1765,7 @@ allocate_string (void)
          string_free_list = ptr_bounds_clip (s, sizeof *s);
        }
 
-      total_free_strings += STRING_BLOCK_SIZE;
+      gcstat.total_free_strings += STRING_BLOCK_SIZE;
     }
 
   check_string_free_list ();
@@ -1955,8 +1776,8 @@ allocate_string (void)
 
   MALLOC_UNBLOCK_INPUT;
 
-  --total_free_strings;
-  ++total_strings;
+  gcstat.total_free_strings--;
+  gcstat.total_strings++;
   ++strings_consed;
   consing_since_gc += sizeof *s;
 
@@ -2053,6 +1874,7 @@ allocate_string_data (struct Lisp_String *s,
 
   data->string = s;
   b->next_free = (sdata *) ((char *) data + needed + GC_STRING_EXTRA);
+  eassert ((uintptr_t) b->next_free % alignof (sdata) == 0);
 
   MALLOC_UNBLOCK_INPUT;
 
@@ -2091,8 +1913,8 @@ sweep_strings (void)
   struct string_block *live_blocks = NULL;
 
   string_free_list = NULL;
-  total_strings = total_free_strings = 0;
-  total_string_bytes = 0;
+  gcstat.total_strings = gcstat.total_free_strings = 0;
+  gcstat.total_string_bytes = 0;
 
   /* Scan strings_blocks, free Lisp_Strings that aren't marked.  */
   for (b = string_blocks; b; b = next)
@@ -2109,16 +1931,16 @@ sweep_strings (void)
          if (s->u.s.data)
            {
              /* String was not on free-list before.  */
-             if (STRING_MARKED_P (s))
+             if (XSTRING_MARKED_P (s))
                {
                  /* String is live; unmark it and its intervals.  */
-                 UNMARK_STRING (s);
+                 XUNMARK_STRING (s);
 
                  /* Do not use string_(set|get)_intervals here.  */
                  s->u.s.intervals = balance_intervals (s->u.s.intervals);
 
-                 ++total_strings;
-                 total_string_bytes += STRING_BYTES (s);
+                 gcstat.total_strings++;
+                 gcstat.total_string_bytes += STRING_BYTES (s);
                }
              else
                {
@@ -2158,14 +1980,14 @@ sweep_strings (void)
       /* Free blocks that contain free Lisp_Strings only, except
         the first two of them.  */
       if (nfree == STRING_BLOCK_SIZE
-         && total_free_strings > STRING_BLOCK_SIZE)
+         && gcstat.total_free_strings > STRING_BLOCK_SIZE)
        {
          lisp_free (b);
          string_free_list = free_list_before;
        }
       else
        {
-         total_free_strings += nfree;
+         gcstat.total_free_strings += nfree;
          b->next = live_blocks;
          live_blocks = b;
        }
@@ -2614,7 +2436,8 @@ make_formatted_string (char *buf, const char *format, ...)
    &= ~((bits_word) 1 << ((n) % BITS_PER_BITS_WORD)))
 
 #define FLOAT_BLOCK(fptr) \
-  ((struct float_block *) (((uintptr_t) (fptr)) & ~(BLOCK_ALIGN - 1)))
+  (eassert (!pdumper_object_p (fptr)),                                  \
+   ((struct float_block *) (((uintptr_t) (fptr)) & ~(BLOCK_ALIGN - 1))))
 
 #define FLOAT_INDEX(fptr) \
   ((((uintptr_t) (fptr)) & (BLOCK_ALIGN - 1)) / sizeof (struct Lisp_Float))
@@ -2627,13 +2450,13 @@ struct float_block
   struct float_block *next;
 };
 
-#define FLOAT_MARKED_P(fptr) \
+#define XFLOAT_MARKED_P(fptr) \
   GETMARKBIT (FLOAT_BLOCK (fptr), FLOAT_INDEX ((fptr)))
 
-#define FLOAT_MARK(fptr) \
+#define XFLOAT_MARK(fptr) \
   SETMARKBIT (FLOAT_BLOCK (fptr), FLOAT_INDEX ((fptr)))
 
-#define FLOAT_UNMARK(fptr) \
+#define XFLOAT_UNMARK(fptr) \
   UNSETMARKBIT (FLOAT_BLOCK (fptr), FLOAT_INDEX ((fptr)))
 
 /* Current float_block.  */
@@ -2672,7 +2495,7 @@ make_float (double float_value)
          memset (new->gcmarkbits, 0, sizeof new->gcmarkbits);
          float_block = new;
          float_block_index = 0;
-         total_free_floats += FLOAT_BLOCK_SIZE;
+         gcstat.total_free_floats += FLOAT_BLOCK_SIZE;
        }
       XSETFLOAT (val, &float_block->floats[float_block_index]);
       float_block_index++;
@@ -2681,10 +2504,10 @@ make_float (double float_value)
   MALLOC_UNBLOCK_INPUT;
 
   XFLOAT_INIT (val, float_value);
-  eassert (!FLOAT_MARKED_P (XFLOAT (val)));
+  eassert (!XFLOAT_MARKED_P (XFLOAT (val)));
   consing_since_gc += sizeof (struct Lisp_Float);
   floats_consed++;
-  total_free_floats--;
+  gcstat.total_free_floats--;
   return val;
 }
 
@@ -2706,7 +2529,8 @@ make_float (double float_value)
    / (sizeof (struct Lisp_Cons) * CHAR_BIT + 1))
 
 #define CONS_BLOCK(fptr) \
-  ((struct cons_block *) ((uintptr_t) (fptr) & ~(BLOCK_ALIGN - 1)))
+  (eassert (!pdumper_object_p (fptr)),                                  \
+   ((struct cons_block *) ((uintptr_t) (fptr) & ~(BLOCK_ALIGN - 1))))
 
 #define CONS_INDEX(fptr) \
   (((uintptr_t) (fptr) & (BLOCK_ALIGN - 1)) / sizeof (struct Lisp_Cons))
@@ -2719,15 +2543,20 @@ struct cons_block
   struct cons_block *next;
 };
 
-#define CONS_MARKED_P(fptr) \
+#define XCONS_MARKED_P(fptr) \
   GETMARKBIT (CONS_BLOCK (fptr), CONS_INDEX ((fptr)))
 
-#define CONS_MARK(fptr) \
+#define XMARK_CONS(fptr) \
   SETMARKBIT (CONS_BLOCK (fptr), CONS_INDEX ((fptr)))
 
-#define CONS_UNMARK(fptr) \
+#define XUNMARK_CONS(fptr) \
   UNSETMARKBIT (CONS_BLOCK (fptr), CONS_INDEX ((fptr)))
 
+/* Minimum number of bytes of consing since GC before next GC,
+   when memory is full.  */
+
+byte_ct const memory_full_cons_threshold = sizeof (struct cons_block);
+
 /* Current cons_block.  */
 
 static struct cons_block *cons_block;
@@ -2749,7 +2578,7 @@ free_cons (struct Lisp_Cons *ptr)
   ptr->u.s.car = Vdead;
   cons_free_list = ptr;
   consing_since_gc -= sizeof *ptr;
-  total_free_conses++;
+  gcstat.total_free_conses++;
 }
 
 DEFUN ("cons", Fcons, Scons, 2, 2, 0,
@@ -2769,13 +2598,26 @@ DEFUN ("cons", Fcons, Scons, 2, 2, 0,
     {
       if (cons_block_index == CONS_BLOCK_SIZE)
        {
+         /* Maximum number of conses that should be active at any
+            given time, so that list lengths fit into a ptrdiff_t and
+            into a fixnum.  */
+         ptrdiff_t max_conses = min (PTRDIFF_MAX, MOST_POSITIVE_FIXNUM);
+
+         /* This check is typically optimized away, as a runtime
+            check is needed only on weird platforms where a count of
+            distinct conses might not fit.  */
+         if (max_conses < INTPTR_MAX / sizeof (struct Lisp_Cons)
+             && (max_conses - CONS_BLOCK_SIZE
+                 < gcstat.total_free_conses + gcstat.total_conses))
+           memory_full (sizeof (struct cons_block));
+
          struct cons_block *new
            = lisp_align_malloc (sizeof *new, MEM_TYPE_CONS);
          memset (new->gcmarkbits, 0, sizeof new->gcmarkbits);
          new->next = cons_block;
          cons_block = new;
          cons_block_index = 0;
-         total_free_conses += CONS_BLOCK_SIZE;
+         gcstat.total_free_conses += CONS_BLOCK_SIZE;
        }
       XSETCONS (val, &cons_block->conses[cons_block_index]);
       cons_block_index++;
@@ -2785,25 +2627,13 @@ DEFUN ("cons", Fcons, Scons, 2, 2, 0,
 
   XSETCAR (val, car);
   XSETCDR (val, cdr);
-  eassert (!CONS_MARKED_P (XCONS (val)));
+  eassert (!XCONS_MARKED_P (XCONS (val)));
   consing_since_gc += sizeof (struct Lisp_Cons);
-  total_free_conses--;
+  gcstat.total_free_conses--;
   cons_cells_consed++;
   return val;
 }
 
-#ifdef GC_CHECK_CONS_LIST
-/* Get an error now if there's any junk in the cons free list.  */
-void
-check_cons_list (void)
-{
-  struct Lisp_Cons *tail = cons_free_list;
-
-  while (tail)
-    tail = tail->u.s.u.chain;
-}
-#endif
-
 /* Make a list of 1, 2, 3, 4 or 5 specified objects.  */
 
 Lisp_Object
@@ -2825,50 +2655,57 @@ list3 (Lisp_Object arg1, Lisp_Object arg2, Lisp_Object 
arg3)
   return Fcons (arg1, Fcons (arg2, Fcons (arg3, Qnil)));
 }
 
-
 Lisp_Object
 list4 (Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, Lisp_Object arg4)
 {
   return Fcons (arg1, Fcons (arg2, Fcons (arg3, Fcons (arg4, Qnil))));
 }
 
-
 Lisp_Object
-list5 (Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, Lisp_Object arg4, 
Lisp_Object arg5)
+list5 (Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, Lisp_Object arg4,
+       Lisp_Object arg5)
 {
   return Fcons (arg1, Fcons (arg2, Fcons (arg3, Fcons (arg4,
                                                       Fcons (arg5, Qnil)))));
 }
 
-/* Make a list of COUNT Lisp_Objects, where ARG is the
-   first one.  Allocate conses from pure space if TYPE
-   is CONSTYPE_PURE, or allocate as usual if type is CONSTYPE_HEAP.  */
-
-Lisp_Object
-listn (enum constype type, ptrdiff_t count, Lisp_Object arg, ...)
+/* Make a list of COUNT Lisp_Objects, where ARG is the first one.
+   Use CONS to construct the pairs.  AP has any remaining args.  */
+static Lisp_Object
+cons_listn (ptrdiff_t count, Lisp_Object arg,
+           Lisp_Object (*cons) (Lisp_Object, Lisp_Object), va_list ap)
 {
-  Lisp_Object (*cons) (Lisp_Object, Lisp_Object);
-  switch (type)
-    {
-    case CONSTYPE_PURE: cons = pure_cons; break;
-    case CONSTYPE_HEAP: cons = Fcons; break;
-    default: emacs_abort ();
-    }
-
   eassume (0 < count);
   Lisp_Object val = cons (arg, Qnil);
   Lisp_Object tail = val;
-
-  va_list ap;
-  va_start (ap, arg);
   for (ptrdiff_t i = 1; i < count; i++)
     {
       Lisp_Object elem = cons (va_arg (ap, Lisp_Object), Qnil);
       XSETCDR (tail, elem);
       tail = elem;
     }
+  return val;
+}
+
+/* Make a list of COUNT Lisp_Objects, where ARG1 is the first one.  */
+Lisp_Object
+listn (ptrdiff_t count, Lisp_Object arg1, ...)
+{
+  va_list ap;
+  va_start (ap, arg1);
+  Lisp_Object val = cons_listn (count, arg1, Fcons, ap);
   va_end (ap);
+  return val;
+}
 
+/* Make a pure list of COUNT Lisp_Objects, where ARG1 is the first one.  */
+Lisp_Object
+pure_listn (ptrdiff_t count, Lisp_Object arg1, ...)
+{
+  va_list ap;
+  va_start (ap, arg1);
+  Lisp_Object val = cons_listn (count, arg1, pure_cons, ap);
+  va_end (ap);
   return val;
 }
 
@@ -3037,14 +2874,6 @@ static struct large_vector *large_vectors;
 
 Lisp_Object zero_vector;
 
-/* Number of live vectors.  */
-
-static EMACS_INT total_vectors;
-
-/* Total size of live and free vectors, in Lisp_Object units.  */
-
-static EMACS_INT total_vector_slots, total_free_vector_slots;
-
 /* Common shortcut to setup vector on a free list.  */
 
 static void
@@ -3059,7 +2888,7 @@ setup_on_free_list (struct Lisp_Vector *v, ptrdiff_t 
nbytes)
   eassert (vindex < VECTOR_MAX_FREE_LIST_INDEX);
   set_next_vector (v, vector_free_lists[vindex]);
   vector_free_lists[vindex] = v;
-  total_free_vector_slots += nbytes / word_size;
+  gcstat.total_free_vector_slots += nbytes / word_size;
 }
 
 /* Get a new vector block.  */
@@ -3085,6 +2914,7 @@ static void
 init_vectors (void)
 {
   zero_vector = make_pure_vector (0);
+  staticpro (&zero_vector);
 }
 
 /* Allocate vector from a vector block.  */
@@ -3106,7 +2936,7 @@ allocate_vector_from_block (ptrdiff_t nbytes)
     {
       vector = vector_free_lists[index];
       vector_free_lists[index] = next_vector (vector);
-      total_free_vector_slots -= nbytes / word_size;
+      gcstat.total_free_vector_slots -= nbytes / word_size;
       return vector;
     }
 
@@ -3120,7 +2950,7 @@ allocate_vector_from_block (ptrdiff_t nbytes)
        /* This vector is larger than requested.  */
        vector = vector_free_lists[index];
        vector_free_lists[index] = next_vector (vector);
-       total_free_vector_slots -= nbytes / word_size;
+       gcstat.total_free_vector_slots -= nbytes / word_size;
 
        /* Excess bytes are used for the smaller vector,
           which should be set on an appropriate free list.  */
@@ -3155,17 +2985,17 @@ allocate_vector_from_block (ptrdiff_t nbytes)
 
 /* Return the memory footprint of V in bytes.  */
 
-static ptrdiff_t
-vector_nbytes (struct Lisp_Vector *v)
+ptrdiff_t
+vectorlike_nbytes (const union vectorlike_header *hdr)
 {
-  ptrdiff_t size = v->header.size & ~ARRAY_MARK_FLAG;
+  ptrdiff_t size = hdr->size & ~ARRAY_MARK_FLAG;
   ptrdiff_t nwords;
 
   if (size & PSEUDOVECTOR_FLAG)
     {
-      if (PSEUDOVECTOR_TYPEP (&v->header, PVEC_BOOL_VECTOR))
+      if (PSEUDOVECTOR_TYPEP (hdr, PVEC_BOOL_VECTOR))
         {
-          struct Lisp_Bool_Vector *bv = (struct Lisp_Bool_Vector *) v;
+          struct Lisp_Bool_Vector *bv = (struct Lisp_Bool_Vector *) hdr;
          ptrdiff_t word_bytes = (bool_vector_words (bv->size)
                                  * sizeof (bits_word));
          ptrdiff_t boolvec_bytes = bool_header_size + word_bytes;
@@ -3231,14 +3061,12 @@ cleanup_vector (struct Lisp_Vector *vector)
       /* sweep_buffer should already have unchained this from its buffer.  */
       eassert (! PSEUDOVEC_STRUCT (vector, Lisp_Marker)->buffer);
     }
-#ifdef HAVE_MODULES
   else if (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_USER_PTR))
     {
       struct Lisp_User_Ptr *uptr = PSEUDOVEC_STRUCT (vector, Lisp_User_Ptr);
       if (uptr->finalizer)
        uptr->finalizer (uptr->p);
     }
-#endif
 }
 
 /* Reclaim space used by unmarked vectors.  */
@@ -3251,7 +3079,8 @@ sweep_vectors (void)
   struct large_vector *lv, **lvprev = &large_vectors;
   struct Lisp_Vector *vector, *next;
 
-  total_vectors = total_vector_slots = total_free_vector_slots = 0;
+  gcstat.total_vectors = 0;
+  gcstat.total_vector_slots = gcstat.total_free_vector_slots = 0;
   memset (vector_free_lists, 0, sizeof (vector_free_lists));
 
   /* Looking through vector blocks.  */
@@ -3263,12 +3092,12 @@ sweep_vectors (void)
       for (vector = (struct Lisp_Vector *) block->data;
           VECTOR_IN_BLOCK (vector, block); vector = next)
        {
-         if (VECTOR_MARKED_P (vector))
+         if (XVECTOR_MARKED_P (vector))
            {
-             VECTOR_UNMARK (vector);
-             total_vectors++;
+             XUNMARK_VECTOR (vector);
+             gcstat.total_vectors++;
              ptrdiff_t nbytes = vector_nbytes (vector);
-             total_vector_slots += nbytes / word_size;
+             gcstat.total_vector_slots += nbytes / word_size;
              next = ADVANCE (vector, nbytes);
            }
          else
@@ -3286,7 +3115,7 @@ sweep_vectors (void)
                  total_bytes += nbytes;
                  next = ADVANCE (next, nbytes);
                }
-             while (VECTOR_IN_BLOCK (next, block) && !VECTOR_MARKED_P (next));
+             while (VECTOR_IN_BLOCK (next, block) && !vector_marked_p (next));
 
              eassert (total_bytes % roundup_size == 0);
 
@@ -3317,15 +3146,14 @@ sweep_vectors (void)
   for (lv = large_vectors; lv; lv = *lvprev)
     {
       vector = large_vector_vec (lv);
-      if (VECTOR_MARKED_P (vector))
+      if (XVECTOR_MARKED_P (vector))
        {
-         VECTOR_UNMARK (vector);
-         total_vectors++;
-         if (vector->header.size & PSEUDOVECTOR_FLAG)
-            total_vector_slots += vector_nbytes (vector) / word_size;
-         else
-           total_vector_slots
-             += header_size / word_size + vector->header.size;
+         XUNMARK_VECTOR (vector);
+         gcstat.total_vectors++;
+         gcstat.total_vector_slots
+           += (vector->header.size & PSEUDOVECTOR_FLAG
+               ? vector_nbytes (vector) / word_size
+               : header_size / word_size + vector->header.size);
          lvprev = &lv->next;
        }
       else
@@ -3659,7 +3487,7 @@ Its value is void, and its function definition and 
property list are nil.  */)
          new->next = symbol_block;
          symbol_block = new;
          symbol_block_index = 0;
-         total_free_symbols += SYMBOL_BLOCK_SIZE;
+         gcstat.total_free_symbols += SYMBOL_BLOCK_SIZE;
        }
       XSETSYMBOL (val, &symbol_block->symbols[symbol_block_index]);
       symbol_block_index++;
@@ -3670,7 +3498,7 @@ Its value is void, and its function definition and 
property list are nil.  */)
   init_symbol (val, name);
   consing_since_gc += sizeof (struct Lisp_Symbol);
   symbols_consed++;
-  total_free_symbols--;
+  gcstat.total_free_symbols--;
   return val;
 }
 
@@ -3679,8 +3507,8 @@ Its value is void, and its function definition and 
property list are nil.  */)
 Lisp_Object
 make_misc_ptr (void *a)
 {
-  struct Lisp_Misc_Ptr *p = ALLOCATE_PSEUDOVECTOR (struct Lisp_Misc_Ptr, 
pointer,
-                                                  PVEC_MISC_PTR);
+  struct Lisp_Misc_Ptr *p = ALLOCATE_PLAIN_PSEUDOVECTOR (struct Lisp_Misc_Ptr,
+                                                        PVEC_MISC_PTR);
   p->pointer = a;
   return make_lisp_ptr (p, Lisp_Vectorlike);
 }
@@ -3690,7 +3518,7 @@ make_misc_ptr (void *a)
 Lisp_Object
 build_overlay (Lisp_Object start, Lisp_Object end, Lisp_Object plist)
 {
-  struct Lisp_Overlay *p = ALLOCATE_PSEUDOVECTOR (struct Lisp_Overlay, next,
+  struct Lisp_Overlay *p = ALLOCATE_PSEUDOVECTOR (struct Lisp_Overlay, plist,
                                                  PVEC_OVERLAY);
   Lisp_Object overlay = make_lisp_ptr (p, Lisp_Vectorlike);
   OVERLAY_START (overlay) = start;
@@ -3704,8 +3532,8 @@ DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0,
        doc: /* Return a newly allocated marker which does not point at any 
place.  */)
   (void)
 {
-  struct Lisp_Marker *p = ALLOCATE_PSEUDOVECTOR (struct Lisp_Marker, buffer,
-                                                PVEC_MARKER);
+  struct Lisp_Marker *p = ALLOCATE_PLAIN_PSEUDOVECTOR (struct Lisp_Marker,
+                                                      PVEC_MARKER);
   p->buffer = 0;
   p->bytepos = 0;
   p->charpos = 0;
@@ -3727,8 +3555,8 @@ build_marker (struct buffer *buf, ptrdiff_t charpos, 
ptrdiff_t bytepos)
   /* Every character is at least one byte.  */
   eassert (charpos <= bytepos);
 
-  struct Lisp_Marker *m = ALLOCATE_PSEUDOVECTOR (struct Lisp_Marker, buffer,
-                                                PVEC_MARKER);
+  struct Lisp_Marker *m = ALLOCATE_PLAIN_PSEUDOVECTOR (struct Lisp_Marker,
+                                                      PVEC_MARKER);
   m->buffer = buf;
   m->charpos = charpos;
   m->bytepos = bytepos;
@@ -3782,8 +3610,8 @@ make_event_array (ptrdiff_t nargs, Lisp_Object *args)
 Lisp_Object
 make_user_ptr (void (*finalizer) (void *), void *p)
 {
-  struct Lisp_User_Ptr *uptr = ALLOCATE_PSEUDOVECTOR (struct Lisp_User_Ptr,
-                                                     finalizer, PVEC_USER_PTR);
+  struct Lisp_User_Ptr *uptr
+    = ALLOCATE_PLAIN_PSEUDOVECTOR (struct Lisp_User_Ptr, PVEC_USER_PTR);
   uptr->finalizer = finalizer;
   uptr->p = p;
   return make_lisp_ptr (uptr, Lisp_Vectorlike);
@@ -3829,7 +3657,7 @@ mark_finalizer_list (struct Lisp_Finalizer *head)
        finalizer != head;
        finalizer = finalizer->next)
     {
-      VECTOR_MARK (finalizer);
+      set_vectorlike_marked (&finalizer->header);
       mark_object (finalizer->function);
     }
 }
@@ -3846,7 +3674,8 @@ queue_doomed_finalizers (struct Lisp_Finalizer *dest,
   while (finalizer != src)
     {
       struct Lisp_Finalizer *next = finalizer->next;
-      if (!VECTOR_MARKED_P (finalizer) && !NILP (finalizer->function))
+      if (!vectorlike_marked_p (&finalizer->header)
+          && !NILP (finalizer->function))
         {
           unchain_finalizer (finalizer);
           finalizer_insert (dest, finalizer);
@@ -3867,6 +3696,9 @@ static void
 run_finalizer_function (Lisp_Object function)
 {
   ptrdiff_t count = SPECPDL_INDEX ();
+#ifdef HAVE_PDUMPER
+  ++number_finalizers_run;
+#endif
 
   specbind (Qinhibit_quit, Qt);
   internal_condition_case_1 (call0, function, Qt, run_finalizer_handler);
@@ -3902,7 +3734,7 @@ FUNCTION.  FUNCTION will be run once per finalizer 
object.  */)
   (Lisp_Object function)
 {
   struct Lisp_Finalizer *finalizer
-    = ALLOCATE_PSEUDOVECTOR (struct Lisp_Finalizer, prev, PVEC_FINALIZER);
+    = ALLOCATE_PSEUDOVECTOR (struct Lisp_Finalizer, function, PVEC_FINALIZER);
   finalizer->function = function;
   finalizer->prev = finalizer->next = NULL;
   finalizer_insert (&finalizers, finalizer);
@@ -3911,6 +3743,126 @@ FUNCTION.  FUNCTION will be run once per finalizer 
object.  */)
 
 
 /************************************************************************
+                         Mark bit access functions
+ ************************************************************************/
+
+/* With the rare exception of functions implementing block-based
+   allocation of various types, you should not directly test or set GC
+   mark bits on objects.  Some objects might live in special memory
+   regions (e.g., a dump image) and might store their mark bits
+   elsewhere.  */
+
+static bool
+vector_marked_p (const struct Lisp_Vector *v)
+{
+  if (pdumper_object_p (v))
+    {
+      /* Look at cold_start first so that we don't have to fault in
+         the vector header just to tell that it's a bool vector.  */
+      if (pdumper_cold_object_p (v))
+        {
+          eassert (PSEUDOVECTOR_TYPE (v) == PVEC_BOOL_VECTOR);
+          return true;
+        }
+      return pdumper_marked_p (v);
+    }
+  return XVECTOR_MARKED_P (v);
+}
+
+static void
+set_vector_marked (struct Lisp_Vector *v)
+{
+  if (pdumper_object_p (v))
+    {
+      eassert (PSEUDOVECTOR_TYPE (v) != PVEC_BOOL_VECTOR);
+      pdumper_set_marked (v);
+    }
+  else
+    XMARK_VECTOR (v);
+}
+
+static bool
+vectorlike_marked_p (const union vectorlike_header *header)
+{
+  return vector_marked_p ((const struct Lisp_Vector *) header);
+}
+
+static void
+set_vectorlike_marked (union vectorlike_header *header)
+{
+  set_vector_marked ((struct Lisp_Vector *) header);
+}
+
+static bool
+cons_marked_p (const struct Lisp_Cons *c)
+{
+  return pdumper_object_p (c)
+    ? pdumper_marked_p (c)
+    : XCONS_MARKED_P (c);
+}
+
+static void
+set_cons_marked (struct Lisp_Cons *c)
+{
+  if (pdumper_object_p (c))
+    pdumper_set_marked (c);
+  else
+    XMARK_CONS (c);
+}
+
+static bool
+string_marked_p (const struct Lisp_String *s)
+{
+  return pdumper_object_p (s)
+    ? pdumper_marked_p (s)
+    : XSTRING_MARKED_P (s);
+}
+
+static void
+set_string_marked (struct Lisp_String *s)
+{
+  if (pdumper_object_p (s))
+    pdumper_set_marked (s);
+  else
+    XMARK_STRING (s);
+}
+
+static bool
+symbol_marked_p (const struct Lisp_Symbol *s)
+{
+  return pdumper_object_p (s)
+    ? pdumper_marked_p (s)
+    : s->u.s.gcmarkbit;
+}
+
+static void
+set_symbol_marked (struct Lisp_Symbol *s)
+{
+  if (pdumper_object_p (s))
+    pdumper_set_marked (s);
+  else
+    s->u.s.gcmarkbit = true;
+}
+
+static bool
+interval_marked_p (INTERVAL i)
+{
+  return pdumper_object_p (i)
+    ? pdumper_marked_p (i)
+    : i->gcmarkbit;
+}
+
+static void
+set_interval_marked (INTERVAL i)
+{
+  if (pdumper_object_p (i))
+    pdumper_set_marked (i);
+  else
+    i->gcmarkbit = true;
+}
+
+
+/************************************************************************
                           Memory Full Handling
  ************************************************************************/
 
@@ -3926,7 +3878,7 @@ void
 memory_full (size_t nbytes)
 {
   /* Do not go into hysterics merely because a large request failed.  */
-  bool enough_free_memory = 0;
+  bool enough_free_memory = false;
   if (SPARE_MEMORY < nbytes)
     {
       void *p;
@@ -3936,21 +3888,17 @@ memory_full (size_t nbytes)
       if (p)
        {
          free (p);
-         enough_free_memory = 1;
+         enough_free_memory = true;
        }
       MALLOC_UNBLOCK_INPUT;
     }
 
   if (! enough_free_memory)
     {
-      int i;
-
       Vmemory_full = Qt;
 
-      memory_full_cons_threshold = sizeof (struct cons_block);
-
       /* The first time we get here, free the spare memory.  */
-      for (i = 0; i < ARRAYELTS (spare_memory); i++)
+      for (int i = 0; i < ARRAYELTS (spare_memory); i++)
        if (spare_memory[i])
          {
            if (i == 0)
@@ -4608,14 +4556,29 @@ static void
 mark_maybe_object (Lisp_Object obj)
 {
 #if USE_VALGRIND
-  if (valgrind_p)
-    VALGRIND_MAKE_MEM_DEFINED (&obj, sizeof (obj));
+  VALGRIND_MAKE_MEM_DEFINED (&obj, sizeof (obj));
 #endif
 
   if (FIXNUMP (obj))
     return;
 
   void *po = XPNTR (obj);
+
+  /* If the pointer is in the dumped image and the dump has a record
+     of the object starting at the place where the pointer points, we
+     definitely have an object.  If the pointer is in the dumped image
+     and the dump has no idea what the pointer is pointing at, we
+     definitely _don't_ have an object.  */
+  if (pdumper_object_p (po))
+    {
+      /* Don't use pdumper_object_p_precise here! It doesn't check the
+         tag bits. OBJ here might be complete garbage, so we need to
+         verify both the pointer and the tag.  */
+      if (XTYPE (obj) == pdumper_find_object_type (po))
+        mark_object (obj);
+      return;
+    }
+
   struct mem_node *m = mem_find (po);
 
   if (m != MEM_NIL)
@@ -4655,9 +4618,9 @@ mark_maybe_object (Lisp_Object obj)
 }
 
 void
-mark_maybe_objects (Lisp_Object *array, ptrdiff_t nelts)
+mark_maybe_objects (Lisp_Object const *array, ptrdiff_t nelts)
 {
-  for (Lisp_Object *lim = array + nelts; array < lim; array++)
+  for (Lisp_Object const *lim = array + nelts; array < lim; array++)
     mark_maybe_object (*array);
 }
 
@@ -4673,10 +4636,6 @@ maybe_lisp_pointer (void *p)
   return (uintptr_t) p % LISP_ALIGNMENT == 0;
 }
 
-#ifndef HAVE_MODULES
-enum { HAVE_MODULES = false };
-#endif
-
 /* If P points to Lisp data, mark that as live if it isn't already
    marked.  */
 
@@ -4685,21 +4644,22 @@ mark_maybe_pointer (void *p)
 {
   struct mem_node *m;
 
-#if USE_VALGRIND
-  if (valgrind_p)
-    VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p));
+#ifdef USE_VALGRIND
+  VALGRIND_MAKE_MEM_DEFINED (&p, sizeof (p));
 #endif
 
-  if (sizeof (Lisp_Object) == sizeof (void *) || !HAVE_MODULES)
-    {
-      if (!maybe_lisp_pointer (p))
-        return;
-    }
-  else
+  if (!maybe_lisp_pointer (p))
+    return;
+
+  if (pdumper_object_p (p))
     {
-      /* For the wide-int case, also mark emacs_value tagged pointers,
-        which can be generated by emacs-module.c's value_to_lisp.  */
-      p = (void *) ((uintptr_t) p & ~((1 << GCTYPEBITS) - 1));
+      enum Lisp_Type type = pdumper_find_object_type (p);
+      if (type != PDUMPER_NO_OBJECT)
+        mark_object ((type == Lisp_Symbol)
+                     ? make_lisp_symbol(p)
+                     : make_lisp_ptr(p, type));
+      /* See mark_maybe_object for why we can confidently return.  */
+      return;
     }
 
   m = mem_find (p);
@@ -4759,15 +4719,15 @@ mark_maybe_pointer (void *p)
    or END+OFFSET..START.  */
 
 static void ATTRIBUTE_NO_SANITIZE_ADDRESS
-mark_memory (void *start, void *end)
+mark_memory (void const *start, void const *end)
 {
-  char *pp;
+  char const *pp;
 
   /* Make START the pointer to the start of the memory region,
      if it isn't already.  */
   if (end < start)
     {
-      void *tem = start;
+      void const *tem = start;
       start = end;
       end = tem;
     }
@@ -4783,7 +4743,7 @@ mark_memory (void *start, void *end)
      {
        Lisp_Object obj = build_string ("test");
        struct Lisp_String *s = XSTRING (obj);
-       Fgarbage_collect ();
+       garbage_collect ();
        fprintf (stderr, "test '%s'\n", s->u.s.data);
        return Qnil;
      }
@@ -4792,14 +4752,14 @@ mark_memory (void *start, void *end)
      away.  The only reference to the life string is through the
      pointer `s'.  */
 
-  for (pp = start; (void *) pp < end; pp += GC_POINTER_ALIGNMENT)
+  for (pp = start; (void const *) pp < end; pp += GC_POINTER_ALIGNMENT)
     {
-      mark_maybe_pointer (*(void **) pp);
+      mark_maybe_pointer (*(void *const *) pp);
 
       verify (alignof (Lisp_Object) % GC_POINTER_ALIGNMENT == 0);
       if (alignof (Lisp_Object) == GC_POINTER_ALIGNMENT
          || (uintptr_t) pp % alignof (Lisp_Object) == 0)
-       mark_maybe_object (*(Lisp_Object *) pp);
+       mark_maybe_object (*(Lisp_Object const *) pp);
     }
 }
 
@@ -5001,7 +4961,7 @@ typedef union
    from the stack start.  */
 
 void
-mark_stack (char *bottom, char *end)
+mark_stack (char const *bottom, char const *end)
 {
   /* This assumes that the stack is a contiguous region in memory.  If
      that's not the case, something has to be done here to iterate
@@ -5058,6 +5018,12 @@ valid_pointer_p (void *p)
     return p ? -1 : 0;
 
   int fd[2];
+  static int under_rr_state;
+
+  if (!under_rr_state)
+    under_rr_state = getenv ("RUNNING_UNDER_RR") ? -1 : 1;
+  if (under_rr_state < 0)
+    return under_rr_state;
 
   /* Obviously, we cannot just access it (we would SEGV trying), so we
      trick the o/s to tell us whether p is a valid pointer.
@@ -5097,6 +5063,9 @@ valid_lisp_object_p (Lisp_Object obj)
   if (p == &buffer_defaults || p == &buffer_local_symbols)
     return 2;
 
+  if (pdumper_object_p (p))
+    return pdumper_object_p_precise (p) ? 1 : 0;
+
   struct mem_node *m = mem_find (p);
 
   if (m == MEM_NIL)
@@ -5149,7 +5118,8 @@ valid_lisp_object_p (Lisp_Object obj)
 
 /* Allocate room for SIZE bytes from pure Lisp storage and return a
    pointer to it.  TYPE is the Lisp type for which the memory is
-   allocated.  TYPE < 0 means it's not used for a Lisp object.  */
+   allocated.  TYPE < 0 means it's not used for a Lisp object,
+   and that the result should have an alignment of -TYPE.  */
 
 static void *
 pure_alloc (size_t size, int type)
@@ -5168,8 +5138,11 @@ pure_alloc (size_t size, int type)
     {
       /* Allocate space for a non-Lisp object from the end of the free
         space.  */
-      pure_bytes_used_non_lisp += size;
-      result = purebeg + pure_size - pure_bytes_used_non_lisp;
+      ptrdiff_t unaligned_non_lisp = pure_bytes_used_non_lisp + size;
+      char *unaligned = purebeg + pure_size - unaligned_non_lisp;
+      int decr = (intptr_t) unaligned & (-1 - type);
+      pure_bytes_used_non_lisp = unaligned_non_lisp + decr;
+      result = unaligned - decr;
     }
   pure_bytes_used = pure_bytes_used_lisp + pure_bytes_used_non_lisp;
 
@@ -5188,7 +5161,7 @@ pure_alloc (size_t size, int type)
 }
 
 
-#ifndef CANNOT_DUMP
+#ifdef HAVE_UNEXEC
 
 /* Print a warning if PURESIZE is too small.  */
 
@@ -5306,7 +5279,7 @@ make_pure_c_string (const char *data, ptrdiff_t nchars)
   Lisp_Object string;
   struct Lisp_String *s = pure_alloc (sizeof *s, Lisp_String);
   s->u.s.size = nchars;
-  s->u.s.size_byte = -1;
+  s->u.s.size_byte = -2;
   s->u.s.data = (unsigned char *) data;
   s->u.s.intervals = NULL;
   XSETSTRING (string, s);
@@ -5356,7 +5329,8 @@ make_pure_bignum (struct Lisp_Bignum *value)
   struct Lisp_Bignum *b = pure_alloc (sizeof *b, Lisp_Vectorlike);
   XSETPVECTYPESIZE (b, PVEC_BIGNUM, 0, VECSIZE (struct Lisp_Bignum));
 
-  pure_limbs = pure_alloc (nbytes, -1);
+  int limb_alignment = alignof (mp_limb_t);
+  pure_limbs = pure_alloc (nbytes, - limb_alignment);
   for (i = 0; i < nlimbs; ++i)
     pure_limbs[i] = mpz_getlimbn (value->value, i);
 
@@ -5533,8 +5507,10 @@ purecopy (Lisp_Object obj)
    VARADDRESS.  */
 
 void
-staticpro (Lisp_Object *varaddress)
+staticpro (Lisp_Object const *varaddress)
 {
+  for (int i = 0; i < staticidx; i++)
+    eassert (staticvec[i] != varaddress);
   if (staticidx >= NSTATICS)
     fatal ("NSTATICS too small; try increasing and recompiling Emacs.");
   staticvec[staticidx++] = varaddress;
@@ -5556,28 +5532,29 @@ inhibit_garbage_collection (void)
   return count;
 }
 
-/* Used to avoid possible overflows when
-   converting from C to Lisp integers.  */
+/* Return the number of bytes in N objects each of size S, guarding
+   against overflow if size_t is narrower than byte_ct.  */
 
-static Lisp_Object
-bounded_number (EMACS_INT number)
+static byte_ct
+object_bytes (object_ct n, size_t s)
 {
-  return make_fixnum (min (MOST_POSITIVE_FIXNUM, number));
+  byte_ct b = s;
+  return n * b;
 }
 
 /* Calculate total bytes of live objects.  */
 
-static size_t
+static byte_ct
 total_bytes_of_live_objects (void)
 {
-  size_t tot = 0;
-  tot += total_conses  * sizeof (struct Lisp_Cons);
-  tot += total_symbols * sizeof (struct Lisp_Symbol);
-  tot += total_string_bytes;
-  tot += total_vector_slots * word_size;
-  tot += total_floats  * sizeof (struct Lisp_Float);
-  tot += total_intervals * sizeof (struct interval);
-  tot += total_strings * sizeof (struct Lisp_String);
+  byte_ct tot = 0;
+  tot += object_bytes (gcstat.total_conses, sizeof (struct Lisp_Cons));
+  tot += object_bytes (gcstat.total_symbols, sizeof (struct Lisp_Symbol));
+  tot += gcstat.total_string_bytes;
+  tot += object_bytes (gcstat.total_vector_slots, word_size);
+  tot += object_bytes (gcstat.total_floats, sizeof (struct Lisp_Float));
+  tot += object_bytes (gcstat.total_intervals, sizeof (struct interval));
+  tot += object_bytes (gcstat.total_strings, sizeof (struct Lisp_String));
   return tot;
 }
 
@@ -5598,7 +5575,7 @@ compact_font_cache_entry (Lisp_Object entry)
 
       /* Consider OBJ if it is (font-spec . [font-entity font-entity ...]).  */
       if (CONSP (obj) && GC_FONT_SPEC_P (XCAR (obj))
-         && !VECTOR_MARKED_P (GC_XFONT_SPEC (XCAR (obj)))
+         && !vectorlike_marked_p (&GC_XFONT_SPEC (XCAR (obj))->header)
          /* Don't use VECTORP here, as that calls ASIZE, which could
             hit assertion violation during GC.  */
          && (VECTORLIKEP (XCDR (obj))
@@ -5614,7 +5591,8 @@ compact_font_cache_entry (Lisp_Object entry)
             {
               Lisp_Object objlist;
 
-              if (VECTOR_MARKED_P (GC_XFONT_ENTITY (AREF (obj_cdr, i))))
+              if (vectorlike_marked_p (
+                    &GC_XFONT_ENTITY (AREF (obj_cdr, i))->header))
                 break;
 
               objlist = AREF (AREF (obj_cdr, i), FONT_OBJLIST_INDEX);
@@ -5624,7 +5602,7 @@ compact_font_cache_entry (Lisp_Object entry)
                   struct font *font = GC_XFONT_OBJECT (val);
 
                   if (!NILP (AREF (val, FONT_TYPE_INDEX))
-                      && VECTOR_MARKED_P(font))
+                      && vectorlike_marked_p(&font->header))
                     break;
                 }
               if (CONSP (objlist))
@@ -5693,7 +5671,7 @@ compact_undo_list (Lisp_Object list)
     {
       if (CONSP (XCAR (tail))
          && MARKERP (XCAR (XCAR (tail)))
-         && !VECTOR_MARKED_P (XMARKER (XCAR (XCAR (tail)))))
+         && !vectorlike_marked_p (&XMARKER (XCAR (XCAR (tail)))->header))
        *prev = XCDR (tail);
       else
        prev = xcdr_addr (tail);
@@ -5726,35 +5704,126 @@ mark_pinned_symbols (void)
     }
 }
 
-/* Subroutine of Fgarbage_collect that does most of the work.  It is a
-   separate function so that we could limit mark_stack in searching
-   the stack frames below this function, thus avoiding the rare cases
-   where mark_stack finds values that look like live Lisp objects on
-   portions of stack that couldn't possibly contain such live objects.
-   For more details of this, see the discussion at
-   https://lists.gnu.org/r/emacs-devel/2014-05/msg00270.html.  */
-static Lisp_Object
-garbage_collect_1 (void *end)
+static void
+visit_vectorlike_root (struct gc_root_visitor visitor,
+                       struct Lisp_Vector *ptr,
+                       enum gc_root_type type)
+{
+  ptrdiff_t size = ptr->header.size;
+  ptrdiff_t i;
+
+  if (size & PSEUDOVECTOR_FLAG)
+    size &= PSEUDOVECTOR_SIZE_MASK;
+  for (i = 0; i < size; i++)
+    visitor.visit (&ptr->contents[i], type, visitor.data);
+}
+
+static void
+visit_buffer_root (struct gc_root_visitor visitor,
+                   struct buffer *buffer,
+                   enum gc_root_type type)
+{
+  /* Buffers that are roots don't have intervals, an undo list, or
+     other constructs that real buffers have.  */
+  eassert (buffer->base_buffer == NULL);
+  eassert (buffer->overlays_before == NULL);
+  eassert (buffer->overlays_after == NULL);
+
+  /* Visit the buffer-locals.  */
+  visit_vectorlike_root (visitor, (struct Lisp_Vector *) buffer, type);
+}
+
+/* Visit GC roots stored in the Emacs data section.  Used by both core
+   GC and by the portable dumping code.
+
+   There are other GC roots of course, but these roots are dynamic
+   runtime data structures that pdump doesn't care about and so we can
+   continue to mark those directly in garbage_collect_1.  */
+void
+visit_static_gc_roots (struct gc_root_visitor visitor)
+{
+  visit_buffer_root (visitor,
+                     &buffer_defaults,
+                     GC_ROOT_BUFFER_LOCAL_DEFAULT);
+  visit_buffer_root (visitor,
+                     &buffer_local_symbols,
+                     GC_ROOT_BUFFER_LOCAL_NAME);
+
+  for (int i = 0; i < ARRAYELTS (lispsym); i++)
+    {
+      Lisp_Object sptr = builtin_lisp_symbol (i);
+      visitor.visit (&sptr, GC_ROOT_C_SYMBOL, visitor.data);
+    }
+
+  for (int i = 0; i < staticidx; i++)
+    visitor.visit (staticvec[i], GC_ROOT_STATICPRO, visitor.data);
+}
+
+static void
+mark_object_root_visitor (Lisp_Object const *root_ptr,
+                          enum gc_root_type type,
+                          void *data)
+{
+  mark_object (*root_ptr);
+}
+
+/* List of weak hash tables we found during marking the Lisp heap.
+   Will be NULL on entry to garbage_collect_1 and after it
+   returns.  */
+static struct Lisp_Hash_Table *weak_hash_tables;
+
+NO_INLINE /* For better stack traces */
+static void
+mark_and_sweep_weak_table_contents (void)
+{
+  struct Lisp_Hash_Table *h;
+  bool marked;
+
+  /* Mark all keys and values that are in use.  Keep on marking until
+     there is no more change.  This is necessary for cases like
+     value-weak table A containing an entry X -> Y, where Y is used in a
+     key-weak table B, Z -> Y.  If B comes after A in the list of weak
+     tables, X -> Y might be removed from A, although when looking at B
+     one finds that it shouldn't.  */
+  do
+    {
+      marked = false;
+      for (h = weak_hash_tables; h; h = h->next_weak)
+        marked |= sweep_weak_table (h, false);
+    }
+  while (marked);
+
+  /* Remove hash table entries that aren't used.  */
+  while (weak_hash_tables)
+    {
+      h = weak_hash_tables;
+      weak_hash_tables = h->next_weak;
+      h->next_weak = NULL;
+      sweep_weak_table (h, true);
+    }
+}
+
+/* Subroutine of Fgarbage_collect that does most of the work.  */
+static bool
+garbage_collect_1 (struct gcstat *gcst)
 {
   struct buffer *nextb;
   char stack_top_variable;
-  ptrdiff_t i;
   bool message_p;
   ptrdiff_t count = SPECPDL_INDEX ();
   struct timespec start;
-  Lisp_Object retval = Qnil;
-  size_t tot_before = 0;
+  byte_ct tot_before = 0;
+
+  eassert (weak_hash_tables == NULL);
 
   /* Can't GC if pure storage overflowed because we can't determine
      if something is a pure object or not.  */
   if (pure_bytes_used_before_overflow)
-    return Qnil;
+    return false;
 
   /* Record this function, so it appears on the profiler's backtraces.  */
   record_in_backtrace (QAutomatic_GC, 0, 0);
 
-  check_cons_list ();
-
   /* Don't keep undo information around forever.
      Do this early on, so it is no problem if the user quits.  */
   FOR_EACH_BUFFER (nextb)
@@ -5784,7 +5853,7 @@ garbage_collect_1 (void *end)
 #if MAX_SAVE_STACK > 0
   if (NILP (Vpurify_flag))
     {
-      char *stack;
+      char const *stack;
       ptrdiff_t stack_size;
       if (&stack_top_variable < stack_bottom)
        {
@@ -5820,14 +5889,8 @@ garbage_collect_1 (void *end)
 
   /* Mark all the special slots that serve as the roots of accessibility.  */
 
-  mark_buffer (&buffer_defaults);
-  mark_buffer (&buffer_local_symbols);
-
-  for (i = 0; i < ARRAYELTS (lispsym); i++)
-    mark_object (builtin_lisp_symbol (i));
-
-  for (i = 0; i < staticidx; i++)
-    mark_object (*staticvec[i]);
+  struct gc_root_visitor visitor = { .visit = mark_object_root_visitor };
+  visit_static_gc_roots (visitor);
 
   mark_pinned_objects ();
   mark_pinned_symbols ();
@@ -5872,16 +5935,14 @@ garbage_collect_1 (void *end)
   queue_doomed_finalizers (&doomed_finalizers, &finalizers);
   mark_finalizer_list (&doomed_finalizers);
 
-  gc_sweep ();
+  /* Must happen after all other marking and before gc_sweep.  */
+  mark_and_sweep_weak_table_contents ();
+  eassert (weak_hash_tables == NULL);
 
-  /* Clear the mark bits that we set in certain root slots.  */
-  VECTOR_UNMARK (&buffer_defaults);
-  VECTOR_UNMARK (&buffer_local_symbols);
+  gc_sweep ();
 
   unmark_main_thread ();
 
-  check_cons_list ();
-
   gc_in_progress = 0;
 
   unblock_input ();
@@ -5898,10 +5959,10 @@ garbage_collect_1 (void *end)
       tot *= XFLOAT_DATA (Vgc_cons_percentage);
       if (0 < tot)
        {
-         if (tot < TYPE_MAXIMUM (EMACS_INT))
+         if (tot < UINTPTR_MAX)
            gc_relative_threshold = tot;
          else
-           gc_relative_threshold = TYPE_MAXIMUM (EMACS_INT);
+           gc_relative_threshold = UINTPTR_MAX;
        }
     }
 
@@ -5915,40 +5976,7 @@ garbage_collect_1 (void *end)
 
   unbind_to (count, Qnil);
 
-  Lisp_Object total[] = {
-    list4 (Qconses, make_fixnum (sizeof (struct Lisp_Cons)),
-          bounded_number (total_conses),
-          bounded_number (total_free_conses)),
-    list4 (Qsymbols, make_fixnum (sizeof (struct Lisp_Symbol)),
-          bounded_number (total_symbols),
-          bounded_number (total_free_symbols)),
-    list4 (Qstrings, make_fixnum (sizeof (struct Lisp_String)),
-          bounded_number (total_strings),
-          bounded_number (total_free_strings)),
-    list3 (Qstring_bytes, make_fixnum (1),
-          bounded_number (total_string_bytes)),
-    list3 (Qvectors,
-          make_fixnum (header_size + sizeof (Lisp_Object)),
-          bounded_number (total_vectors)),
-    list4 (Qvector_slots, make_fixnum (word_size),
-          bounded_number (total_vector_slots),
-          bounded_number (total_free_vector_slots)),
-    list4 (Qfloats, make_fixnum (sizeof (struct Lisp_Float)),
-          bounded_number (total_floats),
-          bounded_number (total_free_floats)),
-    list4 (Qintervals, make_fixnum (sizeof (struct interval)),
-          bounded_number (total_intervals),
-          bounded_number (total_free_intervals)),
-    list3 (Qbuffers, make_fixnum (sizeof (struct buffer)),
-          bounded_number (total_buffers)),
-
-#ifdef DOUG_LEA_MALLOC
-    list4 (Qheap, make_fixnum (1024),
-          bounded_number ((mallinfo ().uordblks + 1023) >> 10),
-          bounded_number ((mallinfo ().fordblks + 1023) >> 10)),
-#endif
-  };
-  retval = CALLMANY (Flist, total);
+  *gcst = gcstat;
 
   /* GC is complete: now we can run our finalizer callbacks.  */
   run_finalizers (&doomed_finalizers);
@@ -5973,14 +6001,19 @@ garbage_collect_1 (void *end)
   /* Collect profiling data.  */
   if (profiler_memory_running)
     {
-      size_t swept = 0;
-      size_t tot_after = total_bytes_of_live_objects ();
-      if (tot_before > tot_after)
-       swept = tot_before - tot_after;
-      malloc_probe (swept);
+      byte_ct tot_after = total_bytes_of_live_objects ();
+      byte_ct swept = tot_before <= tot_after ? 0 : tot_before - tot_after;
+      malloc_probe (min (swept, SIZE_MAX));
     }
 
-  return retval;
+  return true;
+}
+
+void
+garbage_collect (void)
+{
+  struct gcstat gcst;
+  garbage_collect_1 (&gcst);
 }
 
 DEFUN ("garbage-collect", Fgarbage_collect, Sgarbage_collect, 0, 0, "",
@@ -5997,13 +6030,47 @@ where each entry has the form (NAME SIZE USED FREE), 
where:
   to return them to the OS).
 However, if there was overflow in pure space, `garbage-collect'
 returns nil, because real GC can't be done.
-See Info node `(elisp)Garbage Collection'.  */
-       attributes: noinline)
+See Info node `(elisp)Garbage Collection'.  */)
   (void)
 {
-  void *end;
-  SET_STACK_TOP_ADDRESS (&end);
-  return garbage_collect_1 (end);
+  struct gcstat gcst;
+  if (!garbage_collect_1 (&gcst))
+    return Qnil;
+
+  Lisp_Object total[] = {
+    list4 (Qconses, make_fixnum (sizeof (struct Lisp_Cons)),
+          make_int (gcst.total_conses),
+          make_int (gcst.total_free_conses)),
+    list4 (Qsymbols, make_fixnum (sizeof (struct Lisp_Symbol)),
+          make_int (gcst.total_symbols),
+          make_int (gcst.total_free_symbols)),
+    list4 (Qstrings, make_fixnum (sizeof (struct Lisp_String)),
+          make_int (gcst.total_strings),
+          make_int (gcst.total_free_strings)),
+    list3 (Qstring_bytes, make_fixnum (1),
+          make_int (gcst.total_string_bytes)),
+    list3 (Qvectors,
+          make_fixnum (header_size + sizeof (Lisp_Object)),
+          make_int (gcst.total_vectors)),
+    list4 (Qvector_slots, make_fixnum (word_size),
+          make_int (gcst.total_vector_slots),
+          make_int (gcst.total_free_vector_slots)),
+    list4 (Qfloats, make_fixnum (sizeof (struct Lisp_Float)),
+          make_int (gcst.total_floats),
+          make_int (gcst.total_free_floats)),
+    list4 (Qintervals, make_fixnum (sizeof (struct interval)),
+          make_int (gcst.total_intervals),
+          make_int (gcst.total_free_intervals)),
+    list3 (Qbuffers, make_fixnum (sizeof (struct buffer)),
+          make_int (gcst.total_buffers)),
+
+#ifdef DOUG_LEA_MALLOC
+    list4 (Qheap, make_fixnum (1024),
+          make_int ((mallinfo ().uordblks + 1023) >> 10),
+          make_int ((mallinfo ().fordblks + 1023) >> 10)),
+#endif
+  };
+  return CALLMANY (Flist, total);
 }
 
 /* Mark Lisp objects in glyph matrix MATRIX.  Currently the
@@ -6026,7 +6093,7 @@ mark_glyph_matrix (struct glyph_matrix *matrix)
 
            for (; glyph < end_glyph; ++glyph)
              if (STRINGP (glyph->object)
-                 && !STRING_MARKED_P (XSTRING (glyph->object)))
+                 && !string_marked_p (XSTRING (glyph->object)))
                mark_object (glyph->object);
          }
       }
@@ -6043,13 +6110,18 @@ static int last_marked_index;
 ptrdiff_t mark_object_loop_halt EXTERNALLY_VISIBLE;
 
 static void
-mark_vectorlike (struct Lisp_Vector *ptr)
+mark_vectorlike (union vectorlike_header *header)
 {
+  struct Lisp_Vector *ptr = (struct Lisp_Vector *) header;
   ptrdiff_t size = ptr->header.size;
   ptrdiff_t i;
 
-  eassert (!VECTOR_MARKED_P (ptr));
-  VECTOR_MARK (ptr);           /* Else mark it.  */
+  eassert (!vector_marked_p (ptr));
+
+  /* Bool vectors have a different case in mark_object.  */
+  eassert (PSEUDOVECTOR_TYPE (ptr) != PVEC_BOOL_VECTOR);
+
+  set_vector_marked (ptr); /* Else mark it.  */
   if (size & PSEUDOVECTOR_FLAG)
     size &= PSEUDOVECTOR_SIZE_MASK;
 
@@ -6072,17 +6144,18 @@ mark_char_table (struct Lisp_Vector *ptr, enum 
pvec_type pvectype)
   /* Consult the Lisp_Sub_Char_Table layout before changing this.  */
   int i, idx = (pvectype == PVEC_SUB_CHAR_TABLE ? SUB_CHAR_TABLE_OFFSET : 0);
 
-  eassert (!VECTOR_MARKED_P (ptr));
-  VECTOR_MARK (ptr);
+  eassert (!vector_marked_p (ptr));
+  set_vector_marked (ptr);
   for (i = idx; i < size; i++)
     {
       Lisp_Object val = ptr->contents[i];
 
-      if (FIXNUMP (val) || (SYMBOLP (val) && XSYMBOL (val)->u.s.gcmarkbit))
+      if (FIXNUMP (val) ||
+          (SYMBOLP (val) && symbol_marked_p (XSYMBOL (val))))
        continue;
       if (SUB_CHAR_TABLE_P (val))
        {
-         if (! VECTOR_MARKED_P (XVECTOR (val)))
+         if (! vector_marked_p (XVECTOR (val)))
            mark_char_table (XVECTOR (val), PVEC_SUB_CHAR_TABLE);
        }
       else
@@ -6096,7 +6169,7 @@ mark_compiled (struct Lisp_Vector *ptr)
 {
   int i, size = ptr->header.size & PSEUDOVECTOR_SIZE_MASK;
 
-  VECTOR_MARK (ptr);
+  set_vector_marked (ptr);
   for (i = 0; i < size; i++)
     if (i != COMPILED_CONSTANTS)
       mark_object (ptr->contents[i]);
@@ -6108,12 +6181,12 @@ mark_compiled (struct Lisp_Vector *ptr)
 static void
 mark_overlay (struct Lisp_Overlay *ptr)
 {
-  for (; ptr && !VECTOR_MARKED_P (ptr); ptr = ptr->next)
+  for (; ptr && !vectorlike_marked_p (&ptr->header); ptr = ptr->next)
     {
-      VECTOR_MARK (ptr);
+      set_vectorlike_marked (&ptr->header);
       /* These two are always markers and can be marked fast.  */
-      VECTOR_MARK (XMARKER (ptr->start));
-      VECTOR_MARK (XMARKER (ptr->end));
+      set_vectorlike_marked (&XMARKER (ptr->start)->header);
+      set_vectorlike_marked (&XMARKER (ptr->end)->header);
       mark_object (ptr->plist);
     }
 }
@@ -6124,11 +6197,11 @@ static void
 mark_buffer (struct buffer *buffer)
 {
   /* This is handled much like other pseudovectors...  */
-  mark_vectorlike ((struct Lisp_Vector *) buffer);
+  mark_vectorlike (&buffer->header);
 
   /* ...but there are some buffer-specific things.  */
 
-  MARK_INTERVAL_TREE (buffer_intervals (buffer));
+  mark_interval_tree (buffer_intervals (buffer));
 
   /* For now, we just don't mark the undo_list.  It's done later in
      a special way just before the sweep phase, and after stripping
@@ -6138,7 +6211,8 @@ mark_buffer (struct buffer *buffer)
   mark_overlay (buffer->overlays_after);
 
   /* If this is an indirect buffer, mark its base buffer.  */
-  if (buffer->base_buffer && !VECTOR_MARKED_P (buffer->base_buffer))
+  if (buffer->base_buffer &&
+      !vectorlike_marked_p (&buffer->base_buffer->header))
     mark_buffer (buffer->base_buffer);
 }
 
@@ -6157,8 +6231,8 @@ mark_face_cache (struct face_cache *c)
 
          if (face)
            {
-             if (face->font && !VECTOR_MARKED_P (face->font))
-               mark_vectorlike ((struct Lisp_Vector *) face->font);
+             if (face->font && !vectorlike_marked_p (&face->font->header))
+               mark_vectorlike (&face->font->header);
 
              for (j = 0; j < LFACE_VECTOR_SIZE; ++j)
                mark_object (face->lface[j]);
@@ -6189,7 +6263,7 @@ mark_discard_killed_buffers (Lisp_Object list)
 {
   Lisp_Object tail, *prev = &list;
 
-  for (tail = list; CONSP (tail) && !CONS_MARKED_P (XCONS (tail));
+  for (tail = list; CONSP (tail) && !cons_marked_p (XCONS (tail));
        tail = XCDR (tail))
     {
       Lisp_Object tem = XCAR (tail);
@@ -6199,7 +6273,7 @@ mark_discard_killed_buffers (Lisp_Object list)
        *prev = XCDR (tail);
       else
        {
-         CONS_MARK (XCONS (tail));
+         set_cons_marked (XCONS (tail));
          mark_object (XCAR (tail));
          prev = xcdr_addr (tail);
        }
@@ -6208,6 +6282,72 @@ mark_discard_killed_buffers (Lisp_Object list)
   return list;
 }
 
+static void
+mark_frame (struct Lisp_Vector *ptr)
+{
+  struct frame *f = (struct frame *) ptr;
+  mark_vectorlike (&ptr->header);
+  mark_face_cache (f->face_cache);
+#ifdef HAVE_WINDOW_SYSTEM
+  if (FRAME_WINDOW_P (f) && FRAME_OUTPUT_DATA (f))
+    {
+      struct font *font = FRAME_FONT (f);
+
+      if (font && !vectorlike_marked_p (&font->header))
+        mark_vectorlike (&font->header);
+    }
+#endif
+}
+
+static void
+mark_window (struct Lisp_Vector *ptr)
+{
+  struct window *w = (struct window *) ptr;
+
+  mark_vectorlike (&ptr->header);
+
+  /* Mark glyph matrices, if any.  Marking window
+     matrices is sufficient because frame matrices
+     use the same glyph memory.  */
+  if (w->current_matrix)
+    {
+      mark_glyph_matrix (w->current_matrix);
+      mark_glyph_matrix (w->desired_matrix);
+    }
+
+  /* Filter out killed buffers from both buffer lists
+     in attempt to help GC to reclaim killed buffers faster.
+     We can do it elsewhere for live windows, but this is the
+     best place to do it for dead windows.  */
+  wset_prev_buffers
+    (w, mark_discard_killed_buffers (w->prev_buffers));
+  wset_next_buffers
+    (w, mark_discard_killed_buffers (w->next_buffers));
+}
+
+static void
+mark_hash_table (struct Lisp_Vector *ptr)
+{
+  struct Lisp_Hash_Table *h = (struct Lisp_Hash_Table *) ptr;
+
+  mark_vectorlike (&h->header);
+  mark_object (h->test.name);
+  mark_object (h->test.user_hash_function);
+  mark_object (h->test.user_cmp_function);
+  /* If hash table is not weak, mark all keys and values.  For weak
+     tables, mark only the vector and not its contents --- that's what
+     makes it weak.  */
+  if (NILP (h->weak))
+    mark_object (h->key_and_value);
+  else
+    {
+      eassert (h->next_weak == NULL);
+      h->next_weak = weak_hash_tables;
+      weak_hash_tables = h;
+      set_vector_marked (XVECTOR (h->key_and_value));
+    }
+}
+
 /* Determine type of generic Lisp_Object and mark it accordingly.
 
    This function implements a straightforward depth-first marking
@@ -6222,7 +6362,7 @@ mark_object (Lisp_Object arg)
   register Lisp_Object obj;
   void *po;
 #if GC_CHECK_MARKED_OBJECTS
-  struct mem_node *m;
+  struct mem_node *m = NULL;
 #endif
   ptrdiff_t cdr_count = 0;
 
@@ -6245,6 +6385,12 @@ mark_object (Lisp_Object arg)
      structure allocated from the heap.  */
 #define CHECK_ALLOCATED()                      \
   do {                                         \
+    if (pdumper_object_p(po))                   \
+      {                                         \
+        if (!pdumper_object_p_precise (po))     \
+          emacs_abort ();                       \
+        break;                                  \
+      }                                         \
     m = mem_find (po);                         \
     if (m == MEM_NIL)                          \
       emacs_abort ();                          \
@@ -6254,6 +6400,8 @@ mark_object (Lisp_Object arg)
      function LIVEP.  */
 #define CHECK_LIVE(LIVEP)                      \
   do {                                         \
+    if (pdumper_object_p(po))                   \
+      break;                                    \
     if (!LIVEP (m, po))                                \
       emacs_abort ();                          \
   } while (0)
@@ -6288,11 +6436,11 @@ mark_object (Lisp_Object arg)
     case Lisp_String:
       {
        register struct Lisp_String *ptr = XSTRING (obj);
-       if (STRING_MARKED_P (ptr))
-         break;
+        if (string_marked_p (ptr))
+          break;
        CHECK_ALLOCATED_AND_LIVE (live_string_p);
-       MARK_STRING (ptr);
-       MARK_INTERVAL_TREE (ptr->u.s.intervals);
+        set_string_marked (ptr);
+        mark_interval_tree (ptr->u.s.intervals);
 #ifdef GC_CHECK_STRING_BYTES
        /* Check that the string size recorded in the string is the
           same as the one recorded in the sdata structure.  */
@@ -6305,22 +6453,25 @@ mark_object (Lisp_Object arg)
       {
        register struct Lisp_Vector *ptr = XVECTOR (obj);
 
-       if (VECTOR_MARKED_P (ptr))
+       if (vector_marked_p (ptr))
          break;
 
-#if GC_CHECK_MARKED_OBJECTS
-       m = mem_find (po);
-       if (m == MEM_NIL && !SUBRP (obj) && !main_thread_p (po))
-         emacs_abort ();
+#ifdef GC_CHECK_MARKED_OBJECTS
+        if (!pdumper_object_p(po))
+          {
+           m = mem_find (po);
+            if (m == MEM_NIL && !SUBRP (obj) && !main_thread_p (po))
+             emacs_abort ();
+          }
 #endif /* GC_CHECK_MARKED_OBJECTS */
 
         enum pvec_type pvectype
           = PSEUDOVECTOR_TYPE (ptr);
 
-       if (pvectype != PVEC_SUBR
-           && pvectype != PVEC_BUFFER
-           && !main_thread_p (po))
-         CHECK_LIVE (live_vector_p);
+        if (pvectype != PVEC_SUBR &&
+            pvectype != PVEC_BUFFER &&
+            !main_thread_p (po))
+          CHECK_LIVE (live_vector_p);
 
        switch (pvectype)
          {
@@ -6336,77 +6487,28 @@ mark_object (Lisp_Object arg)
            }
 #endif /* GC_CHECK_MARKED_OBJECTS */
            mark_buffer ((struct buffer *) ptr);
-           break;
-
-         case PVEC_COMPILED:
-           /* Although we could treat this just like a vector, mark_compiled
-              returns the COMPILED_CONSTANTS element, which is marked at the
-              next iteration of goto-loop here.  This is done to avoid a few
-              recursive calls to mark_object.  */
-           obj = mark_compiled (ptr);
-           if (!NILP (obj))
-             goto loop;
-           break;
-
-         case PVEC_FRAME:
-           {
-             struct frame *f = (struct frame *) ptr;
-
-             mark_vectorlike (ptr);
-             mark_face_cache (f->face_cache);
-#ifdef HAVE_WINDOW_SYSTEM
-             if (FRAME_WINDOW_P (f) && FRAME_X_OUTPUT (f))
-               {
-                 struct font *font = FRAME_FONT (f);
-
-                 if (font && !VECTOR_MARKED_P (font))
-                   mark_vectorlike ((struct Lisp_Vector *) font);
-               }
-#endif
-           }
-           break;
-
-         case PVEC_WINDOW:
-           {
-             struct window *w = (struct window *) ptr;
-
-             mark_vectorlike (ptr);
-
-             /* Mark glyph matrices, if any.  Marking window
-                matrices is sufficient because frame matrices
-                use the same glyph memory.  */
-             if (w->current_matrix)
-               {
-                 mark_glyph_matrix (w->current_matrix);
-                 mark_glyph_matrix (w->desired_matrix);
-               }
-
-             /* Filter out killed buffers from both buffer lists
-                in attempt to help GC to reclaim killed buffers faster.
-                We can do it elsewhere for live windows, but this is the
-                best place to do it for dead windows.  */
-             wset_prev_buffers
-               (w, mark_discard_killed_buffers (w->prev_buffers));
-             wset_next_buffers
-               (w, mark_discard_killed_buffers (w->next_buffers));
-           }
-           break;
+            break;
+
+          case PVEC_COMPILED:
+            /* Although we could treat this just like a vector, mark_compiled
+               returns the COMPILED_CONSTANTS element, which is marked at the
+               next iteration of goto-loop here.  This is done to avoid a few
+               recursive calls to mark_object.  */
+            obj = mark_compiled (ptr);
+            if (!NILP (obj))
+              goto loop;
+            break;
+
+          case PVEC_FRAME:
+            mark_frame (ptr);
+            break;
+
+          case PVEC_WINDOW:
+            mark_window (ptr);
+            break;
 
          case PVEC_HASH_TABLE:
-           {
-             struct Lisp_Hash_Table *h = (struct Lisp_Hash_Table *) ptr;
-
-             mark_vectorlike (ptr);
-             mark_object (h->test.name);
-             mark_object (h->test.user_hash_function);
-             mark_object (h->test.user_cmp_function);
-             /* If hash table is not weak, mark all keys and values.
-                For weak tables, mark only the vector.  */
-             if (NILP (h->weak))
-               mark_object (h->key_and_value);
-             else
-               VECTOR_MARK (XVECTOR (h->key_and_value));
-           }
+            mark_hash_table (ptr);
            break;
 
          case PVEC_CHAR_TABLE:
@@ -6414,7 +6516,17 @@ mark_object (Lisp_Object arg)
            mark_char_table (ptr, (enum pvec_type) pvectype);
            break;
 
-         case PVEC_OVERLAY:
+          case PVEC_BOOL_VECTOR:
+            /* bool vectors in a dump are permanently "marked", since
+               they're in the old section and don't have mark bits.
+               If we're looking at a dumped bool vector, we should
+               have aborted above when we called vector_marked_p(), so
+               we should never get here.  */
+            eassert (!pdumper_object_p (ptr));
+            set_vector_marked (ptr);
+            break;
+
+          case PVEC_OVERLAY:
            mark_overlay (XOVERLAY (obj));
            break;
 
@@ -6427,7 +6539,7 @@ mark_object (Lisp_Object arg)
          default:
            /* A regular vector, or a pseudovector needing no special
               treatment.  */
-           mark_vectorlike (ptr);
+           mark_vectorlike (&ptr->header);
          }
       }
       break;
@@ -6436,10 +6548,10 @@ mark_object (Lisp_Object arg)
       {
        struct Lisp_Symbol *ptr = XSYMBOL (obj);
       nextsym:
-       if (ptr->u.s.gcmarkbit)
-         break;
-       CHECK_ALLOCATED_AND_LIVE_SYMBOL ();
-       ptr->u.s.gcmarkbit = 1;
+        if (symbol_marked_p (ptr))
+          break;
+        CHECK_ALLOCATED_AND_LIVE_SYMBOL ();
+        set_symbol_marked(ptr);
        /* Attempt to catch bogus objects.  */
        eassert (valid_lisp_object_p (ptr->u.s.function));
        mark_object (ptr->u.s.function);
@@ -6466,8 +6578,8 @@ mark_object (Lisp_Object arg)
          default: emacs_abort ();
          }
        if (!PURE_P (XSTRING (ptr->u.s.name)))
-         MARK_STRING (XSTRING (ptr->u.s.name));
-       MARK_INTERVAL_TREE (string_intervals (ptr->u.s.name));
+          set_string_marked (XSTRING (ptr->u.s.name));
+        mark_interval_tree (string_intervals (ptr->u.s.name));
        /* Inner loop to mark next symbol in this bucket, if any.  */
        po = ptr = ptr->u.s.next;
        if (ptr)
@@ -6478,10 +6590,10 @@ mark_object (Lisp_Object arg)
     case Lisp_Cons:
       {
        struct Lisp_Cons *ptr = XCONS (obj);
-       if (CONS_MARKED_P (ptr))
+       if (cons_marked_p (ptr))
          break;
        CHECK_ALLOCATED_AND_LIVE (live_cons_p);
-       CONS_MARK (ptr);
+        set_cons_marked (ptr);
        /* If the cdr is nil, avoid recursion for the car.  */
        if (NILP (ptr->u.s.u.cdr))
          {
@@ -6499,7 +6611,12 @@ mark_object (Lisp_Object arg)
 
     case Lisp_Float:
       CHECK_ALLOCATED_AND_LIVE (live_float_p);
-      FLOAT_MARK (XFLOAT (obj));
+      /* Do not mark floats stored in a dump image: these floats are
+         "cold" and do not have mark bits.  */
+      if (pdumper_object_p (XFLOAT (obj)))
+        eassert (pdumper_cold_object_p (XFLOAT (obj)));
+      else if (!XFLOAT_MARKED_P (XFLOAT (obj)))
+        XFLOAT_MARK (XFLOAT (obj));
       break;
 
     case_Lisp_Int:
@@ -6513,6 +6630,7 @@ mark_object (Lisp_Object arg)
 #undef CHECK_ALLOCATED
 #undef CHECK_ALLOCATED_AND_LIVE
 }
+
 /* Mark the Lisp pointers in the terminal objects.
    Called by Fgarbage_collect.  */
 
@@ -6529,13 +6647,11 @@ mark_terminals (void)
         gets marked.  */
       mark_image_cache (t->image_cache);
 #endif /* HAVE_WINDOW_SYSTEM */
-      if (!VECTOR_MARKED_P (t))
-       mark_vectorlike ((struct Lisp_Vector *)t);
+      if (!vectorlike_marked_p (&t->header))
+       mark_vectorlike (&t->header);
     }
 }
 
-
-
 /* Value is non-zero if OBJ will survive the current GC because it's
    either marked or does not need to be marked to survive.  */
 
@@ -6547,27 +6663,29 @@ survives_gc_p (Lisp_Object obj)
   switch (XTYPE (obj))
     {
     case_Lisp_Int:
-      survives_p = 1;
+      survives_p = true;
       break;
 
     case Lisp_Symbol:
-      survives_p = XSYMBOL (obj)->u.s.gcmarkbit;
+      survives_p = symbol_marked_p (XSYMBOL (obj));
       break;
 
     case Lisp_String:
-      survives_p = STRING_MARKED_P (XSTRING (obj));
+      survives_p = string_marked_p (XSTRING (obj));
       break;
 
     case Lisp_Vectorlike:
-      survives_p = SUBRP (obj) || VECTOR_MARKED_P (XVECTOR (obj));
+      survives_p = SUBRP (obj) || vector_marked_p (XVECTOR (obj));
       break;
 
     case Lisp_Cons:
-      survives_p = CONS_MARKED_P (XCONS (obj));
+      survives_p = cons_marked_p (XCONS (obj));
       break;
 
     case Lisp_Float:
-      survives_p = FLOAT_MARKED_P (XFLOAT (obj));
+      survives_p =
+        XFLOAT_MARKED_P (XFLOAT (obj)) ||
+        pdumper_object_p (XFLOAT (obj));
       break;
 
     default:
@@ -6584,14 +6702,13 @@ NO_INLINE /* For better stack traces */
 static void
 sweep_conses (void)
 {
-  struct cons_block *cblk;
   struct cons_block **cprev = &cons_block;
   int lim = cons_block_index;
-  EMACS_INT num_free = 0, num_used = 0;
+  object_ct num_free = 0, num_used = 0;
 
   cons_free_list = 0;
 
-  for (cblk = cons_block; cblk; cblk = *cprev)
+  for (struct cons_block *cblk; (cblk = *cprev); )
     {
       int i = 0;
       int this_free = 0;
@@ -6622,7 +6739,7 @@ sweep_conses (void)
                 {
                  struct Lisp_Cons *acons
                    = ptr_bounds_copy (&cblk->conses[pos], cblk);
-                 if (!CONS_MARKED_P (acons))
+                 if (!XCONS_MARKED_P (acons))
                     {
                       this_free++;
                       cblk->conses[pos].u.s.u.chain = cons_free_list;
@@ -6632,7 +6749,7 @@ sweep_conses (void)
                   else
                     {
                       num_used++;
-                     CONS_UNMARK (acons);
+                     XUNMARK_CONS (acons);
                     }
                 }
             }
@@ -6655,29 +6772,27 @@ sweep_conses (void)
           cprev = &cblk->next;
         }
     }
-  total_conses = num_used;
-  total_free_conses = num_free;
+  gcstat.total_conses = num_used;
+  gcstat.total_free_conses = num_free;
 }
 
 NO_INLINE /* For better stack traces */
 static void
 sweep_floats (void)
 {
-  register struct float_block *fblk;
   struct float_block **fprev = &float_block;
-  register int lim = float_block_index;
-  EMACS_INT num_free = 0, num_used = 0;
+  int lim = float_block_index;
+  object_ct num_free = 0, num_used = 0;
 
   float_free_list = 0;
 
-  for (fblk = float_block; fblk; fblk = *fprev)
+  for (struct float_block *fblk; (fblk = *fprev); )
     {
-      register int i;
       int this_free = 0;
-      for (i = 0; i < lim; i++)
+      for (int i = 0; i < lim; i++)
        {
          struct Lisp_Float *afloat = ptr_bounds_copy (&fblk->floats[i], fblk);
-         if (!FLOAT_MARKED_P (afloat))
+         if (!XFLOAT_MARKED_P (afloat))
            {
              this_free++;
              fblk->floats[i].u.chain = float_free_list;
@@ -6686,7 +6801,7 @@ sweep_floats (void)
          else
            {
              num_used++;
-             FLOAT_UNMARK (afloat);
+             XFLOAT_UNMARK (afloat);
            }
        }
       lim = FLOAT_BLOCK_SIZE;
@@ -6706,27 +6821,25 @@ sweep_floats (void)
           fprev = &fblk->next;
         }
     }
-  total_floats = num_used;
-  total_free_floats = num_free;
+  gcstat.total_floats = num_used;
+  gcstat.total_free_floats = num_free;
 }
 
 NO_INLINE /* For better stack traces */
 static void
 sweep_intervals (void)
 {
-  register struct interval_block *iblk;
   struct interval_block **iprev = &interval_block;
-  register int lim = interval_block_index;
-  EMACS_INT num_free = 0, num_used = 0;
+  int lim = interval_block_index;
+  object_ct num_free = 0, num_used = 0;
 
   interval_free_list = 0;
 
-  for (iblk = interval_block; iblk; iblk = *iprev)
+  for (struct interval_block *iblk; (iblk = *iprev); )
     {
-      register int i;
       int this_free = 0;
 
-      for (i = 0; i < lim; i++)
+      for (int i = 0; i < lim; i++)
         {
           if (!iblk->intervals[i].gcmarkbit)
             {
@@ -6757,8 +6870,8 @@ sweep_intervals (void)
           iprev = &iblk->next;
         }
     }
-  total_intervals = num_used;
-  total_free_intervals = num_free;
+  gcstat.total_intervals = num_used;
+  gcstat.total_free_intervals = num_free;
 }
 
 NO_INLINE /* For better stack traces */
@@ -6768,7 +6881,7 @@ sweep_symbols (void)
   struct symbol_block *sblk;
   struct symbol_block **sprev = &symbol_block;
   int lim = symbol_block_index;
-  EMACS_INT num_free = 0, num_used = ARRAYELTS (lispsym);
+  object_ct num_free = 0, num_used = ARRAYELTS (lispsym);
 
   symbol_free_list = NULL;
 
@@ -6826,8 +6939,8 @@ sweep_symbols (void)
           sprev = &sblk->next;
         }
     }
-  total_symbols = num_used;
-  total_free_symbols = num_free;
+  gcstat.total_symbols = num_used;
+  gcstat.total_free_symbols = num_free;
 }
 
 /* Remove BUFFER's markers that are due to be swept.  This is needed since
@@ -6838,7 +6951,7 @@ unchain_dead_markers (struct buffer *buffer)
   struct Lisp_Marker *this, **prev = &BUF_MARKERS (buffer);
 
   while ((this = *prev))
-    if (VECTOR_MARKED_P (this))
+    if (vectorlike_marked_p (&this->header))
       prev = &this->next;
     else
       {
@@ -6851,22 +6964,23 @@ NO_INLINE /* For better stack traces */
 static void
 sweep_buffers (void)
 {
-  register struct buffer *buffer, **bprev = &all_buffers;
+  struct buffer *buffer, **bprev = &all_buffers;
 
-  total_buffers = 0;
+  gcstat.total_buffers = 0;
   for (buffer = all_buffers; buffer; buffer = *bprev)
-    if (!VECTOR_MARKED_P (buffer))
+    if (!vectorlike_marked_p (&buffer->header))
       {
         *bprev = buffer->next;
         lisp_free (buffer);
       }
     else
       {
-        VECTOR_UNMARK (buffer);
+        if (!pdumper_object_p (buffer))
+          XUNMARK_VECTOR (buffer);
         /* Do not use buffer_(set|get)_intervals here.  */
         buffer->text->intervals = balance_intervals (buffer->text->intervals);
         unchain_dead_markers (buffer);
-        total_buffers++;
+       gcstat.total_buffers++;
         bprev = &buffer->next;
       }
 }
@@ -6875,10 +6989,6 @@ sweep_buffers (void)
 static void
 gc_sweep (void)
 {
-  /* Remove or mark entries in weak hash tables.
-     This must be done before any object is unmarked.  */
-  sweep_weak_hash_tables ();
-
   sweep_strings ();
   check_string_bytes (!noninteractive);
   sweep_conses ();
@@ -6887,6 +6997,7 @@ gc_sweep (void)
   sweep_symbols ();
   sweep_buffers ();
   sweep_vectors ();
+  pdumper_clear_marks ();
   check_string_bytes (!noninteractive);
 }
 
@@ -6954,14 +7065,13 @@ Frames, windows, buffers, and subprocesses count as 
vectors
   (but the contents of a buffer's text do not count here).  */)
   (void)
 {
-  return listn (CONSTYPE_HEAP, 7,
-               bounded_number (cons_cells_consed),
-               bounded_number (floats_consed),
-               bounded_number (vector_cells_consed),
-               bounded_number (symbols_consed),
-               bounded_number (string_chars_consed),
-               bounded_number (intervals_consed),
-               bounded_number (strings_consed));
+  return  list (make_int (cons_cells_consed),
+               make_int (floats_consed),
+               make_int (vector_cells_consed),
+               make_int (symbols_consed),
+               make_int (string_chars_consed),
+               make_int (intervals_consed),
+               make_int (strings_consed));
 }
 
 static bool
@@ -7139,19 +7249,34 @@ verify_alloca (void)
 
 /* Initialization.  */
 
+static void init_alloc_once_for_pdumper (void);
+
 void
 init_alloc_once (void)
 {
+  gc_cons_threshold = GC_DEFAULT_THRESHOLD;
   /* Even though Qt's contents are not set up, its address is known.  */
   Vpurify_flag = Qt;
 
-  purebeg = PUREBEG;
-  pure_size = PURESIZE;
+  PDUMPER_REMEMBER_SCALAR (buffer_defaults.header);
+  PDUMPER_REMEMBER_SCALAR (buffer_local_symbols.header);
+
+  /* Call init_alloc_once_for_pdumper now so we run mem_init early.
+     Keep in mind that when we reload from a dump, we'll run _only_
+     init_alloc_once_for_pdumper and not init_alloc_once at all.  */
+  pdumper_do_now_and_after_load (init_alloc_once_for_pdumper);
 
   verify_alloca ();
-  init_finalizer_list (&finalizers);
-  init_finalizer_list (&doomed_finalizers);
 
+  init_strings ();
+  init_vectors ();
+}
+
+static void
+init_alloc_once_for_pdumper (void)
+{
+  purebeg = PUREBEG;
+  pure_size = PURESIZE;
   mem_init ();
   Vdead = make_pure_string ("DEAD", 4, 4, 0);
 
@@ -7160,11 +7285,11 @@ init_alloc_once (void)
   mallopt (M_MMAP_THRESHOLD, 64 * 1024);  /* Mmap threshold.  */
   mallopt (M_MMAP_MAX, MMAP_MAX_AREAS);   /* Max. number of mmap'ed areas.  */
 #endif
-  init_strings ();
-  init_vectors ();
 
+
+  init_finalizer_list (&finalizers);
+  init_finalizer_list (&doomed_finalizers);
   refill_memory_reserve ();
-  gc_cons_threshold = GC_DEFAULT_THRESHOLD;
 }
 
 void
@@ -7172,10 +7297,6 @@ init_alloc (void)
 {
   Vgc_elapsed = make_float (0.0);
   gcs_done = 0;
-
-#if USE_VALGRIND
-  valgrind_p = RUNNING_ON_VALGRIND != 0;
-#endif
 }
 
 void
@@ -7244,8 +7365,10 @@ do hash-consing of the objects allocated to pure space.  
*/);
   /* We build this in advance because if we wait until we need it, we might
      not be able to allocate the memory to hold it.  */
   Vmemory_signal_data
-    = listn (CONSTYPE_PURE, 2, Qerror,
-            build_pure_c_string ("Memory exhausted--use M-x save-some-buffers 
then exit and restart Emacs"));
+    = pure_list (Qerror,
+                build_pure_c_string ("Memory exhausted--use"
+                                     " M-x save-some-buffers then"
+                                     " exit and restart Emacs"));
 
   DEFVAR_LISP ("memory-full", Vmemory_full,
               doc: /* Non-nil means Emacs cannot get much more Lisp memory.  
*/);
@@ -7298,6 +7421,12 @@ than 2**N, where N is this variable's value.  N should 
be nonnegative.  */);
   defsubr (&Ssuspicious_object);
 }
 
+#ifdef HAVE_X_WINDOWS
+enum defined_HAVE_X_WINDOWS { defined_HAVE_X_WINDOWS = true };
+#else
+enum defined_HAVE_X_WINDOWS { defined_HAVE_X_WINDOWS = false };
+#endif
+
 /* When compiled with GCC, GDB might say "No enum type named
    pvec_type" if we don't have at least one symbol with that type, and
    then xbacktrace could fail.  Similarly for the other enums and
@@ -7316,5 +7445,6 @@ union
   enum MAX_ALLOCA MAX_ALLOCA;
   enum More_Lisp_Bits More_Lisp_Bits;
   enum pvec_type pvec_type;
+  enum defined_HAVE_X_WINDOWS defined_HAVE_X_WINDOWS;
 } const EXTERNALLY_VISIBLE gdb_make_enums_visible = {0};
 #endif /* __GNUC__ */
diff --git a/src/atimer.c b/src/atimer.c
index 505f6bc..8387b8a 100644
--- a/src/atimer.c
+++ b/src/atimer.c
@@ -1,5 +1,5 @@
 /* Asynchronous timers.
-   Copyright (C) 2000-2018 Free Software Foundation, Inc.
+   Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -28,7 +28,10 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #ifdef HAVE_TIMERFD
 #include <errno.h>
-# include <sys/timerfd.h>
+#include <sys/timerfd.h>
+# ifdef CYGWIN
+# include <sys/utsname.h>
+# endif
 #endif
 
 #ifdef MSDOS
@@ -557,13 +560,28 @@ Return t if all self-tests are passed, nil otherwise.  */)
 
 #endif /* ENABLE_CHECKING */
 
+/* Cygwin has the timerfd interface starting with release 3.0.0, but
+   it is buggy until release 3.0.2. */
+#ifdef HAVE_TIMERFD
+static bool
+have_buggy_timerfd (void)
+{
+# ifdef CYGWIN
+  struct utsname name;
+  return uname (&name) < 0 || strverscmp (name.release, "3.0.2") < 0;
+# else
+  return false;
+# endif
+}
+#endif
+
 void
 init_atimer (void)
 {
 #ifdef HAVE_ITIMERSPEC
 # ifdef HAVE_TIMERFD
   /* Until this feature is considered stable, you can ask to not use it.  */
-  timerfd = (egetenv ("EMACS_IGNORE_TIMERFD") ? -1 :
+  timerfd = (egetenv ("EMACS_IGNORE_TIMERFD") || have_buggy_timerfd () ? -1 :
             timerfd_create (CLOCK_REALTIME, TFD_NONBLOCK | TFD_CLOEXEC));
 # endif
   if (timerfd < 0)
@@ -584,6 +602,7 @@ init_atimer (void)
   sigaction (SIGALRM, &action, 0);
 
 #ifdef ENABLE_CHECKING
-  defsubr (&Sdebug_timer_check);
+  if (!initialized)
+    defsubr (&Sdebug_timer_check);
 #endif
 }
diff --git a/src/atimer.h b/src/atimer.h
index 2c917a0..dbc9d56 100644
--- a/src/atimer.h
+++ b/src/atimer.h
@@ -1,5 +1,5 @@
 /* Asynchronous timers.
-   Copyright (C) 2000-2018 Free Software Foundation, Inc.
+   Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/bidi.c b/src/bidi.c
index a53a229..c530d49 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -1,6 +1,6 @@
 /* Low-level bidirectional buffer/string-scanning functions for GNU Emacs.
 
-Copyright (C) 2000-2001, 2004-2005, 2009-2018 Free Software Foundation, Inc.
+Copyright (C) 2000-2001, 2004-2005, 2009-2019 Free Software Foundation, Inc.
 
 Author: Eli Zaretskii <address@hidden>
 
@@ -2335,7 +2335,7 @@ bidi_resolve_weak (struct bidi_it *bidi_it)
                      and make it L right away, to avoid the
                      potentially costly loop below.  This is
                      important when the buffer has a long series of
-                     control characters, like binary nulls, and no
+                     control characters, like binary NULs, and no
                      R2L characters at all.  */
                   && new_level == 0
                   && !bidi_explicit_dir_char (bidi_it->ch)
@@ -2993,7 +2993,7 @@ bidi_resolve_neutral (struct bidi_it *bidi_it)
        }
       /* The next two "else if" clauses are shortcuts for the
         important special case when we have a long sequence of
-        neutral or WEAK_BN characters, such as whitespace or nulls or
+        neutral or WEAK_BN characters, such as whitespace or NULs or
         other control characters, on the base embedding level of the
         paragraph, and that sequence goes all the way to the end of
         the paragraph and follows a character whose resolved
diff --git a/src/bignum.c b/src/bignum.c
index e3db037..009d731 100644
--- a/src/bignum.c
+++ b/src/bignum.c
@@ -1,6 +1,6 @@
 /* Big numbers for Emacs.
 
-Copyright 2018 Free Software Foundation, Inc.
+Copyright 2018-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -86,8 +86,8 @@ make_bignum_bits (size_t bits)
   if (integer_width < bits)
     overflow_error ();
 
-  struct Lisp_Bignum *b = ALLOCATE_PSEUDOVECTOR (struct Lisp_Bignum, value,
-                                                PVEC_BIGNUM);
+  struct Lisp_Bignum *b = ALLOCATE_PLAIN_PSEUDOVECTOR (struct Lisp_Bignum,
+                                                      PVEC_BIGNUM);
   mpz_init (b->value);
   mpz_swap (b->value, mpz[0]);
   return make_lisp_ptr (b, Lisp_Vectorlike);
@@ -271,7 +271,7 @@ bignum_to_uintmax (Lisp_Object x)
 
 /* Yield an upper bound on the buffer size needed to contain a C
    string representing the NUM in base BASE.  This includes any
-   preceding '-' and the terminating null.  */
+   preceding '-' and the terminating NUL.  */
 static ptrdiff_t
 mpz_bufsize (mpz_t const num, int base)
 {
@@ -336,14 +336,14 @@ bignum_to_string (Lisp_Object num, int base)
 
 /* Create a bignum by scanning NUM, with digits in BASE.
    NUM must consist of an optional '-', a nonempty sequence
-   of base-BASE digits, and a terminating null byte, and
+   of base-BASE digits, and a terminating NUL byte, and
    the represented number must not be in fixnum range.  */
 
 Lisp_Object
 make_bignum_str (char const *num, int base)
 {
-  struct Lisp_Bignum *b = ALLOCATE_PSEUDOVECTOR (struct Lisp_Bignum, value,
-                                                PVEC_BIGNUM);
+  struct Lisp_Bignum *b = ALLOCATE_PLAIN_PSEUDOVECTOR (struct Lisp_Bignum,
+                                                      PVEC_BIGNUM);
   mpz_init (b->value);
   int check = mpz_set_str (b->value, num, base);
   eassert (check == 0);
diff --git a/src/bignum.h b/src/bignum.h
index fd035e6..4c670bd 100644
--- a/src/bignum.h
+++ b/src/bignum.h
@@ -1,6 +1,6 @@
 /* Big numbers for Emacs.
 
-Copyright 2018 Free Software Foundation, Inc.
+Copyright 2018-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/blockinput.h b/src/blockinput.h
index 2739050..cd2eddb 100644
--- a/src/blockinput.h
+++ b/src/blockinput.h
@@ -1,5 +1,5 @@
 /* blockinput.h - interface to blocking complicated interrupt-driven input.
-   Copyright (C) 1989, 1993, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1989, 1993, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/buffer.c b/src/buffer.c
index a71bd77..ab47748 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1,6 +1,6 @@
 /* Buffer manipulation primitives for GNU Emacs.
 
-Copyright (C) 1985-1989, 1993-1995, 1997-2018 Free Software Foundation,
+Copyright (C) 1985-1989, 1993-1995, 1997-2019 Free Software Foundation,
 Inc.
 
 This file is part of GNU Emacs.
@@ -37,6 +37,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "window.h"
 #include "commands.h"
 #include "character.h"
+#include "coding.h"
 #include "buffer.h"
 #include "region-cache.h"
 #include "indent.h"
@@ -44,6 +45,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "keymap.h"
 #include "frame.h"
 #include "xwidget.h"
+#include "pdumper.h"
 
 #ifdef WINDOWSNT
 #include "w32heap.h"           /* for mmap_* */
@@ -466,7 +468,7 @@ See also `find-buffer-visiting'.  */)
   filename = Fexpand_file_name (filename, Qnil);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (filename, Qget_file_buffer);
   if (!NILP (handler))
     {
@@ -529,6 +531,8 @@ even if it is dead.  The return value is never nil.  */)
   /* No one shows us now.  */
   b->window_count = 0;
 
+  memset (&b->local_flags, 0, sizeof (b->local_flags));
+
   BUF_GAP_SIZE (b) = 20;
   block_input ();
   /* We allocate extra 1-byte at the tail and keep it always '\0' for
@@ -580,6 +584,11 @@ even if it is dead.  The return value is never nil.  */)
   set_string_intervals (name, NULL);
   bset_name (b, name);
 
+  b->inhibit_buffer_hooks
+    = (STRINGP (Vcode_conversion_workbuf_name)
+       && strncmp (SSDATA (name), SSDATA (Vcode_conversion_workbuf_name),
+                  SBYTES (Vcode_conversion_workbuf_name)) == 0);
+
   bset_undo_list (b, SREF (name, 0) != ' ' ? Qnil : Qt);
 
   reset_buffer (b);
@@ -592,7 +601,7 @@ even if it is dead.  The return value is never nil.  */)
   XSETBUFFER (buffer, b);
   Vbuffer_alist = nconc2 (Vbuffer_alist, list1 (Fcons (name, buffer)));
   /* And run buffer-list-update-hook.  */
-  if (!NILP (Vrun_hooks))
+  if (!NILP (Vrun_hooks) && !b->inhibit_buffer_hooks)
     call1 (Vrun_hooks, Qbuffer_list_update_hook);
 
   return buffer;
@@ -781,6 +790,8 @@ CLONE nil means the indirect buffer's state is reset to 
default values.  */)
   /* Always -1 for an indirect buffer.  */
   b->window_count = -1;
 
+  memset (&b->local_flags, 0, sizeof (b->local_flags));
+
   b->pt = b->base_buffer->pt;
   b->begv = b->base_buffer->begv;
   b->zv = b->base_buffer->zv;
@@ -1196,7 +1207,7 @@ buffer_local_value (Lisp_Object variable, Lisp_Object 
buffer)
        result = Fassoc (variable, BVAR (buf, local_var_alist), Qnil);
        if (!NILP (result))
          {
-           if (blv->fwd)
+           if (blv->fwd.fwdptr)
              { /* What binding is loaded right now?  */
                Lisp_Object current_alist_element = blv->valcell;
 
@@ -1217,7 +1228,7 @@ buffer_local_value (Lisp_Object variable, Lisp_Object 
buffer)
       }
     case SYMBOL_FORWARDED:
       {
-       union Lisp_Fwd *fwd = SYMBOL_FWD (sym);
+       lispfwd fwd = SYMBOL_FWD (sym);
        if (BUFFER_OBJFWDP (fwd))
          result = per_buffer_value (buf, XBUFFER_OBJFWD (fwd)->offset);
        else
@@ -1408,7 +1419,7 @@ state of the current buffer.  Use with care.  */)
                 /* If SAVE_MODIFF == auto_save_modified == MODIFF,
                    we can either decrease SAVE_MODIFF and auto_save_modified
                    or increase MODIFF.  */
-                : MODIFF++);
+                : modiff_incr (&MODIFF));
 
   return flag;
 }
@@ -1417,11 +1428,11 @@ DEFUN ("buffer-modified-tick", Fbuffer_modified_tick, 
Sbuffer_modified_tick,
        0, 1, 0,
        doc: /* Return BUFFER's tick counter, incremented for each change in 
text.
 Each buffer has a tick counter which is incremented each time the
-text in that buffer is changed.  It wraps around occasionally.
-No argument or nil as argument means use current buffer as BUFFER.  */)
-  (register Lisp_Object buffer)
+text in that buffer is changed.  No argument or nil as argument means
+use current buffer as BUFFER.  */)
+  (Lisp_Object buffer)
 {
-  return make_fixnum (BUF_MODIFF (decode_buffer (buffer)));
+  return modiff_to_integer (BUF_MODIFF (decode_buffer (buffer)));
 }
 
 DEFUN ("buffer-chars-modified-tick", Fbuffer_chars_modified_tick,
@@ -1434,9 +1445,9 @@ values returned by two individual calls of 
`buffer-chars-modified-tick',
 you can tell whether a character change occurred in that buffer in
 between these calls.  No argument or nil as argument means use current
 buffer as BUFFER.  */)
-  (register Lisp_Object buffer)
+  (Lisp_Object buffer)
 {
-  return make_fixnum (BUF_CHARS_MODIFF (decode_buffer (buffer)));
+  return modiff_to_integer (BUF_CHARS_MODIFF (decode_buffer (buffer)));
 }
 
 DEFUN ("rename-buffer", Frename_buffer, Srename_buffer, 1, 2,
@@ -1488,7 +1499,7 @@ This does not change the name of the visited file (if 
any).  */)
     call0 (intern ("rename-auto-save-file"));
 
   /* Run buffer-list-update-hook.  */
-  if (!NILP (Vrun_hooks))
+  if (!NILP (Vrun_hooks) && !current_buffer->inhibit_buffer_hooks)
     call1 (Vrun_hooks, Qbuffer_list_update_hook);
 
   /* Refetch since that last call may have done GC.  */
@@ -1701,10 +1712,13 @@ cleaning up all windows currently displaying the buffer 
to be killed. */)
 
     /* First run the query functions; if any query is answered no,
        don't kill the buffer.  */
-    tem = CALLN (Frun_hook_with_args_until_failure,
-                Qkill_buffer_query_functions);
-    if (NILP (tem))
-      return unbind_to (count, Qnil);
+    if (!b->inhibit_buffer_hooks)
+      {
+       tem = CALLN (Frun_hook_with_args_until_failure,
+                    Qkill_buffer_query_functions);
+       if (NILP (tem))
+         return unbind_to (count, Qnil);
+      }
 
     /* Query if the buffer is still modified.  */
     if (INTERACTIVE && !NILP (BVAR (b, filename))
@@ -1721,7 +1735,8 @@ cleaning up all windows currently displaying the buffer 
to be killed. */)
       return unbind_to (count, Qt);
 
     /* Then run the hooks.  */
-    run_hook (Qkill_buffer_hook);
+    if (!b->inhibit_buffer_hooks)
+      run_hook (Qkill_buffer_hook);
     unbind_to (count, Qnil);
   }
 
@@ -1923,7 +1938,7 @@ cleaning up all windows currently displaying the buffer 
to be killed. */)
   bset_undo_list (b, Qnil);
 
   /* Run buffer-list-update-hook.  */
-  if (!NILP (Vrun_hooks))
+  if (!NILP (Vrun_hooks) && !b->inhibit_buffer_hooks)
     call1 (Vrun_hooks, Qbuffer_list_update_hook);
 
   return Qt;
@@ -1965,7 +1980,7 @@ record_buffer (Lisp_Object buffer)
   fset_buried_buffer_list (f, Fdelq (buffer, f->buried_buffer_list));
 
   /* Run buffer-list-update-hook.  */
-  if (!NILP (Vrun_hooks))
+  if (!NILP (Vrun_hooks) && !XBUFFER (buffer)->inhibit_buffer_hooks)
     call1 (Vrun_hooks, Qbuffer_list_update_hook);
 }
 
@@ -2004,7 +2019,7 @@ DEFUN ("bury-buffer-internal", Fbury_buffer_internal, 
Sbury_buffer_internal,
     (f, Fcons (buffer, Fdelq (buffer, f->buried_buffer_list)));
 
   /* Run buffer-list-update-hook.  */
-  if (!NILP (Vrun_hooks))
+  if (!NILP (Vrun_hooks) && !XBUFFER (buffer)->inhibit_buffer_hooks)
     call1 (Vrun_hooks, Qbuffer_list_update_hook);
 
   return Qnil;
@@ -2125,7 +2140,7 @@ void set_buffer_internal_2 (register struct buffer *b)
          Lisp_Object var = XCAR (XCAR (tail));
          struct Lisp_Symbol *sym = XSYMBOL (var);
          if (sym->u.s.redirect == SYMBOL_LOCALIZED /* Just to be sure.  */
-             && SYMBOL_BLV (sym)->fwd)
+             && SYMBOL_BLV (sym)->fwd.fwdptr)
            /* Just reference the variable
               to cause it to become set for this buffer.  */
            Fsymbol_value (var);
@@ -2370,9 +2385,12 @@ results, see Info node `(elisp)Swapping Text'.  */)
   bset_point_before_scroll (current_buffer, Qnil);
   bset_point_before_scroll (other_buffer, Qnil);
 
-  current_buffer->text->modiff++;        other_buffer->text->modiff++;
-  current_buffer->text->chars_modiff++;          
other_buffer->text->chars_modiff++;
-  current_buffer->text->overlay_modiff++; other_buffer->text->overlay_modiff++;
+  modiff_incr (&current_buffer->text->modiff);
+  modiff_incr (&other_buffer->text->modiff);
+  modiff_incr (&current_buffer->text->chars_modiff);
+  modiff_incr (&other_buffer->text->chars_modiff);
+  modiff_incr (&current_buffer->text->overlay_modiff);
+  modiff_incr (&other_buffer->text->overlay_modiff);
   current_buffer->text->beg_unchanged = current_buffer->text->gpt;
   current_buffer->text->end_unchanged = current_buffer->text->gpt;
   other_buffer->text->beg_unchanged = other_buffer->text->gpt;
@@ -3908,7 +3926,7 @@ modify_overlay (struct buffer *buf, ptrdiff_t start, 
ptrdiff_t end)
 
   bset_redisplay (buf);
 
-  ++BUF_OVERLAY_MODIFF (buf);
+  modiff_incr (&BUF_OVERLAY_MODIFF (buf));
 }
 
 /* Remove OVERLAY from LIST.  */
@@ -5001,24 +5019,37 @@ alloc_buffer_text (struct buffer *b, ptrdiff_t nbytes)
 void
 enlarge_buffer_text (struct buffer *b, ptrdiff_t delta)
 {
-  void *p;
-  ptrdiff_t nbytes = (BUF_Z_BYTE (b) - BUF_BEG_BYTE (b) + BUF_GAP_SIZE (b) + 1
-                     + delta);
   block_input ();
+  void *p;
+  unsigned char *old_beg = b->text->beg;
+  ptrdiff_t old_nbytes =
+    BUF_Z_BYTE (b) - BUF_BEG_BYTE (b) + BUF_GAP_SIZE (b) + 1;
+  ptrdiff_t new_nbytes = old_nbytes + delta;
+
+  if (pdumper_object_p (old_beg))
+    b->text->beg = NULL;
+  else
+    old_beg = NULL;
+
 #if defined USE_MMAP_FOR_BUFFERS
-  p = mmap_realloc ((void **) &b->text->beg, nbytes);
+  p = mmap_realloc ((void **) &b->text->beg, new_nbytes);
 #elif defined REL_ALLOC
-  p = r_re_alloc ((void **) &b->text->beg, nbytes);
+  p = r_re_alloc ((void **) &b->text->beg, new_nbytes);
 #else
-  p = xrealloc (b->text->beg, nbytes);
+  p = xrealloc (b->text->beg, new_nbytes);
 #endif
 
   if (p == NULL)
     {
+      if (old_beg)
+        b->text->beg = old_beg;
       unblock_input ();
-      memory_full (nbytes);
+      memory_full (new_nbytes);
     }
 
+  if (old_beg)
+    memcpy (p, old_beg, min (old_nbytes, new_nbytes));
+
   BUF_BEG_ADDR (b) = p;
   unblock_input ();
 }
@@ -5031,13 +5062,16 @@ free_buffer_text (struct buffer *b)
 {
   block_input ();
 
+  if (!pdumper_object_p (b->text->beg))
+    {
 #if defined USE_MMAP_FOR_BUFFERS
-  mmap_free ((void **) &b->text->beg);
+      mmap_free ((void **) &b->text->beg);
 #elif defined REL_ALLOC
-  r_alloc_free ((void **) &b->text->beg);
+      r_alloc_free ((void **) &b->text->beg);
 #else
-  xfree (b->text->beg);
+      xfree (b->text->beg);
 #endif
+    }
 
   BUF_BEG_ADDR (b) = NULL;
   unblock_input ();
@@ -5048,14 +5082,25 @@ free_buffer_text (struct buffer *b)
 /***********************************************************************
                            Initialization
  ***********************************************************************/
-
 void
 init_buffer_once (void)
 {
+  /* TODO: clean up the buffer-local machinery.  Right now,
+     we have:
+
+     buffer_defaults: default values of buffer-locals
+     buffer_local_flags: metadata
+     buffer_permanent_local_flags: metadata
+     buffer_local_symbols: metadata
+
+     There must be a simpler way to store the metadata.
+  */
+
   int idx;
 
   /* Items flagged permanent get an explicit permanent-local property
      added in bindings.el, for clarity.  */
+  PDUMPER_REMEMBER_SCALAR (buffer_permanent_local_flags);
   memset (buffer_permanent_local_flags, 0, sizeof 
buffer_permanent_local_flags);
 
   /* 0 means not a lisp var, -1 means always local, else mask.  */
@@ -5144,10 +5189,15 @@ init_buffer_once (void)
   XSETFASTINT (BVAR (&buffer_local_flags, extra_line_spacing), idx); ++idx;
   XSETFASTINT (BVAR (&buffer_local_flags, cursor_in_non_selected_windows), 
idx); ++idx;
 
+  /* buffer_local_flags contains no pointers, so it's safe to treat it
+     as a blob for pdumper.  */
+  PDUMPER_REMEMBER_SCALAR (buffer_local_flags);
+
   /* Need more room? */
   if (idx >= MAX_PER_BUFFER_VARS)
     emacs_abort ();
   last_per_buffer_idx = idx;
+  PDUMPER_REMEMBER_SCALAR (last_per_buffer_idx);
 
   /* Make sure all markable slots in buffer_defaults
      are initialized reasonably, so mark_buffer won't choke.  */
@@ -5242,7 +5292,9 @@ init_buffer_once (void)
 
   Vbuffer_alist = Qnil;
   current_buffer = 0;
+  pdumper_remember_lv_ptr_raw (&current_buffer, Lisp_Vectorlike);
   all_buffers = 0;
+  pdumper_remember_lv_ptr_raw (&all_buffers, Lisp_Vectorlike);
 
   QSFundamental = build_pure_c_string ("Fundamental");
 
@@ -5266,12 +5318,12 @@ init_buffer_once (void)
 }
 
 void
-init_buffer (int initialized)
+init_buffer (void)
 {
   Lisp_Object temp;
 
 #ifdef USE_MMAP_FOR_BUFFERS
-  if (initialized)
+  if (dumped_with_unexec_p ())
     {
       struct buffer *b;
 
@@ -5312,9 +5364,6 @@ init_buffer (int initialized)
          eassert (b->text->beg != NULL);
        }
     }
-#else  /* not USE_MMAP_FOR_BUFFERS */
-  /* Avoid compiler warnings.  */
-  (void) initialized;
 #endif /* USE_MMAP_FOR_BUFFERS */
 
   AUTO_STRING (scratch, "*scratch*");
@@ -5395,7 +5444,7 @@ defvar_per_buffer (struct Lisp_Buffer_Objfwd *bo_fwd, 
const char *namestring,
   bo_fwd->predicate = predicate;
   sym->u.s.declared_special = true;
   sym->u.s.redirect = SYMBOL_FORWARDED;
-  SET_SYMBOL_FWD (sym, (union Lisp_Fwd *) bo_fwd);
+  SET_SYMBOL_FWD (sym, bo_fwd);
   XSETSYMBOL (PER_BUFFER_SYMBOL (offset), sym);
 
   if (PER_BUFFER_IDX (offset) == 0)
@@ -5448,7 +5497,7 @@ syms_of_buffer (void)
               Qoverwrite_mode_binary));
 
   Fput (Qprotected_field, Qerror_conditions,
-       listn (CONSTYPE_PURE, 2, Qprotected_field, Qerror));
+       pure_list (Qprotected_field, Qerror));
   Fput (Qprotected_field, Qerror_message,
        build_pure_c_string ("Attempt to modify a protected field"));
 
@@ -6217,9 +6266,11 @@ The function `kill-all-local-variables' runs this before 
doing anything else.  *
 
   DEFVAR_LISP ("buffer-list-update-hook", Vbuffer_list_update_hook,
               doc: /* Hook run when the buffer list changes.
-Functions running this hook are, `get-buffer-create',
-`make-indirect-buffer', `rename-buffer', `kill-buffer',
-`bury-buffer-internal' and `select-window'.  */);
+Functions (implicitly) running this hook are `get-buffer-create',
+`make-indirect-buffer', `rename-buffer', `kill-buffer', `bury-buffer'
+and `select-window'.  Functions run by this hook should avoid calling
+`select-window' with a nil NORECORD argument or `with-temp-buffer'
+since either may lead to infinite recursion.  */);
   Vbuffer_list_update_hook = Qnil;
   DEFSYM (Qbuffer_list_update_hook, "buffer-list-update-hook");
 
diff --git a/src/buffer.h b/src/buffer.h
index 4ea7fa6..f42c3e9 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1,6 +1,6 @@
 /* Header file for the buffer manipulation primitives.
 
-Copyright (C) 1985-1986, 1993-1995, 1997-2018 Free Software Foundation,
+Copyright (C) 1985-1986, 1993-1995, 1997-2019 Free Software Foundation,
 Inc.
 
 This file is part of GNU Emacs.
@@ -422,20 +422,20 @@ struct buffer_text
     ptrdiff_t gpt_byte;                /* Byte pos of gap in buffer.  */
     ptrdiff_t z_byte;          /* Byte pos of end of buffer.  */
     ptrdiff_t gap_size;                /* Size of buffer's gap.  */
-    EMACS_INT modiff;          /* This counts buffer-modification events
+    modiff_count modiff;       /* This counts buffer-modification events
                                   for this buffer.  It is incremented for
                                   each such event, and never otherwise
                                   changed.  */
-    EMACS_INT chars_modiff;    /* This is modified with character change
+    modiff_count chars_modiff; /* This is modified with character change
                                   events for this buffer.  It is set to
                                   modiff for each such event, and never
                                   otherwise changed.  */
-    EMACS_INT save_modiff;     /* Previous value of modiff, as of last
+    modiff_count save_modiff;  /* Previous value of modiff, as of last
                                   time buffer visited or saved a file.  */
 
-    EMACS_INT overlay_modiff;  /* Counts modifications to overlays.  */
+    modiff_count overlay_modiff; /* Counts modifications to overlays.  */
 
-    EMACS_INT compact;         /* Set to modiff each time when compact_buffer
+    modiff_count compact;      /* Set to modiff each time when compact_buffer
                                   is called for this buffer.  */
 
     /* Minimum value of GPT - BEG since last redisplay that finished.  */
@@ -446,12 +446,12 @@ struct buffer_text
 
     /* MODIFF as of last redisplay that finished; if it matches MODIFF,
        beg_unchanged and end_unchanged contain no useful information.  */
-    EMACS_INT unchanged_modified;
+    modiff_count unchanged_modified;
 
     /* BUF_OVERLAY_MODIFF of current buffer, as of last redisplay that
        finished; if it matches BUF_OVERLAY_MODIFF, beg_unchanged and
        end_unchanged contain no useful information.  */
-    EMACS_INT overlay_unchanged_modified;
+    modiff_count overlay_unchanged_modified;
 
     /* Properties of this buffer's text.  */
     INTERVAL intervals;
@@ -741,8 +741,8 @@ struct buffer
      See `cursor-type' for other values.  */
   Lisp_Object cursor_in_non_selected_windows_;
 
-  /* No more Lisp_Object beyond this point.  Except undo_list,
-     which is handled specially in Fgarbage_collect.  */
+  /* No more Lisp_Object beyond cursor_in_non_selected_windows_.
+     Except undo_list, which is handled specially in Fgarbage_collect.  */
 
   /* This structure holds the coordinates of the buffer contents
      in ordinary buffers.  In indirect buffers, this is not used.  */
@@ -812,11 +812,11 @@ struct buffer
   off_t modtime_size;
 
   /* The value of text->modiff at the last auto-save.  */
-  EMACS_INT auto_save_modified;
+  modiff_count auto_save_modified;
 
   /* The value of text->modiff at the last display error.
      Redisplay of this buffer is inhibited until it changes again.  */
-  EMACS_INT display_error_modiff;
+  modiff_count display_error_modiff;
 
   /* The time at which we detected a failure to auto-save,
      Or 0 if we didn't have a failure.  */
@@ -855,6 +855,13 @@ struct buffer
   /* Non-zero whenever the narrowing is changed in this buffer.  */
   bool_bf clip_changed : 1;
 
+  /* Non-zero for internally used temporary buffers that don't need to
+     run hooks kill-buffer-hook, buffer-list-update-hook, and
+     kill-buffer-query-functions.  This is used in coding.c to avoid
+     slowing down en/decoding when there are a lot of these hooks
+     defined.  */
+  bool_bf inhibit_buffer_hooks : 1;
+
   /* List of overlays that end at or before the current center,
      in order of end-position.  */
   struct Lisp_Overlay *overlays_before;
@@ -1012,14 +1019,12 @@ bset_width_table (struct buffer *b, Lisp_Object val)
    structure, make sure that this is still correct.  */
 
 #define BUFFER_LISP_SIZE                                               \
-  ((offsetof (struct buffer, own_text) - header_size) / word_size)
+  PSEUDOVECSIZE (struct buffer, cursor_in_non_selected_windows_)
 
-/* Size of the struct buffer part beyond leading Lisp_Objects, in word_size
-   units.  Rounding is needed for --with-wide-int configuration.  */
+/* Allocated size of the struct buffer part beyond leading
+   Lisp_Objects, in word_size units.  */
 
-#define BUFFER_REST_SIZE                                               \
-  ((((sizeof (struct buffer) - offsetof (struct buffer, own_text))     \
-     + (word_size - 1)) & ~(word_size - 1)) / word_size)
+#define BUFFER_REST_SIZE (VECSIZE (struct buffer) - BUFFER_LISP_SIZE)
 
 /* Initialize the pseudovector header of buffer object.  BUFFER_LISP_SIZE
    is required for GC, but BUFFER_REST_SIZE is set up just to be consistent
diff --git a/src/bytecode.c b/src/bytecode.c
index 95f7b32..4097779 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -1,5 +1,5 @@
 /* Execution of byte code produced by bytecomp.el.
-   Copyright (C) 1985-1988, 1993, 2000-2018 Free Software Foundation,
+   Copyright (C) 1985-1988, 1993, 2000-2019 Free Software Foundation,
    Inc.
 
 This file is part of GNU Emacs.
@@ -1398,10 +1398,11 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object 
vector, Lisp_Object maxdepth,
               search as the jump table.  */
             Lisp_Object jmp_table = POP;
            if (BYTE_CODE_SAFE && !HASH_TABLE_P (jmp_table))
-             emacs_abort ();
+              emacs_abort ();
             Lisp_Object v1 = POP;
             ptrdiff_t i;
             struct Lisp_Hash_Table *h = XHASH_TABLE (jmp_table);
+            hash_rehash_if_needed (h);
 
             /* h->count is a faster approximation for HASH_TABLE_SIZE (h)
                here. */
diff --git a/src/callint.c b/src/callint.c
index 8741100..88a3c34 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -1,5 +1,5 @@
 /* Call a Lisp function interactively.
-   Copyright (C) 1985-1986, 1993-1995, 1997, 2000-2018 Free Software
+   Copyright (C) 1985-1986, 1993-1995, 1997, 2000-2019 Free Software
    Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -572,7 +572,7 @@ invoke it.  If KEYS is omitted or nil, the return value of
            /* If the key sequence ends with a down-event,
               discard the following up-event.  */
            Lisp_Object teml
-             = Faref (args[i], make_fixnum (XFIXNUM (Flength (args[i])) - 1));
+             = Faref (args[i], make_fixnum (ASIZE (args[i]) - 1));
            if (CONSP (teml))
              teml = XCAR (teml);
            if (SYMBOLP (teml))
@@ -714,7 +714,7 @@ invoke it.  If KEYS is omitted or nil, the return value of
        default:
          {
            /* How many bytes are left unprocessed in the specs string?
-              (Note that this excludes the trailing null byte.)  */
+              (Note that this excludes the trailing NUL byte.)  */
            ptrdiff_t bytes_left = string_len - (tem - string);
            unsigned letter;
 
@@ -814,11 +814,11 @@ syms_of_callint (void)
   callint_message = Qnil;
   staticpro (&callint_message);
 
-  preserved_fns = listn (CONSTYPE_PURE, 4,
-                        intern_c_string ("region-beginning"),
-                        intern_c_string ("region-end"),
-                        intern_c_string ("point"),
-                        intern_c_string ("mark"));
+  preserved_fns = pure_list (intern_c_string ("region-beginning"),
+                            intern_c_string ("region-end"),
+                            intern_c_string ("point"),
+                            intern_c_string ("mark"));
+  staticpro (&preserved_fns);
 
   DEFSYM (Qlist, "list");
   DEFSYM (Qlet, "let");
diff --git a/src/callproc.c b/src/callproc.c
index 9f47c79..98c6731 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1,6 +1,6 @@
 /* Synchronous subprocess invocation for GNU Emacs.
 
-Copyright (C) 1985-1988, 1993-1995, 1999-2018 Free Software Foundation,
+Copyright (C) 1985-1988, 1993-1995, 1999-2019 Free Software Foundation,
 Inc.
 
 This file is part of GNU Emacs.
@@ -237,7 +237,7 @@ DESTINATION can also have the form (REAL-BUFFER 
STDERR-FILE); in that case,
  t (mix it with ordinary output), or a file name string.
 
 Fourth arg DISPLAY non-nil means redisplay buffer as output is inserted.
-Remaining arguments are strings passed as command arguments to PROGRAM.
+Remaining arguments ARGS are strings passed as command arguments to PROGRAM.
 
 If executable PROGRAM can't be found as an executable, `call-process'
 signals a Lisp error.  `call-process' reports errors in execution of
@@ -681,7 +681,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int 
filefd,
   unblock_input ();
 
   if (pid < 0)
-    report_file_errno ("Doing vfork", Qnil, child_errno);
+    report_file_errno (CHILD_SETUP_ERROR_DESC, Qnil, child_errno);
 
   /* Close our file descriptors, except for callproc_fd[CALLPROC_PIPEREAD]
      since we will use that to read input from.  */
@@ -1033,7 +1033,8 @@ STDERR-FILE may be nil (discard standard error output),
 t (mix it with ordinary output), or a file name string.
 
 Sixth arg DISPLAY non-nil means redisplay buffer as output is inserted.
-Remaining args are passed to PROGRAM at startup as command args.
+Remaining arguments ARGS are passed to PROGRAM at startup as command-line
+arguments.
 
 If BUFFER is 0, `call-process-region' returns immediately with value nil.
 Otherwise it waits for PROGRAM to terminate
@@ -1134,7 +1135,7 @@ add_env (char **env, char **new_env, char *string)
    mess up the allocator's data structures in the parent.
    Report the error and exit the child.  */
 
-static _Noreturn void
+static AVOID
 exec_failed (char const *name, int err)
 {
   /* Avoid deadlock if the child's perror writes to a full pipe; the
@@ -1173,7 +1174,7 @@ exec_failed (char const *name, int err)
    executable directory by the parent.
 
    On GNUish hosts, either exec or return an error number.
-   On MS-Windows, either return a pid or signal an error.
+   On MS-Windows, either return a pid or return -1 and set errno.
    On MS-DOS, either return an exit status or signal an error.  */
 
 CHILD_SETUP_TYPE
@@ -1318,9 +1319,6 @@ child_setup (int in, int out, int err, char **new_argv, 
bool set_pgrp,
   /* Spawn the child.  (See w32proc.c:sys_spawnve).  */
   cpid = spawnve (_P_NOWAIT, new_argv[0], new_argv, env);
   reset_standard_handles (in, out, err, handles);
-  if (cpid == -1)
-    /* An error occurred while trying to spawn the process.  */
-    report_file_error ("Spawning child process", Qnil);
   return cpid;
 
 #else  /* not WINDOWSNT */
@@ -1588,9 +1586,7 @@ init_callproc (void)
        }
     }
 
-#ifndef CANNOT_DUMP
-  if (initialized)
-#endif
+  if (!will_dump_p ())
     {
       tempdir = Fdirectory_file_name (Vexec_directory);
       if (! file_accessible_directory_p (tempdir))
diff --git a/src/casefiddle.c b/src/casefiddle.c
index 95857d6..3f407ea 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -1,7 +1,7 @@
 /* -*- coding: utf-8 -*- */
 /* GNU Emacs case conversion functions.
 
-Copyright (C) 1985, 1994, 1997-1999, 2001-2018 Free Software Foundation,
+Copyright (C) 1985, 1994, 1997-1999, 2001-2019 Free Software Foundation,
 Inc.
 
 This file is part of GNU Emacs.
diff --git a/src/casetab.c b/src/casetab.c
index 0e742de..b3ee24c 100644
--- a/src/casetab.c
+++ b/src/casetab.c
@@ -1,5 +1,5 @@
 /* GNU Emacs routines to deal with case tables.
-   Copyright (C) 1993-1994, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1993-1994, 2001-2019 Free Software Foundation, Inc.
 
 Author: Howard Gayle
 
diff --git a/src/category.c b/src/category.c
index c316e9a..132fae9 100644
--- a/src/category.c
+++ b/src/category.c
@@ -1,6 +1,6 @@
 /* GNU Emacs routines to deal with category tables.
 
-Copyright (C) 1998, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1998, 2001-2019 Free Software Foundation, Inc.
 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
   2005, 2006, 2007, 2008, 2009, 2010, 2011
   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -42,15 +42,6 @@ bset_category_table (struct buffer *b, Lisp_Object val)
   b->category_table_ = val;
 }
 
-/* The version number of the latest category table.  Each category
-   table has a unique version number.  It is assigned a new number
-   also when it is modified.  When a regular expression is compiled
-   into the struct re_pattern_buffer, the version number of the
-   category table (of the current buffer) at that moment is also
-   embedded in the structure.
-
-   For the moment, we are not using this feature.  */
-static int category_table_version;
 
 /* Category set staff.  */
 
@@ -512,6 +503,4 @@ See the documentation of the variable 
`word-combining-categories'.  */);
   defsubr (&Schar_category_set);
   defsubr (&Scategory_set_mnemonics);
   defsubr (&Smodify_category_entry);
-
-  category_table_version = 0;
 }
diff --git a/src/ccl.c b/src/ccl.c
index 64e7045..ec108e3 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -1,5 +1,5 @@
 /* CCL (Code Conversion Language) interpreter.
-   Copyright (C) 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 2001-2019 Free Software Foundation, Inc.
    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
      2005, 2006, 2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/src/character.c b/src/character.c
index 63cb1fc..d14d0df 100644
--- a/src/character.c
+++ b/src/character.c
@@ -1,6 +1,6 @@
 /* Basic character support.
 
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 Copyright (C) 1995, 1997, 1998, 2001 Electrotechnical Laboratory, JAPAN.
   Licensed to the Free Software Foundation.
 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
diff --git a/src/charset.c b/src/charset.c
index 83f4de7..c0700f9 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1,6 +1,6 @@
 /* Basic character set support.
 
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
   2005, 2006, 2007, 2008, 2009, 2010, 2011
@@ -39,6 +39,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "coding.h"
 #include "buffer.h"
 #include "sysstdio.h"
+#include "pdumper.h"
 
 /*** GENERAL NOTES on CODED CHARACTER SETS (CHARSETS) ***
 
@@ -61,8 +62,7 @@ Lisp_Object Vcharset_hash_table;
 
 /* Table of struct charset.  */
 struct charset *charset_table;
-
-static ptrdiff_t charset_table_size;
+int charset_table_size;
 static int charset_table_used;
 
 /* Special charsets corresponding to symbols.  */
@@ -851,6 +851,8 @@ usage: (define-charset-internal ...)  */)
   bool new_definition_p;
   int nchars;
 
+  memset (&charset, 0, sizeof (charset));
+
   if (nargs != charset_arg_max)
     Fsignal (Qwrong_number_of_arguments,
             Fcons (intern ("define-charset-internal"),
@@ -1142,9 +1144,9 @@ usage: (define-charset-internal ...)  */)
          struct charset *new_table =
            xpalloc (0, &new_size, 1,
                     min (INT_MAX, MOST_POSITIVE_FIXNUM),
-                    sizeof *charset_table);
-         memcpy (new_table, charset_table, old_size * sizeof *new_table);
-         charset_table = new_table;
+                     sizeof *charset_table);
+          memcpy (new_table, charset_table, old_size * sizeof *new_table);
+          charset_table = new_table;
          charset_table_size = new_size;
          /* FIXME: This leaks memory, as the old charset_table becomes
             unreachable.  If the old charset table is charset_table_init
@@ -1173,8 +1175,7 @@ usage: (define-charset-internal ...)  */)
       ISO_CHARSET_TABLE (charset.dimension, charset.iso_chars_96,
                         charset.iso_final) = id;
       if (new_definition_p)
-       Viso_2022_charset_list = nconc2 (Viso_2022_charset_list,
-                                        list1 (make_fixnum (id)));
+       Viso_2022_charset_list = nconc2 (Viso_2022_charset_list, list1i (id));
       if (ISO_CHARSET_TABLE (1, 0, 'J') == id)
        charset_jisx0201_roman = id;
       else if (ISO_CHARSET_TABLE (2, 0, '@') == id)
@@ -1194,15 +1195,14 @@ usage: (define-charset-internal ...)  */)
        emacs_mule_bytes[charset.emacs_mule_id] = charset.dimension + 2;
       if (new_definition_p)
        Vemacs_mule_charset_list = nconc2 (Vemacs_mule_charset_list,
-                                          list1 (make_fixnum (id)));
+                                          list1i (id));
     }
 
   if (new_definition_p)
     {
       Vcharset_list = Fcons (args[charset_arg_name], Vcharset_list);
       if (charset.supplementary_p)
-       Vcharset_ordered_list = nconc2 (Vcharset_ordered_list,
-                                       list1 (make_fixnum (id)));
+       Vcharset_ordered_list = nconc2 (Vcharset_ordered_list, list1i (id));
       else
        {
          Lisp_Object tail;
@@ -1219,7 +1219,7 @@ usage: (define-charset-internal ...)  */)
                                           Vcharset_ordered_list);
          else if (NILP (tail))
            Vcharset_ordered_list = nconc2 (Vcharset_ordered_list,
-                                           list1 (make_fixnum (id)));
+                                           list1i (id));
          else
            {
              val = Fcons (XCAR (tail), XCDR (tail));
@@ -1276,8 +1276,7 @@ define_charset_internal (Lisp_Object name,
   args[charset_arg_unify_map] = Qnil;
 
   args[charset_arg_plist] =
-    listn (CONSTYPE_HEAP, 14,
-          QCname,
+     list (QCname,
           args[charset_arg_name],
           intern_c_string (":dimension"),
           args[charset_arg_dimension],
@@ -2178,7 +2177,7 @@ usage: (set-charset-priority &rest charsets)  */)
        }
     }
   Vcharset_non_preferred_head = old_list;
-  Vcharset_ordered_list = CALLN (Fnconc, Fnreverse (new_head), old_list);
+  Vcharset_ordered_list = nconc2 (Fnreverse (new_head), old_list);
 
   charset_ordered_list_tick++;
 
@@ -2242,8 +2241,7 @@ Return the sorted list.  CHARSETS is modified by side 
effects.
 See also `charset-priority-list' and `set-charset-priority'.  */)
      (Lisp_Object charsets)
 {
-  Lisp_Object len = Flength (charsets);
-  ptrdiff_t n = XFIXNAT (len), i, j;
+  ptrdiff_t n = list_length (charsets), i, j;
   int done;
   Lisp_Object tail, elt, attrs;
   struct charset_sort_data *sort_data;
@@ -2317,19 +2315,28 @@ init_charset_once (void)
   for (i = 0; i < ISO_MAX_DIMENSION; i++)
     for (j = 0; j < ISO_MAX_CHARS; j++)
       for (k = 0; k < ISO_MAX_FINAL; k++)
-       iso_charset_table[i][j][k] = -1;
+        iso_charset_table[i][j][k] = -1;
+
+  PDUMPER_REMEMBER_SCALAR (iso_charset_table);
 
   for (i = 0; i < 256; i++)
     emacs_mule_charset[i] = -1;
 
+  PDUMPER_REMEMBER_SCALAR (emacs_mule_charset);
+
   charset_jisx0201_roman = -1;
+  PDUMPER_REMEMBER_SCALAR (charset_jisx0201_roman);
+
   charset_jisx0208_1978 = -1;
+  PDUMPER_REMEMBER_SCALAR (charset_jisx0208_1978);
+
   charset_jisx0208 = -1;
+  PDUMPER_REMEMBER_SCALAR (charset_jisx0208);
+
   charset_ksc5601 = -1;
+  PDUMPER_REMEMBER_SCALAR (charset_ksc5601);
 }
 
-#ifdef emacs
-
 /* Allocate an initial charset table that is large enough to handle
    Emacs while it is bootstrapping.  As of September 2011, the size
    needs to be at least 166; make it a bit bigger to allow for future
@@ -2368,7 +2375,9 @@ syms_of_charset (void)
 
   charset_table = charset_table_init;
   charset_table_size = ARRAYELTS (charset_table_init);
+  PDUMPER_REMEMBER_SCALAR (charset_table_size);
   charset_table_used = 0;
+  PDUMPER_REMEMBER_SCALAR (charset_table_used);
 
   defsubr (&Scharsetp);
   defsubr (&Smap_charset_chars);
@@ -2414,21 +2423,30 @@ the value may be a list of mnemonics.  */);
 
   charset_ascii
     = define_charset_internal (Qascii, 1, "\x00\x7F\0\0\0\0\0",
-                              0, 127, 'B', -1, 0, 1, 0, 0);
+                               0, 127, 'B', -1, 0, 1, 0, 0);
+  PDUMPER_REMEMBER_SCALAR (charset_ascii);
+
   charset_iso_8859_1
     = define_charset_internal (Qiso_8859_1, 1, "\x00\xFF\0\0\0\0\0",
-                              0, 255, -1, -1, -1, 1, 0, 0);
+                               0, 255, -1, -1, -1, 1, 0, 0);
+  PDUMPER_REMEMBER_SCALAR (charset_iso_8859_1);
+
   charset_unicode
     = define_charset_internal (Qunicode, 3, "\x00\xFF\x00\xFF\x00\x10\0",
-                              0, MAX_UNICODE_CHAR, -1, 0, -1, 1, 0, 0);
+                               0, MAX_UNICODE_CHAR, -1, 0, -1, 1, 0, 0);
+  PDUMPER_REMEMBER_SCALAR (charset_unicode);
+
   charset_emacs
     = define_charset_internal (Qemacs, 3, "\x00\xFF\x00\xFF\x00\x3F\0",
-                              0, MAX_5_BYTE_CHAR, -1, 0, -1, 1, 1, 0);
+                               0, MAX_5_BYTE_CHAR, -1, 0, -1, 1, 1, 0);
+  PDUMPER_REMEMBER_SCALAR (charset_emacs);
+
   charset_eight_bit
     = define_charset_internal (Qeight_bit, 1, "\x80\xFF\0\0\0\0\0",
                               128, 255, -1, 0, -1, 0, 1,
-                              MAX_5_BYTE_CHAR + 1);
+                               MAX_5_BYTE_CHAR + 1);
+  PDUMPER_REMEMBER_SCALAR (charset_eight_bit);
+
   charset_unibyte = charset_iso_8859_1;
+  PDUMPER_REMEMBER_SCALAR (charset_unibyte);
 }
-
-#endif /* emacs */
diff --git a/src/charset.h b/src/charset.h
index 7b85a1a..7042a71 100644
--- a/src/charset.h
+++ b/src/charset.h
@@ -1,5 +1,5 @@
 /* Header for charset handler.
-   Copyright (C) 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 2001-2019 Free Software Foundation, Inc.
    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
      2005, 2006, 2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
@@ -248,6 +248,7 @@ extern Lisp_Object Vcharset_hash_table;
 
 /* Table of struct charset.  */
 extern struct charset *charset_table;
+extern int charset_table_size;
 
 #define CHARSET_FROM_ID(id) (charset_table + (id))
 
diff --git a/src/cm.c b/src/cm.c
index e936c9f..71cc947 100644
--- a/src/cm.c
+++ b/src/cm.c
@@ -1,5 +1,5 @@
 /* Cursor motion subroutines for GNU Emacs.
-   Copyright (C) 1985, 1995, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1995, 2001-2019 Free Software Foundation, Inc.
     based primarily on public domain code written by Chris Torek
 
 This file is part of GNU Emacs.
diff --git a/src/cm.h b/src/cm.h
index 67515c3..2f6e6ad 100644
--- a/src/cm.h
+++ b/src/cm.h
@@ -1,5 +1,5 @@
 /* Cursor motion calculation definitions for GNU Emacs
-   Copyright (C) 1985, 1989, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1989, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/cmds.c b/src/cmds.c
index f6803f4..9f3c861 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -1,6 +1,6 @@
 /* Simple built-in editing commands.
 
-Copyright (C) 1985, 1993-1998, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1985, 1993-1998, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -121,28 +121,36 @@ it as a line moved across, even though there is no next 
line to
 go to its beginning.  */)
   (Lisp_Object n)
 {
-  ptrdiff_t opoint = PT, pos, pos_byte, shortage, count;
+  ptrdiff_t opoint = PT, pos, pos_byte, count;
+  bool excessive = false;
 
   if (NILP (n))
     count = 1;
   else
     {
-      CHECK_FIXNUM (n);
-      count = XFIXNUM (n);
+      CHECK_INTEGER (n);
+      if (FIXNUMP (n)
+         && -BUF_BYTES_MAX <= XFIXNUM (n) && XFIXNUM (n) <= BUF_BYTES_MAX)
+       count = XFIXNUM (n);
+      else
+       {
+         count = !NILP (Fnatnump (n)) ? BUF_BYTES_MAX : -BUF_BYTES_MAX;
+         excessive = true;
+       }
     }
 
-  shortage = scan_newline_from_point (count, &pos, &pos_byte);
+  ptrdiff_t counted = scan_newline_from_point (count, &pos, &pos_byte);
 
   SET_PT_BOTH (pos, pos_byte);
 
-  if (shortage > 0
-      && (count <= 0
-         || (ZV > BEGV
-             && PT != opoint
-             && (FETCH_BYTE (PT_BYTE - 1) != '\n'))))
-    shortage--;
-
-  return make_fixnum (count <= 0 ? - shortage : shortage);
+  ptrdiff_t shortage = count - (count <= 0) - counted;
+  if (shortage != 0)
+    shortage -= (count <= 0 ? -1
+                 : (BEGV < ZV && PT != opoint
+                    && FETCH_BYTE (PT_BYTE - 1) != '\n'));
+  return (excessive
+         ? CALLN (Fplus, make_fixnum (shortage - count), n)
+         : make_fixnum (shortage));
 }
 
 DEFUN ("beginning-of-line", Fbeginning_of_line, Sbeginning_of_line, 0, 1, "^p",
@@ -415,7 +423,7 @@ internal_self_insert (int c, EMACS_INT n)
                  : UNIBYTE_TO_CHAR (XFIXNAT (Fprevious_char ())))
          == Sword))
     {
-      EMACS_INT modiff = MODIFF;
+      modiff_count modiff = MODIFF;
       Lisp_Object sym;
 
       sym = call0 (Qexpand_abbrev);
diff --git a/src/coding.c b/src/coding.c
index 398691f..2c6b2c4 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -1,5 +1,5 @@
 /* Coding system handler (conversion, detection, etc).
-   Copyright (C) 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 2001-2019 Free Software Foundation, Inc.
    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
      2005, 2006, 2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
@@ -298,25 +298,16 @@ encode_coding_XXX (struct coding_system *coding)
 #include "composite.h"
 #include "coding.h"
 #include "termhooks.h"
+#include "pdumper.h"
 
 Lisp_Object Vcoding_system_hash_table;
 
-/* Format of end-of-line decided by system.  This is Qunix on
-   Unix and Mac, Qdos on DOS/Windows.
-   This has an effect only for external encoding (i.e. for output to
-   file and process), not for in-buffer or Lisp string encoding.  */
-static Lisp_Object system_eol_type;
-
-#ifdef emacs
-
 /* Coding-systems are handed between Emacs Lisp programs and C internal
    routines by the following three variables.  */
 /* Coding system to be used to encode text for terminal display when
    terminal coding system is nil.  */
 struct coding_system safe_terminal_coding;
 
-#endif /* emacs */
-
 /* Two special coding systems.  */
 static Lisp_Object Vsjis_coding_system;
 static Lisp_Object Vbig5_coding_system;
@@ -617,23 +608,7 @@ inhibit_flag (int encoded_flag, bool var)
   do {                                                 \
     (attrs) = CODING_ID_ATTRS ((coding)->id);          \
     (charset_list) = CODING_ATTR_CHARSET_LIST (attrs); \
-  } while (0)
-
-static void
-CHECK_FIXNAT_CAR (Lisp_Object x)
-{
-  Lisp_Object tmp = XCAR (x);
-  CHECK_FIXNAT (tmp);
-  XSETCAR (x, tmp);
-}
-
-static void
-CHECK_FIXNAT_CDR (Lisp_Object x)
-{
-  Lisp_Object tmp = XCDR (x);
-  CHECK_FIXNAT (tmp);
-  XSETCDR (x, tmp);
-}
+  } while (false)
 
 /* True if CODING's destination can be grown.  */
 
@@ -4611,8 +4586,7 @@ detect_coding_sjis (struct coding_system *coding,
   int max_first_byte_of_2_byte_code;
 
   CODING_GET_INFO (coding, attrs, charset_list);
-  max_first_byte_of_2_byte_code
-    = (XFIXNUM (Flength (charset_list)) > 3 ? 0xFC : 0xEF);
+  max_first_byte_of_2_byte_code = list_length (charset_list) <= 3 ? 0xEF : 
0xFC;
 
   detect_info->checked |= CATEGORY_MASK_SJIS;
   /* A coding system of this category is always ASCII compatible.  */
@@ -5739,7 +5713,7 @@ setup_coding_system (Lisp_Object coding_system, struct 
coding_system *coding)
       coding->common_flags |= CODING_REQUIRE_DETECTION_MASK;
       coding->spec.undecided.inhibit_nbd
        = (encode_inhibit_flag
-          (AREF (attrs, coding_attr_undecided_inhibit_null_byte_detection)));
+          (AREF (attrs, coding_attr_undecided_inhibit_nul_byte_detection)));
       coding->spec.undecided.inhibit_ied
        = (encode_inhibit_flag
           (AREF (attrs, coding_attr_undecided_inhibit_iso_escape_detection)));
@@ -5992,8 +5966,7 @@ raw_text_coding_system_p (struct coding_system *coding)
 
 /* If CODING_SYSTEM doesn't specify end-of-line format, return one of
    the subsidiary that has the same eol-spec as PARENT (if it is not
-   nil and specifies end-of-line format) or the system's setting
-   (system_eol_type).  */
+   nil and specifies end-of-line format) or the system's setting.  */
 
 Lisp_Object
 coding_inherit_eol_type (Lisp_Object coding_system, Lisp_Object parent)
@@ -6008,20 +5981,24 @@ coding_inherit_eol_type (Lisp_Object coding_system, 
Lisp_Object parent)
   eol_type = AREF (spec, 2);
   if (VECTORP (eol_type))
     {
-      Lisp_Object parent_eol_type;
+      /* Format of end-of-line decided by system.
+        This is Qunix on Unix and Mac, Qdos on DOS/Windows.
+        This has an effect only for external encoding (i.e., for output to
+        file and process), not for in-buffer or Lisp string encoding.  */
+      Lisp_Object system_eol_type = Qunix;
+      #ifdef DOS_NT
+       system_eol_type = Qdos;
+      #endif
 
+      Lisp_Object parent_eol_type = system_eol_type;
       if (! NILP (parent))
        {
-         Lisp_Object parent_spec;
-
          CHECK_CODING_SYSTEM (parent);
-         parent_spec = CODING_SYSTEM_SPEC (parent);
-         parent_eol_type = AREF (parent_spec, 2);
-         if (VECTORP (parent_eol_type))
-           parent_eol_type = system_eol_type;
+         Lisp_Object parent_spec = CODING_SYSTEM_SPEC (parent);
+         Lisp_Object pspec_type = AREF (parent_spec, 2);
+         if (!VECTORP (pspec_type))
+           parent_eol_type = pspec_type;
        }
-      else
-       parent_eol_type = system_eol_type;
       if (EQ (parent_eol_type, Qunix))
        coding_system = AREF (eol_type, 0);
       else if (EQ (parent_eol_type, Qdos))
@@ -6534,9 +6511,9 @@ detect_coding (struct coding_system *coding)
     {
       int c, i;
       struct coding_detection_info detect_info;
-      bool null_byte_found = 0, eight_bit_found = 0;
+      bool nul_byte_found = 0, eight_bit_found = 0;
       bool inhibit_nbd = inhibit_flag (coding->spec.undecided.inhibit_nbd,
-                                      inhibit_null_byte_detection);
+                                      inhibit_nul_byte_detection);
       bool inhibit_ied = inhibit_flag (coding->spec.undecided.inhibit_ied,
                                       inhibit_iso_escape_detection);
       bool prefer_utf_8 = coding->spec.undecided.prefer_utf_8;
@@ -6549,7 +6526,7 @@ detect_coding (struct coding_system *coding)
          if (c & 0x80)
            {
              eight_bit_found = 1;
-             if (null_byte_found)
+             if (nul_byte_found)
                break;
            }
          else if (c < 0x20)
@@ -6564,7 +6541,7 @@ detect_coding (struct coding_system *coding)
                      if (! (detect_info.rejected & CATEGORY_MASK_ISO_7_ELSE))
                        {
                          /* We didn't find an 8-bit code.  We may
-                            have found a null-byte, but it's very
+                            have found a NUL-byte, but it's very
                             rare that a binary file conforms to
                             ISO-2022.  */
                          src = src_end;
@@ -6576,7 +6553,7 @@ detect_coding (struct coding_system *coding)
                }
              else if (! c && !inhibit_nbd)
                {
-                 null_byte_found = 1;
+                 nul_byte_found = 1;
                  if (eight_bit_found)
                    break;
                }
@@ -6608,7 +6585,7 @@ detect_coding (struct coding_system *coding)
            coding->head_ascii++;
        }
 
-      if (null_byte_found || eight_bit_found
+      if (nul_byte_found || eight_bit_found
          || coding->head_ascii < coding->src_bytes
          || detect_info.found)
        {
@@ -6626,7 +6603,7 @@ detect_coding (struct coding_system *coding)
              }
          else
            {
-             if (null_byte_found)
+             if (nul_byte_found)
                {
                  detect_info.checked |= ~CATEGORY_MASK_UTF_16;
                  detect_info.rejected |= ~CATEGORY_MASK_UTF_16;
@@ -6699,7 +6676,7 @@ detect_coding (struct coding_system *coding)
              else
                found = CODING_ID_NAME (this->id);
            }
-         else if (null_byte_found)
+         else if (nul_byte_found)
            found = Qno_conversion;
          else if ((detect_info.rejected & CATEGORY_MASK_ANY)
                   == CATEGORY_MASK_ANY)
@@ -7805,7 +7782,7 @@ encode_coding (struct coding_system *coding)
 
 
 /* Name (or base name) of work buffer for code conversion.  */
-static Lisp_Object Vcode_conversion_workbuf_name;
+Lisp_Object Vcode_conversion_workbuf_name;
 
 /* A working buffer used by the top level conversion.  Once it is
    created, it is never destroyed.  It has the name
@@ -7817,43 +7794,6 @@ static Lisp_Object Vcode_conversion_reused_workbuf;
 /* True iff Vcode_conversion_reused_workbuf is already in use.  */
 static bool reused_workbuf_in_use;
 
-
-/* Return a working buffer of code conversion.  MULTIBYTE specifies the
-   multibyteness of returning buffer.  */
-
-static Lisp_Object
-make_conversion_work_buffer (bool multibyte)
-{
-  Lisp_Object name, workbuf;
-  struct buffer *current;
-
-  if (reused_workbuf_in_use)
-    {
-      name = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil);
-      workbuf = Fget_buffer_create (name);
-    }
-  else
-    {
-      reused_workbuf_in_use = 1;
-      if (NILP (Fbuffer_live_p (Vcode_conversion_reused_workbuf)))
-       Vcode_conversion_reused_workbuf
-         = Fget_buffer_create (Vcode_conversion_workbuf_name);
-      workbuf = Vcode_conversion_reused_workbuf;
-    }
-  current = current_buffer;
-  set_buffer_internal (XBUFFER (workbuf));
-  /* We can't allow modification hooks to run in the work buffer.  For
-     instance, directory_files_internal assumes that file decoding
-     doesn't compile new regexps.  */
-  Fset (Fmake_local_variable (Qinhibit_modification_hooks), Qt);
-  Ferase_buffer ();
-  bset_undo_list (current_buffer, Qt);
-  bset_enable_multibyte_characters (current_buffer, multibyte ? Qt : Qnil);
-  set_buffer_internal (current);
-  return workbuf;
-}
-
-
 static void
 code_conversion_restore (Lisp_Object arg)
 {
@@ -7877,9 +7817,39 @@ code_conversion_save (bool with_work_buf, bool multibyte)
   Lisp_Object workbuf = Qnil;
 
   if (with_work_buf)
-    workbuf = make_conversion_work_buffer (multibyte);
+    {
+      if (reused_workbuf_in_use)
+       {
+         Lisp_Object name
+           = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil);
+         workbuf = Fget_buffer_create (name);
+       }
+      else
+       {
+         if (NILP (Fbuffer_live_p (Vcode_conversion_reused_workbuf)))
+           Vcode_conversion_reused_workbuf
+             = Fget_buffer_create (Vcode_conversion_workbuf_name);
+         workbuf = Vcode_conversion_reused_workbuf;
+       }
+    }
   record_unwind_protect (code_conversion_restore,
                         Fcons (Fcurrent_buffer (), workbuf));
+  if (!NILP (workbuf))
+    {
+      struct buffer *current = current_buffer;
+      set_buffer_internal (XBUFFER (workbuf));
+      /* We can't allow modification hooks to run in the work buffer.  For
+        instance, directory_files_internal assumes that file decoding
+        doesn't compile new regexps.  */
+      Fset (Fmake_local_variable (Qinhibit_modification_hooks), Qt);
+      Ferase_buffer ();
+      bset_undo_list (current_buffer, Qt);
+      bset_enable_multibyte_characters (current_buffer, multibyte ? Qt : Qnil);
+      if (EQ (workbuf, Vcode_conversion_reused_workbuf))
+       reused_workbuf_in_use = 1;
+      set_buffer_internal (current);
+    }
+
   return workbuf;
 }
 
@@ -8468,7 +8438,7 @@ from_unicode (Lisp_Object str)
 Lisp_Object
 from_unicode_buffer (const wchar_t *wstr)
 {
-  /* We get one of the two final null bytes for free.  */
+  /* We get one of the two final NUL bytes for free.  */
   ptrdiff_t len = 1 + sizeof (wchar_t) * wcslen (wstr);
   AUTO_STRING_WITH_LEN (str, (char *) wstr, len);
   return from_unicode (str);
@@ -8481,7 +8451,7 @@ to_unicode (Lisp_Object str, Lisp_Object *buf)
   /* We need to make another copy (in addition to the one made by
      code_convert_string_norecord) to ensure that the final string is
      _doubly_ zero terminated --- that is, that the string is
-     terminated by two zero bytes and one utf-16le null character.
+     terminated by two zero bytes and one utf-16le NUL character.
      Because strings are already terminated with a single zero byte,
      we just add one additional zero. */
   str = make_uninit_string (SBYTES (*buf) + 1);
@@ -8494,7 +8464,6 @@ to_unicode (Lisp_Object str, Lisp_Object *buf)
 #endif /* WINDOWSNT || CYGWIN */
 
 
-#ifdef emacs
 /*** 8. Emacs Lisp library functions ***/
 
 DEFUN ("coding-system-p", Fcoding_system_p, Scoding_system_p, 1, 1, 0,
@@ -8598,7 +8567,7 @@ detect_coding_system (const unsigned char *src,
   ptrdiff_t id;
   struct coding_detection_info detect_info;
   enum coding_category base_category;
-  bool null_byte_found = 0, eight_bit_found = 0;
+  bool nul_byte_found = 0, eight_bit_found = 0;
 
   if (NILP (coding_system))
     coding_system = Qundecided;
@@ -8625,7 +8594,7 @@ detect_coding_system (const unsigned char *src,
       struct coding_system *this UNINIT;
       int c, i;
       bool inhibit_nbd = inhibit_flag (coding.spec.undecided.inhibit_nbd,
-                                      inhibit_null_byte_detection);
+                                      inhibit_nul_byte_detection);
       bool inhibit_ied = inhibit_flag (coding.spec.undecided.inhibit_ied,
                                       inhibit_iso_escape_detection);
       bool prefer_utf_8 = coding.spec.undecided.prefer_utf_8;
@@ -8637,7 +8606,7 @@ detect_coding_system (const unsigned char *src,
          if (c & 0x80)
            {
              eight_bit_found = 1;
-             if (null_byte_found)
+             if (nul_byte_found)
                break;
            }
          else if (c < 0x20)
@@ -8652,7 +8621,7 @@ detect_coding_system (const unsigned char *src,
                      if (! (detect_info.rejected & CATEGORY_MASK_ISO_7_ELSE))
                        {
                          /* We didn't find an 8-bit code.  We may
-                            have found a null-byte, but it's very
+                            have found a NUL-byte, but it's very
                             rare that a binary file confirm to
                             ISO-2022.  */
                          src = src_end;
@@ -8664,7 +8633,7 @@ detect_coding_system (const unsigned char *src,
                }
              else if (! c && !inhibit_nbd)
                {
-                 null_byte_found = 1;
+                 nul_byte_found = 1;
                  if (eight_bit_found)
                    break;
                }
@@ -8675,7 +8644,7 @@ detect_coding_system (const unsigned char *src,
            coding.head_ascii++;
        }
 
-      if (null_byte_found || eight_bit_found
+      if (nul_byte_found || eight_bit_found
          || coding.head_ascii < coding.src_bytes
          || detect_info.found)
        {
@@ -8690,7 +8659,7 @@ detect_coding_system (const unsigned char *src,
              }
          else
            {
-             if (null_byte_found)
+             if (nul_byte_found)
                {
                  detect_info.checked |= ~CATEGORY_MASK_UTF_16;
                  detect_info.rejected |= ~CATEGORY_MASK_UTF_16;
@@ -8737,24 +8706,24 @@ detect_coding_system (const unsigned char *src,
        }
 
       if ((detect_info.rejected & CATEGORY_MASK_ANY) == CATEGORY_MASK_ANY
-         || null_byte_found)
+         || nul_byte_found)
        {
          detect_info.found = CATEGORY_MASK_RAW_TEXT;
          id = CODING_SYSTEM_ID (Qno_conversion);
-         val = list1 (make_fixnum (id));
+         val = list1i (id);
        }
       else if (! detect_info.rejected && ! detect_info.found)
        {
          detect_info.found = CATEGORY_MASK_ANY;
          id = coding_categories[coding_category_undecided].id;
-         val = list1 (make_fixnum (id));
+         val = list1i (id);
        }
       else if (highest)
        {
          if (detect_info.found)
            {
              detect_info.found = 1 << category;
-             val = list1 (make_fixnum (this->id));
+             val = list1i (this->id);
            }
          else
            for (i = 0; i < coding_category_raw_text; i++)
@@ -8762,7 +8731,7 @@ detect_coding_system (const unsigned char *src,
                {
                  detect_info.found = 1 << coding_priorities[i];
                  id = coding_categories[coding_priorities[i]].id;
-                 val = list1 (make_fixnum (id));
+                 val = list1i (id);
                  break;
                }
        }
@@ -8779,7 +8748,7 @@ detect_coding_system (const unsigned char *src,
                  found |= 1 << category;
                  id = coding_categories[category].id;
                  if (id >= 0)
-                   val = list1 (make_fixnum (id));
+                   val = list1i (id);
                }
            }
          for (i = coding_category_raw_text - 1; i >= 0; i--)
@@ -8804,7 +8773,7 @@ detect_coding_system (const unsigned char *src,
            this = coding_categories + coding_category_utf_8_sig;
          else
            this = coding_categories + coding_category_utf_8_nosig;
-         val = list1 (make_fixnum (this->id));
+         val = list1i (this->id);
        }
     }
   else if (base_category == coding_category_utf_16_auto)
@@ -8821,13 +8790,13 @@ detect_coding_system (const unsigned char *src,
            this = coding_categories + coding_category_utf_16_be_nosig;
          else
            this = coding_categories + coding_category_utf_16_le_nosig;
-         val = list1 (make_fixnum (this->id));
+         val = list1i (this->id);
        }
     }
   else
     {
       detect_info.found = 1 << XFIXNUM (CODING_ATTR_CATEGORY (attrs));
-      val = list1 (make_fixnum (coding.id));
+      val = list1i (coding.id);
     }
 
   /* Then, detect eol-format if necessary.  */
@@ -8839,7 +8808,7 @@ detect_coding_system (const unsigned char *src,
       {
        if (detect_info.found & ~CATEGORY_MASK_UTF_16)
          {
-           if (null_byte_found)
+           if (nul_byte_found)
              normal_eol = EOL_SEEN_LF;
            else
              normal_eol = detect_eol (coding.source, src_bytes,
@@ -9770,7 +9739,7 @@ DEFUN ("set-terminal-coding-system-internal", 
Fset_terminal_coding_system_intern
   tset_charset_list
     (term, (terminal_coding->common_flags & CODING_REQUIRE_ENCODING_MASK
            ? coding_charset_list (terminal_coding)
-           : list1 (make_fixnum (charset_ascii))));
+           : list1i (charset_ascii)));
   return Qnil;
 }
 
@@ -10271,15 +10240,9 @@ usage: (define-coding-system-internal ...)  */)
          else
            {
              CHECK_CONS (val);
-             CHECK_FIXNAT_CAR (val);
-             CHECK_FIXNUM_CDR (val);
-             if (XFIXNUM (XCAR (val)) > 255)
-               args_out_of_range_3 (XCAR (val),
-                                    make_fixnum (0), make_fixnum (255));
+             CHECK_RANGED_INTEGER (XCAR (val), 0, 255);
              from = XFIXNUM (XCAR (val));
-             if (! (from <= XFIXNUM (XCDR (val)) && XFIXNUM (XCDR (val)) <= 
255))
-               args_out_of_range_3 (XCDR (val),
-                                    XCAR (val), make_fixnum (255));
+             CHECK_RANGED_INTEGER (XCDR (val), from, 255);
              to = XFIXNUM (XCDR (val));
            }
          for (int i = from; i <= to; i++)
@@ -10354,23 +10317,18 @@ usage: (define-coding-system-internal ...)  */)
 
       reg_usage = args[coding_arg_iso2022_reg_usage];
       CHECK_CONS (reg_usage);
-      CHECK_FIXNUM_CAR (reg_usage);
-      CHECK_FIXNUM_CDR (reg_usage);
+      CHECK_FIXNUM (XCAR (reg_usage));
+      CHECK_FIXNUM (XCDR (reg_usage));
 
       request = Fcopy_sequence (args[coding_arg_iso2022_request]);
       for (Lisp_Object tail = request; CONSP (tail); tail = XCDR (tail))
        {
          int id;
-         Lisp_Object tmp1;
 
          val = XCAR (tail);
          CHECK_CONS (val);
-         tmp1 = XCAR (val);
-         CHECK_CHARSET_GET_ID (tmp1, id);
-         CHECK_FIXNAT_CDR (val);
-         if (XFIXNUM (XCDR (val)) >= 4)
-           error ("Invalid graphic register number: %"pI"d",
-                  XFIXNUM (XCDR (val)));
+         CHECK_CHARSET_GET_ID (XCAR (val), id);
+         CHECK_RANGED_INTEGER (XCDR (val), 0, 3);
          XSETCAR (val, make_fixnum (id));
        }
 
@@ -10419,14 +10377,11 @@ usage: (define-coding-system-internal ...)  */)
     }
   else if (EQ (coding_type, Qshift_jis))
     {
-
-      struct charset *charset;
-
-      if (XFIXNUM (Flength (charset_list)) != 3
-         && XFIXNUM (Flength (charset_list)) != 4)
+      ptrdiff_t charset_list_len = list_length (charset_list);
+      if (charset_list_len != 3 && charset_list_len != 4)
        error ("There should be three or four charsets");
 
-      charset = CHARSET_FROM_ID (XFIXNUM (XCAR (charset_list)));
+      struct charset *charset = CHARSET_FROM_ID (XFIXNUM (XCAR 
(charset_list)));
       if (CHARSET_DIMENSION (charset) != 1)
        error ("Dimension of charset %s is not one",
               SDATA (SYMBOL_NAME (CHARSET_NAME (charset))));
@@ -10461,7 +10416,7 @@ usage: (define-coding-system-internal ...)  */)
     {
       struct charset *charset;
 
-      if (XFIXNUM (Flength (charset_list)) != 2)
+      if (list_length (charset_list) != 2)
        error ("There should be just two charsets");
 
       charset = CHARSET_FROM_ID (XFIXNUM (XCAR (charset_list)));
@@ -10513,8 +10468,8 @@ usage: (define-coding-system-internal ...)  */)
     {
       if (nargs < coding_arg_undecided_max)
        goto short_args;
-      ASET (attrs, coding_attr_undecided_inhibit_null_byte_detection,
-           args[coding_arg_undecided_inhibit_null_byte_detection]);
+      ASET (attrs, coding_attr_undecided_inhibit_nul_byte_detection,
+           args[coding_arg_undecided_inhibit_nul_byte_detection]);
       ASET (attrs, coding_attr_undecided_inhibit_iso_escape_detection,
            args[coding_arg_undecided_inhibit_iso_escape_detection]);
       ASET (attrs, coding_attr_undecided_prefer_utf_8,
@@ -10759,8 +10714,6 @@ coding system whose eol-type is N.  */)
   return make_fixnum (n);
 }
 
-#endif /* emacs */
-
 
 /*** 9. Post-amble ***/
 
@@ -10775,6 +10728,9 @@ init_coding_once (void)
       coding_priorities[i] = i;
     }
 
+  PDUMPER_REMEMBER_SCALAR (coding_categories);
+  PDUMPER_REMEMBER_SCALAR (coding_priorities);
+
   /* ISO2022 specific initialize routine.  */
   for (i = 0; i < 0x20; i++)
     iso_code_class[i] = ISO_control_0;
@@ -10794,6 +10750,8 @@ init_coding_once (void)
   iso_code_class[ISO_CODE_SS3] = ISO_single_shift_3;
   iso_code_class[ISO_CODE_CSI] = ISO_control_sequence_introducer;
 
+  PDUMPER_REMEMBER_SCALAR (iso_code_class);
+
   for (i = 0; i < 256; i++)
     {
       emacs_mule_bytes[i] = 1;
@@ -10802,9 +10760,11 @@ init_coding_once (void)
   emacs_mule_bytes[EMACS_MULE_LEADING_CODE_PRIVATE_12] = 3;
   emacs_mule_bytes[EMACS_MULE_LEADING_CODE_PRIVATE_21] = 4;
   emacs_mule_bytes[EMACS_MULE_LEADING_CODE_PRIVATE_22] = 4;
+
+  PDUMPER_REMEMBER_SCALAR (emacs_mule_bytes);
 }
 
-#ifdef emacs
+static void reset_coding_after_pdumper_load (void);
 
 void
 syms_of_coding (void)
@@ -10825,6 +10785,7 @@ syms_of_coding (void)
   Vcode_conversion_workbuf_name = build_pure_c_string (" 
*code-conversion-work*");
 
   reused_workbuf_in_use = 0;
+  PDUMPER_REMEMBER_SCALAR (reused_workbuf_in_use);
 
   DEFSYM (Qcharset, "charset");
   DEFSYM (Qtarget_idx, "target-idx");
@@ -10860,6 +10821,7 @@ syms_of_coding (void)
   DEFSYM (Qundecided, "undecided");
   DEFSYM (Qno_conversion, "no-conversion");
   DEFSYM (Qraw_text, "raw-text");
+  DEFSYM (Qus_ascii, "us-ascii");
 
   DEFSYM (Qiso_2022, "iso-2022");
 
@@ -10884,7 +10846,7 @@ syms_of_coding (void)
   /* Error signaled when there's a problem with detecting a coding system.  */
   DEFSYM (Qcoding_system_error, "coding-system-error");
   Fput (Qcoding_system_error, Qerror_conditions,
-       listn (CONSTYPE_PURE, 2, Qcoding_system_error, Qerror));
+       pure_list (Qcoding_system_error, Qerror));
   Fput (Qcoding_system_error, Qerror_message,
        build_pure_c_string ("Invalid coding system"));
 
@@ -11262,18 +11224,18 @@ to explicitly specify some coding system that doesn't 
use ISO-2022
 escape sequence (e.g., `latin-1') on reading by 
\\[universal-coding-system-argument].  */);
   inhibit_iso_escape_detection = 0;
 
-  DEFVAR_BOOL ("inhibit-null-byte-detection",
-              inhibit_null_byte_detection,
-              doc: /* If non-nil, Emacs ignores null bytes on code detection.
+  DEFVAR_BOOL ("inhibit-nul-byte-detection",
+              inhibit_nul_byte_detection,
+              doc: /* If non-nil, Emacs ignores NUL bytes on code detection.
 By default, Emacs treats it as binary data, and does not attempt to
 decode it.  The effect is as if you specified `no-conversion' for
 reading that text.
 
-Set this to non-nil when a regular text happens to include null bytes.
-Examples are Index nodes of Info files and null-byte delimited output
-from GNU Find and GNU Grep.  Emacs will then ignore the null bytes and
+Set this to non-nil when a regular text happens to include NUL bytes.
+Examples are Index nodes of Info files and NUL-byte delimited output
+from GNU Find and GNU Grep.  Emacs will then ignore the NUL bytes and
 decode text as usual.  */);
-  inhibit_null_byte_detection = 0;
+  inhibit_nul_byte_detection = 0;
 
   DEFVAR_BOOL ("disable-ascii-optimization", disable_ascii_optimization,
               doc: /* If non-nil, Emacs does not optimize code decoder for 
ASCII files.
@@ -11326,13 +11288,13 @@ internal character representation.  */);
   /* This is already set.
      plist[7] = args[coding_arg_ascii_compatible_p] = Qt; */
   plist[8] = intern_c_string (":charset-list");
-  plist[9] = args[coding_arg_charset_list] = Fcons (Qascii, Qnil);
+  plist[9] = args[coding_arg_charset_list] = list1 (Qascii);
   plist[11] = args[coding_arg_for_unibyte] = Qnil;
   plist[13] = build_pure_c_string ("No conversion on encoding, "
                                   "automatic conversion on decoding.");
   plist[15] = args[coding_arg_eol_type] = Qnil;
   args[coding_arg_plist] = CALLMANY (Flist, plist);
-  args[coding_arg_undecided_inhibit_null_byte_detection] = make_fixnum (0);
+  args[coding_arg_undecided_inhibit_nul_byte_detection] = make_fixnum (0);
   args[coding_arg_undecided_inhibit_iso_escape_detection] = make_fixnum (0);
   Fdefine_coding_system_internal (coding_arg_undecided_max, args);
 
@@ -11341,11 +11303,31 @@ internal character representation.  */);
   for (int i = 0; i < coding_category_max; i++)
     Fset (AREF (Vcoding_category_table, i), Qno_conversion);
 
-#if defined (DOS_NT)
-  system_eol_type = Qdos;
-#else
-  system_eol_type = Qunix;
-#endif
-  staticpro (&system_eol_type);
+  pdumper_do_now_and_after_load (reset_coding_after_pdumper_load);
+}
+
+static void
+reset_coding_after_pdumper_load (void)
+{
+  if (!dumped_with_pdumper_p ())
+    return;
+  for (struct coding_system *this = &coding_categories[0];
+       this < &coding_categories[coding_category_max];
+       ++this)
+    {
+      int id = this->id;
+      if (id >= 0)
+        {
+          /* Need to rebuild the coding system object because we
+             persisted it as a scalar and it's full of gunk that's now
+             invalid.  */
+          memset (this, 0, sizeof (*this));
+          setup_coding_system (CODING_ID_NAME (id), this);
+        }
+    }
+  /* In temacs the below is done by mule-conf.el, because we need to
+     define us-ascii first.  But in dumped Emacs us-ascii is restored
+     by the above loop, and mule-conf.el will not be loaded, so we set
+     it up now; otherwise safe_terminal_coding will remain zeroed.  */
+  Fset_safe_terminal_coding_system_internal (Qus_ascii);
 }
-#endif /* emacs */
diff --git a/src/coding.h b/src/coding.h
index d2cf4d8..0c03d1a 100644
--- a/src/coding.h
+++ b/src/coding.h
@@ -1,5 +1,5 @@
 /* Header for coding system handler.
-   Copyright (C) 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 2001-2019 Free Software Foundation, Inc.
    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
      2005, 2006, 2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
@@ -82,7 +82,7 @@ enum define_coding_ccl_arg_index
 
 enum define_coding_undecided_arg_index
   {
-    coding_arg_undecided_inhibit_null_byte_detection = coding_arg_max,
+    coding_arg_undecided_inhibit_nul_byte_detection = coding_arg_max,
     coding_arg_undecided_inhibit_iso_escape_detection,
     coding_arg_undecided_prefer_utf_8,
     coding_arg_undecided_max
@@ -97,6 +97,8 @@ enum define_coding_undecided_arg_index
 
 extern Lisp_Object Vcoding_system_hash_table;
 
+/* Name (or base name) of work buffer for code conversion.  */
+extern Lisp_Object Vcode_conversion_workbuf_name;
 
 /* Enumeration of index to an attribute vector of a coding system.  */
 
@@ -137,7 +139,7 @@ enum coding_attr_index
 
     coding_attr_emacs_mule_full,
 
-    coding_attr_undecided_inhibit_null_byte_detection,
+    coding_attr_undecided_inhibit_nul_byte_detection,
     coding_attr_undecided_inhibit_iso_escape_detection,
     coding_attr_undecided_prefer_utf_8,
 
@@ -351,7 +353,7 @@ struct emacs_mule_spec
 
 struct undecided_spec
 {
-  /* Inhibit null byte detection.  1 means always inhibit,
+  /* Inhibit NUL byte detection.  1 means always inhibit,
      -1 means do not inhibit, 0 means rely on user variable.  */
   int inhibit_nbd;
 
@@ -450,7 +452,7 @@ struct coding_system
 
   unsigned char *safe_charsets;
 
-  /* How may heading bytes we can skip for decoding.  This is set to
+  /* How many heading bytes we can skip for decoding.  This is set to
      -1 in setup_coding_system, and updated by detect_coding.  So,
      when this is equal to the byte length of the text being
      converted, we can skip the actual conversion process except for
@@ -762,15 +764,10 @@ surrogates_to_codepoint (int low, int high)
 
 extern Lisp_Object preferred_coding_system (void);
 
-
-#ifdef emacs
-
 /* Coding system to be used to encode text for terminal display when
    terminal coding system is nil.  */
 extern struct coding_system safe_terminal_coding;
 
-#endif
-
 extern char emacs_mule_bytes[256];
 
 INLINE_HEADER_END
diff --git a/src/commands.h b/src/commands.h
index a741da1..1ea6ab6 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -1,5 +1,5 @@
 /* Definitions needed by most editing commands.
-   Copyright (C) 1985, 1994, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1994, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/composite.c b/src/composite.c
index 28501e4..183062d 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -1,5 +1,5 @@
 /* Composite sequence support.
-   Copyright (C) 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 2001-2019 Free Software Foundation, Inc.
    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 
2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H14PRO021
@@ -176,7 +176,7 @@ get_composition_id (ptrdiff_t charpos, ptrdiff_t bytepos, 
ptrdiff_t nchars,
 
   /* Maximum length of a string of glyphs.  XftGlyphExtents limits
      this to INT_MAX, and Emacs limits it further.  Divide INT_MAX - 1
-     by 2 because x_produce_glyphs computes glyph_len * 2 + 1.  Divide
+     by 2 because gui_produce_glyphs computes glyph_len * 2 + 1.  Divide
      the size by MAX_MULTIBYTE_LENGTH because encode_terminal_code
      multiplies glyph_len by MAX_MULTIBYTE_LENGTH.  */
   enum {
@@ -654,6 +654,7 @@ Lisp_Object
 composition_gstring_put_cache (Lisp_Object gstring, ptrdiff_t len)
 {
   struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table);
+  hash_rehash_if_needed (h);
   Lisp_Object header = LGSTRING_HEADER (gstring);
   EMACS_UINT hash = h->test.hashfn (&h->test, header);
   if (len < 0)
@@ -786,28 +787,19 @@ static Lisp_Object gstring_work;
 static Lisp_Object gstring_work_headers;
 
 static Lisp_Object
-fill_gstring_header (Lisp_Object header, ptrdiff_t from, ptrdiff_t from_byte,
+fill_gstring_header (ptrdiff_t from, ptrdiff_t from_byte,
                     ptrdiff_t to, Lisp_Object font_object, Lisp_Object string)
 {
-  ptrdiff_t len = to - from, i;
-
+  ptrdiff_t len = to - from;
   if (len == 0)
     error ("Attempt to shape zero-length text");
-  if (VECTORP (header))
-    {
-      if (ASIZE (header) != len + 1)
-       args_out_of_range (header, make_fixnum (len + 1));
-    }
-  else
-    {
-      if (len <= 8)
-       header = AREF (gstring_work_headers, len - 1);
-      else
-       header = make_uninit_vector (len + 1);
-    }
+  eassume (0 < len);
+  Lisp_Object header = (len <= 8
+                       ? AREF (gstring_work_headers, len - 1)
+                       : make_uninit_vector (len + 1));
 
   ASET (header, 0, font_object);
-  for (i = 0; i < len; i++)
+  for (ptrdiff_t i = 0; i < len; i++)
     {
       int c;
 
@@ -1758,7 +1750,7 @@ should be ignored.  */)
       frombyte = string_char_to_byte (string, frompos);
     }
 
-  header = fill_gstring_header (Qnil, frompos, frombyte,
+  header = fill_gstring_header (frompos, frombyte,
                                topos, font_object, string);
   gstring = gstring_lookup_cache (header);
   if (! NILP (gstring))
diff --git a/src/composite.h b/src/composite.h
index 8ee18cd..45d72fb 100644
--- a/src/composite.h
+++ b/src/composite.h
@@ -1,5 +1,5 @@
 /* Header for composite sequence handler.
-   Copyright (C) 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 2001-2019 Free Software Foundation, Inc.
    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 
2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H14PRO021
diff --git a/src/conf_post.h b/src/conf_post.h
index 2f8b264..7699d2c 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -1,6 +1,6 @@
 /* conf_post.h --- configure.ac includes this via AH_BOTTOM
 
-Copyright (C) 1988, 1993-1994, 1999-2002, 2004-2018 Free Software
+Copyright (C) 1988, 1993-1994, 1999-2002, 2004-2019 Free Software
 Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -73,10 +73,12 @@ typedef bool bool_bf;
 # define __has_attribute(a) __has_attribute_##a
 # define __has_attribute_alloc_size GNUC_PREREQ (4, 3, 0)
 # define __has_attribute_cleanup GNUC_PREREQ (3, 4, 0)
+# define __has_attribute_cold GNUC_PREREQ (4, 3, 0)
 # define __has_attribute_externally_visible GNUC_PREREQ (4, 1, 0)
 # define __has_attribute_no_address_safety_analysis false
 # define __has_attribute_no_sanitize_address GNUC_PREREQ (4, 8, 0)
 # define __has_attribute_no_sanitize_undefined GNUC_PREREQ (4, 9, 0)
+# define __has_attribute_warn_unused_result GNUC_PREREQ (3, 4, 0)
 #endif
 
 /* Simulate __has_feature on compilers that lack it.  It is used only
@@ -92,13 +94,11 @@ typedef bool bool_bf;
 # define ADDRESS_SANITIZER false
 #endif
 
-#ifdef DARWIN_OS
-#if defined emacs && !defined CANNOT_DUMP
-#define malloc unexec_malloc
-#define realloc unexec_realloc
-#define free unexec_free
+#if defined DARWIN_OS && defined emacs && defined HAVE_UNEXEC
+# define malloc unexec_malloc
+# define realloc unexec_realloc
+# define free unexec_free
 #endif
-#endif  /* DARWIN_OS */
 
 /* If HYBRID_MALLOC is defined (e.g., on Cygwin), emacs will use
    gmalloc before dumping and the system malloc after dumping.
@@ -225,6 +225,12 @@ extern void _DebPrint (const char *fmt, ...);
 extern char *emacs_getenv_TZ (void);
 extern int emacs_setenv_TZ (char const *);
 
+#if __has_attribute (cold)
+# define ATTRIBUTE_COLD __attribute__ ((cold))
+#else
+# define ATTRIBUTE_COLD
+#endif
+
 #if __GNUC__ >= 3  /* On GCC 3.0 we might get a warning.  */
 #define NO_INLINE __attribute__((noinline))
 #else
@@ -299,8 +305,10 @@ extern int emacs_setenv_TZ (char const *);
 
 #if 3 <= __GNUC__
 # define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+# define ATTRIBUTE_SECTION(name) __attribute__((section (name)))
 #else
 # define ATTRIBUTE_MALLOC
+#define ATTRIBUTE_SECTION(name)
 #endif
 
 #if __has_attribute (alloc_size)
diff --git a/src/cygw32.c b/src/cygw32.c
index 78bb16c..fb2fa03 100644
--- a/src/cygw32.c
+++ b/src/cygw32.c
@@ -1,5 +1,5 @@
 /* Cygwin support routines.
-   Copyright (C) 2011-2018 Free Software Foundation, Inc.
+   Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/cygw32.h b/src/cygw32.h
index ec6b264..33ddf88 100644
--- a/src/cygw32.h
+++ b/src/cygw32.h
@@ -1,5 +1,5 @@
 /* Header for Cygwin support routines.
-   Copyright (C) 2011-2018 Free Software Foundation, Inc.
+   Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/data.c b/src/data.c
index 0980cf9..7928a1d 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1,5 +1,5 @@
 /* Primitive operations on Lisp data types for GNU Emacs Lisp interpreter.
-   Copyright (C) 1985-1986, 1988, 1993-1995, 1997-2018 Free Software
+   Copyright (C) 1985-1986, 1988, 1993-1995, 1997-2019 Free Software
    Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -42,49 +42,49 @@ static void swap_in_symval_forwarding (struct Lisp_Symbol *,
                                       struct Lisp_Buffer_Local_Value *);
 
 static bool
-BOOLFWDP (union Lisp_Fwd *a)
+BOOLFWDP (lispfwd a)
 {
   return XFWDTYPE (a) == Lisp_Fwd_Bool;
 }
 static bool
-INTFWDP (union Lisp_Fwd *a)
+INTFWDP (lispfwd a)
 {
   return XFWDTYPE (a) == Lisp_Fwd_Int;
 }
 static bool
-KBOARD_OBJFWDP (union Lisp_Fwd *a)
+KBOARD_OBJFWDP (lispfwd a)
 {
   return XFWDTYPE (a) == Lisp_Fwd_Kboard_Obj;
 }
 static bool
-OBJFWDP (union Lisp_Fwd *a)
+OBJFWDP (lispfwd a)
 {
   return XFWDTYPE (a) == Lisp_Fwd_Obj;
 }
 
-static struct Lisp_Boolfwd *
-XBOOLFWD (union Lisp_Fwd *a)
+static struct Lisp_Boolfwd const *
+XBOOLFWD (lispfwd a)
 {
   eassert (BOOLFWDP (a));
-  return &a->u_boolfwd;
+  return a.fwdptr;
 }
-static struct Lisp_Kboard_Objfwd *
-XKBOARD_OBJFWD (union Lisp_Fwd *a)
+static struct Lisp_Kboard_Objfwd const *
+XKBOARD_OBJFWD (lispfwd a)
 {
   eassert (KBOARD_OBJFWDP (a));
-  return &a->u_kboard_objfwd;
+  return a.fwdptr;
 }
-static struct Lisp_Intfwd *
-XFIXNUMFWD (union Lisp_Fwd *a)
+static struct Lisp_Intfwd const *
+XFIXNUMFWD (lispfwd a)
 {
   eassert (INTFWDP (a));
-  return &a->u_intfwd;
+  return a.fwdptr;
 }
-static struct Lisp_Objfwd *
-XOBJFWD (union Lisp_Fwd *a)
+static struct Lisp_Objfwd const *
+XOBJFWD (lispfwd a)
 {
   eassert (OBJFWDP (a));
-  return &a->u_objfwd;
+  return a.fwdptr;
 }
 
 static void
@@ -130,7 +130,7 @@ set_blv_valcell (struct Lisp_Buffer_Local_Value *blv, 
Lisp_Object val)
   blv->valcell = val;
 }
 
-static _Noreturn void
+static AVOID
 wrong_length_argument (Lisp_Object a1, Lisp_Object a2, Lisp_Object a3)
 {
   Lisp_Object size1 = make_fixnum (bool_vector_size (a1));
@@ -142,7 +142,7 @@ wrong_length_argument (Lisp_Object a1, Lisp_Object a2, 
Lisp_Object a3)
              make_fixnum (bool_vector_size (a3)));
 }
 
-_Noreturn void
+AVOID
 wrong_type_argument (register Lisp_Object predicate, register Lisp_Object 
value)
 {
   /* If VALUE is not even a valid Lisp object, we'd want to abort here
@@ -230,9 +230,7 @@ for example, (type-of 1) returns `integer'.  */)
        case PVEC_MARKER: return Qmarker;
        case PVEC_OVERLAY: return Qoverlay;
        case PVEC_FINALIZER: return Qfinalizer;
-#ifdef HAVE_MODULES
        case PVEC_USER_PTR: return Quser_ptr;
-#endif
         case PVEC_WINDOW_CONFIGURATION: return Qwindow_configuration;
         case PVEC_PROCESS: return Qprocess;
         case PVEC_WINDOW: return Qwindow;
@@ -669,7 +667,7 @@ global value outside of any lexical scope.  */)
     case SYMBOL_LOCALIZED:
       {
        struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym);
-       if (blv->fwd)
+       if (blv->fwd.fwdptr)
          /* In set_internal, we un-forward vars when their value is
             set to Qunbound.  */
          return Qt;
@@ -804,7 +802,7 @@ The return value is undefined.  */)
 
   {
     bool autoload = AUTOLOADP (definition);
-    if (NILP (Vpurify_flag) || !autoload)
+    if (!will_dump_p () || !autoload)
       { /* Only add autoload entries after dumping, because the ones before are
           not useful and else we get loads of them from the loaddefs.el.  */
 
@@ -980,14 +978,12 @@ chain of aliases, signal a `cyclic-variable-indirection' 
error.  */)
    swap_in_symval_forwarding for that.  */
 
 Lisp_Object
-do_symval_forwarding (register union Lisp_Fwd *valcontents)
+do_symval_forwarding (lispfwd valcontents)
 {
-  register Lisp_Object val;
   switch (XFWDTYPE (valcontents))
     {
     case Lisp_Fwd_Int:
-      XSETINT (val, *XFIXNUMFWD (valcontents)->intvar);
-      return val;
+      return make_int (*XFIXNUMFWD (valcontents)->intvar);
 
     case Lisp_Fwd_Bool:
       return (*XBOOLFWD (valcontents)->boolvar ? Qt : Qnil);
@@ -1023,7 +1019,7 @@ do_symval_forwarding (register union Lisp_Fwd 
*valcontents)
 void
 wrong_choice (Lisp_Object choice, Lisp_Object wrong)
 {
-  ptrdiff_t i = 0, len = XFIXNUM (Flength (choice));
+  ptrdiff_t i = 0, len = list_length (choice);
   Lisp_Object obj, *args;
   AUTO_STRING (one_of, "One of ");
   AUTO_STRING (comma, ", ");
@@ -1073,13 +1069,19 @@ wrong_range (Lisp_Object min, Lisp_Object max, 
Lisp_Object wrong)
    current buffer.  This only plays a role for per-buffer variables.  */
 
 static void
-store_symval_forwarding (union Lisp_Fwd *valcontents, register Lisp_Object 
newval, struct buffer *buf)
+store_symval_forwarding (lispfwd valcontents, Lisp_Object newval,
+                        struct buffer *buf)
 {
   switch (XFWDTYPE (valcontents))
     {
     case Lisp_Fwd_Int:
-      CHECK_FIXNUM (newval);
-      *XFIXNUMFWD (valcontents)->intvar = XFIXNUM (newval);
+      {
+       intmax_t i;
+       CHECK_INTEGER (newval);
+       if (! integer_to_intmax (newval, &i))
+         xsignal1 (Qoverflow_error, newval);
+       *XFIXNUMFWD (valcontents)->intvar = i;
+      }
       break;
 
     case Lisp_Fwd_Bool:
@@ -1175,12 +1177,12 @@ swap_in_global_binding (struct Lisp_Symbol *symbol)
   struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (symbol);
 
   /* Unload the previously loaded binding.  */
-  if (blv->fwd)
+  if (blv->fwd.fwdptr)
     set_blv_value (blv, do_symval_forwarding (blv->fwd));
 
   /* Select the global binding in the symbol.  */
   set_blv_valcell (blv, blv->defcell);
-  if (blv->fwd)
+  if (blv->fwd.fwdptr)
     store_symval_forwarding (blv->fwd, XCDR (blv->defcell), NULL);
 
   /* Indicate that the global binding is set up now.  */
@@ -1210,7 +1212,7 @@ swap_in_symval_forwarding (struct Lisp_Symbol *symbol, 
struct Lisp_Buffer_Local_
 
       /* Unload the previously loaded binding.  */
       tem1 = blv->valcell;
-      if (blv->fwd)
+      if (blv->fwd.fwdptr)
        set_blv_value (blv, do_symval_forwarding (blv->fwd));
       /* Choose the new binding.  */
       {
@@ -1224,7 +1226,7 @@ swap_in_symval_forwarding (struct Lisp_Symbol *symbol, 
struct Lisp_Buffer_Local_
 
       /* Load the new binding.  */
       set_blv_valcell (blv, tem1);
-      if (blv->fwd)
+      if (blv->fwd.fwdptr)
        store_symval_forwarding (blv->fwd, blv_value (blv), NULL);
     }
 }
@@ -1252,7 +1254,9 @@ find_symbol_value (Lisp_Object symbol)
       {
        struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym);
        swap_in_symval_forwarding (sym, blv);
-       return blv->fwd ? do_symval_forwarding (blv->fwd) : blv_value (blv);
+       return (blv->fwd.fwdptr
+               ? do_symval_forwarding (blv->fwd)
+               : blv_value (blv));
       }
     case SYMBOL_FORWARDED:
       return do_symval_forwarding (SYMBOL_FWD (sym));
@@ -1354,7 +1358,7 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, 
Lisp_Object where,
               We need to unload it, and choose a new binding.  */
 
            /* Write out `realvalue' to the old loaded binding.  */
-           if (blv->fwd)
+           if (blv->fwd.fwdptr)
              set_blv_value (blv, do_symval_forwarding (blv->fwd));
 
            /* Find the new binding.  */
@@ -1401,12 +1405,12 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, 
Lisp_Object where,
        /* Store the new value in the cons cell.  */
        set_blv_value (blv, newval);
 
-       if (blv->fwd)
+       if (blv->fwd.fwdptr)
          {
            if (voide)
              /* If storing void (making the symbol void), forward only through
                 buffer-local indicator, not through Lisp_Objfwd, etc.  */
-             blv->fwd = NULL;
+             blv->fwd.fwdptr = NULL;
            else
              store_symval_forwarding (blv->fwd, newval,
                                       BUFFERP (where)
@@ -1418,7 +1422,7 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, 
Lisp_Object where,
       {
        struct buffer *buf
          = BUFFERP (where) ? XBUFFER (where) : current_buffer;
-       union Lisp_Fwd *innercontents = SYMBOL_FWD (sym);
+       lispfwd innercontents = SYMBOL_FWD (sym);
        if (BUFFER_OBJFWDP (innercontents))
          {
            int offset = XBUFFER_OBJFWD (innercontents)->offset;
@@ -1590,14 +1594,14 @@ default_value (Lisp_Object symbol)
           But the `realvalue' slot may be more up to date, since
           ordinary setq stores just that slot.  So use that.  */
        struct Lisp_Buffer_Local_Value *blv = SYMBOL_BLV (sym);
-       if (blv->fwd && EQ (blv->valcell, blv->defcell))
+       if (blv->fwd.fwdptr && EQ (blv->valcell, blv->defcell))
          return do_symval_forwarding (blv->fwd);
        else
          return XCDR (blv->defcell);
       }
     case SYMBOL_FORWARDED:
       {
-       union Lisp_Fwd *valcontents = SYMBOL_FWD (sym);
+       lispfwd valcontents = SYMBOL_FWD (sym);
 
        /* For a built-in buffer-local variable, get the default value
           rather than letting do_symval_forwarding get the current value.  */
@@ -1685,13 +1689,13 @@ set_default_internal (Lisp_Object symbol, Lisp_Object 
value,
        XSETCDR (blv->defcell, value);
 
        /* If the default binding is now loaded, set the REALVALUE slot too.  */
-       if (blv->fwd && EQ (blv->defcell, blv->valcell))
+       if (blv->fwd.fwdptr && EQ (blv->defcell, blv->valcell))
          store_symval_forwarding (blv->fwd, value, NULL);
         return;
       }
     case SYMBOL_FORWARDED:
       {
-       union Lisp_Fwd *valcontents = SYMBOL_FWD (sym);
+       lispfwd valcontents = SYMBOL_FWD (sym);
 
        /* Handle variables like case-fold-search that have special slots
           in the buffer.
@@ -1741,43 +1745,13 @@ for this variable.  */)
   set_default_internal (symbol, value, SET_INTERNAL_SET);
   return value;
 }
-
-DEFUN ("setq-default", Fsetq_default, Ssetq_default, 0, UNEVALLED, 0,
-       doc: /* Set the default value of variable VAR to VALUE.
-VAR, the variable name, is literal (not evaluated);
-VALUE is an expression: it is evaluated and its value returned.
-The default value of a variable is seen in buffers
-that do not have their own values for the variable.
-
-More generally, you can use multiple variables and values, as in
-  (setq-default VAR VALUE VAR VALUE...)
-This sets each VAR's default value to the corresponding VALUE.
-The VALUE for the Nth VAR can refer to the new default values
-of previous VARs.
-usage: (setq-default [VAR VALUE]...)  */)
-  (Lisp_Object args)
-{
-  Lisp_Object args_left, symbol, val;
-
-  args_left = val = args;
-
-  while (CONSP (args_left))
-    {
-      val = eval_sub (Fcar (XCDR (args_left)));
-      symbol = XCAR (args_left);
-      Fset_default (symbol, val);
-      args_left = Fcdr (XCDR (args_left));
-    }
-
-  return val;
-}
 
 /* Lisp functions for creating and removing buffer-local variables.  */
 
 union Lisp_Val_Fwd
   {
     Lisp_Object value;
-    union Lisp_Fwd *fwd;
+    lispfwd fwd;
   };
 
 static struct Lisp_Buffer_Local_Value *
@@ -1797,7 +1771,10 @@ make_blv (struct Lisp_Symbol *sym, bool forwarded,
      or keyboard-local forwarding.  */
   eassert (!(forwarded && BUFFER_OBJFWDP (valcontents.fwd)));
   eassert (!(forwarded && KBOARD_OBJFWDP (valcontents.fwd)));
-  blv->fwd = forwarded ? valcontents.fwd : NULL;
+  if (forwarded)
+    blv->fwd = valcontents.fwd;
+  else
+    blv->fwd.fwdptr = NULL;
   set_blv_where (blv, Qnil);
   blv->local_if_set = 0;
   set_blv_defcell (blv, tem);
@@ -1828,7 +1805,7 @@ The function `default-value' gets the default value and 
`set-default' sets it.
 {
   struct Lisp_Symbol *sym;
   struct Lisp_Buffer_Local_Value *blv = NULL;
-  union Lisp_Val_Fwd valcontents;
+  union Lisp_Val_Fwd valcontents UNINIT;
   bool forwarded UNINIT;
 
   CHECK_SYMBOL (variable);
@@ -1895,7 +1872,7 @@ Instead, use `add-hook' and specify t for the LOCAL 
argument.  */)
 {
   Lisp_Object tem;
   bool forwarded UNINIT;
-  union Lisp_Val_Fwd valcontents;
+  union Lisp_Val_Fwd valcontents UNINIT;
   struct Lisp_Symbol *sym;
   struct Lisp_Buffer_Local_Value *blv = NULL;
 
@@ -1960,6 +1937,16 @@ Instead, use `add-hook' and specify t for the LOCAL 
argument.  */)
        (current_buffer,
         Fcons (Fcons (variable, XCDR (blv->defcell)),
                BVAR (current_buffer, local_var_alist)));
+
+      /* If the symbol forwards into a C variable, then load the binding
+         for this buffer now, to preserve the invariant that forwarded
+         variables must always hold the value corresponding to the
+         current buffer (they are swapped eagerly).
+         Otherwise, if C code modifies the variable before we load the
+         binding in, then that new value would clobber the default binding
+         the next time we unload it.  See bug#34318.  */
+      if (blv->fwd.fwdptr)
+        swap_in_symval_forwarding (sym, blv);
     }
 
   return variable;
@@ -1985,7 +1972,7 @@ From now on the default value will apply in this buffer.  
Return VARIABLE.  */)
     case SYMBOL_PLAINVAL: return variable;
     case SYMBOL_FORWARDED:
       {
-       union Lisp_Fwd *valcontents = SYMBOL_FWD (sym);
+       lispfwd valcontents = SYMBOL_FWD (sym);
        if (BUFFER_OBJFWDP (valcontents))
          {
            int offset = XBUFFER_OBJFWD (valcontents)->offset;
@@ -2068,7 +2055,7 @@ BUFFER defaults to the current buffer.  */)
       }
     case SYMBOL_FORWARDED:
       {
-       union Lisp_Fwd *valcontents = SYMBOL_FWD (sym);
+       lispfwd valcontents = SYMBOL_FWD (sym);
        if (BUFFER_OBJFWDP (valcontents))
          {
            int offset = XBUFFER_OBJFWD (valcontents)->offset;
@@ -2139,7 +2126,7 @@ If the current binding is global (the default), the value 
is nil.  */)
     case SYMBOL_PLAINVAL: return Qnil;
     case SYMBOL_FORWARDED:
       {
-       union Lisp_Fwd *valcontents = SYMBOL_FWD (sym);
+       lispfwd valcontents = SYMBOL_FWD (sym);
        if (KBOARD_OBJFWDP (valcontents))
          return Fframe_terminal (selected_frame);
        else if (!BUFFER_OBJFWDP (valcontents))
@@ -2414,14 +2401,14 @@ emacs_mpz_mul (mpz_t rop, mpz_t const op1, mpz_t const 
op2)
 }
 
 static void
-emacs_mpz_mul_2exp (mpz_t rop, mpz_t const op1, mp_bitcnt_t op2)
+emacs_mpz_mul_2exp (mpz_t rop, mpz_t const op1, EMACS_INT op2)
 {
   /* Fudge factor derived from GMP 6.1.2, to avoid an abort in
      mpz_mul_2exp (look for the '+ 1' in its source code).  */
   enum { mul_2exp_extra_limbs = 1 };
   enum { lim = min (NLIMBS_LIMIT, GMP_NLIMBS_MAX - mul_2exp_extra_limbs) };
 
-  mp_bitcnt_t op2limbs = op2 / GMP_NUMB_BITS;
+  EMACS_INT op2limbs = op2 / GMP_NUMB_BITS;
   if (lim - emacs_mpz_size (op1) < op2limbs)
     overflow_error ();
   mpz_mul_2exp (rop, op1, op2);
@@ -2655,7 +2642,7 @@ cons_to_unsigned (Lisp_Object c, uintmax_t max)
   else
     {
       Lisp_Object hi = CONSP (c) ? XCAR (c) : c;
-      valid = integer_to_uintmax (hi, &val);
+      valid = INTEGERP (hi) && integer_to_uintmax (hi, &val);
 
       if (valid && CONSP (c))
        {
@@ -2716,7 +2703,7 @@ cons_to_signed (Lisp_Object c, intmax_t min, intmax_t max)
   else
     {
       Lisp_Object hi = CONSP (c) ? XCAR (c) : c;
-      valid = integer_to_intmax (hi, &val);
+      valid = INTEGERP (hi) && integer_to_intmax (hi, &val);
 
       if (valid && CONSP (c))
        {
@@ -2960,7 +2947,7 @@ arith_driver (enum arithop code, ptrdiff_t nargs, 
Lisp_Object *args,
        /* Set ACCUM to the next operation's result if it fits,
           else exit the loop.  */
        bool overflow = false;
-       intmax_t a;
+       intmax_t a UNINIT;
        switch (code)
          {
          case Aadd : overflow = INT_ADD_WRAPV (accum, next, &a); break;
@@ -3251,12 +3238,21 @@ If COUNT is negative, shifting is actually to the right.
 In this case, the sign bit is duplicated.  */)
   (Lisp_Object value, Lisp_Object count)
 {
-  /* The negative of the minimum value of COUNT that fits into a fixnum,
-     such that mpz_fdiv_q_exp supports -COUNT.  */
-  EMACS_INT minus_count_min = min (-MOST_NEGATIVE_FIXNUM,
-                                  TYPE_MAXIMUM (mp_bitcnt_t));
   CHECK_INTEGER (value);
-  CHECK_RANGED_INTEGER (count, - minus_count_min, TYPE_MAXIMUM (mp_bitcnt_t));
+  CHECK_INTEGER (count);
+
+  if (! FIXNUMP (count))
+    {
+      if (EQ (value, make_fixnum (0)))
+       return value;
+      if (mpz_sgn (XBIGNUM (count)->value) < 0)
+       {
+         EMACS_INT v = (FIXNUMP (value) ? XFIXNUM (value)
+                        : mpz_sgn (XBIGNUM (value)->value));
+         return make_fixnum (v < 0 ? -1 : 0);
+       }
+      overflow_error ();
+    }
 
   if (XFIXNUM (count) <= 0)
     {
@@ -3275,7 +3271,11 @@ In this case, the sign bit is duplicated.  */)
 
   mpz_t *zval = bignum_integer (&mpz[0], value);
   if (XFIXNUM (count) < 0)
-    mpz_fdiv_q_2exp (mpz[0], *zval, - XFIXNUM (count));
+    {
+      if (TYPE_MAXIMUM (mp_bitcnt_t) < - XFIXNUM (count))
+       return make_fixnum (mpz_sgn (*zval) < 0 ? -1 : 0);
+      mpz_fdiv_q_2exp (mpz[0], *zval, - XFIXNUM (count));
+    }
   else
     emacs_mpz_mul_2exp (mpz[0], *zval, XFIXNUM (count));
   return make_integer_mpz ();
@@ -3836,9 +3836,7 @@ syms_of_data (void)
   DEFSYM (Qbool_vector_p, "bool-vector-p");
   DEFSYM (Qchar_or_string_p, "char-or-string-p");
   DEFSYM (Qmarkerp, "markerp");
-#ifdef HAVE_MODULES
   DEFSYM (Quser_ptrp, "user-ptrp");
-#endif
   DEFSYM (Qbuffer_or_string_p, "buffer-or-string-p");
   DEFSYM (Qinteger_or_marker_p, "integer-or-marker-p");
   DEFSYM (Qfboundp, "fboundp");
@@ -3933,9 +3931,7 @@ syms_of_data (void)
   DEFSYM (Qoverlay, "overlay");
   DEFSYM (Qfinalizer, "finalizer");
   DEFSYM (Qmodule_function, "module-function");
-#ifdef HAVE_MODULES
   DEFSYM (Quser_ptr, "user-ptr");
-#endif
   DEFSYM (Qfloat, "float");
   DEFSYM (Qwindow_configuration, "window-configuration");
   DEFSYM (Qprocess, "process");
@@ -4021,7 +4017,6 @@ syms_of_data (void)
   defsubr (&Sdefault_boundp);
   defsubr (&Sdefault_value);
   defsubr (&Sset_default);
-  defsubr (&Ssetq_default);
   defsubr (&Smake_variable_buffer_local);
   defsubr (&Smake_local_variable);
   defsubr (&Skill_local_variable);
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 403fc59..0afae6b 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -1,5 +1,5 @@
 /* Elisp bindings for D-Bus.
-   Copyright (C) 2007-2018 Free Software Foundation, Inc.
+   Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -1831,6 +1831,8 @@ be called when the D-Bus reply message arrives.  */);
   xd_registered_buses = Qnil;
   staticpro (&xd_registered_buses);
 
+  // TODO: reset buses on dump load
+
   Fprovide (intern_c_string ("dbusbind"), Qnil);
 
 }
diff --git a/src/decompress.c b/src/decompress.c
index 2836338..4ca6a50 100644
--- a/src/decompress.c
+++ b/src/decompress.c
@@ -1,5 +1,5 @@
 /* Interface to zlib.
-   Copyright (C) 2013-2018 Free Software Foundation, Inc.
+   Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -120,12 +120,18 @@ DEFUN ("zlib-available-p", Fzlib_available_p, 
Szlib_available_p, 0, 0, 0,
 
 DEFUN ("zlib-decompress-region", Fzlib_decompress_region,
        Szlib_decompress_region,
-       2, 2, 0,
+       2, 3, 0,
        doc: /* Decompress a gzip- or zlib-compressed region.
 Replace the text in the region by the decompressed data.
-On failure, return nil and leave the data in place.
+
+If optional parameter ALLOW-PARTIAL is nil or omitted, then on
+failure, return nil and leave the data in place.  Otherwise, return
+the number of bytes that were not decompressed and replace the region
+text by whatever data was successfully decompressed (similar to gzip).
+If decompression is completely successful return t.
+
 This function can be called only in unibyte buffers.  */)
-  (Lisp_Object start, Lisp_Object end)
+  (Lisp_Object start, Lisp_Object end, Lisp_Object allow_partial)
 {
   ptrdiff_t istart, iend, pos_byte;
   z_stream stream;
@@ -206,8 +212,14 @@ This function can be called only in unibyte buffers.  */)
     }
   while (inflate_status == Z_OK);
 
+  Lisp_Object ret = Qt;
   if (inflate_status != Z_STREAM_END)
-    return unbind_to (count, Qnil);
+    {
+      if (!NILP (allow_partial))
+        ret = make_int (iend - pos_byte);
+      else
+        return unbind_to (count, Qnil);
+    }
 
   unwind_data.start = 0;
 
@@ -218,7 +230,7 @@ This function can be called only in unibyte buffers.  */)
   signal_after_change (istart, iend - istart, unwind_data.nbytes);
   update_compositions (istart, istart, CHECK_HEAD);
 
-  return unbind_to (count, Qt);
+  return unbind_to (count, ret);
 }
 
 
diff --git a/src/deps.mk b/src/deps.mk
index f202d0e..2cdeba8 100644
--- a/src/deps.mk
+++ b/src/deps.mk
@@ -1,6 +1,6 @@
 ### deps.mk --- src/Makefile fragment for GNU Emacs
 
-## Copyright (C) 1985, 1987-1988, 1993-1995, 1999-2018 Free Software
+## Copyright (C) 1985, 1987-1988, 1993-1995, 1999-2019 Free Software
 ## Foundation, Inc.
 
 ## This file is part of GNU Emacs.
diff --git a/src/dired.c b/src/dired.c
index 7ad401c..4937582 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -1,5 +1,5 @@
 /* Lisp functions for making directory listings.
-   Copyright (C) 1985-1986, 1993-1994, 1999-2018 Free Software
+   Copyright (C) 1985-1986, 1993-1994, 1999-2019 Free Software
    Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -236,6 +236,9 @@ directory_files_internal (Lisp_Object directory, 
Lisp_Object full,
 #endif
     ;
 
+  if (!NILP (match))
+    CHECK_STRING (match);
+
   /* Loop reading directory entries.  */
   for (struct dirent *dp; (dp = read_dirent (d, directory)); )
     {
@@ -333,7 +336,7 @@ If NOSORT is non-nil, the list is not sorted--its order is 
unpredictable.
   directory = Fexpand_file_name (directory, Qnil);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (directory, Qdirectory_files);
   if (!NILP (handler))
     return call5 (handler, Qdirectory_files, directory,
@@ -368,7 +371,7 @@ which see.  */)
   directory = Fexpand_file_name (directory, Qnil);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (directory, 
Qdirectory_files_and_attributes);
   if (!NILP (handler))
     return call6 (handler, Qdirectory_files_and_attributes,
@@ -403,13 +406,13 @@ is matched against file and directory names relative to 
DIRECTORY.  */)
   directory = Fexpand_file_name (directory, Qnil);
 
   /* If the directory name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (directory, Qfile_name_completion);
   if (!NILP (handler))
     return call4 (handler, Qfile_name_completion, file, directory, predicate);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (file, Qfile_name_completion);
   if (!NILP (handler))
     return call4 (handler, Qfile_name_completion, file, directory, predicate);
@@ -431,13 +434,13 @@ is matched against file and directory names relative to 
DIRECTORY.  */)
   directory = Fexpand_file_name (directory, Qnil);
 
   /* If the directory name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (directory, Qfile_name_all_completions);
   if (!NILP (handler))
     return call3 (handler, Qfile_name_all_completions, file, directory);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (file, Qfile_name_all_completions);
   if (!NILP (handler))
     return call3 (handler, Qfile_name_all_completions, file, directory);
@@ -901,11 +904,12 @@ so last access time will always be midnight of that day.  
*/)
     return Qnil;
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (filename, Qfile_attributes);
   if (!NILP (handler))
-    { /* Only pass the extra arg if it is used to help backward compatibility
-        with old file handlers which do not implement the new arg.  --Stef  */
+    { /* Only pass the extra arg if it is used to help backward
+        compatibility with old file name handlers which do not
+        implement the new arg.  --Stef */
       if (NILP (id_format))
        return call2 (handler, Qfile_attributes, filename);
       else
@@ -926,7 +930,7 @@ file_attributes (int fd, char const *name,
   struct stat s;
 
   /* An array to hold the mode string generated by filemodestring,
-     including its terminating space and null byte.  */
+     including its terminating space and NUL byte.  */
   char modes[sizeof "-rwxr-xr-x "];
 
   char *uname = NULL, *gname = NULL;
diff --git a/src/dispextern.h b/src/dispextern.h
index 4cd0176..4d6d037 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1,6 +1,6 @@
 /* Interface definitions for display code.
 
-Copyright (C) 1985, 1993-1994, 1997-2018 Free Software Foundation, Inc.
+Copyright (C) 1985, 1993-1994, 1997-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -31,6 +31,9 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include <X11/Intrinsic.h>
 #endif /* USE_X_TOOLKIT */
 
+#ifdef HAVE_XRENDER
+# include <X11/extensions/Xrender.h>
+#endif
 #else /* !HAVE_X_WINDOWS */
 
 /* X-related stuff used by non-X gui code.  */
@@ -1677,7 +1680,7 @@ struct face
 
   /* True means that colors of this face may not be freed because they
      have been copied bitwise from a base face (see
-     realize_x_face).  */
+     realize_gui_face).  */
   bool_bf colors_copied_bitwise_p : 1;
 
   /* If non-zero, use overstrike (to simulate bold-face).  */
@@ -1934,7 +1937,7 @@ struct bidi_string_data {
   Lisp_Object lstring;         /* Lisp string to reorder, or nil */
   const unsigned char *s;      /* string data, or NULL if reordering buffer */
   ptrdiff_t schars;            /* the number of characters in the string,
-                                  excluding the terminating null */
+                                  excluding the terminating NUL */
   ptrdiff_t bufpos;            /* buffer position of lstring, or 0 if N/A */
   bool_bf from_disp_str : 1;   /* True means the string comes from a
                                   display property */
@@ -2894,6 +2897,11 @@ struct redisplay_interface
   void (*clear_frame_area) (struct frame *f, int x, int y,
                             int width, int height);
 
+ /* Clear area of frame F's internal border.  If the internal border
+    face of F has been specified (is not null), fill the area with
+    that face.  */
+  void (*clear_under_internal_border) (struct frame *f);
+
   /* Draw specified cursor CURSOR_TYPE of width CURSOR_WIDTH
      at row GLYPH_ROW on window W if ON_P is true.  If ON_P is
      false, don't draw cursor.  If ACTIVE_P is true, system caret
@@ -2935,6 +2943,10 @@ struct redisplay_interface
 
 #ifdef HAVE_WINDOW_SYSTEM
 
+# if defined USE_CAIRO || defined HAVE_XRENDER || defined HAVE_NS || defined 
HAVE_NTGUI
+#  define HAVE_NATIVE_SCALING
+# endif
+
 /* Structure describing an image.  Specific image formats like XBM are
    converted into this form, so that display only has to deal with
    this type of image.  */
@@ -2950,7 +2962,6 @@ struct image
 
 #ifdef USE_CAIRO
   void *cr_data;
-  void *cr_data2;
 #endif
 #ifdef HAVE_X_WINDOWS
   /* X images of the image, corresponding to the above Pixmaps.
@@ -2958,6 +2969,11 @@ struct image
      and the latter is outdated.  NULL means the X image has been
      synchronized to Pixmap.  */
   XImagePtr ximg, mask_img;
+
+# ifdef HAVE_NATIVE_SCALING
+  /* Picture versions of pixmap and mask for compositing.  */
+  Picture picture, mask_picture;
+# endif
 #endif
 
   /* Colors allocated for this image, if any.  Allocated via xmalloc.  */
@@ -3263,19 +3279,19 @@ extern void get_font_ascent_descent (struct font *, int 
*, int *);
 extern void dump_glyph_string (struct glyph_string *) EXTERNALLY_VISIBLE;
 #endif
 
-extern void x_get_glyph_overhangs (struct glyph *, struct frame *,
-                                   int *, int *);
+extern void gui_get_glyph_overhangs (struct glyph *, struct frame *,
+                                     int *, int *);
 extern struct font *font_for_underline_metrics (struct glyph_string *);
-extern void x_produce_glyphs (struct it *);
-
-extern void x_write_glyphs (struct window *, struct glyph_row *,
-                           struct glyph *, enum glyph_row_area, int);
-extern void x_insert_glyphs (struct window *, struct glyph_row *,
-                            struct glyph *, enum glyph_row_area, int);
-extern void x_clear_end_of_line (struct window *, struct glyph_row *,
-                                enum glyph_row_area, int);
-extern void x_fix_overlapping_area (struct window *, struct glyph_row *,
-                                    enum glyph_row_area, int);
+extern void gui_produce_glyphs (struct it *);
+
+extern void gui_write_glyphs (struct window *, struct glyph_row *,
+                              struct glyph *, enum glyph_row_area, int);
+extern void gui_insert_glyphs (struct window *, struct glyph_row *,
+                               struct glyph *, enum glyph_row_area, int);
+extern void gui_clear_end_of_line (struct window *, struct glyph_row *,
+                                   enum glyph_row_area, int);
+extern void gui_fix_overlapping_area (struct window *, struct glyph_row *,
+                                      enum glyph_row_area, int);
 extern void draw_phys_cursor_glyph (struct window *,
                                     struct glyph_row *,
                                     enum draw_glyphs_face);
@@ -3283,10 +3299,10 @@ extern void get_phys_cursor_geometry (struct window *, 
struct glyph_row *,
                                       struct glyph *, int *, int *, int *);
 extern void erase_phys_cursor (struct window *);
 extern void display_and_set_cursor (struct window *, bool, int, int, int, int);
-extern void x_update_cursor (struct frame *, bool);
-extern void x_clear_cursor (struct window *);
-extern void x_draw_vertical_border (struct window *w);
-extern void x_draw_right_divider (struct window *w);
+extern void gui_update_cursor (struct frame *, bool);
+extern void gui_clear_cursor (struct window *);
+extern void gui_draw_vertical_border (struct window *w);
+extern void gui_draw_right_divider (struct window *w);
 
 extern int get_glyph_string_clip_rects (struct glyph_string *,
                                         NativeRectangle *, int);
@@ -3298,11 +3314,11 @@ extern void handle_tool_bar_click (struct frame *,
                                    int, int, bool, int);
 
 extern void expose_frame (struct frame *, int, int, int, int);
-extern bool x_intersect_rectangles (XRectangle *, XRectangle *, XRectangle *);
+extern bool gui_intersect_rectangles (XRectangle *, XRectangle *, XRectangle 
*);
 #endif /* HAVE_WINDOW_SYSTEM */
 
 extern void note_mouse_highlight (struct frame *, int, int);
-extern void x_clear_window_mouse_face (struct window *);
+extern void gui_clear_window_mouse_face (struct window *);
 extern void cancel_mouse_face (struct frame *);
 extern bool clear_mouse_face (Mouse_HLInfo *);
 extern bool cursor_in_mouse_face_p (struct window *w);
@@ -3336,20 +3352,22 @@ extern bool buffer_flipping_blocked_p (void);
 
 #ifdef HAVE_WINDOW_SYSTEM
 
-extern ptrdiff_t x_bitmap_pixmap (struct frame *, ptrdiff_t);
-extern void x_reference_bitmap (struct frame *, ptrdiff_t);
-extern ptrdiff_t x_create_bitmap_from_data (struct frame *, char *,
-                                           unsigned int, unsigned int);
-extern ptrdiff_t x_create_bitmap_from_file (struct frame *, Lisp_Object);
+extern ptrdiff_t image_bitmap_pixmap (struct frame *, ptrdiff_t);
+extern void image_reference_bitmap (struct frame *, ptrdiff_t);
+extern ptrdiff_t image_create_bitmap_from_data (struct frame *, char *,
+                                                unsigned int, unsigned int);
+extern ptrdiff_t image_create_bitmap_from_file (struct frame *, Lisp_Object);
 #if defined HAVE_XPM && defined HAVE_X_WINDOWS && !defined USE_GTK
 extern ptrdiff_t x_create_bitmap_from_xpm_data (struct frame *, const char **);
 #endif
-#ifndef x_destroy_bitmap
-extern void x_destroy_bitmap (struct frame *, ptrdiff_t);
+#ifndef image_destroy_bitmap
+extern void image_destroy_bitmap (struct frame *, ptrdiff_t);
 #endif
-extern void x_destroy_all_bitmaps (Display_Info *);
+extern void image_destroy_all_bitmaps (Display_Info *);
+#ifdef HAVE_X_WINDOWS
 extern void x_create_bitmap_mask (struct frame *, ptrdiff_t);
-extern Lisp_Object x_find_image_file (Lisp_Object);
+#endif
+extern Lisp_Object image_find_image_file (Lisp_Object);
 
 void x_kill_gs_process (Pixmap, struct frame *);
 struct image_cache *make_image_cache (void);
@@ -3395,6 +3413,9 @@ void x_free_colors (struct frame *, unsigned long *, int);
 
 void update_face_from_frame_parameter (struct frame *, Lisp_Object,
                                        Lisp_Object);
+extern bool tty_defined_color (struct frame *f, const char *, XColor *, bool,
+                               bool);
+
 Lisp_Object tty_color_name (struct frame *, int);
 void clear_face_cache (bool);
 unsigned long load_color (struct frame *, struct face *, Lisp_Object,
@@ -3435,11 +3456,6 @@ void gamma_correct (struct frame *, COLORREF *);
 
 #ifdef HAVE_WINDOW_SYSTEM
 
-void x_implicitly_set_name (struct frame *, Lisp_Object, Lisp_Object);
-void x_change_tool_bar_height (struct frame *f, int);
-
-extern frame_parm_handler x_frame_parm_handlers[];
-
 extern void start_hourglass (void);
 extern void cancel_hourglass (void);
 
@@ -3575,23 +3591,21 @@ enum resource_types
 };
 
 extern Display_Info *check_x_display_info (Lisp_Object);
-extern Lisp_Object x_get_arg (Display_Info *, Lisp_Object,
-                              Lisp_Object, const char *, const char *class,
-                              enum resource_types);
-extern Lisp_Object x_frame_get_and_record_arg (struct frame *, Lisp_Object,
-                                               Lisp_Object,
-                                              const char *, const char *,
-                                               enum resource_types);
-extern Lisp_Object x_default_parameter (struct frame *, Lisp_Object,
-                                        Lisp_Object, Lisp_Object,
-                                        const char *, const char *,
+extern Lisp_Object gui_display_get_arg (Display_Info *, Lisp_Object,
+                                        Lisp_Object, const char *, const char 
*,
                                         enum resource_types);
-extern char *x_get_string_resource (XrmDatabase, const char *,
-                                   const char *);
+extern Lisp_Object gui_frame_get_and_record_arg (struct frame *, Lisp_Object,
+                                                 Lisp_Object,
+                                                 const char *, const char *,
+                                                 enum resource_types);
+extern Lisp_Object gui_default_parameter (struct frame *, Lisp_Object,
+                                          Lisp_Object, Lisp_Object,
+                                          const char *, const char *,
+                                          enum resource_types);
 
 #ifndef HAVE_NS /* These both used on W32 and X only.  */
-extern bool x_mouse_grabbed (Display_Info *);
-extern void x_redo_mouse_highlight (Display_Info *);
+extern bool gui_mouse_grabbed (Display_Info *);
+extern void gui_redo_mouse_highlight (Display_Info *);
 #endif /* HAVE_NS */
 
 #endif /* HAVE_WINDOW_SYSTEM */
diff --git a/src/dispnew.c b/src/dispnew.c
index b628c69..25a2d1c 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -1,6 +1,6 @@
 /* Updating of data structures for redisplay.
 
-Copyright (C) 1985-1988, 1993-1995, 1997-2018 Free Software Foundation,
+Copyright (C) 1985-1988, 1993-1995, 1997-2019 Free Software Foundation,
 Inc.
 
 This file is part of GNU Emacs.
@@ -42,6 +42,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "systime.h"
 #include "tparam.h"
 #include "xwidget.h"
+#include "pdumper.h"
 
 #ifdef HAVE_WINDOW_SYSTEM
 #include TERM_HEADER
@@ -766,7 +767,7 @@ clear_current_matrices (register struct frame *f)
     clear_glyph_matrix (XWINDOW (f->menu_bar_window)->current_matrix);
 #endif
 
-#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
   /* Clear the matrix of the tool-bar window, if any.  */
   if (WINDOWP (f->tool_bar_window))
     clear_glyph_matrix (XWINDOW (f->tool_bar_window)->current_matrix);
@@ -791,7 +792,7 @@ clear_desired_matrices (register struct frame *f)
     clear_glyph_matrix (XWINDOW (f->menu_bar_window)->desired_matrix);
 #endif
 
-#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
   if (WINDOWP (f->tool_bar_window))
     clear_glyph_matrix (XWINDOW (f->tool_bar_window)->desired_matrix);
 #endif
@@ -2105,7 +2106,7 @@ adjust_frame_glyphs_for_window_redisplay (struct frame *f)
   }
 #endif
 
-#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
   {
     /* Allocate/ reallocate matrices of the tool bar window.  If we
        don't have a tool bar window yet, make one.  */
@@ -2187,7 +2188,7 @@ free_glyphs (struct frame *f)
        }
 #endif
 
-#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
       /* Free the tool bar window and its glyph matrices.  */
       if (!NILP (f->tool_bar_window))
        {
@@ -3081,7 +3082,7 @@ update_frame (struct frame *f, bool force_p, bool 
inhibit_hairy_id_p)
        update_window (XWINDOW (f->menu_bar_window), true);
 #endif
 
-#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
       /* Update the tool-bar window, if present.  */
       if (WINDOWP (f->tool_bar_window))
        {
@@ -3388,7 +3389,7 @@ update_window (struct window *w, bool force_p)
 {
   struct glyph_matrix *desired_matrix = w->desired_matrix;
   bool paused_p;
-  int preempt_count = baud_rate / 2400 + 1;
+  int preempt_count = clip_to_bounds (1, baud_rate / 2400 + 1, INT_MAX);
   struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
 #ifdef GLYPH_DEBUG
   /* Check that W's frame doesn't have glyph matrices.  */
@@ -4484,16 +4485,13 @@ update_frame_1 (struct frame *f, bool force_p, bool 
inhibit_id_p,
   struct glyph_matrix *desired_matrix = f->desired_matrix;
   int i;
   bool pause_p;
-  int preempt_count = baud_rate / 2400 + 1;
+  int preempt_count = clip_to_bounds (1, baud_rate / 2400 + 1, INT_MAX);
 
   eassert (current_matrix && desired_matrix);
 
   if (baud_rate != FRAME_COST_BAUD_RATE (f))
     calculate_costs (f);
 
-  if (preempt_count <= 0)
-    preempt_count = 1;
-
   if (!force_p && detect_input_pending_ignore_squeezables ())
     {
       pause_p = 1;
@@ -5099,13 +5097,15 @@ update_frame_line (struct frame *f, int vpos, bool 
updating_menu_p)
  ***********************************************************************/
 
 /* Determine what's under window-relative pixel position (*X, *Y).
-   Return the OBJECT (string or buffer) that's there.
+   Return the object (string or buffer) that's there.
    Return in *POS the position in that object.
    Adjust *X and *Y to character positions.
+   If an image is shown at the specified position, return
+   in *OBJECT its image-spec.
    Return in *DX and *DY the pixel coordinates of the click,
-   relative to the top left corner of OBJECT, or relative to
+   relative to the top left corner of object, or relative to
    the top left corner of the character glyph at (*X, *Y)
-   if OBJECT is nil.
+   if the object at (*X, *Y) is nil.
    Return WIDTH and HEIGHT of the object at (*X, *Y), or zero
    if the coordinates point to an empty area of the display.  */
 
@@ -5551,7 +5551,7 @@ change_frame_size_1 (struct frame *f, int new_width, int 
new_height,
                        * FRAME_LINE_HEIGHT (f));
        }
 
-      /* Adjust frame size but make sure x_set_window_size does not
+      /* Adjust frame size but make sure set_window_size_hook does not
         get called.  */
       adjust_frame_size (f, new_width, new_height, 5, pretend,
                         Qchange_frame_size);
@@ -5985,12 +5985,24 @@ pass nil for VARIABLE.  */)
                            Initialization
 ***********************************************************************/
 
+static void
+init_faces_initial (void)
+{
+  /* For the initial frame, we don't have any way of knowing what
+     are the foreground and background colors of the terminal.  */
+  struct frame *sf = SELECTED_FRAME ();
+
+  FRAME_FOREGROUND_PIXEL (sf) = FACE_TTY_DEFAULT_FG_COLOR;
+  FRAME_BACKGROUND_PIXEL (sf) = FACE_TTY_DEFAULT_BG_COLOR;
+  call0 (intern ("tty-set-up-initial-frame-faces"));
+}
+
 /* Initialization done when Emacs fork is started, before doing stty.
    Determine terminal type and set terminal_driver.  Then invoke its
    decoding routine to set up variables in the terminal package.  */
 
-void
-init_display (void)
+static void
+init_display_interactive (void)
 {
   char *terminal_type;
 
@@ -6010,9 +6022,7 @@ init_display (void)
      with.  Otherwise newly opened tty frames will not resize
      automatically. */
 #ifdef SIGWINCH
-#ifndef CANNOT_DUMP
-  if (initialized)
-#endif /* CANNOT_DUMP */
+  if (!will_dump_p ())
     {
       struct sigaction action;
       emacs_sigaction_init (&action, deliver_window_change_signal);
@@ -6022,10 +6032,21 @@ init_display (void)
 
   /* If running as a daemon, no need to initialize any frames/terminal,
      except on Windows, where we at least want to initialize it.  */
-#ifndef WINDOWSNT
   if (IS_DAEMON)
+    {
+      /* Pdump'ed Emacs doesn't record the initial frame from temacs,
+        so the non-basic faces realized for that frame in temacs
+        aren't in emacs.  This causes errors when users try to
+        customize those faces in their init file.  The call to
+        init_faces_initial will realize these faces now.  (Non-daemon
+        Emacs does this either near the end of this function or when
+        the GUI frame is created.)  */
+      if (dumped_with_pdumper_p ())
+        init_faces_initial ();
+#ifndef WINDOWSNT
       return;
 #endif
+    }
 
   /* If the user wants to use a window system, we shouldn't bother
      initializing the terminal.  This is especially important when the
@@ -6076,11 +6097,7 @@ init_display (void)
 #endif /* HAVE_NTGUI */
 
 #ifdef HAVE_NS
-  if (!inhibit_window_system
-#ifndef CANNOT_DUMP
-     && initialized
-#endif
-      )
+  if (!inhibit_window_system && !will_dump_p ())
     {
       Vinitial_window_system = Qns;
       Vwindow_system_version = make_fixnum (10);
@@ -6125,6 +6142,7 @@ init_display (void)
 
     t->reference_count++;
 #ifdef MSDOS
+    f->output_data.tty = &the_only_tty_output;
     f->output_data.tty->display_info = &the_only_display_info;
 #else
     if (f->output_method == output_termcap)
@@ -6168,22 +6186,23 @@ init_display (void)
 
   calculate_costs (XFRAME (selected_frame));
 
-  /* Set up faces of the initial terminal frame of a dumped Emacs.  */
-  if (initialized
-      && !noninteractive
-      && NILP (Vinitial_window_system))
-    {
-      /* For the initial frame, we don't have any way of knowing what
-        are the foreground and background colors of the terminal.  */
-      struct frame *sf = SELECTED_FRAME ();
+  /* Set up faces of the initial terminal frame.  */
+  if (initialized && !noninteractive && NILP (Vinitial_window_system))
+    init_faces_initial ();
+}
 
-      FRAME_FOREGROUND_PIXEL (sf) = FACE_TTY_DEFAULT_FG_COLOR;
-      FRAME_BACKGROUND_PIXEL (sf) = FACE_TTY_DEFAULT_BG_COLOR;
-      call0 (intern ("tty-set-up-initial-frame-faces"));
+void
+init_display (void)
+{
+  if (noninteractive)
+    {
+      if (dumped_with_pdumper_p ())
+        init_faces_initial ();
     }
+  else
+    init_display_interactive ();
 }
 
-
 
 /***********************************************************************
                           Blinking cursor
@@ -6218,6 +6237,8 @@ WINDOW nil or omitted means report on the selected 
window.  */)
                            Initialization
  ***********************************************************************/
 
+static void syms_of_display_for_pdumper (void);
+
 void
 syms_of_display (void)
 {
@@ -6325,11 +6346,12 @@ See `buffer-display-table' for more information.  */);
      beginning of the next redisplay).  */
   redisplay_dont_pause = true;
 
-#ifdef CANNOT_DUMP
-  if (noninteractive)
-#endif
-    {
-      Vinitial_window_system = Qnil;
-      Vwindow_system_version = Qnil;
-    }
+  pdumper_do_now_and_after_load (syms_of_display_for_pdumper);
+}
+
+static void
+syms_of_display_for_pdumper (void)
+{
+  Vinitial_window_system = Qnil;
+  Vwindow_system_version = Qnil;
 }
diff --git a/src/disptab.h b/src/disptab.h
index c8de011..f7a1628 100644
--- a/src/disptab.h
+++ b/src/disptab.h
@@ -1,5 +1,5 @@
 /* Things for GLYPHS and glyph tables.
-   Copyright (C) 1993, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1993, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/dmpstruct.awk b/src/dmpstruct.awk
new file mode 100644
index 0000000..55626cf
--- /dev/null
+++ b/src/dmpstruct.awk
@@ -0,0 +1,45 @@
+# Copyright (C) 2018-2019 Free Software Foundation, Inc.
+#
+# This file is part of GNU Emacs.
+#
+# GNU Emacs is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or (at
+# your option) any later version.
+#
+# GNU Emacs is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+BEGIN {
+  print "/* Generated by dmpstruct.awk */"
+  print "#ifndef EMACS_DMPSTRUCT_H"
+  print "#define EMACS_DMPSTRUCT_H"
+  struct_name = ""
+  tmpfile = "dmpstruct.tmp"
+}
+# Match a type followed by optional syntactic whitespace
+/^(enum|struct|union) [a-zA-Z0-9_]+([\t ]|\/\*.*\*\/)*$/ {
+  struct_name = $2
+  close (tmpfile)
+}
+/^(enum|struct|union) [a-zA-Z0-9_]+([\t ]|\/\*.*\*\/)*$/, /^(  )?};$/ {
+  print $0 > tmpfile
+}
+/^(  )?} *(GCALIGNED_STRUCT)? *;$/ {
+  if (struct_name != "") {
+    fflush (tmpfile)
+    cmd = "../lib-src/make-fingerprint -r " tmpfile
+    cmd | getline hash
+    close (cmd)
+    printf "#define HASH_%s_%.10s\n", struct_name, hash
+    struct_name = ""
+  }
+}
+END {
+  print "#endif /* EMACS_DMPSTRUCT_H */"
+}
diff --git a/src/doc.c b/src/doc.c
index 3437346..3fa0eaa 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -1,6 +1,6 @@
 /* Record indices of function doc strings stored in a file. -*- coding: utf-8 
-*-
 
-Copyright (C) 1985-1986, 1993-1995, 1997-2018 Free Software Foundation,
+Copyright (C) 1985-1986, 1993-1995, 1997-2019 Free Software Foundation,
 Inc.
 
 This file is part of GNU Emacs.
@@ -118,17 +118,15 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool 
definition)
   Lisp_Object docdir
     = NILP (tem) ? ENCODE_FILE (Vdoc_directory) : empty_unibyte_string;
   ptrdiff_t docdir_sizemax = SBYTES (docdir) + 1;
-#ifndef CANNOT_DUMP
-  docdir_sizemax = max (docdir_sizemax, sizeof sibling_etc);
-#endif
+  if (will_dump_p ())
+    docdir_sizemax = max (docdir_sizemax, sizeof sibling_etc);
   name = SAFE_ALLOCA (docdir_sizemax + SBYTES (file));
   lispstpcpy (lispstpcpy (name, docdir), file);
 
   fd = emacs_open (name, O_RDONLY, 0);
   if (fd < 0)
     {
-#ifndef CANNOT_DUMP
-      if (!NILP (Vpurify_flag))
+      if (will_dump_p ())
        {
          /* Preparing to dump; DOC file is probably not installed.
             So check in ../etc.  */
@@ -136,7 +134,6 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool 
definition)
 
          fd = emacs_open (name, O_RDONLY, 0);
        }
-#endif
       if (fd < 0)
        {
          if (errno == EMFILE || errno == ENFILE)
@@ -236,7 +233,7 @@ get_doc_string (Lisp_Object filepos, bool unibyte, bool 
definition)
     }
 
   /* Scan the text and perform quoting with ^A (char code 1).
-     ^A^A becomes ^A, ^A0 becomes a null char, and ^A_ becomes a ^_.  */
+     ^A^A becomes ^A, ^A0 becomes a NUL char, and ^A_ becomes a ^_.  */
   from = get_doc_string_buffer + offset;
   to = get_doc_string_buffer + offset;
   while (from != p)
@@ -340,8 +337,10 @@ string is passed through `substitute-command-keys'.  */)
     fun = XCDR (fun);
   if (SUBRP (fun))
     doc = make_fixnum (XSUBR (fun)->doc);
+#ifdef HAVE_MODULES
   else if (MODULE_FUNCTIONP (fun))
-    doc = XMODULE_FUNCTION (fun)->documentation;
+    doc = module_function_documentation (XMODULE_FUNCTION (fun));
+#endif
   else if (COMPILEDP (fun))
     {
       if (PVSIZE (fun) <= COMPILED_DOC_STRING)
@@ -545,12 +544,7 @@ the same file name is found in the `doc-directory'.  */)
 
   CHECK_STRING (filename);
 
-  if
-#ifndef CANNOT_DUMP
-    (!NILP (Vpurify_flag))
-#else /* CANNOT_DUMP */
-      (0)
-#endif /* CANNOT_DUMP */
+  if (will_dump_p ())
     {
       dirname = sibling_etc;
       dirlen = sizeof sibling_etc - 1;
diff --git a/src/doprnt.c b/src/doprnt.c
index f194b43..5fb7063 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -1,7 +1,7 @@
 /* Output like sprintf to a buffer of specified size.    -*- coding: utf-8 -*-
    Also takes args differently: pass one pointer to the end
    of the format string in addition to the format string itself.
-   Copyright (C) 1985, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1985, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -35,7 +35,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
      sequence.
 
    . It accepts a pointer to the end of the format string, so the format string
-     could include embedded null characters.
+     could include embedded NUL characters.
 
    . It signals an error if the length of the formatted string is about to
      overflow ptrdiff_t or size_t, to avoid producing strings longer than what
@@ -123,7 +123,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
    to fit and return BUFSIZE - 1; if this truncates a multibyte
    sequence, store '\0' into the sequence's first byte.
    Returns the number of bytes stored into BUFFER, excluding
-   the terminating null byte.  Output is always null-terminated.
+   the terminating NUL byte.  Output is always NUL-terminated.
    String arguments are passed as C strings.
    Integers are passed as C integers.  */
 
diff --git a/src/dosfns.c b/src/dosfns.c
index c159b26..47c5450 100644
--- a/src/dosfns.c
+++ b/src/dosfns.c
@@ -1,6 +1,6 @@
 /* MS-DOS specific Lisp utilities.  Coded by Manabu Higashida, 1991.
    Major changes May-July 1993 Morten Welinder (only 10% original code left)
-   Copyright (C) 1991, 1993, 1996-1998, 2001-2018 Free Software
+   Copyright (C) 1991, 1993, 1996-1998, 2001-2019 Free Software
    Foundation, Inc.
 
 This file is part of GNU Emacs.
diff --git a/src/dosfns.h b/src/dosfns.h
index 0e108fd..35b91be 100644
--- a/src/dosfns.h
+++ b/src/dosfns.h
@@ -2,7 +2,7 @@
    Coded by Manabu Higashida, 1991.
    Modified by Morten Welinder, 1993-1994.
 
-Copyright (C) 1991, 1994-1995, 1997, 1999, 2001-2018 Free Software
+Copyright (C) 1991, 1994-1995, 1997, 1999, 2001-2019 Free Software
 Foundation, Inc.
 
 This file is part of GNU Emacs.
diff --git a/src/dynlib.c b/src/dynlib.c
index d40aa67..8c25b75 100644
--- a/src/dynlib.c
+++ b/src/dynlib.c
@@ -1,6 +1,6 @@
 /* Portable API for dynamic loading.
 
-Copyright 2015-2018 Free Software Foundation, Inc.
+Copyright 2015-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -123,7 +123,7 @@ dynlib_sym (dynlib_handle_ptr h, const char *sym)
 }
 
 void
-dynlib_addr (void *addr, const char **fname, const char **symname)
+dynlib_addr (void (*funcptr) (void), const char **fname, const char **symname)
 {
   static char dll_filename[MAX_UTF8_PATH];
   static GetModuleHandleExA_Proc s_pfn_Get_Module_HandleExA = NULL;
@@ -132,6 +132,7 @@ dynlib_addr (void *addr, const char **fname, const char 
**symname)
   HMODULE hm_dll = NULL;
   wchar_t mfn_w[MAX_PATH];
   char mfn_a[MAX_PATH];
+  void *addr = (void *) funcptr;
 
   /* Step 1: Find the handle of the module where ADDR lives.  */
   if (os_subtype == OS_9X
@@ -279,11 +280,12 @@ dynlib_sym (dynlib_handle_ptr h, const char *sym)
 }
 
 void
-dynlib_addr (void *ptr, const char **path, const char **sym)
+dynlib_addr (void (*funcptr) (void), const char **path, const char **sym)
 {
   *path = NULL;
   *sym = NULL;
 #ifdef HAVE_DLADDR
+  void *ptr = (void *) funcptr;
   Dl_info info;
   if (dladdr (ptr, &info) && info.dli_fname && info.dli_sname)
     {
diff --git a/src/dynlib.h b/src/dynlib.h
index eebd2bd..2688712 100644
--- a/src/dynlib.h
+++ b/src/dynlib.h
@@ -1,6 +1,6 @@
 /* Portable API for dynamic loading.
 
-Copyright 2015-2018 Free Software Foundation, Inc.
+Copyright 2015-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -35,6 +35,6 @@ dynlib_function_ptr dynlib_func (dynlib_handle_ptr h, const 
char *sym);
 /* Sets *FILE to the file name from which PTR was loaded, and *SYM to
    its symbol name.  If the file or symbol name could not be
    determined, set the corresponding argument to NULL.  */
-void dynlib_addr (void *ptr, const char **file, const char **sym);
+void dynlib_addr (void (*ptr) (void), const char **file, const char **sym);
 
 #endif /* DYNLIB_H */
diff --git a/src/editfns.c b/src/editfns.c
index 8df4ed1..6fb43af 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1,6 +1,6 @@
 /* Lisp functions pertaining to editing.                 -*- coding: utf-8 -*-
 
-Copyright (C) 1985-1987, 1989, 1993-2018 Free Software Foundation, Inc.
+Copyright (C) 1985-1987, 1989, 1993-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -47,6 +47,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "composite.h"
 #include "intervals.h"
 #include "ptr-bounds.h"
+#include "systime.h"
 #include "character.h"
 #include "buffer.h"
 #include "window.h"
@@ -668,7 +669,7 @@ Field boundaries are not noticed if 
`inhibit-field-text-motion' is non-nil.  */)
     /* It is possible that NEW_POS is not within the same field as
        OLD_POS; try to move NEW_POS so that it is.  */
     {
-      ptrdiff_t shortage;
+      ptrdiff_t counted;
       Lisp_Object field_bound;
 
       if (fwd)
@@ -691,8 +692,8 @@ Field boundaries are not noticed if 
`inhibit-field-text-motion' is non-nil.  */)
                 there's an intervening newline or not.  */
              || (find_newline (XFIXNAT (new_pos), -1,
                                XFIXNAT (field_bound), -1,
-                               fwd ? -1 : 1, &shortage, NULL, 1),
-                 shortage != 0)))
+                               fwd ? -1 : 1, &counted, NULL, 1),
+                 counted == 0)))
        /* Constrain NEW_POS to FIELD_BOUND.  */
        new_pos = field_bound;
 
@@ -1260,7 +1261,7 @@ name, or nil if there is no such user.  */)
   /* Substitute the login name for the &, upcasing the first character.  */
   if (q)
     {
-      Lisp_Object login = Fuser_login_name (make_fixnum (pw->pw_uid));
+      Lisp_Object login = Fuser_login_name (INT_TO_INTEGER (pw->pw_uid));
       USE_SAFE_ALLOCA;
       char *r = SAFE_ALLOCA (strlen (p) + SBYTES (login) + 1);
       memcpy (r, p, q - p);
@@ -1471,7 +1472,8 @@ called interactively, INHERIT is t.  */)
   CHECK_CHARACTER (character);
   if (NILP (count))
     XSETFASTINT (count, 1);
-  CHECK_FIXNUM (count);
+  else
+    CHECK_FIXNUM (count);
   c = XFIXNAT (character);
 
   if (!NILP (BVAR (current_buffer, enable_multibyte_characters)))
@@ -1909,6 +1911,7 @@ determines whether case is significant or ignored.  */)
 
 #undef ELEMENT
 #undef EQUAL
+#define USE_HEURISTIC
 
 /* Counter used to rarely_quit in replace-buffer-contents.  */
 static unsigned short rbc_quitcounter;
@@ -1931,30 +1934,53 @@ static unsigned short rbc_quitcounter;
   /* Bit vectors recording for each character whether it was deleted
      or inserted.  */                           \
   unsigned char *deletions;                     \
-  unsigned char *insertions;
+  unsigned char *insertions;                   \
+  struct timespec time_limit;                  \
+  unsigned int early_abort_tests;
 
 #define NOTE_DELETE(ctx, xoff) set_bit ((ctx)->deletions, (xoff))
 #define NOTE_INSERT(ctx, yoff) set_bit ((ctx)->insertions, (yoff))
+#define EARLY_ABORT(ctx) compareseq_early_abort (ctx)
 
 struct context;
 static void set_bit (unsigned char *, OFFSET);
 static bool bit_is_set (const unsigned char *, OFFSET);
 static bool buffer_chars_equal (struct context *, OFFSET, OFFSET);
+static bool compareseq_early_abort (struct context *);
 
 #include "minmax.h"
 #include "diffseq.h"
 
 DEFUN ("replace-buffer-contents", Freplace_buffer_contents,
-       Sreplace_buffer_contents, 1, 1, "bSource buffer: ",
+       Sreplace_buffer_contents, 1, 3, "bSource buffer: ",
        doc: /* Replace accessible portion of current buffer with that of 
SOURCE.
 SOURCE can be a buffer or a string that names a buffer.
 Interactively, prompt for SOURCE.
+
 As far as possible the replacement is non-destructive, i.e. existing
 buffer contents, markers, properties, and overlays in the current
 buffer stay intact.
-Warning: this function can be slow if there's a large number of small
-differences between the two buffers.  */)
-  (Lisp_Object source)
+
+Because this function can be very slow if there is a large number of
+differences between the two buffers, there are two optional arguments
+mitigating this issue.
+
+The MAX-SECS argument, if given, defines a hard limit on the time used
+for comparing the buffers.  If it takes longer than MAX-SECS, the
+function falls back to a plain `delete-region' and
+`insert-buffer-substring'.  (Note that the checks are not performed
+too evenly over time, so in some cases it may run a bit longer than
+allowed).
+
+The optional argument MAX-COSTS defines the quality of the difference
+computation.  If the actual costs exceed this limit, heuristics are
+used to provide a faster but suboptimal solution.  The default value
+is 1000000.
+
+This function returns t if a non-destructive replacement could be
+performed.  Otherwise, i.e., if MAX-SECS was exceeded, it returns
+nil.  */)
+  (Lisp_Object source, Lisp_Object max_secs, Lisp_Object max_costs)
 {
   struct buffer *a = current_buffer;
   Lisp_Object source_buffer = Fget_buffer (source);
@@ -1979,15 +2005,18 @@ differences between the two buffers.  */)
      empty.  */
 
   if (a_empty && b_empty)
-    return Qnil;
+    return Qt;
 
   if (a_empty)
-    return Finsert_buffer_substring (source, Qnil, Qnil);
+    {
+      Finsert_buffer_substring (source, Qnil, Qnil);
+      return Qt;
+    }
 
   if (b_empty)
     {
       del_range_both (BEGV, BEGV_BYTE, ZV, ZV_BYTE, true);
-      return Qnil;
+      return Qt;
     }
 
   ptrdiff_t count = SPECPDL_INDEX ();
@@ -2001,6 +2030,23 @@ differences between the two buffers.  */)
   ptrdiff_t *buffer;
   USE_SAFE_ALLOCA;
   SAFE_NALLOCA (buffer, 2, diags);
+
+  if (NILP (max_costs))
+    XSETFASTINT (max_costs, 1000000);
+  else
+    CHECK_FIXNUM (max_costs);
+
+  struct timespec time_limit = make_timespec (0, -1);
+  if (!NILP (max_secs))
+    {
+      struct timespec
+       tlim = timespec_add (current_timespec (),
+                            lisp_time_argument (max_secs)),
+       tmax = make_timespec (TYPE_MAXIMUM (time_t), TIMESPEC_HZ - 1);
+      if (timespec_cmp (tlim, tmax) < 0)
+       time_limit = tlim;
+    }
+
   /* Micro-optimization: Casting to size_t generates much better
      code.  */
   ptrdiff_t del_bytes = (size_t) size_a / CHAR_BIT + 1;
@@ -2016,17 +2062,25 @@ differences between the two buffers.  */)
     .insertions = SAFE_ALLOCA (ins_bytes),
     .fdiag = buffer + size_b + 1,
     .bdiag = buffer + diags + size_b + 1,
-    /* FIXME: Find a good number for .too_expensive.  */
-    .too_expensive = 1000000,
+    .heuristic = true,
+    .too_expensive = XFIXNUM (max_costs),
+    .time_limit = time_limit,
+    .early_abort_tests = 0
   };
   memclear (ctx.deletions, del_bytes);
   memclear (ctx.insertions, ins_bytes);
+
   /* compareseq requires indices to be zero-based.  We add BEGV back
      later.  */
   bool early_abort = compareseq (0, size_a, 0, size_b, false, &ctx);
-  /* Since we didn’t define EARLY_ABORT, we should never abort
-     early.  */
-  eassert (! early_abort);
+
+  if (early_abort)
+    {
+      del_range (min_a, ZV);
+      Finsert_buffer_substring (source, Qnil,Qnil);
+      SAFE_FREE_UNBIND_TO (count, Qnil);
+      return Qnil;
+    }
 
   rbc_quitcounter = 0;
 
@@ -2088,6 +2142,7 @@ differences between the two buffers.  */)
       --i;
       --j;
     }
+
   SAFE_FREE_UNBIND_TO (count, Qnil);
   rbc_quitcounter = 0;
 
@@ -2097,7 +2152,7 @@ differences between the two buffers.  */)
       update_compositions (BEGV, ZV, CHECK_INSIDE);
     }
 
-  return Qnil;
+  return Qt;
 }
 
 static void
@@ -2164,6 +2219,14 @@ buffer_chars_equal (struct context *ctx,
     == BUF_FETCH_MULTIBYTE_CHAR (ctx->buffer_b, bpos_b);
 }
 
+static bool
+compareseq_early_abort (struct context *ctx)
+{
+  if (ctx->time_limit.tv_nsec < 0)
+    return false;
+  return timespec_cmp (ctx->time_limit, current_timespec ()) < 0;
+}
+
 
 static void
 subst_char_in_region_unwind (Lisp_Object arg)
@@ -2290,10 +2353,11 @@ Both characters must have the same length of multi-byte 
form.  */)
 
              if (! NILP (noundo))
                {
-                 if (MODIFF - 1 == SAVE_MODIFF)
-                   SAVE_MODIFF++;
-                 if (MODIFF - 1 == BUF_AUTOSAVE_MODIFF (current_buffer))
-                   BUF_AUTOSAVE_MODIFF (current_buffer)++;
+                 modiff_count m = MODIFF;
+                 if (SAVE_MODIFF == m - 1)
+                   SAVE_MODIFF = m;
+                 if (BUF_AUTOSAVE_MODIFF (current_buffer) == m - 1)
+                   BUF_AUTOSAVE_MODIFF (current_buffer) = m;
                }
 
              /* The before-change-function may have moved the gap
@@ -2321,7 +2385,7 @@ Both characters must have the same length of multi-byte 
form.  */)
              /* replace_range is less efficient, because it moves the gap,
                 but it handles combining correctly.  */
              replace_range (pos, pos + 1, string,
-                            0, 0, 1, 0);
+                            false, false, true, false);
              pos_byte_next = CHAR_TO_BYTE (pos);
              if (pos_byte_next > pos_byte)
                /* Before combining happened.  We should not increment
@@ -2432,60 +2496,53 @@ From START to END, translate characters according to 
TABLE.
 TABLE is a string or a char-table; the Nth character in it is the
 mapping for the character with code N.
 It returns the number of characters changed.  */)
-  (Lisp_Object start, Lisp_Object end, register Lisp_Object table)
+  (Lisp_Object start, Lisp_Object end, Lisp_Object table)
 {
-  register unsigned char *tt;  /* Trans table. */
-  register int nc;             /* New character. */
-  int cnt;                     /* Number of changes made. */
-  ptrdiff_t size;              /* Size of translate table. */
-  ptrdiff_t pos, pos_byte, end_pos;
+  int translatable_chars = MAX_CHAR + 1;
   bool multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters));
   bool string_multibyte UNINIT;
 
   validate_region (&start, &end);
-  if (CHAR_TABLE_P (table))
-    {
-      if (! EQ (XCHAR_TABLE (table)->purpose, Qtranslation_table))
-       error ("Not a translation table");
-      size = MAX_CHAR;
-      tt = NULL;
-    }
-  else
+  if (STRINGP (table))
     {
-      CHECK_STRING (table);
-
-      if (! multibyte && (SCHARS (table) < SBYTES (table)))
+      if (! multibyte)
        table = string_make_unibyte (table);
-      string_multibyte = SCHARS (table) < SBYTES (table);
-      size = SBYTES (table);
-      tt = SDATA (table);
+      translatable_chars = min (translatable_chars, SBYTES (table));
+      string_multibyte = STRING_MULTIBYTE (table);
     }
+  else if (! (CHAR_TABLE_P (table)
+             && EQ (XCHAR_TABLE (table)->purpose, Qtranslation_table)))
+    error ("Not a translation table");
 
-  pos = XFIXNUM (start);
-  pos_byte = CHAR_TO_BYTE (pos);
-  end_pos = XFIXNUM (end);
+  ptrdiff_t pos = XFIXNUM (start);
+  ptrdiff_t pos_byte = CHAR_TO_BYTE (pos);
+  ptrdiff_t end_pos = XFIXNUM (end);
   modify_text (pos, end_pos);
 
-  cnt = 0;
-  for (; pos < end_pos; )
+  ptrdiff_t characters_changed = 0;
+
+  while (pos < end_pos)
     {
       unsigned char *p = BYTE_POS_ADDR (pos_byte);
       unsigned char *str UNINIT;
       unsigned char buf[MAX_MULTIBYTE_LENGTH];
-      int len, str_len;
-      int oc;
-      Lisp_Object val;
+      int len, oc;
 
       if (multibyte)
        oc = STRING_CHAR_AND_LENGTH (p, len);
       else
        oc = *p, len = 1;
-      if (oc < size)
+      if (oc < translatable_chars)
        {
-         if (tt)
+         int nc; /* New character.  */
+         int str_len;
+         Lisp_Object val;
+
+         if (STRINGP (table))
            {
              /* Reload as signal_after_change in last iteration may GC.  */
-             tt = SDATA (table);
+             unsigned char *tt = SDATA (table);
+
              if (string_multibyte)
                {
                  str = tt + string_char_to_byte (table, oc);
@@ -2534,7 +2591,8 @@ It returns the number of characters changed.  */)
                  /* This is less efficient, because it moves the gap,
                     but it should handle multibyte characters correctly.  */
                  string = make_multibyte_string ((char *) str, 1, str_len);
-                 replace_range (pos, pos + 1, string, 1, 0, 1, 0);
+                 replace_range (pos, pos + 1, string,
+                                true, false, true, false);
                  len = str_len;
                }
              else
@@ -2545,12 +2603,10 @@ It returns the number of characters changed.  */)
                  signal_after_change (pos, 1, 1);
                  update_compositions (pos, pos + 1, CHECK_BORDER);
                }
-             ++cnt;
+             characters_changed++;
            }
          else if (nc < 0)
            {
-             Lisp_Object string;
-
              if (CONSP (val))
                {
                  val = check_translation (pos, pos_byte, end_pos, val);
@@ -2567,18 +2623,14 @@ It returns the number of characters changed.  */)
              else
                len = 1;
 
-             if (VECTORP (val))
-               {
-                 string = Fconcat (1, &val);
-               }
-             else
-               {
-                 string = Fmake_string (make_fixnum (1), val, Qnil);
-               }
-             replace_range (pos, pos + len, string, 1, 0, 1, 0);
+             Lisp_Object string
+               = (VECTORP (val)
+                  ? Fconcat (1, &val)
+                  : Fmake_string (make_fixnum (1), val, Qnil));
+             replace_range (pos, pos + len, string, true, false, true, false);
              pos_byte += SBYTES (string);
              pos += SCHARS (string);
-             cnt += SCHARS (string);
+             characters_changed += SCHARS (string);
              end_pos += SCHARS (string) - len;
              continue;
            }
@@ -2587,7 +2639,7 @@ It returns the number of characters changed.  */)
       pos++;
     }
 
-  return make_fixnum (cnt);
+  return make_fixnum (characters_changed);
 }
 
 DEFUN ("delete-region", Fdelete_region, Sdelete_region, 2, 2, "r",
@@ -2634,8 +2686,9 @@ but is not deleted; if you save the buffer in a file, the 
invisible
 text is included in the file.  \\[widen] makes all visible again.
 See also `save-restriction'.
 
-When calling from a program, pass two arguments; positions (integers
-or markers) bounding the text that should remain visible.  */)
+When calling from Lisp, pass two arguments START and END:
+positions (integers or markers) bounding the text that should
+remain visible.  */)
   (register Lisp_Object start, Lisp_Object end)
 {
   CHECK_FIXNUM_COERCE_MARKER (start);
@@ -2784,6 +2837,25 @@ usage: (save-restriction &rest BODY)  */)
   return unbind_to (count, val);
 }
 
+/* i18n (internationalization).  */
+
+DEFUN ("ngettext", Fngettext, Sngettext, 3, 3, 0,
+       doc: /* Return the translation of MSGID (plural MSGID_PLURAL) depending 
on N.
+MSGID is the singular form of the string to be converted;
+use it as the key for the search in the translation catalog.
+MSGID_PLURAL is the plural form.  Use N to select the proper translation.
+If no message catalog is found, MSGID is returned if N is equal to 1,
+otherwise MSGID_PLURAL.  */)
+  (Lisp_Object msgid, Lisp_Object msgid_plural, Lisp_Object n)
+{
+  CHECK_STRING (msgid);
+  CHECK_STRING (msgid_plural);
+  CHECK_INTEGER (n);
+
+  /* Placeholder implementation until we get our act together.  */
+  return EQ (n, make_fixnum (1)) ? msgid : msgid_plural;
+}
+
 DEFUN ("message", Fmessage, Smessage, 1, MANY, 0,
        doc: /* Display a message at the bottom of the screen.
 The message also goes into the `*Messages*' buffer, if `message-log-max'
@@ -2937,8 +3009,8 @@ the next available argument, or the argument explicitly 
specified:
 
 %s means print a string argument.  Actually, prints any object, with `princ'.
 %d means print as signed number in decimal.
-%o means print as unsigned number in octal.
-%x means print as unsigned number in hex.
+%o means print a number in octal.
+%x means print a number in hex.
 %X is like %x, but uses upper case.
 %e means print a number in exponential notation.
 %f means print a number in decimal-point notation.
@@ -2949,6 +3021,8 @@ the next available argument, or the argument explicitly 
specified:
 %S means print any object as an s-expression (using `prin1').
 
 The argument used for %d, %o, %x, %e, %f, %g or %c must be a number.
+%o, %x, and %X treat arguments as unsigned if `binary-as-unsigned' is t
+  (this is experimental; email address@hidden if you need it).
 Use %% to put a single % into the output.
 
 A %-sequence other than %% may contain optional field number, flag,
@@ -3032,7 +3106,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool 
message)
                              : FLT_RADIX == 16 ? 4
                              : -1)),
 
-   /* Maximum number of bytes (including terminating null) generated
+   /* Maximum number of bytes (including terminating NUL) generated
       by any format, if precision is no more than USEFUL_PRECISION_MAX.
       On all practical hosts, %Lf is the worst case.  */
    SPRINTF_BUFSIZE = (sizeof "-." + (LDBL_MAX_10_EXP + 1)
@@ -3465,7 +3539,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool 
message)
 
                  bool format_as_long_double = false;
                  double darg;
-                 long double ldarg;
+                 long double ldarg UNINIT;
 
                  if (FLOATP (arg))
                    darg = XFLOAT_DATA (arg);
@@ -4431,17 +4505,13 @@ functions if all the text being accessed has this 
property.  */);
               binary_as_unsigned,
               doc: /* Non-nil means `format' %x and %o treat integers as 
unsigned.
 This has machine-dependent results.  Nil means to treat integers as
-signed, which is portable; for example, if N is a negative integer,
-(read (format "#x%x") N) returns N only when this variable is nil.
+signed, which is portable and is the default; for example, if N is a
+negative integer, (read (format "#x%x" N)) returns N only when this
+variable is nil.
 
 This variable is experimental; email address@hidden if you need
 it to be non-nil.  */);
-  /* For now, default to true if bignums exist, false in traditional Emacs.  */
-#ifdef lisp_h_FIXNUMP
   binary_as_unsigned = false;
-#else
-  binary_as_unsigned = true;
-#endif
 
   defsubr (&Spropertize);
   defsubr (&Schar_equal);
@@ -4504,6 +4574,8 @@ it to be non-nil.  */);
   defsubr (&Sinsert_char);
   defsubr (&Sinsert_byte);
 
+  defsubr (&Sngettext);
+
   defsubr (&Suser_login_name);
   defsubr (&Sgroup_name);
   defsubr (&Suser_real_login_name);
diff --git a/src/emacs-icon.h b/src/emacs-icon.h
index b9bf73f..a8fa3df 100644
--- a/src/emacs-icon.h
+++ b/src/emacs-icon.h
@@ -1,7 +1,7 @@
 /* XPM */
 /* Emacs icon
 
-Copyright (C) 2008-2018 Free Software Foundation, Inc.
+Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 Author: Kentaro Ohkouchi <address@hidden>
         Nicolas Petton <address@hidden>
diff --git a/src/emacs-module.c b/src/emacs-module.c
index 0dcd7f0..80a04ba 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -1,6 +1,6 @@
 /* emacs-module.c - Module loading and runtime implementation
 
-Copyright (C) 2015-2018 Free Software Foundation, Inc.
+Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -17,16 +17,76 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 
+/*
+The public module API is defined in the header emacs-module.h.  The
+configure script generates emacs-module.h from emacs-module.h.in and
+the version-specific environment fragments in module-env-*.h.
+
+If you want to change the module API, please abide to the following
+rules:
+
+- Don't remove publicly documented declarations from the headers.
+
+- Don't remove, reorder, or rename structure fields, as such changes
+  break ABI compatibility.
+
+- Don't change the types of structure fields.
+
+- Likewise, the presence, order, and type of structure fields may not
+  depend on preprocessor macros.
+
+- Add structure fields only at the end of structures.
+
+- For every Emacs major version there is a new fragment file
+  module-env-VER.h.  Add functions solely at the end of the fragment
+  file for the next (not yet released) major version of Emacs.  For
+  example, if the current Emacs release is 26.2, add functions only to
+  emacs-env-27.h.
+
+- emacs-module.h should only depend on standard C headers.  In
+  particular, don't include config.h or lisp.h from emacs-module.h.
+
+- Prefix all names in emacs-module.h with "emacs_" or "EMACS_".
+
+To add a new module function, proceed as follows:
+
+1. Add a new function pointer field at the end of the emacs-env-*.h
+   file for the next major version of Emacs.
+
+2. Run config.status or configure to regenerate emacs-module.h.
+
+3. Create a corresponding implementation function in this file.  See
+   "Implementation of runtime and environment functions" below for
+   further rules.
+
+4. Assign the new field in the initialize_environment function.
+
+5. Add a test function that calls your new function to
+   test/data/emacs-module/mod-test.c.  Add a unit test that invokes
+   your new test function to test/src/emacs-module-tests.el.
+
+6. Document your new function in the manual and in etc/NEWS.
+*/
+
 #include <config.h>
 
+#ifndef HAVE_GMP
+#include "mini-gmp.h"
+#define EMACS_MODULE_HAVE_MPZ_T
+#endif
+
+#define EMACS_MODULE_GMP
 #include "emacs-module.h"
 
 #include <stdarg.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
 
 #include "lisp.h"
+#include "bignum.h"
 #include "dynlib.h"
 #include "coding.h"
 #include "keyboard.h"
@@ -65,18 +125,6 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "w32term.h"
 #endif
 
-/* True if Lisp_Object and emacs_value have the same representation.
-   This is typically true unless WIDE_EMACS_INT.  In practice, having
-   the same sizes and alignments and maximums should be a good enough
-   proxy for equality of representation.  */
-enum
-  {
-    plain_values
-      = (sizeof (Lisp_Object) == sizeof (emacs_value)
-        && alignof (Lisp_Object) == alignof (emacs_value)
-        && INTPTR_MAX == EMACS_INT_MAX)
-  };
-
 /* Function prototype for the module init function.  */
 typedef int (*emacs_init_function) (struct emacs_runtime *);
 
@@ -87,6 +135,43 @@ typedef int (*emacs_init_function) (struct emacs_runtime *);
 typedef void (*emacs_finalizer_function) (void *);
 
 
+/* Memory management.  */
+
+/* An `emacs_value' is just a pointer to a structure holding an
+   internal Lisp object.  */
+struct emacs_value_tag { Lisp_Object v; };
+
+/* Local value objects use a simple fixed-sized block allocation
+   scheme without explicit deallocation.  All local values are
+   deallocated when the lifetime of their environment ends.  Keep
+   track of a current frame from which new values are allocated,
+   appending further dynamically-allocated frames if necessary.  */
+
+enum { value_frame_size = 512 };
+
+/* A block from which `emacs_value' object can be allocated.  */
+struct emacs_value_frame
+{
+  /* Storage for values.  */
+  struct emacs_value_tag objects[value_frame_size];
+
+  /* Index of the next free value in `objects'.  */
+  int offset;
+
+  /* Pointer to next frame, if any.  */
+  struct emacs_value_frame *next;
+};
+
+/* A structure that holds an initial frame (so that the first local
+   values require no dynamic allocation) and keeps track of the
+   current frame.  */
+static struct emacs_value_storage
+{
+  struct emacs_value_frame initial;
+  struct emacs_value_frame *current;
+} global_storage;
+
+
 /* Private runtime and environment members.  */
 
 /* The private part of an environment stores the current non local exit state
@@ -99,12 +184,9 @@ struct emacs_env_private
   /* Dedicated storage for non-local exit symbol and data so that
      storage is always available for them, even in an out-of-memory
      situation.  */
-  Lisp_Object non_local_exit_symbol, non_local_exit_data;
+  struct emacs_value_tag non_local_exit_symbol, non_local_exit_data;
 
-  /* List of values allocated from this environment.  The code uses
-     this only if the user gave the -module-assertions command-line
-     option.  */
-  Lisp_Object values;
+  struct emacs_value_storage storage;
 };
 
 /* The private parts of an `emacs_runtime' object contain the initial
@@ -118,37 +200,33 @@ struct emacs_runtime_private
 /* Forward declarations.  */
 
 static Lisp_Object value_to_lisp (emacs_value);
+static emacs_value allocate_emacs_value (emacs_env *, struct 
emacs_value_storage *, Lisp_Object);
 static emacs_value lisp_to_value (emacs_env *, Lisp_Object);
 static enum emacs_funcall_exit module_non_local_exit_check (emacs_env *);
 static void module_assert_thread (void);
 static void module_assert_runtime (struct emacs_runtime *);
 static void module_assert_env (emacs_env *);
-static _Noreturn void module_abort (const char *format, ...)
-  ATTRIBUTE_FORMAT_PRINTF(1, 2);
+static AVOID module_abort (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
 static emacs_env *initialize_environment (emacs_env *,
                                          struct emacs_env_private *);
 static void finalize_environment (emacs_env *);
 static void finalize_environment_unwind (void *);
 static void finalize_runtime_unwind (void *);
-static void module_handle_signal (emacs_env *, Lisp_Object);
-static void module_handle_throw (emacs_env *, Lisp_Object);
+static void module_handle_nonlocal_exit (emacs_env *, enum nonlocal_exit,
+                                         Lisp_Object);
 static void module_non_local_exit_signal_1 (emacs_env *,
                                            Lisp_Object, Lisp_Object);
 static void module_non_local_exit_throw_1 (emacs_env *,
                                           Lisp_Object, Lisp_Object);
 static void module_out_of_memory (emacs_env *);
 static void module_reset_handlerlist (struct handler **);
-
-/* We used to return NULL when emacs_value was a different type from
-   Lisp_Object, but nowadays we just use Qnil instead.  Although they
-   happen to be the same thing in the current implementation, module
-   code should not assume this.  */
-verify (NIL_IS_ZERO);
-static emacs_value const module_nil = 0;
+static bool value_storage_contains_p (const struct emacs_value_storage *,
+                                      emacs_value, ptrdiff_t *);
+static Lisp_Object module_encode (Lisp_Object);
+static Lisp_Object module_decode (Lisp_Object);
+static Lisp_Object module_decode_copy (Lisp_Object);
 
 static bool module_assertions = false;
-static emacs_env *global_env;
-static struct emacs_env_private global_env_private;
 
 /* Convenience macros for non-local exit handling.  */
 
@@ -160,29 +238,19 @@ static struct emacs_env_private global_env_private;
    not prepared for long jumps (e.g., the behavior in C++ is undefined
    if objects with nontrivial destructors would be skipped).
    Therefore, catch all non-local exits.  There are two kinds of
-   non-local exits: `signal' and `throw'.  The macros in this section
-   can be used to catch both.  Use macros to avoid additional variants
+   non-local exits: `signal' and `throw'.  The macro in this section
+   can be used to catch both.  Use a macro to avoid additional variants
    of `internal_condition_case' etc., and to avoid worrying about
    passing information to the handler functions.  */
 
+#if !__has_attribute (cleanup)
+ #error "__attribute__ ((cleanup)) not supported by this compiler; try GCC"
+#endif
+
 /* Place this macro at the beginning of a function returning a number
    or a pointer to handle non-local exits.  The function must have an
    ENV parameter.  The function will return the specified value if a
    signal or throw is caught.  */
-/* TODO: Have Fsignal check for CATCHER_ALL so we only have to install
-   one handler.  */
-#define MODULE_HANDLE_NONLOCAL_EXIT(retval)                     \
-  MODULE_SETJMP (CONDITION_CASE, module_handle_signal, retval); \
-  MODULE_SETJMP (CATCHER_ALL, module_handle_throw, retval)
-
-#define MODULE_SETJMP(handlertype, handlerfunc, retval)                        
       \
-  MODULE_SETJMP_1 (handlertype, handlerfunc, retval,                          \
-                  internal_handler_##handlertype,                             \
-                  internal_cleanup_##handlertype)
-
-#if !__has_attribute (cleanup)
- #error "__attribute__ ((cleanup)) not supported by this compiler; try GCC"
-#endif
 
 /* It is very important that pushing the handler doesn't itself raise
    a signal.  Install the cleanup only after the handler has been
@@ -192,24 +260,28 @@ static struct emacs_env_private global_env_private;
    The do-while forces uses of the macro to be followed by a semicolon.
    This macro cannot enclose its entire body inside a do-while, as the
    code after the macro may longjmp back into the macro, which means
-   its local variable C must stay live in later code.  */
+   its local variable INTERNAL_CLEANUP must stay live in later code.  */
 
-/* TODO: Make backtraces work if this macros is used.  */
+/* TODO: Make backtraces work if this macro is used.  */
 
-#define MODULE_SETJMP_1(handlertype, handlerfunc, retval, c0, c)       \
+#define MODULE_HANDLE_NONLOCAL_EXIT(retval)                             \
   if (module_non_local_exit_check (env) != emacs_funcall_exit_return)  \
     return retval;                                                     \
-  struct handler *c0 = push_handler_nosignal (Qt, handlertype);                
\
-  if (!c0)                                                             \
+  struct handler *internal_handler =                                    \
+    push_handler_nosignal (Qt, CATCHER_ALL);                            \
+  if (!internal_handler)                                                \
     {                                                                  \
       module_out_of_memory (env);                                      \
       return retval;                                                   \
     }                                                                  \
-  struct handler *c __attribute__ ((cleanup (module_reset_handlerlist))) \
-    = c0;                                                              \
-  if (sys_setjmp (c->jmp))                                             \
+  struct handler *internal_cleanup                                      \
+    __attribute__ ((cleanup (module_reset_handlerlist)))                \
+    = internal_handler;                                                 \
+  if (sys_setjmp (internal_cleanup->jmp))                               \
     {                                                                  \
-      (handlerfunc) (env, c->val);                                     \
+      module_handle_nonlocal_exit (env,                                 \
+                                   internal_cleanup->nonlocal_exit,     \
+                                   internal_cleanup->val);              \
       return retval;                                                   \
     }                                                                  \
   do { } while (false)
@@ -290,10 +362,12 @@ module_get_environment (struct emacs_runtime *ert)
 /* To make global refs (GC-protected global values) keep a hash that
    maps global Lisp objects to reference counts.  */
 
+static Lisp_Object Vmodule_refs_hash;
+
 static emacs_value
 module_make_global_ref (emacs_env *env, emacs_value ref)
 {
-  MODULE_FUNCTION_BEGIN (module_nil);
+  MODULE_FUNCTION_BEGIN (NULL);
   struct Lisp_Hash_Table *h = XHASH_TABLE (Vmodule_refs_hash);
   Lisp_Object new_obj = value_to_lisp (ref);
   EMACS_UINT hashcode;
@@ -313,7 +387,7 @@ module_make_global_ref (emacs_env *env, emacs_value ref)
       hash_put (h, new_obj, make_fixed_natnum (1), hashcode);
     }
 
-  return lisp_to_value (module_assertions ? global_env : env, new_obj);
+  return allocate_emacs_value (env, &global_storage, new_obj);
 }
 
 static void
@@ -341,24 +415,9 @@ module_free_global_ref (emacs_env *env, emacs_value ref)
 
   if (module_assertions)
     {
-      Lisp_Object globals = global_env_private.values;
-      Lisp_Object prev = Qnil;
       ptrdiff_t count = 0;
-      for (Lisp_Object tail = globals; CONSP (tail);
-           tail = XCDR (tail))
-        {
-          emacs_value global = xmint_pointer (XCAR (tail));
-          if (global == ref)
-            {
-              if (NILP (prev))
-                global_env_private.values = XCDR (globals);
-              else
-                XSETCDR (prev, XCDR (tail));
-              return;
-            }
-          ++count;
-          prev = tail;
-        }
+      if (value_storage_contains_p (&global_storage, ref, &count))
+        return;
       module_abort ("Global value was not found in list of %"pD"d globals",
                     count);
     }
@@ -388,9 +447,8 @@ module_non_local_exit_get (emacs_env *env, emacs_value 
*sym, emacs_value *data)
   struct emacs_env_private *p = env->private_members;
   if (p->pending_non_local_exit != emacs_funcall_exit_return)
     {
-      /* FIXME: lisp_to_value can exit non-locally.  */
-      *sym = lisp_to_value (env, p->non_local_exit_symbol);
-      *data = lisp_to_value (env, p->non_local_exit_data);
+      *sym = &p->non_local_exit_symbol;
+      *data = &p->non_local_exit_data;
     }
   return p->pending_non_local_exit;
 }
@@ -416,11 +474,35 @@ module_non_local_exit_throw (emacs_env *env, emacs_value 
tag, emacs_value value)
                                   value_to_lisp (value));
 }
 
+/* Function prototype for the module Lisp functions.  */
+typedef emacs_value (*emacs_subr) (emacs_env *, ptrdiff_t,
+                                  emacs_value [], void *);
+
+/* Module function.  */
+
+/* A function environment is an auxiliary structure returned by
+   `module_make_function' to store information about a module
+   function.  It is stored in a pseudovector.  Its members correspond
+   to the arguments given to `module_make_function'.  */
+
+struct Lisp_Module_Function
+{
+  union vectorlike_header header;
+
+  /* Fields traced by GC; these must come first.  */
+  Lisp_Object documentation;
+
+  /* Fields ignored by GC.  */
+  ptrdiff_t min_arity, max_arity;
+  emacs_subr subr;
+  void *data;
+} GCALIGNED_STRUCT;
+
 static struct Lisp_Module_Function *
 allocate_module_function (void)
 {
   return ALLOCATE_PSEUDOVECTOR (struct Lisp_Module_Function,
-                                min_arity, PVEC_MODULE_FUNCTION);
+                                documentation, PVEC_MODULE_FUNCTION);
 }
 
 #define XSET_MODULE_FUNCTION(var, ptr) \
@@ -434,7 +516,7 @@ module_make_function (emacs_env *env, ptrdiff_t min_arity, 
ptrdiff_t max_arity,
                      emacs_subr subr, const char *documentation,
                      void *data)
 {
-  MODULE_FUNCTION_BEGIN (module_nil);
+  MODULE_FUNCTION_BEGIN (NULL);
 
   if (! (0 <= min_arity
         && (max_arity < 0
@@ -452,8 +534,7 @@ module_make_function (emacs_env *env, ptrdiff_t min_arity, 
ptrdiff_t max_arity,
   if (documentation)
     {
       AUTO_STRING (unibyte_doc, documentation);
-      function->documentation =
-        code_convert_string_norecord (unibyte_doc, Qutf_8, false);
+      function->documentation = module_decode_copy (unibyte_doc);
     }
 
   Lisp_Object result;
@@ -467,7 +548,7 @@ static emacs_value
 module_funcall (emacs_env *env, emacs_value fun, ptrdiff_t nargs,
                emacs_value args[])
 {
-  MODULE_FUNCTION_BEGIN (module_nil);
+  MODULE_FUNCTION_BEGIN (NULL);
 
   /* Make a new Lisp_Object array starting with the function as the
      first arg, because that's what Ffuncall takes.  */
@@ -488,14 +569,14 @@ module_funcall (emacs_env *env, emacs_value fun, 
ptrdiff_t nargs,
 static emacs_value
 module_intern (emacs_env *env, const char *name)
 {
-  MODULE_FUNCTION_BEGIN (module_nil);
+  MODULE_FUNCTION_BEGIN (NULL);
   return lisp_to_value (env, intern (name));
 }
 
 static emacs_value
 module_type_of (emacs_env *env, emacs_value value)
 {
-  MODULE_FUNCTION_BEGIN (module_nil);
+  MODULE_FUNCTION_BEGIN (NULL);
   return lisp_to_value (env, Ftype_of (value_to_lisp (value)));
 }
 
@@ -528,7 +609,7 @@ module_extract_integer (emacs_env *env, emacs_value n)
 static emacs_value
 module_make_integer (emacs_env *env, intmax_t n)
 {
-  MODULE_FUNCTION_BEGIN (module_nil);
+  MODULE_FUNCTION_BEGIN (NULL);
   return lisp_to_value (env, make_int (n));
 }
 
@@ -544,7 +625,7 @@ module_extract_float (emacs_env *env, emacs_value f)
 static emacs_value
 module_make_float (emacs_env *env, double d)
 {
-  MODULE_FUNCTION_BEGIN (module_nil);
+  MODULE_FUNCTION_BEGIN (NULL);
   return lisp_to_value (env, make_float (d));
 }
 
@@ -556,7 +637,7 @@ module_copy_string_contents (emacs_env *env, emacs_value 
value, char *buffer,
   Lisp_Object lisp_str = value_to_lisp (value);
   CHECK_STRING (lisp_str);
 
-  Lisp_Object lisp_str_utf8 = ENCODE_UTF_8 (lisp_str);
+  Lisp_Object lisp_str_utf8 = module_encode (lisp_str);
   ptrdiff_t raw_size = SBYTES (lisp_str_utf8);
   ptrdiff_t required_buf_size = raw_size + 1;
 
@@ -568,8 +649,11 @@ module_copy_string_contents (emacs_env *env, emacs_value 
value, char *buffer,
 
   if (*length < required_buf_size)
     {
+      ptrdiff_t actual = *length;
       *length = required_buf_size;
-      xsignal0 (Qargs_out_of_range);
+      args_out_of_range_3 (INT_TO_INTEGER (actual),
+                           INT_TO_INTEGER (required_buf_size),
+                           INT_TO_INTEGER (PTRDIFF_MAX));
     }
 
   *length = required_buf_size;
@@ -581,20 +665,17 @@ module_copy_string_contents (emacs_env *env, emacs_value 
value, char *buffer,
 static emacs_value
 module_make_string (emacs_env *env, const char *str, ptrdiff_t length)
 {
-  MODULE_FUNCTION_BEGIN (module_nil);
+  MODULE_FUNCTION_BEGIN (NULL);
   if (! (0 <= length && length <= STRING_BYTES_BOUND))
     overflow_error ();
-  /* FIXME: AUTO_STRING_WITH_LEN requires STR to be null-terminated,
-     but we shouldn't require that.  */
-  AUTO_STRING_WITH_LEN (lstr, str, length);
-  return lisp_to_value (env,
-                        code_convert_string_norecord (lstr, Qutf_8, false));
+  Lisp_Object lstr = make_unibyte_string (str, length);
+  return lisp_to_value (env, module_decode (lstr));
 }
 
 static emacs_value
 module_make_user_ptr (emacs_env *env, emacs_finalizer_function fin, void *ptr)
 {
-  MODULE_FUNCTION_BEGIN (module_nil);
+  MODULE_FUNCTION_BEGIN (NULL);
   return lisp_to_value (env, make_user_ptr (fin, ptr));
 }
 
@@ -656,7 +737,7 @@ module_vec_set (emacs_env *env, emacs_value vec, ptrdiff_t 
i, emacs_value val)
 static emacs_value
 module_vec_get (emacs_env *env, emacs_value vec, ptrdiff_t i)
 {
-  MODULE_FUNCTION_BEGIN (module_nil);
+  MODULE_FUNCTION_BEGIN (NULL);
   Lisp_Object lvec = value_to_lisp (vec);
   check_vec_index (lvec, i);
   return lisp_to_value (env, AREF (lvec, i));
@@ -671,13 +752,56 @@ module_vec_size (emacs_env *env, emacs_value vec)
   return ASIZE (lvec);
 }
 
-/* This function should return true if and only if maybe_quit would do
-   anything.  */
+/* This function should return true if and only if maybe_quit would
+   quit.  */
 static bool
 module_should_quit (emacs_env *env)
 {
   MODULE_FUNCTION_BEGIN_NO_CATCH (false);
-  return (! NILP (Vquit_flag) && NILP (Vinhibit_quit)) || pending_signals;
+  return QUITP;
+}
+
+static enum emacs_process_input_result
+module_process_input (emacs_env *env)
+{
+  MODULE_FUNCTION_BEGIN (emacs_process_input_quit);
+  maybe_quit ();
+  return emacs_process_input_continue;
+}
+
+static struct timespec
+module_extract_time (emacs_env *env, emacs_value value)
+{
+  MODULE_FUNCTION_BEGIN ((struct timespec) {0});
+  return lisp_time_argument (value_to_lisp (value));
+}
+
+static emacs_value
+module_make_time (emacs_env *env, struct timespec time)
+{
+  MODULE_FUNCTION_BEGIN (NULL);
+  return lisp_to_value (env, timespec_to_lisp (time));
+}
+
+static void
+module_extract_big_integer (emacs_env *env, emacs_value value,
+                            struct emacs_mpz *result)
+{
+  MODULE_FUNCTION_BEGIN ();
+  Lisp_Object o = value_to_lisp (value);
+  CHECK_INTEGER (o);
+  if (FIXNUMP (o))
+    mpz_set_intmax (result->value, XFIXNUM (o));
+  else
+    mpz_set (result->value, XBIGNUM (o)->value);
+}
+
+static emacs_value
+module_make_big_integer (emacs_env *env, const struct emacs_mpz *value)
+{
+  MODULE_FUNCTION_BEGIN (NULL);
+  mpz_set (mpz[0], value->value);
+  return lisp_to_value (env, make_integer_mpz ());
 }
 
 
@@ -691,14 +815,20 @@ module_signal_or_throw (struct emacs_env_private *env)
     case emacs_funcall_exit_return:
       return;
     case emacs_funcall_exit_signal:
-      xsignal (env->non_local_exit_symbol, env->non_local_exit_data);
+      xsignal (value_to_lisp (&env->non_local_exit_symbol),
+               value_to_lisp (&env->non_local_exit_data));
     case emacs_funcall_exit_throw:
-      Fthrow (env->non_local_exit_symbol, env->non_local_exit_data);
+      Fthrow (value_to_lisp (&env->non_local_exit_symbol),
+              value_to_lisp (&env->non_local_exit_data));
     default:
       eassume (false);
     }
 }
 
+/* Live runtime and environment objects, for assertions.  */
+static Lisp_Object Vmodule_runtimes;
+static Lisp_Object Vmodule_environments;
+
 DEFUN ("module-load", Fmodule_load, Smodule_load, 1, 1, 0,
        doc: /* Load module FILE.  */)
   (Lisp_Object file)
@@ -769,17 +899,12 @@ funcall_module (Lisp_Object function, ptrdiff_t nargs, 
Lisp_Object *arglist)
   record_unwind_protect_ptr (finalize_environment_unwind, env);
 
   USE_SAFE_ALLOCA;
-  ATTRIBUTE_MAY_ALIAS emacs_value *args;
-  if (plain_values && ! module_assertions)
-    /* FIXME: The cast below is incorrect because the argument array
-       is not declared as const, so module functions can modify it.
-       Either declare it as const, or remove this branch.  */
-    args = (emacs_value *) arglist;
-  else
+  emacs_value *args = nargs > 0 ? SAFE_ALLOCA (nargs * sizeof *args) : NULL;
+  for (ptrdiff_t i = 0; i < nargs; ++i)
     {
-      args = SAFE_ALLOCA (nargs * sizeof *args);
-      for (ptrdiff_t i = 0; i < nargs; i++)
-       args[i] = lisp_to_value (env, arglist[i]);
+      args[i] = lisp_to_value (env, arglist[i]);
+      if (! args[i])
+       memory_full (sizeof *args[i]);
     }
 
   emacs_value ret = func->subr (env, nargs, args, func->data);
@@ -803,6 +928,18 @@ module_function_arity (const struct Lisp_Module_Function 
*const function)
                maxargs == MANY ? Qmany : make_fixnum (maxargs));
 }
 
+Lisp_Object
+module_function_documentation (const struct Lisp_Module_Function *function)
+{
+  return function->documentation;
+}
+
+module_funcptr
+module_function_address (const struct Lisp_Module_Function *function)
+{
+  return (module_funcptr) function->subr;
+}
+
 
 /* Helper functions.  */
 
@@ -859,8 +996,8 @@ module_non_local_exit_signal_1 (emacs_env *env, Lisp_Object 
sym,
   if (p->pending_non_local_exit == emacs_funcall_exit_return)
     {
       p->pending_non_local_exit = emacs_funcall_exit_signal;
-      p->non_local_exit_symbol = sym;
-      p->non_local_exit_data = data;
+      p->non_local_exit_symbol.v = sym;
+      p->non_local_exit_data.v = data;
     }
 }
 
@@ -872,8 +1009,8 @@ module_non_local_exit_throw_1 (emacs_env *env, Lisp_Object 
tag,
   if (p->pending_non_local_exit == emacs_funcall_exit_return)
     {
       p->pending_non_local_exit = emacs_funcall_exit_throw;
-      p->non_local_exit_symbol = tag;
-      p->non_local_exit_data = value;
+      p->non_local_exit_symbol.v = tag;
+      p->non_local_exit_data.v = value;
     }
 }
 
@@ -887,58 +1024,30 @@ module_out_of_memory (emacs_env *env)
                                  XCDR (Vmemory_signal_data));
 }
 
-
-/* Value conversion.  */
+static Lisp_Object
+module_encode (Lisp_Object string)
+{
+  return code_convert_string (string, Qutf_8_unix, Qt, true, true, true);
+}
 
-/* We represent Lisp objects differently depending on whether the user
-   gave -module-assertions.  If assertions are disabled, emacs_value
-   objects are Lisp_Objects cast to emacs_value.  If assertions are
-   enabled, emacs_value objects are pointers to Lisp_Object objects
-   allocated from the free store; they are never freed, which ensures
-   that their addresses are unique and can be used for liveness
-   checking.  */
-
-/* Unique Lisp_Object used to mark those emacs_values which are really
-   just containers holding a Lisp_Object that does not fit as an emacs_value,
-   either because it is an integer out of range, or is not properly aligned.
-   Used only if !plain_values.  */
-static Lisp_Object ltv_mark;
-
-/* Convert V to the corresponding internal object O, such that
-   V == lisp_to_value_bits (O).  Never fails.  */
 static Lisp_Object
-value_to_lisp_bits (emacs_value v)
-{
-  if (plain_values || USE_LSB_TAG)
-    return XPL (v);
-
-  /* With wide EMACS_INT and when tag bits are the most significant,
-     reassembling integers differs from reassembling pointers in two
-     ways.  First, save and restore the least-significant bits of the
-     integer, not the most-significant bits.  Second, sign-extend the
-     integer when restoring, but zero-extend pointers because that
-     makes TAG_PTR faster.  */
-
-  intptr_t i = (intptr_t) v;
-  EMACS_UINT tag = i & ((1 << GCTYPEBITS) - 1);
-  EMACS_UINT untagged = i - tag;
-  switch (tag)
-    {
-    case_Lisp_Int:
-      {
-       bool negative = tag & 1;
-       EMACS_UINT sign_extension
-         = negative ? VALMASK & ~(INTPTR_MAX >> INTTYPEBITS): 0;
-       uintptr_t u = i;
-       intptr_t all_but_sign = u >> GCTYPEBITS;
-       untagged = sign_extension + all_but_sign;
-       break;
-      }
-    }
+module_decode (Lisp_Object string)
+{
+  return code_convert_string (string, Qutf_8_unix, Qt, false, true, true);
+}
 
-  return XIL ((tag << VALBITS) + untagged);
+static Lisp_Object
+module_decode_copy (Lisp_Object string)
+{
+  return code_convert_string (string, Qutf_8_unix, Qt, false, false, true);
 }
 
+
+/* Value conversion.  */
+
+/* Convert an `emacs_value' to the corresponding internal object.
+   Never fails.  */
+
 /* If V was computed from lisp_to_value (O), then return O.
    Exits non-locally only if the stack overflows.  */
 static Lisp_Object
@@ -948,91 +1057,118 @@ value_to_lisp (emacs_value v)
     {
       /* Check the liveness of the value by iterating over all live
          environments.  */
-      void *vptr = v;
-      ATTRIBUTE_MAY_ALIAS Lisp_Object *optr = vptr;
       ptrdiff_t num_environments = 0;
       ptrdiff_t num_values = 0;
       for (Lisp_Object environments = Vmodule_environments;
            CONSP (environments); environments = XCDR (environments))
         {
           emacs_env *env = xmint_pointer (XCAR (environments));
-          for (Lisp_Object values = env->private_members->values;
-               CONSP (values); values = XCDR (values))
-            {
-              Lisp_Object *p = xmint_pointer (XCAR (values));
-              if (p == optr)
-                return *p;
-              ++num_values;
-            }
+          struct emacs_env_private *priv = env->private_members;
+          /* The value might be one of the nonlocal exit values.  Note
+             that we don't check whether a nonlocal exit is currently
+             pending, because the module might have cleared the flag
+             in the meantime.  */
+          if (&priv->non_local_exit_symbol == v
+              || &priv->non_local_exit_data == v)
+            goto ok;
+          if (value_storage_contains_p (&priv->storage, v, &num_values))
+            goto ok;
           ++num_environments;
         }
+      /* Also check global values.  */
+      if (value_storage_contains_p (&global_storage, v, &num_values))
+        goto ok;
       module_abort (("Emacs value not found in %"pD"d values "
                     "of %"pD"d environments"),
                     num_values, num_environments);
     }
 
-  Lisp_Object o = value_to_lisp_bits (v);
-  if (! plain_values && CONSP (o) && EQ (XCDR (o), ltv_mark))
-    o = XCAR (o);
-  return o;
+ ok: return v->v;
 }
 
-/* Attempt to convert O to an emacs_value.  Do not do any checking
-   or allocate any storage; the caller should prevent or detect
-   any resulting bit pattern that is not a valid emacs_value.  */
+/* Convert an internal object to an `emacs_value'.  Allocate storage
+   from the environment; return NULL if allocation fails.  */
 static emacs_value
-lisp_to_value_bits (Lisp_Object o)
+lisp_to_value (emacs_env *env, Lisp_Object o)
 {
-  if (plain_values || USE_LSB_TAG)
-    return XLP (o);
+  struct emacs_env_private *p = env->private_members;
+  if (p->pending_non_local_exit != emacs_funcall_exit_return)
+    return NULL;
+  return allocate_emacs_value (env, &p->storage, o);
+}
 
-  /* Compress O into the space of a pointer, possibly losing information.  */
-  EMACS_UINT u = XLI (o);
-  if (FIXNUMP (o))
-    {
-      uintptr_t i = (u << VALBITS) + XTYPE (o);
-      return (emacs_value) i;
-    }
-  else
+/* Must be called for each frame before it can be used for allocation.  */
+static void
+initialize_frame (struct emacs_value_frame *frame)
+{
+  frame->offset = 0;
+  frame->next = NULL;
+}
+
+/* Must be called for any storage object before it can be used for
+   allocation.  */
+static void
+initialize_storage (struct emacs_value_storage *storage)
+{
+  initialize_frame (&storage->initial);
+  storage->current = &storage->initial;
+}
+
+/* Must be called for any initialized storage object before its
+   lifetime ends.  Free all dynamically-allocated frames.  */
+static void
+finalize_storage (struct emacs_value_storage *storage)
+{
+  struct emacs_value_frame *next = storage->initial.next;
+  while (next != NULL)
     {
-      char *p = XLP (o);
-      void *v = p - (u & ~VALMASK) + XTYPE (o);
-      return v;
+      struct emacs_value_frame *current = next;
+      next = current->next;
+      free (current);
     }
 }
 
-/* Convert O to an emacs_value.  Allocate storage if needed; this can
-   signal if memory is exhausted.  Must be an injective function.  */
+/* Allocate a new value from STORAGE and stores OBJ in it.  Return
+   NULL if allocation fails and use ENV for non local exit reporting.  */
 static emacs_value
-lisp_to_value (emacs_env *env, Lisp_Object o)
+allocate_emacs_value (emacs_env *env, struct emacs_value_storage *storage,
+                     Lisp_Object obj)
 {
-  if (module_assertions)
+  eassert (storage->current);
+  eassert (storage->current->offset < value_frame_size);
+  eassert (! storage->current->next);
+  if (storage->current->offset == value_frame_size - 1)
     {
-      /* Add the new value to the list of values allocated from this
-         environment.  The value is actually a pointer to the
-         Lisp_Object cast to emacs_value.  We make a copy of the
-         object on the free store to guarantee unique addresses.  */
-      ATTRIBUTE_MAY_ALIAS Lisp_Object *optr = xmalloc (sizeof o);
-      *optr = o;
-      void *vptr = optr;
-      ATTRIBUTE_MAY_ALIAS emacs_value ret = vptr;
-      struct emacs_env_private *priv = env->private_members;
-      priv->values = Fcons (make_mint_ptr (ret), priv->values);
-      return ret;
+      storage->current->next = malloc (sizeof *storage->current->next);
+      if (! storage->current->next)
+        {
+          module_out_of_memory (env);
+          return NULL;
+        }
+      initialize_frame (storage->current->next);
+      storage->current = storage->current->next;
     }
+  emacs_value value = storage->current->objects + storage->current->offset;
+  value->v = obj;
+  ++storage->current->offset;
+  return value;
+}
 
-  emacs_value v = lisp_to_value_bits (o);
-
-  if (! EQ (o, value_to_lisp_bits (v)))
+/* Mark all objects allocated from local environments so that they
+   don't get garbage-collected.  */
+void
+mark_modules (void)
+{
+  for (Lisp_Object tem = Vmodule_environments; CONSP (tem); tem = XCDR (tem))
     {
-      /* Package the incompressible object pointer inside a pair
-        that is compressible.  */
-      Lisp_Object pair = Fcons (o, ltv_mark);
-      v = (emacs_value) ((intptr_t) XCONS (pair) + Lisp_Cons);
+      emacs_env *env = xmint_pointer (XCAR (tem));
+      struct emacs_env_private *priv = env->private_members;
+      for (struct emacs_value_frame *frame = &priv->storage.initial;
+          frame != NULL;
+          frame = frame->next)
+        for (int i = 0; i < frame->offset; ++i)
+          mark_object (frame->objects[i].v);
     }
-
-  eassert (EQ (o, value_to_lisp (v)));
-  return v;
 }
 
 
@@ -1051,7 +1187,7 @@ initialize_environment (emacs_env *env, struct 
emacs_env_private *priv)
       env = xmalloc (sizeof *env);
 
   priv->pending_non_local_exit = emacs_funcall_exit_return;
-  priv->values = priv->non_local_exit_symbol = priv->non_local_exit_data = 
Qnil;
+  initialize_storage (&priv->storage);
   env->size = sizeof *env;
   env->private_members = priv;
   env->make_global_ref = module_make_global_ref;
@@ -1082,6 +1218,11 @@ initialize_environment (emacs_env *env, struct 
emacs_env_private *priv)
   env->vec_get = module_vec_get;
   env->vec_size = module_vec_size;
   env->should_quit = module_should_quit;
+  env->process_input = module_process_input;
+  env->extract_time = module_extract_time;
+  env->make_time = module_make_time;
+  env->extract_big_integer = module_extract_big_integer;
+  env->make_big_integer = module_make_big_integer;
   Vmodule_environments = Fcons (make_mint_ptr (env), Vmodule_environments);
   return env;
 }
@@ -1091,11 +1232,9 @@ initialize_environment (emacs_env *env, struct 
emacs_env_private *priv)
 static void
 finalize_environment (emacs_env *env)
 {
+  finalize_storage (&env->private_members->storage);
   eassert (xmint_pointer (XCAR (Vmodule_environments)) == env);
   Vmodule_environments = XCDR (Vmodule_environments);
-  if (module_assertions)
-    /* There is always at least the global environment.  */
-    eassert (CONSP (Vmodule_environments));
 }
 
 static void
@@ -1113,20 +1252,6 @@ finalize_runtime_unwind (void *raw_ert)
   finalize_environment (ert->private_members->env);
 }
 
-void
-mark_modules (void)
-{
-  for (Lisp_Object tail = Vmodule_environments; CONSP (tail);
-       tail = XCDR (tail))
-    {
-      emacs_env *env = xmint_pointer (XCAR (tail));
-      struct emacs_env_private *priv = env->private_members;
-      mark_object (priv->non_local_exit_symbol);
-      mark_object (priv->non_local_exit_data);
-      mark_object (priv->values);
-    }
-}
-
 
 /* Non-local exit handling.  */
 
@@ -1142,20 +1267,22 @@ module_reset_handlerlist (struct handler **phandlerlist)
   handlerlist = handlerlist->next;
 }
 
-/* Called on `signal'.  ERR is a pair (SYMBOL . DATA), which gets
-   stored in the environment.  Set the pending non-local exit flag.  */
+/* Called on `signal' and `throw'.  DATA is a pair
+   (ERROR-SYMBOL . ERROR-DATA) or (TAG . VALUE), which gets stored in
+   the environment.  Set the pending non-local exit flag.  */
 static void
-module_handle_signal (emacs_env *env, Lisp_Object err)
+module_handle_nonlocal_exit (emacs_env *env, enum nonlocal_exit type,
+                             Lisp_Object data)
 {
-  module_non_local_exit_signal_1 (env, XCAR (err), XCDR (err));
-}
-
-/* Called on `throw'.  TAG_VAL is a pair (TAG . VALUE), which gets
-   stored in the environment.  Set the pending non-local exit flag.  */
-static void
-module_handle_throw (emacs_env *env, Lisp_Object tag_val)
-{
-  module_non_local_exit_throw_1 (env, XCAR (tag_val), XCDR (tag_val));
+  switch (type)
+    {
+    case NONLOCAL_EXIT_SIGNAL:
+      module_non_local_exit_signal_1 (env, XCAR (data), XCDR (data));
+      break;
+    case NONLOCAL_EXIT_THROW:
+      module_non_local_exit_throw_1 (env, XCAR (data), XCDR (data));
+      break;
+    }
 }
 
 
@@ -1166,12 +1293,30 @@ init_module_assertions (bool enable)
   /* If enabling module assertions, use a hidden environment for
      storing the globals.  This environment is never freed.  */
   module_assertions = enable;
-  if (enable)
-    global_env = initialize_environment (NULL, &global_env_private);
+  initialize_storage (&global_storage);
 }
 
-static _Noreturn void
-ATTRIBUTE_FORMAT_PRINTF(1, 2)
+/* Return whether STORAGE contains VALUE.  Used to check module
+   assertions.  Increment *COUNT by the number of values searched.  */
+
+static bool
+value_storage_contains_p (const struct emacs_value_storage *storage,
+                          emacs_value value, ptrdiff_t *count)
+{
+  for (const struct emacs_value_frame *frame = &storage->initial; frame != 
NULL;
+       frame = frame->next)
+    {
+      for (int i = 0; i < frame->offset; ++i)
+        {
+          if (&frame->objects[i] == value)
+            return true;
+          ++*count;
+        }
+    }
+  return false;
+}
+
+static AVOID ATTRIBUTE_FORMAT_PRINTF (1, 2)
 module_abort (const char *format, ...)
 {
   fputs ("Emacs module assertion: ", stderr);
@@ -1190,81 +1335,55 @@ module_abort (const char *format, ...)
 void
 syms_of_module (void)
 {
-  if (!plain_values)
-    ltv_mark = Fcons (Qnil, Qnil);
-  eassert (NILP (value_to_lisp (module_nil)));
-
-  DEFSYM (Qmodule_refs_hash, "module-refs-hash");
-  DEFVAR_LISP ("module-refs-hash", Vmodule_refs_hash,
-              doc: /* Module global reference table.  */);
-
+  staticpro (&Vmodule_refs_hash);
   Vmodule_refs_hash
     = make_hash_table (hashtest_eq, DEFAULT_HASH_SIZE,
                       DEFAULT_REHASH_SIZE, DEFAULT_REHASH_THRESHOLD,
                       Qnil, false);
-  Funintern (Qmodule_refs_hash, Qnil);
 
-  DEFSYM (Qmodule_runtimes, "module-runtimes");
-  DEFVAR_LISP ("module-runtimes", Vmodule_runtimes,
-               doc: /* List of active module runtimes.  */);
+  staticpro (&Vmodule_runtimes);
   Vmodule_runtimes = Qnil;
-  /* Unintern `module-runtimes' because it is only used
-     internally.  */
-  Funintern (Qmodule_runtimes, Qnil);
 
-  DEFSYM (Qmodule_environments, "module-environments");
-  DEFVAR_LISP ("module-environments", Vmodule_environments,
-               doc: /* List of active module environments.  */);
+  staticpro (&Vmodule_environments);
   Vmodule_environments = Qnil;
-  /* Unintern `module-environments' because it is only used
-     internally.  */
-  Funintern (Qmodule_environments, Qnil);
 
   DEFSYM (Qmodule_load_failed, "module-load-failed");
   Fput (Qmodule_load_failed, Qerror_conditions,
-        listn (CONSTYPE_PURE, 2, Qmodule_load_failed, Qerror));
+       pure_list (Qmodule_load_failed, Qerror));
   Fput (Qmodule_load_failed, Qerror_message,
         build_pure_c_string ("Module load failed"));
 
   DEFSYM (Qmodule_open_failed, "module-open-failed");
   Fput (Qmodule_open_failed, Qerror_conditions,
-        listn (CONSTYPE_PURE, 3,
-               Qmodule_open_failed, Qmodule_load_failed, Qerror));
+       pure_list (Qmodule_open_failed, Qmodule_load_failed, Qerror));
   Fput (Qmodule_open_failed, Qerror_message,
         build_pure_c_string ("Module could not be opened"));
 
   DEFSYM (Qmodule_not_gpl_compatible, "module-not-gpl-compatible");
   Fput (Qmodule_not_gpl_compatible, Qerror_conditions,
-        listn (CONSTYPE_PURE, 3,
-               Qmodule_not_gpl_compatible, Qmodule_load_failed, Qerror));
+       pure_list (Qmodule_not_gpl_compatible, Qmodule_load_failed, Qerror));
   Fput (Qmodule_not_gpl_compatible, Qerror_message,
         build_pure_c_string ("Module is not GPL compatible"));
 
   DEFSYM (Qmissing_module_init_function, "missing-module-init-function");
   Fput (Qmissing_module_init_function, Qerror_conditions,
-        listn (CONSTYPE_PURE, 3,
-               Qmissing_module_init_function, Qmodule_load_failed, Qerror));
+       pure_list (Qmissing_module_init_function, Qmodule_load_failed,
+                  Qerror));
   Fput (Qmissing_module_init_function, Qerror_message,
         build_pure_c_string ("Module does not export an "
                              "initialization function"));
 
   DEFSYM (Qmodule_init_failed, "module-init-failed");
   Fput (Qmodule_init_failed, Qerror_conditions,
-        listn (CONSTYPE_PURE, 3,
-               Qmodule_init_failed, Qmodule_load_failed, Qerror));
+       pure_list (Qmodule_init_failed, Qmodule_load_failed, Qerror));
   Fput (Qmodule_init_failed, Qerror_message,
         build_pure_c_string ("Module initialization failed"));
 
   DEFSYM (Qinvalid_arity, "invalid-arity");
-  Fput (Qinvalid_arity, Qerror_conditions,
-        listn (CONSTYPE_PURE, 2, Qinvalid_arity, Qerror));
+  Fput (Qinvalid_arity, Qerror_conditions, pure_list (Qinvalid_arity, Qerror));
   Fput (Qinvalid_arity, Qerror_message,
         build_pure_c_string ("Invalid function arity"));
 
-  /* Unintern `module-refs-hash' because it is internal-only and Lisp
-     code or modules should not access it.  */
-  Funintern (Qmodule_refs_hash, Qnil);
-
   DEFSYM (Qmodule_function_p, "module-function-p");
 
   defsubr (&Smodule_load);
diff --git a/src/emacs-module.h.in b/src/emacs-module.h.in
index 8e0b42a..fbc62a6 100644
--- a/src/emacs-module.h.in
+++ b/src/emacs-module.h.in
@@ -1,6 +1,6 @@
 /* emacs-module.h - GNU Emacs module API.
 
-Copyright (C) 2015-2018 Free Software Foundation, Inc.
+Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -22,11 +22,16 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #include <stdint.h>
 #include <stddef.h>
+#include <time.h>
 
 #ifndef __cplusplus
 #include <stdbool.h>
 #endif
 
+#if defined EMACS_MODULE_GMP && !defined EMACS_MODULE_HAVE_MPZ_T
+#include <gmp.h>
+#endif
+
 #if defined __cplusplus && __cplusplus >= 201103L
 # define EMACS_NOEXCEPT noexcept
 #else
@@ -47,7 +52,7 @@ extern "C" {
 #endif
 
 /* Current environment.  */
-typedef struct emacs_env_26 emacs_env;
+typedef struct emacs_env_27 emacs_env;
 
 /* Opaque pointer representing an Emacs Lisp value.
    BEWARE: Do not assume NULL is a valid value!  */
@@ -83,6 +88,22 @@ enum emacs_funcall_exit
   emacs_funcall_exit_throw = 2
 };
 
+/* Possible return values for emacs_env.process_input.  */
+enum emacs_process_input_result
+{
+  /* Module code may continue  */
+  emacs_process_input_continue = 0,
+
+  /* Module code should return control to Emacs as soon as possible.  */
+  emacs_process_input_quit = 1
+};
+
+#ifdef EMACS_MODULE_GMP
+struct emacs_mpz { mpz_t value; };
+#else
+struct emacs_mpz;  /* no definition */
+#endif
+
 struct emacs_env_25
 {
 @module_env_snippet_25@
@@ -95,6 +116,15 @@ struct emacs_env_26
 @module_env_snippet_26@
 };
 
+struct emacs_env_27
+{
address@hidden@
+
address@hidden@
+
address@hidden@
+};
+
 /* Every module should define a function as follows.  */
 extern int emacs_module_init (struct emacs_runtime *ert)
   EMACS_NOEXCEPT
diff --git a/src/emacs.c b/src/emacs.c
index eddd729..86d2bc6 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1,6 +1,6 @@
 /* Fully extensible Emacs, running on Unix, intended for GNU.
 
-Copyright (C) 1985-1987, 1993-1995, 1997-1999, 2001-2018 Free Software
+Copyright (C) 1985-1987, 1993-1995, 1997-1999, 2001-2019 Free Software
 Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -118,6 +118,9 @@ extern char etext;
 #include <sys/resource.h>
 #endif
 
+#include "pdumper.h"
+#include "epaths.h"
+
 static const char emacs_version[] = PACKAGE_VERSION;
 static const char emacs_copyright[] = COPYRIGHT;
 static const char emacs_bugreport[] = PACKAGE_BUGREPORT;
@@ -130,19 +133,9 @@ Lisp_Object empty_unibyte_string, empty_multibyte_string;
 Lisp_Object Vlibrary_cache;
 #endif
 
-/* Set after Emacs has started up the first time.
-   Prevents reinitialization of the Lisp world and keymaps
-   on subsequent starts.  */
+struct gflags gflags;
 bool initialized;
 
-#ifndef CANNOT_DUMP
-/* Set to true if this instance of Emacs might dump.  */
-# ifndef DOUG_LEA_MALLOC
-static
-# endif
-bool might_dump;
-#endif
-
 /* If true, Emacs should not attempt to use a window-specific code,
    but instead should use the virtual terminal under which it was started.  */
 bool inhibit_window_system;
@@ -156,7 +149,7 @@ bool running_asynch_code;
 bool display_arg;
 #endif
 
-#if defined GNU_LINUX && !defined CANNOT_DUMP
+#if defined GNU_LINUX && defined HAVE_UNEXEC
 /* The gap between BSS end and heap start as far as we can tell.  */
 static uprintmax_t heap_bss_diff;
 #endif
@@ -164,9 +157,14 @@ static uprintmax_t heap_bss_diff;
 /* To run as a background daemon under Cocoa or Windows,
    we must do a fork+exec, not a simple fork.
 
-   On Cocoa, CoreFoundation lib fails in forked process:
+   On Cocoa, CoreFoundation lib fails in forked process, see Mac OS X
+   Leopard Developer Release Notes for CoreFoundation Framework:
+
    http://developer.apple.com/ReleaseNotes/
-   CoreFoundation/CoreFoundation.html)
+   CoreFoundation/CoreFoundation.html
+
+   Note: the above is no longer available on-line, but it can be found
+   via the "Wayback machine", https://web.archive.org.
 
    On Windows, a Cygwin fork child cannot access the USER subsystem.
 
@@ -238,6 +236,11 @@ Initialization options:\n\
 --module-assertions         assert behavior of dynamic modules\n\
 ",
 #endif
+#ifdef HAVE_PDUMPER
+    "\
+--dump-file FILE            read dumped state from FILE\n\
+",
+#endif
     "\
 --no-build-details          do not add build details such as time stamps\n\
 --no-desktop                do not load a saved desktop\n\
@@ -339,7 +342,7 @@ section of the Emacs manual or the file BUGS.\n"
 bool fatal_error_in_progress;
 
 #ifdef HAVE_NS
-/* NS autrelease pool, for memory management.  */
+/* NS autorelease pool, for memory management.  */
 static void *ns_pool;
 #endif
 
@@ -367,7 +370,7 @@ using_utf8 (void)
 
 /* Report a fatal error due to signal SIG, output a backtrace of at
    most BACKTRACE_LIMIT lines, and exit.  */
-_Noreturn void
+AVOID
 terminate_due_to_signal (int sig, int backtrace_limit)
 {
   signal (sig, SIG_DFL);
@@ -519,8 +522,7 @@ init_cmdargs (int argc, char **argv, int skip_args, char 
const *original_pwd)
              etc_exists = Ffile_exists_p (tem);
              if (!NILP (etc_exists))
                {
-                 Vinstallation_directory
-                   = Ffile_name_as_directory (dir);
+                  Vinstallation_directory = Ffile_name_as_directory (dir);
                  break;
                }
            }
@@ -545,8 +547,7 @@ init_cmdargs (int argc, char **argv, int skip_args, char 
const *original_pwd)
              if (!NILP (etc_exists))
                {
                  tem = Fexpand_file_name (build_string (".."), dir);
-                 Vinstallation_directory
-                   = Ffile_name_as_directory (tem);
+                  Vinstallation_directory = Ffile_name_as_directory (tem);
                  break;
                }
            }
@@ -677,6 +678,160 @@ close_output_streams (void)
     _exit (EXIT_FAILURE);
 }
 
+#ifdef HAVE_PDUMPER
+
+static const char *
+dump_error_to_string (enum pdumper_load_result result)
+{
+  switch (result)
+    {
+    case PDUMPER_LOAD_SUCCESS:
+      return "success";
+    case PDUMPER_LOAD_OOM:
+      return "out of memory";
+    case PDUMPER_NOT_LOADED:
+      return "not loaded";
+    case PDUMPER_LOAD_FILE_NOT_FOUND:
+      return "could not open file";
+    case PDUMPER_LOAD_BAD_FILE_TYPE:
+      return "not a dump file";
+    case PDUMPER_LOAD_FAILED_DUMP:
+      return "dump file is result of failed dump attempt";
+    case PDUMPER_LOAD_VERSION_MISMATCH:
+      return "not built for this Emacs executable";
+    default:
+      return "generic error";
+    }
+}
+
+static enum pdumper_load_result
+load_pdump (int argc, char **argv)
+{
+  const char *const suffix = ".pdmp";
+  enum pdumper_load_result result;
+#ifdef WINDOWSNT
+  size_t argv0_len;
+#endif
+
+  /* TODO: maybe more thoroughly scrub process environment in order to
+     make this use case (loading a pdumper image in an unexeced emacs)
+     possible?  Right now, we assume that things we don't touch are
+     zero-initialized, and in an unexeced Emacs, this assumption
+     doesn't hold.  */
+  if (initialized)
+    fatal ("cannot load pdumper image in unexeced Emacs");
+
+  /* Look for an explicitly-specified dump file.  */
+  const char *path_exec = PATH_EXEC;
+  char *dump_file = NULL;
+  int skip_args = 0;
+  while (skip_args < argc - 1)
+    {
+      if (argmatch (argv, argc, "-dump-file", "--dump-file", 6,
+                   &dump_file, &skip_args)
+         || argmatch (argv, argc, "--", NULL, 2, NULL, &skip_args))
+       break;
+      skip_args++;
+    }
+
+  result = PDUMPER_NOT_LOADED;
+  if (dump_file)
+    {
+      result = pdumper_load (dump_file);
+
+      if (result != PDUMPER_LOAD_SUCCESS)
+        fatal ("could not load dump file \"%s\": %s",
+               dump_file, dump_error_to_string (result));
+      else
+        goto out;
+    }
+
+  /* Look for a dump file in the same directory as the executable; it
+     should have the same basename.  */
+
+  dump_file = alloca (strlen (argv[0]) + strlen (suffix) + 1);
+#ifdef DOS_NT
+  /* Remove the .exe extension if present.  */
+  argv0_len = strlen (argv[0]);
+  if (argv0_len >= 4 && c_strcasecmp (argv[0] + argv0_len - 4, ".exe") == 0)
+    sprintf (dump_file, "%.*s%s", (int)(argv0_len - 4), argv[0], suffix);
+  else
+#endif
+  sprintf (dump_file, "%s%s", argv[0], suffix);
+
+  result = pdumper_load (dump_file);
+  if (result == PDUMPER_LOAD_SUCCESS)
+    goto out;
+
+  if (result != PDUMPER_LOAD_FILE_NOT_FOUND)
+    fatal ("could not load dump file \"%s\": %s",
+           dump_file, dump_error_to_string (result));
+
+#ifdef WINDOWSNT
+  /* On MS-Windows, PATH_EXEC normally starts with a literal
+     "%emacs_dir%", so it will never work without some tweaking.  */
+  path_exec = w32_relocate (path_exec);
+#endif
+
+  /* Look for "emacs.pdmp" in PATH_EXEC.  We hardcode "emacs" in
+     "emacs.pdmp" so that the Emacs binary still works if the user
+     copies and renames it.  */
+  const char *argv0_base = "emacs";
+  dump_file = alloca (strlen (path_exec)
+                      + 1
+                      + strlen (argv0_base)
+                      + strlen (suffix)
+                      + 1);
+  sprintf (dump_file, "%s%c%s%s",
+           path_exec, DIRECTORY_SEP, argv0_base, suffix);
+  result = pdumper_load (dump_file);
+  if (result == PDUMPER_LOAD_SUCCESS)
+    goto out;
+
+  if (result == PDUMPER_LOAD_FILE_NOT_FOUND)
+    {
+      /* Finally, look for basename(argv[0])+".pdmp" in PATH_EXEC.
+        This way, they can rename both the executable and its pdump
+        file in PATH_EXEC, and have several Emacs configurations in
+        the same versioned libexec subdirectory.  */
+      char *p, *last_sep = NULL;
+      for (p = argv[0]; *p; p++)
+       {
+         if (IS_DIRECTORY_SEP (*p))
+           last_sep = p;
+       }
+      argv0_base = last_sep ? last_sep + 1 : argv[0];
+      dump_file = alloca (strlen (path_exec)
+                         + 1
+                         + strlen (argv0_base)
+                         + strlen (suffix)
+                         + 1);
+#ifdef DOS_NT
+      argv0_len = strlen (argv0_base);
+      if (argv0_len >= 4
+         && c_strcasecmp (argv0_base + argv0_len - 4, ".exe") == 0)
+       sprintf (dump_file, "%s%c%.*s%s", path_exec, DIRECTORY_SEP,
+                (int)(argv0_len - 4), argv0_base, suffix);
+      else
+#endif
+      sprintf (dump_file, "%s%c%s%s",
+              path_exec, DIRECTORY_SEP, argv0_base, suffix);
+      result = pdumper_load (dump_file);
+    }
+
+  if (result != PDUMPER_LOAD_SUCCESS)
+    {
+      if (result != PDUMPER_LOAD_FILE_NOT_FOUND)
+       fatal ("could not load dump file \"%s\": %s",
+              dump_file, dump_error_to_string (result));
+      dump_file = NULL;
+    }
+
+ out:
+  return result;
+}
+#endif /* HAVE_PDUMPER */
+
 /* ARGSUSED */
 int
 main (int argc, char **argv)
@@ -686,8 +841,6 @@ main (int argc, char **argv)
   void *stack_bottom_variable;
 
   bool do_initial_setlocale;
-  bool dumping;
-  int skip_args = 0;
   bool no_loadup = false;
   char *junk = 0;
   char *dname_arg = 0;
@@ -702,30 +855,94 @@ main (int argc, char **argv)
   /* Record (approximately) where the stack begins.  */
   stack_bottom = (char *) &stack_bottom_variable;
 
-#ifndef CANNOT_DUMP
-  dumping = !initialized && (strcmp (argv[argc - 1], "dump") == 0
-                            || strcmp (argv[argc - 1], "bootstrap") == 0);
-#else
-  dumping = false;
+  const char *dump_mode = NULL;
+  int skip_args = 0;
+  char *temacs = NULL;
+  while (skip_args < argc - 1)
+    {
+      if (argmatch (argv, argc, "-temacs", "--temacs", 8, &temacs, &skip_args)
+         || argmatch (argv, argc, "--", NULL, 2, NULL, &skip_args))
+       break;
+      skip_args++;
+    }
+#ifdef HAVE_PDUMPER
+  bool attempt_load_pdump = false;
 #endif
 
-  argc = maybe_disable_address_randomization (dumping, argc, argv);
+  /* Look for this argument first, before any heap allocation, so we
+     can set heap flags properly if we're going to unexec.  */
+  if (!initialized && temacs)
+    {
+#ifdef HAVE_UNEXEC
+      if (strcmp (temacs, "dump") == 0 ||
+          strcmp (temacs, "bootstrap") == 0)
+        gflags.will_dump_with_unexec_ = true;
+#endif
+#ifdef HAVE_PDUMPER
+      if (strcmp (temacs, "pdump") == 0 ||
+          strcmp (temacs, "pbootstrap") == 0)
+        gflags.will_dump_with_pdumper_ = true;
+#endif
+#if defined HAVE_PDUMPER || defined HAVE_UNEXEC
+      if (strcmp (temacs, "bootstrap") == 0 ||
+          strcmp (temacs, "pbootstrap") == 0)
+        gflags.will_bootstrap_ = true;
+      gflags.will_dump_ =
+        will_dump_with_pdumper_p () ||
+        will_dump_with_unexec_p ();
+      if (will_dump_p ())
+        dump_mode = temacs;
+#endif
+      if (!dump_mode)
+        fatal ("Invalid temacs mode '%s'", temacs);
+    }
+  else if (temacs)
+    {
+      fatal ("--temacs not supported for unexeced emacs");
+    }
+  else
+    {
+      eassert (!temacs);
+#ifndef HAVE_UNEXEC
+      eassert (!initialized);
+#endif
+#ifdef HAVE_PDUMPER
+      if (!initialized)
+       attempt_load_pdump = true;
+#endif
+    }
 
-#ifndef CANNOT_DUMP
-  might_dump = !initialized;
+#ifdef HAVE_UNEXEC
+  if (!will_dump_with_unexec_p ())
+    gflags.will_not_unexec_ = true;
+#endif
 
-# ifdef GNU_LINUX
-  if (!initialized)
+#ifdef WINDOWSNT
+  /* Grab our malloc arena space now, before anything important
+     happens.  This relies on the static heap being needed only in
+     temacs and only if we are going to dump with unexec.  */
+  bool use_dynamic_heap = true;
+  if (temacs)
     {
-      char *heap_start = my_heap_start ();
-      heap_bss_diff = heap_start - max (my_endbss, my_endbss_static);
+      char *temacs_str = NULL, *p;
+      for (p = argv[0]; (p = strstr (p, "temacs")) != NULL; p++)
+       temacs_str = p;
+      if (temacs_str != NULL
+         && (temacs_str == argv[0] || IS_DIRECTORY_SEP (temacs_str[-1])))
+       {
+         /* Note that gflags are set at this point only if we have been
+            called with the --temacs=METHOD option.  We assume here that
+            temacs is always called that way, otherwise the functions
+            that rely on gflags, like will_dump_with_pdumper_p below,
+            will not do their job.  */
+         use_dynamic_heap = will_dump_with_pdumper_p ();
+       }
     }
-# endif
+  init_heap (use_dynamic_heap);
 #endif
-
 #if defined WINDOWSNT || defined HAVE_NTGUI
   /* Set global variables used to detect Windows version.  Do this as
-     early as possible.  (unexw32.c calls this function as well, but
+     early as possible.  (w32proc.c calls this function as well, but
      the additional call here is harmless.) */
   cache_system_info ();
 #ifdef WINDOWSNT
@@ -742,13 +959,29 @@ main (int argc, char **argv)
   w32_init_main_thread ();
 #endif
 
+#ifdef HAVE_PDUMPER
+  if (attempt_load_pdump)
+    load_pdump (argc, argv);
+#endif
+
+  argc = maybe_disable_address_randomization (
+    will_dump_with_unexec_p (), argc, argv);
+
+#if defined GNU_LINUX && defined HAVE_UNEXEC
+  if (!initialized)
+    {
+      char *heap_start = my_heap_start ();
+      heap_bss_diff = heap_start - max (my_endbss, my_endbss_static);
+    }
+#endif
+
 #ifdef RUN_TIME_REMAP
   if (initialized)
     run_time_remap (argv[0]);
 #endif
 
 /* If using unexmacosx.c (set by s/darwin.h), we must do this. */
-#if defined DARWIN_OS && !defined CANNOT_DUMP
+#if defined DARWIN_OS && defined HAVE_UNEXEC
   if (!initialized)
     unexec_init_emacs_zone ();
 #endif
@@ -760,6 +993,7 @@ main (int argc, char **argv)
   argc = 0;
   while (argv[argc]) argc++;
 
+  skip_args = 0;
   if (argmatch (argv, argc, "-version", "--version", 3, NULL, &skip_args))
     {
       const char *version, *copyright;
@@ -800,6 +1034,10 @@ main (int argc, char **argv)
     }
 
   emacs_wd = emacs_get_current_dir_name ();
+#ifdef HAVE_PDUMPER
+  if (dumped_with_pdumper_p ())
+    pdumper_record_wd (emacs_wd);
+#endif
 
   if (argmatch (argv, argc, "-chdir", "--chdir", 4, &ch_to_dir, &skip_args))
     {
@@ -850,10 +1088,7 @@ main (int argc, char **argv)
          frames.  */
       int extra = (30 * 1000) * 50;
 
-      bool try_to_grow_stack = true;
-#ifndef CANNOT_DUMP
-      try_to_grow_stack = !noninteractive || initialized;
-#endif
+      bool try_to_grow_stack = !noninteractive || initialized;
 
       if (try_to_grow_stack)
        {
@@ -1184,17 +1419,15 @@ Using an Emacs configured with --with-x-toolkit=lucid 
does not have this problem
 
 #if defined HAVE_PTHREAD && !defined SYSTEM_MALLOC \
   && !defined DOUG_LEA_MALLOC && !defined HYBRID_MALLOC
-# ifndef CANNOT_DUMP
   /* Do not make gmalloc thread-safe when creating bootstrap-emacs, as
      that causes an infinite recursive loop with FreeBSD.  See
      Bug#14569.  The part of this bug involving Cygwin is no longer
      relevant, now that Cygwin defines HYBRID_MALLOC.  */
-  if (!noninteractive || initialized)
-# endif
+  if (!noninteractive || !will_dump_p ())
     malloc_enable_thread ();
 #endif
 
-  init_signals (dumping);
+  init_signals ();
 
   noninteractive1 = noninteractive;
 
@@ -1203,8 +1436,7 @@ Using an Emacs configured with --with-x-toolkit=lucid 
does not have this problem
   if (!initialized)
     {
       init_alloc_once ();
-      init_threads_once ();
-      init_obarray ();
+      init_obarray_once ();
       init_eval_once ();
       init_charset_once ();
       init_coding_once ();
@@ -1226,7 +1458,7 @@ Using an Emacs configured with --with-x-toolkit=lucid 
does not have this problem
       /* Call syms_of_keyboard before init_window_once because
         keyboard sets up symbols that include some face names that
         the X support will want to use.  This can happen when
-        CANNOT_DUMP is defined.  */
+        Emacs starts up from scratch (e.g., temacs).  */
       syms_of_keyboard ();
 
       /* Called before syms_of_fileio, because it sets up Qerror_condition.  */
@@ -1242,7 +1474,7 @@ Using an Emacs configured with --with-x-toolkit=lucid 
does not have this problem
       /* Before init_window_once, because it sets up the
         Vcoding_system_hash_table.  */
       syms_of_coding ();       /* This should be after syms_of_fileio.  */
-
+      init_frame_once ();       /* Before init_window_once.  */
       init_window_once ();     /* Init the window system.  */
 #ifdef HAVE_WINDOW_SYSTEM
       init_fringe_once ();     /* Swap bitmaps if necessary.  */
@@ -1265,6 +1497,11 @@ Using an Emacs configured with --with-x-toolkit=lucid 
does not have this problem
   running_asynch_code = 0;
   init_random ();
 
+#ifdef HAVE_PDUMPER
+  if (dumped_with_pdumper_p ())
+    init_xfaces ();
+#endif
+
 #if defined HAVE_JSON && !defined WINDOWSNT
   init_json ();
 #endif
@@ -1282,7 +1519,7 @@ Using an Emacs configured with --with-x-toolkit=lucid 
does not have this problem
   bool module_assertions
     = argmatch (argv, argc, "-module-assertions", "--module-assertions", 15,
                 NULL, &skip_args);
-  if (dumping && module_assertions)
+  if (will_dump_p () && module_assertions)
     {
       fputs ("Module assertions are not supported during dumping\n", stderr);
       exit (1);
@@ -1419,7 +1656,7 @@ Using an Emacs configured with --with-x-toolkit=lucid 
does not have this problem
   /* egetenv is a pretty low-level facility, which may get called in
      many circumstances; it seems flimsy to put off initializing it
      until calling init_callproc.  Do not do it when dumping.  */
-  if (! dumping)
+  if (!will_dump_p ())
     set_initial_environment ();
 
 #ifdef WINDOWSNT
@@ -1433,7 +1670,7 @@ Using an Emacs configured with --with-x-toolkit=lucid 
does not have this problem
      variables from the parent process without modifications from
      Emacs.  */
   init_environment (argv);
-  init_ntproc (dumping); /* must precede init_editfns.  */
+  init_ntproc (will_dump_p ()); /* must precede init_editfns.  */
 #endif
 
   /* AIX crashes are reported in system versions 3.2.3 and 3.2.4
@@ -1445,7 +1682,7 @@ Using an Emacs configured with --with-x-toolkit=lucid 
does not have this problem
 #endif
 
   /* Init buffer storage and default directory of main buffer.  */
-  init_buffer (initialized);
+  init_buffer ();
 
   init_callproc_1 ();  /* Must precede init_cmdargs and init_sys_modes.  */
 
@@ -1620,6 +1857,7 @@ Using an Emacs configured with --with-x-toolkit=lucid 
does not have this problem
 
       syms_of_threads ();
       syms_of_profiler ();
+      syms_of_pdumper ();
 
 #ifdef HAVE_JSON
       syms_of_json ();
@@ -1650,7 +1888,7 @@ Using an Emacs configured with --with-x-toolkit=lucid 
does not have this problem
   init_charset ();
 
   /* This calls putenv and so must precede init_process_emacs.  */
-  init_timefns (dumping);
+  init_timefns ();
 
   /* This sets Voperating_system_release, which init_process_emacs uses.  */
   init_editfns ();
@@ -1669,10 +1907,9 @@ Using an Emacs configured with --with-x-toolkit=lucid 
does not have this problem
   init_process_emacs (sockfd);
 
   init_keyboard ();    /* This too must precede init_sys_modes.  */
-  if (!noninteractive)
-    init_display ();   /* Determine terminal type.  Calls init_sys_modes.  */
+  init_display ();     /* Determine terminal type.  Calls init_sys_modes.  */
 #if HAVE_W32NOTIFY
-  else
+  if (noninteractive)
     init_crit ();      /* w32notify.c needs this in batch mode.  */
 #endif /* HAVE_W32NOTIFY */
   init_xdisp ();
@@ -1716,7 +1953,10 @@ Using an Emacs configured with --with-x-toolkit=lucid 
does not have this problem
     moncontrol (0);
 #endif
 
-  initialized = 1;
+  initialized = true;
+
+  if (dump_mode)
+    Vdump_mode = build_string (dump_mode);
 
   /* Enter editor command loop.  This never returns.  */
   Frecursive_edit ();
@@ -1806,6 +2046,12 @@ static const struct standard_args standard_args[] =
   { "-color", "--color", 5, 0},
   { "-no-splash", "--no-splash", 3, 0 },
   { "-no-desktop", "--no-desktop", 3, 0 },
+  /* The following two must be just above the file-name args, to get
+     them out of our way, but without mixing them with file names.  */
+  { "-temacs", "--temacs", 1, 1 },
+#ifdef HAVE_PDUMPER
+  { "-dump-file", "--dump-file", 1, 1 },
+#endif
 #ifdef HAVE_NS
   { "-NSAutoLaunch", 0, 5, 1 },
   { "-NXAutoLaunch", 0, 5, 1 },
@@ -2145,7 +2391,7 @@ shut_down_emacs (int sig, Lisp_Object stuff)
 
 
 
-#ifndef CANNOT_DUMP
+#ifdef HAVE_UNEXEC
 
 #include "unexec.h"
 
@@ -2166,13 +2412,16 @@ You must run Emacs in batch mode in order to dump it.  
*/)
   if (! noninteractive)
     error ("Dumping Emacs works only in batch mode");
 
-  if (!might_dump)
-    error ("Emacs can be dumped only once");
+  if (dumped_with_unexec_p ())
+    error ("Emacs can be dumped using unexec only once");
+
+  if (definitely_will_not_unexec_p ())
+    error ("This Emacs instance was not started in temacs mode");
 
-#if defined GNU_LINUX && !defined CANNOT_DUMP
+# if defined GNU_LINUX && defined HAVE_UNEXEC
 
   /* Warn if the gap between BSS end and heap start is larger than this.  */
-# define MAX_HEAP_BSS_DIFF (1024*1024)
+#  define MAX_HEAP_BSS_DIFF (1024 * 1024)
 
   if (heap_bss_diff > MAX_HEAP_BSS_DIFF)
     {
@@ -2185,7 +2434,7 @@ You must run Emacs in batch mode in order to dump it.  */)
       fprintf (stderr, "exec-shield in etc/PROBLEMS for more information.\n");
       fprintf (stderr, "**************************************************\n");
     }
-#endif /* GNU_LINUX */
+# endif
 
   /* Bind `command-line-processed' to nil before dumping,
      so that the dumped Emacs will process its command line
@@ -2209,7 +2458,7 @@ You must run Emacs in batch mode in order to dump it.  */)
   tem = Vpurify_flag;
   Vpurify_flag = Qnil;
 
-#ifdef HYBRID_MALLOC
+# ifdef HYBRID_MALLOC
   {
     static char const fmt[] = "%d of %d static heap bytes used";
     char buf[sizeof fmt + 2 * (INT_STRLEN_BOUND (int) - 2)];
@@ -2218,18 +2467,21 @@ You must run Emacs in batch mode in order to dump it.  
*/)
     /* Don't log messages, because at this point buffers cannot be created.  */
     message1_nolog (buf);
   }
-#endif
+# endif
 
   fflush_unlocked (stdout);
   /* Tell malloc where start of impure now is.  */
   /* Also arrange for warnings when nearly out of space.  */
-#if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC
-#ifndef WINDOWSNT
+# if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC && !defined WINDOWSNT
   /* On Windows, this was done before dumping, and that once suffices.
      Meanwhile, my_edata is not valid on Windows.  */
   memory_warnings (my_edata, malloc_warning);
-#endif /* not WINDOWSNT */
-#endif /* not SYSTEM_MALLOC and not HYBRID_MALLOC */
+# endif
+
+  struct gflags old_gflags = gflags;
+  gflags.will_dump_ = false;
+  gflags.will_dump_with_unexec_ = false;
+  gflags.dumped_with_unexec_ = true;
 
   alloc_unexec_pre ();
 
@@ -2237,19 +2489,22 @@ You must run Emacs in batch mode in order to dump it.  
*/)
 
   alloc_unexec_post ();
 
-#ifdef WINDOWSNT
+  gflags = old_gflags;
+
+# ifdef WINDOWSNT
   Vlibrary_cache = Qnil;
-#endif
-#ifdef HAVE_WINDOW_SYSTEM
+# endif
+# ifdef HAVE_WINDOW_SYSTEM
   reset_image_types ();
-#endif
+# endif
 
   Vpurify_flag = tem;
 
   return unbind_to (count, Qnil);
 }
 
-#endif /* not CANNOT_DUMP */
+#endif
+
 
 #if HAVE_SETLOCALE
 /* Recover from setlocale (LC_ALL, "").  */
@@ -2388,7 +2643,7 @@ decode_env_path (const char *evarname, const char 
*defalt, bool empty)
              }
          }
        else if (cnv_result != 0 && d > path_utf8)
-         d[-1] = '\0'; /* remove last semi-colon and null-terminate PATH */
+         d[-1] = '\0'; /* remove last semi-colon and NUL-terminate PATH */
       } while (q);
       path_copy = path_utf8;
 #else  /* MSDOS */
@@ -2537,7 +2792,7 @@ syms_of_emacs (void)
   DEFSYM (Qkill_emacs, "kill-emacs");
   DEFSYM (Qkill_emacs_hook, "kill-emacs-hook");
 
-#ifndef CANNOT_DUMP
+#ifdef HAVE_UNEXEC
   defsubr (&Sdump_emacs);
 #endif
 
@@ -2585,7 +2840,7 @@ Don't rely on it for testing whether a feature you want 
to use is available.  */
   Vsystem_configuration_features = build_string (EMACS_CONFIG_FEATURES);
 
   DEFVAR_BOOL ("noninteractive", noninteractive1,
-              doc: /* Non-nil means Emacs is running without interactive 
terminal.  */);
+               doc: /* Non-nil means Emacs is running without interactive 
terminal.  */);
 
   DEFVAR_LISP ("kill-emacs-hook", Vkill_emacs_hook,
               doc: /* Hook run when `kill-emacs' is called.
@@ -2670,6 +2925,9 @@ component .BUILD is present.  This is now stored 
separately in
               doc: /* Address of mailing list for GNU Emacs bugs.  */);
   Vreport_emacs_bug_address = build_string (emacs_bugreport);
 
+  DEFVAR_LISP ("dump-mode", Vdump_mode,
+               doc: /* Non-nil when Emacs is dumping itself.  */);
+
   DEFVAR_LISP ("dynamic-library-alist", Vdynamic_library_alist,
     doc: /* Alist of dynamic libraries vs external files implementing them.
 Each element is a list (LIBRARY FILE...), where the car is a symbol
diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c
index e404729..6b2b4f7 100644
--- a/src/emacsgtkfixed.c
+++ b/src/emacsgtkfixed.c
@@ -1,7 +1,7 @@
 /* A Gtk Widget that inherits GtkFixed, but can be shrunk.
 This file is only use when compiling with Gtk+ 3.
 
-Copyright (C) 2011-2018 Free Software Foundation, Inc.
+Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/emacsgtkfixed.h b/src/emacsgtkfixed.h
index 738a3fc..2f01328 100644
--- a/src/emacsgtkfixed.h
+++ b/src/emacsgtkfixed.h
@@ -1,7 +1,7 @@
 /* A Gtk Widget that inherits GtkFixed, but can be shrunk.
 This file is only use when compiling with Gtk+ 3.
 
-Copyright (C) 2011-2018 Free Software Foundation, Inc.
+Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/epaths.in b/src/epaths.in
index 4a91acd..5fe35b6 100644
--- a/src/epaths.in
+++ b/src/epaths.in
@@ -1,6 +1,6 @@
 /* Hey Emacs, this is -*- C -*- code!  */
 /*
-Copyright (C) 1993, 1995, 1997, 1999, 2001-2018 Free Software
+Copyright (C) 1993, 1995, 1997, 1999, 2001-2019 Free Software
 Foundation, Inc.
 
 This file is part of GNU Emacs.
diff --git a/src/eval.c b/src/eval.c
index a51d0c9..3fd9a40 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1,6 +1,6 @@
 /* Evaluator for GNU Emacs Lisp interpreter.
 
-Copyright (C) 1985-1987, 1993-1995, 1999-2018 Free Software Foundation,
+Copyright (C) 1985-1987, 1993-1995, 1999-2019 Free Software Foundation,
 Inc.
 
 This file is part of GNU Emacs.
@@ -29,6 +29,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "keyboard.h"
 #include "dispextern.h"
 #include "buffer.h"
+#include "pdumper.h"
 
 /* CACHEABLE is ordinarily nothing, except it is 'volatile' if
    necessary to cajole GCC into not warning incorrectly that a
@@ -39,10 +40,6 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 # define CACHEABLE /* empty */
 #endif
 
-/* Chain of condition and catch handlers currently in effect.  */
-
-/* struct handler *handlerlist; */
-
 /* Non-nil means record all fset's and provide's, to be undone
    if the file being autoloaded is not fully loaded.
    They are recorded by being consed onto the front of Vautoload_queue:
@@ -55,44 +52,11 @@ Lisp_Object Vautoload_queue;
    is shutting down.  */
 Lisp_Object Vrun_hooks;
 
-/* The commented-out variables below are macros defined in thread.h.  */
-
-/* Current number of specbindings allocated in specpdl, not counting
-   the dummy entry specpdl[-1].  */
-
-/* ptrdiff_t specpdl_size; */
-
-/* Pointer to beginning of specpdl.  A dummy entry specpdl[-1] exists
-   only so that its address can be taken.  */
-
-/* union specbinding *specpdl; */
-
-/* Pointer to first unused element in specpdl.  */
-
-/* union specbinding *specpdl_ptr; */
-
-/* Depth in Lisp evaluations and function calls.  */
-
-/* static EMACS_INT lisp_eval_depth; */
-
-/* The value of num_nonmacro_input_events as of the last time we
-   started to enter the debugger.  If we decide to enter the debugger
-   again when this is still equal to num_nonmacro_input_events, then we
-   know that the debugger itself has an error, and we should just
-   signal the error instead of entering an infinite loop of debugger
-   invocations.  */
-
-static EMACS_INT when_entered_debugger;
-
 /* The function from which the last `signal' was called.  Set in
    Fsignal.  */
 /* FIXME: We should probably get rid of this!  */
 Lisp_Object Vsignaling_function;
 
-/* If non-nil, Lisp code must not be run since some part of Emacs is in
-   an inconsistent state.  Currently unused.  */
-Lisp_Object inhibit_lisp_code;
-
 /* These would ordinarily be static, but they need to be visible to GDB.  */
 bool backtrace_p (union specbinding *) EXTERNALLY_VISIBLE;
 Lisp_Object *backtrace_args (union specbinding *) EXTERNALLY_VISIBLE;
@@ -202,7 +166,7 @@ set_backtrace_debug_on_exit (union specbinding *pdl, bool 
doe)
 
 bool
 backtrace_p (union specbinding *pdl)
-{ return pdl >= specpdl; }
+{ return specpdl ? pdl >= specpdl : false; }
 
 static bool
 backtrace_thread_p (struct thread_state *tstate, union specbinding *pdl)
@@ -211,6 +175,12 @@ backtrace_thread_p (struct thread_state *tstate, union 
specbinding *pdl)
 union specbinding *
 backtrace_top (void)
 {
+  /* This is so "xbacktrace" doesn't crash in pdumped Emacs if they
+     invoke the command before init_eval_once_for_pdumper initializes
+     specpdl machinery.  See also backtrace_p above.  */
+  if (!specpdl)
+    return NULL;
+
   union specbinding *pdl = specpdl_ptr - 1;
   while (backtrace_p (pdl) && pdl->kind != SPECPDL_BACKTRACE)
     pdl--;
@@ -235,6 +205,8 @@ backtrace_next (union specbinding *pdl)
   return pdl;
 }
 
+static void init_eval_once_for_pdumper (void);
+
 static union specbinding *
 backtrace_thread_next (struct thread_state *tstate, union specbinding *pdl)
 {
@@ -247,18 +219,21 @@ backtrace_thread_next (struct thread_state *tstate, union 
specbinding *pdl)
 void
 init_eval_once (void)
 {
-  enum { size = 50 };
-  union specbinding *pdlvec = xmalloc ((size + 1) * sizeof *specpdl);
-  specpdl_size = size;
-  specpdl = specpdl_ptr = pdlvec + 1;
   /* Don't forget to update docs (lispref node "Local Variables").  */
   max_specpdl_size = 1300; /* 1000 is not enough for CEDET's c-by.el.  */
   max_lisp_eval_depth = 800;
-
   Vrun_hooks = Qnil;
+  pdumper_do_now_and_after_load (init_eval_once_for_pdumper);
 }
 
-/* static struct handler handlerlist_sentinel; */
+static void
+init_eval_once_for_pdumper (void)
+{
+  enum { size = 50 };
+  union specbinding *pdlvec = malloc ((size + 1) * sizeof *specpdl);
+  specpdl_size = size;
+  specpdl = specpdl_ptr = pdlvec + 1;
+}
 
 void
 init_eval (void)
@@ -281,13 +256,23 @@ init_eval (void)
   when_entered_debugger = -1;
 }
 
+/* Ensure that *M is at least A + B if possible, or is its maximum
+   value otherwise.  */
+
+static void
+max_ensure_room (intmax_t *m, intmax_t a, intmax_t b)
+{
+  intmax_t sum = INT_ADD_WRAPV (a, b, &sum) ? INTMAX_MAX : sum;
+  *m = max (*m, sum);
+}
+
 /* Unwind-protect function used by call_debugger.  */
 
 static void
 restore_stack_limits (Lisp_Object data)
 {
-  max_specpdl_size = XFIXNUM (XCAR (data));
-  max_lisp_eval_depth = XFIXNUM (XCDR (data));
+  integer_to_intmax (XCAR (data), &max_specpdl_size);
+  integer_to_intmax (XCDR (data), &max_lisp_eval_depth);
 }
 
 static void grow_specpdl (void);
@@ -300,21 +285,19 @@ call_debugger (Lisp_Object arg)
   bool debug_while_redisplaying;
   ptrdiff_t count = SPECPDL_INDEX ();
   Lisp_Object val;
-  EMACS_INT old_depth = max_lisp_eval_depth;
+  intmax_t old_depth = max_lisp_eval_depth;
   /* Do not allow max_specpdl_size less than actual depth (Bug#16603).  */
-  EMACS_INT old_max = max (max_specpdl_size, count);
+  intmax_t old_max = max (max_specpdl_size, count);
 
   /* The previous value of 40 is too small now that the debugger
      prints using cl-prin1 instead of prin1.  Printing lists nested 8
      deep (which is the value of print-level used in the debugger)
      currently requires 77 additional frames.  See bug#31919.  */
-  if (lisp_eval_depth + 100 > max_lisp_eval_depth)
-    max_lisp_eval_depth = lisp_eval_depth + 100;
+  max_ensure_room (&max_lisp_eval_depth, lisp_eval_depth, 100);
 
   /* While debugging Bug#16603, previous value of 100 was found
      too small to avoid specpdl overflow in the debugger itself.  */
-  if (max_specpdl_size - 200 < count)
-    max_specpdl_size = count + 200;
+  max_ensure_room (&max_specpdl_size, count, 200);
 
   if (old_max == count)
     {
@@ -325,8 +308,7 @@ call_debugger (Lisp_Object arg)
 
   /* Restore limits after leaving the debugger.  */
   record_unwind_protect (restore_stack_limits,
-                        Fcons (make_fixnum (old_max),
-                               make_fixnum (old_depth)));
+                        Fcons (make_int (old_max), make_int (old_depth)));
 
 #ifdef HAVE_WINDOW_SYSTEM
   if (display_hourglass_p)
@@ -504,17 +486,6 @@ usage: (prog1 FIRST BODY...)  */)
   return val;
 }
 
-DEFUN ("prog2", Fprog2, Sprog2, 2, UNEVALLED, 0,
-       doc: /* Eval FORM1, FORM2 and BODY sequentially; return value from 
FORM2.
-The value of FORM2 is saved during the evaluation of the
-remaining args, whose values are discarded.
-usage: (prog2 FORM1 FORM2 BODY...)  */)
-  (Lisp_Object args)
-{
-  eval_sub (XCAR (args));
-  return Fprog1 (XCDR (args));
-}
-
 DEFUN ("setq", Fsetq, Ssetq, 0, UNEVALLED, 0,
        doc: /* Set each SYM to the value of its VAL.
 The symbols SYM are variables; they are literal (not evaluated).
@@ -530,7 +501,7 @@ usage: (setq [SYM VAL]...)  */)
 
   for (EMACS_INT nargs = 0; CONSP (tail); nargs += 2)
     {
-      Lisp_Object sym = XCAR (tail), lex_binding;
+      Lisp_Object sym = XCAR (tail);
       tail = XCDR (tail);
       if (!CONSP (tail))
        xsignal2 (Qwrong_number_of_arguments, Qsetq, make_fixnum (nargs + 1));
@@ -539,10 +510,12 @@ usage: (setq [SYM VAL]...)  */)
       val = eval_sub (arg);
       /* Like for eval_sub, we do not check declared_special here since
         it's been done when let-binding.  */
-      if (!NILP (Vinternal_interpreter_environment) /* Mere optimization!  */
-         && SYMBOLP (sym)
-         && !NILP (lex_binding
-                   = Fassq (sym, Vinternal_interpreter_environment)))
+      Lisp_Object lex_binding
+       = ((!NILP (Vinternal_interpreter_environment) /* Mere optimization!  */
+           && SYMBOLP (sym))
+          ? Fassq (sym, Vinternal_interpreter_environment)
+          : Qnil);
+      if (!NILP (lex_binding))
        XSETCDR (lex_binding, val); /* SYM is lexically bound.  */
       else
        Fset (sym, val);        /* SYM is dynamically bound.  */
@@ -951,16 +924,15 @@ usage: (let VARLIST BODY...)  */)
   (Lisp_Object args)
 {
   Lisp_Object *temps, tem, lexenv;
-  Lisp_Object elt, varlist;
+  Lisp_Object elt;
   ptrdiff_t count = SPECPDL_INDEX ();
   ptrdiff_t argnum;
   USE_SAFE_ALLOCA;
 
-  varlist = XCAR (args);
-  CHECK_LIST (varlist);
+  Lisp_Object varlist = XCAR (args);
 
   /* Make space to hold the values to give the bound variables.  */
-  EMACS_INT varlist_len = XFIXNAT (Flength (varlist));
+  EMACS_INT varlist_len = list_length (varlist);
   SAFE_ALLOCA_LISP (temps, varlist_len);
   ptrdiff_t nvars = varlist_len;
 
@@ -1163,14 +1135,16 @@ internal_catch (Lisp_Object tag,
 
    This is used for correct unwinding in Fthrow and Fsignal.  */
 
-static _Noreturn void
-unwind_to_catch (struct handler *catch, Lisp_Object value)
+static AVOID
+unwind_to_catch (struct handler *catch, enum nonlocal_exit type,
+                 Lisp_Object value)
 {
   bool last_time;
 
   eassert (catch->next);
 
   /* Save the value in the tag.  */
+  catch->nonlocal_exit = type;
   catch->val = value;
 
   /* Restore certain special C variables.  */
@@ -1207,9 +1181,9 @@ Both TAG and VALUE are evalled.  */
     for (c = handlerlist; c; c = c->next)
       {
        if (c->type == CATCHER_ALL)
-          unwind_to_catch (c, Fcons (tag, value));
-       if (c->type == CATCHER && EQ (c->tag_or_ch, tag))
-         unwind_to_catch (c, value);
+          unwind_to_catch (c, NONLOCAL_EXIT_THROW, Fcons (tag, value));
+        if (c->type == CATCHER && EQ (c->tag_or_ch, tag))
+         unwind_to_catch (c, NONLOCAL_EXIT_THROW, value);
       }
   xsignal2 (Qno_catch, tag, value);
 }
@@ -1457,28 +1431,7 @@ internal_condition_case_n (Lisp_Object (*bfun) 
(ptrdiff_t, Lisp_Object *),
     }
 }
 
-static Lisp_Object
-internal_catch_all_1 (Lisp_Object (*function) (void *), void *argument)
-{
-  struct handler *c = push_handler_nosignal (Qt, CATCHER_ALL);
-  if (c == NULL)
-    return Qcatch_all_memory_full;
-
-  if (sys_setjmp (c->jmp) == 0)
-    {
-      Lisp_Object val = function (argument);
-      eassert (handlerlist == c);
-      handlerlist = c->next;
-      return val;
-    }
-  else
-    {
-      eassert (handlerlist == c);
-      Lisp_Object val = c->val;
-      handlerlist = c->next;
-      Fsignal (Qno_catch, val);
-    }
-}
+static Lisp_Object Qcatch_all_memory_full;
 
 /* Like a combination of internal_condition_case_1 and internal_catch.
    Catches all signals and throws.  Never exits nonlocally; returns
@@ -1486,15 +1439,15 @@ internal_catch_all_1 (Lisp_Object (*function) (void *), 
void *argument)
 
 Lisp_Object
 internal_catch_all (Lisp_Object (*function) (void *), void *argument,
-                    Lisp_Object (*handler) (Lisp_Object))
+                    Lisp_Object (*handler) (enum nonlocal_exit, Lisp_Object))
 {
-  struct handler *c = push_handler_nosignal (Qt, CONDITION_CASE);
+  struct handler *c = push_handler_nosignal (Qt, CATCHER_ALL);
   if (c == NULL)
     return Qcatch_all_memory_full;
 
   if (sys_setjmp (c->jmp) == 0)
     {
-      Lisp_Object val = internal_catch_all_1 (function, argument);
+      Lisp_Object val = function (argument);
       eassert (handlerlist == c);
       handlerlist = c->next;
       return val;
@@ -1502,9 +1455,10 @@ internal_catch_all (Lisp_Object (*function) (void *), 
void *argument,
   else
     {
       eassert (handlerlist == c);
+      enum nonlocal_exit type = c->nonlocal_exit;
       Lisp_Object val = c->val;
       handlerlist = c->next;
-      return handler (val);
+      return handler (type, val);
     }
 }
 
@@ -1572,10 +1526,7 @@ process_quit_flag (void)
    If quit-flag is set to `kill-emacs' the SIGINT handler has received
    a request to exit Emacs when it is safe to do.
 
-   When not quitting, process any pending signals.
-
-   If you change this function, also adapt module_should_quit in
-   emacs-module.c.  */
+   When not quitting, process any pending signals.  */
 
 void
 maybe_quit (void)
@@ -1654,11 +1605,8 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object 
data, bool keyboard_quit)
       && specpdl_ptr < specpdl + specpdl_size)
     {
       /* Edebug takes care of restoring these variables when it exits.  */
-      if (lisp_eval_depth + 20 > max_lisp_eval_depth)
-       max_lisp_eval_depth = lisp_eval_depth + 20;
-
-      if (SPECPDL_INDEX () + 40 > max_specpdl_size)
-       max_specpdl_size = SPECPDL_INDEX () + 40;
+      max_ensure_room (&max_lisp_eval_depth, lisp_eval_depth, 20);
+      max_ensure_room (&max_specpdl_size, SPECPDL_INDEX (), 40);
 
       call2 (Vsignal_hook_function, error_symbol, data);
     }
@@ -1681,6 +1629,11 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object 
data, bool keyboard_quit)
 
   for (h = handlerlist; h; h = h->next)
     {
+      if (h->type == CATCHER_ALL)
+        {
+          clause = Qt;
+          break;
+        }
       if (h->type != CONDITION_CASE)
        continue;
       clause = find_handler_clause (h->tag_or_ch, conditions);
@@ -1714,7 +1667,7 @@ signal_or_quit (Lisp_Object error_symbol, Lisp_Object 
data, bool keyboard_quit)
       Lisp_Object unwind_data
        = (NILP (error_symbol) ? data : Fcons (error_symbol, data));
 
-      unwind_to_catch (h, unwind_data);
+      unwind_to_catch (h, NONLOCAL_EXIT_SIGNAL, unwind_data);
     }
   else
     {
@@ -1862,7 +1815,8 @@ maybe_call_debugger (Lisp_Object conditions, Lisp_Object 
sig, Lisp_Object data)
          ? debug_on_quit
          : wants_debugger (Vdebug_on_error, conditions))
       && ! skip_debugger (conditions, combined_data)
-      /* RMS: What's this for?  */
+      /* See commentary on definition of
+         `internal-when-entered-debugger'.  */
       && when_entered_debugger < num_nonmacro_input_events)
     {
       call_debugger (list2 (Qerror, combined_data));
@@ -2085,7 +2039,7 @@ it defines a macro.  */)
 
   /* This is to make sure that loadup.el gives a clear picture
      of what files are preloaded and when.  */
-  if (! NILP (Vpurify_flag))
+  if (will_dump_p () && !will_bootstrap_p ())
     error ("Attempt to autoload %s while preparing to dump",
           SDATA (SYMBOL_NAME (funname)));
 
@@ -2201,27 +2155,16 @@ record_in_backtrace (Lisp_Object function, Lisp_Object 
*args, ptrdiff_t nargs)
 Lisp_Object
 eval_sub (Lisp_Object form)
 {
-  Lisp_Object fun, val, original_fun, original_args;
-  Lisp_Object funcar;
-  ptrdiff_t count;
-
-  /* Declare here, as this array may be accessed by call_debugger near
-     the end of this function.  See Bug#21245.  */
-  Lisp_Object argvals[8];
-
   if (SYMBOLP (form))
     {
       /* Look up its binding in the lexical environment.
         We do not pay attention to the declared_special flag here, since we
         already did that when let-binding the variable.  */
       Lisp_Object lex_binding
-       = !NILP (Vinternal_interpreter_environment) /* Mere optimization!  */
-       ? Fassq (form, Vinternal_interpreter_environment)
-       : Qnil;
-      if (CONSP (lex_binding))
-       return XCDR (lex_binding);
-      else
-       return Fsymbol_value (form);
+       = (!NILP (Vinternal_interpreter_environment) /* Mere optimization!  */
+          ? Fassq (form, Vinternal_interpreter_environment)
+          : Qnil);
+      return !NILP (lex_binding) ? XCDR (lex_binding) : Fsymbol_value (form);
     }
 
   if (!CONSP (form))
@@ -2239,38 +2182,41 @@ eval_sub (Lisp_Object form)
        error ("Lisp nesting exceeds `max-lisp-eval-depth'");
     }
 
-  original_fun = XCAR (form);
-  original_args = XCDR (form);
+  Lisp_Object original_fun = XCAR (form);
+  Lisp_Object original_args = XCDR (form);
   CHECK_LIST (original_args);
 
   /* This also protects them from gc.  */
-  count = record_in_backtrace (original_fun, &original_args, UNEVALLED);
+  ptrdiff_t count
+    = record_in_backtrace (original_fun, &original_args, UNEVALLED);
 
   if (debug_on_next_call)
     do_debug_on_call (Qt, count);
 
-  /* At this point, only original_fun and original_args
-     have values that will be used below.  */
+  Lisp_Object fun, val, funcar;
+  /* Declare here, as this array may be accessed by call_debugger near
+     the end of this function.  See Bug#21245.  */
+  Lisp_Object argvals[8];
+
  retry:
 
   /* Optimize for no indirection.  */
   fun = original_fun;
   if (!SYMBOLP (fun))
-    fun = Ffunction (Fcons (fun, Qnil));
+    fun = Ffunction (list1 (fun));
   else if (!NILP (fun) && (fun = XSYMBOL (fun)->u.s.function, SYMBOLP (fun)))
     fun = indirect_function (fun);
 
   if (SUBRP (fun))
     {
       Lisp_Object args_left = original_args;
-      Lisp_Object numargs = Flength (args_left);
+      ptrdiff_t numargs = list_length (args_left);
 
-      check_cons_list ();
-
-      if (XFIXNUM (numargs) < XSUBR (fun)->min_args
+      if (numargs < XSUBR (fun)->min_args
          || (XSUBR (fun)->max_args >= 0
-             && XSUBR (fun)->max_args < XFIXNUM (numargs)))
-       xsignal2 (Qwrong_number_of_arguments, original_fun, numargs);
+             && XSUBR (fun)->max_args < numargs))
+       xsignal2 (Qwrong_number_of_arguments, original_fun,
+                 make_fixnum (numargs));
 
       else if (XSUBR (fun)->max_args == UNEVALLED)
        val = (XSUBR (fun)->function.aUNEVALLED) (args_left);
@@ -2281,9 +2227,9 @@ eval_sub (Lisp_Object form)
          ptrdiff_t argnum = 0;
          USE_SAFE_ALLOCA;
 
-         SAFE_ALLOCA_LISP (vals, XFIXNUM (numargs));
+         SAFE_ALLOCA_LISP (vals, numargs);
 
-         while (CONSP (args_left) && argnum < XFIXNUM (numargs))
+         while (CONSP (args_left) && argnum < numargs)
            {
              Lisp_Object arg = XCAR (args_left);
              args_left = XCDR (args_left);
@@ -2294,7 +2240,6 @@ eval_sub (Lisp_Object form)
 
          val = XSUBR (fun)->function.aMANY (argnum, vals);
 
-         check_cons_list ();
          lisp_eval_depth--;
          /* Do the debug-on-exit now, while VALS still exists.  */
          if (backtrace_debug_on_exit (specpdl + count))
@@ -2313,7 +2258,7 @@ eval_sub (Lisp_Object form)
              args_left = Fcdr (args_left);
            }
 
-         set_backtrace_args (specpdl + count, argvals, XFIXNUM (numargs));
+         set_backtrace_args (specpdl + count, argvals, numargs);
 
          switch (i)
            {
@@ -2400,7 +2345,6 @@ eval_sub (Lisp_Object form)
       else
        xsignal1 (Qinvalid_function, original_fun);
     }
-  check_cons_list ();
 
   lisp_eval_depth--;
   if (backtrace_debug_on_exit (specpdl + count))
@@ -2417,16 +2361,13 @@ Thus, (apply \\='+ 1 2 \\='(3 4)) returns 10.
 usage: (apply FUNCTION &rest ARGUMENTS)  */)
   (ptrdiff_t nargs, Lisp_Object *args)
 {
-  ptrdiff_t i, numargs, funcall_nargs;
-  register Lisp_Object *funcall_args = NULL;
-  register Lisp_Object spread_arg = args[nargs - 1];
+  ptrdiff_t i, funcall_nargs;
+  Lisp_Object *funcall_args = NULL;
+  Lisp_Object spread_arg = args[nargs - 1];
   Lisp_Object fun = args[0];
-  Lisp_Object retval;
   USE_SAFE_ALLOCA;
 
-  CHECK_LIST (spread_arg);
-
-  numargs = XFIXNUM (Flength (spread_arg));
+  ptrdiff_t numargs = list_length (spread_arg);
 
   if (numargs == 0)
     return Ffuncall (nargs - 1, args);
@@ -2476,7 +2417,7 @@ usage: (apply FUNCTION &rest ARGUMENTS)  */)
       spread_arg = XCDR (spread_arg);
     }
 
-  retval = Ffuncall (funcall_nargs, funcall_args);
+  Lisp_Object retval = Ffuncall (funcall_nargs, funcall_args);
 
   SAFE_FREE ();
   return retval;
@@ -2843,8 +2784,6 @@ usage: (funcall FUNCTION &rest ARGUMENTS)  */)
   if (debug_on_next_call)
     do_debug_on_call (Qlambda, count);
 
-  check_cons_list ();
-
   original_fun = args[0];
 
  retry:
@@ -2874,13 +2813,11 @@ usage: (funcall FUNCTION &rest ARGUMENTS)  */)
       else if (EQ (funcar, Qautoload))
        {
          Fautoload_do_load (fun, original_fun, Qnil);
-         check_cons_list ();
          goto retry;
        }
       else
        xsignal1 (Qinvalid_function, original_fun);
     }
-  check_cons_list ();
   lisp_eval_depth--;
   if (backtrace_debug_on_exit (specpdl + count))
     val = call_debugger (list2 (Qexit, val));
@@ -2974,28 +2911,24 @@ funcall_subr (struct Lisp_Subr *subr, ptrdiff_t 
numargs, Lisp_Object *args)
 static Lisp_Object
 apply_lambda (Lisp_Object fun, Lisp_Object args, ptrdiff_t count)
 {
-  Lisp_Object args_left;
-  ptrdiff_t i;
-  EMACS_INT numargs;
   Lisp_Object *arg_vector;
   Lisp_Object tem;
   USE_SAFE_ALLOCA;
 
-  numargs = XFIXNAT (Flength (args));
+  ptrdiff_t numargs = list_length (args);
   SAFE_ALLOCA_LISP (arg_vector, numargs);
-  args_left = args;
+  Lisp_Object args_left = args;
 
-  for (i = 0; i < numargs; )
+  for (ptrdiff_t i = 0; i < numargs; i++)
     {
       tem = Fcar (args_left), args_left = Fcdr (args_left);
       tem = eval_sub (tem);
-      arg_vector[i++] = tem;
+      arg_vector[i] = tem;
     }
 
-  set_backtrace_args (specpdl + count, arg_vector, i);
+  set_backtrace_args (specpdl + count, arg_vector, numargs);
   tem = funcall_lambda (fun, numargs, arg_vector);
 
-  check_cons_list ();
   lisp_eval_depth--;
   /* Do the debug-on-exit now, while arg_vector still exists.  */
   if (backtrace_debug_on_exit (specpdl + count))
@@ -3705,7 +3638,7 @@ backtrace_frame_apply (Lisp_Object function, union 
specbinding *pdl)
 
   Lisp_Object flags = Qnil;
   if (backtrace_debug_on_exit (pdl))
-    flags = Fcons (QCdebug_on_exit, Fcons (Qt, Qnil));
+    flags = list2 (QCdebug_on_exit, Qt);
 
   if (backtrace_nargs (pdl) == UNEVALLED)
     return call4 (function, Qnil, backtrace_function (pdl), *backtrace_args 
(pdl), flags);
@@ -4008,7 +3941,7 @@ mark_specpdl (union specbinding *first, union specbinding 
*ptr)
   for (pdl = first; pdl != ptr; pdl++)
     {
       switch (pdl->kind)
-       {
+        {
        case SPECPDL_UNWIND:
          mark_object (specpdl_arg (pdl));
          break;
@@ -4045,7 +3978,7 @@ mark_specpdl (union specbinding *first, union specbinding 
*ptr)
 
        case SPECPDL_UNWIND_PTR:
        case SPECPDL_UNWIND_INT:
-       case SPECPDL_UNWIND_VOID:
+        case SPECPDL_UNWIND_VOID:
          break;
 
        default:
@@ -4202,6 +4135,18 @@ Note that `debug-on-error', `debug-on-quit' and friends
 still determine whether to handle the particular condition.  */);
   Vdebug_on_signal = Qnil;
 
+  /* The value of num_nonmacro_input_events as of the last time we
+   started to enter the debugger.  If we decide to enter the debugger
+   again when this is still equal to num_nonmacro_input_events, then we
+   know that the debugger itself has an error, and we should just
+   signal the error instead of entering an infinite loop of debugger
+   invocations.  */
+  DEFSYM (Qinternal_when_entered_debugger, "internal-when-entered-debugger");
+  DEFVAR_INT ("internal-when-entered-debugger", when_entered_debugger,
+              doc: /* The number of keyboard events as of last time `debugger' 
was called.
+Used to avoid infinite loops if the debugger itself has an error.
+Don't set this unless you're sure that can't happen.  */);
+
   /* When lexical binding is being used,
    Vinternal_interpreter_environment is non-nil, and contains an alist
    of lexically-bound variable, or (t), indicating an empty
@@ -4231,10 +4176,12 @@ alist of active lexical bindings.  */);
   staticpro (&Vsignaling_function);
   Vsignaling_function = Qnil;
 
-  inhibit_lisp_code = Qnil;
-
-  DEFSYM (Qcatch_all_memory_full, "catch-all-memory-full");
-  Funintern (Qcatch_all_memory_full, Qnil);
+  staticpro (&Qcatch_all_memory_full);
+  /* Make sure Qcatch_all_memory_full is a unique object.  We could
+     also use something like Fcons (Qnil, Qnil), but json.c treats any
+     cons cell as error data, so use an uninterned symbol instead.  */
+  Qcatch_all_memory_full
+    = Fmake_symbol (build_pure_c_string ("catch-all-memory-full"));
 
   defsubr (&Sor);
   defsubr (&Sand);
@@ -4242,7 +4189,6 @@ alist of active lexical bindings.  */);
   defsubr (&Scond);
   defsubr (&Sprogn);
   defsubr (&Sprog1);
-  defsubr (&Sprog2);
   defsubr (&Ssetq);
   defsubr (&Squote);
   defsubr (&Sfunction);
diff --git a/src/fileio.c b/src/fileio.c
index d979571..4ee125d 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -1,6 +1,6 @@
 /* File IO for GNU Emacs.
 
-Copyright (C) 1985-1988, 1993-2018 Free Software Foundation, Inc.
+Copyright (C) 1985-1988, 1993-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -347,7 +347,7 @@ Given a Unix syntax file name, returns a string ending in 
slash.  */)
   CHECK_STRING (filename);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (filename, Qfile_name_directory);
   if (!NILP (handler))
     {
@@ -442,7 +442,7 @@ or the entire name if it contains no slash.  */)
   CHECK_STRING (filename);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (filename, Qfile_name_nondirectory);
   if (!NILP (handler))
     {
@@ -473,7 +473,7 @@ DEFUN ("unhandled-file-name-directory", 
Funhandled_file_name_directory,
        Sunhandled_file_name_directory, 1, 1, 0,
        doc: /* Return a directly usable directory name somehow associated with 
FILENAME.
 A `directly usable' directory name is one that may be used without the
-intervention of any file handler.
+intervention of any file name handler.
 If FILENAME is a directly usable file itself, return
 \(file-name-as-directory FILENAME).
 If FILENAME refers to a file which is not accessible from a local process,
@@ -485,7 +485,7 @@ get a current directory to run processes in.  */)
   Lisp_Object handler;
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (filename, Qunhandled_file_name_directory);
   if (!NILP (handler))
     {
@@ -547,7 +547,7 @@ is already present.  */)
   CHECK_STRING (file);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (file, Qfile_name_as_directory);
   if (!NILP (handler))
     {
@@ -638,7 +638,7 @@ In Unix-syntax, this function just removes the final slash. 
 */)
   CHECK_STRING (directory);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (directory, Qdirectory_file_name);
   if (!NILP (handler))
     {
@@ -790,7 +790,7 @@ the root directory.  */)
   CHECK_STRING (name);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (name, Qexpand_file_name);
   if (!NILP (handler))
     {
@@ -1447,7 +1447,7 @@ the root directory.  */)
   }
 
   /* Again look to see if the file name has special constructs in it
-     and perhaps call the corresponding file handler.  This is needed
+     and perhaps call the corresponding file name handler.  This is needed
      for filenames such as "/foo/../address@hidden:/bar/../baz".  Expanding
      the ".." component gives us "/address@hidden:/bar/../baz" which needs
      to be expanded again.  */
@@ -1626,7 +1626,7 @@ See also the function `substitute-in-file-name'.")
 }
 #endif
 
-static bool
+bool
 file_name_absolute_p (const char *filename)
 {
   return
@@ -1639,7 +1639,7 @@ file_name_absolute_p (const char *filename)
 }
 
 /* Put into BUF the concatenation of DIR and FILE, with an intervening
-   directory separator if needed.  Return a pointer to the null byte
+   directory separator if needed.  Return a pointer to the NUL byte
    at the end of the concatenated string.  */
 char *
 splice_dir_file (char *buf, char const *dir, char const *file)
@@ -1692,6 +1692,34 @@ get_homedir (void)
       if (!home)
        return "";
     }
+#ifdef DOS_NT
+  /* If home is a drive-relative directory, expand it.  */
+  if (IS_DRIVE (*home)
+      && IS_DEVICE_SEP (home[1])
+      && !IS_DIRECTORY_SEP (home[2]))
+    {
+# ifdef WINDOWSNT
+      static char hdir[MAX_UTF8_PATH];
+# else
+      static char hdir[MAXPATHLEN];
+# endif
+      if (!getdefdir (c_toupper (*home) - 'A' + 1, hdir))
+       {
+         hdir[0] = c_toupper (*home);
+         hdir[1] = ':';
+         hdir[2] = '/';
+         hdir[3] = '\0';
+       }
+      if (home[2])
+       {
+         size_t homelen = strlen (hdir);
+         if (!IS_DIRECTORY_SEP (hdir[homelen - 1]))
+           strcat (hdir, "/");
+         strcat (hdir, home + 2);
+       }
+      home = hdir;
+    }
+#endif
   if (IS_ABSOLUTE_FILE_NAME (home))
     return home;
   if (!emacs_wd)
@@ -1772,7 +1800,7 @@ those `/' is discarded.  */)
   multibyte = STRING_MULTIBYTE (filename);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (filename, Qsubstitute_in_file_name);
   if (!NILP (handler))
     {
@@ -1986,7 +2014,7 @@ permissions.  */)
   newname = expand_cp_target (file, newname);
 
   /* If the input file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (file, Qcopy_file);
   /* Likewise for output file name.  */
   if (NILP (handler))
@@ -2347,7 +2375,7 @@ The arg must be a string.  */)
   filename = Fexpand_file_name (filename, Qnil);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (filename, Qfile_name_case_insensitive_p);
   if (!NILP (handler))
     return call2 (handler, Qfile_name_case_insensitive_p, filename);
@@ -2408,7 +2436,7 @@ This is what happens in interactive use with M-x.  */)
     newname = expand_cp_target (Fdirectory_file_name (file), newname);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (file, Qrename_file);
   if (NILP (handler))
     handler = Ffind_file_name_handler (newname, Qrename_file);
@@ -2510,14 +2538,14 @@ This is what happens in interactive use with M-x.  */)
   newname = expand_cp_target (file, newname);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (file, Qadd_name_to_file);
   if (!NILP (handler))
     return call4 (handler, Qadd_name_to_file, file,
                  newname, ok_if_already_exists);
 
   /* If the new name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (newname, Qadd_name_to_file);
   if (!NILP (handler))
     return call4 (handler, Qadd_name_to_file, file,
@@ -2570,7 +2598,7 @@ This happens for interactive use with M-x.  */)
   linkname = expand_cp_target (target, linkname);
 
   /* If the new link name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (linkname, Qmake_symbolic_link);
   if (!NILP (handler))
     return call4 (handler, Qmake_symbolic_link, target,
@@ -2625,7 +2653,7 @@ Use `file-symlink-p' to test for such links.  */)
   absname = Fexpand_file_name (filename, Qnil);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (absname, Qfile_exists_p);
   if (!NILP (handler))
     {
@@ -2653,7 +2681,7 @@ purpose, though.)  */)
   absname = Fexpand_file_name (filename, Qnil);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (absname, Qfile_executable_p);
   if (!NILP (handler))
     return call2 (handler, Qfile_executable_p, absname);
@@ -2675,7 +2703,7 @@ See also `file-exists-p' and `file-attributes'.  */)
   absname = Fexpand_file_name (filename, Qnil);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (absname, Qfile_readable_p);
   if (!NILP (handler))
     return call2 (handler, Qfile_readable_p, absname);
@@ -2696,7 +2724,7 @@ DEFUN ("file-writable-p", Ffile_writable_p, 
Sfile_writable_p, 1, 1, 0,
   absname = Fexpand_file_name (filename, Qnil);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (absname, Qfile_writable_p);
   if (!NILP (handler))
     return call2 (handler, Qfile_writable_p, absname);
@@ -2738,7 +2766,7 @@ If there is no error, returns nil.  */)
   CHECK_STRING (string);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (absname, Qaccess_file);
   if (!NILP (handler))
     return call3 (handler, Qaccess_file, absname, string);
@@ -2786,7 +2814,7 @@ This function does not check whether the link target 
exists.  */)
   filename = Fexpand_file_name (filename, Qnil);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (filename, Qfile_symlink_p);
   if (!NILP (handler))
     return call2 (handler, Qfile_symlink_p, filename);
@@ -2805,7 +2833,7 @@ See `file-symlink-p' to distinguish symlinks.  */)
   Lisp_Object absname = expand_and_dir_to_file (filename);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   Lisp_Object handler = Ffind_file_name_handler (absname, Qfile_directory_p);
   if (!NILP (handler))
     return call2 (handler, Qfile_directory_p, absname);
@@ -2874,7 +2902,7 @@ really is a readable and searchable directory.  */)
   absname = Fexpand_file_name (filename, Qnil);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (absname, Qfile_accessible_directory_p);
   if (!NILP (handler))
     {
@@ -2965,7 +2993,7 @@ See `file-symlink-p' to distinguish symlinks.  */)
   Lisp_Object absname = expand_and_dir_to_file (filename);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   Lisp_Object handler = Ffind_file_name_handler (absname, Qfile_regular_p);
   if (!NILP (handler))
     return call2 (handler, Qfile_regular_p, absname);
@@ -3008,7 +3036,7 @@ or if SELinux is disabled, or if Emacs lacks SELinux 
support.  */)
   Lisp_Object absname = expand_and_dir_to_file (filename);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   Lisp_Object handler = Ffind_file_name_handler (absname,
                                                 Qfile_selinux_context);
   if (!NILP (handler))
@@ -3070,7 +3098,7 @@ or if Emacs was not compiled with SELinux support.  */)
   absname = Fexpand_file_name (filename, BVAR (current_buffer, directory));
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (absname, Qset_file_selinux_context);
   if (!NILP (handler))
     return call3 (handler, Qset_file_selinux_context, absname, context);
@@ -3140,7 +3168,7 @@ was unable to determine the ACL entries.  */)
   Lisp_Object absname = expand_and_dir_to_file (filename);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   Lisp_Object handler = Ffind_file_name_handler (absname, Qfile_acl);
   if (!NILP (handler))
     return call2 (handler, Qfile_acl, absname);
@@ -3195,7 +3223,7 @@ support.  */)
   absname = Fexpand_file_name (filename, BVAR (current_buffer, directory));
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (absname, Qset_file_acl);
   if (!NILP (handler))
     return call3 (handler, Qset_file_acl, absname, acl_string);
@@ -3237,7 +3265,7 @@ Return nil, if file does not exist or is not accessible.  
*/)
   Lisp_Object absname = expand_and_dir_to_file (filename);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   Lisp_Object handler = Ffind_file_name_handler (absname, Qfile_modes);
   if (!NILP (handler))
     return call2 (handler, Qfile_modes, absname);
@@ -3267,7 +3295,7 @@ symbolic notation, like the `chmod' command from GNU 
Coreutils.  */)
   CHECK_FIXNUM (mode);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (absname, Qset_file_modes);
   if (!NILP (handler))
     return call3 (handler, Qset_file_modes, absname, mode);
@@ -3334,7 +3362,7 @@ Use the current time if TIMESTAMP is nil.  TIMESTAMP is 
in the format of
   absname = Fexpand_file_name (filename, BVAR (current_buffer, directory));
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (absname, Qset_file_times);
   if (!NILP (handler))
     return call3 (handler, Qset_file_times, absname, timestamp);
@@ -3382,7 +3410,7 @@ otherwise, if FILE2 does not exist, the answer is t.  */)
   Lisp_Object absname2 = expand_and_dir_to_file (file2);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   Lisp_Object handler = Ffind_file_name_handler (absname1,
                                                 Qfile_newer_than_file_p);
   if (NILP (handler))
@@ -3658,7 +3686,7 @@ by calling `format-decode', which see.  */)
   coding_system = Qnil;
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (filename, Qinsert_file_contents);
   if (!NILP (handler))
     {
@@ -4590,7 +4618,7 @@ by calling `format-decode', which see.  */)
          ptrdiff_t opoint = PT;
          ptrdiff_t opoint_byte = PT_BYTE;
          ptrdiff_t oinserted = ZV - BEGV;
-         EMACS_INT ochars_modiff = CHARS_MODIFF;
+         modiff_count ochars_modiff = CHARS_MODIFF;
 
          TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE);
          insval = call3 (Qformat_decode,
@@ -4630,7 +4658,7 @@ by calling `format-decode', which see.  */)
              ptrdiff_t opoint = PT;
              ptrdiff_t opoint_byte = PT_BYTE;
              ptrdiff_t oinserted = ZV - BEGV;
-             EMACS_INT ochars_modiff = CHARS_MODIFF;
+             modiff_count ochars_modiff = CHARS_MODIFF;
 
              TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE);
              insval = call1 (XCAR (p), make_fixnum (oinserted));
@@ -4826,7 +4854,7 @@ choose_write_coding_system (Lisp_Object start, 
Lisp_Object end, Lisp_Object file
   val = coding_inherit_eol_type (val, eol_parent);
   setup_coding_system (val, coding);
 
-  if (!STRINGP (start) && !NILP (BVAR (current_buffer, selective_display)))
+  if (!STRINGP (start) && EQ (Qt, BVAR (current_buffer, selective_display)))
     coding->mode |= CODING_MODE_SELECTIVE_DISPLAY;
   return val;
 }
@@ -4929,7 +4957,7 @@ write_region (Lisp_Object start, Lisp_Object end, 
Lisp_Object filename,
   annotations = Qnil;
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (filename, Qwrite_region);
   /* If FILENAME has no handler, see if VISIT has one.  */
   if (NILP (handler) && STRINGP (visit))
@@ -5489,7 +5517,7 @@ See Info node `(elisp)Modification Time' for more 
details.  */)
   if (b->modtime.tv_nsec == UNKNOWN_MODTIME_NSECS) return Qt;
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   handler = Ffind_file_name_handler (BVAR (b, filename),
                                     Qverify_visited_file_modtime);
   if (!NILP (handler))
@@ -5555,7 +5583,7 @@ in `current-time' or an integer flag as returned by 
`visited-file-modtime'.  */)
       filename = Fexpand_file_name (BVAR (current_buffer, filename), Qnil);
 
       /* If the file name has special constructs in it,
-        call the corresponding file handler.  */
+        call the corresponding file name handler.  */
       handler = Ffind_file_name_handler (filename, Qset_visited_file_modtime);
       if (!NILP (handler))
        /* The handler can find the file name the same way we did.  */
@@ -5678,8 +5706,9 @@ A non-nil CURRENT-ONLY argument means save only current 
buffer.  */)
   bool old_message_p = 0;
   struct auto_save_unwind auto_save_unwind;
 
-  if (max_specpdl_size < specpdl_size + 40)
-    max_specpdl_size = specpdl_size + 40;
+  intmax_t sum = INT_ADD_WRAPV (specpdl_size, 40, &sum) ? INTMAX_MAX : sum;
+  if (max_specpdl_size < sum)
+    max_specpdl_size = sum;
 
   if (minibuf_level)
     no_message = Qt;
@@ -5973,7 +6002,7 @@ If the underlying system call fails, value is nil.  */)
   Lisp_Object encoded = ENCODE_FILE (Fexpand_file_name (filename, Qnil));
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   Lisp_Object handler = Ffind_file_name_handler (encoded, Qfile_system_info);
   if (!NILP (handler))
     {
diff --git a/src/filelock.c b/src/filelock.c
index d33063c..baf87b7 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -1,6 +1,6 @@
 /* Lock files for editing.
 
-Copyright (C) 1985-1987, 1993-1994, 1996, 1998-2018 Free Software
+Copyright (C) 1985-1987, 1993-1994, 1996, 1998-2019 Free Software
 Foundation, Inc.
 
 Author: Richard King
@@ -171,13 +171,10 @@ get_boot_time (void)
     }
 
 #if defined (BOOT_TIME)
-#ifndef CANNOT_DUMP
-  /* The utmp routines maintain static state.
-     Don't touch that state unless we are initialized,
-     since it might not survive dumping.  */
-  if (! initialized)
+  /* The utmp routines maintain static state.  Don't touch that state
+     if we are going to dump, since it might not survive dumping.  */
+  if (will_dump_p ())
     return boot_time;
-#endif /* not CANNOT_DUMP */
 
   /* Try to get boot time from utmp before wtmp,
      since utmp is typically much smaller than wtmp.
@@ -299,7 +296,7 @@ typedef struct
 
 /* Write the name of the lock file for FNAME into LOCKNAME.  Length
    will be that of FNAME plus two more for the leading ".#", plus one
-   for the null.  */
+   for the NUL.  */
 #define MAKE_LOCK_NAME(lockname, fname) \
   (lockname = SAFE_ALLOCA (SBYTES (fname) + 2 + 1), \
    fill_in_lock_file_name (lockname, fname))
@@ -666,7 +663,7 @@ lock_file (Lisp_Object fn)
   /* Don't do locking while dumping Emacs.
      Uncompressing wtmp files uses call-process, which does not work
      in an uninitialized Emacs.  */
-  if (! NILP (Vpurify_flag))
+  if (will_dump_p ())
     return;
 
   orig_fn = fn;
@@ -825,6 +822,7 @@ t if it is locked by you, else a string saying which user 
has locked it.  */)
   USE_SAFE_ALLOCA;
 
   filename = Fexpand_file_name (filename, Qnil);
+  filename = ENCODE_FILE (filename);
 
   MAKE_LOCK_NAME (lfname, filename);
 
diff --git a/src/firstfile.c b/src/firstfile.c
index b0dd30c..f1cb418 100644
--- a/src/firstfile.c
+++ b/src/firstfile.c
@@ -1,5 +1,5 @@
 /* Mark beginning of data space to dump as pure, for GNU Emacs.
-   Copyright (C) 1997, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1997, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/floatfns.c b/src/floatfns.c
index 9003925..a913aad 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -1,6 +1,6 @@
 /* Primitive operations on floating point for GNU Emacs Lisp interpreter.
 
-Copyright (C) 1988, 1993-1994, 1999, 2001-2018 Free Software Foundation,
+Copyright (C) 1988, 1993-1994, 1999, 2001-2019 Free Software Foundation,
 Inc.
 
 Author: Wolfgang Rupprecht (according to ack.texi)
@@ -306,27 +306,22 @@ This is the same as the exponent of a float.  */)
   if (FLOATP (arg))
     {
       double f = XFLOAT_DATA (arg);
-
       if (f == 0)
-       value = MOST_NEGATIVE_FIXNUM;
-      else if (isfinite (f))
-       {
-         int ivalue;
-         frexp (f, &ivalue);
-         value = ivalue - 1;
-       }
-      else
-       value = MOST_POSITIVE_FIXNUM;
+       return make_float (-HUGE_VAL);
+      if (!isfinite (f))
+       return f < 0 ? make_float (-f) : arg;
+      int ivalue;
+      frexp (f, &ivalue);
+      value = ivalue - 1;
     }
-  else if (BIGNUMP (arg))
+  else if (!FIXNUMP (arg))
     value = mpz_sizeinbase (XBIGNUM (arg)->value, 2) - 1;
   else
     {
-      eassert (FIXNUMP (arg));
-      EMACS_INT i = eabs (XFIXNUM (arg));
-      value = (i == 0
-              ? MOST_NEGATIVE_FIXNUM
-              : EMACS_UINT_WIDTH - 1 - ecount_leading_zeros (i));
+      EMACS_INT i = XFIXNUM (arg);
+      if (i == 0)
+       return make_float (-HUGE_VAL);
+      value = EMACS_UINT_WIDTH - 1 - ecount_leading_zeros (eabs (i));
     }
 
   return make_fixnum (value);
diff --git a/src/fns.c b/src/fns.c
index 9ef9601..c320249 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -1,6 +1,6 @@
 /* Random utility Lisp functions.
 
-Copyright (C) 1985-1987, 1993-1995, 1997-2018 Free Software Foundation,
+Copyright (C) 1985-1987, 1993-1995, 1997-2019 Free Software Foundation,
 Inc.
 
 This file is part of GNU Emacs.
@@ -91,56 +91,60 @@ See Info node `(elisp)Random Numbers' for more details.  */)
 
 /* Random data-structure functions.  */
 
+/* Return LIST's length.  Signal an error if LIST is not a proper list.  */
+
+ptrdiff_t
+list_length (Lisp_Object list)
+{
+  intptr_t i = 0;
+  FOR_EACH_TAIL (list)
+    i++;
+  CHECK_LIST_END (list, list);
+  return i;
+}
+
+
 DEFUN ("length", Flength, Slength, 1, 1, 0,
        doc: /* Return the length of vector, list or string SEQUENCE.
 A byte-code function object is also allowed.
 If the string contains multibyte characters, this is not necessarily
 the number of bytes in the string; it is the number of characters.
 To get the number of bytes, use `string-bytes'.  */)
-  (register Lisp_Object sequence)
+  (Lisp_Object sequence)
 {
-  register Lisp_Object val;
+  EMACS_INT val;
 
   if (STRINGP (sequence))
-    XSETFASTINT (val, SCHARS (sequence));
+    val = SCHARS (sequence);
   else if (VECTORP (sequence))
-    XSETFASTINT (val, ASIZE (sequence));
+    val = ASIZE (sequence);
   else if (CHAR_TABLE_P (sequence))
-    XSETFASTINT (val, MAX_CHAR);
+    val = MAX_CHAR;
   else if (BOOL_VECTOR_P (sequence))
-    XSETFASTINT (val, bool_vector_size (sequence));
+    val = bool_vector_size (sequence);
   else if (COMPILEDP (sequence) || RECORDP (sequence))
-    XSETFASTINT (val, PVSIZE (sequence));
+    val = PVSIZE (sequence);
   else if (CONSP (sequence))
-    {
-      intptr_t i = 0;
-      FOR_EACH_TAIL (sequence)
-       i++;
-      CHECK_LIST_END (sequence, sequence);
-      if (MOST_POSITIVE_FIXNUM < i)
-       error ("List too long");
-      val = make_fixnum (i);
-    }
+    val = list_length (sequence);
   else if (NILP (sequence))
-    XSETFASTINT (val, 0);
+    val = 0;
   else
     wrong_type_argument (Qsequencep, sequence);
 
-  return val;
+  return make_fixnum (val);
 }
 
 DEFUN ("safe-length", Fsafe_length, Ssafe_length, 1, 1, 0,
        doc: /* Return the length of a list, but avoid error or infinite loop.
 This function never gets an error.  If LIST is not really a list,
 it returns 0.  If LIST is circular, it returns an integer that is at
-least the number of distinct elements.
-Value is a fixnum, if it's small enough, otherwise a bignum.  */)
+least the number of distinct elements.  */)
   (Lisp_Object list)
 {
   intptr_t len = 0;
   FOR_EACH_TAIL_SAFE (list)
     len++;
-  return INT_TO_INTEGER (len);
+  return make_fixnum (len);
 }
 
 DEFUN ("proper-list-p", Fproper_list_p, Sproper_list_p, 1, 1, 0,
@@ -160,8 +164,6 @@ A proper list is neither circular nor dotted (i.e., its 
last cdr is nil).  */
     }
   if (!NILP (last_tail))
     return Qnil;
-  if (MOST_POSITIVE_FIXNUM < len)
-    xsignal0 (Qoverflow_error);
   return make_fixnum (len);
 }
 
@@ -410,7 +412,7 @@ Symbols are also allowed; their print names are used 
instead.  */)
 
   while ((cmp = filevercmp (p1, p2)) == 0)
     {
-      /* If the strings are identical through their first null bytes,
+      /* If the strings are identical through their first NUL bytes,
         skip past identical prefixes and try again.  */
       ptrdiff_t size = strlen (p1) + 1;
       p1 += size;
@@ -1957,24 +1959,15 @@ See also the function `nreverse', which is used more 
often.  */)
 static Lisp_Object
 sort_list (Lisp_Object list, Lisp_Object predicate)
 {
-  Lisp_Object front, back;
-  Lisp_Object len, tem;
-  EMACS_INT length;
-
-  front = list;
-  len = Flength (list);
-  length = XFIXNUM (len);
+  ptrdiff_t length = list_length (list);
   if (length < 2)
     return list;
 
-  XSETINT (len, (length / 2) - 1);
-  tem = Fnthcdr (len, list);
-  back = Fcdr (tem);
+  Lisp_Object tem = Fnthcdr (make_fixnum (length / 2 - 1), list);
+  Lisp_Object back = Fcdr (tem);
   Fsetcdr (tem, Qnil);
 
-  front = Fsort (front, predicate);
-  back = Fsort (back, predicate);
-  return merge (front, back, predicate);
+  return merge (Fsort (list, predicate), Fsort (back, predicate), predicate);
 }
 
 /* Using PRED to compare, return whether A and B are in order.
@@ -2090,7 +2083,7 @@ the second.  */)
   else if (VECTORP (seq))
     sort_vector (seq, predicate);
   else if (!NILP (seq))
-    wrong_type_argument (Qsequencep, seq);
+    wrong_type_argument (Qlist_or_vector_p, seq);
   return seq;
 }
 
@@ -2955,7 +2948,7 @@ suppressed.  */)
 
       /* This is to make sure that loadup.el gives a clear picture
         of what files are preloaded and when.  */
-      if (! NILP (Vpurify_flag))
+      if (will_dump_p () && !will_bootstrap_p ())
        error ("(require %s) while preparing to dump",
               SDATA (SYMBOL_NAME (feature)));
 
@@ -3106,8 +3099,9 @@ ITEM should be one of the following:
 
 `months', returning a 12-element vector of month names (locale items MON_n);
 
-`paper', returning a list (WIDTH HEIGHT) for the default paper size,
-  both measured in millimeters (locale items PAPER_WIDTH, PAPER_HEIGHT).
+`paper', returning a list of 2 integers (WIDTH HEIGHT) for the default
+  paper size, both measured in millimeters (locale items _NL_PAPER_WIDTH,
+  _NL_PAPER_HEIGHT).
 
 If the system can't provide such information through a call to
 `nl_langinfo', or if ITEM isn't from the list above, return nil.
@@ -3124,8 +3118,8 @@ The data read from the system are decoded using 
`locale-coding-system'.  */)
       str = nl_langinfo (CODESET);
       return build_string (str);
     }
-#ifdef DAY_1
-  else if (EQ (item, Qdays))   /* e.g. for calendar-day-name-array */
+# ifdef DAY_1
+  if (EQ (item, Qdays))  /* E.g., for calendar-day-name-array.  */
     {
       Lisp_Object v = make_nil_vector (7);
       const int days[7] = {DAY_1, DAY_2, DAY_3, DAY_4, DAY_5, DAY_6, DAY_7};
@@ -3142,9 +3136,9 @@ The data read from the system are decoded using 
`locale-coding-system'.  */)
        }
       return v;
     }
-#endif /* DAY_1 */
-#ifdef MON_1
-  else if (EQ (item, Qmonths)) /* e.g. for calendar-month-name-array */
+# endif
+# ifdef MON_1
+  if (EQ (item, Qmonths))  /* E.g., for calendar-month-name-array.  */
     {
       Lisp_Object v = make_nil_vector (12);
       const int months[12] = {MON_1, MON_2, MON_3, MON_4, MON_5, MON_6, MON_7,
@@ -3159,13 +3153,12 @@ The data read from the system are decoded using 
`locale-coding-system'.  */)
        }
       return v;
     }
-#endif /* MON_1 */
-/* LC_PAPER stuff isn't defined as accessible in glibc as of 2.3.1,
-   but is in the locale files.  This could be used by ps-print.  */
-#ifdef PAPER_WIDTH
-  else if (EQ (item, Qpaper))
-    return list2i (nl_langinfo (PAPER_WIDTH), nl_langinfo (PAPER_HEIGHT));
-#endif /* PAPER_WIDTH */
+# endif
+# ifdef HAVE_LANGINFO__NL_PAPER_WIDTH
+  if (EQ (item, Qpaper))
+    return list2i ((intptr_t) nl_langinfo (_NL_PAPER_WIDTH),
+                  (intptr_t) nl_langinfo (_NL_PAPER_HEIGHT));
+# endif
 #endif /* HAVE_LANGINFO_CODESET*/
   return Qnil;
 }
@@ -3654,10 +3647,6 @@ base64_decode_1 (const char *from, char *to, ptrdiff_t 
length,
    if a `:linear-search t' argument is given to make-hash-table.  */
 
 
-/* The list of all weak hash tables.  Don't staticpro this one.  */
-
-static struct Lisp_Hash_Table *weak_hash_tables;
-
 
 /***********************************************************************
                               Utilities
@@ -3872,7 +3861,7 @@ hashfn_eq (struct hash_table_test *ht, Lisp_Object key)
    `equal' to compare keys.  The hash code returned is guaranteed to fit
    in a Lisp integer.  */
 
-static EMACS_UINT
+EMACS_UINT
 hashfn_equal (struct hash_table_test *ht, Lisp_Object key)
 {
   return sxhash (key, 0);
@@ -3882,7 +3871,7 @@ hashfn_equal (struct hash_table_test *ht, Lisp_Object key)
    `eql' to compare keys.  The hash code returned is guaranteed to fit
    in a Lisp integer.  */
 
-static EMACS_UINT
+EMACS_UINT
 hashfn_eql (struct hash_table_test *ht, Lisp_Object key)
 {
   return ((FLOATP (key) || BIGNUMP (key))
@@ -3915,7 +3904,7 @@ static struct Lisp_Hash_Table *
 allocate_hash_table (void)
 {
   return ALLOCATE_PSEUDOVECTOR (struct Lisp_Hash_Table,
-                               count, PVEC_HASH_TABLE);
+                               index, PVEC_HASH_TABLE);
 }
 
 /* An upper bound on the size of a hash table index.  It must fit in
@@ -3990,6 +3979,7 @@ make_hash_table (struct hash_table_test test, EMACS_INT 
size,
   h->hash = make_nil_vector (size);
   h->next = make_vector (size, make_fixnum (-1));
   h->index = make_vector (index_size, make_fixnum (-1));
+  h->next_weak = NULL;
   h->pure = pure;
 
   /* Set up the free list.  */
@@ -4001,13 +3991,6 @@ make_hash_table (struct hash_table_test test, EMACS_INT 
size,
   eassert (HASH_TABLE_P (table));
   eassert (XHASH_TABLE (table) == h);
 
-  /* Maybe add this hash table to the list of all weak hash tables.  */
-  if (! NILP (weak))
-    {
-      h->next_weak = weak_hash_tables;
-      weak_hash_tables = h;
-    }
-
   return table;
 }
 
@@ -4029,13 +4012,6 @@ copy_hash_table (struct Lisp_Hash_Table *h1)
   h2->index = Fcopy_sequence (h1->index);
   XSET_HASH_TABLE (table, h2);
 
-  /* Maybe add this hash table to the list of all weak hash tables.  */
-  if (!NILP (h2->weak))
-    {
-      h2->next_weak = h1->next_weak;
-      h1->next_weak = h2;
-    }
-
   return table;
 }
 
@@ -4121,6 +4097,43 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h)
     }
 }
 
+void
+hash_table_rehash (struct Lisp_Hash_Table *h)
+{
+  ptrdiff_t size = HASH_TABLE_SIZE (h);
+
+  /* Recompute the actual hash codes for each entry in the table.
+     Order is still invalid.  */
+  for (ptrdiff_t i = 0; i < size; ++i)
+    if (!NILP (HASH_HASH (h, i)))
+      {
+        Lisp_Object key = HASH_KEY (h, i);
+        EMACS_UINT hash_code = h->test.hashfn (&h->test, key);
+        set_hash_hash_slot (h, i, make_fixnum (hash_code));
+      }
+
+  /* Reset the index so that any slot we don't fill below is marked
+     invalid.  */
+  Ffillarray (h->index, make_fixnum (-1));
+
+  /* Rebuild the collision chains.  */
+  for (ptrdiff_t i = 0; i < size; ++i)
+    if (!NILP (HASH_HASH (h, i)))
+      {
+        EMACS_UINT hash_code = XUFIXNUM (HASH_HASH (h, i));
+        ptrdiff_t start_of_bucket = hash_code % ASIZE (h->index);
+        set_hash_next_slot (h, i, HASH_INDEX (h, start_of_bucket));
+        set_hash_index_slot (h, start_of_bucket, i);
+        eassert (HASH_NEXT (h, i) != i); /* Stop loops.  */
+      }
+
+  /* Finally, mark the hash table as having a valid hash order.
+     Do this last so that if we're interrupted, we retry on next
+     access. */
+  eassert (h->count < 0);
+  h->count = -h->count;
+  eassert (!hash_rehash_needed_p (h));
+}
 
 /* Lookup KEY in hash table H.  If HASH is non-null, return in *HASH
    the hash code of KEY.  Value is the index of the entry in H
@@ -4132,6 +4145,8 @@ hash_lookup (struct Lisp_Hash_Table *h, Lisp_Object key, 
EMACS_UINT *hash)
   EMACS_UINT hash_code;
   ptrdiff_t start_of_bucket, i;
 
+  hash_rehash_if_needed (h);
+
   hash_code = h->test.hashfn (&h->test, key);
   eassert ((hash_code & ~INTMASK) == 0);
   if (hash)
@@ -4160,6 +4175,8 @@ hash_put (struct Lisp_Hash_Table *h, Lisp_Object key, 
Lisp_Object value,
 {
   ptrdiff_t start_of_bucket, i;
 
+  hash_rehash_if_needed (h);
+
   eassert ((hash & ~INTMASK) == 0);
 
   /* Increment count after resizing because resizing may fail.  */
@@ -4193,6 +4210,8 @@ hash_remove_from_table (struct Lisp_Hash_Table *h, 
Lisp_Object key)
   ptrdiff_t start_of_bucket = hash_code % ASIZE (h->index);
   ptrdiff_t prev = -1;
 
+  hash_rehash_if_needed (h);
+
   for (ptrdiff_t i = HASH_INDEX (h, start_of_bucket);
        0 <= i;
        i = HASH_NEXT (h, i))
@@ -4261,7 +4280,7 @@ hash_clear (struct Lisp_Hash_Table *h)
    !REMOVE_ENTRIES_P means mark entries that are in use.  Value is
    true if anything was marked.  */
 
-static bool
+bool
 sweep_weak_table (struct Lisp_Hash_Table *h, bool remove_entries_p)
 {
   ptrdiff_t n = gc_asize (h->index);
@@ -4269,12 +4288,14 @@ sweep_weak_table (struct Lisp_Hash_Table *h, bool 
remove_entries_p)
 
   for (ptrdiff_t bucket = 0; bucket < n; ++bucket)
     {
-      /* Follow collision chain, removing entries that
-        don't survive this garbage collection.  */
+      /* Follow collision chain, removing entries that don't survive
+         this garbage collection.  It's okay if hash_rehash_needed_p
+         (h) is true, since we're operating entirely on the cached
+         hash values. */
       ptrdiff_t prev = -1;
       ptrdiff_t next;
       for (ptrdiff_t i = HASH_INDEX (h, bucket); 0 <= i; i = next)
-       {
+        {
          bool key_known_to_survive_p = survives_gc_p (HASH_KEY (h, i));
          bool value_known_to_survive_p = survives_gc_p (HASH_VALUE (h, i));
          bool remove_p;
@@ -4309,10 +4330,11 @@ sweep_weak_table (struct Lisp_Hash_Table *h, bool 
remove_entries_p)
                  /* Clear key, value, and hash.  */
                  set_hash_key_slot (h, i, Qnil);
                  set_hash_value_slot (h, i, Qnil);
-                 set_hash_hash_slot (h, i, Qnil);
+                  set_hash_hash_slot (h, i, Qnil);
 
-                 h->count--;
-               }
+                  eassert (h->count != 0);
+                  h->count += h->count > 0 ? -1 : 1;
+                }
              else
                {
                  prev = i;
@@ -4326,13 +4348,13 @@ sweep_weak_table (struct Lisp_Hash_Table *h, bool 
remove_entries_p)
                  if (!key_known_to_survive_p)
                    {
                      mark_object (HASH_KEY (h, i));
-                     marked = 1;
+                      marked = true;
                    }
 
                  if (!value_known_to_survive_p)
                    {
                      mark_object (HASH_VALUE (h, i));
-                     marked = 1;
+                      marked = true;
                    }
                }
            }
@@ -4342,55 +4364,6 @@ sweep_weak_table (struct Lisp_Hash_Table *h, bool 
remove_entries_p)
   return marked;
 }
 
-/* Remove elements from weak hash tables that don't survive the
-   current garbage collection.  Remove weak tables that don't survive
-   from Vweak_hash_tables.  Called from gc_sweep.  */
-
-NO_INLINE /* For better stack traces */
-void
-sweep_weak_hash_tables (void)
-{
-  struct Lisp_Hash_Table *h, *used, *next;
-  bool marked;
-
-  /* Mark all keys and values that are in use.  Keep on marking until
-     there is no more change.  This is necessary for cases like
-     value-weak table A containing an entry X -> Y, where Y is used in a
-     key-weak table B, Z -> Y.  If B comes after A in the list of weak
-     tables, X -> Y might be removed from A, although when looking at B
-     one finds that it shouldn't.  */
-  do
-    {
-      marked = 0;
-      for (h = weak_hash_tables; h; h = h->next_weak)
-       {
-         if (h->header.size & ARRAY_MARK_FLAG)
-           marked |= sweep_weak_table (h, 0);
-       }
-    }
-  while (marked);
-
-  /* Remove tables and entries that aren't used.  */
-  for (h = weak_hash_tables, used = NULL; h; h = next)
-    {
-      next = h->next_weak;
-
-      if (h->header.size & ARRAY_MARK_FLAG)
-       {
-         /* TABLE is marked as used.  Sweep its contents.  */
-         if (h->count > 0)
-           sweep_weak_table (h, 1);
-
-         /* Add table to the list of used weak hash tables.  */
-         h->next_weak = used;
-         used = h;
-       }
-    }
-
-  weak_hash_tables = used;
-}
-
-
 
 /***********************************************************************
                        Hash Code Computation
@@ -4941,13 +4914,7 @@ DEFUN ("secure-hash-algorithms", Fsecure_hash_algorithms,
        doc: /* Return a list of all the supported `secure_hash' algorithms. */)
   (void)
 {
-  return listn (CONSTYPE_HEAP, 6,
-                Qmd5,
-                Qsha1,
-                Qsha224,
-                Qsha256,
-                Qsha384,
-                Qsha512);
+  return list (Qmd5, Qsha1, Qsha224, Qsha256, Qsha384, Qsha512);
 }
 
 /* Extract data from a string or a buffer. SPEC is a list of
@@ -4997,7 +4964,8 @@ extract_data_from_object (Lisp_Object spec,
        }
 
       if (STRING_MULTIBYTE (object))
-       object = code_convert_string (object, coding_system, Qnil, 1, 0, 1);
+       object = code_convert_string (object, coding_system,
+                                     Qnil, true, false, true);
 
       ptrdiff_t size = SCHARS (object), start_char, end_char;
       validate_subarray (object, start, end, size, &start_char, &end_char);
@@ -5052,7 +5020,7 @@ extract_data_from_object (Lisp_Object spec,
            coding_system = Vcoding_system_for_write;
          else
            {
-             bool force_raw_text = 0;
+             bool force_raw_text = false;
 
              coding_system = BVAR (XBUFFER (object), 
buffer_file_coding_system);
              if (NILP (coding_system)
@@ -5060,14 +5028,15 @@ extract_data_from_object (Lisp_Object spec,
                {
                  coding_system = Qnil;
                  if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
-                   force_raw_text = 1;
+                   force_raw_text = true;
                }
 
              if (NILP (coding_system) && !NILP (Fbuffer_file_name (object)))
                {
                  /* Check file-coding-system-alist.  */
                  Lisp_Object val = CALLN (Ffind_operation_coding_system,
-                                          Qwrite_region, start, end,
+                                          Qwrite_region,
+                                          make_fixnum (b), make_fixnum (e),
                                           Fbuffer_file_name (object));
                  if (CONSP (val) && !NILP (XCDR (val)))
                    coding_system = XCDR (val);
@@ -5103,14 +5072,15 @@ extract_data_from_object (Lisp_Object spec,
            }
        }
 
-      object = make_buffer_string (b, e, 0);
+      object = make_buffer_string (b, e, false);
       set_buffer_internal (prev);
       /* Discard the unwind protect for recovering the current
         buffer.  */
       specpdl_ptr--;
 
       if (STRING_MULTIBYTE (object))
-       object = code_convert_string (object, coding_system, Qnil, 1, 0, 0);
+       object = code_convert_string (object, coding_system,
+                                     Qnil, true, false, false);
       *start_byte = 0;
       *end_byte = SBYTES (object);
     }
@@ -5297,6 +5267,7 @@ disregarding any coding systems.  If nil, use the current 
buffer.  */ )
 }
 
 
+
 void
 syms_of_fns (void)
 {
@@ -5380,6 +5351,7 @@ Used by `featurep' and `require', and altered by 
`provide'.  */);
   DEFSYM (Qsubfeatures, "subfeatures");
   DEFSYM (Qfuncall, "funcall");
   DEFSYM (Qplistp, "plistp");
+  DEFSYM (Qlist_or_vector_p, "list-or-vector-p");
 
 #ifdef HAVE_LANGINFO_CODESET
   DEFSYM (Qcodeset, "codeset");
@@ -5395,7 +5367,7 @@ invoked by mouse clicks and mouse menu items.
 
 On some platforms, file selection dialogs are also enabled if this is
 non-nil.  */);
-  use_dialog_box = 1;
+  use_dialog_box = true;
 
   DEFVAR_BOOL ("use-file-dialog", use_file_dialog,
     doc: /* Non-nil means mouse commands use a file dialog to ask for files.
@@ -5403,7 +5375,7 @@ This applies to commands from menus and tool bar buttons 
even when
 they are initiated from the keyboard.  If `use-dialog-box' is nil,
 that disables the use of a file dialog, regardless of the value of
 this variable.  */);
-  use_file_dialog = 1;
+  use_file_dialog = true;
 
   defsubr (&Sidentity);
   defsubr (&Srandom);
diff --git a/src/font.c b/src/font.c
index fc8efa7..f1cb756 100644
--- a/src/font.c
+++ b/src/font.c
@@ -1,6 +1,6 @@
 /* font.c -- "Font" primitives.
 
-Copyright (C) 2006-2018 Free Software Foundation, Inc.
+Copyright (C) 2006-2019 Free Software Foundation, Inc.
 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
   National Institute of Advanced Industrial Science and Technology (AIST)
   Registration Number H13PRO009
@@ -38,6 +38,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "fontset.h"
 #include "font.h"
 #include "termhooks.h"
+#include "pdumper.h"
 
 #ifdef HAVE_WINDOW_SYSTEM
 #include TERM_HEADER
@@ -1006,7 +1007,7 @@ font_expand_wildcards (Lisp_Object *field, int n)
 }
 
 
-/* Parse NAME (null terminated) as XLFD and store information in FONT
+/* Parse NAME (NUL terminated) as XLFD and store information in FONT
    (font-spec or font-entity).  Size property of FONT is set as
    follows:
        specified XLFD fields           FONT property
@@ -1352,7 +1353,7 @@ font_unparse_xlfd (Lisp_Object font, int pixel_size, char 
*name, int nbytes)
   return len < nbytes ? len : -1;
 }
 
-/* Parse NAME (null terminated) and store information in FONT
+/* Parse NAME (NUL terminated) and store information in FONT
    (font-spec or font-entity).  NAME is supplied in either the
    Fontconfig or GTK font name format.  If NAME is successfully
    parsed, return 0.  Otherwise return -1.
@@ -1724,7 +1725,7 @@ font_unparse_fcname (Lisp_Object font, int pixel_size, 
char *name, int nbytes)
 
 #endif
 
-/* Parse NAME (null terminated) and store information in FONT
+/* Parse NAME (NUL terminated) and store information in FONT
    (font-spec or font-entity).  If NAME is successfully parsed, return
    0.  Otherwise return -1.  */
 
@@ -2174,13 +2175,12 @@ font_score (Lisp_Object entity, Lisp_Object *spec_prop)
 static Lisp_Object
 font_vconcat_entity_vectors (Lisp_Object list)
 {
-  EMACS_INT nargs = XFIXNAT (Flength (list));
+  ptrdiff_t nargs = list_length (list);
   Lisp_Object *args;
   USE_SAFE_ALLOCA;
   SAFE_ALLOCA_LISP (args, nargs);
-  ptrdiff_t i;
 
-  for (i = 0; i < nargs; i++, list = XCDR (list))
+  for (ptrdiff_t i = 0; i < nargs; i++, list = XCDR (list))
     args[i] = XCAR (list);
   Lisp_Object result = Fvconcat (nargs, args);
   SAFE_FREE ();
@@ -2781,7 +2781,7 @@ font_list_entities (struct frame *f, Lisp_Object spec)
          {
            Lisp_Object copy;
 
-           val = driver_list->driver->list (f, scratch_font_spec);
+           val = (driver_list->driver->list) (f, scratch_font_spec);
            /* We put zero_vector in the font-cache to indicate that
               no fonts matching SPEC were found on the system.
               Failure to have this indication in the font cache can
@@ -3241,7 +3241,7 @@ font_find_for_lface (struct frame *f, Lisp_Object *attrs, 
Lisp_Object spec, int
 
       if (! NILP (alters))
        {
-         EMACS_INT alterslen = XFIXNAT (Flength (alters));
+         EMACS_INT alterslen = list_length (alters);
          SAFE_ALLOCA_LISP (family, alterslen + 2);
          for (i = 0; CONSP (alters); i++, alters = XCDR (alters))
            family[i] = XCAR (alters);
@@ -5314,9 +5314,10 @@ syms_of_font (void)
   sort_shift_bits[FONT_SIZE_INDEX] = 16;
   sort_shift_bits[FONT_WIDTH_INDEX] = 23;
   /* Note that the other elements in sort_shift_bits are not used.  */
+  PDUMPER_REMEMBER_SCALAR (sort_shift_bits);
 
-  staticpro (&font_charset_alist);
   font_charset_alist = Qnil;
+  staticpro (&font_charset_alist);
 
   DEFSYM (Qopentype, "opentype");
 
@@ -5358,13 +5359,13 @@ syms_of_font (void)
   DEFSYM (QL2R, "L2R");
   DEFSYM (QR2L, "R2L");
 
-  staticpro (&scratch_font_spec);
   scratch_font_spec = Ffont_spec (0, NULL);
-  staticpro (&scratch_font_prefer);
+  staticpro (&scratch_font_spec);
   scratch_font_prefer = Ffont_spec (0, NULL);
+  staticpro (&scratch_font_prefer);
 
-  staticpro (&Vfont_log_deferred);
   Vfont_log_deferred = make_nil_vector (3);
+  staticpro (&Vfont_log_deferred);
 
 #if 0
 #ifdef HAVE_LIBOTF
diff --git a/src/font.h b/src/font.h
index 52bdaa3..3540a8d 100644
--- a/src/font.h
+++ b/src/font.h
@@ -1,5 +1,5 @@
 /* font.h -- Interface definition for font handling.
-   Copyright (C) 2006-2018 Free Software Foundation, Inc.
+   Copyright (C) 2006-2019 Free Software Foundation, Inc.
    Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H13PRO009
@@ -284,7 +284,7 @@ struct font
   /* By which pixel size the font is opened.  */
   int pixel_size;
 
-  /* Height of the font.  On X window, this is the same as
+  /* Height of the font.  On X window system, this is the same as
      (font->ascent + font->descent).  */
   int height;
 
@@ -293,7 +293,7 @@ struct font
   int space_width;
 
   /* Average width of glyphs in the font.  If the font itself doesn't
-     have that information but has glyphs of ASCII characters, the
+     have that information, but has glyphs of ASCII characters, the
      value is the average width of those glyphs.  Otherwise, the value
      is 0.  */
   int average_width;
@@ -576,8 +576,8 @@ struct font_driver
      cons whose cdr part is the actual cache area.  */
   Lisp_Object (*get_cache) (struct frame *f);
 
-  /* List fonts exactly matching with FONT_SPEC on FRAME.  The value
-     is a list of font-entities.  The font properties to be considered
+  /* List fonts exactly matching FONT_SPEC on FRAME.  The value is
+     a list of font-entities.  The font properties to be considered
      are: :foundry, :family, :adstyle, :registry, :script, :lang, and
      :otf.  See the function `font-spec' for their meanings.  Note
      that the last three properties are stored in FONT_EXTRA_INDEX
@@ -593,20 +593,20 @@ struct font_driver
      The `open' method of the same font-backend is called with one of
      the returned font-entities.  If the backend needs additional
      information to be used in `open' method, this method can add any
-     Lispy value by the property :font-entity to the entities.
+     Lispy value using the property :font-entity to the entities.
 
      This and the following `match' are the only APIs that allocate
      font-entities.  */
   Lisp_Object (*list) (struct frame *frame, Lisp_Object font_spec);
 
-  /* Return a font-entity most closely matching with FONT_SPEC on
-     FRAME.  Which font property to consider, and how to calculate the
-     closeness is determined by the font backend, thus
+  /* Return a font-entity most closely matching FONT_SPEC on FRAME.
+     Which font property to consider, and how to calculate the
+     closeness, is determined by the font backend, thus
      `face-font-selection-order' is ignored here.
 
-     The properties that the font-entity has is the same as `list'
-     method.  */
-  Lisp_Object (*match) (struct frame *f, Lisp_Object spec);
+     The properties that the font-entity has are the same as described
+     for the `list' method above.  */
+  Lisp_Object (*match) (struct frame *f, Lisp_Object font_spec);
 
   /* Optional.
      List available families.  The value is a list of family names
@@ -630,7 +630,7 @@ struct font_driver
   void (*prepare_face) (struct frame *f, struct face *face);
 
   /* Optional.
-     Done FACE for displaying characters by FACE->font on frame F.  */
+     Done with FACE for displaying characters by FACE->font on frame F.  */
   void (*done_face) (struct frame *f, struct face *face);
 
   /* Optional.
@@ -662,8 +662,8 @@ struct font_driver
 
   /* Optional.
      Store bitmap data for glyph-code CODE of FONT in BITMAP.  It is
-     intended that this method is called from the other font-driver
-     for actual drawing.  */
+     intended that this method is called from other font-driver
+     methods for actual drawing.  */
   int (*get_bitmap) (struct font *font, unsigned code,
                      struct font_bitmap *bitmap,
                      int bits_per_pixel);
@@ -677,13 +677,16 @@ struct font_driver
   /* Optional.
      Get coordinates of the INDEXth anchor point of the glyph whose
      code is CODE.  Store the coordinates in *X and *Y.  Return 0 if
-     the operations was successful.  Otherwise return -1.  */
+     the operation was successful.  Otherwise return -1.  */
   int (*anchor_point) (struct font *font, unsigned code, int index,
                        int *x, int *y);
 
   /* Optional.
      Return a list describing which scripts/languages FONT
-     supports by which GSUB/GPOS features of OpenType tables.  */
+     supports by which GSUB/GPOS features of OpenType tables.
+     The list should be of the form (GSUB GPOS), where both
+     GSUB and GPOS are lists of the form
+     ((SCRIPT (LANGSYS FEATURE ...) ...) ...)  */
   Lisp_Object (*otf_capability) (struct font *font);
 
   /* Optional.
@@ -711,17 +714,16 @@ struct font_driver
 
   /* Optional.
      Make the font driver ready for frame F.  Usually this function
-     makes some data specific to F and stores it in F by calling
-     font_put_frame_data ().  */
+     makes some data specific to F and stores it in F's font_data
+     member by calling font_put_frame_data.  */
   int (*start_for_frame) (struct frame *f);
 
   /* Optional.
-     End using the driver for frame F.  Usually this function free
-     some data stored for F.  */
+     End using the driver for frame F.  Usually this function frees
+     some font data stored in frame F's font_data member.  */
   int (*end_for_frame) (struct frame *f);
 
   /* Optional.
-
      Shape text in GSTRING.  See the docstring of
      `composition-get-gstring' for the format of GSTRING.  If the
      (N+1)th element of GSTRING is nil, input of shaping is from the
@@ -735,19 +737,17 @@ struct font_driver
      output glyphs (M) are more than the input glyphs (N), (N+1)th
      through (M)th elements of GSTRING are updated possibly by making
      a new glyph object and storing it in GSTRING.  If (M) is greater
-     than the length of GSTRING, nil should be return.  In that case,
-     this function is called again with the larger GSTRING.  */
+     than the length of GSTRING, this method should return nil.  In
+     that case, the method is called again with a larger GSTRING.  */
   Lisp_Object (*shape) (Lisp_Object lgstring, Lisp_Object direction);
 
   /* Optional.
-
      If FONT is usable on frame F, return 0.  Otherwise return -1.
      This method is used only for debugging.  If this method is NULL,
      Emacs assumes that the font is usable on any frame.  */
   int (*check) (struct frame *f, struct font *font);
 
   /* Optional.
-
      Return the number of variation glyphs of character C supported by
      FONT.  VARIATIONS is an array of 256 elements.  If the variation
      selector N (1..256) defines a glyph, that glyph code is stored in
@@ -755,24 +755,27 @@ struct font_driver
   int (*get_variation_glyphs) (struct font *font,
                                int c, unsigned variations[256]);
 
+  /* Optional.
+     Set attributes of FONT according to PROPERTIES.
+     PROPERTIES is an alist of pairs (KEY . VALUE) that specifies
+     font properties.  This method should use font-put to set
+     properties of FONT supported by the font driver.
+     See font_filter_properties for more details.  */
   void (*filter_properties) (Lisp_Object font, Lisp_Object properties);
 
   /* Optional.
-
      Return non-zero if FONT_OBJECT can be used as a (cached) font
      for ENTITY on frame F.  */
   bool (*cached_font_ok) (struct frame *f,
                           Lisp_Object font_object,
                           Lisp_Object entity);
 
-  /* Optional
-
-     Return non-nil if the driver support rendering of combining
+  /* Optional.
+     Return non-nil if the driver supports rendering of combining
      characters for FONT according to Unicode combining class.  */
   Lisp_Object (*combining_capability) (struct font *font);
 
-  /* Optional
-
+  /* Optional.
      Called when frame F is double-buffered and its size changes; Xft
      relies on this hook to throw away its old XftDraw (which won't
      work after the size change) and get a new one.  */
diff --git a/src/fontset.c b/src/fontset.c
index 07f4233..2c45c95 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -1,6 +1,6 @@
 /* Fontset handler.
 
-Copyright (C) 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 2001-2019 Free Software Foundation, Inc.
 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
   2005, 2006, 2007, 2008, 2009, 2010, 2011
   National Institute of Advanced Industrial Science and Technology (AIST)
@@ -39,6 +39,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include TERM_HEADER
 #endif /* HAVE_WINDOW_SYSTEM */
 #include "font.h"
+#include "pdumper.h"
 
 /* FONTSET
 
@@ -1060,7 +1061,7 @@ font_for_char (struct face *face, int c, ptrdiff_t pos, 
Lisp_Object object)
 /* Make a realized fontset for ASCII face FACE on frame F from the
    base fontset BASE_FONTSET_ID.  If BASE_FONTSET_ID is -1, use the
    default fontset as the base.  Value is the id of the new fontset.
-   Called from realize_x_face.  */
+   Called from realize_gui_face.  */
 
 int
 make_fontset_for_ascii_face (struct frame *f, int base_fontset_id, struct face 
*face)
@@ -1443,7 +1444,7 @@ or t for the default fontset.
 
 TARGET may be a single character to use FONT-SPEC for.
 
-Target may be a cons (FROM . TO), where FROM and TO are characters.
+TARGET may be a cons (FROM . TO), where FROM and TO are characters.
 In that case, use FONT-SPEC for all the characters in the range
 between FROM and TO (inclusive).
 
@@ -1742,13 +1743,14 @@ static Lisp_Object auto_fontset_alist;
 static ptrdiff_t num_auto_fontsets;
 
 /* Return a fontset synthesized from FONT-OBJECT.  This is called from
-   x_new_font when FONT-OBJECT is used for the default ASCII font of a
-   frame, and the returned fontset is used for the default fontset of
-   that frame.  The fontset specifies a font of the same registry as
-   FONT-OBJECT for all characters in the repertory of the registry
-   (see Vfont_encoding_alist).  If the repertory is not known, the
-   fontset specifies the font for all Latin characters assuming that a
-   user intends to use FONT-OBJECT for Latin characters.  */
+   the terminal hook set_new_font_hook when FONT-OBJECT is used for
+   the default ASCII font of a frame, and the returned fontset is used
+   for the default fontset of that frame.  The fontset specifies a
+   font of the same registry as FONT-OBJECT for all characters in the
+   repertory of the registry (see Vfont_encoding_alist).  If the
+   repertory is not known, the fontset specifies the font for all
+   Latin characters assuming that a user intends to use FONT-OBJECT
+   for Latin characters.  */
 
 int
 fontset_from_font (Lisp_Object font_object)
@@ -2127,6 +2129,7 @@ syms_of_fontset (void)
      build_pure_c_string ("-*-*-*-*-*-*-*-*-*-*-*-*-fontset-default"));
   ASET (Vfontset_table, 0, Vdefault_fontset);
   next_fontset_id = 1;
+  PDUMPER_REMEMBER_SCALAR (next_fontset_id);
 
   auto_fontset_alist = Qnil;
   staticpro (&auto_fontset_alist);
diff --git a/src/fontset.h b/src/fontset.h
index a010ff8..40650e8 100644
--- a/src/fontset.h
+++ b/src/fontset.h
@@ -1,5 +1,5 @@
 /* Header for fontset handler.
-   Copyright (C) 1998, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2001-2019 Free Software Foundation, Inc.
    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
      2005, 2006, 2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
diff --git a/src/frame.c b/src/frame.c
index 4371ef7..03bbbfb 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -1,6 +1,6 @@
 /* Generic frame functions.
 
-Copyright (C) 1993-1995, 1997, 1999-2018 Free Software Foundation, Inc.
+Copyright (C) 1993-1995, 1997, 1999-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -53,11 +53,14 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #ifdef USE_X_TOOLKIT
 #include "widget.h"
 #endif
+#include "pdumper.h"
 
 /* The currently selected frame.  */
-
 Lisp_Object selected_frame;
 
+/* The selected frame the last time window change functions were run.  */
+Lisp_Object old_selected_frame;
+
 /* A frame which is not just a mini-buffer, or NULL if there are no such
    frames.  This is usually the most recent such frame that was selected.  */
 
@@ -67,14 +70,14 @@ static struct frame *last_nonminibuf_frame;
 bool frame_garbaged;
 
 /* The default tool bar height for future frames.  */
-#if defined USE_GTK || defined HAVE_NS
+#ifdef HAVE_EXT_TOOL_BAR
 enum { frame_default_tool_bar_height = 0 };
 #else
 int frame_default_tool_bar_height;
 #endif
 
 #ifdef HAVE_WINDOW_SYSTEM
-static void x_report_frame_params (struct frame *, Lisp_Object *);
+static void gui_report_frame_params (struct frame *, Lisp_Object *);
 #endif
 
 /* These setters are used only in this file, so they can be private.  */
@@ -160,10 +163,8 @@ frame_size_history_add (struct frame *f, Lisp_Object 
fun_symbol,
             Fcons (list4
                    (frame, fun_symbol,
                     ((width > 0)
-                     ? list4 (make_fixnum (FRAME_TEXT_WIDTH (f)),
-                              make_fixnum (FRAME_TEXT_HEIGHT (f)),
-                              make_fixnum (width),
-                              make_fixnum (height))
+                     ? list4i (FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f),
+                               width, height)
                      : Qnil),
                     rest),
                    XCDR (frame_size_history)));
@@ -481,7 +482,8 @@ keep_ratio (struct frame *f, struct frame *p, int 
old_width, int old_height,
              f->top_pos = pos_y;
            }
 
-         x_set_offset (f, pos_x, pos_y, -1);
+          if (FRAME_TERMINAL (f)->set_frame_offset_hook)
+            FRAME_TERMINAL (f)->set_frame_offset_hook (f, pos_x, pos_y, -1);
        }
 
       if (!CONSP (keep_ratio) || !NILP (Fcar (keep_ratio)))
@@ -517,36 +519,37 @@ keep_ratio (struct frame *f, struct frame *p, int 
old_width, int old_height,
  * text size of F in pixels.  A value of -1 means no change is requested
  * for that direction (but the frame may still have to be resized to
  * accommodate windows with their minimum sizes).  This can either issue
- * a request to resize the frame externally (via x_set_window_size), to
+ * a request to resize the frame externally (via set_window_size_hook), to
  * resize the frame internally (via resize_frame_windows) or do nothing
  * at all.
  *
  * The argument INHIBIT can assume the following values:
  *
- * 0 means to unconditionally call x_set_window_size even if sizes
+ * 0 means to unconditionally call set_window_size_hook even if sizes
  *   apparently do not change.  Fx_create_frame uses this to pass the
  *   initial size to the window manager.
  *
- * 1 means to call x_set_window_size if the native frame size really
+ * 1 means to call set_window_size_hook if the native frame size really
  *   changes.  Fset_frame_size, Fset_frame_height, ... use this.
  *
- * 2 means to call x_set_window_size provided frame_inhibit_resize
+ * 2 means to call set_window_size_hook provided frame_inhibit_resize
  *   allows it.  The menu and tool bar code use this ("3" won't work
  *   here in general because menu and tool bar are often not counted in
  *   the frame's text height).
  *
- * 3 means call x_set_window_size if window minimum sizes must be
- *   preserved or frame_inhibit_resize allows it.  x_set_left_fringe,
- *   x_set_scroll_bar_width, x_new_font ... use (or should use) this.
+ * 3 means call set_window_size_hook if window minimum sizes must be
+ *   preserved or frame_inhibit_resize allows it.
+ *   gui_set_left_fringe, gui_set_scroll_bar_width, gui_new_font
+ *   ... use (or should use) this.
  *
- * 4 means call x_set_window_size only if window minimum sizes must be
- *   preserved.  x_set_right_divider_width, x_set_border_width and the
- *   code responsible for wrapping the tool bar use this.
+ * 4 means call set_window_size_hook only if window minimum sizes must
+ *   be preserved.  x_set_right_divider_width, x_set_border_width and
+ *   the code responsible for wrapping the tool bar use this.
  *
- * 5 means to never call x_set_window_size.  change_frame_size uses
+ * 5 means to never call set_window_size_hook.  change_frame_size uses
  *   this.
  *
- * Note that even when x_set_window_size is not called, individual
+ * Note that even when set_window_size_hook is not called, individual
  * windows may have to be resized (via `window--sanitize-window-sizes')
  * in order to support minimum size constraints.
  *
@@ -569,7 +572,7 @@ adjust_frame_size (struct frame *f, int new_width, int 
new_height, int inhibit,
   /* The following two values are calculated from the old frame pixel
      sizes and any "new" settings for tool bar, menu bar and internal
      borders.  We do it this way to detect whether we have to call
-     x_set_window_size as consequence of the new settings.  */
+     set_window_size_hook as consequence of the new settings.  */
   int windows_width = FRAME_WINDOWS_WIDTH (f);
   int windows_height = FRAME_WINDOWS_HEIGHT (f);
   int min_windows_width, min_windows_height;
@@ -644,7 +647,7 @@ adjust_frame_size (struct frame *f, int new_width, int 
new_height, int inhibit,
 
 #ifdef HAVE_WINDOW_SYSTEM
   if (FRAME_WINDOW_P (f)
-      && f->can_x_set_window_size
+      && f->can_set_window_size
       && ((!inhibit_horizontal
           && (new_pixel_width != old_pixel_width
               || inhibit == 0 || inhibit == 2))
@@ -667,7 +670,12 @@ adjust_frame_size (struct frame *f, int new_width, int 
new_height, int inhibit,
         list2 (inhibit_horizontal ? Qt : Qnil,
                inhibit_vertical ? Qt : Qnil));
 
-      x_set_window_size (f, 0, new_text_width, new_text_height, 1);
+      if (FRAME_TERMINAL (f)->set_window_size_hook)
+        FRAME_TERMINAL (f)->set_window_size_hook (f,
+                                                  0,
+                                                  new_text_width,
+                                                  new_text_height,
+                                                  1);
       f->resized_p = true;
 
       return;
@@ -711,7 +719,7 @@ adjust_frame_size (struct frame *f, int new_width, int 
new_height, int inhibit,
       if ((FRAME_TERMCAP_P (f) && !pretend) || FRAME_MSDOS_P (f))
        FrameCols (FRAME_TTY (f)) = new_cols;
 
-#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
       if (WINDOWP (f->tool_bar_window))
        {
          XWINDOW (f->tool_bar_window)->pixel_width = new_windows_width;
@@ -741,8 +749,8 @@ adjust_frame_size (struct frame *f, int new_width, int 
new_height, int inhibit,
 
   frame_size_history_add
     (f, Qadjust_frame_size_3, new_text_width, new_text_height,
-     list4 (make_fixnum (old_pixel_width), make_fixnum (old_pixel_height),
-           make_fixnum (new_pixel_width), make_fixnum (new_pixel_height)));
+     list4i (old_pixel_width, old_pixel_height,
+            new_pixel_width, new_pixel_height));
 
   /* Assign new sizes.  */
   FRAME_TEXT_WIDTH (f) = new_text_width;
@@ -797,7 +805,8 @@ adjust_frame_size (struct frame *f, int new_width, int 
new_height, int inhibit,
 static struct frame *
 allocate_frame (void)
 {
-  return ALLOCATE_ZEROED_PSEUDOVECTOR (struct frame, face_cache, PVEC_FRAME);
+  return ALLOCATE_ZEROED_PSEUDOVECTOR (struct frame, tool_bar_items,
+                                      PVEC_FRAME);
 }
 
 struct frame *
@@ -825,7 +834,7 @@ make_frame (bool mini_p)
   f->wants_modeline = true;
   f->redisplay = true;
   f->garbaged = true;
-  f->can_x_set_window_size = false;
+  f->can_set_window_size = false;
   f->after_make_frame = false;
   f->inhibit_horizontal_resize = false;
   f->inhibit_vertical_resize = false;
@@ -847,7 +856,7 @@ make_frame (bool mini_p)
   f->no_accept_focus = false;
   f->z_group = z_group_none;
   f->tooltip = false;
-#if ! defined (USE_GTK) && ! defined (HAVE_NS)
+#ifndef HAVE_EXT_TOOL_BAR
   f->last_tool_bar_item = -1;
 #endif
 #ifdef NS_IMPL_COCOA
@@ -855,7 +864,8 @@ make_frame (bool mini_p)
   f->ns_transparent_titlebar = false;
 #endif
 #endif
-
+  /* This one should never be zero.  */
+  f->change_stamp = 1;
   root_window = make_window ();
   rw = XWINDOW (root_window);
   if (mini_p)
@@ -1048,10 +1058,7 @@ make_initial_frame (void)
   Lisp_Object frame;
 
   eassert (initial_kboard);
-
-  /* The first call must initialize Vframe_list.  */
-  if (! (NILP (Vframe_list) || CONSP (Vframe_list)))
-    Vframe_list = Qnil;
+  eassert (NILP (Vframe_list) || CONSP (Vframe_list));
 
   terminal = init_initial_terminal ();
 
@@ -1089,7 +1096,7 @@ make_initial_frame (void)
 
   last_nonminibuf_frame = f;
 
-  f->can_x_set_window_size = true;
+  f->can_set_window_size = true;
   f->after_make_frame = true;
 
   return f;
@@ -1118,6 +1125,7 @@ make_terminal_frame (struct terminal *terminal)
   f->terminal = terminal;
   f->terminal->reference_count++;
 #ifdef MSDOS
+  f->output_data.tty = &the_only_tty_output;
   f->output_data.tty->display_info = &the_only_display_info;
   if (!inhibit_window_system
       && (!FRAMEP (selected_frame) || !FRAME_LIVE_P (XFRAME (selected_frame))
@@ -1290,7 +1298,7 @@ affects all frames on the same terminal device.  */)
   for (tem = f->face_alist; CONSP (tem); tem = XCDR (tem))
     XSETCDR (XCAR (tem), Fcopy_sequence (XCDR (XCAR (tem))));
 
-  f->can_x_set_window_size = true;
+  f->can_set_window_size = true;
   f->after_make_frame = true;
 
   return frame;
@@ -1364,20 +1372,20 @@ do_switch_frame (Lisp_Object frame, int track, int 
for_deletion, Lisp_Object nor
 #else /* ! 0 */
   /* Instead, apply it only to the frame we're pointing to.  */
 #ifdef HAVE_WINDOW_SYSTEM
-  if (track && FRAME_WINDOW_P (f))
+  if (track && FRAME_WINDOW_P (f) && FRAME_TERMINAL (f)->get_focus_frame)
     {
-      Lisp_Object focus, xfocus;
+      Lisp_Object focus, gfocus;
 
-      xfocus = x_get_focus_frame (f);
-      if (FRAMEP (xfocus))
+      gfocus = FRAME_TERMINAL (f)->get_focus_frame (f);
+      if (FRAMEP (gfocus))
        {
-         focus = FRAME_FOCUS_FRAME (XFRAME (xfocus));
+         focus = FRAME_FOCUS_FRAME (XFRAME (gfocus));
          if ((FRAMEP (focus) && XFRAME (focus) == SELECTED_FRAME ())
              /* Redirect frame focus also when FRAME has its minibuffer
                 window on the selected frame (see Bug#24500).  */
              || (NILP (focus)
                  && EQ (FRAME_MINIBUF_WINDOW (f), sf->selected_window)))
-           Fredirect_frame_focus (xfocus, frame);
+           Fredirect_frame_focus (gfocus, frame);
        }
     }
 #endif /* HAVE_X_WINDOWS */
@@ -1451,7 +1459,8 @@ This function returns FRAME, or nil if FRAME has been 
deleted.  */)
   return do_switch_frame (frame, 1, 0, norecord);
 }
 
-DEFUN ("handle-switch-frame", Fhandle_switch_frame, Shandle_switch_frame, 1, 
1, "^e",
+DEFUN ("handle-switch-frame", Fhandle_switch_frame,
+       Shandle_switch_frame, 1, 1, "^e",
        doc: /* Handle a switch-frame event EVENT.
 Switch-frame events are usually bound to this function.
 A switch-frame event is an event Emacs sends itself to
@@ -1471,6 +1480,18 @@ DEFUN ("selected-frame", Fselected_frame, 
Sselected_frame, 0, 0, 0,
 {
   return selected_frame;
 }
+
+DEFUN ("old-selected-frame", Fold_selected_frame,
+       Sold_selected_frame, 0, 0, 0,
+       doc: /* Return the old selected FRAME.
+FRAME must be a live frame and defaults to the selected one.
+
+The return value is the frame selected the last time window change
+functions were run.  */)
+  (void)
+{
+  return old_selected_frame;
+}
 
 DEFUN ("frame-list", Fframe_list, Sframe_list,
        0, 0, 0,
@@ -1837,6 +1858,7 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
   Lisp_Object frames, frame1;
   int minibuffer_selected, is_tooltip_frame;
   bool nochild = !FRAME_PARENT_FRAME (f);
+  Lisp_Object minibuffer_child_frame = Qnil;
 
   if (!FRAME_LIVE_P (f))
     return Qnil;
@@ -1853,13 +1875,33 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
   /* Softly delete all frames with this frame as their parent frame or
      as their `delete-before' frame parameter value.  */
   FOR_EACH_FRAME (frames, frame1)
-    if (FRAME_PARENT_FRAME (XFRAME (frame1)) == f
+    {
+      struct frame *f1 = XFRAME (frame1);
+
+      if (EQ (frame1, frame) || FRAME_TOOLTIP_P (f1))
+       continue;
+      else if (FRAME_PARENT_FRAME (f1) == f)
+       {
+         if (FRAME_HAS_MINIBUF_P (f1) && !FRAME_HAS_MINIBUF_P (f)
+             && EQ (FRAME_MINIBUF_WINDOW (f), FRAME_MINIBUF_WINDOW (f1)))
+           /* frame1 owns frame's minibuffer window so we must not
+              delete it here to avoid a surrogate minibuffer error.
+              Unparent frame1 and make it a top-level frame.  */
+           {
+             Fmodify_frame_parameters
+               (frame1, Fcons (Fcons (Qparent_frame, Qnil), Qnil));
+             minibuffer_child_frame = frame1;
+           }
+         else
+           delete_frame (frame1, Qnil);
+       }
+      else if (nochild
+              && EQ (get_frame_param (XFRAME (frame1), Qdelete_before), frame))
        /* Process `delete-before' parameter iff FRAME is not a child
           frame.  This avoids that we enter an infinite chain of mixed
           dependencies.  */
-       || (nochild
-           && EQ (get_frame_param (XFRAME (frame1), Qdelete_before), frame)))
-      delete_frame (frame1, Qnil);
+       delete_frame (frame1, Qnil);
+    }
 
   /* Does this frame have a minibuffer, and is it the surrogate
      minibuffer for any other frame?  */
@@ -2124,18 +2166,27 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
        {
          struct frame *f1 = XFRAME (frame1);
 
-         /* Consider only frames on the same kboard
-            and only those with minibuffers.  */
-         if (kb == FRAME_KBOARD (f1)
-             && FRAME_HAS_MINIBUF_P (f1))
+         /* Set frame_on_same_kboard to frame1 if it is on the same
+            keyboard.  Set frame_with_minibuf to frame1 if it also
+            has a minibuffer.  Leave the loop immediately if frame1
+            is also minibuffer-only.
+
+            Emacs 26 does _not_ set frame_on_same_kboard here when it
+            finds a minibuffer-only frame and subsequently fails to
+            set default_minibuffer_frame below.  Not a great deal and
+            never noticed since make_frame_without_minibuffer creates
+            a new minibuffer frame in that case (which can be a minor
+            annoyance though).  To consider for Emacs 26.3.  */
+         if (kb == FRAME_KBOARD (f1))
            {
-             frame_with_minibuf = frame1;
-             if (FRAME_MINIBUF_ONLY_P (f1))
-               break;
+             frame_on_same_kboard = frame1;
+             if (FRAME_HAS_MINIBUF_P (f1))
+               {
+                 frame_with_minibuf = frame1;
+                 if (FRAME_MINIBUF_ONLY_P (f1))
+                   break;
+               }
            }
-
-         if (kb == FRAME_KBOARD (f1))
-           frame_on_same_kboard = frame1;
        }
 
       if (!NILP (frame_on_same_kboard))
@@ -2168,7 +2219,46 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
       = Fcons (list3 (Qrun_hook_with_args, Qafter_delete_frame_functions, 
frame),
               pending_funcalls);
   else
-      safe_call2 (Qrun_hook_with_args, Qafter_delete_frame_functions, frame);
+    safe_call2 (Qrun_hook_with_args, Qafter_delete_frame_functions, frame);
+
+  if (!NILP (minibuffer_child_frame))
+    /* If minibuffer_child_frame is non-nil, it was FRAME's minibuffer
+       child frame.  Delete it unless it's also the minibuffer frame
+       of another frame in which case we make sure it's visible.  */
+    {
+      struct frame *f1 = XFRAME (minibuffer_child_frame);
+
+      if (FRAME_LIVE_P (f1))
+       {
+         Lisp_Object window1 = FRAME_ROOT_WINDOW (f1);
+         Lisp_Object frame2;
+
+         FOR_EACH_FRAME (frames, frame2)
+           {
+             struct frame *f2 = XFRAME (frame2);
+
+             if (EQ (frame2, minibuffer_child_frame) || FRAME_TOOLTIP_P (f2))
+               continue;
+             else if (EQ (FRAME_MINIBUF_WINDOW (f2), window1))
+               {
+                 /* minibuffer_child_frame serves as minibuffer frame
+                    for at least one other frame - so make it visible
+                    and quit.  */
+                 if (!FRAME_VISIBLE_P (f1) && !FRAME_ICONIFIED_P (f1))
+                   Fmake_frame_visible (minibuffer_child_frame);
+
+                 return Qnil;
+               }
+           }
+
+         /* No other frame found that uses minibuffer_child_frame as
+            minibuffer frame.  If FORCE is Qnoelisp or there are
+            other visible frames left, delete minibuffer_child_frame
+            since it presumably was used by FRAME only.  */
+         if (EQ (force, Qnoelisp) || other_frames (f1, false, !NILP (force)))
+           delete_frame (minibuffer_child_frame, Qnoelisp);
+       }
+    }
 
   return Qnil;
 }
@@ -2501,11 +2591,8 @@ If omitted, FRAME defaults to the currently selected 
frame.  */)
 {
   struct frame *f = decode_live_frame (frame);
 
-  /* I think this should be done with a hook.  */
-#ifdef HAVE_WINDOW_SYSTEM
-  if (FRAME_WINDOW_P (f))
-    x_make_frame_visible (f);
-#endif
+  if (FRAME_WINDOW_P (f) && FRAME_TERMINAL (f)->frame_visible_invisible_hook)
+    FRAME_TERMINAL (f)->frame_visible_invisible_hook (f, true);
 
   make_frame_visible_1 (f->root_window);
 
@@ -2557,11 +2644,8 @@ displayed in the terminal.  */)
   /* Don't allow minibuf_window to remain on an invisible frame.  */
   check_minibuf_window (frame, EQ (minibuf_window, selected_window));
 
-  /* I think this should be done with a hook.  */
-#ifdef HAVE_WINDOW_SYSTEM
-  if (FRAME_WINDOW_P (f))
-    x_make_frame_invisible (f);
-#endif
+  if (FRAME_WINDOW_P (f) && FRAME_TERMINAL (f)->frame_visible_invisible_hook)
+    FRAME_TERMINAL (f)->frame_visible_invisible_hook (f, false);
 
   /* Make menu bar update for the Buffers and Frames menus.  */
   windows_or_buffers_changed = 16;
@@ -2605,13 +2689,8 @@ for how to proceed.  */)
   /* Don't allow minibuf_window to remain on an iconified frame.  */
   check_minibuf_window (frame, EQ (minibuf_window, selected_window));
 
-  /* I think this should be done with a hook.  */
-  if (FRAME_WINDOW_P (f))
-    {
-#ifdef HAVE_WINDOW_SYSTEM
-      x_iconify_frame (f);
-#endif
-    }
+  if (FRAME_WINDOW_P (f) && FRAME_TERMINAL (f)->iconify_frame_hook)
+    FRAME_TERMINAL (f)->iconify_frame_hook (f);
 
   return Qnil;
 }
@@ -2673,7 +2752,7 @@ doesn't support multiple overlapping frames, this 
function selects FRAME.  */)
     Fmake_frame_visible (frame);
 
   if (FRAME_TERMINAL (f)->frame_raise_lower_hook)
-    (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 1);
+    (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, true);
 
   return Qnil;
 }
@@ -2689,7 +2768,7 @@ doesn't support multiple overlapping frames, this 
function does nothing.  */)
   struct frame *f = decode_live_frame (frame);
 
   if (FRAME_TERMINAL (f)->frame_raise_lower_hook)
-    (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, 0);
+    (*FRAME_TERMINAL (f)->frame_raise_lower_hook) (f, false);
 
   return Qnil;
 }
@@ -2758,7 +2837,9 @@ If there is no window system support, this function does 
nothing.  */)
      (Lisp_Object frame, Lisp_Object noactivate)
 {
 #ifdef HAVE_WINDOW_SYSTEM
-  x_focus_frame (decode_window_system_frame (frame), !NILP (noactivate));
+  struct frame *f = decode_window_system_frame (frame);
+  if (f && FRAME_TERMINAL (f)->focus_frame_hook)
+    FRAME_TERMINAL (f)->focus_frame_hook (f, !NILP (noactivate));
 #endif
   return Qnil;
 }
@@ -2829,7 +2910,7 @@ frame_name_fnn_p (char *str, ptrdiff_t len)
 }
 
 /* Set the name of the terminal frame.  Also used by MSDOS frames.
-   Modeled after x_set_name which is used for WINDOW frames.  */
+   Modeled after *_set_name which is used for WINDOW frames.  */
 
 static void
 set_term_frame_name (struct frame *f, Lisp_Object name)
@@ -2961,6 +3042,13 @@ store_frame_param (struct frame *f, Lisp_Object prop, 
Lisp_Object val)
       fset_buried_buffer_list (f, Fnreverse (list));
       return;
     }
+  else if ((EQ (prop, Qscroll_bar_width) || EQ (prop, Qscroll_bar_height))
+          && !NILP (val) && !RANGED_FIXNUMP (1, val, INT_MAX))
+    {
+      Lisp_Object old_val = Fcdr (Fassq (prop, f->param_alist));
+
+      val = old_val;
+    }
 
   /* The tty color needed to be set before the frame's parameter
      alist was updated with the new value.  This is not true any more,
@@ -3074,7 +3162,7 @@ If FRAME is omitted or nil, return information on the 
currently selected frame.
   /* I think this should be done with a hook.  */
 #ifdef HAVE_WINDOW_SYSTEM
   if (FRAME_WINDOW_P (f))
-    x_report_frame_params (f, &alist);
+    gui_report_frame_params (f, &alist);
   else
 #endif
     {
@@ -3180,7 +3268,7 @@ list, but are otherwise ignored.  */)
   /* I think this should be done with a hook.  */
 #ifdef HAVE_WINDOW_SYSTEM
   if (FRAME_WINDOW_P (f))
-    x_set_frame_parameters (f, alist);
+    gui_set_frame_parameters (f, alist);
   else
 #endif
 #ifdef MSDOS
@@ -3190,7 +3278,7 @@ list, but are otherwise ignored.  */)
 #endif
 
     {
-      EMACS_INT length = XFIXNAT (Flength (alist));
+      EMACS_INT length = list_length (alist);
       ptrdiff_t i;
       Lisp_Object *parms;
       Lisp_Object *values;
@@ -3513,27 +3601,64 @@ bottom edge of FRAME's display.  */)
   CHECK_TYPE_RANGED_INTEGER (int, x);
   CHECK_TYPE_RANGED_INTEGER (int, y);
 
-  /* I think this should be done with a hook.  */
   if (FRAME_WINDOW_P (f))
     {
 #ifdef HAVE_WINDOW_SYSTEM
-      x_set_offset (f, XFIXNUM (x), XFIXNUM (y), 1);
+      if (FRAME_TERMINAL (f)->set_frame_offset_hook)
+        FRAME_TERMINAL (f)->set_frame_offset_hook (f,
+                                                   XFIXNUM (x),
+                                                   XFIXNUM (y),
+                                                   1);
 #endif
     }
 
   return Qt;
 }
+
+DEFUN ("frame-window-state-change", Fframe_window_state_change,
+       Sframe_window_state_change, 0, 1, 0,
+       doc: /* Return t if FRAME's window state change flag is set, nil 
otherwise.
+FRAME must be a live frame and defaults to the selected one.
+
+If FRAME's window state change flag is set, the default values of
+`window-state-change-functions' and `window-state-change-hook' will be
+run during next redisplay, regardless of whether a window state change
+actually occurred on FRAME or not.  After that, the value of this flag
+is reset.  */)
+     (Lisp_Object frame)
+{
+  return FRAME_WINDOW_STATE_CHANGE (decode_live_frame (frame)) ? Qt : Qnil;
+}
+
+DEFUN ("set-frame-window-state-change", Fset_frame_window_state_change,
+       Sset_frame_window_state_change, 0, 2, 0,
+       doc: /* Set FRAME's window state change flag according to ARG.
+Set FRAME's window state change flag if ARG is non-nil, reset it
+otherwise.
+
+If FRAME's window state change flag is set, the default values of
+`window-state-change-functions' and `window-state-change-hook' will be
+run during next redisplay, regardless of whether a window state change
+actually occurred on FRAME or not.  After that, the value of FRAME's
+window state change flag is reset.  */)
+     (Lisp_Object frame, Lisp_Object arg)
+{
+  struct frame *f = decode_live_frame (frame);
+
+  return (FRAME_WINDOW_STATE_CHANGE (f) = !NILP (arg)) ? Qt : Qnil;
+}
+
 
 /***********************************************************************
                                Frame Parameters
  ***********************************************************************/
 
-/* Connect the frame-parameter names for X frames
-   to the ways of passing the parameter values to the window system.
+/* Connect the frame-parameter names for frames to the ways of passing
+   the parameter values to the window system.
 
-   The name of a parameter, as a Lisp symbol,
-   has an `x-frame-parameter' property which is an integer in Lisp
-   that is an index in this table.  */
+   The name of a parameter, as a Lisp symbol, has a
+   `frame-parameter-pos' property which is an integer in Lisp that is
+   an index in this table.  */
 
 struct frame_parm_table {
   const char *name;
@@ -3780,12 +3905,12 @@ frame_float (struct frame *f, Lisp_Object val, enum 
frame_float_type what,
 
 /* Change the parameters of frame F as specified by ALIST.
    If a parameter is not specially recognized, do nothing special;
-   otherwise call the `x_set_...' function for that parameter.
+   otherwise call the `gui_set_...' function for that parameter.
    Except for certain geometry properties, always call store_frame_param
    to store the new value in the parameter alist.  */
 
 void
-x_set_frame_parameters (struct frame *f, Lisp_Object alist)
+gui_set_frame_parameters (struct frame *f, Lisp_Object alist)
 {
   Lisp_Object tail, frame;
 
@@ -3973,7 +4098,7 @@ x_set_frame_parameters (struct frame *f, Lisp_Object 
alist)
        all.  With the old setting it can get a Heisenbug when
        EmacsFrameResize intermittently provokes a delayed
        change_frame_size in the middle of adjust_frame_size.  */
-    /**        || (f->can_x_set_window_size && (f->new_height || 
f->new_width))) **/
+    /**        || (f->can_set_window_size && (f->new_height || f->new_width))) 
**/
     adjust_frame_size (f, width, height, 1, 0, Qx_set_frame_parameters);
 
   if ((!NILP (left) || !NILP (top))
@@ -4039,7 +4164,8 @@ x_set_frame_parameters (struct frame *f, Lisp_Object 
alist)
       f->win_gravity = NorthWestGravity;
 
       /* Actually set that position, and convert to absolute.  */
-      x_set_offset (f, leftpos, toppos, -1);
+      if (FRAME_TERMINAL (f)->set_frame_offset_hook)
+        FRAME_TERMINAL (f)->set_frame_offset_hook (f, leftpos, toppos, -1);
     }
 
   if (fullscreen_change)
@@ -4051,7 +4177,7 @@ x_set_frame_parameters (struct frame *f, Lisp_Object 
alist)
 
       store_frame_param (f, Qfullscreen, fullscreen);
       if (!EQ (fullscreen, old_value))
-       x_set_fullscreen (f, fullscreen, old_value);
+       gui_set_fullscreen (f, fullscreen, old_value);
     }
 
 
@@ -4065,14 +4191,14 @@ x_set_frame_parameters (struct frame *f, Lisp_Object 
alist)
 }
 
 
-/* Insert a description of internally-recorded parameters of frame X
+/* Insert a description of internally-recorded parameters of frame F
    into the parameter alist *ALISTPTR that is to be given to the user.
    Only parameters that are specific to the X window system
    and whose values are not correctly recorded in the frame's
    param_alist need to be considered here.  */
 
 void
-x_report_frame_params (struct frame *f, Lisp_Object *alistptr)
+gui_report_frame_params (struct frame *f, Lisp_Object *alistptr)
 {
   Lisp_Object tem;
   uprintmax_t w;
@@ -4105,27 +4231,23 @@ x_report_frame_params (struct frame *f, Lisp_Object 
*alistptr)
   store_in_alist (alistptr, Qright_fringe,
                  make_fixnum (FRAME_RIGHT_FRINGE_WIDTH (f)));
   store_in_alist (alistptr, Qscroll_bar_width,
-                 (! FRAME_HAS_VERTICAL_SCROLL_BARS (f)
-                  ? make_fixnum (0)
-                  : FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0
+                 (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0
                   ? make_fixnum (FRAME_CONFIG_SCROLL_BAR_WIDTH (f))
                   /* nil means "use default width"
                      for non-toolkit scroll bar.
                      ruler-mode.el depends on this.  */
                   : Qnil));
   store_in_alist (alistptr, Qscroll_bar_height,
-                 (! FRAME_HAS_HORIZONTAL_SCROLL_BARS (f)
-                  ? make_fixnum (0)
-                  : FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) > 0
+                 (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) > 0
                   ? make_fixnum (FRAME_CONFIG_SCROLL_BAR_HEIGHT (f))
                   /* nil means "use default height"
                      for non-toolkit scroll bar.  */
                   : Qnil));
-  /* FRAME_X_WINDOW is not guaranteed to return an integer.  E.g., on
-     MS-Windows it returns a value whose type is HANDLE, which is
-     actually a pointer.  Explicit casting avoids compiler
+  /* FRAME_NATIVE_WINDOW is not guaranteed to return an integer.
+     E.g., on MS-Windows it returns a value whose type is HANDLE,
+     which is actually a pointer.  Explicit casting avoids compiler
      warnings.  */
-  w = (uintptr_t) FRAME_X_WINDOW (f);
+  w = (uintptr_t) FRAME_NATIVE_WINDOW (f);
   store_in_alist (alistptr, Qwindow_id,
                  make_formatted_string (buf, "%"pMu, w));
 #ifdef HAVE_X_WINDOWS
@@ -4144,10 +4266,10 @@ x_report_frame_params (struct frame *f, Lisp_Object 
*alistptr)
   store_in_alist (alistptr, Qdisplay,
                  XCAR (FRAME_DISPLAY_INFO (f)->name_list_element));
 
-  if (FRAME_X_OUTPUT (f)->parent_desc == FRAME_DISPLAY_INFO (f)->root_window)
+  if (FRAME_OUTPUT_DATA (f)->parent_desc == FRAME_DISPLAY_INFO 
(f)->root_window)
     tem = Qnil;
   else
-    tem = make_fixed_natnum ((uintptr_t) FRAME_X_OUTPUT (f)->parent_desc);
+    tem = make_fixed_natnum ((uintptr_t) FRAME_OUTPUT_DATA (f)->parent_desc);
   store_in_alist (alistptr, Qexplicit_name, (f->explicit_name ? Qt : Qnil));
   store_in_alist (alistptr, Qparent_id, tem);
   store_in_alist (alistptr, Qtool_bar_position, FRAME_TOOL_BAR_POSITION (f));
@@ -4158,7 +4280,7 @@ x_report_frame_params (struct frame *f, Lisp_Object 
*alistptr)
    the previous value of that parameter, NEW_VALUE is the new value. */
 
 void
-x_set_fullscreen (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
+gui_set_fullscreen (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
 {
   if (NILP (new_value))
     f->want_fullscreen = FULLSCREEN_NONE;
@@ -4180,7 +4302,7 @@ x_set_fullscreen (struct frame *f, Lisp_Object new_value, 
Lisp_Object old_value)
    the previous value of that parameter, NEW_VALUE is the new value.  */
 
 void
-x_set_line_spacing (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
+gui_set_line_spacing (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
 {
   if (NILP (new_value))
     f->extra_line_spacing = 0;
@@ -4206,7 +4328,7 @@ x_set_line_spacing (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_valu
    the previous value of that parameter, NEW_VALUE is the new value.  */
 
 void
-x_set_screen_gamma (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
+gui_set_screen_gamma (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
 {
   Lisp_Object bgcolor;
 
@@ -4236,7 +4358,7 @@ x_set_screen_gamma (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_valu
 
 
 void
-x_set_font (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+gui_set_font (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   Lisp_Object font_object;
   int fontset = -1;
@@ -4306,8 +4428,8 @@ x_set_font (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval)
          /* SPEC might be nil because ASCII_FONT's name doesn't parse
             according to stupid XLFD rules, which, for example,
             disallow font names that include a dash followed by a
-            number.  So in those cases we simply request x_new_font
-            below to generate a new fontset.  */
+            number.  So in those cases we simply call
+            set_new_font_hook below to generate a new fontset.  */
          if (NILP (spec) || ! font_match_p (spec, font_object))
            fontset = -1;
        }
@@ -4318,7 +4440,8 @@ x_set_font (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval)
   if (! NILP (Fequal (font_object, oldval)))
     return;
 
-  x_new_font (f, font_object, fontset);
+  if (FRAME_TERMINAL (f)->set_new_font_hook)
+    FRAME_TERMINAL (f)->set_new_font_hook (f, font_object, fontset);
   store_frame_param (f, Qfont, arg);
 #ifdef HAVE_X_WINDOWS
   store_frame_param (f, Qfont_parameter, font_param);
@@ -4350,7 +4473,7 @@ x_set_font (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval)
 
 
 void
-x_set_font_backend (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
+gui_set_font_backend (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
 {
   if (! NILP (new_value)
       && !CONSP (new_value))
@@ -4398,14 +4521,14 @@ x_set_font_backend (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_valu
       Lisp_Object frame;
 
       XSETFRAME (frame, f);
-      x_set_font (f, Fframe_parameter (frame, Qfont), Qnil);
+      gui_set_font (f, Fframe_parameter (frame, Qfont), Qnil);
       face_change = true;
       windows_or_buffers_changed = 18;
     }
 }
 
 void
-x_set_left_fringe (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
+gui_set_left_fringe (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
 {
   int unit = FRAME_COLUMN_WIDTH (f);
   int old_width = FRAME_LEFT_FRINGE_WIDTH (f);
@@ -4420,7 +4543,7 @@ x_set_left_fringe (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_value
       f->fringe_cols /* Round up.  */
        = (new_width + FRAME_RIGHT_FRINGE_WIDTH (f) + unit - 1) / unit;
 
-      if (FRAME_X_WINDOW (f) != 0)
+      if (FRAME_NATIVE_WINDOW (f) != 0)
        adjust_frame_size (f, -1, -1, 3, 0, Qleft_fringe);
 
       SET_FRAME_GARBAGED (f);
@@ -4429,7 +4552,7 @@ x_set_left_fringe (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_value
 
 
 void
-x_set_right_fringe (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
+gui_set_right_fringe (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
 {
   int unit = FRAME_COLUMN_WIDTH (f);
   int old_width = FRAME_RIGHT_FRINGE_WIDTH (f);
@@ -4444,7 +4567,7 @@ x_set_right_fringe (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_valu
       f->fringe_cols /* Round up.  */
        = (new_width + FRAME_LEFT_FRINGE_WIDTH (f) + unit - 1) / unit;
 
-      if (FRAME_X_WINDOW (f) != 0)
+      if (FRAME_NATIVE_WINDOW (f) != 0)
        adjust_frame_size (f, -1, -1, 3, 0, Qright_fringe);
 
       SET_FRAME_GARBAGED (f);
@@ -4453,21 +4576,21 @@ x_set_right_fringe (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_valu
 
 
 void
-x_set_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+gui_set_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   CHECK_TYPE_RANGED_INTEGER (int, arg);
 
   if (XFIXNUM (arg) == f->border_width)
     return;
 
-  if (FRAME_X_WINDOW (f) != 0)
+  if (FRAME_NATIVE_WINDOW (f) != 0)
     error ("Cannot change the border width of a frame");
 
   f->border_width = XFIXNUM (arg);
 }
 
 void
-x_set_right_divider_width (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval)
+gui_set_right_divider_width (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval)
 {
   int old = FRAME_RIGHT_DIVIDER_WIDTH (f);
   CHECK_TYPE_RANGED_INTEGER (int, arg);
@@ -4482,7 +4605,7 @@ x_set_right_divider_width (struct frame *f, Lisp_Object 
arg, Lisp_Object oldval)
 }
 
 void
-x_set_bottom_divider_width (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval)
+gui_set_bottom_divider_width (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval)
 {
   int old = FRAME_BOTTOM_DIVIDER_WIDTH (f);
   CHECK_TYPE_RANGED_INTEGER (int, arg);
@@ -4497,7 +4620,7 @@ x_set_bottom_divider_width (struct frame *f, Lisp_Object 
arg, Lisp_Object oldval
 }
 
 void
-x_set_visibility (struct frame *f, Lisp_Object value, Lisp_Object oldval)
+gui_set_visibility (struct frame *f, Lisp_Object value, Lisp_Object oldval)
 {
   Lisp_Object frame;
   XSETFRAME (frame, f);
@@ -4511,25 +4634,25 @@ x_set_visibility (struct frame *f, Lisp_Object value, 
Lisp_Object oldval)
 }
 
 void
-x_set_autoraise (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+gui_set_autoraise (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   f->auto_raise = !NILP (arg);
 }
 
 void
-x_set_autolower (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+gui_set_autolower (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   f->auto_lower = !NILP (arg);
 }
 
 void
-x_set_unsplittable (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+gui_set_unsplittable (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   f->no_split = !NILP (arg);
 }
 
 void
-x_set_vertical_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval)
+gui_set_vertical_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval)
 {
   if ((EQ (arg, Qleft) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_RIGHT (f))
       || (EQ (arg, Qright) && FRAME_HAS_VERTICAL_SCROLL_BARS_ON_LEFT (f))
@@ -4549,11 +4672,11 @@ x_set_vertical_scroll_bars (struct frame *f, 
Lisp_Object arg, Lisp_Object oldval
           ? vertical_scroll_bar_right
           : vertical_scroll_bar_none);
 
-      /* We set this parameter before creating the X window for the
-        frame, so we can get the geometry right from the start.
+      /* We set this parameter before creating the native window for
+        the frame, so we can get the geometry right from the start.
         However, if the window hasn't been created yet, we shouldn't
-        call x_set_window_size.  */
-      if (FRAME_X_WINDOW (f))
+        call set_window_size_hook.  */
+      if (FRAME_NATIVE_WINDOW (f))
        adjust_frame_size (f, -1, -1, 3, 0, Qvertical_scroll_bars);
 
       SET_FRAME_GARBAGED (f);
@@ -4561,7 +4684,7 @@ x_set_vertical_scroll_bars (struct frame *f, Lisp_Object 
arg, Lisp_Object oldval
 }
 
 void
-x_set_horizontal_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval)
+gui_set_horizontal_scroll_bars (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval)
 {
 #if USE_HORIZONTAL_SCROLL_BARS
   if ((NILP (arg) && FRAME_HAS_HORIZONTAL_SCROLL_BARS (f))
@@ -4569,11 +4692,11 @@ x_set_horizontal_scroll_bars (struct frame *f, 
Lisp_Object arg, Lisp_Object oldv
     {
       f->horizontal_scroll_bars = NILP (arg) ? false : true;
 
-      /* We set this parameter before creating the X window for the
-        frame, so we can get the geometry right from the start.
+      /* We set this parameter before creating the native window for
+        the frame, so we can get the geometry right from the start.
         However, if the window hasn't been created yet, we shouldn't
-        call x_set_window_size.  */
-      if (FRAME_X_WINDOW (f))
+        call set_window_size_hook.  */
+      if (FRAME_NATIVE_WINDOW (f))
        adjust_frame_size (f, -1, -1, 3, 0, Qhorizontal_scroll_bars);
 
       SET_FRAME_GARBAGED (f);
@@ -4582,25 +4705,26 @@ x_set_horizontal_scroll_bars (struct frame *f, 
Lisp_Object arg, Lisp_Object oldv
 }
 
 void
-x_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+gui_set_scroll_bar_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   int unit = FRAME_COLUMN_WIDTH (f);
 
-  if (NILP (arg))
+  if (RANGED_FIXNUMP (1, arg, INT_MAX)
+      && XFIXNAT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f))
     {
-      x_set_scroll_bar_default_width (f);
-
-      if (FRAME_X_WINDOW (f))
+      FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = XFIXNAT (arg);
+      FRAME_CONFIG_SCROLL_BAR_COLS (f) = (XFIXNAT (arg) + unit - 1) / unit;
+      if (FRAME_NATIVE_WINDOW (f))
        adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width);
 
       SET_FRAME_GARBAGED (f);
     }
-  else if (RANGED_FIXNUMP (1, arg, INT_MAX)
-          && XFIXNAT (arg) != FRAME_CONFIG_SCROLL_BAR_WIDTH (f))
+  else
     {
-      FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = XFIXNAT (arg);
-      FRAME_CONFIG_SCROLL_BAR_COLS (f) = (XFIXNAT (arg) + unit - 1) / unit;
-      if (FRAME_X_WINDOW (f))
+      if (FRAME_TERMINAL (f)->set_scroll_bar_default_width_hook)
+        FRAME_TERMINAL (f)->set_scroll_bar_default_width_hook (f);
+
+      if (FRAME_NATIVE_WINDOW (f))
        adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_width);
 
       SET_FRAME_GARBAGED (f);
@@ -4611,26 +4735,27 @@ x_set_scroll_bar_width (struct frame *f, Lisp_Object 
arg, Lisp_Object oldval)
 }
 
 void
-x_set_scroll_bar_height (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+gui_set_scroll_bar_height (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval)
 {
 #if USE_HORIZONTAL_SCROLL_BARS
   int unit = FRAME_LINE_HEIGHT (f);
 
-  if (NILP (arg))
+  if (RANGED_FIXNUMP (1, arg, INT_MAX)
+      && XFIXNAT (arg) != FRAME_CONFIG_SCROLL_BAR_HEIGHT (f))
     {
-      x_set_scroll_bar_default_height (f);
-
-      if (FRAME_X_WINDOW (f))
+      FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) = XFIXNAT (arg);
+      FRAME_CONFIG_SCROLL_BAR_LINES (f) = (XFIXNAT (arg) + unit - 1) / unit;
+      if (FRAME_NATIVE_WINDOW (f))
        adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_height);
 
       SET_FRAME_GARBAGED (f);
     }
-  else if (RANGED_FIXNUMP (1, arg, INT_MAX)
-          && XFIXNAT (arg) != FRAME_CONFIG_SCROLL_BAR_HEIGHT (f))
+  else
     {
-      FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) = XFIXNAT (arg);
-      FRAME_CONFIG_SCROLL_BAR_LINES (f) = (XFIXNAT (arg) + unit - 1) / unit;
-      if (FRAME_X_WINDOW (f))
+      if (FRAME_TERMINAL (f)->set_scroll_bar_default_height_hook)
+        FRAME_TERMINAL (f)->set_scroll_bar_default_height_hook (f);
+
+      if (FRAME_NATIVE_WINDOW (f))
        adjust_frame_size (f, -1, -1, 3, 0, Qscroll_bar_height);
 
       SET_FRAME_GARBAGED (f);
@@ -4642,7 +4767,7 @@ x_set_scroll_bar_height (struct frame *f, Lisp_Object 
arg, Lisp_Object oldval)
 }
 
 void
-x_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+gui_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   double alpha = 1.0;
   double newval[2];
@@ -4683,25 +4808,24 @@ x_set_alpha (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
   for (i = 0; i < 2; i++)
     f->alpha[i] = newval[i];
 
-#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) || defined (NS_IMPL_COCOA)
-  block_input ();
-  x_set_frame_alpha (f);
-  unblock_input ();
-#endif
-
-  return;
+  if (FRAME_TERMINAL (f)->set_frame_alpha_hook)
+    {
+      block_input ();
+      FRAME_TERMINAL (f)->set_frame_alpha_hook (f);
+      unblock_input ();
+    }
 }
 
 
 /**
- * x_set_no_special_glyphs:
+ * gui_set_no_special_glyphs:
  *
  * Set frame F's `no-special-glyphs' parameter which, if non-nil,
  * suppresses the display of truncation and continuation glyphs
  * outside fringes.
  */
 void
-x_set_no_special_glyphs (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
+gui_set_no_special_glyphs (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
 {
   if (!EQ (new_value, old_value))
     FRAME_NO_SPECIAL_GLYPHS (f) = !NILP (new_value);
@@ -4713,7 +4837,8 @@ x_set_no_special_glyphs (struct frame *f, Lisp_Object 
new_value, Lisp_Object old
 /* Non-zero if mouse is grabbed on DPYINFO
    and we know the frame where it is.  */
 
-bool x_mouse_grabbed (Display_Info *dpyinfo)
+bool
+gui_mouse_grabbed (Display_Info *dpyinfo)
 {
   return (dpyinfo->grabbed
          && dpyinfo->last_mouse_frame
@@ -4724,7 +4849,7 @@ bool x_mouse_grabbed (Display_Info *dpyinfo)
    on DPYINFO using saved frame and mouse position.  */
 
 void
-x_redo_mouse_highlight (Display_Info *dpyinfo)
+gui_redo_mouse_highlight (Display_Info *dpyinfo)
 {
   if (dpyinfo->last_mouse_motion_frame
       && FRAME_LIVE_P (dpyinfo->last_mouse_motion_frame))
@@ -4806,11 +4931,13 @@ validate_x_resource_name (void)
     }
 }
 
-/* Get specified attribute from resource database RDB.
+/* Get a GUI resource, like Fx_get_resource, but for display DPYINFO.
    See Fx_get_resource below for other parameters.  */
 
-static Lisp_Object
-xrdb_get_resource (XrmDatabase rdb, Lisp_Object attribute, Lisp_Object class, 
Lisp_Object component, Lisp_Object subclass)
+Lisp_Object
+gui_display_get_resource (Display_Info *dpyinfo, Lisp_Object attribute,
+                          Lisp_Object class, Lisp_Object component,
+                          Lisp_Object subclass)
 {
   CHECK_STRING (attribute);
   CHECK_STRING (class);
@@ -4863,7 +4990,10 @@ xrdb_get_resource (XrmDatabase rdb, Lisp_Object 
attribute, Lisp_Object class, Li
   *nz++ = '.';
   lispstpcpy (nz, attribute);
 
-  char *value = x_get_string_resource (rdb, name_key, class_key);
+  const char *value =
+    dpyinfo->terminal->get_string_resource_hook (&dpyinfo->rdb,
+                                                 name_key,
+                                                 class_key);
   SAFE_FREE();
 
   if (value && *value)
@@ -4888,28 +5018,17 @@ and the class is `Emacs.CLASS.SUBCLASS'.  */)
 {
   check_window_system (NULL);
 
-  return xrdb_get_resource (check_x_display_info (Qnil)->xrdb,
-                           attribute, class, component, subclass);
-}
-
-/* Get an X resource, like Fx_get_resource, but for display DPYINFO.  */
-
-Lisp_Object
-display_x_get_resource (Display_Info *dpyinfo, Lisp_Object attribute,
-                       Lisp_Object class, Lisp_Object component,
-                       Lisp_Object subclass)
-{
-  return xrdb_get_resource (dpyinfo->xrdb,
-                           attribute, class, component, subclass);
+  return gui_display_get_resource (check_x_display_info (Qnil),
+                                   attribute, class, component, subclass);
 }
 
 #if defined HAVE_X_WINDOWS && !defined USE_X_TOOLKIT && !defined USE_GTK
 /* Used when C code wants a resource value.  */
 /* Called from oldXMenu/Create.c.  */
-char *
+const char *
 x_get_resource_string (const char *attribute, const char *class)
 {
-  char *result;
+  const char *result;
   struct frame *sf = SELECTED_FRAME ();
   ptrdiff_t invocation_namelen = SBYTES (Vinvocation_name);
   USE_SAFE_ALLOCA;
@@ -4926,7 +5045,7 @@ x_get_resource_string (const char *attribute, const char 
*class)
   esprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute);
   sprintf (class_key, "%s.%s", EMACS_CLASS, class);
 
-  result = x_get_string_resource (FRAME_DISPLAY_INFO (sf)->xrdb,
+  result = x_get_string_resource (&FRAME_DISPLAY_INFO (sf)->rdb,
                                  name_key, class_key);
   SAFE_FREE ();
   return result;
@@ -4935,18 +5054,21 @@ x_get_resource_string (const char *attribute, const 
char *class)
 
 /* Return the value of parameter PARAM.
 
-   First search ALIST, then Vdefault_frame_alist, then the X defaults
-   database, using ATTRIBUTE as the attribute name and CLASS as its class.
+   First search ALIST, then Vdefault_frame_alist, then the GUI
+   resource database, using ATTRIBUTE as the attribute name and CLASS
+   as its class.
 
    Convert the resource to the type specified by desired_type.
 
    If no default is specified, return Qunbound.  If you call
-   x_get_arg, make sure you deal with Qunbound in a reasonable way,
-   and don't let it get stored in any Lisp-visible variables!  */
+   gui_display_get_arg, make sure you deal with Qunbound in a
+   reasonable way, and don't let it get stored in any Lisp-visible
+   variables!  */
 
 Lisp_Object
-x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object param,
-          const char *attribute, const char *class, enum resource_types type)
+gui_display_get_arg (Display_Info *dpyinfo, Lisp_Object alist, Lisp_Object 
param,
+                     const char *attribute, const char *class,
+                     enum resource_types type)
 {
   Lisp_Object tem;
 
@@ -4976,7 +5098,7 @@ x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, 
Lisp_Object param,
        {
          AUTO_STRING (at, attribute);
          AUTO_STRING (cl, class);
-         tem = display_x_get_resource (dpyinfo, at, cl, Qnil, Qnil);
+         tem = gui_display_get_resource (dpyinfo, at, cl, Qnil, Qnil);
 
          if (NILP (tem))
            return Qunbound;
@@ -5043,26 +5165,26 @@ x_get_arg (Display_Info *dpyinfo, Lisp_Object alist, 
Lisp_Object param,
 }
 
 static Lisp_Object
-x_frame_get_arg (struct frame *f, Lisp_Object alist, Lisp_Object param,
-                const char *attribute, const char *class,
-                enum resource_types type)
+gui_frame_get_arg (struct frame *f, Lisp_Object alist, Lisp_Object param,
+                   const char *attribute, const char *class,
+                   enum resource_types type)
 {
-  return x_get_arg (FRAME_DISPLAY_INFO (f),
-                   alist, param, attribute, class, type);
+  return gui_display_get_arg (FRAME_DISPLAY_INFO (f),
+                              alist, param, attribute, class, type);
 }
 
-/* Like x_frame_get_arg, but also record the value in f->param_alist.  */
+/* Like gui_frame_get_arg, but also record the value in f->param_alist.  */
 
 Lisp_Object
-x_frame_get_and_record_arg (struct frame *f, Lisp_Object alist,
-                           Lisp_Object param,
-                           const char *attribute, const char *class,
-                           enum resource_types type)
+gui_frame_get_and_record_arg (struct frame *f, Lisp_Object alist,
+                              Lisp_Object param,
+                              const char *attribute, const char *class,
+                              enum resource_types type)
 {
   Lisp_Object value;
 
-  value = x_get_arg (FRAME_DISPLAY_INFO (f), alist, param,
-                    attribute, class, type);
+  value = gui_display_get_arg (FRAME_DISPLAY_INFO (f), alist, param,
+                               attribute, class, type);
   if (! NILP (value) && ! EQ (value, Qunbound))
     store_frame_param (f, param, value);
 
@@ -5077,17 +5199,17 @@ x_frame_get_and_record_arg (struct frame *f, 
Lisp_Object alist,
    If that is not found either, use the value DEFLT.  */
 
 Lisp_Object
-x_default_parameter (struct frame *f, Lisp_Object alist, Lisp_Object prop,
-                    Lisp_Object deflt, const char *xprop, const char *xclass,
-                    enum resource_types type)
+gui_default_parameter (struct frame *f, Lisp_Object alist, Lisp_Object prop,
+                       Lisp_Object deflt, const char *xprop, const char 
*xclass,
+                       enum resource_types type)
 {
   Lisp_Object tem;
 
-  tem = x_frame_get_arg (f, alist, prop, xprop, xclass, type);
+  tem = gui_frame_get_arg (f, alist, prop, xprop, xclass, type);
   if (EQ (tem, Qunbound))
     tem = deflt;
   AUTO_FRAME_ARG (arg, prop, tem);
-  x_set_frame_parameters (f, arg);
+  gui_set_frame_parameters (f, arg);
   return tem;
 }
 
@@ -5262,7 +5384,8 @@ On Nextstep, this just calls `ns-parse-geometry'.  */)
 #define DEFAULT_COLS 80
 
 long
-x_figure_window_size (struct frame *f, Lisp_Object parms, bool toolbar_p, int 
*x_width, int *x_height)
+gui_figure_window_size (struct frame *f, Lisp_Object parms, bool toolbar_p,
+                        int *x_width, int *x_height)
 {
   Lisp_Object height, width, user_size, top, left, user_position;
   long window_prompting = 0;
@@ -5295,9 +5418,9 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, 
bool toolbar_p, int *x
        {
          int margin, relief;
 
-         relief = (tool_bar_button_relief >= 0
-                   ? tool_bar_button_relief
-                   : DEFAULT_TOOL_BAR_BUTTON_RELIEF);
+         relief = (tool_bar_button_relief < 0
+                   ? DEFAULT_TOOL_BAR_BUTTON_RELIEF
+                   : min (tool_bar_button_relief, 1000000));
 
          if (RANGED_FIXNUMP (1, Vtool_bar_button_margin, INT_MAX))
            margin = XFIXNAT (Vtool_bar_button_margin);
@@ -5316,8 +5439,8 @@ x_figure_window_size (struct frame *f, Lisp_Object parms, 
bool toolbar_p, int *x
      override what we specify below.  */
   f->new_width = f->new_height = 0;
 
-  height = x_get_arg (dpyinfo, parms, Qheight, 0, 0, RES_TYPE_NUMBER);
-  width = x_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER);
+  height = gui_display_get_arg (dpyinfo, parms, Qheight, 0, 0, 
RES_TYPE_NUMBER);
+  width = gui_display_get_arg (dpyinfo, parms, Qwidth, 0, 0, RES_TYPE_NUMBER);
   if (!EQ (width, Qunbound) || !EQ (height, Qunbound))
     {
       if (!EQ (width, Qunbound))
@@ -5394,16 +5517,18 @@ x_figure_window_size (struct frame *f, Lisp_Object 
parms, bool toolbar_p, int *x
            }
        }
 
-      user_size = x_get_arg (dpyinfo, parms, Quser_size, 0, 0, 
RES_TYPE_NUMBER);
+      user_size = gui_display_get_arg (dpyinfo, parms, Quser_size, 0, 0,
+                                       RES_TYPE_NUMBER);
       if (!NILP (user_size) && !EQ (user_size, Qunbound))
        window_prompting |= USSize;
       else
        window_prompting |= PSize;
     }
 
-  top = x_get_arg (dpyinfo, parms, Qtop, 0, 0, RES_TYPE_NUMBER);
-  left = x_get_arg (dpyinfo, parms, Qleft, 0, 0, RES_TYPE_NUMBER);
-  user_position = x_get_arg (dpyinfo, parms, Quser_position, 0, 0, 
RES_TYPE_NUMBER);
+  top = gui_display_get_arg (dpyinfo, parms, Qtop, 0, 0, RES_TYPE_NUMBER);
+  left = gui_display_get_arg (dpyinfo, parms, Qleft, 0, 0, RES_TYPE_NUMBER);
+  user_position = gui_display_get_arg (dpyinfo, parms, Quser_position, 0, 0,
+                                       RES_TYPE_NUMBER);
   if (! EQ (top, Qunbound) || ! EQ (left, Qunbound))
     {
       if (EQ (top, Qminus))
@@ -5544,8 +5669,8 @@ selected frame.  This is useful when 
`make-pointer-invisible' is set.  */)
 
 #ifdef HAVE_WINDOW_SYSTEM
 
-# if (defined HAVE_NS \
-      || (!defined USE_GTK && (defined HAVE_XINERAMA || defined HAVE_XRANDR)))
+# if (defined USE_GTK || defined HAVE_NS || defined HAVE_XINERAMA \
+      || defined HAVE_XRANDR)
 void
 free_monitors (struct MonitorInfo *monitors, int n_monitors)
 {
@@ -5610,6 +5735,26 @@ make_monitor_attribute_list (struct MonitorInfo 
*monitors,
                                Initialization
  ***********************************************************************/
 
+static void init_frame_once_for_pdumper (void);
+
+void
+init_frame_once (void)
+{
+  staticpro (&Vframe_list);
+  staticpro (&selected_frame);
+  PDUMPER_IGNORE (last_nonminibuf_frame);
+  Vframe_list = Qnil;
+  selected_frame = Qnil;
+  pdumper_do_now_and_after_load (init_frame_once_for_pdumper);
+}
+
+static void
+init_frame_once_for_pdumper (void)
+{
+  PDUMPER_RESET_LV (Vframe_list, Qnil);
+  PDUMPER_RESET_LV (selected_frame, Qnil);
+}
+
 void
 syms_of_frame (void)
 {
@@ -5941,6 +6086,19 @@ setting this variable does not change that frame's 
previous association.
 
 This variable is local to the current terminal and cannot be buffer-local.  
*/);
 
+  DEFVAR_LISP ("resize-mini-frames", resize_mini_frames,
+    doc: /* Non-nil means resize minibuffer-only frames automatically.
+If this is nil, do not resize minibuffer-only frames automatically.
+
+If this is a function, call that function with the minibuffer-only
+frame that shall be resized as sole argument.  The buffer of the root
+window of that frame is the buffer whose text will be eventually shown
+in the minibuffer window.
+
+Any other non-nil value means to resize minibuffer-only frames by
+calling `fit-frame-to-buffer'.  */);
+  resize_mini_frames = Qnil;
+
   DEFVAR_LISP ("focus-follows-mouse", focus_follows_mouse,
               doc: /* Non-nil if window system changes focus when you move the 
mouse.
 You should set this variable to tell Emacs how your window manager
@@ -6091,16 +6249,15 @@ making the child frame unresponsive to user actions, 
the default is to
 iconify the top level frame instead.  */);
   iconify_child_frame = Qiconify_top_level;
 
-  staticpro (&Vframe_list);
-
   defsubr (&Sframep);
   defsubr (&Sframe_live_p);
   defsubr (&Swindow_system);
   defsubr (&Sframe_windows_min_size);
   defsubr (&Smake_terminal_frame);
-  defsubr (&Shandle_switch_frame);
   defsubr (&Sselect_frame);
+  defsubr (&Shandle_switch_frame);
   defsubr (&Sselected_frame);
+  defsubr (&Sold_selected_frame);
   defsubr (&Sframe_list);
   defsubr (&Sframe_parent);
   defsubr (&Sframe_ancestor_p);
@@ -6153,6 +6310,8 @@ iconify the top level frame instead.  */);
   defsubr (&Sframe_position);
   defsubr (&Sset_frame_position);
   defsubr (&Sframe_pointer_visible_p);
+  defsubr (&Sframe_window_state_change);
+  defsubr (&Sset_frame_window_state_change);
 
 #ifdef HAVE_WINDOW_SYSTEM
   defsubr (&Sx_get_resource);
diff --git a/src/frame.h b/src/frame.h
index ad7376a..b8aed82 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -1,5 +1,5 @@
 /* Define frame-object for GNU Emacs.
-   Copyright (C) 1993-1994, 1999-2018 Free Software Foundation, Inc.
+   Copyright (C) 1993-1994, 1999-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -125,6 +125,10 @@ struct frame
      The selected window of the selected frame is Emacs's selected window.  */
   Lisp_Object selected_window;
 
+  /* This frame's selected window when run_window_change_functions was
+     called the last time on this frame.  */
+  Lisp_Object old_selected_window;
+
   /* This frame's minibuffer window.
      Most frames have their own minibuffer windows,
      but only the selected frame's minibuffer window
@@ -177,7 +181,7 @@ struct frame
   Lisp_Object menu_bar_window;
 #endif
 
-#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
   /* A window used to display the tool-bar of a frame.  */
   Lisp_Object tool_bar_window;
 
@@ -186,9 +190,6 @@ struct frame
   Lisp_Object current_tool_bar_string;
 #endif
 
-  /* Desired and current tool-bar items.  */
-  Lisp_Object tool_bar_items;
-
 #ifdef USE_GTK
   /* Where tool bar is, can be left, right, top or bottom.
      Except with GTK, the only supported position is `top'.  */
@@ -200,12 +201,14 @@ struct frame
   Lisp_Object font_data;
 #endif
 
-  /* Beyond here, there should be no more Lisp_Object components.  */
+  /* Desired and current tool-bar items.  */
+  Lisp_Object tool_bar_items;
+  /* tool_bar_items should be the last Lisp_Object member.  */
 
   /* Cache of realized faces.  */
   struct face_cache *face_cache;
 
-#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
   /* Tool-bar item index of the item on which a mouse button was pressed.  */
   int last_tool_bar_item;
 #endif
@@ -253,13 +256,13 @@ struct frame
   /* Set to true when current redisplay has updated frame.  */
   bool_bf updated_p : 1;
 
-#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
   /* Set to true to minimize tool-bar height even when
      auto-resize-tool-bar is set to grow-only.  */
   bool_bf minimize_tool_bar_window_p : 1;
 #endif
 
-#if defined (USE_GTK) || defined (HAVE_NS)
+#ifdef HAVE_EXT_TOOL_BAR
   /* True means using a tool bar that comes from the toolkit.  */
   bool_bf external_tool_bar : 1;
 #endif
@@ -274,9 +277,8 @@ struct frame
   /* True if it needs to be redisplayed.  */
   bool_bf redisplay : 1;
 
-#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI)    \
-    || defined (HAVE_NS) || defined (USE_GTK)
-  /* True means using a menu bar that comes from the X toolkit.  */
+#ifdef HAVE_EXT_MENU_BAR
+  /* True means using a menu bar that comes from the toolkit.  */
   bool_bf external_menu_bar : 1;
 #endif
 
@@ -321,9 +323,18 @@ struct frame
      cleared.  */
   bool_bf explicit_name : 1;
 
-  /* True if configuration of windows on this frame has changed since
-     last call of run_window_size_change_functions.  */
-  bool_bf window_configuration_changed : 1;
+  /* True if at least one window on this frame changed since the last
+     call of run_window_change_functions.  Changes are either "state
+     changes" (a window has been created, deleted or got assigned
+     another buffer) or "size changes" (the total or body size of a
+     window changed).  run_window_change_functions exits early unless
+     either this flag is true or a window selection happened on this
+     frame.  */
+  bool_bf window_change : 1;
+
+  /* True if running window state change functions has been explicitly
+     requested for this frame since last redisplay.  */
+  bool_bf window_state_change : 1;
 
   /* True if the mouse has moved on this display device
      since the last time we checked.  */
@@ -386,9 +397,9 @@ struct frame
      in pixels.  */
   bool_bf new_pixelwise : 1;
 
-  /* True means x_set_window_size requests can be processed for this
-     frame.  */
-  bool_bf can_x_set_window_size : 1;
+  /* True means set_window_size_hook requests can be processed for
+     this frame.  */
+  bool_bf can_set_window_size : 1;
 
   /* Set to true after this frame was made by `make-frame'.  */
   bool_bf after_make_frame : 1;
@@ -404,8 +415,26 @@ struct frame
   /* Non-zero if this frame's faces need to be recomputed.  */
   bool_bf face_change : 1;
 
+  /* Non-zero if this frame's image cache cannot be freed because the
+     frame is in the process of being redisplayed.  */
+  bool_bf inhibit_clear_image_cache : 1;
+
   /* Bitfield area ends here.  */
 
+  /* This frame's change stamp, set the last time window change
+     functions were run for this frame.  Should never be 0 because
+     that's the change stamp of a new window.  A window was not on a
+     frame the last run_window_change_functions was called on it if
+     it's change stamp differs from that of its frame.  */
+  int change_stamp;
+
+  /* This frame's number of windows, set the last time window change
+     functions were run for this frame.  Should never be 0 even for
+     minibuffer-only frames.  If no window has been added, this allows
+     to detect whether a window was deleted on this frame since the
+     last time run_window_change_functions was called on it.  */
+  ptrdiff_t number_of_windows;
+
   /* Number of lines (rounded up) of tool bar.  REMOVE THIS  */
   int tool_bar_lines;
 
@@ -553,7 +582,7 @@ struct frame
   int config_scroll_bar_lines;
 
   /* The baud rate that was used to calculate costs for this frame.  */
-  int cost_calculation_baud_rate;
+  intmax_t cost_calculation_baud_rate;
 
   /* Frame opacity
      alpha[0]: alpha transparency of the active frame
@@ -662,6 +691,11 @@ fset_selected_window (struct frame *f, Lisp_Object val)
   f->selected_window = val;
 }
 INLINE void
+fset_old_selected_window (struct frame *f, Lisp_Object val)
+{
+  f->old_selected_window = val;
+}
+INLINE void
 fset_title (struct frame *f, Lisp_Object val)
 {
   f->title = val;
@@ -678,7 +712,7 @@ fset_tool_bar_position (struct frame *f, Lisp_Object val)
   f->tool_bar_position = val;
 }
 #endif /* USE_GTK */
-#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
 INLINE void
 fset_tool_bar_window (struct frame *f, Lisp_Object val)
 {
@@ -752,8 +786,8 @@ default_pixels_per_inch_y (void)
 #define FRAME_NS_P(f) ((f)->output_method == output_ns)
 #endif
 
-/* FRAME_WINDOW_P tests whether the frame is a window, and is
-   defined to be the predicate for the window system being used.  */
+/* FRAME_WINDOW_P tests whether the frame is a graphical window system
+   frame.  */
 
 #ifdef HAVE_X_WINDOWS
 #define FRAME_WINDOW_P(f) FRAME_X_P (f)
@@ -846,7 +880,7 @@ default_pixels_per_inch_y (void)
 
 /* True if this frame should display a tool bar
    in a way that does not use any text lines.  */
-#if defined (USE_GTK) || defined (HAVE_NS)
+#ifdef HAVE_EXT_TOOL_BAR
 #define FRAME_EXTERNAL_TOOL_BAR(f) (f)->external_tool_bar
 #else
 #define FRAME_EXTERNAL_TOOL_BAR(f) false
@@ -875,8 +909,7 @@ default_pixels_per_inch_y (void)
 
 /* True if this frame should display a menu bar
    in a way that does not use any text lines.  */
-#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
-     || defined (HAVE_NS) || defined (USE_GTK)
+#ifdef HAVE_EXT_MENU_BAR
 #define FRAME_EXTERNAL_MENU_BAR(f) (f)->external_menu_bar
 #else
 #define FRAME_EXTERNAL_MENU_BAR(f) false
@@ -908,10 +941,13 @@ default_pixels_per_inch_y (void)
    are frozen on frame F.  */
 #define FRAME_WINDOWS_FROZEN(f) (f)->frozen_window_starts
 
-/* True if the frame's window configuration has changed since last call
-   of run_window_size_change_functions.  */
-#define FRAME_WINDOW_CONFIGURATION_CHANGED(f)  \
-  (f)->window_configuration_changed
+/* True if at least one window changed on frame F since the last time
+   window change functions were run on F.  */
+#define FRAME_WINDOW_CHANGE(f) (f)->window_change
+
+/* True if running window state change functions has been explicitly
+   requested for this frame since last redisplay.  */
+#define FRAME_WINDOW_STATE_CHANGE(f) (f)->window_state_change
 
 /* The minibuffer window of frame F, if it has one; otherwise nil.  */
 #define FRAME_MINIBUF_WINDOW(f) f->minibuffer_window
@@ -919,8 +955,10 @@ default_pixels_per_inch_y (void)
 /* The root window of the window tree of frame F.  */
 #define FRAME_ROOT_WINDOW(f) f->root_window
 
-/* The currently selected window of the window tree of frame F.  */
+/* The currently selected window of frame F.  */
 #define FRAME_SELECTED_WINDOW(f) f->selected_window
+/* The old selected window of frame F.  */
+#define FRAME_OLD_SELECTED_WINDOW(f) f->old_selected_window
 
 #define FRAME_INSERT_COST(f) (f)->insert_line_cost
 #define FRAME_DELETE_COST(f) (f)->delete_line_cost
@@ -1215,15 +1253,16 @@ SET_FRAME_VISIBLE (struct frame *f, int v)
   (f)->iconified = (eassert (0 <= (i) && (i) <= 1), (i))
 
 extern Lisp_Object selected_frame;
+extern Lisp_Object old_selected_frame;
 
-#if ! (defined USE_GTK || defined HAVE_NS)
+#ifndef HAVE_EXT_TOOL_BAR
 extern int frame_default_tool_bar_height;
 #endif
 
 #ifdef HAVE_WINDOW_SYSTEM
 # define WINDOW_SYSTEM_RETURN
 #else
-# define WINDOW_SYSTEM_RETURN _Noreturn
+# define WINDOW_SYSTEM_RETURN _Noreturn ATTRIBUTE_COLD
 #endif
 
 extern WINDOW_SYSTEM_RETURN struct frame *
@@ -1505,86 +1544,67 @@ FRAME_BOTTOM_DIVIDER_WIDTH (struct frame *f)
 /* The class of this X application.  */
 #define EMACS_CLASS "Emacs"
 
-extern void x_set_scroll_bar_default_width (struct frame *);
-extern void x_set_scroll_bar_default_height (struct frame *);
-extern void x_set_offset (struct frame *, int, int, int);
-extern void x_wm_set_size_hint (struct frame *f, long flags, bool 
user_position);
-extern Lisp_Object x_new_font (struct frame *, Lisp_Object, int);
-extern void x_set_frame_parameters (struct frame *, Lisp_Object);
-extern void x_set_fullscreen (struct frame *, Lisp_Object, Lisp_Object);
-extern void x_set_line_spacing (struct frame *, Lisp_Object, Lisp_Object);
-extern void x_set_screen_gamma (struct frame *, Lisp_Object, Lisp_Object);
-extern void x_set_font (struct frame *, Lisp_Object, Lisp_Object);
-extern void x_set_font_backend (struct frame *, Lisp_Object, Lisp_Object);
-extern void x_set_left_fringe (struct frame *, Lisp_Object, Lisp_Object);
-extern void x_set_right_fringe (struct frame *, Lisp_Object, Lisp_Object);
-extern void x_set_border_width (struct frame *, Lisp_Object, Lisp_Object);
-extern void x_set_right_divider_width (struct frame *, Lisp_Object,
-                                      Lisp_Object);
-extern void x_set_bottom_divider_width (struct frame *, Lisp_Object,
-                                       Lisp_Object);
-extern void x_set_visibility (struct frame *, Lisp_Object, Lisp_Object);
-extern void x_set_autoraise (struct frame *, Lisp_Object, Lisp_Object);
-extern void x_set_autolower (struct frame *, Lisp_Object, Lisp_Object);
-extern void x_set_unsplittable (struct frame *, Lisp_Object, Lisp_Object);
-extern void x_set_vertical_scroll_bars (struct frame *, Lisp_Object, 
Lisp_Object);
-extern void x_set_horizontal_scroll_bars (struct frame *, Lisp_Object, 
Lisp_Object);
-extern void x_set_scroll_bar_width (struct frame *, Lisp_Object, Lisp_Object);
-extern void x_set_scroll_bar_height (struct frame *, Lisp_Object, Lisp_Object);
-
-extern long x_figure_window_size (struct frame *, Lisp_Object, bool, int *, 
int *);
-
-extern void x_set_alpha (struct frame *, Lisp_Object, Lisp_Object);
-extern void x_set_no_special_glyphs (struct frame *, Lisp_Object, Lisp_Object);
+extern void gui_set_frame_parameters (struct frame *, Lisp_Object);
+extern void gui_set_fullscreen (struct frame *, Lisp_Object, Lisp_Object);
+extern void gui_set_line_spacing (struct frame *, Lisp_Object, Lisp_Object);
+extern void gui_set_screen_gamma (struct frame *, Lisp_Object, Lisp_Object);
+extern void gui_set_font (struct frame *, Lisp_Object, Lisp_Object);
+extern void gui_set_font_backend (struct frame *, Lisp_Object, Lisp_Object);
+extern void gui_set_left_fringe (struct frame *, Lisp_Object, Lisp_Object);
+extern void gui_set_right_fringe (struct frame *, Lisp_Object, Lisp_Object);
+extern void gui_set_border_width (struct frame *, Lisp_Object, Lisp_Object);
+extern void gui_set_right_divider_width (struct frame *, Lisp_Object,
+                                         Lisp_Object);
+extern void gui_set_bottom_divider_width (struct frame *, Lisp_Object,
+                                          Lisp_Object);
+extern void gui_set_visibility (struct frame *, Lisp_Object, Lisp_Object);
+extern void gui_set_autoraise (struct frame *, Lisp_Object, Lisp_Object);
+extern void gui_set_autolower (struct frame *, Lisp_Object, Lisp_Object);
+extern void gui_set_unsplittable (struct frame *, Lisp_Object, Lisp_Object);
+extern void gui_set_vertical_scroll_bars (struct frame *, Lisp_Object, 
Lisp_Object);
+extern void gui_set_horizontal_scroll_bars (struct frame *, Lisp_Object, 
Lisp_Object);
+extern void gui_set_scroll_bar_width (struct frame *, Lisp_Object, 
Lisp_Object);
+extern void gui_set_scroll_bar_height (struct frame *, Lisp_Object, 
Lisp_Object);
+
+extern long gui_figure_window_size (struct frame *, Lisp_Object, bool, int *, 
int *);
+
+extern void gui_set_alpha (struct frame *, Lisp_Object, Lisp_Object);
+extern void gui_set_no_special_glyphs (struct frame *, Lisp_Object, 
Lisp_Object);
 
 extern void validate_x_resource_name (void);
 
-extern Lisp_Object display_x_get_resource (Display_Info *,
-                                          Lisp_Object attribute,
-                                          Lisp_Object class,
-                                          Lisp_Object component,
-                                          Lisp_Object subclass);
+extern Lisp_Object gui_display_get_resource (Display_Info *,
+                                             Lisp_Object attribute,
+                                             Lisp_Object class,
+                                             Lisp_Object component,
+                                             Lisp_Object subclass);
 
 extern void set_frame_menubar (struct frame *f, bool first_time, bool deep_p);
-extern void x_set_window_size (struct frame *f, bool change_gravity,
-                              int width, int height, bool pixelwise);
-extern Lisp_Object x_get_focus_frame (struct frame *);
 extern void frame_set_mouse_pixel_position (struct frame *f, int pix_x, int 
pix_y);
-extern void x_make_frame_visible (struct frame *f);
-extern void x_make_frame_invisible (struct frame *f);
-extern void x_iconify_frame (struct frame *f);
-extern void x_set_frame_alpha (struct frame *f);
-extern void x_activate_menubar (struct frame *);
-extern void x_real_positions (struct frame *, int *, int *);
 extern void free_frame_menubar (struct frame *);
-extern void x_free_frame_resources (struct frame *);
 extern bool frame_ancestor_p (struct frame *af, struct frame *df);
 extern enum internal_border_part frame_internal_border_part (struct frame *f, 
int x, int y);
 
 #if defined HAVE_X_WINDOWS
 extern void x_wm_set_icon_position (struct frame *, int, int);
 #if !defined USE_X_TOOLKIT
-extern char *x_get_resource_string (const char *, const char *);
+extern const char *x_get_resource_string (const char *, const char *);
 #endif
 extern void x_sync (struct frame *);
 #endif /* HAVE_X_WINDOWS */
 
-extern void x_query_colors (struct frame *f, XColor *, int);
-extern void x_focus_frame (struct frame *, bool);
-
 #ifndef HAVE_NS
 
-extern bool x_bitmap_icon (struct frame *, Lisp_Object);
-
 /* Set F's bitmap icon, if specified among F's parameters.  */
 
 INLINE void
-x_set_bitmap_icon (struct frame *f)
+gui_set_bitmap_icon (struct frame *f)
 {
   Lisp_Object obj = assq_no_quit (Qicon_type, f->param_alist);
 
-  if (CONSP (obj) && !NILP (XCDR (obj)))
-    x_bitmap_icon (f, XCDR (obj));
+  if (CONSP (obj) && !NILP (XCDR (obj))
+      && FRAME_TERMINAL (f)->set_bitmap_icon_hook)
+    FRAME_TERMINAL (f)->set_bitmap_icon_hook (f, XCDR (obj));
 }
 
 #endif /* !HAVE_NS */
diff --git a/src/fringe.c b/src/fringe.c
index a1016ad..335a6eb 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -1,5 +1,5 @@
 /* Fringe handling (split from xdisp.c).
-   Copyright (C) 1985-1988, 1993-1995, 1997-2018 Free Software
+   Copyright (C) 1985-1988, 1993-1995, 1997-2019 Free Software
    Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -30,6 +30,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "buffer.h"
 #include "blockinput.h"
 #include "termhooks.h"
+#include "pdumper.h"
 
 /* Fringe bitmaps are represented in three different ways:
 
@@ -719,7 +720,7 @@ static int
 get_logical_fringe_bitmap (struct window *w, Lisp_Object bitmap, int right_p, 
int partial_p)
 {
   Lisp_Object cmap, bm1 = Qnil, bm2 = Qnil, bm;
-  EMACS_INT ln1 = 0, ln2 = 0;
+  ptrdiff_t ln1 = 0, ln2 = 0;
   int ix1 = right_p;
   int ix2 = ix1 + (partial_p ? 2 : 0);
 
@@ -743,7 +744,7 @@ get_logical_fringe_bitmap (struct window *w, Lisp_Object 
bitmap, int right_p, in
            return NO_FRINGE_BITMAP;
          if (CONSP (bm1))
            {
-             ln1 = XFIXNUM (Flength (bm1));
+             ln1 = list_length (bm1);
              if (partial_p)
                {
                  if (ln1 > ix2)
@@ -778,7 +779,7 @@ get_logical_fringe_bitmap (struct window *w, Lisp_Object 
bitmap, int right_p, in
            {
              if (CONSP (bm2))
                {
-                 ln2 = XFIXNUM (Flength (bm2));
+                 ln2 = list_length (bm2);
                  if (partial_p)
                    {
                      if (ln2 > ix2)
@@ -1739,12 +1740,18 @@ mark_fringe_data (void)
 
 /* Initialize this module when Emacs starts.  */
 
+static void init_fringe_once_for_pdumper (void);
+
 void
 init_fringe_once (void)
 {
-  int bt;
+  pdumper_do_now_and_after_load (init_fringe_once_for_pdumper);
+}
 
-  for (bt = NO_FRINGE_BITMAP + 1; bt < MAX_STANDARD_FRINGE_BITMAPS; bt++)
+static void
+init_fringe_once_for_pdumper (void)
+{
+  for (int bt = NO_FRINGE_BITMAP + 1; bt < MAX_STANDARD_FRINGE_BITMAPS; bt++)
     init_fringe_bitmap (bt, &standard_bitmaps[bt], 1);
 }
 
diff --git a/src/ftcrfont.c b/src/ftcrfont.c
index 45e526d..c0f62e0 100644
--- a/src/ftcrfont.c
+++ b/src/ftcrfont.c
@@ -1,5 +1,5 @@
 /* ftcrfont.c -- FreeType font driver on cairo.
-   Copyright (C) 2015-2018 Free Software Foundation, Inc.
+   Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -19,13 +19,16 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include <stdio.h>
+#include <math.h>
 #include <cairo-ft.h>
 
 #include "lisp.h"
 #include "xterm.h"
 #include "blockinput.h"
+#include "composite.h"
 #include "font.h"
 #include "ftfont.h"
+#include "pdumper.h"
 
 #define METRICS_NCOLS_PER_ROW  (128)
 
@@ -72,7 +75,19 @@ ftcrfont_glyph_extents (struct font *font,
   cache = ftcrfont_info->metrics[row] + col;
 
   if (METRICS_STATUS (cache) == METRICS_INVALID)
-    ftfont_text_extents (font, &glyph, 1, cache);
+    {
+      cairo_glyph_t cr_glyph = {.index = glyph};
+      cairo_text_extents_t extents;
+
+      FT_Activate_Size (ftcrfont_info->ft_size_draw);
+      cairo_scaled_font_glyph_extents (ftcrfont_info->cr_scaled_font,
+                                      &cr_glyph, 1, &extents);
+      cache->lbearing = floor (extents.x_bearing);
+      cache->rbearing = ceil (extents.width + extents.x_bearing);
+      cache->width = lround (extents.x_advance);
+      cache->ascent = ceil (- extents.y_bearing);
+      cache->descent = ceil (extents.height + extents.y_bearing);
+    }
 
   if (metrics)
     *metrics = *cache;
@@ -104,31 +119,90 @@ static Lisp_Object
 ftcrfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
 {
   Lisp_Object font_object;
-  struct font *font;
-  struct font_info *ftcrfont_info;
-  FT_Face ft_face;
-  FT_UInt size;
 
-  block_input ();
-  size = XFIXNUM (AREF (entity, FONT_SIZE_INDEX));
+  FT_UInt size = XFIXNUM (AREF (entity, FONT_SIZE_INDEX));
   if (size == 0)
     size = pixel_size;
   font_object = font_build_object (VECSIZE (struct font_info),
                                   Qftcr, entity, size);
+  block_input ();
   font_object = ftfont_open2 (f, entity, pixel_size, font_object);
-  if (NILP (font_object)) return Qnil;
-
-  font = XFONT_OBJECT (font_object);
-  font->driver = &ftcrfont_driver;
-  ftcrfont_info = (struct font_info *) font;
-  ft_face = ftcrfont_info->ft_size->face;
-  FT_New_Size (ft_face, &ftcrfont_info->ft_size_draw);
-  FT_Activate_Size (ftcrfont_info->ft_size_draw);
-  FT_Set_Pixel_Sizes (ft_face, 0, font->pixel_size);
-  ftcrfont_info->cr_font_face =
-    cairo_ft_font_face_create_for_ft_face (ft_face, 0);
-  ftcrfont_info->metrics = NULL;
-  ftcrfont_info->metrics_nrows = 0;
+  if (FONT_OBJECT_P (font_object))
+    {
+      struct font *font = XFONT_OBJECT (font_object);
+      struct font_info *ftcrfont_info = (struct font_info *) font;
+      FT_Face ft_face = ftcrfont_info->ft_size->face;
+
+      font->driver = &ftcrfont_driver;
+      FT_New_Size (ft_face, &ftcrfont_info->ft_size_draw);
+      FT_Activate_Size (ftcrfont_info->ft_size_draw);
+      if (ftcrfont_info->bitmap_strike_index < 0)
+       FT_Set_Pixel_Sizes (ft_face, 0, font->pixel_size);
+      else
+       FT_Select_Size (ft_face, ftcrfont_info->bitmap_strike_index);
+      cairo_font_face_t *font_face =
+       cairo_ft_font_face_create_for_ft_face (ft_face, 0);
+      cairo_matrix_t font_matrix, ctm;
+      cairo_matrix_init_scale (&font_matrix, pixel_size, pixel_size);
+      cairo_matrix_init_identity (&ctm);
+      cairo_font_options_t *options = cairo_font_options_create ();
+      ftcrfont_info->cr_scaled_font =
+       cairo_scaled_font_create (font_face, &font_matrix, &ctm, options);
+      cairo_font_face_destroy (font_face);
+      cairo_font_options_destroy (options);
+      ftcrfont_info->metrics = NULL;
+      ftcrfont_info->metrics_nrows = 0;
+      if (ftcrfont_info->bitmap_strike_index >= 0)
+       {
+         /* Several members of struct font/font_info set by
+            ftfont_open2 are bogus.  Recalculate them with cairo
+            scaled font functions.  */
+         cairo_font_extents_t extents;
+         cairo_scaled_font_extents (ftcrfont_info->cr_scaled_font, &extents);
+         font->ascent = lround (extents.ascent);
+         font->descent = lround (extents.descent);
+         font->height = lround (extents.height);
+
+         cairo_glyph_t stack_glyph;
+         int n = 0;
+         font->min_width = font->average_width = font->space_width = 0;
+         for (char c = 32; c < 127; c++)
+           {
+             cairo_glyph_t *glyphs = &stack_glyph;
+             int num_glyphs = 1;
+             cairo_status_t status =
+               cairo_scaled_font_text_to_glyphs (ftcrfont_info->cr_scaled_font,
+                                                 0, 0, &c, 1,
+                                                 &glyphs, &num_glyphs,
+                                                 NULL, NULL, NULL);
+
+             if (status == CAIRO_STATUS_SUCCESS)
+               {
+                 if (glyphs != &stack_glyph)
+                   cairo_glyph_free (glyphs);
+                 else
+                   {
+                     int this_width =
+                       ftcrfont_glyph_extents (font, stack_glyph.index, NULL);
+
+                     if (this_width > 0
+                         && (! font->min_width
+                             || font->min_width > this_width))
+                       font->min_width = this_width;
+                     if (c == 32)
+                       font->space_width = this_width;
+                     font->average_width += this_width;
+                     n++;
+                   }
+               }
+           }
+         if (n > 0)
+           font->average_width /= n;
+
+         font->underline_position = -1;
+         font->underline_thickness = 0;
+       }
+    }
   unblock_input ();
 
   return font_object;
@@ -150,7 +224,7 @@ ftcrfont_close (struct font *font)
   if (ftcrfont_info->metrics)
     xfree (ftcrfont_info->metrics);
   FT_Done_Size (ftcrfont_info->ft_size_draw);
-  cairo_font_face_destroy (ftcrfont_info->cr_font_face);
+  cairo_scaled_font_destroy (ftcrfont_info->cr_scaled_font);
   unblock_input ();
 
   ftfont_close (font);
@@ -191,6 +265,44 @@ ftcrfont_text_extents (struct font *font,
 }
 
 static int
+ftcrfont_get_bitmap (struct font *font, unsigned int code,
+                    struct font_bitmap *bitmap, int bits_per_pixel)
+{
+  struct font_info *ftcrfont_info = (struct font_info *) font;
+
+  if (ftcrfont_info->bitmap_strike_index < 0)
+    return ftfont_get_bitmap (font, code, bitmap, bits_per_pixel);
+
+  return -1;
+}
+
+static int
+ftcrfont_anchor_point (struct font *font, unsigned int code, int idx,
+                      int *x, int *y)
+{
+  struct font_info *ftcrfont_info = (struct font_info *) font;
+
+  if (ftcrfont_info->bitmap_strike_index < 0)
+    return ftfont_anchor_point (font, code, idx, x, y);
+
+  return -1;
+}
+
+static Lisp_Object
+ftcrfont_shape (Lisp_Object lgstring, Lisp_Object direction)
+{
+#if (defined HAVE_M17N_FLT && defined HAVE_LIBOTF) || defined HAVE_HARFBUZZ
+  struct font *font = CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring));
+  struct font_info *ftcrfont_info = (struct font_info *) font;
+
+  if (ftcrfont_info->bitmap_strike_index < 0)
+    return ftfont_shape (lgstring, direction);
+#endif
+
+  return make_fixnum (0);
+}
+
+static int
 ftcrfont_draw (struct glyph_string *s,
                int from, int to, int x, int y, bool with_background)
 {
@@ -229,10 +341,7 @@ ftcrfont_draw (struct glyph_string *s,
     }
 
   x_set_cr_source_with_gc_foreground (f, s->gc);
-  cairo_set_font_face (cr, ftcrfont_info->cr_font_face);
-  cairo_set_font_size (cr, s->font->pixel_size);
-  /* cairo_set_font_matrix */
-  /* cairo_set_font_options */
+  cairo_set_scaled_font (cr, ftcrfont_info->cr_scaled_font);
 
   FT_Activate_Size (ftcrfont_info->ft_size_draw);
   cairo_show_glyphs (cr, glyphs, len);
@@ -254,6 +363,8 @@ ftcrfont_draw (struct glyph_string *s,
 
 
 
+static void syms_of_ftcrfont_for_pdumper (void);
+
 struct font_driver const ftcrfont_driver =
   {
   .type = LISPSYM_INITIALLY (Qftcr),
@@ -267,14 +378,12 @@ struct font_driver const ftcrfont_driver =
   .encode_char = ftfont_encode_char,
   .text_extents = ftcrfont_text_extents,
   .draw = ftcrfont_draw,
-  .get_bitmap = ftfont_get_bitmap,
-  .anchor_point = ftfont_anchor_point,
+  .get_bitmap = ftcrfont_get_bitmap,
+  .anchor_point = ftcrfont_anchor_point,
 #ifdef HAVE_LIBOTF
   .otf_capability = ftfont_otf_capability,
 #endif
-#if (defined HAVE_M17N_FLT && defined HAVE_LIBOTF) || defined HAVE_HARFBUZZ
-  .shape = ftfont_shape,
-#endif
+  .shape = ftcrfont_shape,
 #ifdef HAVE_OTF_GET_VARIATION_GLYPHS
   .get_variation_glyphs = ftfont_variation_glyphs,
 #endif
@@ -286,5 +395,11 @@ void
 syms_of_ftcrfont (void)
 {
   DEFSYM (Qftcr, "ftcr");
+  pdumper_do_now_and_after_load (syms_of_ftcrfont_for_pdumper);
+}
+
+static void
+syms_of_ftcrfont_for_pdumper (void)
+{
   register_font_driver (&ftcrfont_driver, NULL);
 }
diff --git a/src/ftfont.c b/src/ftfont.c
index 63df123..58c462a 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -1,5 +1,5 @@
 /* ftfont.c -- FreeType font driver.
-   Copyright (C) 2006-2018 Free Software Foundation, Inc.
+   Copyright (C) 2006-2019 Free Software Foundation, Inc.
    Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H13PRO009
@@ -45,6 +45,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "composite.h"
 #include "font.h"
 #include "ftfont.h"
+#include "pdumper.h"
 
 static struct font_driver const ftfont_driver;
 
@@ -598,16 +599,14 @@ ftfont_get_open_type_spec (Lisp_Object otf_spec)
   spec->nfeatures[0] = spec->nfeatures[1] = 0;
   for (i = 0; i < 2 && ! NILP (otf_spec); i++, otf_spec = XCDR (otf_spec))
     {
-      Lisp_Object len;
-
       val = XCAR (otf_spec);
       if (NILP (val))
        continue;
-      len = Flength (val);
+      ptrdiff_t len = list_length (val);
       spec->features[i] =
-       (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (int) < XFIXNUM (len)
+       (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (int) < len
         ? 0
-        : malloc (XFIXNUM (len) * sizeof *spec->features[i]));
+        : malloc (len * sizeof *spec->features[i]));
       if (! spec->features[i])
        {
          if (i > 0 && spec->features[0])
@@ -1111,6 +1110,7 @@ ftfont_open2 (struct frame *f,
   int spacing;
   int i;
   double upEM;
+  FT_Int strike_index = -1;
 
   val = assq_no_quit (QCfont_entity, AREF (entity, FONT_EXTRA_INDEX));
   if (! CONSP (val))
@@ -1140,12 +1140,32 @@ ftfont_open2 (struct frame *f,
     size = pixel_size;
   if (FT_Set_Pixel_Sizes (ft_face, size, size) != 0)
     {
-      if (cache_data->face_refcount == 0)
+      int min_distance = INT_MAX;
+      bool magnify = true;
+
+      for (FT_Int i = 0; i < ft_face->num_fixed_sizes; i++)
        {
-         FT_Done_Face (ft_face);
-         cache_data->ft_face = NULL;
+         int distance = ft_face->available_sizes[i].height - (int) size;
+
+         /* Prefer down-scaling to upscaling.  */
+         if (magnify == (distance < 0) ? abs (distance) <= min_distance
+             : magnify)
+           {
+             magnify = distance < 0;
+             min_distance = abs (distance);
+             strike_index = i;
+           }
+       }
+
+      if (strike_index < 0 || FT_Select_Size (ft_face, strike_index) != 0)
+       {
+         if (cache_data->face_refcount == 0)
+           {
+             FT_Done_Face (ft_face);
+             cache_data->ft_face = NULL;
+           }
+         return Qnil;
        }
-      return Qnil;
     }
   cache_data->face_refcount++;
 
@@ -1161,6 +1181,7 @@ ftfont_open2 (struct frame *f,
 #ifdef HAVE_HARFBUZZ
   ftfont_info->hb_font = NULL;
 #endif /* HAVE_HARFBUZZ */
+  ftfont_info->bitmap_strike_index = strike_index;
   /* This means that there's no need of transformation.  */
   ftfont_info->matrix.xx = 0;
   font->pixel_size = size;
@@ -1246,7 +1267,19 @@ ftfont_open (struct frame *f, Lisp_Object entity, int 
pixel_size)
     size = pixel_size;
   font_object = font_build_object (VECSIZE (struct font_info),
                                   Qfreetype, entity, size);
-  return ftfont_open2 (f, entity, pixel_size, font_object);
+  font_object = ftfont_open2 (f, entity, pixel_size, font_object);
+  if (FONT_OBJECT_P (font_object))
+    {
+      struct font *font = XFONT_OBJECT (font_object);
+      struct font_info *ftfont_info = (struct font_info *) font;
+
+      if (ftfont_info->bitmap_strike_index >= 0)
+       {
+         ftfont_close (font);
+         font_object = Qnil;
+       }
+    }
+  return font_object;
 }
 
 void
@@ -3020,6 +3053,8 @@ ftfont_combining_capability (struct font *font)
 #endif
 }
 
+static void syms_of_ftfont_for_pdumper (void);
+
 static struct font_driver const ftfont_driver =
   {
   /* We can't draw a text without device dependent functions.  */
@@ -3071,5 +3106,12 @@ syms_of_ftfont (void)
   staticpro (&ft_face_cache);
   ft_face_cache = Qnil;
 
+  pdumper_do_now_and_after_load (syms_of_ftfont_for_pdumper);
+}
+
+static void
+syms_of_ftfont_for_pdumper (void)
+{
+  PDUMPER_RESET_LV (ft_face_cache, Qnil);
   register_font_driver (&ftfont_driver, NULL);
 }
diff --git a/src/ftfont.h b/src/ftfont.h
index 3bbcbfb..f877860 100644
--- a/src/ftfont.h
+++ b/src/ftfont.h
@@ -59,13 +59,17 @@ struct font_info
 #endif /* HAVE_LIBOTF */
   FT_Size ft_size;
   int index;
+  /* Index of the bitmap strike used as a fallback for
+     FT_Set_Pixel_Sizes failure.  If the value is non-negative, then
+     ft_size is not of the requested size.  Otherwise it is -1.  */
+  FT_Int bitmap_strike_index;
   FT_Matrix matrix;
 #ifdef HAVE_HARFBUZZ
   hb_font_t *hb_font;
 #endif  /* HAVE_HARFBUZZ */
 
 #ifdef USE_CAIRO
-  cairo_font_face_t *cr_font_face;
+  cairo_scaled_font_t *cr_scaled_font;
   /* To prevent cairo from cluttering the activated FT_Size maintained
      in ftfont.c, we activate this special FT_Size before drawing.  */
   FT_Size ft_size_draw;
diff --git a/src/ftxfont.c b/src/ftxfont.c
index 66fd9ab..a549fd7 100644
--- a/src/ftxfont.c
+++ b/src/ftxfont.c
@@ -1,5 +1,5 @@
 /* ftxfont.c -- FreeType font driver on X (without using XFT).
-   Copyright (C) 2006-2018 Free Software Foundation, Inc.
+   Copyright (C) 2006-2019 Free Software Foundation, Inc.
    Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H13PRO009
@@ -28,6 +28,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "frame.h"
 #include "blockinput.h"
 #include "font.h"
+#include "pdumper.h"
 
 /* FTX font driver.  */
 
@@ -339,6 +340,8 @@ ftxfont_end_for_frame (struct frame *f)
 
 
 
+static void syms_of_ftxfont_for_pdumper (void);
+
 struct font_driver const ftxfont_driver =
   {
   /* We can't draw a text without device dependent functions.  */
@@ -373,5 +376,11 @@ void
 syms_of_ftxfont (void)
 {
   DEFSYM (Qftx, "ftx");
+  pdumper_do_now_and_after_load (syms_of_ftxfont_for_pdumper);
+}
+
+static void
+syms_of_ftxfont_for_pdumper (void)
+{
   register_font_driver (&ftxfont_driver, NULL);
 }
diff --git a/src/getpagesize.h b/src/getpagesize.h
index 561014a..aa21cf3 100644
--- a/src/getpagesize.h
+++ b/src/getpagesize.h
@@ -1,5 +1,5 @@
 /* Emulate getpagesize on systems that lack it.
-   Copyright (C) 1986, 1992, 1995, 2001-2018 Free Software Foundation,
+   Copyright (C) 1986, 1992, 1995, 2001-2019 Free Software Foundation,
    Inc.
 
 This file is part of GNU Emacs.
diff --git a/src/gfilenotify.c b/src/gfilenotify.c
index 798f308..ddb1977 100644
--- a/src/gfilenotify.c
+++ b/src/gfilenotify.c
@@ -1,5 +1,5 @@
 /* Filesystem notifications support with glib API.
-   Copyright (C) 2013-2018 Free Software Foundation, Inc.
+   Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -18,7 +18,6 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 
-#ifdef HAVE_GFILENOTIFY
 #include <stdio.h>
 #include <gio/gio.h>
 #include "lisp.h"
@@ -86,11 +85,11 @@ dir_monitor_callback (GFileMonitor *monitor,
 
       /* Check, whether event_type is expected.  */
       flags = XCAR (XCDR (XCDR (watch_object)));
-      if ((!NILP (Fmember (Qchange, flags)) &&
-          !NILP (Fmember (symbol, list5 (Qchanged, Qchanges_done_hint,
-                                         Qdeleted, Qcreated, Qmoved)))) ||
-         (!NILP (Fmember (Qattribute_change, flags)) &&
-          ((EQ (symbol, Qattribute_changed)))))
+      if ((!NILP (Fmember (Qchange, flags))
+          && !NILP (Fmember (symbol, list5 (Qchanged, Qchanges_done_hint,
+                                            Qdeleted, Qcreated, Qmoved))))
+         || (!NILP (Fmember (Qattribute_change, flags))
+             && EQ (symbol, Qattribute_changed)))
        {
          /* Construct an event.  */
          EVENT_INIT (event);
@@ -108,9 +107,9 @@ dir_monitor_callback (GFileMonitor *monitor,
        }
 
       /* Cancel monitor if file or directory is deleted.  */
-      if (!NILP (Fmember (symbol, list2 (Qdeleted, Qmoved))) &&
-         (strcmp (name, SSDATA (XCAR (XCDR (watch_object)))) == 0) &&
-         !g_file_monitor_is_cancelled (monitor))
+      if (!NILP (Fmember (symbol, list2 (Qdeleted, Qmoved)))
+         && strcmp (name, SSDATA (XCAR (XCDR (watch_object)))) == 0
+         && !g_file_monitor_is_cancelled (monitor))
        g_file_monitor_cancel (monitor);
     }
 
@@ -240,10 +239,10 @@ WATCH-DESCRIPTOR should be an object returned by 
`gfile-add-watch'.  */)
 
   eassert (FIXNUMP (watch_descriptor));
   GFileMonitor *monitor = XFIXNUMPTR (watch_descriptor);
-  if (!g_file_monitor_is_cancelled (monitor) &&
-      !g_file_monitor_cancel (monitor))
-      xsignal2 (Qfile_notify_error, build_string ("Could not rm watch"),
-               watch_descriptor);
+  if (!g_file_monitor_is_cancelled (monitor)
+      && !g_file_monitor_cancel (monitor))
+    xsignal2 (Qfile_notify_error, build_string ("Could not rm watch"),
+             watch_descriptor);
 
   /* Remove watch descriptor from watch list.  */
   watch_list = Fdelq (watch_object, watch_list);
@@ -333,7 +332,4 @@ syms_of_gfilenotify (void)
   staticpro (&watch_list);
 
   Fprovide (intern_c_string ("gfilenotify"), Qnil);
-
 }
-
-#endif /* HAVE_GFILENOTIFY  */
diff --git a/src/gmalloc.c b/src/gmalloc.c
index ebba789..b6a96d5 100644
--- a/src/gmalloc.c
+++ b/src/gmalloc.c
@@ -1,5 +1,5 @@
 /* Declarations for `malloc' and friends.
-   Copyright (C) 1990-1993, 1995-1996, 1999, 2002-2007, 2013-2018 Free
+   Copyright (C) 1990-1993, 1995-1996, 1999, 2002-2007, 2013-2019 Free
    Software Foundation, Inc.
                  Written May 1989 by Mike Haertel.
 
@@ -36,9 +36,7 @@ License along with this library.  If not, see 
<https://www.gnu.org/licenses/>.
 #include <pthread.h>
 #endif
 
-#ifdef emacs
-# include "lisp.h"
-#endif
+#include "lisp.h"
 
 #include "ptr-bounds.h"
 
@@ -78,7 +76,6 @@ extern void *(*__morecore) (ptrdiff_t);
 
 #ifdef HYBRID_MALLOC
 # include "sheap.h"
-# define DUMPED bss_sbrk_did_unexec
 #endif
 
 #ifdef __cplusplus
@@ -1510,7 +1507,7 @@ static void *
 gdefault_morecore (ptrdiff_t increment)
 {
 #ifdef HYBRID_MALLOC
-  if (!DUMPED)
+  if (!definitely_will_not_unexec_p ())
     {
       return bss_sbrk (increment);
     }
@@ -1728,6 +1725,8 @@ extern int posix_memalign (void **memptr, size_t 
alignment, size_t size);
 static bool
 allocated_via_gmalloc (void *ptr)
 {
+  if (!__malloc_initialized)
+    return false;
   size_t block = BLOCK (ptr);
   size_t blockmax = _heaplimit - 1;
   return block <= blockmax && _heapinfo[block].busy.type != 0;
@@ -1739,7 +1738,7 @@ allocated_via_gmalloc (void *ptr)
 void *
 hybrid_malloc (size_t size)
 {
-  if (DUMPED)
+  if (definitely_will_not_unexec_p ())
     return malloc (size);
   return gmalloc (size);
 }
@@ -1747,7 +1746,7 @@ hybrid_malloc (size_t size)
 void *
 hybrid_calloc (size_t nmemb, size_t size)
 {
-  if (DUMPED)
+  if (definitely_will_not_unexec_p ())
     return calloc (nmemb, size);
   return gcalloc (nmemb, size);
 }
@@ -1765,7 +1764,7 @@ hybrid_free (void *ptr)
 void *
 hybrid_aligned_alloc (size_t alignment, size_t size)
 {
-  if (!DUMPED)
+  if (!definitely_will_not_unexec_p ())
     return galigned_alloc (alignment, size);
   /* The following is copied from alloc.c */
 #ifdef HAVE_ALIGNED_ALLOC
@@ -1788,7 +1787,7 @@ hybrid_realloc (void *ptr, size_t size)
     return hybrid_malloc (size);
   if (!allocated_via_gmalloc (ptr))
     return realloc (ptr, size);
-  if (!DUMPED)
+  if (!definitely_will_not_unexec_p ())
     return grealloc (ptr, size);
 
   /* The dumped emacs is trying to realloc storage allocated before
@@ -2022,11 +2021,7 @@ mabort (enum mcheck_status status)
 #else
   fprintf (stderr, "mcheck: %s\n", msg);
   fflush (stderr);
-# ifdef emacs
   emacs_abort ();
-# else
-  abort ();
-# endif
 #endif
 }
 
diff --git a/src/gnutls.c b/src/gnutls.c
index 4b94dbb..1afbb2b 100644
--- a/src/gnutls.c
+++ b/src/gnutls.c
@@ -1,5 +1,5 @@
 /* GnuTLS glue for GNU Emacs.
-   Copyright (C) 2010-2018 Free Software Foundation, Inc.
+   Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -25,6 +25,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "gnutls.h"
 #include "coding.h"
 #include "buffer.h"
+#include "pdumper.h"
 
 #if GNUTLS_VERSION_NUMBER >= 0x030014
 # define HAVE_GNUTLS_X509_SYSTEM_TRUST
@@ -71,7 +72,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #  include "w32.h"
 # endif
 
-static bool emacs_gnutls_handle_error (gnutls_session_t, int);
+static int emacs_gnutls_handle_error (gnutls_session_t, int);
 
 static bool gnutls_global_initialized;
 
@@ -394,8 +395,7 @@ init_gnutls_functions (void)
 #   endif
 #  endif        /* HAVE_GNUTLS3 */
 
-  max_log_level = global_gnutls_log_level;
-
+  max_log_level = clip_to_bounds (INT_MIN, global_gnutls_log_level, INT_MAX);
   {
     Lisp_Object name = CAR_SAFE (Fget (Qgnutls, QCloaded_from));
     GNUTLS_LOG2 (1, max_log_level, "GnuTLS library loaded:",
@@ -578,15 +578,17 @@ gnutls_try_handshake (struct Lisp_Process *proc)
   if (non_blocking)
     proc->gnutls_p = true;
 
-  do
+  while ((ret = gnutls_handshake (state)) < 0)
     {
-      ret = gnutls_handshake (state);
-      emacs_gnutls_handle_error (state, ret);
+      do
+       ret = gnutls_handshake (state);
+      while (ret == GNUTLS_E_INTERRUPTED);
+
+      if (0 <= ret || emacs_gnutls_handle_error (state, ret) == 0
+         || non_blocking)
+       break;
       maybe_quit ();
     }
-  while (ret < 0
-        && gnutls_error_is_fatal (ret) == 0
-        && ! non_blocking);
 
   proc->gnutls_initstage = GNUTLS_STAGE_HANDSHAKE_TRIED;
 
@@ -681,8 +683,6 @@ emacs_gnutls_transport_set_errno (gnutls_session_t state, 
int err)
 ptrdiff_t
 emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, ptrdiff_t 
nbyte)
 {
-  ssize_t rtnval = 0;
-  ptrdiff_t bytes_written;
   gnutls_session_t state = proc->gnutls_state;
 
   if (proc->gnutls_initstage != GNUTLS_STAGE_READY)
@@ -691,25 +691,19 @@ emacs_gnutls_write (struct Lisp_Process *proc, const char 
*buf, ptrdiff_t nbyte)
       return 0;
     }
 
-  bytes_written = 0;
+  ptrdiff_t bytes_written = 0;
 
   while (nbyte > 0)
     {
-      rtnval = gnutls_record_send (state, buf, nbyte);
+      ssize_t rtnval;
+      do
+       rtnval = gnutls_record_send (state, buf, nbyte);
+      while (rtnval == GNUTLS_E_INTERRUPTED);
 
       if (rtnval < 0)
        {
-         if (rtnval == GNUTLS_E_INTERRUPTED)
-           continue;
-         else
-           {
-             /* If we get GNUTLS_E_AGAIN, then set errno
-                appropriately so that send_process retries the
-                correct way instead of erroring out. */
-             if (rtnval == GNUTLS_E_AGAIN)
-               errno = EAGAIN;
-             break;
-           }
+         emacs_gnutls_handle_error (state, rtnval);
+         break;
        }
 
       buf += rtnval;
@@ -717,14 +711,12 @@ emacs_gnutls_write (struct Lisp_Process *proc, const char 
*buf, ptrdiff_t nbyte)
       bytes_written += rtnval;
     }
 
-  emacs_gnutls_handle_error (state, rtnval);
   return (bytes_written);
 }
 
 ptrdiff_t
 emacs_gnutls_read (struct Lisp_Process *proc, char *buf, ptrdiff_t nbyte)
 {
-  ssize_t rtnval;
   gnutls_session_t state = proc->gnutls_state;
 
   if (proc->gnutls_initstage != GNUTLS_STAGE_READY)
@@ -733,19 +725,18 @@ emacs_gnutls_read (struct Lisp_Process *proc, char *buf, 
ptrdiff_t nbyte)
       return -1;
     }
 
-  rtnval = gnutls_record_recv (state, buf, nbyte);
+  ssize_t rtnval;
+  do
+    rtnval = gnutls_record_recv (state, buf, nbyte);
+  while (rtnval == GNUTLS_E_INTERRUPTED);
+
   if (rtnval >= 0)
     return rtnval;
   else if (rtnval == GNUTLS_E_UNEXPECTED_PACKET_LENGTH)
     /* The peer closed the connection. */
     return 0;
-  else if (emacs_gnutls_handle_error (state, rtnval))
-    /* non-fatal error */
-    return -1;
-  else {
-    /* a fatal error occurred */
-    return 0;
-  }
+  else
+    return emacs_gnutls_handle_error (state, rtnval);
 }
 
 static char const *
@@ -756,25 +747,25 @@ emacs_gnutls_strerror (int err)
 }
 
 /* Report a GnuTLS error to the user.
-   Return true if the error code was successfully handled.  */
-static bool
+   SESSION is the GnuTLS session, ERR is the (negative) GnuTLS error code.
+   Return 0 if the error was fatal, -1 (setting errno) otherwise so
+   that the caller can notice the error and attempt a repair.  */
+static int
 emacs_gnutls_handle_error (gnutls_session_t session, int err)
 {
-  int max_log_level = 0;
-
-  bool ret;
+  int ret;
 
   /* TODO: use a Lisp_Object generated by gnutls_make_error?  */
-  if (err >= 0)
-    return 1;
 
   check_memory_full (err);
 
-  max_log_level = global_gnutls_log_level;
+  int max_log_level
+    = clip_to_bounds (INT_MIN, global_gnutls_log_level, INT_MAX);
 
   /* TODO: use gnutls-error-fatalp and gnutls-error-string.  */
 
   char const *str = emacs_gnutls_strerror (err);
+  int errnum = EINVAL;
 
   if (gnutls_error_is_fatal (err))
     {
@@ -788,11 +779,11 @@ emacs_gnutls_handle_error (gnutls_session_t session, int 
err)
 # endif
 
       GNUTLS_LOG2 (level, max_log_level, "fatal error:", str);
-      ret = false;
+      ret = 0;
     }
   else
     {
-      ret = true;
+      ret = -1;
 
       switch (err)
         {
@@ -808,6 +799,26 @@ emacs_gnutls_handle_error (gnutls_session_t session, int 
err)
                        "non-fatal error:",
                        str);
         }
+
+      switch (err)
+       {
+       case GNUTLS_E_AGAIN:
+         errnum = EAGAIN;
+         break;
+
+# ifdef EMSGSIZE
+       case GNUTLS_E_LARGE_PACKET:
+       case GNUTLS_E_PUSH_ERROR:
+         errnum = EMSGSIZE;
+         break;
+# endif
+
+# if defined HAVE_GNUTLS3 && defined ECONNRESET
+       case GNUTLS_E_PREMATURE_TERMINATION:
+         errnum = ECONNRESET;
+         break;
+# endif
+       }
     }
 
   if (err == GNUTLS_E_WARNING_ALERT_RECEIVED
@@ -821,6 +832,8 @@ emacs_gnutls_handle_error (gnutls_session_t session, int 
err)
 
       GNUTLS_LOG2 (level, max_log_level, "Received alert: ", str);
     }
+
+  errno = errnum;
   return ret;
 }
 
@@ -1678,14 +1691,17 @@ one trustfile (usually a CA bundle).  */)
 
   state = XPROCESS (proc)->gnutls_state;
 
-  if (TYPE_RANGED_FIXNUMP (int, loglevel))
+  if (INTEGERP (loglevel))
     {
       gnutls_global_set_log_function (gnutls_log_function);
 # ifdef HAVE_GNUTLS3
       gnutls_global_set_audit_log_function (gnutls_audit_log_function);
 # endif
-      gnutls_global_set_log_level (XFIXNUM (loglevel));
-      max_log_level = XFIXNUM (loglevel);
+      int level = (FIXNUMP (loglevel)
+                  ? clip_to_bounds (INT_MIN, XFIXNUM (loglevel), INT_MAX)
+                  : NILP (Fnatnump (loglevel)) ? INT_MIN : INT_MAX);
+      gnutls_global_set_log_level (level);
+      max_log_level = level;
       XPROCESS (proc)->gnutls_log_level = max_log_level;
     }
 
@@ -1982,7 +1998,7 @@ The alist key is the cipher name. */)
       ptrdiff_t cipher_tag_size = gnutls_cipher_get_tag_size (gca);
 
       Lisp_Object cp
-       = listn (CONSTYPE_HEAP, 15, cipher_symbol,
+        = list (cipher_symbol,
                 QCcipher_id, make_fixnum (gca),
                 QCtype, Qgnutls_type_cipher,
                 QCcipher_aead_capable, cipher_tag_size == 0 ? Qnil : Qt,
@@ -2313,7 +2329,7 @@ name. */)
 # ifdef HAVE_GNUTLS_MAC_GET_NONCE_SIZE
       nonce_size = gnutls_mac_get_nonce_size (gma);
 # endif
-      Lisp_Object mp = listn (CONSTYPE_HEAP, 11, gma_symbol,
+      Lisp_Object mp =  list (gma_symbol,
                              QCmac_algorithm_id, make_fixnum (gma),
                              QCtype, Qgnutls_type_mac_algorithm,
 
@@ -2348,7 +2364,7 @@ method name. */)
       /* A symbol representing the GnuTLS digest algorithm.  */
       Lisp_Object gda_symbol = intern (gnutls_digest_get_name (gda));
 
-      Lisp_Object mp = listn (CONSTYPE_HEAP, 7, gda_symbol,
+      Lisp_Object mp  = list (gda_symbol,
                              QCdigest_algorithm_id, make_fixnum (gda),
                              QCtype, Qgnutls_type_digest_algorithm,
 
@@ -2626,6 +2642,7 @@ syms_of_gnutls (void)
         );
 #ifdef HAVE_GNUTLS
   gnutls_global_initialized = 0;
+  PDUMPER_IGNORE (gnutls_global_initialized);
 
   DEFSYM (Qgnutls_code, "gnutls-code");
   DEFSYM (Qgnutls_anon, "gnutls-anon");
diff --git a/src/gnutls.h b/src/gnutls.h
index 3c55739..6332dad 100644
--- a/src/gnutls.h
+++ b/src/gnutls.h
@@ -1,5 +1,5 @@
 /* GnuTLS glue for GNU Emacs.
-   Copyright (C) 2010-2018 Free Software Foundation, Inc.
+   Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 382039c..4823357 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -1,6 +1,6 @@
 /* Functions for creating and updating GTK widgets.
 
-Copyright (C) 2003-2018 Free Software Foundation, Inc.
+Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -52,48 +52,19 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include <X11/extensions/Xdbe.h>
 #endif
 
-#ifndef HAVE_GTK_WIDGET_SET_HAS_WINDOW
-#define gtk_widget_set_has_window(w, b) \
-  (gtk_fixed_set_has_window (GTK_FIXED (w), b))
-#endif
-#ifndef HAVE_GTK_DIALOG_GET_ACTION_AREA
-#define gtk_dialog_get_action_area(w) ((w)->action_area)
-#define gtk_dialog_get_content_area(w) ((w)->vbox)
-#endif
-#ifndef HAVE_GTK_WIDGET_GET_SENSITIVE
-#define gtk_widget_get_sensitive(w) (GTK_WIDGET_SENSITIVE (w))
-#endif
-#ifndef HAVE_GTK_ADJUSTMENT_GET_PAGE_SIZE
-#define gtk_adjustment_set_page_size(w, s) ((w)->page_size = (s))
-#define gtk_adjustment_set_page_increment(w, s) ((w)->page_increment = (s))
-#define gtk_adjustment_get_step_increment(w) ((w)->step_increment)
-#define gtk_adjustment_set_step_increment(w, s) ((w)->step_increment = (s))
-#endif
-#if GTK_CHECK_VERSION (2, 12, 0)
-#define remove_submenu(w) gtk_menu_item_set_submenu ((w), NULL)
+#ifdef HAVE_GTK3
+#define XG_TEXT_CANCEL "Cancel"
+#define XG_TEXT_OK     "OK"
+#define XG_TEXT_OPEN   "Open"
 #else
-#define remove_submenu(w) gtk_menu_item_remove_submenu ((w))
+#define XG_TEXT_CANCEL GTK_STOCK_CANCEL
+#define XG_TEXT_OK     GTK_STOCK_OK
+#define XG_TEXT_OPEN   GTK_STOCK_OPEN
 #endif
 
-#if ! GTK_CHECK_VERSION (2, 14, 0)
-#define gtk_adjustment_configure(adj, xvalue, xlower,            \
-                                 xupper, xstep_increment,        \
-                                 xpage_increment, xpagesize)     \
-  do {                                                           \
-    adj->lower = xlower;                                         \
-    adj->upper = xupper;                                         \
-    adj->page_size = xpagesize;                                  \
-    gtk_adjustment_set_value (adj, xvalue);                      \
-    adj->page_increment = xpage_increment;                       \
-    adj->step_increment = xstep_increment;                       \
-  } while (0)
-#endif /* < Gtk+ 2.14 */
+#ifndef HAVE_GTK3
 
 #ifdef HAVE_FREETYPE
-#if GTK_CHECK_VERSION (3, 2, 0)
-#define USE_NEW_GTK_FONT_CHOOSER 1
-#else
-#define USE_NEW_GTK_FONT_CHOOSER 0
 #define gtk_font_chooser_dialog_new(x, y) \
   gtk_font_selection_dialog_new (x)
 #undef GTK_FONT_CHOOSER
@@ -101,35 +72,15 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #define  gtk_font_chooser_set_font(x, y) \
   gtk_font_selection_dialog_set_font_name (x, y)
 #endif
-#endif /* HAVE_FREETYPE */
 
-#if GTK_CHECK_VERSION (3, 10, 0)
-#define XG_TEXT_CANCEL "Cancel"
-#define XG_TEXT_OK     "OK"
-#define XG_TEXT_OPEN   "Open"
-#else
-#define XG_TEXT_CANCEL GTK_STOCK_CANCEL
-#define XG_TEXT_OK     GTK_STOCK_OK
-#define XG_TEXT_OPEN   GTK_STOCK_OPEN
-#endif
-
-#ifndef HAVE_GTK3
-#ifdef USE_GTK_TOOLTIP
-#define gdk_window_get_screen(w) gdk_drawable_get_screen (w)
-#endif
 #define gdk_window_get_geometry(w, a, b, c, d) \
   gdk_window_get_geometry (w, a, b, c, d, 0)
-#define gdk_x11_window_lookup_for_display(d, w) \
-  gdk_xid_table_lookup_for_display (d, w)
 #define gtk_box_new(ori, spacing)                                       \
   ((ori) == GTK_ORIENTATION_HORIZONTAL                                  \
    ? gtk_hbox_new (FALSE, (spacing)) : gtk_vbox_new (FALSE, (spacing)))
 #define gtk_scrollbar_new(ori, spacing)                                 \
   ((ori) == GTK_ORIENTATION_HORIZONTAL                                  \
    ? gtk_hscrollbar_new ((spacing)) : gtk_vscrollbar_new ((spacing)))
-#ifndef GDK_KEY_g
-#define GDK_KEY_g GDK_g
-#endif
 #endif /* HAVE_GTK3 */
 
 #define XG_BIN_CHILD(x) gtk_bin_get_child (GTK_BIN (x))
@@ -147,7 +98,9 @@ struct xg_frame_tb_info
   GtkTextDirection dir;
 };
 
+#ifdef HAVE_XWIDGETS
 bool xg_gtk_initialized;        /* Used to make sure xwidget calls are 
possible */
+#endif
 
 static GtkWidget * xg_get_widget_from_map (ptrdiff_t idx);
 
@@ -225,7 +178,7 @@ xg_get_gdk_scale (void)
 int
 xg_get_scale (struct frame *f)
 {
-#if GTK_CHECK_VERSION (3, 10, 0)
+#ifdef HAVE_GTK3
   if (FRAME_GTK_WIDGET (f))
     return gtk_widget_get_scale_factor (FRAME_GTK_WIDGET (f));
 #endif
@@ -259,15 +212,7 @@ xg_display_close (Display *dpy)
       gdpy_def = gdpy_new;
     }
 
-#if GTK_CHECK_VERSION (2, 0, 0) && ! GTK_CHECK_VERSION (2, 10, 0)
-  /* GTK 2.2-2.8 has a bug that makes gdk_display_close crash
-     <https://gitlab.gnome.org/GNOME/gtk/issues/221>.  This way we
-     can continue running, but there will be memory leaks.  */
-  g_object_run_dispose (G_OBJECT (gdpy));
-#else
-  /* This seems to be fixed in GTK 2.10. */
   gdk_display_close (gdpy);
-#endif
 }
 
 
@@ -366,7 +311,11 @@ xg_get_image_for_pixmap (struct frame *f,
                          GtkWidget *widget,
                          GtkImage *old_widget)
 {
+#if defined USE_CAIRO && defined HAVE_GTK3
+  cairo_surface_t *surface;
+#else
   GdkPixbuf *icon_buf;
+#endif
 
   /* If we have a file, let GTK do all the image handling.
      This seems to be the only way to make insensitive and activated icons
@@ -379,7 +328,7 @@ xg_get_image_for_pixmap (struct frame *f,
      In that case, use the pixmap already loaded.  */
 
   if (STRINGP (specified_file)
-      && STRINGP (file = x_find_image_file (specified_file)))
+      && STRINGP (file = image_find_image_file (specified_file)))
     {
       char *encoded_file = SSDATA (ENCODE_FILE (file));
       if (! old_widget)
@@ -394,6 +343,17 @@ xg_get_image_for_pixmap (struct frame *f,
      on a monochrome display, and sometimes bad on all displays with
      certain themes.  */
 
+#if defined USE_CAIRO && defined HAVE_GTK3
+  surface = img->cr_data;
+
+  if (surface)
+    {
+      if (! old_widget)
+        old_widget = GTK_IMAGE (gtk_image_new_from_surface (surface));
+      else
+        gtk_image_set_from_surface (old_widget, surface);
+    }
+#else
   /* This is a workaround to make icons look good on pseudo color
      displays.  Apparently GTK expects the images to have an alpha
      channel.  If they don't, insensitive and activated icons will
@@ -414,6 +374,7 @@ xg_get_image_for_pixmap (struct frame *f,
 
       g_object_unref (G_OBJECT (icon_buf));
     }
+#endif
 
   return GTK_WIDGET (old_widget);
 }
@@ -625,8 +586,6 @@ xg_check_special_colors (struct frame *f,
    We use that to pop down the tooltip.  This happens if Gtk+ for some
    reason wants to change or hide the tooltip.  */
 
-#ifdef USE_GTK_TOOLTIP
-
 static void
 hierarchy_ch_cb (GtkWidget *widget,
                  GtkWidget *previous_toplevel,
@@ -693,8 +652,6 @@ qttip_cb (GtkWidget  *widget,
   return FALSE;
 }
 
-#endif /* USE_GTK_TOOLTIP */
-
 /* Prepare a tooltip to be shown, i.e. calculate WIDTH and HEIGHT.
    Return true if a system tooltip is available.  */
 
@@ -704,9 +661,6 @@ xg_prepare_tooltip (struct frame *f,
                     int *width,
                     int *height)
 {
-#ifndef USE_GTK_TOOLTIP
-  return 0;
-#else
   struct x_output *x = f->output_data.x;
   GtkWidget *widget;
   GdkWindow *gwin;
@@ -750,7 +704,6 @@ xg_prepare_tooltip (struct frame *f,
   unblock_input ();
 
   return TRUE;
-#endif /* USE_GTK_TOOLTIP */
 }
 
 /* Show the tooltip at ROOT_X and ROOT_Y.
@@ -759,7 +712,6 @@ xg_prepare_tooltip (struct frame *f,
 void
 xg_show_tooltip (struct frame *f, int root_x, int root_y)
 {
-#ifdef USE_GTK_TOOLTIP
   struct x_output *x = f->output_data.x;
   if (x->ttip_window)
     {
@@ -769,7 +721,6 @@ xg_show_tooltip (struct frame *f, int root_x, int root_y)
       gtk_widget_show (GTK_WIDGET (x->ttip_window));
       unblock_input ();
     }
-#endif
 }
 
 
@@ -779,7 +730,6 @@ xg_show_tooltip (struct frame *f, int root_x, int root_y)
 bool
 xg_hide_tooltip (struct frame *f)
 {
-#ifdef USE_GTK_TOOLTIP
   if (f->output_data.x->ttip_window)
     {
       GtkWindow *win = f->output_data.x->ttip_window;
@@ -798,7 +748,6 @@ xg_hide_tooltip (struct frame *f)
 
       return TRUE;
     }
-#endif
   return FALSE;
 }
 
@@ -917,7 +866,7 @@ xg_frame_resized (struct frame *f, int pixelwidth, int 
pixelheight)
       || pixelwidth != FRAME_PIXEL_WIDTH (f)
       || pixelheight != FRAME_PIXEL_HEIGHT (f))
     {
-      x_clear_under_internal_border (f);
+      FRAME_RIF (f)->clear_under_internal_border (f);
       change_frame_size (f, width, height, 0, 1, 0, 1);
       SET_FRAME_GARBAGED (f);
       cancel_mouse_face (f);
@@ -945,7 +894,7 @@ xg_frame_set_char_size (struct frame *f, int width, int 
height)
                       &gwidth, &gheight);
 
   /* Do this before resize, as we don't know yet if we will be resized.  */
-  x_clear_under_internal_border (f);
+  FRAME_RIF (f)->clear_under_internal_border (f);
 
   totalheight /= xg_get_scale (f);
   totalwidth /= xg_get_scale (f);
@@ -965,7 +914,7 @@ xg_frame_set_char_size (struct frame *f, int width, int 
height)
     {
       frame_size_history_add
        (f, Qxg_frame_set_char_size_1, width, height,
-        list2 (make_fixnum (gheight), make_fixnum (totalheight)));
+        list2i (gheight, totalheight));
 
       gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
                         gwidth, totalheight);
@@ -974,7 +923,7 @@ xg_frame_set_char_size (struct frame *f, int width, int 
height)
     {
       frame_size_history_add
        (f, Qxg_frame_set_char_size_2, width, height,
-        list2 (make_fixnum (gwidth), make_fixnum (totalwidth)));
+        list2i (gwidth, totalwidth));
 
       gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
                         totalwidth, gheight);
@@ -983,7 +932,7 @@ xg_frame_set_char_size (struct frame *f, int width, int 
height)
     {
       frame_size_history_add
        (f, Qxg_frame_set_char_size_3, width, height,
-        list2 (make_fixnum (totalwidth), make_fixnum (totalheight)));
+        list2i (totalwidth, totalheight));
 
       gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
                         totalwidth, totalheight);
@@ -1011,7 +960,7 @@ xg_frame_set_char_size (struct frame *f, int width, int 
height)
        /* Try to restore fullscreen state.  */
        {
          store_frame_param (f, Qfullscreen, fullscreen);
-         x_set_fullscreen (f, fullscreen, fullscreen);
+         gui_set_fullscreen (f, fullscreen, fullscreen);
        }
     }
   else
@@ -1129,8 +1078,8 @@ style_changed_cb (GObject *go,
               && FRAME_X_P (f)
               && FRAME_X_DISPLAY (f) == dpy)
             {
-              x_set_scroll_bar_default_width (f);
-              x_set_scroll_bar_default_height (f);
+              FRAME_TERMINAL (f)->set_scroll_bar_default_width_hook (f);
+              FRAME_TERMINAL (f)->set_scroll_bar_default_height_hook (f);
               xg_frame_set_char_size (f, FRAME_TEXT_WIDTH (f), 
FRAME_TEXT_HEIGHT (f));
             }
         }
@@ -1175,7 +1124,7 @@ xg_create_frame_widgets (struct frame *f)
      has backported it to Gtk+ 2.0 and they add the resize grip for
      Gtk+ 2.0 applications also.  But it has a bug that makes Emacs loop
      forever, so disable the grip.  */
-#if (! GTK_CHECK_VERSION (3, 0, 0) \
+#if (! defined HAVE_GTK3 \
      && defined HAVE_GTK_WINDOW_SET_HAS_RESIZE_GRIP)
   gtk_window_set_has_resize_grip (GTK_WINDOW (wtop), FALSE);
 #endif
@@ -1310,14 +1259,12 @@ xg_create_frame_widgets (struct frame *f)
        gdk_window_set_override_redirect (gwin, TRUE);
     }
 
-#ifdef USE_GTK_TOOLTIP
   /* Steal a tool tip window we can move ourselves.  */
   f->output_data.x->ttip_widget = 0;
   f->output_data.x->ttip_lbl = 0;
   f->output_data.x->ttip_window = 0;
   gtk_widget_set_tooltip_text (wtop, "Dummy text");
   g_signal_connect (wtop, "query-tooltip", G_CALLBACK (qttip_cb), f);
-#endif
 
   {
     GdkScreen *screen = gtk_widget_get_screen (wtop);
@@ -1345,9 +1292,7 @@ xg_free_frame_widgets (struct frame *f)
 {
   if (FRAME_GTK_OUTER_WIDGET (f))
     {
-#ifdef USE_GTK_TOOLTIP
       struct x_output *x = f->output_data.x;
-#endif
       struct xg_frame_tb_info *tbinfo
         = g_object_get_data (G_OBJECT (FRAME_GTK_OUTER_WIDGET (f)),
                              TB_INFO_KEY);
@@ -1360,12 +1305,10 @@ xg_free_frame_widgets (struct frame *f)
       FRAME_X_WINDOW (f) = 0; /* Set to avoid XDestroyWindow in xterm.c */
       FRAME_X_RAW_DRAWABLE (f) = 0;
       FRAME_GTK_OUTER_WIDGET (f) = 0;
-#ifdef USE_GTK_TOOLTIP
       if (x->ttip_lbl)
         gtk_widget_destroy (x->ttip_lbl);
       if (x->ttip_widget)
         g_object_unref (G_OBJECT (x->ttip_widget));
-#endif
     }
 }
 
@@ -1383,7 +1326,6 @@ x_wm_set_size_hint (struct frame *f, long int flags, bool 
user_position)
   GdkGeometry size_hints;
   gint hint_flags = 0;
   int base_width, base_height;
-  int min_rows = 0, min_cols = 0;
   int win_gravity = f->win_gravity;
   Lisp_Object fs_state, frame;
   int scale = xg_get_scale (f);
@@ -1432,13 +1374,10 @@ x_wm_set_size_hint (struct frame *f, long int flags, 
bool user_position)
   base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 1)
     + FRAME_MENUBAR_HEIGHT (f) + FRAME_TOOLBAR_HEIGHT (f);
 
-  if (min_cols > 0) --min_cols; /* We used one col in base_width = ... 1); */
-  if (min_rows > 0) --min_rows; /* We used one row in base_height = ... 1); */
-
   size_hints.base_width = base_width;
   size_hints.base_height = base_height;
-  size_hints.min_width  = base_width + min_cols * FRAME_COLUMN_WIDTH (f);
-  size_hints.min_height = base_height + min_rows * FRAME_LINE_HEIGHT (f);
+  size_hints.min_width  = base_width;
+  size_hints.min_height = base_height;
 
   /* These currently have a one to one mapping with the X values, but I
      don't think we should rely on that.  */
@@ -1547,7 +1486,6 @@ xg_set_undecorated (struct frame *f, Lisp_Object 
undecorated)
 void
 xg_frame_restack (struct frame *f1, struct frame *f2, bool above_flag)
 {
-#if GTK_CHECK_VERSION (2, 18, 0)
   block_input ();
   if (FRAME_GTK_OUTER_WIDGET (f1) && FRAME_GTK_OUTER_WIDGET (f2))
     {
@@ -1562,7 +1500,6 @@ xg_frame_restack (struct frame *f1, struct frame *f2, 
bool above_flag)
       x_sync (f1);
     }
   unblock_input ();
-#endif
 }
 
 
@@ -2202,7 +2139,7 @@ xg_get_file_name (struct frame *f,
 
 #ifdef HAVE_FREETYPE
 
-#if USE_NEW_GTK_FONT_CHOOSER
+#ifdef HAVE_GTK3
 
 #define XG_WEIGHT_TO_SYMBOL(w)                 \
   (w <= PANGO_WEIGHT_THIN ? Qextra_light       \
@@ -2219,7 +2156,7 @@ xg_get_file_name (struct frame *f,
    : s == PANGO_STYLE_ITALIC ? Qitalic         \
    : Qnormal)
 
-#endif /* USE_NEW_GTK_FONT_CHOOSER */
+#endif /* HAVE_GTK3 */
 
 
 static char *x_last_font_name;
@@ -2266,7 +2203,7 @@ xg_get_font (struct frame *f, const char *default_name)
   done = xg_dialog_run (f, w);
   if (done == GTK_RESPONSE_OK)
     {
-#if USE_NEW_GTK_FONT_CHOOSER
+#ifdef HAVE_GTK3
       /* Use the GTK3 font chooser.  */
       PangoFontDescription *desc
        = gtk_font_chooser_get_font_desc (GTK_FONT_CHOOSER (w));
@@ -2306,7 +2243,7 @@ xg_get_font (struct frame *f, const char *default_name)
          g_free (x_last_font_name);
          x_last_font_name = font_name;
        }
-#endif /* USE_NEW_GTK_FONT_CHOOSER */
+#endif /* HAVE_GTK3 */
     }
 
   gtk_widget_destroy (w);
@@ -3027,9 +2964,7 @@ xg_update_menubar (GtkWidget *menubar,
              bridge that might be loaded) that the item's label has
              changed.  */
           gtk_label_set_text (wlabel, utf8_label);
-#if GTK_CHECK_VERSION (2, 16, 0)
           g_object_notify (G_OBJECT (witem), "label");
-#endif
           if (utf8_label) g_free (utf8_label);
           iter = g_list_next (iter);
           val = val->next;
@@ -3208,10 +3143,8 @@ xg_update_menu_item (widget_value *val,
         }
     }
 
-#if GTK_CHECK_VERSION (2, 16, 0)
   if (label_changed) /* See comment in xg_update_menubar.  */
     g_object_notify (G_OBJECT (w), "label");
-#endif
 }
 
 /* Update the toggle menu item W so it corresponds to VAL.  */
@@ -3310,7 +3243,7 @@ xg_update_submenu (GtkWidget *submenu,
           {
             /* Not a submenu anymore.  */
             g_object_ref (G_OBJECT (sub));
-            remove_submenu (witem);
+            gtk_menu_item_set_submenu (witem, NULL);
             gtk_widget_destroy (sub);
           }
         else if (cur->contents)
@@ -4258,23 +4191,16 @@ xg_get_page_setup (void)
       eassume (false);
     }
 
-  return listn (CONSTYPE_HEAP, 7,
-               Fcons (Qorientation, orientation_symbol),
-#define MAKE_FLOAT_PAGE_SETUP(f)  make_float (f (page_setup, GTK_UNIT_POINTS))
-               Fcons (Qwidth,
-                      MAKE_FLOAT_PAGE_SETUP (gtk_page_setup_get_page_width)),
-               Fcons (Qheight,
-                      MAKE_FLOAT_PAGE_SETUP (gtk_page_setup_get_page_height)),
-               Fcons (Qleft_margin,
-                      MAKE_FLOAT_PAGE_SETUP (gtk_page_setup_get_left_margin)),
-               Fcons (Qright_margin,
-                      MAKE_FLOAT_PAGE_SETUP (gtk_page_setup_get_right_margin)),
-               Fcons (Qtop_margin,
-                      MAKE_FLOAT_PAGE_SETUP (gtk_page_setup_get_top_margin)),
-               Fcons (Qbottom_margin,
-                      MAKE_FLOAT_PAGE_SETUP (gtk_page_setup_get_bottom_margin))
-#undef MAKE_FLOAT_PAGE_SETUP
-               );
+#define GETSETUP(f) make_float (f (page_setup, GTK_UNIT_POINTS))
+  return
+    list (Fcons (Qorientation, orientation_symbol),
+         Fcons (Qwidth, GETSETUP (gtk_page_setup_get_page_width)),
+         Fcons (Qheight, GETSETUP (gtk_page_setup_get_page_height)),
+         Fcons (Qleft_margin, GETSETUP (gtk_page_setup_get_left_margin)),
+         Fcons (Qright_margin, GETSETUP (gtk_page_setup_get_right_margin)),
+         Fcons (Qtop_margin, GETSETUP (gtk_page_setup_get_top_margin)),
+         Fcons (Qbottom_margin, GETSETUP (gtk_page_setup_get_bottom_margin)));
+#undef GETSETUP
 }
 
 static void
@@ -4299,7 +4225,7 @@ xg_print_frames_dialog (Lisp_Object frames)
     gtk_print_operation_set_print_settings (print, print_settings);
   if (page_setup != NULL)
     gtk_print_operation_set_default_page_setup (print, page_setup);
-  gtk_print_operation_set_n_pages (print, XFIXNUM (Flength (frames)));
+  gtk_print_operation_set_n_pages (print, list_length (frames));
   g_signal_connect (print, "draw-page", G_CALLBACK (draw_page), &frames);
   res = gtk_print_operation_run (print, 
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
                                  NULL, NULL);
@@ -4398,7 +4324,7 @@ xg_tool_bar_callback (GtkWidget *w, gpointer client_data)
 
   /* Return focus to the frame after we have clicked on a detached
      tool bar button. */
-  x_focus_frame (f, false);
+  FRAME_TERMINAL (f)->focus_frame_hook (f, false);
 }
 
 static GtkWidget *
@@ -4485,14 +4411,6 @@ xg_tool_bar_item_expose_callback (GtkWidget *w,
 }
 #endif
 
-#ifdef HAVE_GTK_ORIENTABLE_SET_ORIENTATION
-#define toolbar_set_orientation(w, o) \
-  gtk_orientable_set_orientation (GTK_ORIENTABLE (w), o)
-#else
-#define toolbar_set_orientation(w, o) \
-  gtk_toolbar_set_orientation (GTK_TOOLBAR (w), o)
-#endif
-
 /* Attach a tool bar to frame F.  */
 
 static void
@@ -4502,10 +4420,10 @@ xg_pack_tool_bar (struct frame *f, Lisp_Object pos)
   bool into_hbox = EQ (pos, Qleft) || EQ (pos, Qright);
   GtkWidget *top_widget = x->toolbar_widget;
 
-  toolbar_set_orientation (x->toolbar_widget,
-                           into_hbox
-                           ? GTK_ORIENTATION_VERTICAL
-                           : GTK_ORIENTATION_HORIZONTAL);
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (x->toolbar_widget),
+                                  into_hbox
+                                  ? GTK_ORIENTATION_VERTICAL
+                                  : GTK_ORIENTATION_HORIZONTAL);
 
   if (into_hbox)
     {
@@ -4558,7 +4476,7 @@ static void
 xg_create_tool_bar (struct frame *f)
 {
   struct x_output *x = f->output_data.x;
-#if GTK_CHECK_VERSION (3, 3, 6)
+#ifdef HAVE_GTK3
   GtkStyleContext *gsty;
 #endif
   struct xg_frame_tb_info *tbinfo
@@ -4582,10 +4500,11 @@ xg_create_tool_bar (struct frame *f)
   gtk_widget_set_name (x->toolbar_widget, "emacs-toolbar");
 
   gtk_toolbar_set_style (GTK_TOOLBAR (x->toolbar_widget), GTK_TOOLBAR_ICONS);
-  toolbar_set_orientation (x->toolbar_widget, GTK_ORIENTATION_HORIZONTAL);
+  gtk_orientable_set_orientation (GTK_ORIENTABLE (x->toolbar_widget),
+                                  GTK_ORIENTATION_HORIZONTAL);
   g_signal_connect (x->toolbar_widget, "size-allocate",
                     G_CALLBACK (tb_size_cb), f);
-#if GTK_CHECK_VERSION (3, 3, 6)
+#ifdef HAVE_GTK3
   gsty = gtk_widget_get_style_context (x->toolbar_widget);
   gtk_style_context_add_class (gsty, "primary-toolbar");
 #endif
@@ -4638,7 +4557,7 @@ xg_make_tool_item (struct frame *f,
   GtkWidget *wb = gtk_button_new ();
   /* The eventbox is here so we can have tooltips on disabled items.  */
   GtkWidget *weventbox = gtk_event_box_new ();
-#if GTK_CHECK_VERSION (3, 3, 6)
+#ifdef HAVE_GTK3
   GtkCssProvider *css_prov = gtk_css_provider_new ();
   GtkStyleContext *gsty;
 
@@ -4770,9 +4689,15 @@ xg_tool_item_stale_p (GtkWidget *wbutton, const char 
*stock_name,
     {
       gpointer gold_img = g_object_get_data (G_OBJECT (wimage),
                                              XG_TOOL_BAR_IMAGE_DATA);
+#if defined USE_CAIRO && defined HAVE_GTK3
+      void *old_img = (void *) gold_img;
+      if (old_img != img->cr_data)
+       return 1;
+#else
       Pixmap old_img = (Pixmap) gold_img;
       if (old_img != img->pixmap)
        return 1;
+#endif
     }
 
   /* Check button configuration and label.  */
@@ -4837,7 +4762,7 @@ find_icon_from_name (char *name,
                      GtkIconTheme *icon_theme,
                      char **icon_name)
 {
-#if ! GTK_CHECK_VERSION (3, 10, 0)
+#ifndef HAVE_GTK3
   GtkStockItem stock_item;
 #endif
 
@@ -4850,7 +4775,7 @@ find_icon_from_name (char *name,
         *icon_name = NULL;
     }
 
-#if ! GTK_CHECK_VERSION (3, 10, 0)
+#ifndef HAVE_GTK3
   else if (gtk_stock_lookup (name, &stock_item))
     *icon_name = NULL;
 #endif
@@ -5064,7 +4989,13 @@ update_frame_tool_bar (struct frame *f)
           img = IMAGE_FROM_ID (f, img_id);
           prepare_image_for_display (f, img);
 
-          if (img->load_failed_p || img->pixmap == None)
+          if (img->load_failed_p
+#if defined USE_CAIRO && defined HAVE_GTK3
+             || img->cr_data == NULL
+#else
+             || img->pixmap == None
+#endif
+             )
             {
               if (ti)
                gtk_container_remove (GTK_CONTAINER (wtoolbar),
@@ -5094,7 +5025,7 @@ update_frame_tool_bar (struct frame *f)
          else if (stock_name)
             {
 
-#if GTK_CHECK_VERSION (3, 10, 0)
+#ifdef HAVE_GTK3
               w = gtk_image_new_from_icon_name (stock_name, icon_size);
 #else
               w = gtk_image_new_from_stock (stock_name, icon_size);
@@ -5114,7 +5045,12 @@ update_frame_tool_bar (struct frame *f)
             {
               w = xg_get_image_for_pixmap (f, img, x->widget, NULL);
               g_object_set_data (G_OBJECT (w), XG_TOOL_BAR_IMAGE_DATA,
-                                 (gpointer)img->pixmap);
+#if defined USE_CAIRO && defined HAVE_GTK3
+                                 (gpointer)img->cr_data
+#else
+                                 (gpointer)img->pixmap
+#endif
+                                );
             }
 
 #if GTK_CHECK_VERSION (3, 14, 0)
@@ -5285,7 +5221,7 @@ xg_initialize (void)
 
   settings = gtk_settings_get_for_screen (gdk_display_get_default_screen
                                           (gdk_display_get_default ()));
-#if ! GTK_CHECK_VERSION (3, 10, 0)
+#ifndef HAVE_GTK3
   /* Remove F10 as a menu accelerator, it does not mix well with Emacs key
      bindings.  It doesn't seem to be any way to remove properties,
      so we set it to "" which in means "no key".  */
@@ -5324,7 +5260,9 @@ xg_initialize (void)
   x_last_font_name = NULL;
 #endif
 
+#ifdef HAVE_XWIDGETS
   xg_gtk_initialized = true;
+#endif
 }
 
 #endif /* USE_GTK */
diff --git a/src/gtkutil.h b/src/gtkutil.h
index 3b07407..ec89978 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -1,6 +1,6 @@
 /* Definitions and headers for GTK widgets.
 
-Copyright (C) 2003-2018 Free Software Foundation, Inc.
+Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/image.c b/src/image.c
index b54cd76..bf59498 100644
--- a/src/image.c
+++ b/src/image.c
@@ -1,6 +1,6 @@
 /* Functions for image support on window system.
 
-Copyright (C) 1989, 1992-2018 Free Software Foundation, Inc.
+Copyright (C) 1989, 1992-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -46,6 +46,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "coding.h"
 #include "termhooks.h"
 #include "font.h"
+#include "pdumper.h"
 
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
@@ -88,8 +89,6 @@ typedef struct w32_bitmap_record Bitmap_Record;
 #define PIX_MASK_RETAIN        0
 #define PIX_MASK_DRAW  1
 
-#define x_defined_color w32_defined_color
-
 #endif /* HAVE_NTGUI */
 
 #ifdef HAVE_NS
@@ -100,8 +99,6 @@ typedef struct ns_bitmap_record Bitmap_Record;
 
 #define PIX_MASK_RETAIN        0
 
-#define x_defined_color(f, name, color_def, alloc) \
-  ns_defined_color (f, name, color_def, alloc, 0)
 #endif /* HAVE_NS */
 
 #if (defined HAVE_X_WINDOWS \
@@ -110,9 +107,9 @@ typedef struct ns_bitmap_record Bitmap_Record;
 # define COLOR_TABLE_SUPPORT 1
 #endif
 
-static void x_disable_image (struct frame *, struct image *);
-static void x_edge_detection (struct frame *, struct image *, Lisp_Object,
-                              Lisp_Object);
+static void image_disable_image (struct frame *, struct image *);
+static void image_edge_detection (struct frame *, struct image *, Lisp_Object,
+                                  Lisp_Object);
 
 static void init_color_table (void);
 static unsigned long lookup_rgb_color (struct frame *f, int r, int g, int b);
@@ -128,8 +125,8 @@ static unsigned long *colors_in_color_table (int *n);
    Bitmap indices are guaranteed to be > 0, so a negative number can
    be used to indicate no bitmap.
 
-   If you use x_create_bitmap_from_data, then you must keep track of
-   the bitmaps yourself.  That is, creating a bitmap from the same
+   If you use image_create_bitmap_from_data, then you must keep track
+   of the bitmaps yourself.  That is, creating a bitmap from the same
    data more than once will not be caught.  */
 
 #ifdef HAVE_NS
@@ -168,7 +165,7 @@ x_bitmap_width (struct frame *f, ptrdiff_t id)
 
 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
 ptrdiff_t
-x_bitmap_pixmap (struct frame *f, ptrdiff_t id)
+image_bitmap_pixmap (struct frame *f, ptrdiff_t id)
 {
   /* HAVE_NTGUI needs the explicit cast here.  */
   return (ptrdiff_t) FRAME_DISPLAY_INFO (f)->bitmaps[id - 1].pixmap;
@@ -186,7 +183,7 @@ x_bitmap_mask (struct frame *f, ptrdiff_t id)
 /* Allocate a new bitmap record.  Returns index of new record.  */
 
 static ptrdiff_t
-x_allocate_bitmap_record (struct frame *f)
+image_allocate_bitmap_record (struct frame *f)
 {
   Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f);
   ptrdiff_t i;
@@ -207,7 +204,7 @@ x_allocate_bitmap_record (struct frame *f)
 /* Add one reference to the reference count of the bitmap with id ID.  */
 
 void
-x_reference_bitmap (struct frame *f, ptrdiff_t id)
+image_reference_bitmap (struct frame *f, ptrdiff_t id)
 {
   ++FRAME_DISPLAY_INFO (f)->bitmaps[id - 1].refcount;
 }
@@ -215,7 +212,8 @@ x_reference_bitmap (struct frame *f, ptrdiff_t id)
 /* Create a bitmap for frame F from a HEIGHT x WIDTH array of bits at BITS.  */
 
 ptrdiff_t
-x_create_bitmap_from_data (struct frame *f, char *bits, unsigned int width, 
unsigned int height)
+image_create_bitmap_from_data (struct frame *f, char *bits,
+                               unsigned int width, unsigned int height)
 {
   Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f);
   ptrdiff_t id;
@@ -245,7 +243,7 @@ x_create_bitmap_from_data (struct frame *f, char *bits, 
unsigned int width, unsi
       return -1;
 #endif
 
-  id = x_allocate_bitmap_record (f);
+  id = image_allocate_bitmap_record (f);
 
 #ifdef HAVE_NS
   dpyinfo->bitmaps[id - 1].img = bitmap;
@@ -275,7 +273,7 @@ x_create_bitmap_from_data (struct frame *f, char *bits, 
unsigned int width, unsi
 /* Create bitmap from file FILE for frame F.  */
 
 ptrdiff_t
-x_create_bitmap_from_file (struct frame *f, Lisp_Object file)
+image_create_bitmap_from_file (struct frame *f, Lisp_Object file)
 {
 #ifdef HAVE_NTGUI
   return -1;  /* W32_TODO : bitmap support */
@@ -291,7 +289,7 @@ x_create_bitmap_from_file (struct frame *f, Lisp_Object 
file)
       return -1;
 
 
-  id = x_allocate_bitmap_record (f);
+  id = image_allocate_bitmap_record (f);
   dpyinfo->bitmaps[id - 1].img = bitmap;
   dpyinfo->bitmaps[id - 1].refcount = 1;
   dpyinfo->bitmaps[id - 1].file = xlispstrdup (file);
@@ -334,7 +332,7 @@ x_create_bitmap_from_file (struct frame *f, Lisp_Object 
file)
   if (result != BitmapSuccess)
     return -1;
 
-  id = x_allocate_bitmap_record (f);
+  id = image_allocate_bitmap_record (f);
   dpyinfo->bitmaps[id - 1].pixmap = bitmap;
   dpyinfo->bitmaps[id - 1].have_mask = false;
   dpyinfo->bitmaps[id - 1].refcount = 1;
@@ -376,7 +374,7 @@ free_bitmap_record (Display_Info *dpyinfo, Bitmap_Record 
*bm)
 /* Remove reference to bitmap with id number ID.  */
 
 void
-x_destroy_bitmap (struct frame *f, ptrdiff_t id)
+image_destroy_bitmap (struct frame *f, ptrdiff_t id)
 {
   Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f);
 
@@ -396,7 +394,7 @@ x_destroy_bitmap (struct frame *f, ptrdiff_t id)
 /* Free all the bitmaps for the display specified by DPYINFO.  */
 
 void
-x_destroy_all_bitmaps (Display_Info *dpyinfo)
+image_destroy_all_bitmaps (Display_Info *dpyinfo)
 {
   ptrdiff_t i;
   Bitmap_Record *bm = dpyinfo->bitmaps;
@@ -408,9 +406,14 @@ x_destroy_all_bitmaps (Display_Info *dpyinfo)
   dpyinfo->bitmaps_last = 0;
 }
 
-static bool x_create_x_image_and_pixmap (struct frame *, int, int, int,
-                                        XImagePtr *, Pixmap *);
-static void x_destroy_x_image (XImagePtr ximg);
+#ifndef HAVE_XRENDER
+/* Required for the definition of image_create_x_image_and_pixmap_1 below.  */
+typedef void Picture;
+#endif
+
+static bool image_create_x_image_and_pixmap_1 (struct frame *, int, int, int,
+                                               XImagePtr *, Pixmap *, Picture 
*);
+static void image_destroy_x_image (XImagePtr ximg);
 
 #ifdef HAVE_NTGUI
 static XImagePtr_or_DC image_get_x_image_or_dc (struct frame *, struct image *,
@@ -458,7 +461,7 @@ x_create_bitmap_mask (struct frame *f, ptrdiff_t id)
   if (!(id > 0))
     return;
 
-  pixmap = x_bitmap_pixmap (f, id);
+  pixmap = image_bitmap_pixmap (f, id);
   width = x_bitmap_width (f, id);
   height = x_bitmap_height (f, id);
 
@@ -472,7 +475,8 @@ x_create_bitmap_mask (struct frame *f, ptrdiff_t id)
       return;
     }
 
-  result = x_create_x_image_and_pixmap (f, width, height, 1, &mask_img, &mask);
+  result = image_create_x_image_and_pixmap_1 (f, width, height, 1,
+                                              &mask_img, &mask, NULL);
 
   unblock_input ();
   if (!result)
@@ -516,7 +520,7 @@ x_create_bitmap_mask (struct frame *f, ptrdiff_t id)
   dpyinfo->bitmaps[id - 1].mask = mask;
 
   XDestroyImage (ximg);
-  x_destroy_x_image (mask_img);
+  image_destroy_x_image (mask_img);
 }
 
 #endif /* HAVE_X_WINDOWS */
@@ -560,9 +564,9 @@ static struct image_type *image_types;
 /* Forward function prototypes.  */
 
 static struct image_type *lookup_image_type (Lisp_Object);
-static void x_laplace (struct frame *, struct image *);
-static void x_emboss (struct frame *, struct image *);
-static void x_build_heuristic_mask (struct frame *, struct image *,
+static void image_laplace (struct frame *, struct image *);
+static void image_emboss (struct frame *, struct image *);
+static void image_build_heuristic_mask (struct frame *, struct image *,
                                     Lisp_Object);
 #ifdef WINDOWSNT
 #define CACHE_IMAGE_TYPE(type, status) \
@@ -1011,6 +1015,13 @@ free_image (struct frame *f, struct image *img)
 
       c->images[img->id] = NULL;
 
+#ifdef HAVE_XRENDER
+      if (img->picture)
+        XRenderFreePicture (FRAME_X_DISPLAY (f), img->picture);
+      if (img->mask_picture)
+        XRenderFreePicture (FRAME_X_DISPLAY (f), img->mask_picture);
+#endif
+
       /* Windows NT redefines 'free', but in this file, we need to
          avoid the redefinition.  */
 #ifdef WINDOWSNT
@@ -1143,24 +1154,22 @@ get_spec_bg_or_alpha_as_argb (struct image *img,
   return bgcolor;
 }
 
-static void
-create_cairo_image_surface (struct image *img,
-                            unsigned char *data,
-                            int width,
-                            int height)
+static cairo_surface_t *
+create_cairo_image_surface (int width, int height)
 {
-  cairo_surface_t *surface;
   cairo_format_t format = CAIRO_FORMAT_ARGB32;
-  int stride = cairo_format_stride_for_width (format, width);
-  surface = cairo_image_surface_create_for_data (data,
-                                                 format,
-                                                 width,
-                                                 height,
-                                                 stride);
-  img->width = width;
-  img->height = height;
+  eassert (cairo_format_stride_for_width (format, width) == width * 4);
+
+  return cairo_image_surface_create (format, width, height);
+}
+
+static void
+set_cairo_image_surface (struct image *img, cairo_surface_t *surface)
+{
+  cairo_surface_mark_dirty (surface);
+  img->width = cairo_image_surface_get_width (surface);
+  img->height = cairo_image_surface_get_height (surface);
   img->cr_data = surface;
-  img->cr_data2 = data;
   img->pixmap = 0;
 }
 #endif
@@ -1297,22 +1306,6 @@ image_background_transparent (struct image *img, struct 
frame *f, XImagePtr_or_D
   return img->background_transparent;
 }
 
-#if defined (HAVE_PNG) || defined (HAVE_IMAGEMAGICK) || defined (HAVE_RSVG)
-
-/* Store F's background color into *BGCOLOR.  */
-static void
-x_query_frame_background_color (struct frame *f, XColor *bgcolor)
-{
-#ifndef HAVE_NS
-  bgcolor->pixel = FRAME_BACKGROUND_PIXEL (f);
-  x_query_color (f, bgcolor);
-#else
-  ns_query_color (FRAME_BACKGROUND_COLOR (f), bgcolor, 1);
-#endif
-}
-
-#endif /* HAVE_PNG || HAVE_IMAGEMAGICK || HAVE_RSVG */
-
 /***********************************************************************
                  Helper functions for X image types
  ***********************************************************************/
@@ -1329,7 +1322,7 @@ x_query_frame_background_color (struct frame *f, XColor 
*bgcolor)
 #define CLEAR_IMAGE_COLORS     (1 << 2)
 
 static void
-x_clear_image_1 (struct frame *f, struct image *img, int flags)
+image_clear_image_1 (struct frame *f, struct image *img, int flags)
 {
   if (flags & CLEAR_IMAGE_PIXMAP)
     {
@@ -1343,7 +1336,7 @@ x_clear_image_1 (struct frame *f, struct image *img, int 
flags)
 #ifdef HAVE_X_WINDOWS
       if (img->ximg)
        {
-         x_destroy_x_image (img->ximg);
+         image_destroy_x_image (img->ximg);
          img->ximg = NULL;
          img->background_valid = 0;
        }
@@ -1361,7 +1354,7 @@ x_clear_image_1 (struct frame *f, struct image *img, int 
flags)
 #ifdef HAVE_X_WINDOWS
       if (img->mask_img)
        {
-         x_destroy_x_image (img->mask_img);
+         image_destroy_x_image (img->mask_img);
          img->mask_img = NULL;
          img->background_transparent_valid = 0;
        }
@@ -1384,15 +1377,14 @@ x_clear_image_1 (struct frame *f, struct image *img, 
int flags)
 /* Free X resources of image IMG which is used on frame F.  */
 
 static void
-x_clear_image (struct frame *f, struct image *img)
+image_clear_image (struct frame *f, struct image *img)
 {
   block_input ();
 #ifdef USE_CAIRO
   if (img->cr_data)
     cairo_surface_destroy ((cairo_surface_t *)img->cr_data);
-  if (img->cr_data2) xfree (img->cr_data2);
 #endif
-  x_clear_image_1 (f, img,
+  image_clear_image_1 (f, img,
                   CLEAR_IMAGE_PIXMAP | CLEAR_IMAGE_MASK | CLEAR_IMAGE_COLORS);
   unblock_input ();
 }
@@ -1404,15 +1396,19 @@ x_clear_image (struct frame *f, struct image *img)
    color.  */
 
 static unsigned long
-x_alloc_image_color (struct frame *f, struct image *img, Lisp_Object 
color_name,
-                    unsigned long dflt)
+image_alloc_image_color (struct frame *f, struct image *img,
+                         Lisp_Object color_name, unsigned long dflt)
 {
   XColor color;
   unsigned long result;
 
   eassert (STRINGP (color_name));
 
-  if (x_defined_color (f, SSDATA (color_name), &color, 1)
+  if (FRAME_TERMINAL (f)->defined_color_hook (f,
+                                              SSDATA (color_name),
+                                              &color,
+                                              true,
+                                              false)
       && img->ncolors < min (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *img->colors,
                             INT_MAX))
     {
@@ -1540,7 +1536,7 @@ clear_image_cache (struct frame *f, Lisp_Object filter)
 {
   struct image_cache *c = FRAME_IMAGE_CACHE (f);
 
-  if (c)
+  if (c && !f->inhibit_clear_image_cache)
     {
       ptrdiff_t i, nfreed = 0;
 
@@ -1704,7 +1700,7 @@ postprocess_image (struct frame *f, struct image *img)
 
       mask = image_spec_value (spec, QCheuristic_mask, NULL);
       if (!NILP (mask))
-       x_build_heuristic_mask (f, img, mask);
+       image_build_heuristic_mask (f, img, mask);
       else
        {
          bool found_p;
@@ -1712,41 +1708,192 @@ postprocess_image (struct frame *f, struct image *img)
          mask = image_spec_value (spec, QCmask, &found_p);
 
          if (EQ (mask, Qheuristic))
-           x_build_heuristic_mask (f, img, Qt);
+           image_build_heuristic_mask (f, img, Qt);
          else if (CONSP (mask)
                   && EQ (XCAR (mask), Qheuristic))
            {
              if (CONSP (XCDR (mask)))
-               x_build_heuristic_mask (f, img, XCAR (XCDR (mask)));
+               image_build_heuristic_mask (f, img, XCAR (XCDR (mask)));
              else
-               x_build_heuristic_mask (f, img, XCDR (mask));
+               image_build_heuristic_mask (f, img, XCDR (mask));
            }
          else if (NILP (mask) && found_p && img->mask)
-           x_clear_image_1 (f, img, CLEAR_IMAGE_MASK);
+           image_clear_image_1 (f, img, CLEAR_IMAGE_MASK);
        }
 
 
       /* Should we apply an image transformation algorithm?  */
       conversion = image_spec_value (spec, QCconversion, NULL);
       if (EQ (conversion, Qdisabled))
-       x_disable_image (f, img);
+       image_disable_image (f, img);
       else if (EQ (conversion, Qlaplace))
-       x_laplace (f, img);
+       image_laplace (f, img);
       else if (EQ (conversion, Qemboss))
-       x_emboss (f, img);
+       image_emboss (f, img);
       else if (CONSP (conversion)
               && EQ (XCAR (conversion), Qedge_detection))
        {
          Lisp_Object tem;
          tem = XCDR (conversion);
          if (CONSP (tem))
-           x_edge_detection (f, img,
-                             Fplist_get (tem, QCmatrix),
-                             Fplist_get (tem, QCcolor_adjustment));
+           image_edge_detection (f, img,
+                                  Fplist_get (tem, QCmatrix),
+                                  Fplist_get (tem, QCcolor_adjustment));
        }
     }
 }
 
+#if defined (HAVE_IMAGEMAGICK) || defined (HAVE_NATIVE_SCALING)
+/* Scale an image size by returning SIZE / DIVISOR * MULTIPLIER,
+   safely rounded and clipped to int range.  */
+
+static int
+scale_image_size (int size, size_t divisor, size_t multiplier)
+{
+  if (divisor != 0)
+    {
+      double s = size;
+      double scaled = s * multiplier / divisor + 0.5;
+      if (scaled < INT_MAX)
+       return scaled;
+    }
+  return INT_MAX;
+}
+
+/* Compute the desired size of an image with native size WIDTH x HEIGHT.
+   Use SPEC to deduce the size.  Store the desired size into
+   *D_WIDTH x *D_HEIGHT.  Store -1 x -1 if the native size is OK.  */
+static void
+compute_image_size (size_t width, size_t height,
+                   Lisp_Object spec,
+                   int *d_width, int *d_height)
+{
+  Lisp_Object value;
+  int desired_width = -1, desired_height = -1, max_width = -1, max_height = -1;
+  double scale = 1;
+
+  value = image_spec_value (spec, QCscale, NULL);
+  if (NUMBERP (value))
+    scale = XFLOATINT (value);
+
+  value = image_spec_value (spec, QCmax_width, NULL);
+  if (FIXNATP (value))
+    max_width = min (XFIXNAT (value), INT_MAX);
+
+  value = image_spec_value (spec, QCmax_height, NULL);
+  if (FIXNATP (value))
+    max_height = min (XFIXNAT (value), INT_MAX);
+
+  /* If width and/or height is set in the display spec assume we want
+     to scale to those values.  If either h or w is unspecified, the
+     unspecified should be calculated from the specified to preserve
+     aspect ratio.  */
+  value = image_spec_value (spec, QCwidth, NULL);
+  if (FIXNATP (value))
+    {
+      desired_width = min (XFIXNAT (value) * scale, INT_MAX);
+      /* :width overrides :max-width. */
+      max_width = -1;
+    }
+
+  value = image_spec_value (spec, QCheight, NULL);
+  if (FIXNATP (value))
+    {
+      desired_height = min (XFIXNAT (value) * scale, INT_MAX);
+      /* :height overrides :max-height. */
+      max_height = -1;
+    }
+
+  /* If we have both width/height set explicitly, we skip past all the
+     aspect ratio-preserving computations below. */
+  if (desired_width != -1 && desired_height != -1)
+    goto out;
+
+  width = width * scale;
+  height = height * scale;
+
+  if (desired_width != -1)
+    /* Width known, calculate height. */
+    desired_height = scale_image_size (desired_width, width, height);
+  else if (desired_height != -1)
+    /* Height known, calculate width. */
+    desired_width = scale_image_size (desired_height, height, width);
+  else
+    {
+      desired_width = width;
+      desired_height = height;
+    }
+
+  if (max_width != -1 && desired_width > max_width)
+    {
+      /* The image is wider than :max-width. */
+      desired_width = max_width;
+      desired_height = scale_image_size (desired_width, width, height);
+    }
+
+  if (max_height != -1 && desired_height > max_height)
+    {
+      /* The image is higher than :max-height. */
+      desired_height = max_height;
+      desired_width = scale_image_size (desired_height, height, width);
+    }
+
+ out:
+  *d_width = desired_width;
+  *d_height = desired_height;
+}
+#endif /* HAVE_IMAGEMAGICK || HAVE_NATIVE_SCALING */
+
+static void
+image_set_image_size (struct frame *f, struct image *img)
+{
+#ifdef HAVE_NATIVE_SCALING
+# ifdef HAVE_IMAGEMAGICK
+  /* ImageMagick images are already the correct size.  */
+  if (EQ (image_spec_value (img->spec, QCtype, NULL), Qimagemagick))
+    return;
+# endif
+
+  int width, height;
+  compute_image_size (img->width, img->height, img->spec, &width, &height);
+
+# ifdef HAVE_NS
+  ns_image_set_size (img->pixmap, width, height);
+  img->width = width;
+  img->height = height;
+# endif
+
+# ifdef USE_CAIRO
+  img->width = width;
+  img->height = height;
+# elif defined HAVE_XRENDER
+  if (img->picture)
+    {
+      double xscale = img->width / (double) width;
+      double yscale = img->height / (double) height;
+
+      XTransform tmat
+       = {{{XDoubleToFixed (xscale), XDoubleToFixed (0), XDoubleToFixed (0)},
+           {XDoubleToFixed (0), XDoubleToFixed (yscale), XDoubleToFixed (0)},
+           {XDoubleToFixed (0), XDoubleToFixed (0), XDoubleToFixed (1)}}};
+
+      XRenderSetPictureFilter (FRAME_X_DISPLAY (f), img->picture, FilterBest,
+                              0, 0);
+      XRenderSetPictureTransform (FRAME_X_DISPLAY (f), img->picture, &tmat);
+
+      img->width = width;
+      img->height = height;
+    }
+# endif
+# ifdef HAVE_NTGUI
+  /* Under HAVE_NTGUI, we will scale the image on the fly, when we
+     draw it.  See w32term.c:x_draw_image_foreground.  */
+  img->width = width;
+  img->height = height;
+# endif
+#endif
+}
+
 
 /* Return the id of image with Lisp specification SPEC on frame F.
    SPEC must be a valid Lisp image specification (see valid_image_p).  */
@@ -1802,6 +1949,7 @@ lookup_image (struct frame *f, Lisp_Object spec)
             `:background COLOR'.  */
          Lisp_Object ascent, margin, relief, bg;
          int relief_bound;
+          image_set_image_size (f, img);
 
          ascent = image_spec_value (spec, QCascent, NULL);
          if (FIXNUMP (ascent))
@@ -1833,8 +1981,8 @@ lookup_image (struct frame *f, Lisp_Object spec)
              if (!NILP (bg))
                {
                  img->background
-                   = x_alloc_image_color (f, img, bg,
-                                          FRAME_BACKGROUND_PIXEL (f));
+                   = image_alloc_image_color (f, img, bg,
+                                               FRAME_BACKGROUND_PIXEL (f));
                  img->background_valid = 1;
                }
            }
@@ -1931,7 +2079,7 @@ mark_image_cache (struct image_cache *c)
    WIDTH and HEIGHT must both be positive.
    If XIMG is null, assume it is a bitmap.  */
 static bool
-x_check_image_size (XImagePtr ximg, int width, int height)
+image_check_image_size (XImagePtr ximg, int width, int height)
 {
 #ifdef HAVE_X_WINDOWS
   /* Respect Xlib's limits: it cannot deal with images that have more
@@ -1975,8 +2123,8 @@ x_check_image_size (XImagePtr ximg, int width, int height)
    should indicate the bit depth of the image.  */
 
 static bool
-x_create_x_image_and_pixmap (struct frame *f, int width, int height, int depth,
-                            XImagePtr *ximg, Pixmap *pixmap)
+image_create_x_image_and_pixmap_1 (struct frame *f, int width, int height, int 
depth,
+                                   XImagePtr *ximg, Pixmap *pixmap, Picture 
*picture)
 {
 #ifdef HAVE_X_WINDOWS
   Display *display = FRAME_X_DISPLAY (f);
@@ -1996,9 +2144,9 @@ x_create_x_image_and_pixmap (struct frame *f, int width, 
int height, int depth,
       return 0;
     }
 
-  if (! x_check_image_size (*ximg, width, height))
+  if (! image_check_image_size (*ximg, width, height))
     {
-      x_destroy_x_image (*ximg);
+      image_destroy_x_image (*ximg);
       *ximg = NULL;
       image_error ("Image too large (%dx%d)",
                   make_fixnum (width), make_fixnum (height));
@@ -2012,12 +2160,42 @@ x_create_x_image_and_pixmap (struct frame *f, int 
width, int height, int depth,
   *pixmap = XCreatePixmap (display, drawable, width, height, depth);
   if (*pixmap == NO_PIXMAP)
     {
-      x_destroy_x_image (*ximg);
+      image_destroy_x_image (*ximg);
       *ximg = NULL;
       image_error ("Unable to create X pixmap");
       return 0;
     }
 
+# ifdef HAVE_XRENDER
+  int event_basep, error_basep;
+  if (picture && XRenderQueryExtension (display, &event_basep, &error_basep))
+    {
+      if (depth == 32 || depth == 24 || depth == 8)
+        {
+          XRenderPictFormat *format;
+          XRenderPictureAttributes attr;
+
+          /* FIXME: Do we need to handle all possible bit depths?
+             XRenderFindStandardFormat supports PictStandardARGB32,
+             PictStandardRGB24, PictStandardA8, PictStandardA4,
+             PictStandardA1, and PictStandardNUM (what is this?!).
+
+             XRenderFindFormat may support more, but I don't
+             understand the documentation.  */
+          format = XRenderFindStandardFormat (display,
+                                              depth == 32 ? PictStandardARGB32
+                                              : depth == 24 ? PictStandardRGB24
+                                              : PictStandardA8);
+          *picture = XRenderCreatePicture (display, *pixmap, format, 0, &attr);
+        }
+      else
+        {
+          image_error ("Specified image bit depth is not supported by 
XRender");
+          *picture = 0;
+        }
+    }
+# endif
+
   return 1;
 #endif /* HAVE_X_WINDOWS */
 
@@ -2104,7 +2282,7 @@ x_create_x_image_and_pixmap (struct frame *f, int width, 
int height, int depth,
       /* All system errors are < 10000, so the following is safe.  */
       XSETINT (errcode, err);
       image_error ("Unable to create bitmap, error code %d", errcode);
-      x_destroy_x_image (*ximg);
+      image_destroy_x_image (*ximg);
       *ximg = NULL;
       return 0;
     }
@@ -2130,7 +2308,7 @@ x_create_x_image_and_pixmap (struct frame *f, int width, 
int height, int depth,
 /* Destroy XImage XIMG.  Free XIMG->data.  */
 
 static void
-x_destroy_x_image (XImagePtr ximg)
+image_destroy_x_image (XImagePtr ximg)
 {
   eassert (input_blocked_p ());
   if (ximg)
@@ -2156,14 +2334,16 @@ x_destroy_x_image (XImagePtr ximg)
    are width and height of both the image and pixmap.  */
 
 static void
-x_put_x_image (struct frame *f, XImagePtr ximg, Pixmap pixmap, int width, int 
height)
+gui_put_x_image (struct frame *f, XImagePtr ximg, Pixmap pixmap,
+                 int width, int height)
 {
 #ifdef HAVE_X_WINDOWS
   GC gc;
 
   eassert (input_blocked_p ());
   gc = XCreateGC (FRAME_X_DISPLAY (f), pixmap, 0, NULL);
-  XPutImage (FRAME_X_DISPLAY (f), pixmap, gc, ximg, 0, 0, 0, 0, width, height);
+  XPutImage (FRAME_X_DISPLAY (f), pixmap, gc, ximg, 0, 0, 0, 0,
+             ximg->width, ximg->height);
   XFreeGC (FRAME_X_DISPLAY (f), gc);
 #endif /* HAVE_X_WINDOWS */
 
@@ -2181,7 +2361,7 @@ x_put_x_image (struct frame *f, XImagePtr ximg, Pixmap 
pixmap, int width, int he
 #endif
 }
 
-/* Thin wrapper for x_create_x_image_and_pixmap, so that it matches
+/* Thin wrapper for image_create_x_image_and_pixmap_1, so that it matches
    with image_put_x_image.  */
 
 static bool
@@ -2191,8 +2371,13 @@ image_create_x_image_and_pixmap (struct frame *f, struct 
image *img,
 {
   eassert ((!mask_p ? img->pixmap : img->mask) == NO_PIXMAP);
 
-  return x_create_x_image_and_pixmap (f, width, height, depth, ximg,
-                                     !mask_p ? &img->pixmap : &img->mask);
+  Picture *picture = NULL;
+#ifdef HAVE_XRENDER
+  picture = !mask_p ? &img->picture : &img->mask_picture;
+#endif
+  return image_create_x_image_and_pixmap_1 (f, width, height, depth, ximg,
+                                            !mask_p ? &img->pixmap : 
&img->mask,
+                                            picture);
 }
 
 /* Put X image XIMG into image IMG on frame F, as a mask if and only
@@ -2217,9 +2402,9 @@ image_put_x_image (struct frame *f, struct image *img, 
XImagePtr ximg,
       img->mask_img = ximg;
     }
 #else
-  x_put_x_image (f, ximg, !mask_p ? img->pixmap : img->mask,
-                img->width, img->height);
-  x_destroy_x_image (ximg);
+  gui_put_x_image (f, ximg, !mask_p ? img->pixmap : img->mask,
+                   img->width, img->height);
+  image_destroy_x_image (ximg);
 #endif
 }
 
@@ -2232,14 +2417,14 @@ image_sync_to_pixmaps (struct frame *f, struct image 
*img)
 {
   if (img->ximg)
     {
-      x_put_x_image (f, img->ximg, img->pixmap, img->width, img->height);
-      x_destroy_x_image (img->ximg);
+      gui_put_x_image (f, img->ximg, img->pixmap, img->width, img->height);
+      image_destroy_x_image (img->ximg);
       img->ximg = NULL;
     }
   if (img->mask_img)
     {
-      x_put_x_image (f, img->mask_img, img->mask, img->width, img->height);
-      x_destroy_x_image (img->mask_img);
+      gui_put_x_image (f, img->mask_img, img->mask, img->width, img->height);
+      image_destroy_x_image (img->mask_img);
       img->mask_img = NULL;
     }
 }
@@ -2321,7 +2506,7 @@ image_unget_x_image (struct image *img, bool mask_p, 
XImagePtr ximg)
    PFD is null, do not open the file.  */
 
 static Lisp_Object
-x_find_image_fd (Lisp_Object file, int *pfd)
+image_find_image_fd (Lisp_Object file, int *pfd)
 {
   Lisp_Object file_found, search_path;
   int fd;
@@ -2340,10 +2525,10 @@ x_find_image_fd (Lisp_Object file, int *pfd)
       file_found = ENCODE_FILE (file_found);
       if (fd == -2)
        {
-         /* The file exists locally, but has a file handler.  (This
-            happens, e.g., under Auto Image File Mode.)  'openp'
-            didn't open the file, so we should, because the caller
-            expects that.  */
+         /* The file exists locally, but has a file name handler.
+            (This happens, e.g., under Auto Image File Mode.)
+            'openp' didn't open the file, so we should, because the
+            caller expects that.  */
          fd = emacs_open (SSDATA (file_found), O_RDONLY, 0);
        }
     }
@@ -2359,9 +2544,9 @@ x_find_image_fd (Lisp_Object file, int *pfd)
    found, or nil if not found.  */
 
 Lisp_Object
-x_find_image_file (Lisp_Object file)
+image_find_image_file (Lisp_Object file)
 {
-  return x_find_image_fd (file, 0);
+  return image_find_image_fd (file, 0);
 }
 
 /* Read FILE into memory.  Value is a pointer to a buffer allocated
@@ -2462,7 +2647,7 @@ static struct image_type xbm_type =
   SYMBOL_INDEX (Qxbm),
   xbm_image_p,
   xbm_load,
-  x_clear_image,
+  image_clear_image,
   NULL,
   NULL
 };
@@ -2782,7 +2967,7 @@ Create_Pixmap_From_Bitmap_Data (struct frame *f, struct 
image *img, char *data,
 
 #else
   img->pixmap =
-   (x_check_image_size (0, img->width, img->height)
+   (image_check_image_size (0, img->width, img->height)
     ? XCreatePixmapFromBitmapData (FRAME_X_DISPLAY (f),
                                    FRAME_X_DRAWABLE (f),
                                   data,
@@ -2899,7 +3084,7 @@ xbm_read_bitmap_data (struct frame *f, char *contents, 
char *end,
   expect ('=');
   expect ('{');
 
-  if (! x_check_image_size (0, *width, *height))
+  if (! image_check_image_size (0, *width, *height))
     {
       if (!inhibit_image_error)
        image_error ("Image too large (%dx%d)",
@@ -2987,13 +3172,13 @@ xbm_load_image (struct frame *f, struct image *img, 
char *contents, char *end)
       value = image_spec_value (img->spec, QCforeground, NULL);
       if (!NILP (value))
        {
-         foreground = x_alloc_image_color (f, img, value, foreground);
+         foreground = image_alloc_image_color (f, img, value, foreground);
          non_default_colors = 1;
        }
       value = image_spec_value (img->spec, QCbackground, NULL);
       if (!NILP (value))
        {
-         background = x_alloc_image_color (f, img, value, background);
+         background = image_alloc_image_color (f, img, value, background);
          img->background = background;
          img->background_valid = 1;
          non_default_colors = 1;
@@ -3006,7 +3191,7 @@ xbm_load_image (struct frame *f, struct image *img, char 
*contents, char *end)
 
       if (img->pixmap == NO_PIXMAP)
        {
-         x_clear_image (f, img);
+         image_clear_image (f, img);
          image_error ("Unable to create X pixmap for `%s'", img->spec);
        }
       else
@@ -3048,7 +3233,7 @@ xbm_load (struct frame *f, struct image *img)
   if (STRINGP (file_name))
     {
       int fd;
-      Lisp_Object file = x_find_image_fd (file_name, &fd);
+      Lisp_Object file = image_find_image_fd (file_name, &fd);
       if (!STRINGP (file))
        {
          image_error ("Cannot find image file `%s'", file_name);
@@ -3103,16 +3288,20 @@ xbm_load (struct frame *f, struct image *img)
       if (fmt[XBM_FOREGROUND].count
          && STRINGP (fmt[XBM_FOREGROUND].value))
        {
-         foreground = x_alloc_image_color (f, img, fmt[XBM_FOREGROUND].value,
-                                           foreground);
+         foreground = image_alloc_image_color (f,
+                                                img,
+                                                fmt[XBM_FOREGROUND].value,
+                                                foreground);
          non_default_colors = 1;
        }
 
       if (fmt[XBM_BACKGROUND].count
          && STRINGP (fmt[XBM_BACKGROUND].value))
        {
-         background = x_alloc_image_color (f, img, fmt[XBM_BACKGROUND].value,
-                                           background);
+         background = image_alloc_image_color (f,
+                                                img,
+                                                fmt[XBM_BACKGROUND].value,
+                                                background);
          non_default_colors = 1;
        }
 
@@ -3159,7 +3348,7 @@ xbm_load (struct frame *f, struct image *img)
 #endif
          /* Create the pixmap.  */
 
-         if (x_check_image_size (0, img->width, img->height))
+         if (image_check_image_size (0, img->width, img->height))
            Create_Pixmap_From_Bitmap_Data (f, img, bits,
                                            foreground, background,
                                            non_default_colors);
@@ -3172,7 +3361,7 @@ xbm_load (struct frame *f, struct image *img)
            {
              image_error ("Unable to create pixmap for XBM image `%s'",
                           img->spec);
-             x_clear_image (f, img);
+             image_clear_image (f, img);
            }
 
          SAFE_FREE ();
@@ -3269,7 +3458,7 @@ static struct image_type xpm_type =
   SYMBOL_INDEX (Qxpm),
   xpm_image_p,
   xpm_load,
-  x_clear_image,
+  image_clear_image,
   init_xpm_functions,
   NULL
 };
@@ -3570,7 +3759,7 @@ x_create_bitmap_from_xpm_data (struct frame *f, const 
char **bits)
       return -1;
     }
 
-  id = x_allocate_bitmap_record (f);
+  id = image_allocate_bitmap_record (f);
   dpyinfo->bitmaps[id - 1].pixmap = bitmap;
   dpyinfo->bitmaps[id - 1].have_mask = true;
   dpyinfo->bitmaps[id - 1].mask = mask;
@@ -3704,7 +3893,7 @@ xpm_load (struct frame *f, struct image *img)
 
   if (STRINGP (specified_file))
     {
-      Lisp_Object file = x_find_image_file (specified_file);
+      Lisp_Object file = image_find_image_file (specified_file);
       if (!STRINGP (file))
        {
          image_error ("Cannot find image file `%s'", specified_file);
@@ -3768,9 +3957,9 @@ xpm_load (struct frame *f, struct image *img)
     {
       int width = img->ximg->width;
       int height = img->ximg->height;
-      void *data = xmalloc (width * height * 4);
+      cairo_surface_t *surface = create_cairo_image_surface (width, height);
       int i;
-      uint32_t *od = data;
+      uint32_t *od = (uint32_t *) cairo_image_surface_get_data (surface);
       uint32_t *id = (uint32_t *) img->ximg->data;
       char *mid = img->mask_img ? img->mask_img->data : 0;
       uint32_t bgcolor = get_spec_bg_or_alpha_as_argb (img, f);
@@ -3789,12 +3978,12 @@ xpm_load (struct frame *f, struct image *img)
             }
         }
 
-      create_cairo_image_surface (img, data, width, height);
+      set_cairo_image_surface (img, surface);
     }
   else
     {
       rc = XpmFileInvalid;
-      x_clear_image (f, img);
+      image_clear_image (f, img);
     }
 #else
 #ifdef HAVE_X_WINDOWS
@@ -3805,7 +3994,7 @@ xpm_load (struct frame *f, struct image *img)
                                   img->ximg->depth);
       if (img->pixmap == NO_PIXMAP)
        {
-         x_clear_image (f, img);
+         image_clear_image (f, img);
          rc = XpmNoMemory;
        }
       else if (img->mask_img)
@@ -3816,7 +4005,7 @@ xpm_load (struct frame *f, struct image *img)
                                     img->mask_img->depth);
          if (img->mask == NO_PIXMAP)
            {
-             x_clear_image (f, img);
+             image_clear_image (f, img);
              rc = XpmNoMemory;
            }
        }
@@ -4265,8 +4454,8 @@ xpm_load_image (struct frame *f,
            {
              if (xstrcasecmp (SSDATA (XCDR (specified_color)), "None") == 0)
                color_val = Qt;
-             else if (x_defined_color (f, SSDATA (XCDR (specified_color)),
-                                       &cdef, 0))
+             else if (FRAME_TERMINAL (f)->defined_color_hook
+                       (f, SSDATA (XCDR (specified_color)), &cdef, false, 
false))
                color_val = make_fixnum (cdef.pixel);
            }
        }
@@ -4274,7 +4463,8 @@ xpm_load_image (struct frame *f,
        {
          if (xstrcasecmp (max_color, "None") == 0)
            color_val = Qt;
-         else if (x_defined_color (f, max_color, &cdef, 0))
+         else if (FRAME_TERMINAL (f)->defined_color_hook
+                   (f, max_color, &cdef, false, false))
            color_val = make_fixnum (cdef.pixel);
        }
       if (!NILP (color_val))
@@ -4329,17 +4519,17 @@ xpm_load_image (struct frame *f,
     }
   else
     {
-      x_destroy_x_image (mask_img);
-      x_clear_image_1 (f, img, CLEAR_IMAGE_MASK);
+      image_destroy_x_image (mask_img);
+      image_clear_image_1 (f, img, CLEAR_IMAGE_MASK);
     }
 #endif
   return 1;
 
  failure:
   image_error ("Invalid XPM3 file (%s)", img->spec);
-  x_destroy_x_image (ximg);
-  x_destroy_x_image (mask_img);
-  x_clear_image (f, img);
+  image_destroy_x_image (ximg);
+  image_destroy_x_image (mask_img);
+  image_clear_image (f, img);
   return 0;
 
 #undef match
@@ -4359,7 +4549,7 @@ xpm_load (struct frame *f,
   if (STRINGP (file_name))
     {
       int fd;
-      Lisp_Object file = x_find_image_fd (file_name, &fd);
+      Lisp_Object file = image_find_image_fd (file_name, &fd);
       if (!STRINGP (file))
        {
          image_error ("Cannot find image file `%s'", file_name);
@@ -4590,7 +4780,7 @@ lookup_pixel_color (struct frame *f, unsigned long pixel)
 #ifdef HAVE_X_WINDOWS
       cmap = FRAME_X_COLORMAP (f);
       color.pixel = pixel;
-      x_query_color (f, &color);
+      x_query_colors (f, &color, 1);
       rc = x_alloc_nearest_color (f, cmap, &color);
 #else
       block_input ();
@@ -4706,7 +4896,7 @@ static int laplace_matrix[9] = {
    allocated with xmalloc; it must be freed by the caller.  */
 
 static XColor *
-x_to_xcolors (struct frame *f, struct image *img, bool rgb_p)
+image_to_xcolors (struct frame *f, struct image *img, bool rgb_p)
 {
   int x, y;
   XColor *colors, *p;
@@ -4735,8 +4925,9 @@ x_to_xcolors (struct frame *f, struct image *img, bool 
rgb_p)
       for (x = 0; x < img->width; ++x, ++p)
        p->pixel = GET_PIXEL (ximg, x, y);
       if (rgb_p)
-       x_query_colors (f, row, img->width);
-
+        {
+          FRAME_TERMINAL (f)->query_colors (f, row, img->width);
+        }
 #else
 
       for (x = 0; x < img->width; ++x, ++p)
@@ -4809,7 +5000,7 @@ XPutPixel (XImagePtr ximg, int x, int y, COLORREF color)
    COLORS will be freed; an existing IMG->pixmap will be freed, too.  */
 
 static void
-x_from_xcolors (struct frame *f, struct image *img, XColor *colors)
+image_from_xcolors (struct frame *f, struct image *img, XColor *colors)
 {
   int x, y;
   XImagePtr oimg = NULL;
@@ -4817,7 +5008,7 @@ x_from_xcolors (struct frame *f, struct image *img, 
XColor *colors)
 
   init_color_table ();
 
-  x_clear_image_1 (f, img, CLEAR_IMAGE_PIXMAP | CLEAR_IMAGE_COLORS);
+  image_clear_image_1 (f, img, CLEAR_IMAGE_PIXMAP | CLEAR_IMAGE_COLORS);
   image_create_x_image_and_pixmap (f, img, img->width, img->height, 0,
                                   &oimg, 0);
   p = colors;
@@ -4848,9 +5039,10 @@ x_from_xcolors (struct frame *f, struct image *img, 
XColor *colors)
    outgoing image.  */
 
 static void
-x_detect_edges (struct frame *f, struct image *img, int *matrix, int 
color_adjust)
+image_detect_edges (struct frame *f, struct image *img,
+                    int *matrix, int color_adjust)
 {
-  XColor *colors = x_to_xcolors (f, img, 1);
+  XColor *colors = image_to_xcolors (f, img, 1);
   XColor *new, *p;
   int x, y, i, sum;
   ptrdiff_t nbytes;
@@ -4908,7 +5100,7 @@ x_detect_edges (struct frame *f, struct image *img, int 
*matrix, int color_adjus
     }
 
   xfree (colors);
-  x_from_xcolors (f, img, new);
+  image_from_xcolors (f, img, new);
 
 #undef COLOR
 }
@@ -4918,9 +5110,9 @@ x_detect_edges (struct frame *f, struct image *img, int 
*matrix, int color_adjus
    on frame F.  */
 
 static void
-x_emboss (struct frame *f, struct image *img)
+image_emboss (struct frame *f, struct image *img)
 {
-  x_detect_edges (f, img, emboss_matrix, 0xffff / 2);
+  image_detect_edges (f, img, emboss_matrix, 0xffff / 2);
 }
 
 
@@ -4929,9 +5121,9 @@ x_emboss (struct frame *f, struct image *img)
    to draw disabled buttons, for example.  */
 
 static void
-x_laplace (struct frame *f, struct image *img)
+image_laplace (struct frame *f, struct image *img)
 {
-  x_detect_edges (f, img, laplace_matrix, 45000);
+  image_detect_edges (f, img, laplace_matrix, 45000);
 }
 
 
@@ -4947,8 +5139,8 @@ x_laplace (struct frame *f, struct image *img)
    number.  */
 
 static void
-x_edge_detection (struct frame *f, struct image *img, Lisp_Object matrix,
-                 Lisp_Object color_adjust)
+image_edge_detection (struct frame *f, struct image *img,
+                      Lisp_Object matrix, Lisp_Object color_adjust)
 {
   int i = 0;
   int trans[9];
@@ -4970,14 +5162,14 @@ x_edge_detection (struct frame *f, struct image *img, 
Lisp_Object matrix,
     color_adjust = make_fixnum (0xffff / 2);
 
   if (i == 9 && NUMBERP (color_adjust))
-    x_detect_edges (f, img, trans, XFLOATINT (color_adjust));
+    image_detect_edges (f, img, trans, XFLOATINT (color_adjust));
 }
 
 
 /* Transform image IMG on frame F so that it looks disabled.  */
 
 static void
-x_disable_image (struct frame *f, struct image *img)
+image_disable_image (struct frame *f, struct image *img)
 {
   Display_Info *dpyinfo = FRAME_DISPLAY_INFO (f);
 #ifdef HAVE_NTGUI
@@ -4991,7 +5183,7 @@ x_disable_image (struct frame *f, struct image *img)
       /* Color (or grayscale).  Convert to gray, and equalize.  Just
         drawing such images with a stipple can look very odd, so
         we're using this method instead.  */
-      XColor *colors = x_to_xcolors (f, img, 1);
+      XColor *colors = image_to_xcolors (f, img, 1);
       XColor *p, *end;
       const int h = 15000;
       const int l = 30000;
@@ -5005,7 +5197,7 @@ x_disable_image (struct frame *f, struct image *img)
          p->red = p->green = p->blue = i2;
        }
 
-      x_from_xcolors (f, img, colors);
+      image_from_xcolors (f, img, colors);
     }
 
   /* Draw a cross over the disabled image, if we must or if we
@@ -5080,7 +5272,8 @@ x_disable_image (struct frame *f, struct image *img)
    heuristically.  */
 
 static void
-x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how)
+image_build_heuristic_mask (struct frame *f, struct image *img,
+                            Lisp_Object how)
 {
   XImagePtr_or_DC ximg;
 #ifdef HAVE_NTGUI
@@ -5095,7 +5288,7 @@ x_build_heuristic_mask (struct frame *f, struct image 
*img, Lisp_Object how)
   unsigned long bg = 0;
 
   if (img->mask)
-    x_clear_image_1 (f, img, CLEAR_IMAGE_MASK);
+    image_clear_image_1 (f, img, CLEAR_IMAGE_MASK);
 
 #ifndef HAVE_NTGUI
 #ifndef HAVE_NS
@@ -5136,7 +5329,7 @@ x_build_heuristic_mask (struct frame *f, struct image 
*img, Lisp_Object how)
 #ifdef HAVE_NTGUI
                0x00ffffff & /* Filter out palette info.  */
 #endif /* HAVE_NTGUI */
-               x_alloc_image_color (f, img, build_string (color_name), 0));
+               image_alloc_image_color (f, img, build_string (color_name), 0));
          use_img_background = 0;
        }
     }
@@ -5179,7 +5372,7 @@ x_build_heuristic_mask (struct frame *f, struct image 
*img, Lisp_Object how)
   SelectObject (ximg, img->mask);
   image_background_transparent (img, f, ximg);
 
-  /* Was: x_destroy_x_image ((XImagePtr )mask_img); which seems bogus ++kfs */
+  /* Was: image_destroy_x_image ((XImagePtr )mask_img); which seems bogus 
++kfs */
   xfree (mask_img);
 #endif /* HAVE_NTGUI */
 
@@ -5237,7 +5430,7 @@ static struct image_type pbm_type =
   SYMBOL_INDEX (Qpbm),
   pbm_image_p,
   pbm_load,
-  x_clear_image,
+  image_clear_image,
   NULL,
   NULL
 };
@@ -5348,7 +5541,7 @@ pbm_load (struct frame *f, struct image *img)
   if (STRINGP (specified_file))
     {
       int fd;
-      Lisp_Object file = x_find_image_fd (specified_file, &fd);
+      Lisp_Object file = image_find_image_fd (specified_file, &fd);
       if (!STRINGP (file))
        {
          image_error ("Cannot find image file `%s'", specified_file);
@@ -5426,8 +5619,8 @@ pbm_load (struct frame *f, struct image *img)
   height = pbm_scan_number (&p, end);
 
 #ifdef USE_CAIRO
-  void *data = xmalloc (width * height * 4);
-  uint32_t *dataptr = data;
+  cairo_surface_t *surface = create_cairo_image_surface (width, height);
+  uint32_t *dataptr = (uint32_t *) cairo_image_surface_get_data (surface);
 #endif
 
   if (type != PBM_MONO)
@@ -5473,29 +5666,37 @@ pbm_load (struct frame *f, struct image *img)
 #ifdef USE_CAIRO
       if (! fmt[PBM_FOREGROUND].count
           || ! STRINGP (fmt[PBM_FOREGROUND].value)
-          || ! x_defined_color (f, SSDATA (fmt[PBM_FOREGROUND].value), &xfg, 
0))
+          || ! FRAME_TERMINAL (f)->defined_color_hook (f,
+                                                       SSDATA 
(fmt[PBM_FOREGROUND].value),
+                                                       &xfg,
+                                                       false,
+                                                       false))
         {
           xfg.pixel = fg;
-          x_query_color (f, &xfg);
+          x_query_colors (f, &xfg, 1);
         }
       fga32 = xcolor_to_argb32 (xfg);
 
       if (! fmt[PBM_BACKGROUND].count
           || ! STRINGP (fmt[PBM_BACKGROUND].value)
-          || ! x_defined_color (f, SSDATA (fmt[PBM_BACKGROUND].value), &xbg, 
0))
+          || ! FRAME_TERMINAL (f)->defined_color_hook (f,
+                                                       SSDATA 
(fmt[PBM_BACKGROUND].value),
+                                                       &xbg,
+                                                       false,
+                                                       false))
        {
           xbg.pixel = bg;
-          x_query_color (f, &xbg);
+          x_query_colors (f, &xbg, 1);
        }
       bga32 = xcolor_to_argb32 (xbg);
 #else
       if (fmt[PBM_FOREGROUND].count
          && STRINGP (fmt[PBM_FOREGROUND].value))
-       fg = x_alloc_image_color (f, img, fmt[PBM_FOREGROUND].value, fg);
+       fg = image_alloc_image_color (f, img, fmt[PBM_FOREGROUND].value, fg);
       if (fmt[PBM_BACKGROUND].count
          && STRINGP (fmt[PBM_BACKGROUND].value))
        {
-         bg = x_alloc_image_color (f, img, fmt[PBM_BACKGROUND].value, bg);
+         bg = image_alloc_image_color (f, img, fmt[PBM_BACKGROUND].value, bg);
          img->background = bg;
          img->background_valid = 1;
        }
@@ -5511,11 +5712,11 @@ pbm_load (struct frame *f, struct image *img)
                    if (p >= end)
                      {
 #ifdef USE_CAIRO
-                        xfree (data);
+                        cairo_surface_destroy (surface);
 #else
-                       x_destroy_x_image (ximg);
+                       image_destroy_x_image (ximg);
 #endif
-                       x_clear_image (f, img);
+                       image_clear_image (f, img);
                        image_error ("Invalid image size in image `%s'",
                                     img->spec);
                        goto error;
@@ -5557,11 +5758,11 @@ pbm_load (struct frame *f, struct image *img)
       if (raw_p && p + expected_size > end)
        {
 #ifdef USE_CAIRO
-          xfree (data);
+          cairo_surface_destroy (surface);
 #else
-         x_destroy_x_image (ximg);
+         image_destroy_x_image (ximg);
 #endif
-         x_clear_image (f, img);
+         image_clear_image (f, img);
          image_error ("Invalid image size in image `%s'", img->spec);
          goto error;
        }
@@ -5591,9 +5792,9 @@ pbm_load (struct frame *f, struct image *img)
            if (r < 0 || g < 0 || b < 0)
              {
 #ifdef USE_CAIRO
-                xfree (data);
+                cairo_surface_destroy (surface);
 #else
-               x_destroy_x_image (ximg);
+               image_destroy_x_image (ximg);
 #endif
                image_error ("Invalid pixel value in image `%s'", img->spec);
                goto error;
@@ -5628,7 +5829,7 @@ pbm_load (struct frame *f, struct image *img)
   /* Maybe fill in the background field while we have ximg handy.  */
 
 #ifdef USE_CAIRO
-  create_cairo_image_surface (img, data, width, height);
+  set_cairo_image_surface (img, surface);
 #else
   if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
     /* Casting avoids a GCC warning.  */
@@ -5705,7 +5906,7 @@ static struct image_type png_type =
   SYMBOL_INDEX (Qpng),
   png_image_p,
   png_load,
-  x_clear_image,
+  image_clear_image,
   init_png_functions,
   NULL
 };
@@ -5880,7 +6081,7 @@ init_png_functions (void)
 /* Error and warning handlers installed when the PNG library
    is initialized.  */
 
-static _Noreturn void
+static AVOID
 my_png_error (png_struct *png_ptr, const char *msg)
 {
   eassert (png_ptr != NULL);
@@ -5974,7 +6175,7 @@ png_load_body (struct frame *f, struct image *img, struct 
png_load_context *c)
   ptrdiff_t nbytes;
 
 #ifdef USE_CAIRO
-  unsigned char *data = 0;
+  cairo_surface_t *surface;
   uint32_t *dataptr;
 #else
   XImagePtr ximg, mask_img = NULL;
@@ -5987,7 +6188,7 @@ png_load_body (struct frame *f, struct image *img, struct 
png_load_context *c)
   if (NILP (specified_data))
     {
       int fd;
-      Lisp_Object file = x_find_image_fd (specified_file, &fd);
+      Lisp_Object file = image_find_image_fd (specified_file, &fd);
       if (!STRINGP (file))
        {
          image_error ("Cannot find image file `%s'", specified_file);
@@ -6141,8 +6342,13 @@ png_load_body (struct frame *f, struct image *img, 
struct png_load_context *c)
         current frame background, ignoring any default background
         color set by the image.  */
       if (STRINGP (specified_bg)
-         ? x_defined_color (f, SSDATA (specified_bg), &color, false)
-         : (x_query_frame_background_color (f, &color), true))
+         ? FRAME_TERMINAL (f)->defined_color_hook (f,
+                                                    SSDATA (specified_bg),
+                                                    &color,
+                                                    false,
+                                                    false)
+         : (FRAME_TERMINAL (f)->query_frame_background_color (f, &color),
+             true))
        /* The user specified `:background', use that.  */
        {
          int shift = bit_depth == 16 ? 0 : 8;
@@ -6189,8 +6395,8 @@ png_load_body (struct frame *f, struct image *img, struct 
png_load_context *c)
     }
 
 #ifdef USE_CAIRO
-  data = (unsigned char *) xmalloc (width * height * 4);
-  dataptr = (uint32_t *) data;
+  surface = create_cairo_image_surface (width, height);
+  dataptr = (uint32_t *) cairo_image_surface_get_data (surface);
 #else
   /* Create an image and pixmap serving as mask if the PNG image
      contains an alpha channel.  */
@@ -6199,8 +6405,8 @@ png_load_body (struct frame *f, struct image *img, struct 
png_load_context *c)
       && !image_create_x_image_and_pixmap (f, img, width, height, 1,
                                           &mask_img, 1))
     {
-      x_destroy_x_image (ximg);
-      x_clear_image_1 (f, img, CLEAR_IMAGE_PIXMAP);
+      image_destroy_x_image (ximg);
+      image_clear_image_1 (f, img, CLEAR_IMAGE_PIXMAP);
       goto error;
     }
 #endif
@@ -6281,7 +6487,7 @@ png_load_body (struct frame *f, struct image *img, struct 
png_load_context *c)
   img->height = height;
 
 #ifdef USE_CAIRO
-  create_cairo_image_surface (img, data, width, height);
+  set_cairo_image_surface (img, surface);
 #else
   /* Maybe fill in the background field while we have ximg handy.
      Casting avoids a GCC warning.  */
@@ -6382,7 +6588,7 @@ static struct image_type jpeg_type =
   SYMBOL_INDEX (Qjpeg),
   jpeg_image_p,
   jpeg_load,
-  x_clear_image,
+  image_clear_image,
   init_jpeg_functions,
   NULL
 };
@@ -6519,7 +6725,7 @@ struct my_jpeg_error_mgr
 };
 
 
-static _Noreturn void
+static AVOID
 my_error_exit (j_common_ptr cinfo)
 {
   struct my_jpeg_error_mgr *mgr = (struct my_jpeg_error_mgr *) cinfo->err;
@@ -6746,7 +6952,7 @@ jpeg_load_body (struct frame *f, struct image *img,
   if (NILP (specified_data))
     {
       int fd;
-      Lisp_Object file = x_find_image_fd (specified_file, &fd);
+      Lisp_Object file = image_find_image_fd (specified_file, &fd);
       if (!STRINGP (file))
        {
          image_error ("Cannot find image file `%s'", specified_file);
@@ -6798,10 +7004,10 @@ jpeg_load_body (struct frame *f, struct image *img,
 
       /* If we already have an XImage, free that.  */
 #ifndef USE_CAIRO
-      x_destroy_x_image (ximg);
+      image_destroy_x_image (ximg);
 #endif
       /* Free pixmap and colors.  */
-      x_clear_image (f, img);
+      image_clear_image (f, img);
       return 0;
     }
 
@@ -6844,7 +7050,9 @@ jpeg_load_body (struct frame *f, struct image *img,
      colors generated, and mgr->cinfo.colormap is a two-dimensional array
      of color indices in the range 0..mgr->cinfo.actual_number_of_colors.
      No more than 255 colors will be generated.  */
+#ifndef USE_CAIRO
   USE_SAFE_ALLOCA;
+#endif
   {
     if (mgr->cinfo.out_color_components > 2)
       ir = 0, ig = 1, ib = 2;
@@ -6885,8 +7093,8 @@ jpeg_load_body (struct frame *f, struct image *img,
                                         JPOOL_IMAGE, row_stride, 1);
 #ifdef USE_CAIRO
   {
-    unsigned char *data = (unsigned char *) xmalloc (width*height*4);
-    uint32_t *dataptr = (uint32_t *) data;
+    cairo_surface_t *surface = create_cairo_image_surface (width, height);
+    uint32_t *dataptr = (uint32_t *) cairo_image_surface_get_data (surface);
     int r, g, b;
 
     for (y = 0; y < height; ++y)
@@ -6903,7 +7111,7 @@ jpeg_load_body (struct frame *f, struct image *img,
           }
       }
 
-    create_cairo_image_surface (img, data, width, height);
+    set_cairo_image_surface (img, surface);
   }
 #else
   for (y = 0; y < height; ++y)
@@ -6928,8 +7136,8 @@ jpeg_load_body (struct frame *f, struct image *img,
 
   /* Put ximg into the image.  */
   image_put_x_image (f, img, ximg, 0);
-#endif
   SAFE_FREE ();
+#endif
   return 1;
 }
 
@@ -7014,7 +7222,7 @@ static struct image_type tiff_type =
   SYMBOL_INDEX (Qtiff),
   tiff_image_p,
   tiff_load,
-  x_clear_image,
+  image_clear_image,
   init_tiff_functions,
   NULL
 };
@@ -7258,7 +7466,7 @@ tiff_load (struct frame *f, struct image *img)
   if (NILP (specified_data))
     {
       /* Read from a file */
-      Lisp_Object file = x_find_image_file (specified_file);
+      Lisp_Object file = image_find_image_file (specified_file);
       if (!STRINGP (file))
        {
          image_error ("Cannot find image file `%s'", specified_file);
@@ -7365,8 +7573,8 @@ tiff_load (struct frame *f, struct image *img)
 
 #ifdef USE_CAIRO
   {
-    unsigned char *data = (unsigned char *) xmalloc (width*height*4);
-    uint32_t *dataptr = (uint32_t *) data;
+    cairo_surface_t *surface = create_cairo_image_surface (width, height);
+    uint32_t *dataptr = (uint32_t *) cairo_image_surface_get_data (surface);
 
     for (y = 0; y < height; ++y)
       {
@@ -7382,7 +7590,7 @@ tiff_load (struct frame *f, struct image *img)
           }
       }
 
-    create_cairo_image_surface (img, data, width, height);
+    set_cairo_image_surface (img, surface);
   }
 #else
   /* Initialize the color table.  */
@@ -7510,7 +7718,7 @@ static void
 gif_clear_image (struct frame *f, struct image *img)
 {
   img->lisp_data = Qnil;
-  x_clear_image (f, img);
+  image_clear_image (f, img);
 }
 
 /* Return true if OBJECT is a valid GIF image specification.  */
@@ -7694,7 +7902,7 @@ gif_load (struct frame *f, struct image *img)
 
   if (NILP (specified_data))
     {
-      Lisp_Object file = x_find_image_file (specified_file);
+      Lisp_Object file = image_find_image_file (specified_file);
       if (!STRINGP (file))
        {
          image_error ("Cannot find image file `%s'", specified_file);
@@ -7821,13 +8029,13 @@ gif_load (struct frame *f, struct image *img)
     }
 
 #ifdef USE_CAIRO
-  /* xzalloc so data is zero => transparent */
-  void *data = xzalloc (width * height * 4);
-  uint32_t *data32 = data;
+  cairo_surface_t *surface = create_cairo_image_surface (width, height);
+  uint32_t *data32 = (uint32_t *) cairo_image_surface_get_data (surface);
   if (STRINGP (specified_bg))
     {
       XColor color;
-      if (x_defined_color (f, SSDATA (specified_bg), &color, 0))
+      if (FRAME_TERMINAL (f)->defined_color_hook
+          (f, SSDATA (specified_bg), &color, false, false))
         {
           uint32_t *dataptr = data32;
           int r = color.red/256;
@@ -7881,8 +8089,8 @@ gif_load (struct frame *f, struct image *img)
 #ifndef USE_CAIRO
   unsigned long bgcolor UNINIT;
   if (STRINGP (specified_bg))
-    bgcolor = x_alloc_image_color (f, img, specified_bg,
-                                  FRAME_BACKGROUND_PIXEL (f));
+    bgcolor = image_alloc_image_color (f, img, specified_bg,
+                                       FRAME_BACKGROUND_PIXEL (f));
 #endif
 
   for (j = 0; j <= idx; ++j)
@@ -7970,7 +8178,7 @@ gif_load (struct frame *f, struct image *img)
                     {
 #ifdef USE_CAIRO
                       uint32_t *dataptr =
-                        (data32 + ((row + subimg_top) * subimg_width
+                        (data32 + ((row + subimg_top) * width
                                   + x + subimg_left));
                       int r = gif_color_map->Colors[c].Red;
                       int g = gif_color_map->Colors[c].Green;
@@ -7982,7 +8190,7 @@ gif_load (struct frame *f, struct image *img)
                       XPutPixel (ximg, x + subimg_left, row + subimg_top,
                                  pixel_colors[c]);
 #endif
-                    }
+                   }
                }
            }
        }
@@ -7996,7 +8204,7 @@ gif_load (struct frame *f, struct image *img)
                   {
 #ifdef USE_CAIRO
                     uint32_t *dataptr =
-                      (data32 + ((y + subimg_top) * subimg_width
+                      (data32 + ((y + subimg_top) * width
                                 + x + subimg_left));
                     int r = gif_color_map->Colors[c].Red;
                     int g = gif_color_map->Colors[c].Green;
@@ -8066,7 +8274,7 @@ gif_load (struct frame *f, struct image *img)
     }
 
 #ifdef USE_CAIRO
-  create_cairo_image_surface (img, data, width, height);
+  set_cairo_image_surface (img, surface);
 #else
   /* Maybe fill in the background field while we have ximg handy. */
   if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
@@ -8101,105 +8309,6 @@ gif_load (struct frame *f, struct image *img)
                                 ImageMagick
 ***********************************************************************/
 
-/* Scale an image size by returning SIZE / DIVISOR * MULTIPLIER,
-   safely rounded and clipped to int range.  */
-
-static int
-scale_image_size (int size, size_t divisor, size_t multiplier)
-{
-  if (divisor != 0)
-    {
-      double s = size;
-      double scaled = s * multiplier / divisor + 0.5;
-      if (scaled < INT_MAX)
-       return scaled;
-    }
-  return INT_MAX;
-}
-
-/* Compute the desired size of an image with native size WIDTH x HEIGHT.
-   Use SPEC to deduce the size.  Store the desired size into
-   *D_WIDTH x *D_HEIGHT.  Store -1 x -1 if the native size is OK.  */
-static void
-compute_image_size (size_t width, size_t height,
-                   Lisp_Object spec,
-                   int *d_width, int *d_height)
-{
-  Lisp_Object value;
-  int desired_width = -1, desired_height = -1, max_width = -1, max_height = -1;
-  double scale = 1;
-
-  value = image_spec_value (spec, QCscale, NULL);
-  if (NUMBERP (value))
-    scale = XFLOATINT (value);
-
-  value = image_spec_value (spec, QCmax_width, NULL);
-  if (FIXNATP (value))
-    max_width = min (XFIXNAT (value), INT_MAX);
-
-  value = image_spec_value (spec, QCmax_height, NULL);
-  if (FIXNATP (value))
-    max_height = min (XFIXNAT (value), INT_MAX);
-
-  /* If width and/or height is set in the display spec assume we want
-     to scale to those values.  If either h or w is unspecified, the
-     unspecified should be calculated from the specified to preserve
-     aspect ratio.  */
-  value = image_spec_value (spec, QCwidth, NULL);
-  if (FIXNATP (value))
-    {
-      desired_width = min (XFIXNAT (value) * scale, INT_MAX);
-      /* :width overrides :max-width. */
-      max_width = -1;
-    }
-
-  value = image_spec_value (spec, QCheight, NULL);
-  if (FIXNATP (value))
-    {
-      desired_height = min (XFIXNAT (value) * scale, INT_MAX);
-      /* :height overrides :max-height. */
-      max_height = -1;
-    }
-
-  /* If we have both width/height set explicitly, we skip past all the
-     aspect ratio-preserving computations below. */
-  if (desired_width != -1 && desired_height != -1)
-    goto out;
-
-  width = width * scale;
-  height = height * scale;
-
-  if (desired_width != -1)
-    /* Width known, calculate height. */
-    desired_height = scale_image_size (desired_width, width, height);
-  else if (desired_height != -1)
-    /* Height known, calculate width. */
-    desired_width = scale_image_size (desired_height, height, width);
-  else
-    {
-      desired_width = width;
-      desired_height = height;
-    }
-
-  if (max_width != -1 && desired_width > max_width)
-    {
-      /* The image is wider than :max-width. */
-      desired_width = max_width;
-      desired_height = scale_image_size (desired_width, width, height);
-    }
-
-  if (max_height != -1 && desired_height > max_height)
-    {
-      /* The image is higher than :max-height. */
-      desired_height = max_height;
-      desired_width = scale_image_size (desired_height, height, width);
-    }
-
- out:
-  *d_width = desired_width;
-  *d_height = desired_height;
-}
-
 static bool imagemagick_image_p (Lisp_Object);
 static bool imagemagick_load (struct frame *, struct image *);
 static void imagemagick_clear_image (struct frame *, struct image *);
@@ -8277,7 +8386,7 @@ static void
 imagemagick_clear_image (struct frame *f,
                          struct image *img)
 {
-  x_clear_image (f, img);
+  image_clear_image (f, img);
 }
 
 /* Return true if OBJECT is a valid IMAGEMAGICK image specification.  Do
@@ -8593,7 +8702,7 @@ imagemagick_load_image (struct frame *f, struct image 
*img,
   char hint_buffer[MaxTextExtent];
   char *filename_hint = NULL;
 #ifdef USE_CAIRO
-  void *data = NULL;
+  cairo_surface_t *surface;
 #endif
 
   /* Initialize the ImageMagick environment.  */
@@ -8687,8 +8796,12 @@ imagemagick_load_image (struct frame *f, struct image 
*img,
 
     specified_bg = image_spec_value (img->spec, QCbackground, NULL);
     if (!STRINGP (specified_bg)
-       || !x_defined_color (f, SSDATA (specified_bg), &bgcolor, 0))
-      x_query_frame_background_color (f, &bgcolor);
+       || !FRAME_TERMINAL (f)->defined_color_hook (f,
+                                                    SSDATA (specified_bg),
+                                                    &bgcolor,
+                                                    false,
+                                                    false))
+      FRAME_TERMINAL (f)->query_frame_background_color (f, &bgcolor);
 
     bg_wand = NewPixelWand ();
     PixelSetRed   (bg_wand, (double) bgcolor.red   / 65535);
@@ -8805,9 +8918,9 @@ imagemagick_load_image (struct frame *f, struct image 
*img,
          ad-hoc and needs to be more researched. */
       void *dataptr;
 #ifdef USE_CAIRO
-      data = xmalloc (width * height * 4);
+      surface = create_cairo_image_surface (width, height);
       const char *exportdepth = "BGRA";
-      dataptr = data;
+      dataptr = cairo_image_surface_get_data (surface);
 #else
       int imagedepth = 24; /*MagickGetImageDepth(image_wand);*/
       const char *exportdepth = imagedepth <= 8 ? "I" : "BGRP"; /*"RGBP";*/
@@ -8854,7 +8967,8 @@ imagemagick_load_image (struct frame *f, struct image 
*img,
       double quantum_range = QuantumRange;
       MagickRealType color_scale = 65535.0 / quantum_range;
 #ifdef USE_CAIRO
-      data = xmalloc (width * height * 4);
+      surface = create_cairo_image_surface (width, height);
+      uint32_t *dataptr = (uint32_t *) cairo_image_surface_get_data (surface);
       color_scale /= 256;
 #else
       /* Try to create a x pixmap to hold the imagemagick pixmap.  */
@@ -8881,7 +8995,7 @@ imagemagick_load_image (struct frame *f, struct image 
*img,
          free_color_table ();
 #endif
 #ifndef USE_CAIRO
-         x_destroy_x_image (ximg);
+         image_destroy_x_image (ximg);
 #endif
           image_error ("Imagemagick pixel iterator creation failed");
           goto imagemagick_error;
@@ -8899,7 +9013,7 @@ imagemagick_load_image (struct frame *f, struct image 
*img,
             {
               PixelGetMagickColor (pixels[x], &pixel);
 #ifdef USE_CAIRO
-             ((uint32_t *)data)[width * y + x] =
+             dataptr[width * y + x] =
                lookup_rgb_color (f,
                                  color_scale * pixel.red,
                                  color_scale * pixel.green,
@@ -8917,7 +9031,7 @@ imagemagick_load_image (struct frame *f, struct image 
*img,
     }
 
 #ifdef USE_CAIRO
-  create_cairo_image_surface (img, data, width, height);
+  set_cairo_image_surface (img, surface);
 #else
 #ifdef COLOR_TABLE_SUPPORT
   /* Remember colors allocated for this image.  */
@@ -8967,7 +9081,7 @@ imagemagick_load (struct frame *f, struct image *img)
   file_name = image_spec_value (img->spec, QCfile, NULL);
   if (STRINGP (file_name))
     {
-      Lisp_Object file = x_find_image_file (file_name);
+      Lisp_Object file = image_find_image_file (file_name);
       if (!STRINGP (file))
        {
          image_error ("Cannot find image file `%s'", file_name);
@@ -8979,8 +9093,8 @@ imagemagick_load (struct frame *f, struct image *img)
 #endif
       success_p = imagemagick_load_image (f, img, 0, 0, SSDATA (file));
     }
-  /* Else its not a file, its a lisp object.  Load the image from a
-     lisp object rather than a file.  */
+  /* Else it's not a file, it's a Lisp object.  Load the image from a
+     Lisp object rather than a file.  */
   else
     {
       Lisp_Object data;
@@ -9098,7 +9212,7 @@ static struct image_type svg_type =
   SYMBOL_INDEX (Qsvg),
   svg_image_p,
   svg_load,
-  x_clear_image,
+  image_clear_image,
   init_svg_functions,
   NULL
 };
@@ -9268,7 +9382,7 @@ svg_load (struct frame *f, struct image *img)
   if (STRINGP (file_name))
     {
       int fd;
-      Lisp_Object file = x_find_image_fd (file_name, &fd);
+      Lisp_Object file = image_find_image_fd (file_name, &fd);
       if (!STRINGP (file))
        {
          image_error ("Cannot find image file `%s'", file_name);
@@ -9288,8 +9402,8 @@ svg_load (struct frame *f, struct image *img)
                                  SSDATA (ENCODE_FILE (file)));
       xfree (contents);
     }
-  /* Else its not a file, its a lisp object.  Load the image from a
-     lisp object rather than a file.  */
+  /* Else it's not a file, it's a Lisp object.  Load the image from a
+     Lisp object rather than a file.  */
   else
     {
       Lisp_Object data, original_filename;
@@ -9380,13 +9494,13 @@ svg_load_image (struct frame *f, struct image *img, 
char *contents,
 
   {
 #ifdef USE_CAIRO
-    unsigned char *data = (unsigned char *) xmalloc (width*height*4);
+    cairo_surface_t *surface = create_cairo_image_surface (width, height);
+    uint32_t *dataptr = (uint32_t *) cairo_image_surface_get_data (surface);
     uint32_t bgcolor = get_spec_bg_or_alpha_as_argb (img, f);
 
     for (int y = 0; y < height; ++y)
       {
         const guchar *iconptr = pixels + y * rowstride;
-        uint32_t *dataptr = (uint32_t *) (data + y * rowstride);
 
         for (int x = 0; x < width; ++x)
           {
@@ -9403,7 +9517,7 @@ svg_load_image (struct frame *f, struct image *img, char 
*contents,
           }
       }
 
-    create_cairo_image_surface (img, data, width, height);
+    set_cairo_image_surface (img, surface);
     g_object_unref (pixbuf);
 #else
     /* Try to create a x pixmap to hold the svg pixmap.  */
@@ -9421,8 +9535,12 @@ svg_load_image (struct frame *f, struct image *img, char 
*contents,
     XColor background;
     Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, 
NULL);
     if (!STRINGP (specified_bg)
-       || !x_defined_color (f, SSDATA (specified_bg), &background, 0))
-      x_query_frame_background_color (f, &background);
+       || !FRAME_TERMINAL (f)->defined_color_hook (f,
+                                                    SSDATA (specified_bg),
+                                                    &background,
+                                                    false,
+                                                    false))
+      FRAME_TERMINAL (f)->query_frame_background_color (f, &background);
 
     /* SVG pixmaps specify transparency in the last byte, so right
        shift 8 bits to get rid of it, since emacs doesn't support
@@ -9565,7 +9683,7 @@ static struct image_type gs_type =
 static void
 gs_clear_image (struct frame *f, struct image *img)
 {
-  x_clear_image (f, img);
+  image_clear_image (f, img);
 }
 
 
@@ -9645,7 +9763,7 @@ gs_load (struct frame *f, struct image *img)
   /* Create the pixmap.  */
   eassert (img->pixmap == NO_PIXMAP);
 
-  if (x_check_image_size (0, img->width, img->height))
+  if (image_check_image_size (0, img->width, img->height))
     {
       /* Only W32 version did BLOCK_INPUT here.  ++kfs */
       block_input ();
@@ -9755,7 +9873,7 @@ x_kill_gs_process (Pixmap pixmap, struct frame *f)
          XDestroyImage (ximg);
 
 #if 0 /* This doesn't seem to be the case.  If we free the colors
-        here, we get a BadAccess later in x_clear_image when
+        here, we get a BadAccess later in image_clear_image when
         freeing the colors.  */
          /* We have allocated colors once, but Ghostscript has also
             allocated colors on behalf of us.  So, to get the
@@ -9816,6 +9934,25 @@ DEFUN ("lookup-image", Flookup_image, Slookup_image, 1, 
1, 0,
                            Initialization
  ***********************************************************************/
 
+DEFUN ("image-scaling-p", Fimage_scaling_p, Simage_scaling_p, 0, 1, 0,
+       doc: /* Test whether FRAME supports resizing images.
+Return t if FRAME supports native scaling, nil otherwise.  */)
+     (Lisp_Object frame)
+{
+#if defined (USE_CAIRO) || defined (HAVE_NS) || defined (HAVE_NTGUI)
+  return Qt;
+#elif defined (HAVE_X_WINDOWS) && defined (HAVE_XRENDER)
+  int event_basep, error_basep;
+
+  if (XRenderQueryExtension
+      (FRAME_X_DISPLAY (decode_window_system_frame (frame)),
+       &event_basep, &error_basep))
+    return Qt;
+#endif
+
+  return Qnil;
+}
+
 DEFUN ("init-image-library", Finit_image_library, Sinit_image_library, 1, 1, 0,
        doc: /* Initialize image library implementing image type TYPE.
 Return non-nil if TYPE is a supported image type.
@@ -9884,7 +10021,7 @@ lookup_image_type (Lisp_Object type)
   return NULL;
 }
 
-#if !defined CANNOT_DUMP && defined HAVE_WINDOW_SYSTEM
+#if defined HAVE_UNEXEC && defined HAVE_WINDOW_SYSTEM
 
 /* Reset image_types before dumping.
    Called from Fdump_emacs.  */
@@ -9905,7 +10042,9 @@ void
 syms_of_image (void)
 {
   /* Initialize this only once; it will be reset before dumping.  */
+  /* The portable dumper will just leave it NULL, so no need to reset.  */
   image_types = NULL;
+  PDUMPER_IGNORE (image_types);
 
   /* Must be defined now because we're going to update it below, while
      defining the supported image types.  */
@@ -10058,6 +10197,8 @@ non-numeric, there is no explicit limit on the size of 
images.  */);
   defsubr (&Slookup_image);
 #endif
 
+  defsubr (&Simage_scaling_p);
+
   DEFVAR_BOOL ("cross-disabled-images", cross_disabled_images,
     doc: /* Non-nil means always draw a cross over disabled images.
 Disabled images are those having a `:conversion disabled' property.
diff --git a/src/indent.c b/src/indent.c
index e0d35f8..a022ae9 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -1,5 +1,5 @@
 /* Indentation functions.
-   Copyright (C) 1985-1988, 1993-1995, 1998, 2000-2018 Free Software
+   Copyright (C) 1985-1988, 1993-1995, 1998, 2000-2019 Free Software
    Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -49,7 +49,7 @@ ptrdiff_t last_known_column_point;
 
 /* Value of MODIFF when current_column was called.  */
 
-static EMACS_INT last_known_column_modified;
+static modiff_count last_known_column_modified;
 
 static ptrdiff_t current_column_1 (void);
 static ptrdiff_t position_indentation (ptrdiff_t);
@@ -1756,14 +1756,14 @@ visible section of the buffer, and pass LINE and COL as 
TOPOS.  */)
 
   CHECK_FIXNUM_COERCE_MARKER (from);
   CHECK_CONS (frompos);
-  CHECK_FIXNUM_CAR (frompos);
-  CHECK_FIXNUM_CDR (frompos);
+  CHECK_FIXNUM (XCAR (frompos));
+  CHECK_FIXNUM (XCDR (frompos));
   CHECK_FIXNUM_COERCE_MARKER (to);
   if (!NILP (topos))
     {
       CHECK_CONS (topos);
-      CHECK_FIXNUM_CAR (topos);
-      CHECK_FIXNUM_CDR (topos);
+      CHECK_FIXNUM (XCAR (topos));
+      CHECK_FIXNUM (XCDR (topos));
     }
   if (!NILP (width))
     CHECK_FIXNUM (width);
@@ -1771,8 +1771,8 @@ visible section of the buffer, and pass LINE and COL as 
TOPOS.  */)
   if (!NILP (offsets))
     {
       CHECK_CONS (offsets);
-      CHECK_FIXNUM_CAR (offsets);
-      CHECK_FIXNUM_CDR (offsets);
+      CHECK_FIXNUM (XCAR (offsets));
+      CHECK_FIXNUM (XCDR (offsets));
       if (! (0 <= XFIXNUM (XCAR (offsets)) && XFIXNUM (XCAR (offsets)) <= 
PTRDIFF_MAX
             && 0 <= XFIXNUM (XCDR (offsets)) && XFIXNUM (XCDR (offsets)) <= 
INT_MAX))
        args_out_of_range (XCAR (offsets), XCDR (offsets));
@@ -1968,8 +1968,11 @@ line_number_display_width (struct window *w, int *width, 
int *pixel_width)
         outside the accessible region, in which case we widen the
         buffer temporarily.  It could even be beyond the buffer's end
         (Org mode's display of source code snippets is known to cause
-        that), in which case we just punt and start from point instead.  */
-      if (startpos.charpos > Z)
+        that) or belong to the wrong buffer, in which cases we just
+        punt and start from point instead.  */
+      if (startpos.charpos > Z
+         || !(BUFFERP (w->contents)
+              && XBUFFER (w->contents) == XMARKER (w->start)->buffer))
        SET_TEXT_POS (startpos, PT, PT_BYTE);
       if (startpos.charpos < BEGV || startpos.charpos > ZV)
        {
@@ -2286,7 +2289,7 @@ whether or not it is currently displayed in some window.  
*/)
          it.current_y = 0;
          /* Do this even if LINES is 0, so that we move back to the
             beginning of the current line as we ought.  */
-         if ((nlines < 0 && IT_CHARPOS (it) > 0)
+         if ((nlines < 0 && IT_CHARPOS (it) > BEGV)
              || (nlines == 0 && !(start_x_given && start_x <= to_x)))
            move_it_by_lines (&it, max (PTRDIFF_MIN, nlines));
        }
@@ -2338,7 +2341,7 @@ whether or not it is currently displayed in some window.  
*/)
             and then reposition point at the requested X coordinate;
             if we don't, the cursor will be placed just after the
             string, which might not be the requested column.  */
-         if (nlines > 0 && it.area == TEXT_AREA)
+         if (nlines >= 0 && it.area == TEXT_AREA)
            {
              while (it.method == GET_FROM_STRING
                     && !it.string_from_display_prop_p
diff --git a/src/indent.h b/src/indent.h
index f0fd23a..7fd1067 100644
--- a/src/indent.h
+++ b/src/indent.h
@@ -1,5 +1,5 @@
 /* Definitions for interface to indent.c
-   Copyright (C) 1985-1986, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1985-1986, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/inotify.c b/src/inotify.c
index 6e54c18..9a7dbb8 100644
--- a/src/inotify.c
+++ b/src/inotify.c
@@ -1,6 +1,6 @@
 /* Inotify support for Emacs
 
-Copyright (C) 2012-2018 Free Software Foundation, Inc.
+Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -19,8 +19,6 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 
-#ifdef HAVE_INOTIFY
-
 #include "lisp.h"
 #include "coding.h"
 #include "process.h"
@@ -550,5 +548,3 @@ syms_of_inotify (void)
 
   Fprovide (intern_c_string ("inotify"), Qnil);
 }
-
-#endif /* HAVE_INOTIFY */
diff --git a/src/insdel.c b/src/insdel.c
index 70cebc0..1231bb2 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -1,5 +1,5 @@
 /* Buffer insertion/deletion and gap motion for GNU Emacs. -*- coding: utf-8 
-*-
-   Copyright (C) 1985-1986, 1993-1995, 1997-2018 Free Software
+   Copyright (C) 1985-1986, 1993-1995, 1997-2019 Free Software
    Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -29,6 +29,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "buffer.h"
 #include "window.h"
 #include "region-cache.h"
+#include "pdumper.h"
 
 static void insert_from_string_1 (Lisp_Object, ptrdiff_t, ptrdiff_t, ptrdiff_t,
                                  ptrdiff_t, bool, bool);
@@ -707,7 +708,7 @@ insert_char (int c)
   insert ((char *) str, len);
 }
 
-/* Insert the null-terminated string S before point.  */
+/* Insert the NUL-terminated string S before point.  */
 
 void
 insert_string (const char *s)
@@ -902,7 +903,7 @@ insert_1_both (const char *string,
      the insertion.  This, together with recording the insertion,
      will add up to the right stuff in the undo list.  */
   record_insert (PT, nchars);
-  MODIFF++;
+  modiff_incr (&MODIFF);
   CHARS_MODIFF = MODIFF;
 
   memcpy (GPT_ADDR, string, nbytes);
@@ -1030,7 +1031,7 @@ insert_from_string_1 (Lisp_Object string, ptrdiff_t pos, 
ptrdiff_t pos_byte,
 #endif
 
   record_insert (PT, nchars);
-  MODIFF++;
+  modiff_incr (&MODIFF);
   CHARS_MODIFF = MODIFF;
 
   GAP_SIZE -= outgoing_nbytes;
@@ -1087,7 +1088,7 @@ insert_from_gap (ptrdiff_t nchars, ptrdiff_t nbytes, bool 
text_at_gap_tail)
      of this dance.  */
   invalidate_buffer_caches (current_buffer, GPT, GPT);
   record_insert (GPT, nchars);
-  MODIFF++;
+  modiff_incr (&MODIFF);
 
   GAP_SIZE -= nbytes;
   if (! text_at_gap_tail)
@@ -1227,7 +1228,7 @@ insert_from_buffer_1 (struct buffer *buf,
 #endif
 
   record_insert (PT, nchars);
-  MODIFF++;
+  modiff_incr (&MODIFF);
   CHARS_MODIFF = MODIFF;
 
   GAP_SIZE -= outgoing_nbytes;
@@ -1328,7 +1329,7 @@ adjust_after_replace (ptrdiff_t from, ptrdiff_t from_byte,
 
   if (len == 0)
     evaporate_overlays (from);
-  MODIFF++;
+  modiff_incr (&MODIFF);
   CHARS_MODIFF = MODIFF;
 }
 
@@ -1523,7 +1524,7 @@ replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object 
new,
 
   check_markers ();
 
-  MODIFF++;
+  modiff_incr (&MODIFF);
   CHARS_MODIFF = MODIFF;
 
   if (adjust_match_data)
@@ -1654,7 +1655,7 @@ replace_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
 
   check_markers ();
 
-  MODIFF++;
+  modiff_incr (&MODIFF);
   CHARS_MODIFF = MODIFF;
 }
 
@@ -1829,7 +1830,7 @@ del_range_2 (ptrdiff_t from, ptrdiff_t from_byte,
      at the end of the text before the gap.  */
   adjust_markers_for_delete (from, from_byte, to, to_byte);
 
-  MODIFF++;
+  modiff_incr (&MODIFF);
   CHARS_MODIFF = MODIFF;
 
   /* Relocate point as if it were a marker.  */
@@ -1883,7 +1884,7 @@ modify_text (ptrdiff_t start, ptrdiff_t end)
   BUF_COMPUTE_UNCHANGED (current_buffer, start - 1, end);
   if (MODIFF <= SAVE_MODIFF)
     record_first_change ();
-  MODIFF++;
+  modiff_incr (&MODIFF);
   CHARS_MODIFF = MODIFF;
 
   bset_point_before_scroll (current_buffer, Qnil);
@@ -1927,6 +1928,14 @@ prepare_to_modify_buffer_1 (ptrdiff_t start, ptrdiff_t 
end,
   if (!NILP (BVAR (current_buffer, read_only)))
     Fbarf_if_buffer_read_only (temp);
 
+  /* If we're about to modify a buffer the contents of which come from
+     a dump file, copy the contents to private storage first so we
+     don't take a COW fault on the buffer text and keep it around
+     forever.  */
+  if (pdumper_object_p (BEG_ADDR))
+    enlarge_buffer_text (current_buffer, 0);
+  eassert (!pdumper_object_p (BEG_ADDR));
+
   run_undoable_change();
 
   bset_redisplay (current_buffer);
@@ -2255,7 +2264,7 @@ DEFUN ("combine-after-change-execute", 
Fcombine_after_change_execute,
 
   /* It is rare for combine_after_change_buffer to be invalid, but
      possible.  It can happen when combine-after-change-calls is
-     non-nil, and insertion calls a file handler (e.g. through
+     non-nil, and insertion calls a file name handler (e.g. through
      lock_file) which scribbles into a temp file -- cyd  */
   if (!BUFFERP (combine_after_change_buffer)
       || !BUFFER_LIVE_P (XBUFFER (combine_after_change_buffer)))
diff --git a/src/intervals.c b/src/intervals.c
index 7e77714..8f39c45 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -1,5 +1,5 @@
 /* Code for doing intervals.
-   Copyright (C) 1993-1995, 1997-1998, 2001-2018 Free Software
+   Copyright (C) 1993-1995, 1997-1998, 2001-2019 Free Software
    Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -713,11 +713,21 @@ previous_interval (register INTERVAL interval)
   return NULL;
 }
 
-/* Find the interval containing POS given some non-NULL INTERVAL
-   in the same tree.  Note that we need to update interval->position
-   if we go down the tree.
-   To speed up the process, we assume that the ->position of
-   I and all its parents is already uptodate.  */
+/* Set the ->position field of I's parent, based on I->position. */
+#define SET_PARENT_POSITION(i)                                  \
+  if (AM_LEFT_CHILD (i))                                        \
+    INTERVAL_PARENT (i)->position =                             \
+      i->position + TOTAL_LENGTH (i) - LEFT_TOTAL_LENGTH (i);   \
+  else                                                          \
+    INTERVAL_PARENT (i)->position =                             \
+      i->position - LEFT_TOTAL_LENGTH (i)                       \
+      - LENGTH (INTERVAL_PARENT (i))
+
+/* Find the interval containing POS, given some non-NULL INTERVAL in
+   the same tree.  Note that we update interval->position in each
+   interval we traverse, assuming it is already correctly set for the
+   argument I.  We don't assume that any other interval already has a
+   correctly set ->position.  */
 INTERVAL
 update_interval (register INTERVAL i, ptrdiff_t pos)
 {
@@ -738,7 +748,10 @@ update_interval (register INTERVAL i, ptrdiff_t pos)
          else if (NULL_PARENT (i))
            error ("Point before start of properties");
          else
-             i = INTERVAL_PARENT (i);
+            {
+              SET_PARENT_POSITION (i);
+              i = INTERVAL_PARENT (i);
+            }
          continue;
        }
       else if (pos >= INTERVAL_LAST_POS (i))
@@ -753,7 +766,10 @@ update_interval (register INTERVAL i, ptrdiff_t pos)
          else if (NULL_PARENT (i))
            error ("Point %"pD"d after end of properties", pos);
          else
-            i = INTERVAL_PARENT (i);
+            {
+              SET_PARENT_POSITION (i);
+              i = INTERVAL_PARENT (i);
+            }
          continue;
        }
       else
diff --git a/src/intervals.h b/src/intervals.h
index f37372a..e916694 100644
--- a/src/intervals.h
+++ b/src/intervals.h
@@ -1,5 +1,5 @@
 /* Definitions and global variables for intervals.
-   Copyright (C) 1993-1994, 2000-2018 Free Software Foundation, Inc.
+   Copyright (C) 1993-1994, 2000-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -29,14 +29,17 @@ INLINE_HEADER_BEGIN
 struct interval
 {
   /* The first group of entries deal with the tree structure.  */
-
   ptrdiff_t total_length;       /* Length of myself and both children.  */
   ptrdiff_t position;          /* Cache of interval's character position.  */
-                               /* This field is usually updated
-                                  simultaneously with an interval
-                                  traversal, there is no guarantee
-                                  that it is valid for a random
-                                  interval.  */
+                                /* This field is valid in the final
+                                   target interval returned by
+                                   find_interval, next_interval,
+                                   previous_interval and
+                                   update_interval.  It cannot be
+                                   depended upon in any intermediate
+                                   intervals traversed by these
+                                   functions, or any other
+                                   interval. */
   struct interval *left;       /* Intervals which precede me.  */
   struct interval *right;      /* Intervals which succeed me.  */
 
diff --git a/src/json.c b/src/json.c
index 770b63c..03468e9 100644
--- a/src/json.c
+++ b/src/json.c
@@ -1,6 +1,6 @@
 /* JSON parsing and serialization.
 
-Copyright (C) 2017-2018 Free Software Foundation, Inc.
+Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -217,7 +217,8 @@ json_has_suffix (const char *string, const char *suffix)
 
 /* Create a multibyte Lisp string from the UTF-8 string in
    [DATA, DATA + SIZE).  If the range [DATA, DATA + SIZE) does not
-   contain a valid UTF-8 string, an unspecified string is returned.
+   contain a valid UTF-8 string, the returned string will include raw
+   bytes.
    Note that all callers below either pass only value UTF-8 strings or
    use this function for formatting error messages; in the latter case
    correctness isn't critical.  */
@@ -225,11 +226,24 @@ json_has_suffix (const char *string, const char *suffix)
 static Lisp_Object
 json_make_string (const char *data, ptrdiff_t size)
 {
-  return code_convert_string (make_specified_string (data, -1, size, false),
-                              Qutf_8_unix, Qt, false, true, true);
+  ptrdiff_t chars, bytes;
+  parse_str_as_multibyte ((const unsigned char *) data, size, &chars, &bytes);
+  /* If DATA is a valid UTF-8 string, we can convert it to a Lisp
+     string directly.  Otherwise, we need to decode it.  */
+  if (chars == size || bytes == size)
+    return make_specified_string (data, chars, size, true);
+  else
+    {
+      struct coding_system coding;
+      setup_coding_system (Qutf_8_unix, &coding);
+      coding.mode |= CODING_MODE_LAST_BLOCK;
+      coding.source = (const unsigned char *) data;
+      decode_coding_object (&coding, Qnil, 0, 0, size, size, Qt);
+      return coding.dst_object;
+    }
 }
 
-/* Create a multibyte Lisp string from the null-terminated UTF-8
+/* Create a multibyte Lisp string from the NUL-terminated UTF-8
    string beginning at DATA.  If the string is not a valid UTF-8
    string, an unspecified string is returned.  Note that all callers
    below either pass only value UTF-8 strings or use this function for
@@ -255,7 +269,7 @@ json_encode (Lisp_Object string)
   return code_convert_string (string, Qutf_8_unix, Qt, true, true, true);
 }
 
-static _Noreturn void
+static AVOID
 json_out_of_memory (void)
 {
   xsignal0 (Qjson_out_of_memory);
@@ -263,7 +277,7 @@ json_out_of_memory (void)
 
 /* Signal a Lisp error corresponding to the JSON ERROR.  */
 
-static _Noreturn void
+static AVOID
 json_parse_error (const json_error_t *error)
 {
   Lisp_Object symbol;
@@ -290,8 +304,8 @@ json_parse_error (const json_error_t *error)
 #endif
   xsignal (symbol,
            list5 (json_build_string (error->text),
-                  json_build_string (error->source), make_fixed_natnum 
(error->line),
-                  make_fixed_natnum (error->column), make_fixed_natnum 
(error->position)));
+                  json_build_string (error->source), INT_TO_INTEGER 
(error->line),
+                  INT_TO_INTEGER (error->column), INT_TO_INTEGER 
(error->position)));
 }
 
 static void
@@ -301,10 +315,10 @@ json_release_object (void *object)
 }
 
 /* Signal an error if OBJECT is not a string, or if OBJECT contains
-   embedded null characters.  */
+   embedded NUL characters.  */
 
 static void
-check_string_without_embedded_nulls (Lisp_Object object)
+check_string_without_embedded_nuls (Lisp_Object object)
 {
   CHECK_STRING (object);
   CHECK_TYPE (memchr (SDATA (object), '\0', SBYTES (object)) == NULL,
@@ -337,8 +351,14 @@ enum json_object_type {
   json_object_plist
 };
 
+enum json_array_type {
+  json_array_array,
+  json_array_list
+};
+
 struct json_configuration {
   enum json_object_type object_type;
+  enum json_array_type array_type;
   Lisp_Object null_object;
   Lisp_Object false_object;
 };
@@ -381,8 +401,8 @@ lisp_to_json_toplevel_1 (Lisp_Object lisp,
           {
             Lisp_Object key = json_encode (HASH_KEY (h, i));
             /* We can't specify the length, so the string must be
-               null-terminated.  */
-            check_string_without_embedded_nulls (key);
+               NUL-terminated.  */
+            check_string_without_embedded_nuls (key);
             const char *key_str = SSDATA (key);
             /* Reject duplicate keys.  These are possible if the hash
                table test is not `equal'.  */
@@ -432,8 +452,8 @@ lisp_to_json_toplevel_1 (Lisp_Object lisp,
           CHECK_SYMBOL (key_symbol);
           Lisp_Object key = SYMBOL_NAME (key_symbol);
           /* We can't specify the length, so the string must be
-             null-terminated.  */
-          check_string_without_embedded_nulls (key);
+             NUL-terminated.  */
+          check_string_without_embedded_nuls (key);
           key_str = SSDATA (key);
           /* In plists, ensure leading ":" in keys is stripped.  It
              will be reconstructed later in `json_to_lisp'.*/
@@ -493,7 +513,7 @@ lisp_to_json (Lisp_Object lisp, struct json_configuration 
*conf)
       intmax_t low = TYPE_MINIMUM (json_int_t);
       intmax_t high = TYPE_MAXIMUM (json_int_t);
       intmax_t value;
-      if (! integer_to_intmax (lisp, &value) || value < low || high < value)
+      if (! (integer_to_intmax (lisp, &value) && low <= value && value <= 
high))
         args_out_of_range_3 (lisp, make_int (low), make_int (high));
       return json_check (json_integer (value));
     }
@@ -521,7 +541,7 @@ static void
 json_parse_args (ptrdiff_t nargs,
                  Lisp_Object *args,
                  struct json_configuration *conf,
-                 bool configure_object_type)
+                 bool parse_object_types)
 {
   if ((nargs % 2) != 0)
     wrong_type_argument (Qplistp, Flist (nargs, args));
@@ -531,7 +551,7 @@ json_parse_args (ptrdiff_t nargs,
   for (ptrdiff_t i = nargs; i > 0; i -= 2) {
     Lisp_Object key = args[i - 2];
     Lisp_Object value = args[i - 1];
-    if (configure_object_type && EQ (key, QCobject_type))
+    if (parse_object_types && EQ (key, QCobject_type))
       {
         if (EQ (value, Qhash_table))
           conf->object_type = json_object_hashtable;
@@ -542,12 +562,22 @@ json_parse_args (ptrdiff_t nargs,
         else
           wrong_choice (list3 (Qhash_table, Qalist, Qplist), value);
       }
+    else if (parse_object_types && EQ (key, QCarray_type))
+      {
+        if (EQ (value, Qarray))
+          conf->array_type = json_array_array;
+        else if (EQ (value, Qlist))
+          conf->array_type = json_array_list;
+        else
+          wrong_choice (list2 (Qarray, Qlist), value);
+      }
     else if (EQ (key, QCnull_object))
       conf->null_object = value;
     else if (EQ (key, QCfalse_object))
       conf->false_object = value;
-    else if (configure_object_type)
-      wrong_choice (list3 (QCobject_type,
+    else if (parse_object_types)
+      wrong_choice (list4 (QCobject_type,
+                           QCarray_type,
                            QCnull_object,
                            QCfalse_object),
                     value);
@@ -568,7 +598,7 @@ false values, t, numbers, strings, or other vectors 
hashtables, alists
 or plists.  t will be converted to the JSON true value.  Vectors will
 be converted to JSON arrays, whereas hashtables, alists and plists are
 converted to JSON objects.  Hashtable keys must be strings without
-embedded null characters and must be unique within each object.  Alist
+embedded NUL characters and must be unique within each object.  Alist
 and plist keys must be symbols; if a key is duplicate, the first
 instance is used.
 
@@ -604,7 +634,8 @@ usage: (json-serialize OBJECT &rest ARGS)  */)
     }
 #endif
 
-  struct json_configuration conf = {json_object_hashtable, QCnull, QCfalse};
+  struct json_configuration conf =
+    {json_object_hashtable, json_array_array, QCnull, QCfalse};
   json_parse_args (nargs - 1, args + 1, &conf, false);
 
   json_t *json = lisp_to_json_toplevel (args[0], &conf);
@@ -648,6 +679,20 @@ json_insert (void *data)
   return Qnil;
 }
 
+static Lisp_Object
+json_handle_nonlocal_exit (enum nonlocal_exit type, Lisp_Object data)
+{
+  switch (type)
+    {
+    case NONLOCAL_EXIT_SIGNAL:
+      return data;
+    case NONLOCAL_EXIT_THROW:
+      return Fcons (Qno_catch, data);
+    default:
+      eassume (false);
+    }
+}
+
 struct json_insert_data
 {
   /* This tracks how many bytes were inserted by the callback since
@@ -670,7 +715,8 @@ json_insert_callback (const char *buffer, size_t size, void 
*data)
   struct json_insert_data *d = data;
   struct json_buffer_and_size buffer_and_size
     = {.buffer = buffer, .size = size, .inserted_bytes = d->inserted_bytes};
-  d->error = internal_catch_all (json_insert, &buffer_and_size, Fidentity);
+  d->error = internal_catch_all (json_insert, &buffer_and_size,
+                                 json_handle_nonlocal_exit);
   d->inserted_bytes = buffer_and_size.inserted_bytes;
   return NILP (d->error) ? 0 : -1;
 }
@@ -701,7 +747,8 @@ usage: (json-insert OBJECT &rest ARGS)  */)
     }
 #endif
 
-  struct json_configuration conf = {json_object_hashtable, QCnull, QCfalse};
+  struct json_configuration conf =
+    {json_object_hashtable, json_array_array, QCnull, QCfalse};
   json_parse_args (nargs - 1, args + 1, &conf, false);
 
   json_t *json = lisp_to_json (args[0], &conf);
@@ -815,12 +862,37 @@ json_to_lisp (json_t *json, struct json_configuration 
*conf)
         if (++lisp_eval_depth > max_lisp_eval_depth)
           xsignal0 (Qjson_object_too_deep);
         size_t size = json_array_size (json);
-        if (FIXNUM_OVERFLOW_P (size))
+        if (PTRDIFF_MAX < size)
           overflow_error ();
-        Lisp_Object result = make_vector (size, Qunbound);
-        for (ptrdiff_t i = 0; i < size; ++i)
-          ASET (result, i,
-                json_to_lisp (json_array_get (json, i), conf));
+        Lisp_Object result;
+        switch (conf->array_type)
+          {
+          case json_array_array:
+            {
+              result = make_vector (size, Qunbound);
+              for (ptrdiff_t i = 0; i < size; ++i)
+                {
+                  rarely_quit (i);
+                  ASET (result, i,
+                        json_to_lisp (json_array_get (json, i), conf));
+                }
+              break;
+            }
+          case json_array_list:
+            {
+              result = Qnil;
+              for (ptrdiff_t i = size - 1; i >= 0; --i)
+                {
+                  rarely_quit (i);
+                  result = Fcons (json_to_lisp (json_array_get (json, i), 
conf),
+                                  result);
+                }
+              break;
+            }
+          default:
+            /* Can't get here.  */
+            emacs_abort ();
+          }
         --lisp_eval_depth;
         return result;
       }
@@ -905,18 +977,22 @@ json_to_lisp (json_t *json, struct json_configuration 
*conf)
 DEFUN ("json-parse-string", Fjson_parse_string, Sjson_parse_string, 1, MANY,
        NULL,
        doc: /* Parse the JSON STRING into a Lisp object.
-
 This is essentially the reverse operation of `json-serialize', which
-see.  The returned object will be a vector, hashtable, alist, or
+see.  The returned object will be a vector, list, hashtable, alist, or
 plist.  Its elements will be the JSON null value, the JSON false
 value, t, numbers, strings, or further vectors, hashtables, alists, or
 plists.  If there are duplicate keys in an object, all but the last
-one are ignored.  If STRING doesn't contain a valid JSON object, an
-error of type `json-parse-error' is signaled.  The arguments ARGS are
-a list of keyword/argument pairs:
+one are ignored.  If STRING doesn't contain a valid JSON object, this
+function signals an error of type `json-parse-error'.
+
+The arguments ARGS are a list of keyword/argument pairs:
 
 The keyword argument `:object-type' specifies which Lisp type is used
-to represent objects; it can be `hash-table', `alist' or `plist'.
+to represent objects; it can be `hash-table', `alist' or `plist'.  It
+defaults to `hash-table'.
+
+The keyword argument `:array-type' specifies which Lisp type is used
+to represent arrays; it can be `array' (the default) or `list'.
 
 The keyword argument `:null-object' specifies which object to use
 to represent a JSON null value.  It defaults to `:null'.
@@ -945,8 +1021,9 @@ usage: (json-parse-string STRING &rest ARGS) */)
 
   Lisp_Object string = args[0];
   Lisp_Object encoded = json_encode (string);
-  check_string_without_embedded_nulls (encoded);
-  struct json_configuration conf = {json_object_hashtable, QCnull, QCfalse};
+  check_string_without_embedded_nuls (encoded);
+  struct json_configuration conf =
+    {json_object_hashtable, json_array_array, QCnull, QCfalse};
   json_parse_args (nargs - 1, args + 1, &conf, true);
 
   json_error_t error;
@@ -993,9 +1070,32 @@ json_read_buffer_callback (void *buffer, size_t buflen, 
void *data)
 DEFUN ("json-parse-buffer", Fjson_parse_buffer, Sjson_parse_buffer,
        0, MANY, NULL,
        doc: /* Read JSON object from current buffer starting at point.
-This is similar to `json-parse-string', which see.  Move point after
-the end of the object if parsing was successful.  On error, point is
-not moved.
+Move point after the end of the object if parsing was successful.
+On error, don't move point.
+
+The returned object will be a vector, list, hashtable, alist, or
+plist.  Its elements will be the JSON null value, the JSON false
+value, t, numbers, strings, or further vectors, lists, hashtables,
+alists, or plists.  If there are duplicate keys in an object, all
+but the last one are ignored.
+
+If the current buffer doesn't contain a valid JSON object, the
+function signals an error of type `json-parse-error'.
+
+The arguments ARGS are a list of keyword/argument pairs:
+
+The keyword argument `:object-type' specifies which Lisp type is used
+to represent objects; it can be `hash-table', `alist' or `plist'.  It
+defaults to `hash-table'.
+
+The keyword argument `:array-type' specifies which Lisp type is used
+to represent arrays; it can be `array' (the default) or `list'.
+
+The keyword argument `:null-object' specifies which object to use
+to represent a JSON null value.  It defaults to `:null'.
+
+The keyword argument `:false-object' specifies which object to use to
+represent a JSON false value.  It defaults to `:false'.
 usage: (json-parse-buffer &rest args) */)
      (ptrdiff_t nargs, Lisp_Object *args)
 {
@@ -1016,7 +1116,8 @@ usage: (json-parse-buffer &rest args) */)
     }
 #endif
 
-  struct json_configuration conf = {json_object_hashtable, QCnull, QCfalse};
+  struct json_configuration conf =
+    {json_object_hashtable, json_array_array, QCnull, QCfalse};
   json_parse_args (nargs, args, &conf, true);
 
   ptrdiff_t point = PT_BYTE;
@@ -1095,10 +1196,12 @@ syms_of_json (void)
   Fput (Qjson_parse_string, Qside_effect_free, Qt);
 
   DEFSYM (QCobject_type, ":object-type");
+  DEFSYM (QCarray_type, ":array-type");
   DEFSYM (QCnull_object, ":null-object");
   DEFSYM (QCfalse_object, ":false-object");
   DEFSYM (Qalist, "alist");
   DEFSYM (Qplist, "plist");
+  DEFSYM (Qarray, "array");
 
   defsubr (&Sjson_serialize);
   defsubr (&Sjson_insert);
diff --git a/src/keyboard.c b/src/keyboard.c
index baf2f51..ea13c7f 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -1,6 +1,6 @@
 /* Keyboard and mouse input; editor command loop.
 
-Copyright (C) 1985-1989, 1993-1997, 1999-2018 Free Software Foundation,
+Copyright (C) 1985-1989, 1993-1997, 1999-2019 Free Software Foundation,
 Inc.
 
 This file is part of GNU Emacs.
@@ -68,6 +68,8 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #include <ignore-value.h>
 
+#include "pdumper.h"
+
 #ifdef HAVE_WINDOW_SYSTEM
 #include TERM_HEADER
 #endif /* HAVE_WINDOW_SYSTEM */
@@ -206,7 +208,7 @@ struct buffer *buffer_before_last_command_or_undo;
 
 /* Value of num_nonmacro_input_events as of last auto save.  */
 
-static EMACS_INT last_auto_save;
+static intmax_t last_auto_save;
 
 /* The value of point when the last command was started. */
 static ptrdiff_t last_point_position;
@@ -358,11 +360,11 @@ static Lisp_Object make_lispy_focus_in (Lisp_Object);
 static Lisp_Object make_lispy_focus_out (Lisp_Object);
 static bool help_char_p (Lisp_Object);
 static void save_getcjmp (sys_jmp_buf);
-static void restore_getcjmp (sys_jmp_buf);
+static void restore_getcjmp (void *);
 static Lisp_Object apply_modifiers (int, Lisp_Object);
 static void restore_kboard_configuration (int);
 static void handle_interrupt (bool);
-static _Noreturn void quit_throw_to_read_char (bool);
+static AVOID quit_throw_to_read_char (bool);
 static void timer_start_idle (void);
 static void timer_stop_idle (void);
 static void timer_resume_idle (void);
@@ -735,7 +737,8 @@ void
 force_auto_save_soon (void)
 {
   last_auto_save = - auto_save_interval - 1;
-
+  /* FIXME: What's the relationship between forcing auto-save and adding
+     a buffer-switch event?  */
   record_asynch_buffer_change ();
 }
 #endif
@@ -1128,13 +1131,12 @@ This also exits all active minibuffers.  */
   Fthrow (Qtop_level, Qnil);
 }
 
-static _Noreturn void
+static AVOID
 user_error (const char *msg)
 {
   xsignal1 (Quser_error, build_string (msg));
 }
 
-/* _Noreturn will be added to prototype by make-docfile.  */
 DEFUN ("exit-recursive-edit", Fexit_recursive_edit, Sexit_recursive_edit, 0, 
0, "",
        doc: /* Exit from the innermost recursive edit or minibuffer.  */
        attributes: noreturn)
@@ -1146,7 +1148,6 @@ DEFUN ("exit-recursive-edit", Fexit_recursive_edit, 
Sexit_recursive_edit, 0, 0,
   user_error ("No recursive edit is in progress");
 }
 
-/* _Noreturn will be added to prototype by make-docfile.  */
 DEFUN ("abort-recursive-edit", Fabort_recursive_edit, Sabort_recursive_edit, 
0, 0, "",
        doc: /* Abort the command that requested this recursive edit or 
minibuffer input.  */
        attributes: noreturn)
@@ -1211,7 +1212,7 @@ some_mouse_moved (void)
 
   if (ignore_mouse_drag_p)
     {
-      /* ignore_mouse_drag_p = 0; */
+      /* ignore_mouse_drag_p = false; */
       return 0;
     }
 
@@ -1236,7 +1237,7 @@ static void adjust_point_for_property (ptrdiff_t, bool);
 Lisp_Object
 command_loop_1 (void)
 {
-  EMACS_INT prev_modiff = 0;
+  modiff_count prev_modiff = 0;
   struct buffer *prev_buffer = NULL;
   bool already_adjusted = 0;
 
@@ -1299,7 +1300,7 @@ command_loop_1 (void)
         loop.  (This flag is set in xdisp.c whenever the tool bar is
         resized, because the resize moves text up or down, and would
         generate false mouse drag events if we don't ignore them.)  */
-      ignore_mouse_drag_p = 0;
+      ignore_mouse_drag_p = false;
 
       /* If minibuffer on and echo area in use,
         wait a short time and redraw minibuffer.  */
@@ -1326,7 +1327,7 @@ command_loop_1 (void)
          if (!NILP (Vquit_flag))
            {
              Vquit_flag = Qnil;
-             Vunread_command_events = list1 (make_fixnum (quit_char));
+             Vunread_command_events = list1i (quit_char);
            }
        }
 
@@ -1474,8 +1475,12 @@ command_loop_1 (void)
       safe_run_hooks (Qpost_command_hook);
 
       /* If displaying a message, resize the echo area window to fit
-        that message's size exactly.  */
-      if (!NILP (echo_area_buffer[0]))
+        that message's size exactly.  Do this only if the echo area
+        window is the minibuffer window of the selected frame.  See
+        Bug#34317.  */
+      if (!NILP (echo_area_buffer[0])
+         && (EQ (echo_area_window,
+                 FRAME_MINIBUF_WINDOW (XFRAME (selected_frame)))))
        resize_echo_area_exactly ();
 
       /* If there are warnings waiting, process them.  */
@@ -1964,14 +1969,14 @@ void
 bind_polling_period (int n)
 {
 #ifdef POLL_FOR_INPUT
-  EMACS_INT new = polling_period;
+  intmax_t new = polling_period;
 
   if (n > new)
     new = n;
 
   stop_other_atimers (poll_timer);
   stop_polling ();
-  specbind (Qpolling_period, make_fixnum (new));
+  specbind (Qpolling_period, make_int (new));
   /* Start a new alarm with the new period.  */
   start_polling ();
 #endif
@@ -2124,12 +2129,14 @@ read_event_from_main_queue (struct timespec *end_time,
     return c;
 
   /* Actually read a character, waiting if necessary.  */
+  ptrdiff_t count = SPECPDL_INDEX ();
   save_getcjmp (save_jump);
+  record_unwind_protect_ptr (restore_getcjmp, save_jump);
   restore_getcjmp (local_getcjmp);
   if (!end_time)
     timer_start_idle ();
   c = kbd_buffer_get_event (&kb, used_mouse_menu, end_time);
-  restore_getcjmp (save_jump);
+  unbind_to (count, Qnil);
 
   if (! NILP (c) && (kb != current_kboard))
     {
@@ -2356,7 +2363,14 @@ read_char (int commandflag, Lisp_Object map,
       if (CONSP (c) && EQ (XCAR (c), Qt))
        c = XCDR (c);
       else
-       reread = true;
+       {
+         if (CONSP (c) && EQ (XCAR (c), Qno_record))
+           {
+             c = XCDR (c);
+             recorded = true;
+           }
+         reread = true;
+       }
 
       /* Undo what read_char_x_menu_prompt did when it unread
         additional keys returned by Fx_popup_menu.  */
@@ -2418,7 +2432,7 @@ read_char (int commandflag, Lisp_Object map,
          goto exit;
        }
 
-      c = Faref (Vexecuting_kbd_macro, make_fixnum 
(executing_kbd_macro_index));
+      c = Faref (Vexecuting_kbd_macro, make_int (executing_kbd_macro_index));
       if (STRINGP (Vexecuting_kbd_macro)
          && (XFIXNAT (c) & 0x80) && (XFIXNAT (c) <= 0xff))
        XSETFASTINT (c, CHAR_META | (XFIXNAT (c) & ~0x80));
@@ -2547,7 +2561,10 @@ read_char (int commandflag, Lisp_Object map,
       restore_getcjmp (save_jump);
       pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
       unbind_to (jmpcount, Qnil);
-      XSETINT (c, quit_char);
+      /* If we are in while-no-input, don't trigger C-g, as that will
+        quit instead of letting while-no-input do its thing.  */
+      if (!EQ (Vquit_flag, Vthrow_on_input))
+       XSETINT (c, quit_char);
       internal_last_event_frame = selected_frame;
       Vlast_event_frame = internal_last_event_frame;
       /* If we report the quit char as an event,
@@ -2618,10 +2635,12 @@ read_char (int commandflag, Lisp_Object map,
        {
          Lisp_Object tem0;
 
+         ptrdiff_t count = SPECPDL_INDEX ();
          save_getcjmp (save_jump);
+         record_unwind_protect_ptr (restore_getcjmp, save_jump);
          restore_getcjmp (local_getcjmp);
          tem0 = sit_for (Vecho_keystrokes, 1, 1);
-         restore_getcjmp (save_jump);
+         unbind_to (count, Qnil);
          if (EQ (tem0, Qt)
              && ! CONSP (Vunread_command_events))
            echo_now ();
@@ -2692,10 +2711,12 @@ read_char (int commandflag, Lisp_Object map,
 
          timeout = min (timeout, MOST_POSITIVE_FIXNUM / delay_level * 4);
          timeout = delay_level * timeout / 4;
+         ptrdiff_t count1 = SPECPDL_INDEX ();
          save_getcjmp (save_jump);
+         record_unwind_protect_ptr (restore_getcjmp, save_jump);
          restore_getcjmp (local_getcjmp);
          tem0 = sit_for (make_fixnum (timeout), 1, 1);
-         restore_getcjmp (save_jump);
+         unbind_to (count1, Qnil);
 
          if (EQ (tem0, Qt)
              && ! CONSP (Vunread_command_events))
@@ -2730,7 +2751,14 @@ read_char (int commandflag, Lisp_Object map,
       if (CONSP (c) && EQ (XCAR (c), Qt))
        c = XCDR (c);
       else
-       reread = true;
+       {
+         if (CONSP (c) && EQ (XCAR (c), Qno_record))
+           {
+             c = XCDR (c);
+             recorded = true;
+           }
+         reread = true;
+       }
     }
 
   /* Read something from current KBOARD's side queue, if possible.  */
@@ -2792,6 +2820,11 @@ read_char (int commandflag, Lisp_Object map,
 
       if (CONSP (c) && EQ (XCAR (c), Qt))
        c = XCDR (c);
+      else if (CONSP (c) && EQ (XCAR (c), Qno_record))
+       {
+         c = XCDR (c);
+         recorded = true;
+       }
   }
 
  non_reread:
@@ -3316,7 +3349,7 @@ save_getcjmp (sys_jmp_buf temp)
 }
 
 static void
-restore_getcjmp (sys_jmp_buf temp)
+restore_getcjmp (void *temp)
 {
   memcpy (getcjmp, temp, sizeof getcjmp);
 }
@@ -3854,14 +3887,15 @@ kbd_buffer_get_event (KBOARD **kbp,
        }
         break;
 
-#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
-    || defined (HAVE_NS) || defined (USE_GTK)
+#ifdef HAVE_EXT_MENU_BAR
       case MENU_BAR_ACTIVATE_EVENT:
        {
+          struct frame *f;
          kbd_fetch_ptr = next_kbd_event (event);
          input_pending = readable_events (0);
-         if (FRAME_LIVE_P (XFRAME (event->ie.frame_or_window)))
-           x_activate_menubar (XFRAME (event->ie.frame_or_window));
+          f = (XFRAME (event->ie.frame_or_window));
+         if (FRAME_LIVE_P (f) && FRAME_TERMINAL (f)->activate_menubar_hook)
+           FRAME_TERMINAL (f)->activate_menubar_hook (f);
        }
         break;
 #endif
@@ -3935,8 +3969,7 @@ kbd_buffer_get_event (KBOARD **kbp,
            {
              obj = make_lispy_event (&event->ie);
 
-#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
-    || defined (HAVE_NS) || defined (USE_GTK)
+#ifdef HAVE_EXT_MENU_BAR
              /* If this was a menu selection, then set the flag to inhibit
                 writing to last_nonmenu_event.  Don't do this if the event
                 we're returning is (menu-bar), though; that indicates the
@@ -5217,7 +5250,7 @@ make_lispy_position (struct frame *f, Lisp_Object x, 
Lisp_Object y,
 static bool
 toolkit_menubar_in_use (struct frame *f)
 {
-#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) || 
defined (HAVE_NTGUI)
+#ifdef HAVE_EXT_MENU_BAR
   return !(!FRAME_WINDOW_P (f));
 #else
   return false;
@@ -5575,7 +5608,7 @@ make_lispy_event (struct input_event *event)
             double-click-fuzz as is.  On other frames, interpret it
             as a multiple of 1/8 characters.  */
          struct frame *f;
-         int fuzz;
+         intmax_t fuzz;
 
          if (WINDOWP (event->frame_or_window))
            f = XFRAME (XWINDOW (event->frame_or_window)->frame);
@@ -5618,7 +5651,7 @@ make_lispy_event (struct input_event *event)
              double_click_count = 1;
            button_down_time = event->timestamp;
            *start_pos_ptr = Fcopy_alist (position);
-           ignore_mouse_drag_p = 0;
+           ignore_mouse_drag_p = false;
          }
 
        /* Now we're releasing a button - check the co-ordinates to
@@ -5634,11 +5667,14 @@ make_lispy_event (struct input_event *event)
            if (!CONSP (start_pos))
              return Qnil;
 
-           event->modifiers &= ~up_modifier;
+           unsigned click_or_drag_modifier = click_modifier;
 
+           if (ignore_mouse_drag_p)
+             ignore_mouse_drag_p = false;
+           else
              {
                Lisp_Object new_down, down;
-               EMACS_INT xdiff = double_click_fuzz, ydiff = double_click_fuzz;
+               intmax_t xdiff = double_click_fuzz, ydiff = double_click_fuzz;
 
                /* The third element of every position
                   should be the (x,y) pair.  */
@@ -5652,39 +5688,37 @@ make_lispy_event (struct input_event *event)
                    ydiff = XFIXNUM (XCDR (new_down)) - XFIXNUM (XCDR (down));
                  }
 
-               if (ignore_mouse_drag_p)
-                 {
-                   event->modifiers |= click_modifier;
-                   ignore_mouse_drag_p = 0;
-                 }
-               else if (xdiff < double_click_fuzz && xdiff > - 
double_click_fuzz
-                        && ydiff < double_click_fuzz && ydiff > - 
double_click_fuzz
-                 /* Maybe the mouse has moved a lot, caused scrolling, and
-                    eventually ended up at the same screen position (but
-                    not buffer position) in which case it is a drag, not
-                    a click.  */
-                   /* FIXME: OTOH if the buffer position has changed
-                      because of a timer or process filter rather than
-                      because of mouse movement, it should be considered as
-                      a click.  But mouse-drag-region completely ignores
-                      this case and it hasn't caused any real problem, so
-                      it's probably OK to ignore it as well.  */
-                   && EQ (Fcar (Fcdr (start_pos)), Fcar (Fcdr (position))))
-                 /* Mouse hasn't moved (much).  */
-                 event->modifiers |= click_modifier;
-               else
+               if (! (0 < double_click_fuzz
+                      && - double_click_fuzz < xdiff
+                      && xdiff < double_click_fuzz
+                      && - double_click_fuzz < ydiff
+                      && ydiff < double_click_fuzz
+                      /* Maybe the mouse has moved a lot, caused scrolling, and
+                         eventually ended up at the same screen position (but
+                         not buffer position) in which case it is a drag, not
+                         a click.  */
+                      /* FIXME: OTOH if the buffer position has changed
+                         because of a timer or process filter rather than
+                         because of mouse movement, it should be considered as
+                         a click.  But mouse-drag-region completely ignores
+                         this case and it hasn't caused any real problem, so
+                         it's probably OK to ignore it as well.  */
+                      && EQ (Fcar (Fcdr (start_pos)), Fcar (Fcdr (position)))))
                  {
+                   /* Mouse has moved enough.  */
                    button_down_time = 0;
-                   event->modifiers |= drag_modifier;
+                   click_or_drag_modifier = drag_modifier;
                  }
-
-               /* Don't check is_double; treat this as multiple
-                  if the down-event was multiple.  */
-               if (double_click_count > 1)
-                 event->modifiers |= ((double_click_count > 2)
-                                      ? triple_modifier
-                                      : double_modifier);
              }
+
+           /* Don't check is_double; treat this as multiple if the
+              down-event was multiple.  */
+           event->modifiers
+             = ((event->modifiers & ~up_modifier)
+                | click_or_drag_modifier
+                | (double_click_count < 2 ? 0
+                   : double_click_count == 2 ? double_modifier
+                   : triple_modifier));
          }
        else
          /* Every mouse event should either have the down_modifier or
@@ -5733,7 +5767,7 @@ make_lispy_event (struct input_event *event)
             double-click-fuzz as is.  On other frames, interpret it
             as a multiple of 1/8 characters.  */
          struct frame *fr;
-         int fuzz;
+         intmax_t fuzz;
          int symbol_num;
          bool is_double;
 
@@ -5909,8 +5943,7 @@ make_lispy_event (struct input_event *event)
        return list3 (head, position, files);
       }
 
-#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
-    || defined (HAVE_NS) || defined (USE_GTK)
+#ifdef HAVE_EXT_MENU_BAR
     case MENU_BAR_EVENT:
       if (EQ (event->arg, event->frame_or_window))
        /* This is the prefix key.  We translate this to
@@ -6159,7 +6192,7 @@ parse_modifiers_uncached (Lisp_Object symbol, ptrdiff_t 
*modifier_end)
 static Lisp_Object
 apply_modifiers_uncached (int modifiers, char *base, int base_len, int 
base_len_byte)
 {
-  /* Since BASE could contain nulls, we can't use intern here; we have
+  /* Since BASE could contain NULs, we can't use intern here; we have
      to use Fintern, which expects a genuine Lisp_String, and keeps a
      reference to it.  */
   char new_mods[sizeof "A-C-H-M-S-s-up-down-drag-double-triple-"];
@@ -6477,7 +6510,7 @@ modify_event_symbol (ptrdiff_t symbol_num, int modifiers, 
Lisp_Object symbol_kin
 #ifdef HAVE_WINDOW_SYSTEM
       if (NILP (value))
        {
-         char *name = x_get_keysym_name (symbol_num);
+         char *name = get_keysym_name (symbol_num);
          if (name)
            value = intern (name);
        }
@@ -8120,7 +8153,7 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
       if (menu_separator_name_p (SSDATA (caption)))
        {
          set_prop (TOOL_BAR_ITEM_TYPE, Qt);
-#if !defined (USE_GTK) && !defined (HAVE_NS)
+#ifndef HAVE_EXT_TOOL_BAR
          /* If we use build_desired_tool_bar_string to render the
             tool bar, the separator is rendered as an image.  */
          set_prop (TOOL_BAR_ITEM_IMAGES,
@@ -10977,6 +11010,8 @@ static const struct event_head head_table[] = {
   {SYMBOL_INDEX (Qselect_window),       SYMBOL_INDEX (Qswitch_frame)}
 };
 
+static void syms_of_keyboard_for_pdumper (void);
+
 void
 syms_of_keyboard (void)
 {
@@ -10987,9 +11022,11 @@ syms_of_keyboard (void)
   staticpro (&Vlispy_mouse_stem);
 
   regular_top_level_message = build_pure_c_string ("Back to top level");
+  staticpro (&regular_top_level_message);
 #ifdef HAVE_STACK_OVERFLOW_HANDLING
   recover_top_level_message
     = build_pure_c_string ("Re-entering top level after C stack overflow");
+  staticpro (&recover_top_level_message);
 #endif
   DEFVAR_LISP ("internal--top-level-message", Vinternal__top_level_message,
               doc: /* Message displayed by `normal-top-level'.  */);
@@ -11176,6 +11213,7 @@ syms_of_keyboard (void)
        Fput (var, Qevent_symbol_elements, list1 (var));
       }
   }
+  DEFSYM (Qno_record, "no-record");
 
   button_down_location = make_nil_vector (5);
   staticpro (&button_down_location);
@@ -11286,7 +11324,9 @@ so that you can determine whether the command was run 
by mouse or not.  */);
 These events are processed first, before actual keyboard input.
 Events read from this list are not normally added to `this-command-keys',
 as they will already have been added once as they were read for the first time.
-An element of the form (t . EVENT) forces EVENT to be added to that list.  */);
+An element of the form (t . EVENT) forces EVENT to be added to that list.
+An element of the form (no-record . EVENT) means process EVENT, but do not
+record it in the keyboard macros, recent-keys, and the dribble file.  */);
   Vunread_command_events = Qnil;
 
   DEFVAR_LISP ("unread-post-input-method-events", 
Vunread_post_input_method_events,
@@ -11828,13 +11868,9 @@ preserve data in modified buffers that would otherwise 
be lost.
 If nil, Emacs crashes immediately in response to fatal signals.  */);
   attempt_orderly_shutdown_on_fatal_signal = true;
 
-  /* Create the initial keyboard.  Qt means 'unset'.  */
-  initial_kboard = allocate_kboard (Qt);
-
   DEFVAR_LISP ("while-no-input-ignore-events",
                Vwhile_no_input_ignore_events,
                doc: /* Ignored events from while-no-input.  */);
-  Vwhile_no_input_ignore_events = Qnil;
 
   DEFVAR_BOOL ("inhibit--record-char",
               inhibit_record_char,
@@ -11842,6 +11878,43 @@ If nil, Emacs crashes immediately in response to fatal 
signals.  */);
 This inhibits recording input events for the purposes of keyboard
 macros, dribble file, and `recent-keys'.
 Internal use only.  */);
+
+  pdumper_do_now_and_after_load (syms_of_keyboard_for_pdumper);
+}
+
+static void
+syms_of_keyboard_for_pdumper (void)
+{
+  /* Make sure input state is pristine when restoring from a dump.
+     init_keyboard() also resets some of these, but the duplication
+     doesn't hurt and makes sure that allocate_kboard and subsequent
+     early init functions see the environment they expect.  */
+
+  PDUMPER_RESET_LV (pending_funcalls, Qnil);
+  PDUMPER_RESET_LV (unread_switch_frame, Qnil);
+  PDUMPER_RESET_LV (internal_last_event_frame, Qnil);
+  PDUMPER_RESET_LV (last_command_event, Qnil);
+  PDUMPER_RESET_LV (last_nonmenu_event, Qnil);
+  PDUMPER_RESET_LV (last_input_event, Qnil);
+  PDUMPER_RESET_LV (Vunread_command_events, Qnil);
+  PDUMPER_RESET_LV (Vunread_post_input_method_events, Qnil);
+  PDUMPER_RESET_LV (Vunread_input_method_events, Qnil);
+  PDUMPER_RESET_LV (Vthis_command, Qnil);
+  PDUMPER_RESET_LV (Vreal_this_command, Qnil);
+  PDUMPER_RESET_LV (Vthis_command_keys_shift_translated, Qnil);
+  PDUMPER_RESET_LV (Vthis_original_command, Qnil);
+  PDUMPER_RESET (num_input_keys, 0);
+  PDUMPER_RESET (num_nonmacro_input_events, 0);
+  PDUMPER_RESET_LV (Vlast_event_frame, Qnil);
+  PDUMPER_RESET_LV (Vdeferred_action_list, Qnil);
+  PDUMPER_RESET_LV (Vdelayed_warnings_list, Qnil);
+
+  /* Create the initial keyboard.  Qt means 'unset'.  */
+  eassert (initial_kboard == NULL);
+  initial_kboard = allocate_kboard (Qt);
+
+  Vwhile_no_input_ignore_events = Qnil;
+
   inhibit_record_char = false;
 }
 
@@ -11940,8 +12013,8 @@ mark_kboards (void)
   for (kb = all_kboards; kb; kb = kb->next_kboard)
     {
       if (kb->kbd_macro_buffer)
-       for (p = kb->kbd_macro_buffer; p < kb->kbd_macro_ptr; p++)
-         mark_object (*p);
+        for (p = kb->kbd_macro_buffer; p < kb->kbd_macro_ptr; p++)
+          mark_object (*p);
       mark_object (KVAR (kb, Voverriding_terminal_local_map));
       mark_object (KVAR (kb, Vlast_command));
       mark_object (KVAR (kb, Vreal_last_command));
diff --git a/src/keyboard.h b/src/keyboard.h
index ce4630b..65c7402 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -1,5 +1,5 @@
 /* Declarations useful when processing input.
-   Copyright (C) 1985-1987, 1993, 2001-2018 Free Software Foundation,
+   Copyright (C) 1985-1987, 1993, 2001-2019 Free Software Foundation,
    Inc.
 
 This file is part of GNU Emacs.
@@ -327,9 +327,9 @@ extern Lisp_Object item_properties;
    takes care of protecting all the data from GC.  */
 extern Lisp_Object menu_items;
 
-/* If non-nil, means that the global vars defined here are already in use.
+/* Whether the global vars defined here are already in use.
    Used to detect cases where we try to re-enter this non-reentrant code.  */
-extern Lisp_Object menu_items_inuse;
+extern bool menu_items_inuse;
 
 /* Number of slots currently allocated in menu_items.  */
 extern int menu_items_allocated;
diff --git a/src/keymap.c b/src/keymap.c
index a1c9eb6..2ac3d33 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1,5 +1,5 @@
 /* Manipulation of keymaps
-   Copyright (C) 1985-1988, 1993-1995, 1998-2018 Free Software
+   Copyright (C) 1985-1988, 1993-1995, 1998-2019 Free Software
    Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -120,11 +120,7 @@ The optional arg STRING supplies a menu name for the keymap
 in case you use it as a menu with `x-popup-menu'.  */)
   (Lisp_Object string)
 {
-  Lisp_Object tail;
-  if (!NILP (string))
-    tail = list1 (string);
-  else
-    tail = Qnil;
+  Lisp_Object tail = !NILP (string) ? list1 (string) : Qnil;
   return Fcons (Qkeymap,
                Fcons (Fmake_char_table (Qkeymap, Qnil), tail));
 }
@@ -2042,7 +2038,7 @@ For an approximate inverse of this, see `kbd'.  */)
   else if (VECTORP (list))
     size = ASIZE (list);
   else if (CONSP (list))
-    size = XFIXNUM (Flength (list));
+    size = list_length (list);
   else
     wrong_type_argument (Qarrayp, list);
 
@@ -3608,12 +3604,12 @@ syms_of_keymap (void)
   Fset (intern_c_string ("ctl-x-map"), control_x_map);
   Ffset (intern_c_string ("Control-X-prefix"), control_x_map);
 
-  exclude_keys = listn (CONSTYPE_PURE, 5,
-                       pure_cons (build_pure_c_string ("DEL"), 
build_pure_c_string ("\\d")),
-                       pure_cons (build_pure_c_string ("TAB"), 
build_pure_c_string ("\\t")),
-                       pure_cons (build_pure_c_string ("RET"), 
build_pure_c_string ("\\r")),
-                       pure_cons (build_pure_c_string ("ESC"), 
build_pure_c_string ("\\e")),
-                       pure_cons (build_pure_c_string ("SPC"), 
build_pure_c_string (" ")));
+  exclude_keys = pure_list
+    (pure_cons (build_pure_c_string ("DEL"), build_pure_c_string ("\\d")),
+     pure_cons (build_pure_c_string ("TAB"), build_pure_c_string ("\\t")),
+     pure_cons (build_pure_c_string ("RET"), build_pure_c_string ("\\r")),
+     pure_cons (build_pure_c_string ("ESC"), build_pure_c_string ("\\e")),
+     pure_cons (build_pure_c_string ("SPC"), build_pure_c_string (" ")));
   staticpro (&exclude_keys);
 
   DEFVAR_LISP ("define-key-rebound-commands", Vdefine_key_rebound_commands,
@@ -3669,16 +3665,12 @@ be preferred.  */);
   DEFSYM (Qmode_line, "mode-line");
 
   staticpro (&Vmouse_events);
-  Vmouse_events = listn (CONSTYPE_PURE, 9,
-                        Qmenu_bar,
-                        Qtool_bar,
-                        Qheader_line,
-                        Qmode_line,
-                        intern_c_string ("mouse-1"),
-                        intern_c_string ("mouse-2"),
-                        intern_c_string ("mouse-3"),
-                        intern_c_string ("mouse-4"),
-                        intern_c_string ("mouse-5"));
+  Vmouse_events = pure_list (Qmenu_bar, Qtool_bar, Qheader_line, Qmode_line,
+                            intern_c_string ("mouse-1"),
+                            intern_c_string ("mouse-2"),
+                            intern_c_string ("mouse-3"),
+                            intern_c_string ("mouse-4"),
+                            intern_c_string ("mouse-5"));
 
   /* Keymap used for minibuffers when doing completion.  */
   /* Keymap used for minibuffers when doing completion and require a match.  */
diff --git a/src/keymap.h b/src/keymap.h
index 8389220..e29145f 100644
--- a/src/keymap.h
+++ b/src/keymap.h
@@ -1,5 +1,5 @@
 /* Functions to manipulate keymaps.
-   Copyright (C) 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/kqueue.c b/src/kqueue.c
index bc01ab5..42391f8 100644
--- a/src/kqueue.c
+++ b/src/kqueue.c
@@ -1,6 +1,6 @@
 /* Filesystem notifications support with kqueue API.
 
-Copyright (C) 2015-2018 Free Software Foundation, Inc.
+Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -19,7 +19,6 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 
-#ifdef HAVE_KQUEUE
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/event.h>
@@ -99,7 +98,7 @@ kqueue_generate_event (Lisp_Object watch_object, Lisp_Object 
actions,
     event.arg = list2 (Fcons (XCAR (watch_object),
                              Fcons (actions,
                                     NILP (file1)
-                                    ? Fcons (file, Qnil)
+                                    ? list1 (file)
                                     : list2 (file, file1))),
                       Fnth (make_fixnum (3), watch_object));
     kbd_buffer_store_event (&event);
@@ -395,11 +394,12 @@ only when the upper directory of the renamed file is 
watched.  */)
     maxfd = 256;
 
   /* We assume 50 file descriptors are sufficient for the rest of Emacs.  */
-  if ((maxfd - 50) < XFIXNUM (Flength (watch_list)))
+  ptrdiff_t watch_list_len = list_length (watch_list);
+  if (maxfd - 50 < watch_list_len)
     xsignal2
       (Qfile_notify_error,
        build_string ("File watching not possible, no file descriptor left"),
-       Flength (watch_list));
+       make_fixnum (watch_list_len));
 
   if (kqueuefd < 0)
     {
@@ -532,8 +532,6 @@ syms_of_kqueue (void)
   Fprovide (intern_c_string ("kqueue"), Qnil);
 }
 
-#endif /* HAVE_KQUEUE  */
-
 /* PROBLEMS
    * https://bugs.launchpad.net/ubuntu/+source/libkqueue/+bug/1514837
      prevents tests on Ubuntu.  */
diff --git a/src/lastfile.c b/src/lastfile.c
index ec53111..bcaf105 100644
--- a/src/lastfile.c
+++ b/src/lastfile.c
@@ -1,5 +1,5 @@
 /* Mark end of data space to dump as pure, for GNU Emacs.
-   Copyright (C) 1985, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1985, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -43,7 +43,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 char my_edata[] = "End of Emacs initialized data";
 #endif
 
-#ifndef CANNOT_DUMP
+#ifdef HAVE_UNEXEC
 
 /* Help unexec locate the end of the .bss area used by Emacs (which
    isn't always a separate section in NT executables).  */
diff --git a/src/lcms.c b/src/lcms.c
index d5cfafa..cd8de0e 100644
--- a/src/lcms.c
+++ b/src/lcms.c
@@ -1,5 +1,5 @@
 /* Interface to Little CMS
-   Copyright (C) 2017-2018 Free Software Foundation, Inc.
+   Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/lisp.h b/src/lisp.h
index 3943bf6..ca83347 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1,6 +1,6 @@
 /* Fundamental definitions for GNU Emacs Lisp interpreter. -*- coding: utf-8 
-*-
 
-Copyright (C) 1985-1987, 1993-1995, 1997-2018 Free Software Foundation,
+Copyright (C) 1985-1987, 1993-1995, 1997-2019 Free Software Foundation,
 Inc.
 
 This file is part of GNU Emacs.
@@ -166,6 +166,9 @@ typedef EMACS_UINT uprintmax_t;
 # define pD "t"
 #endif
 
+/* Convenience macro for rarely-used functions that do not return.  */
+#define AVOID _Noreturn ATTRIBUTE_COLD void
+
 /* Extra internal type checking?  */
 
 /* Define Emacs versions of <assert.h>'s 'assert (COND)' and <verify.h>'s
@@ -196,7 +199,7 @@ typedef EMACS_UINT uprintmax_t;
 # define eassume(cond) assume (cond)
 #else /* ENABLE_CHECKING */
 
-extern _Noreturn void die (const char *, const char *, int);
+extern AVOID die (const char *, const char *, int);
 
 extern bool suppress_checking EXTERNALLY_VISIBLE;
 
@@ -410,27 +413,11 @@ typedef EMACS_INT Lisp_Word;
 #define lisp_h_XCONS(a) \
    (eassert (CONSP (a)), XUNTAG (a, Lisp_Cons, struct Lisp_Cons))
 #define lisp_h_XHASH(a) XUFIXNUM (a)
-#ifndef GC_CHECK_CONS_LIST
-# define lisp_h_check_cons_list() ((void) 0)
-#endif
 #if USE_LSB_TAG
 # define lisp_h_make_fixnum(n) \
     XIL ((EMACS_INT) (((EMACS_UINT) (n) << INTTYPEBITS) + Lisp_Int0))
 # define lisp_h_XFIXNAT(a) XFIXNUM (a)
 # define lisp_h_XFIXNUM(a) (XLI (a) >> INTTYPEBITS)
-# ifdef __CHKP__
-#  define lisp_h_XSYMBOL(a) \
-    (eassert (SYMBOLP (a)), \
-     (struct Lisp_Symbol *) ((char *) XUNTAG (a, Lisp_Symbol, \
-                                             struct Lisp_Symbol) \
-                            + (intptr_t) lispsym))
-# else
-   /* If !__CHKP__ this is equivalent, and is a bit faster as of GCC 7.  */
-#  define lisp_h_XSYMBOL(a) \
-    (eassert (SYMBOLP (a)), \
-     (struct Lisp_Symbol *) ((intptr_t) XLI (a) - Lisp_Symbol \
-                            + (char *) lispsym))
-# endif
 # define lisp_h_XTYPE(a) ((enum Lisp_Type) (XLI (a) & ~VALMASK))
 #endif
 
@@ -469,14 +456,10 @@ typedef EMACS_INT Lisp_Word;
 # define XCDR(c) lisp_h_XCDR (c)
 # define XCONS(a) lisp_h_XCONS (a)
 # define XHASH(a) lisp_h_XHASH (a)
-# ifndef GC_CHECK_CONS_LIST
-#  define check_cons_list() lisp_h_check_cons_list ()
-# endif
 # if USE_LSB_TAG
 #  define make_fixnum(n) lisp_h_make_fixnum (n)
 #  define XFIXNAT(a) lisp_h_XFIXNAT (a)
 #  define XFIXNUM(a) lisp_h_XFIXNUM (a)
-#  define XSYMBOL(a) lisp_h_XSYMBOL (a)
 #  define XTYPE(a) lisp_h_XTYPE (a)
 # endif
 #endif
@@ -527,6 +510,7 @@ enum Lisp_Type
     /* Cons.  XCONS (object) points to a struct Lisp_Cons.  */
     Lisp_Cons = USE_LSB_TAG ? 3 : 6,
 
+    /* Must be last entry in Lisp_Type enumeration.  */
     Lisp_Float = 7
   };
 
@@ -620,19 +604,114 @@ extern Lisp_Object char_table_ref (Lisp_Object, int);
 extern void char_table_set (Lisp_Object, int, Lisp_Object);
 
 /* Defined in data.c.  */
-extern _Noreturn void wrong_type_argument (Lisp_Object, Lisp_Object);
+extern AVOID wrong_type_argument (Lisp_Object, Lisp_Object);
 
 
-#ifdef CANNOT_DUMP
-enum { might_dump = false };
-#elif defined DOUG_LEA_MALLOC
 /* Defined in emacs.c.  */
-extern bool might_dump;
-#endif
-/* True means Emacs has already been initialized.
-   Used during startup to detect startup of dumped Emacs.  */
+
+/* Set after Emacs has started up the first time.
+   Prevents reinitialization of the Lisp world and keymaps on
+   subsequent starts.  */
 extern bool initialized;
 
+extern struct gflags
+{
+  /* True means this Emacs instance was born to dump.  */
+#if defined HAVE_PDUMPER || defined HAVE_UNEXEC
+  bool will_dump_ : 1;
+  bool will_bootstrap_ : 1;
+#endif
+#ifdef HAVE_PDUMPER
+  /* Set in an Emacs process that will likely dump with pdumper; all
+     Emacs processes may dump with pdumper, however.  */
+  bool will_dump_with_pdumper_ : 1;
+  /* Set in an Emacs process that has been restored from a portable
+     dump.  */
+  bool dumped_with_pdumper_ : 1;
+#endif
+#ifdef HAVE_UNEXEC
+  bool will_dump_with_unexec_ : 1;
+  /* Set in an Emacs process that has been restored from an unexec
+     dump.  */
+  bool dumped_with_unexec_ : 1;
+  /* We promise not to unexec: useful for hybrid malloc.  */
+  bool will_not_unexec_ : 1;
+#endif
+} gflags;
+
+INLINE bool
+will_dump_p (void)
+{
+#if HAVE_PDUMPER || defined HAVE_UNEXEC
+  return gflags.will_dump_;
+#else
+  return false;
+#endif
+}
+
+INLINE bool
+will_bootstrap_p (void)
+{
+#if HAVE_PDUMPER || defined HAVE_UNEXEC
+  return gflags.will_bootstrap_;
+#else
+  return false;
+#endif
+}
+
+INLINE bool
+will_dump_with_pdumper_p (void)
+{
+#if HAVE_PDUMPER
+  return gflags.will_dump_with_pdumper_;
+#else
+  return false;
+#endif
+}
+
+INLINE bool
+dumped_with_pdumper_p (void)
+{
+#if HAVE_PDUMPER
+  return gflags.dumped_with_pdumper_;
+#else
+  return false;
+#endif
+}
+
+INLINE bool
+will_dump_with_unexec_p (void)
+{
+#ifdef HAVE_UNEXEC
+  return gflags.will_dump_with_unexec_;
+#else
+  return false;
+#endif
+}
+
+INLINE bool
+dumped_with_unexec_p (void)
+{
+#ifdef HAVE_UNEXEC
+  return gflags.dumped_with_unexec_;
+#else
+  return false;
+#endif
+}
+
+/* This function is the opposite of will_dump_with_unexec_p(), except
+   that it returns false before main runs.  It's important to use
+   gmalloc for any pre-main allocations if we're going to unexec.  */
+INLINE bool
+definitely_will_not_unexec_p (void)
+{
+#ifdef HAVE_UNEXEC
+  return gflags.will_not_unexec_;
+#else
+  return true;
+#endif
+}
+
 /* Defined in floatfns.c.  */
 extern double extract_float (Lisp_Object);
 
@@ -701,6 +780,13 @@ INLINE void
 
 #define XUNTAG(a, type, ctype) ((ctype *) \
                                ((char *) XLP (a) - LISP_WORD_TAG (type)))
+
+/* A forwarding pointer to a value.  It uses a generic pointer to
+   avoid alignment bugs that could occur if it used a pointer to a
+   union of the possible values (struct Lisp_Objfwd, struct
+   Lisp_Intfwd, etc.).  The pointer is packaged inside a struct to
+   help static checking.  */
+typedef struct { void const *fwdptr; } lispfwd;
 
 /* Interned state of a symbol.  */
 
@@ -766,7 +852,7 @@ struct Lisp_Symbol
        Lisp_Object value;
        struct Lisp_Symbol *alias;
        struct Lisp_Buffer_Local_Value *blv;
-       union Lisp_Fwd *fwd;
+       lispfwd fwd;
       } val;
 
       /* Function value of the symbol or Qnil if not fboundp.  */
@@ -862,6 +948,19 @@ typedef EMACS_UINT Lisp_Word_tag;
 # define DEFINE_NON_NIL_Q_SYMBOL_MACROS true
 #endif
 
+/* True if N is a power of 2.  N should be positive.  */
+
+#define POWER_OF_2(n) (((n) & ((n) - 1)) == 0)
+
+/* Return X rounded to the next multiple of Y.  Y should be positive,
+   and Y - 1 + X should not overflow.  Arguments should not have side
+   effects, as they are evaluated more than once.  Tune for Y being a
+   power of 2.  */
+
+#define ROUNDUP(x, y) (POWER_OF_2 (y)                                  \
+                       ? ((y) - 1 + (x)) & ~ ((y) - 1)                 \
+                       : ((y) - 1 + (x)) - ((y) - 1 + (x)) % (y))
+
 #include "globals.h"
 
 /* Header of vector-like objects.  This documents the layout constraints on
@@ -904,21 +1003,17 @@ INLINE bool
 }
 
 INLINE struct Lisp_Symbol * ATTRIBUTE_NO_SANITIZE_UNDEFINED
-(XSYMBOL) (Lisp_Object a)
+XSYMBOL (Lisp_Object a)
 {
-#if USE_LSB_TAG
-  return lisp_h_XSYMBOL (a);
-#else
   eassert (SYMBOLP (a));
   intptr_t i = (intptr_t) XUNTAG (a, Lisp_Symbol, struct Lisp_Symbol);
   void *p = (char *) lispsym + i;
-# ifdef __CHKP__
+#ifdef __CHKP__
   /* Bypass pointer checking.  Although this could be improved it is
      probably not worth the trouble.  */
   p = __builtin___bnd_set_ptr_bounds (p, sizeof (struct Lisp_Symbol));
-# endif
-  return p;
 #endif
+  return p;
 }
 
 INLINE Lisp_Object
@@ -978,9 +1073,7 @@ enum pvec_type
   PVEC_OVERLAY,
   PVEC_FINALIZER,
   PVEC_MISC_PTR,
-#ifdef HAVE_MODULES
   PVEC_USER_PTR,
-#endif
   PVEC_PROCESS,
   PVEC_FRAME,
   PVEC_WINDOW,
@@ -1152,8 +1245,8 @@ INLINE bool
 #define FIXNUM_OVERFLOW_P(i) \
   (! ((0 <= (i) || MOST_NEGATIVE_FIXNUM <= (i)) && (i) <= 
MOST_POSITIVE_FIXNUM))
 
-INLINE ptrdiff_t
-clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper)
+INLINE intmax_t
+clip_to_bounds (intmax_t lower, intmax_t num, intmax_t upper)
 {
   return num < lower ? lower : num <= upper ? num : upper;
 }
@@ -1186,11 +1279,11 @@ INLINE bool
 
 #define XSETPVECTYPE(v, code)                                          \
   ((v)->header.size |= PSEUDOVECTOR_FLAG | ((code) << PSEUDOVECTOR_AREA_BITS))
+#define PVECHEADERSIZE(code, lispsize, restsize) \
+  (PSEUDOVECTOR_FLAG | ((code) << PSEUDOVECTOR_AREA_BITS) \
+   | ((restsize) << PSEUDOVECTOR_SIZE_BITS) | (lispsize))
 #define XSETPVECTYPESIZE(v, code, lispsize, restsize)          \
-  ((v)->header.size = (PSEUDOVECTOR_FLAG                       \
-                      | ((code) << PSEUDOVECTOR_AREA_BITS)     \
-                      | ((restsize) << PSEUDOVECTOR_SIZE_BITS) \
-                      | (lispsize)))
+  ((v)->header.size = PVECHEADERSIZE (code, lispsize, restsize))
 
 /* The cast to union vectorlike_header * avoids aliasing issues.  */
 #define XSETPSEUDOVECTOR(a, b, code) \
@@ -1421,11 +1514,11 @@ STRING_MULTIBYTE (Lisp_Object str)
 }
 
 /* An upper bound on the number of bytes in a Lisp string, not
-   counting the terminating null.  This a tight enough bound to
+   counting the terminating NUL.  This a tight enough bound to
    prevent integer overflow errors that would otherwise occur during
    string size calculations.  A string cannot contain more bytes than
    a fixnum can represent, nor can it be so long that C pointer
-   arithmetic stops working on the string plus its terminating null.
+   arithmetic stops working on the string plus its terminating NUL.
    Although the actual size limit (see STRING_BYTES_MAX in alloc.c)
    may be a bit smaller than STRING_BYTES_BOUND, calculating it here
    would expose alloc.c internal details that we'd rather keep
@@ -1568,7 +1661,7 @@ CHECK_VECTOR (Lisp_Object x)
 /* A pseudovector is like a vector, but has other non-Lisp components.  */
 
 INLINE enum pvec_type
-PSEUDOVECTOR_TYPE (struct Lisp_Vector *v)
+PSEUDOVECTOR_TYPE (const struct Lisp_Vector *v)
 {
   ptrdiff_t size = v->header.size;
   return (size & PSEUDOVECTOR_FLAG
@@ -1578,7 +1671,7 @@ PSEUDOVECTOR_TYPE (struct Lisp_Vector *v)
 
 /* Can't be used with PVEC_NORMAL_VECTOR.  */
 INLINE bool
-PSEUDOVECTOR_TYPEP (union vectorlike_header *a, enum pvec_type code)
+PSEUDOVECTOR_TYPEP (const union vectorlike_header *a, enum pvec_type code)
 {
   /* We don't use PSEUDOVECTOR_TYPE here so as to avoid a shift
    * operation when `code' is known.  */
@@ -1788,9 +1881,9 @@ memclear (void *p, ptrdiff_t nbytes)
    at the end and we need to compute the number of Lisp_Object fields (the
    ones that the GC needs to trace).  */
 
-#define PSEUDOVECSIZE(type, nonlispfield)                      \
-   (offsetof (type, nonlispfield) < header_size                        \
-    ? 0 : (offsetof (type, nonlispfield) - header_size) / word_size)
+#define PSEUDOVECSIZE(type, lastlispfield)                             \
+  (offsetof (type, lastlispfield) + word_size < header_size            \
+   ? 0 : (offsetof (type, lastlispfield) + word_size - header_size) / 
word_size)
 
 /* Compute A OP B, using the unsigned comparison operator OP.  A and B
    should be integer expressions.  This is not the same as
@@ -1993,11 +2086,14 @@ enum char_table_specials
     /* This is the number of slots that every char table must have.  This
        counts the ordinary slots and the top, defalt, parent, and purpose
        slots.  */
-    CHAR_TABLE_STANDARD_SLOTS = PSEUDOVECSIZE (struct Lisp_Char_Table, extras),
+    CHAR_TABLE_STANDARD_SLOTS
+      = (PSEUDOVECSIZE (struct Lisp_Char_Table, contents) - 1
+        + (1 << CHARTAB_SIZE_BITS_0)),
 
-    /* This is an index of first Lisp_Object field in Lisp_Sub_Char_Table
+    /* This is the index of the first Lisp_Object field in Lisp_Sub_Char_Table
        when the latter is treated as an ordinary Lisp_Vector.  */
-    SUB_CHAR_TABLE_OFFSET = PSEUDOVECSIZE (struct Lisp_Sub_Char_Table, 
contents)
+    SUB_CHAR_TABLE_OFFSET
+      = PSEUDOVECSIZE (struct Lisp_Sub_Char_Table, contents) - 1
   };
 
 /* Sanity-check pseudovector layout.  */
@@ -2062,10 +2158,10 @@ SYMBOL_BLV (struct Lisp_Symbol *sym)
   eassume (sym->u.s.redirect == SYMBOL_LOCALIZED && sym->u.s.val.blv);
   return sym->u.s.val.blv;
 }
-INLINE union Lisp_Fwd *
+INLINE lispfwd
 SYMBOL_FWD (struct Lisp_Symbol *sym)
 {
-  eassume (sym->u.s.redirect == SYMBOL_FORWARDED && sym->u.s.val.fwd);
+  eassume (sym->u.s.redirect == SYMBOL_FORWARDED && sym->u.s.val.fwd.fwdptr);
   return sym->u.s.val.fwd;
 }
 
@@ -2088,10 +2184,10 @@ SET_SYMBOL_BLV (struct Lisp_Symbol *sym, struct 
Lisp_Buffer_Local_Value *v)
   sym->u.s.val.blv = v;
 }
 INLINE void
-SET_SYMBOL_FWD (struct Lisp_Symbol *sym, union Lisp_Fwd *v)
+SET_SYMBOL_FWD (struct Lisp_Symbol *sym, void const *v)
 {
   eassume (sym->u.s.redirect == SYMBOL_FORWARDED && v);
-  sym->u.s.val.fwd = v;
+  sym->u.s.val.fwd.fwdptr = v;
 }
 
 INLINE Lisp_Object
@@ -2168,6 +2264,12 @@ struct hash_table_test
 
 struct Lisp_Hash_Table
 {
+  /* Change pdumper.c if you change the fields here.
+
+     IMPORTANT!!!!!!!
+
+     Call hash_rehash_if_needed() before accessing.  */
+
   /* This is for Lisp; the hash table code does not refer to it.  */
   union vectorlike_header header;
 
@@ -2191,8 +2293,8 @@ struct Lisp_Hash_Table
      hash table size to reduce collisions.  */
   Lisp_Object index;
 
-  /* Only the fields above are traced normally by the GC.  The ones below
-     `count' are special and are either ignored by the GC or traced in
+  /* Only the fields above are traced normally by the GC.  The ones after
+     'index' are special and are either ignored by the GC or traced in
      a special way (e.g. because of weakness).  */
 
   /* Number of key/value entries in the table.  */
@@ -2224,8 +2326,9 @@ struct Lisp_Hash_Table
   /* The comparison and hash functions.  */
   struct hash_table_test test;
 
-  /* Next weak hash table if this is a weak hash table.  The head
-     of the list is in weak_hash_tables.  */
+  /* Next weak hash table if this is a weak hash table.  The head of
+     the list is in weak_hash_tables.  Used only during garbage
+     collection --- at other times, it is NULL.  */
   struct Lisp_Hash_Table *next_weak;
 } GCALIGNED_STRUCT;
 
@@ -2250,32 +2353,47 @@ XHASH_TABLE (Lisp_Object a)
 
 /* Value is the key part of entry IDX in hash table H.  */
 INLINE Lisp_Object
-HASH_KEY (struct Lisp_Hash_Table *h, ptrdiff_t idx)
+HASH_KEY (const struct Lisp_Hash_Table *h, ptrdiff_t idx)
 {
   return AREF (h->key_and_value, 2 * idx);
 }
 
 /* Value is the value part of entry IDX in hash table H.  */
 INLINE Lisp_Object
-HASH_VALUE (struct Lisp_Hash_Table *h, ptrdiff_t idx)
+HASH_VALUE (const struct Lisp_Hash_Table *h, ptrdiff_t idx)
 {
   return AREF (h->key_and_value, 2 * idx + 1);
 }
 
 /* Value is the hash code computed for entry IDX in hash table H.  */
 INLINE Lisp_Object
-HASH_HASH (struct Lisp_Hash_Table *h, ptrdiff_t idx)
+HASH_HASH (const struct Lisp_Hash_Table *h, ptrdiff_t idx)
 {
   return AREF (h->hash, idx);
 }
 
 /* Value is the size of hash table H.  */
 INLINE ptrdiff_t
-HASH_TABLE_SIZE (struct Lisp_Hash_Table *h)
+HASH_TABLE_SIZE (const struct Lisp_Hash_Table *h)
 {
   return ASIZE (h->next);
 }
 
+void hash_table_rehash (struct Lisp_Hash_Table *h);
+
+INLINE bool
+hash_rehash_needed_p (const struct Lisp_Hash_Table *h)
+{
+  return h->count < 0;
+}
+
+INLINE void
+hash_rehash_if_needed (struct Lisp_Hash_Table *h)
+{
+  if (hash_rehash_needed_p (h))
+    hash_table_rehash (h);
+}
+
 /* Default size for hash tables if not specified.  */
 
 enum DEFAULT_HASH_SIZE { DEFAULT_HASH_SIZE = 65 };
@@ -2417,14 +2535,12 @@ xmint_pointer (Lisp_Object a)
   return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Misc_Ptr)->pointer;
 }
 
-#ifdef HAVE_MODULES
 struct Lisp_User_Ptr
 {
   union vectorlike_header header;
   void (*finalizer) (void *);
   void *p;
 } GCALIGNED_STRUCT;
-#endif
 
 /* A finalizer sentinel.  */
 struct Lisp_Finalizer
@@ -2441,6 +2557,9 @@ struct Lisp_Finalizer
     struct Lisp_Finalizer *next;
   } GCALIGNED_STRUCT;
 
+extern struct Lisp_Finalizer finalizers;
+extern struct Lisp_Finalizer doomed_finalizers;
+
 INLINE bool
 FINALIZERP (Lisp_Object x)
 {
@@ -2480,7 +2599,6 @@ XOVERLAY (Lisp_Object a)
   return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Overlay);
 }
 
-#ifdef HAVE_MODULES
 INLINE bool
 USER_PTRP (Lisp_Object x)
 {
@@ -2493,7 +2611,6 @@ XUSER_PTR (Lisp_Object a)
   eassert (USER_PTRP (a));
   return XUNTAG (a, Lisp_Vectorlike, struct Lisp_User_Ptr);
 }
-#endif
 
 INLINE bool
 BIGNUMP (Lisp_Object x)
@@ -2531,7 +2648,7 @@ make_uint (uintmax_t n)
 struct Lisp_Intfwd
   {
     enum Lisp_Fwd_Type type;   /* = Lisp_Fwd_Int */
-    EMACS_INT *intvar;
+    intmax_t *intvar;
   };
 
 /* Boolean forwarding pointer to an int variable.
@@ -2593,7 +2710,7 @@ struct Lisp_Buffer_Local_Value
        Presumably equivalent to (defcell!=valcell).  */
     bool_bf found : 1;
     /* If non-NULL, a forwarding to the C var where it should also be set.  */
-    union Lisp_Fwd *fwd;       /* Should never be (Buffer|Kboard)_Objfwd.  */
+    lispfwd fwd;       /* Should never be (Buffer|Kboard)_Objfwd.  */
     /* The buffer for which the loaded binding was found.  */
     Lisp_Object where;
     /* A cons cell that holds the default value.  It has the form
@@ -2615,32 +2732,24 @@ struct Lisp_Kboard_Objfwd
     int offset;
   };
 
-union Lisp_Fwd
-  {
-    struct Lisp_Intfwd u_intfwd;
-    struct Lisp_Boolfwd u_boolfwd;
-    struct Lisp_Objfwd u_objfwd;
-    struct Lisp_Buffer_Objfwd u_buffer_objfwd;
-    struct Lisp_Kboard_Objfwd u_kboard_objfwd;
-  };
-
 INLINE enum Lisp_Fwd_Type
-XFWDTYPE (union Lisp_Fwd *a)
+XFWDTYPE (lispfwd a)
 {
-  return a->u_intfwd.type;
+  enum Lisp_Fwd_Type const *p = a.fwdptr;
+  return *p;
 }
 
 INLINE bool
-BUFFER_OBJFWDP (union Lisp_Fwd *a)
+BUFFER_OBJFWDP (lispfwd a)
 {
   return XFWDTYPE (a) == Lisp_Fwd_Buffer_Obj;
 }
 
-INLINE struct Lisp_Buffer_Objfwd *
-XBUFFER_OBJFWD (union Lisp_Fwd *a)
+INLINE struct Lisp_Buffer_Objfwd const *
+XBUFFER_OBJFWD (lispfwd a)
 {
   eassert (BUFFER_OBJFWDP (a));
-  return &a->u_buffer_objfwd;
+  return a.fwdptr;
 }
 
 /* Lisp floating point type.  */
@@ -2683,13 +2792,6 @@ XFLOAT_DATA (Lisp_Object f)
 #define IEEE_FLOATING_POINT (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \
                             && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128)
 
-/* A character, declared with the following typedef, is a member
-   of some character set associated with the current buffer.  */
-#ifndef _UCHAR_T  /* Protect against something in ctab.h on AIX.  */
-#define _UCHAR_T
-typedef unsigned char UCHAR;
-#endif
-
 /* Meanings of slots in a Lisp_Compiled:  */
 
 enum Lisp_Compiled
@@ -2848,12 +2950,7 @@ CHECK_FIXNAT (Lisp_Object x)
   do {                                                                 \
     CHECK_FIXNUM (x);                                                  \
     if (! ((lo) <= XFIXNUM (x) && XFIXNUM (x) <= (hi)))                        
\
-      args_out_of_range_3                                              \
-       (x,                                                             \
-        make_fixnum ((lo) < 0 && (lo) < MOST_NEGATIVE_FIXNUM           \
-                     ? MOST_NEGATIVE_FIXNUM                            \
-                     : (lo)),                                          \
-        make_fixnum (min (hi, MOST_POSITIVE_FIXNUM)));                 \
+      args_out_of_range_3 (x, INT_TO_INTEGER (lo), INT_TO_INTEGER (hi)); \
   } while (false)
 #define CHECK_TYPE_RANGED_INTEGER(type, x) \
   do {                                                                 \
@@ -2906,28 +3003,24 @@ CHECK_INTEGER (Lisp_Object x)
     else                                                               \
       CHECK_TYPE (INTEGERP (x), Qnumber_or_marker_p, x);               \
   } while (false)
+
 
-/* Since we can't assign directly to the CAR or CDR fields of a cons
-   cell, use these when checking that those fields contain numbers.  */
-INLINE void
-CHECK_FIXNUM_CAR (Lisp_Object x)
-{
-  Lisp_Object tmp = XCAR (x);
-  CHECK_FIXNUM (tmp);
-  XSETCAR (x, tmp);
-}
+/* If we're not dumping using the legacy dumper and we might be using
+   the portable dumper, try to bunch all the subr structures together
+   for more efficient dump loading.  */
+#ifndef HAVE_UNEXEC
+# ifdef DARWIN_OS
+#  define SUBR_SECTION_ATTRIBUTE ATTRIBUTE_SECTION ("__DATA,subrs")
+# else
+#  define SUBR_SECTION_ATTRIBUTE ATTRIBUTE_SECTION (".subrs")
+# endif
+#else
+# define SUBR_SECTION_ATTRIBUTE
+#endif
 
-INLINE void
-CHECK_FIXNUM_CDR (Lisp_Object x)
-{
-  Lisp_Object tmp = XCDR (x);
-  CHECK_FIXNUM (tmp);
-  XSETCDR (x, tmp);
-}
-
 /* Define a built-in function for calling from Lisp.
  `lname' should be the name to give the function in Lisp,
-    as a null-terminated C string.
+    as a NUL-terminated C string.
  `fnname' should be the name of the function in C.
     By convention, it starts with F.
  `sname' should be the name for the C constant structure
@@ -2953,7 +3046,8 @@ CHECK_FIXNUM_CDR (Lisp_Object x)
 /* This version of DEFUN declares a function prototype with the right
    arguments, so we can catch errors with maxargs at compile-time.  */
 #define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc)    \
-   static union Aligned_Lisp_Subr sname =                              \
+  SUBR_SECTION_ATTRIBUTE                                                \
+  static union Aligned_Lisp_Subr sname =                                \
      {{{ PVEC_SUBR << PSEUDOVECTOR_AREA_BITS },                                
\
        { .a ## maxargs = fnname },                                     \
        minargs, maxargs, lname, intspec, 0}};                          \
@@ -2975,14 +3069,16 @@ enum maxargs
 /* Call a function F that accepts many args, passing it the remaining args,
    E.g., 'return CALLN (Fformat, fmt, text);' is less error-prone than
    '{ Lisp_Object a[2]; a[0] = fmt; a[1] = text; return Fformat (2, a); }'.
-   CALLN is overkill for simple usages like 'Finsert (1, &text);'.  */
+   CALLN requires at least one function argument (as C99 prohibits
+   empty initializers), and is overkill for simple usages like
+   'Finsert (1, &text);'.  */
 #define CALLN(f, ...) CALLMANY (f, ((Lisp_Object []) {__VA_ARGS__}))
 
-extern void defvar_lisp (struct Lisp_Objfwd *, const char *, Lisp_Object *);
-extern void defvar_lisp_nopro (struct Lisp_Objfwd *, const char *, Lisp_Object 
*);
-extern void defvar_bool (struct Lisp_Boolfwd *, const char *, bool *);
-extern void defvar_int (struct Lisp_Intfwd *, const char *, EMACS_INT *);
-extern void defvar_kboard (struct Lisp_Kboard_Objfwd *, const char *, int);
+extern void defvar_lisp (struct Lisp_Objfwd const *, char const *);
+extern void defvar_lisp_nopro (struct Lisp_Objfwd const *, char const *);
+extern void defvar_bool (struct Lisp_Boolfwd const *, char const *);
+extern void defvar_int (struct Lisp_Intfwd const *, char const *);
+extern void defvar_kboard (struct Lisp_Kboard_Objfwd const *, char const *);
 
 /* Macros we use to define forwarded Lisp variables.
    These are used in the syms_of_FILENAME functions.
@@ -3003,29 +3099,34 @@ extern void defvar_kboard (struct Lisp_Kboard_Objfwd *, 
const char *, int);
 
 #define DEFVAR_LISP(lname, vname, doc)         \
   do {                                         \
-    static struct Lisp_Objfwd o_fwd;           \
-    defvar_lisp (&o_fwd, lname, &globals.f_ ## vname);         \
+    static struct Lisp_Objfwd const o_fwd      \
+      = {Lisp_Fwd_Obj, &globals.f_##vname};    \
+    defvar_lisp (&o_fwd, lname);               \
   } while (false)
 #define DEFVAR_LISP_NOPRO(lname, vname, doc)   \
   do {                                         \
-    static struct Lisp_Objfwd o_fwd;           \
-    defvar_lisp_nopro (&o_fwd, lname, &globals.f_ ## vname);   \
+    static struct Lisp_Objfwd const o_fwd      \
+      = {Lisp_Fwd_Obj, &globals.f_##vname};    \
+    defvar_lisp_nopro (&o_fwd, lname);         \
   } while (false)
 #define DEFVAR_BOOL(lname, vname, doc)         \
   do {                                         \
-    static struct Lisp_Boolfwd b_fwd;          \
-    defvar_bool (&b_fwd, lname, &globals.f_ ## vname);         \
+    static struct Lisp_Boolfwd const b_fwd     \
+      = {Lisp_Fwd_Bool, &globals.f_##vname};   \
+    defvar_bool (&b_fwd, lname);               \
   } while (false)
 #define DEFVAR_INT(lname, vname, doc)          \
   do {                                         \
-    static struct Lisp_Intfwd i_fwd;           \
-    defvar_int (&i_fwd, lname, &globals.f_ ## vname);          \
+    static struct Lisp_Intfwd const i_fwd      \
+      = {Lisp_Fwd_Int, &globals.f_##vname};    \
+    defvar_int (&i_fwd, lname);                        \
   } while (false)
 
 #define DEFVAR_KBOARD(lname, vname, doc)                       \
   do {                                                         \
-    static struct Lisp_Kboard_Objfwd ko_fwd;                   \
-    defvar_kboard (&ko_fwd, lname, offsetof (KBOARD, vname ## _)); \
+    static struct Lisp_Kboard_Objfwd const ko_fwd              \
+      = {Lisp_Fwd_Kboard_Obj, offsetof (KBOARD, vname##_)};    \
+    defvar_kboard (&ko_fwd, lname);                            \
   } while (false)
 
 
@@ -3114,11 +3215,6 @@ union specbinding
     } bt;
   };
 
-/* These 3 are defined as macros in thread.h.  */
-/* extern union specbinding *specpdl; */
-/* extern union specbinding *specpdl_ptr; */
-/* extern ptrdiff_t specpdl_size; */
-
 INLINE ptrdiff_t
 SPECPDL_INDEX (void)
 {
@@ -3138,8 +3234,10 @@ SPECPDL_INDEX (void)
    member is TAG, and then unbinds to it.  The `val' member is used to
    hold VAL while the stack is unwound; `val' is returned as the value
    of the catch form.  If there is a handler of type CATCHER_ALL, it will
-   be treated as a handler for all invocations of `throw'; in this case
-   `val' will be set to (TAG . VAL).
+   be treated as a handler for all invocations of `signal' and `throw';
+   in this case `val' will be set to (ERROR-SYMBOL . DATA) or (TAG . VAL),
+   respectively.  During stack unwinding, `nonlocal_exit' is set to
+   specify the type of nonlocal exit that caused the stack unwinding.
 
    All the other members are concerned with restoring the interpreter
    state.
@@ -3149,11 +3247,21 @@ SPECPDL_INDEX (void)
 
 enum handlertype { CATCHER, CONDITION_CASE, CATCHER_ALL };
 
+enum nonlocal_exit
+{
+  NONLOCAL_EXIT_SIGNAL,
+  NONLOCAL_EXIT_THROW,
+};
+
 struct handler
 {
   enum handlertype type;
   Lisp_Object tag_or_ch;
+
+  /* The next two are set by unwind_to_catch.  */
+  enum nonlocal_exit nonlocal_exit;
   Lisp_Object val;
+
   struct handler *next;
   struct handler *nextfree;
 
@@ -3198,16 +3306,33 @@ extern Lisp_Object Vascii_canon_table;
 
 /* Call staticpro (&var) to protect static variable `var'.  */
 
-void staticpro (Lisp_Object *);
+void staticpro (Lisp_Object const *);
+
+enum { NSTATICS = 2048 };
+extern Lisp_Object const *staticvec[NSTATICS];
+extern int staticidx;
+
 
 /* Forward declarations for prototypes.  */
 struct window;
 struct frame;
 
+/* Define if the windowing system provides a menu bar.  */
+#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
+  || defined (HAVE_NS) || defined (USE_GTK)
+#define HAVE_EXT_MENU_BAR true
+#endif
+
+/* Define if the windowing system provides a tool-bar.  */
+#if defined (USE_GTK) || defined (HAVE_NS)
+#define HAVE_EXT_TOOL_BAR true
+#endif
+
 /* Copy COUNT Lisp_Objects from ARGS to contents of V starting from OFFSET.  */
 
 INLINE void
-vcopy (Lisp_Object v, ptrdiff_t offset, Lisp_Object *args, ptrdiff_t count)
+vcopy (Lisp_Object v, ptrdiff_t offset, Lisp_Object const *args,
+       ptrdiff_t count)
 {
   eassert (0 <= offset && 0 <= count && offset + count <= ASIZE (v));
   memcpy (XVECTOR (v)->contents + offset, args, count * sizeof *args);
@@ -3334,7 +3459,7 @@ extern Lisp_Object make_bignum_str (char const *, int);
 extern Lisp_Object make_neg_biguint (uintmax_t);
 extern Lisp_Object double_to_integer (double);
 
-/* Converthe integer NUM to *N.  Return true if successful, false
+/* Convert the integer NUM to *N.  Return true if successful, false
    (possibly setting *N) otherwise.  */
 INLINE bool
 integer_to_intmax (Lisp_Object num, intmax_t *n)
@@ -3367,8 +3492,30 @@ integer_to_uintmax (Lisp_Object num, uintmax_t *n)
     }
 }
 
+/* A modification count.  These are wide enough, and incremented
+   rarely enough, so that they should never overflow a 60-bit counter
+   in practice, and the code below assumes this so a compiler can
+   generate better code if EMACS_INT is 64 bits.  */
+typedef intmax_t modiff_count;
+
+INLINE modiff_count
+modiff_incr (modiff_count *a)
+{
+  modiff_count a0 = *a;
+  bool modiff_overflow = INT_ADD_WRAPV (a0, 1, a);
+  eassert (!modiff_overflow && *a >> 30 >> 30 == 0);
+  return a0;
+}
+
+INLINE Lisp_Object
+modiff_to_integer (modiff_count a)
+{
+  eassume (0 <= a && a >> 30 >> 30 == 0);
+  return make_int (a);
+}
+
 /* Defined in data.c.  */
-extern _Noreturn void wrong_choice (Lisp_Object, Lisp_Object);
+extern AVOID wrong_choice (Lisp_Object, Lisp_Object);
 extern void notify_variable_watchers (Lisp_Object, Lisp_Object,
                                      Lisp_Object, Lisp_Object);
 extern Lisp_Object indirect_function (Lisp_Object);
@@ -3395,11 +3542,10 @@ extern intmax_t cons_to_signed (Lisp_Object, intmax_t, 
intmax_t);
 extern uintmax_t cons_to_unsigned (Lisp_Object, uintmax_t);
 
 extern struct Lisp_Symbol *indirect_variable (struct Lisp_Symbol *);
-extern _Noreturn void args_out_of_range (Lisp_Object, Lisp_Object);
-extern _Noreturn void args_out_of_range_3 (Lisp_Object, Lisp_Object,
-                                          Lisp_Object);
-extern _Noreturn void circular_list (Lisp_Object);
-extern Lisp_Object do_symval_forwarding (union Lisp_Fwd *);
+extern AVOID args_out_of_range (Lisp_Object, Lisp_Object);
+extern AVOID args_out_of_range_3 (Lisp_Object, Lisp_Object, Lisp_Object);
+extern AVOID circular_list (Lisp_Object);
+extern Lisp_Object do_symval_forwarding (lispfwd);
 enum Set_Internal_Bind {
   SET_INTERNAL_SET,
   SET_INTERNAL_BIND,
@@ -3443,14 +3589,17 @@ extern void syms_of_syntax (void);
 
 /* Defined in fns.c.  */
 enum { NEXT_ALMOST_PRIME_LIMIT = 11 };
+extern ptrdiff_t list_length (Lisp_Object);
 extern EMACS_INT next_almost_prime (EMACS_INT) ATTRIBUTE_CONST;
 extern Lisp_Object larger_vector (Lisp_Object, ptrdiff_t, ptrdiff_t);
-extern void sweep_weak_hash_tables (void);
+extern bool sweep_weak_table (struct Lisp_Hash_Table *, bool);
 extern char *extract_data_from_object (Lisp_Object, ptrdiff_t *, ptrdiff_t *);
 EMACS_UINT hash_string (char const *, ptrdiff_t);
 EMACS_UINT sxhash (Lisp_Object, int);
+EMACS_UINT hashfn_eql (struct hash_table_test *ht, Lisp_Object key);
+EMACS_UINT hashfn_equal (struct hash_table_test *ht, Lisp_Object key);
 Lisp_Object make_hash_table (struct hash_table_test, EMACS_INT, float, float,
-                            Lisp_Object, bool);
+                             Lisp_Object, bool);
 ptrdiff_t hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, EMACS_UINT *);
 ptrdiff_t hash_put (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object,
                    EMACS_UINT);
@@ -3503,7 +3652,7 @@ extern void syms_of_json (void);
 
 /* Defined in insdel.c.  */
 extern void move_gap_both (ptrdiff_t, ptrdiff_t);
-extern _Noreturn void buffer_overflow (void);
+extern AVOID buffer_overflow (void);
 extern void make_gap (ptrdiff_t);
 extern void make_gap_1 (struct buffer *, ptrdiff_t);
 extern ptrdiff_t copy_text (const unsigned char *, unsigned char *,
@@ -3603,8 +3752,8 @@ extern void *my_heap_start (void);
 extern void check_pure_size (void);
 extern void allocate_string_data (struct Lisp_String *, EMACS_INT, EMACS_INT);
 extern void malloc_warning (const char *);
-extern _Noreturn void memory_full (size_t);
-extern _Noreturn void buffer_memory_full (ptrdiff_t);
+extern AVOID memory_full (size_t);
+extern AVOID buffer_memory_full (ptrdiff_t);
 extern bool survives_gc_p (Lisp_Object);
 extern void mark_object (Lisp_Object);
 #if defined REL_ALLOC && !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC
@@ -3612,24 +3761,57 @@ extern void refill_memory_reserve (void);
 #endif
 extern void alloc_unexec_pre (void);
 extern void alloc_unexec_post (void);
-extern void mark_maybe_objects (Lisp_Object *, ptrdiff_t);
-extern void mark_stack (char *, char *);
+extern void mark_maybe_objects (Lisp_Object const *, ptrdiff_t);
+extern void mark_stack (char const *, char const *);
 extern void flush_stack_call_func (void (*func) (void *arg), void *arg);
+extern void garbage_collect (void);
 extern const char *pending_malloc_warning;
 extern Lisp_Object zero_vector;
-extern EMACS_INT consing_since_gc;
-extern EMACS_INT gc_relative_threshold;
-extern EMACS_INT memory_full_cons_threshold;
+typedef uintptr_t byte_ct;  /* System byte counts reported by GC.  */
+extern byte_ct consing_since_gc;
+extern byte_ct gc_relative_threshold;
+extern byte_ct const memory_full_cons_threshold;
+#ifdef HAVE_PDUMPER
+extern int number_finalizers_run;
+#endif
+#ifdef ENABLE_CHECKING
+extern Lisp_Object Vdead;
+#endif
 extern Lisp_Object list1 (Lisp_Object);
 extern Lisp_Object list2 (Lisp_Object, Lisp_Object);
 extern Lisp_Object list3 (Lisp_Object, Lisp_Object, Lisp_Object);
 extern Lisp_Object list4 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
 extern Lisp_Object list5 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object,
                          Lisp_Object);
-enum constype {CONSTYPE_HEAP, CONSTYPE_PURE};
-extern Lisp_Object listn (enum constype, ptrdiff_t, Lisp_Object, ...);
+extern Lisp_Object listn (ptrdiff_t, Lisp_Object, ...);
+extern Lisp_Object pure_listn (ptrdiff_t, Lisp_Object, ...);
+#define list(...) \
+  listn (ARRAYELTS (((Lisp_Object []) {__VA_ARGS__})), __VA_ARGS__)
+#define pure_list(...) \
+  pure_listn (ARRAYELTS (((Lisp_Object []) {__VA_ARGS__})), __VA_ARGS__)
+
+enum gc_root_type
+{
+  GC_ROOT_STATICPRO,
+  GC_ROOT_BUFFER_LOCAL_DEFAULT,
+  GC_ROOT_BUFFER_LOCAL_NAME,
+  GC_ROOT_C_SYMBOL
+};
+
+struct gc_root_visitor
+{
+  void (*visit) (Lisp_Object const *, enum gc_root_type, void *);
+  void *data;
+};
+extern void visit_static_gc_roots (struct gc_root_visitor visitor);
+
+/* Build a frequently used 1/2/3/4-integer lists.  */
 
-/* Build a frequently used 2/3/4-integer lists.  */
+INLINE Lisp_Object
+list1i (EMACS_INT x)
+{
+  return list1 (make_fixnum (x));
+}
 
 INLINE Lisp_Object
 list2i (EMACS_INT x, EMACS_INT y)
@@ -3652,11 +3834,18 @@ list4i (EMACS_INT x, EMACS_INT y, EMACS_INT w, 
EMACS_INT h)
 
 extern Lisp_Object make_uninit_bool_vector (EMACS_INT);
 extern Lisp_Object bool_vector_fill (Lisp_Object, Lisp_Object);
-extern _Noreturn void string_overflow (void);
+extern AVOID string_overflow (void);
 extern Lisp_Object make_string (const char *, ptrdiff_t);
 extern Lisp_Object make_formatted_string (char *, const char *, ...)
   ATTRIBUTE_FORMAT_PRINTF (2, 3);
 extern Lisp_Object make_unibyte_string (const char *, ptrdiff_t);
+extern ptrdiff_t vectorlike_nbytes (const union vectorlike_header *hdr);
+
+INLINE ptrdiff_t
+vector_nbytes (const struct Lisp_Vector *v)
+{
+  return vectorlike_nbytes (&v->header);
+}
 
 /* Make unibyte string from C string when the length isn't known.  */
 
@@ -3740,6 +3929,11 @@ make_nil_vector (ptrdiff_t size)
 extern struct Lisp_Vector *allocate_pseudovector (int, int, int,
                                                  enum pvec_type);
 
+/* Allocate uninitialized pseudovector with no Lisp_Object slots.  */
+
+#define ALLOCATE_PLAIN_PSEUDOVECTOR(type, tag) \
+  ((type *) allocate_pseudovector (VECSIZE (type), 0, 0, tag))
+
 /* Allocate partially initialized pseudovector where all Lisp_Object
    slots are set to Qnil but the rest (if any) is left uninitialized.  */
 
@@ -3767,11 +3961,6 @@ extern void init_alloc (void);
 extern void syms_of_alloc (void);
 extern struct buffer * allocate_buffer (void);
 extern int valid_lisp_object_p (Lisp_Object);
-#ifdef GC_CHECK_CONS_LIST
-extern void check_cons_list (void);
-#else
-INLINE void (check_cons_list) (void) { lisp_h_check_cons_list (); }
-#endif
 
 /* Defined in gmalloc.c.  */
 #if !defined DOUG_LEA_MALLOC && !defined HYBRID_MALLOC && !defined 
SYSTEM_MALLOC
@@ -3852,7 +4041,7 @@ extern Lisp_Object string_to_number (char const *, int, 
ptrdiff_t *);
 extern void map_obarray (Lisp_Object, void (*) (Lisp_Object, Lisp_Object),
                          Lisp_Object);
 extern void dir_warning (const char *, Lisp_Object);
-extern void init_obarray (void);
+extern void init_obarray_once (void);
 extern void init_lread (void);
 extern void syms_of_lread (void);
 
@@ -3887,18 +4076,17 @@ extern Lisp_Object run_hook_with_args (ptrdiff_t nargs, 
Lisp_Object *args,
                                       Lisp_Object (*funcall)
                                       (ptrdiff_t nargs, Lisp_Object *args));
 extern Lisp_Object quit (void);
-INLINE _Noreturn void
+INLINE AVOID
 xsignal (Lisp_Object error_symbol, Lisp_Object data)
 {
   Fsignal (error_symbol, data);
 }
-extern _Noreturn void xsignal0 (Lisp_Object);
-extern _Noreturn void xsignal1 (Lisp_Object, Lisp_Object);
-extern _Noreturn void xsignal2 (Lisp_Object, Lisp_Object, Lisp_Object);
-extern _Noreturn void xsignal3 (Lisp_Object, Lisp_Object, Lisp_Object,
-                               Lisp_Object);
-extern _Noreturn void signal_error (const char *, Lisp_Object);
-extern _Noreturn void overflow_error (void);
+extern AVOID xsignal0 (Lisp_Object);
+extern AVOID xsignal1 (Lisp_Object, Lisp_Object);
+extern AVOID xsignal2 (Lisp_Object, Lisp_Object, Lisp_Object);
+extern AVOID xsignal3 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
+extern AVOID signal_error (const char *, Lisp_Object);
+extern AVOID overflow_error (void);
 extern bool FUNCTIONP (Lisp_Object);
 extern Lisp_Object funcall_subr (struct Lisp_Subr *subr, ptrdiff_t numargs, 
Lisp_Object *arg_vector);
 extern Lisp_Object eval_sub (Lisp_Object form);
@@ -3920,7 +4108,7 @@ extern Lisp_Object internal_condition_case_2 (Lisp_Object 
(*) (Lisp_Object, Lisp
 extern Lisp_Object internal_condition_case_n
     (Lisp_Object (*) (ptrdiff_t, Lisp_Object *), ptrdiff_t, Lisp_Object *,
      Lisp_Object, Lisp_Object (*) (Lisp_Object, ptrdiff_t, Lisp_Object *));
-extern Lisp_Object internal_catch_all (Lisp_Object (*) (void *), void *, 
Lisp_Object (*) (Lisp_Object));
+extern Lisp_Object internal_catch_all (Lisp_Object (*) (void *), void *, 
Lisp_Object (*) (enum nonlocal_exit, Lisp_Object));
 extern struct handler *push_handler (Lisp_Object, enum handlertype);
 extern struct handler *push_handler_nosignal (Lisp_Object, enum handlertype);
 extern void specbind (Lisp_Object, Lisp_Object);
@@ -3937,8 +4125,8 @@ extern void set_unwind_protect_ptr (ptrdiff_t, void (*) 
(void *), void *);
 extern Lisp_Object unbind_to (ptrdiff_t, Lisp_Object);
 extern void rebind_for_thread_switch (void);
 extern void unbind_for_thread_switch (struct thread_state *);
-extern _Noreturn void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
-extern _Noreturn void verror (const char *, va_list)
+extern AVOID error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
+extern AVOID verror (const char *, va_list)
   ATTRIBUTE_FORMAT_PRINTF (1, 0);
 extern Lisp_Object vformat_string (const char *, va_list)
   ATTRIBUTE_FORMAT_PRINTF (1, 0);
@@ -3958,38 +4146,15 @@ Lisp_Object backtrace_top_function (void);
 extern bool let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol);
 
 /* Defined in unexmacosx.c.  */
-#if defined DARWIN_OS && !defined CANNOT_DUMP
+#if defined DARWIN_OS && defined HAVE_UNEXEC
 extern void unexec_init_emacs_zone (void);
 extern void *unexec_malloc (size_t);
 extern void *unexec_realloc (void *, size_t);
 extern void unexec_free (void *);
 #endif
 
-#include "emacs-module.h"
-
-/* Function prototype for the module Lisp functions.  */
-typedef emacs_value (*emacs_subr) (emacs_env *, ptrdiff_t,
-                                  emacs_value [], void *);
-
-/* Module function.  */
-
-/* A function environment is an auxiliary structure returned by
-   `module_make_function' to store information about a module
-   function.  It is stored in a pseudovector.  Its members correspond
-   to the arguments given to `module_make_function'.  */
-
-struct Lisp_Module_Function
-{
-  union vectorlike_header header;
-
-  /* Fields traced by GC; these must come first.  */
-  Lisp_Object documentation;
-
-  /* Fields ignored by GC.  */
-  ptrdiff_t min_arity, max_arity;
-  emacs_subr subr;
-  void *data;
-} GCALIGNED_STRUCT;
+/* The definition of Lisp_Module_Function depends on emacs-module.h,
+   so we don't define it here.  It's defined in emacs-module.c.  */
 
 INLINE bool
 MODULE_FUNCTIONP (Lisp_Object o)
@@ -4005,12 +4170,21 @@ XMODULE_FUNCTION (Lisp_Object o)
 }
 
 #ifdef HAVE_MODULES
+/* A function pointer type good enough for lisp.h.  Actual module
+   function pointers are of a different type that relies on details
+   internal to emacs-module.c.  */
+typedef void (*module_funcptr) (void);
+
 /* Defined in alloc.c.  */
 extern Lisp_Object make_user_ptr (void (*finalizer) (void *), void *p);
 
 /* Defined in emacs-module.c.  */
 extern Lisp_Object funcall_module (Lisp_Object, ptrdiff_t, Lisp_Object *);
 extern Lisp_Object module_function_arity (const struct Lisp_Module_Function *);
+extern Lisp_Object module_function_documentation
+  (struct Lisp_Module_Function const *);
+extern module_funcptr module_function_address
+  (struct Lisp_Module_Function const *);
 extern void mark_modules (void);
 extern void init_module_assertions (bool);
 extern void syms_of_module (void);
@@ -4035,7 +4209,7 @@ extern void syms_of_editfns (void);
 /* Defined in buffer.c.  */
 extern bool mouse_face_overlay_overlaps (Lisp_Object);
 extern Lisp_Object disable_line_numbers_overlay_at_eob (void);
-extern _Noreturn void nsberror (Lisp_Object);
+extern AVOID nsberror (Lisp_Object);
 extern void adjust_overlays_for_insert (ptrdiff_t, ptrdiff_t);
 extern void adjust_overlays_for_delete (ptrdiff_t, ptrdiff_t);
 extern void fix_start_end_in_overlays (ptrdiff_t, ptrdiff_t);
@@ -4045,7 +4219,7 @@ extern bool overlay_touches_p (ptrdiff_t);
 extern Lisp_Object other_buffer_safely (Lisp_Object);
 extern Lisp_Object get_truename_buffer (Lisp_Object);
 extern void init_buffer_once (void);
-extern void init_buffer (int);
+extern void init_buffer (void);
 extern void syms_of_buffer (void);
 extern void keys_of_buffer (void);
 
@@ -4068,6 +4242,7 @@ extern void syms_of_marker (void);
 /* Defined in fileio.c.  */
 
 extern char *splice_dir_file (char *, char const *, char const *);
+extern bool file_name_absolute_p (const char *);
 extern char const *get_homedir (void);
 extern Lisp_Object expand_and_dir_to_file (Lisp_Object);
 extern Lisp_Object write_region (Lisp_Object, Lisp_Object, Lisp_Object,
@@ -4077,9 +4252,9 @@ extern void close_file_unwind (int);
 extern void fclose_unwind (void *);
 extern void restore_point_unwind (Lisp_Object);
 extern Lisp_Object get_file_errno_data (const char *, Lisp_Object, int);
-extern _Noreturn void report_file_errno (const char *, Lisp_Object, int);
-extern _Noreturn void report_file_error (const char *, Lisp_Object);
-extern _Noreturn void report_file_notify_error (const char *, Lisp_Object);
+extern AVOID report_file_errno (const char *, Lisp_Object, int);
+extern AVOID report_file_error (const char *, Lisp_Object);
+extern AVOID report_file_notify_error (const char *, Lisp_Object);
 extern bool internal_delete_file (Lisp_Object);
 extern Lisp_Object emacs_readlinkat (int, const char *);
 extern bool file_directory_p (Lisp_Object);
@@ -4114,8 +4289,8 @@ extern ptrdiff_t fast_looking_at (Lisp_Object, ptrdiff_t, 
ptrdiff_t,
                                   ptrdiff_t, ptrdiff_t, Lisp_Object);
 extern ptrdiff_t find_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t,
                               ptrdiff_t, ptrdiff_t *, ptrdiff_t *, bool);
-extern ptrdiff_t scan_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t,
-                              ptrdiff_t, bool);
+extern void scan_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t,
+                         ptrdiff_t, bool);
 extern ptrdiff_t scan_newline_from_point (ptrdiff_t, ptrdiff_t *, ptrdiff_t *);
 extern ptrdiff_t find_newline_no_quit (ptrdiff_t, ptrdiff_t,
                                       ptrdiff_t, ptrdiff_t *);
@@ -4188,6 +4363,7 @@ extern void store_in_alist (Lisp_Object *, Lisp_Object, 
Lisp_Object);
 extern Lisp_Object do_switch_frame (Lisp_Object, int, int, Lisp_Object);
 extern Lisp_Object get_frame_param (struct frame *, Lisp_Object);
 extern void frames_discard_buffer (Lisp_Object);
+extern void init_frame_once (void);
 extern void syms_of_frame (void);
 
 /* Defined in emacs.c.  */
@@ -4199,7 +4375,7 @@ extern bool display_arg;
 #endif
 extern Lisp_Object decode_env_path (const char *, const char *, bool);
 extern Lisp_Object empty_unibyte_string, empty_multibyte_string;
-extern _Noreturn void terminate_due_to_signal (int, int);
+extern AVOID terminate_due_to_signal (int, int);
 #ifdef WINDOWSNT
 extern Lisp_Object Vlibrary_cache;
 #endif
@@ -4270,11 +4446,14 @@ extern void syms_of_process (void);
 extern void setup_process_coding_systems (Lisp_Object);
 
 /* Defined in callproc.c.  */
-#ifndef DOS_NT
-# define CHILD_SETUP_TYPE _Noreturn void
-#else
+#ifdef DOS_NT
 # define CHILD_SETUP_TYPE int
+# define CHILD_SETUP_ERROR_DESC "Spawning child process"
+#else
+# define CHILD_SETUP_TYPE _Noreturn void
+# define CHILD_SETUP_ERROR_DESC "Doing vfork"
 #endif
+
 extern CHILD_SETUP_TYPE child_setup (int, int, int, char **, bool, 
Lisp_Object);
 extern void init_callproc_1 (void);
 extern void init_callproc (void);
@@ -4361,7 +4540,7 @@ extern EMACS_INT get_random (void);
 extern void seed_random (void *, ptrdiff_t);
 extern void init_random (void);
 extern void emacs_backtrace (int);
-extern _Noreturn void emacs_abort (void) NO_INLINE;
+extern AVOID emacs_abort (void) NO_INLINE;
 extern int emacs_open (const char *, int, int);
 extern int emacs_pipe (int[2]);
 extern int emacs_close (int);
@@ -4402,8 +4581,7 @@ extern Lisp_Object directory_files_internal (Lisp_Object, 
Lisp_Object,
 /* Defined in term.c.  */
 extern int *char_ins_del_vector;
 extern void syms_of_term (void);
-extern _Noreturn void fatal (const char *msgid, ...)
-  ATTRIBUTE_FORMAT_PRINTF (1, 2);
+extern AVOID fatal (const char *msgid, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
 
 /* Defined in terminal.c.  */
 extern void syms_of_terminal (void);
@@ -4448,6 +4626,9 @@ extern void syms_of_w32cygwinx (void);
 extern Lisp_Object Vface_alternative_font_family_alist;
 extern Lisp_Object Vface_alternative_font_registry_alist;
 extern void syms_of_xfaces (void);
+#ifdef HAVE_PDUMPER
+extern void init_xfaces (void);
+#endif
 
 #ifdef HAVE_X_WINDOWS
 /* Defined in xfns.c.  */
@@ -4466,7 +4647,7 @@ extern void syms_of_xterm (void);
 
 #ifdef HAVE_WINDOW_SYSTEM
 /* Defined in xterm.c, nsterm.m, w32term.c.  */
-extern char *x_get_keysym_name (int);
+extern char *get_keysym_name (int);
 #endif /* HAVE_WINDOW_SYSTEM */
 
 /* Defined in xml.c.  */
@@ -4522,7 +4703,7 @@ extern char *xlispstrdup (Lisp_Object) ATTRIBUTE_MALLOC;
 extern void dupstring (char **, char const *);
 
 /* Make DEST a copy of STRING's data.  Return a pointer to DEST's terminating
-   null byte.  This is like stpcpy, except the source is a Lisp string.  */
+   NUL byte.  This is like stpcpy, except the source is a Lisp string.  */
 
 INLINE char *
 lispstpcpy (char *dest, Lisp_Object string)
@@ -4726,7 +4907,7 @@ enum
         : list4 (a, b, c, d))
 
 /* Declare NAME as an auto Lisp string if possible, a GC-based one if not.
-   Take its unibyte value from the null-terminated string STR,
+   Take its unibyte value from the NUL-terminated string STR,
    an expression that should not have side effects.
    STR's value is not necessarily copied.  The resulting Lisp string
    should not be modified or given text properties or made visible to
@@ -4736,8 +4917,8 @@ enum
   AUTO_STRING_WITH_LEN (name, str, strlen (str))
 
 /* Declare NAME as an auto Lisp string if possible, a GC-based one if not.
-   Take its unibyte value from the null-terminated string STR with length LEN.
-   STR may have side effects and may contain null bytes.
+   Take its unibyte value from the NUL-terminated string STR with length LEN.
+   STR may have side effects and may contain NUL bytes.
    STR's value is not necessarily copied.  The resulting Lisp string
    should not be modified or given text properties or made visible to
    user code.  */
@@ -4820,7 +5001,7 @@ maybe_gc (void)
        && consing_since_gc > gc_relative_threshold)
       || (!NILP (Vmemory_full)
          && consing_since_gc > memory_full_cons_threshold))
-    Fgarbage_collect ();
+    garbage_collect ();
 }
 
 INLINE_HEADER_END
diff --git a/src/lread.c b/src/lread.c
index 4c6b767..1c97805 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -1,6 +1,6 @@
 /* Lisp parsing and input streams.
 
-Copyright (C) 1985-1989, 1993-1995, 1997-2018 Free Software Foundation,
+Copyright (C) 1985-1989, 1993-1995, 1997-2019 Free Software Foundation,
 Inc.
 
 This file is part of GNU Emacs.
@@ -42,14 +42,11 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "systime.h"
 #include "termhooks.h"
 #include "blockinput.h"
+#include "pdumper.h"
 #include <c-ctype.h>
 
 #ifdef MSDOS
 #include "msdos.h"
-#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 5
-# define INFINITY  __builtin_inf()
-# define NAN       __builtin_nan("")
-#endif
 #endif
 
 #ifdef HAVE_NS
@@ -74,6 +71,9 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #if IEEE_FLOATING_POINT
 # include <ieee754.h>
+# ifndef INFINITY
+#  define INFINITY ((union ieee754_double) {.ieee = {.exponent = -1}}.d)
+# endif
 #endif
 
 /* The objects or placeholders read with the #n=object form.
@@ -1019,7 +1019,7 @@ load_error_handler (Lisp_Object data)
   return Qnil;
 }
 
-static _Noreturn void
+static AVOID
 load_error_old_style_backquotes (void)
 {
   if (NILP (Vload_file_name))
@@ -1034,18 +1034,12 @@ load_error_old_style_backquotes (void)
 static void
 load_warn_unescaped_character_literals (Lisp_Object file)
 {
-  if (NILP (Vlread_unescaped_character_literals)) return;
-  CHECK_CONS (Vlread_unescaped_character_literals);
-  Lisp_Object format =
-    build_string ("Loading `%s': unescaped character literals %s detected!");
-  Lisp_Object separator = build_string (", ");
-  Lisp_Object inner_format = build_string ("`?%c'");
-  CALLN (Fmessage,
-         format, file,
-         Fmapconcat (list3 (Qlambda, list1 (Qchar),
-                            list3 (Qformat, inner_format, Qchar)),
-                     Fsort (Vlread_unescaped_character_literals, Qlss),
-                     separator));
+  Lisp_Object warning = call0 (Qbyte_run_unescaped_character_literals_warning);
+  if (!NILP (warning))
+    {
+      AUTO_STRING (format, "Loading `%s': %s");
+      CALLN (Fmessage, format, file, warning);
+    }
 }
 
 DEFUN ("get-load-suffixes", Fget_load_suffixes, Sget_load_suffixes, 0, 0, 0,
@@ -1070,14 +1064,15 @@ This uses the variables `load-suffixes' and 
`load-file-rep-suffixes'.  */)
   return Fnreverse (lst);
 }
 
-/* Returns true if STRING ends with SUFFIX */
+/* Return true if STRING ends with SUFFIX.  */
 static bool
 suffix_p (Lisp_Object string, const char *suffix)
 {
   ptrdiff_t suffix_len = strlen (suffix);
   ptrdiff_t string_len = SBYTES (string);
 
-  return string_len >= suffix_len && !strcmp (SSDATA (string) + string_len - 
suffix_len, suffix);
+  return (suffix_len <= string_len
+         && strcmp (SSDATA (string) + string_len - suffix_len, suffix) == 0);
 }
 
 static void
@@ -1306,8 +1301,8 @@ Return t if the file exists and loads successfully.  */)
   specbind (Qlread_unescaped_character_literals, Qnil);
   record_unwind_protect (load_warn_unescaped_character_literals, file);
 
-  int is_elc;
-  if ((is_elc = suffix_p (found, ".elc")) != 0
+  bool is_elc = suffix_p (found, ".elc");
+  if (is_elc
       /* version = 1 means the file is empty, in which case we can
         treat it as not byte-compiled.  */
       || (fd >= 0 && (version = safe_to_load_version (fd)) > 1))
@@ -1444,6 +1439,10 @@ Return t if the file exists and loads successfully.  */)
   specbind (Qinhibit_file_name_operation, Qnil);
   specbind (Qload_in_progress, Qt);
 
+  /* Declare here rather than inside the else-part because the storage
+     might be accessed by the unbind_to call below.  */
+  struct infile input;
+
   if (is_module)
     {
 #ifdef HAVE_MODULES
@@ -1458,7 +1457,6 @@ Return t if the file exists and loads successfully.  */)
     }
   else
     {
-      struct infile input;
       input.stream = stream;
       input.lookahead = 0;
       infile = &input;
@@ -1873,7 +1871,7 @@ readevalloop_1 (int old)
 /* Signal an `end-of-file' error, if possible with file name
    information.  */
 
-static _Noreturn void
+static AVOID
 end_of_file_error (void)
 {
   if (STRINGP (Vload_file_name))
@@ -1932,13 +1930,10 @@ readevalloop (Lisp_Object readcharfun,
   Lisp_Object macroexpand = intern ("internal-macroexpand-for-load");
 
   if (NILP (Ffboundp (macroexpand))
-      /* Don't macroexpand in .elc files, since it should have been done
-        already.  We actually don't know whether we're in a .elc file or not,
-        so we use circumstantial evidence: .el files normally go through
-        Vload_source_file_function -> load-with-code-conversion
-        -> eval-buffer.  */
-      || EQ (readcharfun, Qget_file_char)
-      || EQ (readcharfun, Qget_emacs_mule_file_char))
+      || (STRINGP (sourcename) && suffix_p (sourcename, ".elc")))
+    /* Don't macroexpand before the corresponding function is defined
+       and don't bother macroexpanding in .elc files, since it should have
+       been done already.  */
     macroexpand = Qnil;
 
   if (MARKERP (readcharfun))
@@ -1970,7 +1965,7 @@ readevalloop (Lisp_Object readcharfun,
             ? Qnil : list1 (Qt)));
 
   /* Try to ensure sourcename is a truename, except whilst preloading.  */
-  if (NILP (Vpurify_flag)
+  if (!will_dump_p ()
       && !NILP (sourcename) && !NILP (Ffile_name_absolute_p (sourcename))
       && !NILP (Ffboundp (Qfile_truename)))
     sourcename = call1 (Qfile_truename, sourcename) ;
@@ -2299,7 +2294,7 @@ read_internal_start (Lisp_Object stream, Lisp_Object 
start, Lisp_Object end)
 /* Signal Qinvalid_read_syntax error.
    S is error string of length N (if > 0)  */
 
-static _Noreturn void
+static AVOID
 invalid_syntax (const char *s)
 {
   xsignal1 (Qinvalid_read_syntax, build_string (s));
@@ -2661,7 +2656,7 @@ free_contents (void *p)
 static Lisp_Object
 read_integer (Lisp_Object readcharfun, EMACS_INT radix)
 {
-  /* Room for sign, leading 0, other digits, trailing null byte.
+  /* Room for sign, leading 0, other digits, trailing NUL byte.
      Also, room for invalid syntax diagnostic.  */
   size_t len = max (1 + 1 + UINTMAX_WIDTH + 1,
                    sizeof "integer, radix " + INT_STRLEN_BOUND (EMACS_INT));
@@ -2880,7 +2875,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool 
first_in_list)
                  /* Sub char-table can't be read as a regular
                     vector because of a two C integer fields.  */
                  Lisp_Object tbl, tmp = read_list (1, readcharfun);
-                 ptrdiff_t size = XFIXNUM (Flength (tmp));
+                 ptrdiff_t size = list_length (tmp);
                  int i, depth, min_char;
                  struct Lisp_Cons *cell;
 
@@ -3787,7 +3782,7 @@ string_to_number (char const *string, int base, ptrdiff_t 
*plen)
              state |= E_EXP;
              cp += 3;
              union ieee754_double u
-               = { .ieee_nan = { .exponent = -1, .quiet_nan = 1,
+               = { .ieee_nan = { .exponent = 0x7ff, .quiet_nan = 1,
                                  .mantissa0 = n >> 31 >> 1, .mantissa1 = n }};
              value = u.d;
            }
@@ -3847,8 +3842,7 @@ static Lisp_Object
 read_vector (Lisp_Object readcharfun, bool bytecodeflag)
 {
   Lisp_Object tem = read_list (1, readcharfun);
-  Lisp_Object len = Flength (tem);
-  ptrdiff_t size = XFIXNAT (len);
+  ptrdiff_t size = list_length (tem);
   if (bytecodeflag && size <= COMPILED_STACK_DEPTH)
     error ("Invalid byte code");
   Lisp_Object vector = make_nil_vector (size);
@@ -4375,7 +4369,7 @@ OBARRAY defaults to the value of `obarray'.  */)
 #define OBARRAY_SIZE 15121
 
 void
-init_obarray (void)
+init_obarray_once (void)
 {
   Vobarray = make_vector (OBARRAY_SIZE, make_fixnum (0));
   initial_obarray = Vobarray;
@@ -4396,11 +4390,12 @@ init_obarray (void)
   make_symbol_constant (Qt);
   XSYMBOL (Qt)->u.s.declared_special = true;
 
-  /* Qt is correct even if CANNOT_DUMP.  loadup.el will set to nil at end.  */
+  /* Qt is correct even if not dumping.  loadup.el will set to nil at end.  */
   Vpurify_flag = Qt;
 
   DEFSYM (Qvariable_documentation, "variable-documentation");
 }
+
 
 void
 defsubr (union Aligned_Lisp_Subr *aname)
@@ -4424,34 +4419,25 @@ defalias (struct Lisp_Subr *sname, char *string)
 #endif /* NOTDEF */
 
 /* Define an "integer variable"; a symbol whose value is forwarded to a
-   C variable of type EMACS_INT.  Sample call (with "xx" to fool make-docfile):
+   C variable of type intmax_t.  Sample call (with "xx" to fool make-docfile):
    DEFxxVAR_INT ("emacs-priority", &emacs_priority, "Documentation");  */
 void
-defvar_int (struct Lisp_Intfwd *i_fwd,
-           const char *namestring, EMACS_INT *address)
+defvar_int (struct Lisp_Intfwd const *i_fwd, char const *namestring)
 {
-  Lisp_Object sym;
-  sym = intern_c_string (namestring);
-  i_fwd->type = Lisp_Fwd_Int;
-  i_fwd->intvar = address;
+  Lisp_Object sym = intern_c_string (namestring);
   XSYMBOL (sym)->u.s.declared_special = true;
   XSYMBOL (sym)->u.s.redirect = SYMBOL_FORWARDED;
-  SET_SYMBOL_FWD (XSYMBOL (sym), (union Lisp_Fwd *)i_fwd);
+  SET_SYMBOL_FWD (XSYMBOL (sym), i_fwd);
 }
 
-/* Similar but define a variable whose value is t if address contains 1,
-   nil if address contains 0.  */
+/* Similar but define a variable whose value is t if 1, nil if 0.  */
 void
-defvar_bool (struct Lisp_Boolfwd *b_fwd,
-            const char *namestring, bool *address)
+defvar_bool (struct Lisp_Boolfwd const *b_fwd, char const *namestring)
 {
-  Lisp_Object sym;
-  sym = intern_c_string (namestring);
-  b_fwd->type = Lisp_Fwd_Bool;
-  b_fwd->boolvar = address;
+  Lisp_Object sym = intern_c_string (namestring);
   XSYMBOL (sym)->u.s.declared_special = true;
   XSYMBOL (sym)->u.s.redirect = SYMBOL_FORWARDED;
-  SET_SYMBOL_FWD (XSYMBOL (sym), (union Lisp_Fwd *)b_fwd);
+  SET_SYMBOL_FWD (XSYMBOL (sym), b_fwd);
   Vbyte_boolean_vars = Fcons (sym, Vbyte_boolean_vars);
 }
 
@@ -4461,40 +4447,31 @@ defvar_bool (struct Lisp_Boolfwd *b_fwd,
    gc-marked for some other reason, since marking the same slot twice
    can cause trouble with strings.  */
 void
-defvar_lisp_nopro (struct Lisp_Objfwd *o_fwd,
-                  const char *namestring, Lisp_Object *address)
+defvar_lisp_nopro (struct Lisp_Objfwd const *o_fwd, char const *namestring)
 {
-  Lisp_Object sym;
-  sym = intern_c_string (namestring);
-  o_fwd->type = Lisp_Fwd_Obj;
-  o_fwd->objvar = address;
+  Lisp_Object sym = intern_c_string (namestring);
   XSYMBOL (sym)->u.s.declared_special = true;
   XSYMBOL (sym)->u.s.redirect = SYMBOL_FORWARDED;
-  SET_SYMBOL_FWD (XSYMBOL (sym), (union Lisp_Fwd *)o_fwd);
+  SET_SYMBOL_FWD (XSYMBOL (sym), o_fwd);
 }
 
 void
-defvar_lisp (struct Lisp_Objfwd *o_fwd,
-            const char *namestring, Lisp_Object *address)
+defvar_lisp (struct Lisp_Objfwd const *o_fwd, char const *namestring)
 {
-  defvar_lisp_nopro (o_fwd, namestring, address);
-  staticpro (address);
+  defvar_lisp_nopro (o_fwd, namestring);
+  staticpro (o_fwd->objvar);
 }
 
 /* Similar but define a variable whose value is the Lisp Object stored
    at a particular offset in the current kboard object.  */
 
 void
-defvar_kboard (struct Lisp_Kboard_Objfwd *ko_fwd,
-              const char *namestring, int offset)
+defvar_kboard (struct Lisp_Kboard_Objfwd const *ko_fwd, char const *namestring)
 {
-  Lisp_Object sym;
-  sym = intern_c_string (namestring);
-  ko_fwd->type = Lisp_Fwd_Kboard_Obj;
-  ko_fwd->offset = offset;
+  Lisp_Object sym = intern_c_string (namestring);
   XSYMBOL (sym)->u.s.declared_special = true;
   XSYMBOL (sym)->u.s.redirect = SYMBOL_FORWARDED;
-  SET_SYMBOL_FWD (XSYMBOL (sym), (union Lisp_Fwd *)ko_fwd);
+  SET_SYMBOL_FWD (XSYMBOL (sym), ko_fwd);
 }
 
 /* Check that the elements of lpath exist.  */
@@ -4528,11 +4505,9 @@ load_path_check (Lisp_Object lpath)
    are running uninstalled.
 
    Uses the following logic:
-   If CANNOT_DUMP:
-     If Vinstallation_directory is not nil (ie, running uninstalled),
-     use PATH_DUMPLOADSEARCH (ie, build path).  Else use PATH_LOADSEARCH.
-   The remainder is what happens when dumping works:
-   If purify-flag (ie dumping) just use PATH_DUMPLOADSEARCH.
+   If !will_dump: Use PATH_LOADSEARCH.
+   The remainder is what happens when dumping is about to happen:
+   If dumping, just use PATH_DUMPLOADSEARCH.
    Otherwise use PATH_LOADSEARCH.
 
    If !initialized, then just return PATH_DUMPLOADSEARCH.
@@ -4555,131 +4530,109 @@ load_path_check (Lisp_Object lpath)
 static Lisp_Object
 load_path_default (void)
 {
+  if (will_dump_p ())
+    /* PATH_DUMPLOADSEARCH is the lisp dir in the source directory.
+       We used to add ../lisp (ie the lisp dir in the build
+       directory) at the front here, but that should not be
+       necessary, since in out of tree builds lisp/ is empty, save
+       for Makefile.  */
+    return decode_env_path (0, PATH_DUMPLOADSEARCH, 0);
+
   Lisp_Object lpath = Qnil;
-  const char *normal;
+  const char *normal = PATH_LOADSEARCH;
+  const char *loadpath = NULL;
 
-#ifdef CANNOT_DUMP
 #ifdef HAVE_NS
-  const char *loadpath = ns_load_path ();
+  loadpath = ns_load_path ();
 #endif
 
-  normal = PATH_LOADSEARCH;
-  if (!NILP (Vinstallation_directory)) normal = PATH_DUMPLOADSEARCH;
-
-#ifdef HAVE_NS
   lpath = decode_env_path (0, loadpath ? loadpath : normal, 0);
-#else
-  lpath = decode_env_path (0, normal, 0);
-#endif
-
-#else  /* !CANNOT_DUMP */
 
-  normal = NILP (Vpurify_flag) ? PATH_LOADSEARCH : PATH_DUMPLOADSEARCH;
-
-  if (initialized)
+  if (!NILP (Vinstallation_directory))
     {
-#ifdef HAVE_NS
-      const char *loadpath = ns_load_path ();
-      lpath = decode_env_path (0, loadpath ? loadpath : normal, 0);
-#else
-      lpath = decode_env_path (0, normal, 0);
-#endif
-      if (!NILP (Vinstallation_directory))
+      Lisp_Object tem, tem1;
+
+      /* Add to the path the lisp subdir of the installation
+         dir, if it is accessible.  Note: in out-of-tree builds,
+         this directory is empty save for Makefile.  */
+      tem = Fexpand_file_name (build_string ("lisp"),
+                               Vinstallation_directory);
+      tem1 = Ffile_accessible_directory_p (tem);
+      if (!NILP (tem1))
         {
-          Lisp_Object tem, tem1;
+          if (NILP (Fmember (tem, lpath)))
+            {
+              /* We are running uninstalled.  The default load-path
+                 points to the eventual installed lisp directories.
+                 We should not use those now, even if they exist,
+                 so start over from a clean slate.  */
+              lpath = list1 (tem);
+            }
+        }
+      else
+        /* That dir doesn't exist, so add the build-time
+           Lisp dirs instead.  */
+        {
+          Lisp_Object dump_path =
+            decode_env_path (0, PATH_DUMPLOADSEARCH, 0);
+          lpath = nconc2 (lpath, dump_path);
+        }
 
-          /* Add to the path the lisp subdir of the installation
-             dir, if it is accessible.  Note: in out-of-tree builds,
-             this directory is empty save for Makefile.  */
-          tem = Fexpand_file_name (build_string ("lisp"),
+      /* Add site-lisp under the installation dir, if it exists.  */
+      if (!no_site_lisp)
+        {
+          tem = Fexpand_file_name (build_string ("site-lisp"),
                                    Vinstallation_directory);
           tem1 = Ffile_accessible_directory_p (tem);
           if (!NILP (tem1))
             {
               if (NILP (Fmember (tem, lpath)))
-                {
-                  /* We are running uninstalled.  The default load-path
-                     points to the eventual installed lisp directories.
-                     We should not use those now, even if they exist,
-                     so start over from a clean slate.  */
-                  lpath = list1 (tem);
-                }
-            }
-          else
-            /* That dir doesn't exist, so add the build-time
-               Lisp dirs instead.  */
-            {
-              Lisp_Object dump_path =
-                decode_env_path (0, PATH_DUMPLOADSEARCH, 0);
-              lpath = nconc2 (lpath, dump_path);
+                lpath = Fcons (tem, lpath);
             }
+        }
 
-          /* Add site-lisp under the installation dir, if it exists.  */
-          if (!no_site_lisp)
-            {
-              tem = Fexpand_file_name (build_string ("site-lisp"),
-                                       Vinstallation_directory);
-              tem1 = Ffile_accessible_directory_p (tem);
-              if (!NILP (tem1))
-                {
-                  if (NILP (Fmember (tem, lpath)))
-                    lpath = Fcons (tem, lpath);
-                }
-            }
+      /* If Emacs was not built in the source directory,
+         and it is run from where it was built, add to load-path
+         the lisp and site-lisp dirs under that directory.  */
 
-          /* If Emacs was not built in the source directory,
-             and it is run from where it was built, add to load-path
-             the lisp and site-lisp dirs under that directory.  */
+      if (NILP (Fequal (Vinstallation_directory, Vsource_directory)))
+        {
+          Lisp_Object tem2;
 
-          if (NILP (Fequal (Vinstallation_directory, Vsource_directory)))
+          tem = Fexpand_file_name (build_string ("src/Makefile"),
+                                   Vinstallation_directory);
+          tem1 = Ffile_exists_p (tem);
+
+          /* Don't be fooled if they moved the entire source tree
+             AFTER dumping Emacs.  If the build directory is indeed
+             different from the source dir, src/Makefile.in and
+             src/Makefile will not be found together.  */
+          tem = Fexpand_file_name (build_string ("src/Makefile.in"),
+                                   Vinstallation_directory);
+          tem2 = Ffile_exists_p (tem);
+          if (!NILP (tem1) && NILP (tem2))
             {
-              Lisp_Object tem2;
-
-              tem = Fexpand_file_name (build_string ("src/Makefile"),
-                                       Vinstallation_directory);
-              tem1 = Ffile_exists_p (tem);
-
-              /* Don't be fooled if they moved the entire source tree
-                 AFTER dumping Emacs.  If the build directory is indeed
-                 different from the source dir, src/Makefile.in and
-                 src/Makefile will not be found together.  */
-              tem = Fexpand_file_name (build_string ("src/Makefile.in"),
-                                       Vinstallation_directory);
-              tem2 = Ffile_exists_p (tem);
-              if (!NILP (tem1) && NILP (tem2))
-                {
-                  tem = Fexpand_file_name (build_string ("lisp"),
-                                           Vsource_directory);
+              tem = Fexpand_file_name (build_string ("lisp"),
+                                       Vsource_directory);
 
-                  if (NILP (Fmember (tem, lpath)))
-                    lpath = Fcons (tem, lpath);
+              if (NILP (Fmember (tem, lpath)))
+                lpath = Fcons (tem, lpath);
 
-                  if (!no_site_lisp)
+              if (!no_site_lisp)
+                {
+                  tem = Fexpand_file_name (build_string ("site-lisp"),
+                                           Vsource_directory);
+                  tem1 = Ffile_accessible_directory_p (tem);
+                  if (!NILP (tem1))
                     {
-                      tem = Fexpand_file_name (build_string ("site-lisp"),
-                                               Vsource_directory);
-                      tem1 = Ffile_accessible_directory_p (tem);
-                      if (!NILP (tem1))
-                        {
-                          if (NILP (Fmember (tem, lpath)))
-                            lpath = Fcons (tem, lpath);
-                        }
+                      if (NILP (Fmember (tem, lpath)))
+                        lpath = Fcons (tem, lpath);
                     }
                 }
-            } /* Vinstallation_directory != Vsource_directory */
+            }
+        } /* Vinstallation_directory != Vsource_directory */
 
-        } /* if Vinstallation_directory */
-    }
-  else                          /* !initialized */
-    {
-      /* NORMAL refers to PATH_DUMPLOADSEARCH, ie the lisp dir in the
-         source directory.  We used to add ../lisp (ie the lisp dir in
-         the build directory) at the front here, but that should not
-         be necessary, since in out of tree builds lisp/ is empty, save
-         for Makefile.  */
-      lpath = decode_env_path (0, normal, 0);
-    }
-#endif /* !CANNOT_DUMP */
+    } /* if Vinstallation_directory */
 
   return lpath;
 }
@@ -4693,11 +4646,7 @@ init_lread (void)
   /* First, set Vload_path.  */
 
   /* Ignore EMACSLOADPATH when dumping.  */
-#ifdef CANNOT_DUMP
-  bool use_loadpath = true;
-#else
-  bool use_loadpath = NILP (Vpurify_flag);
-#endif
+  bool use_loadpath = !will_dump_p ();
 
   if (use_loadpath && egetenv ("EMACSLOADPATH"))
     {
@@ -4748,7 +4697,7 @@ init_lread (void)
       load_path_check (Vload_path);
 
       /* Add the site-lisp directories at the front.  */
-      if (initialized && !no_site_lisp && PATH_SITELOADSEARCH[0] != '\0')
+      if (!will_dump_p () && !no_site_lisp && PATH_SITELOADSEARCH[0] != '\0')
         {
           Lisp_Object sitelisp;
           sitelisp = decode_env_path (0, PATH_SITELOADSEARCH, 0);
@@ -5062,9 +5011,9 @@ For internal use only.  */);
   DEFSYM (Qlread_unescaped_character_literals,
           "lread--unescaped-character-literals");
 
-  DEFSYM (Qlss, "<");
-  DEFSYM (Qchar, "char");
-  DEFSYM (Qformat, "format");
+  /* Defined in lisp/emacs-lisp/byte-run.el.  */
+  DEFSYM (Qbyte_run_unescaped_character_literals_warning,
+          "byte-run--unescaped-character-literals-warning");
 
   DEFVAR_BOOL ("load-prefer-newer", load_prefer_newer,
                doc: /* Non-nil means `load' prefers the newest version of a 
file.
diff --git a/src/macfont.h b/src/macfont.h
index 4073fce..7065070 100644
--- a/src/macfont.h
+++ b/src/macfont.h
@@ -1,5 +1,5 @@
 /* Interface definition for macOS Core text font backend.
-   Copyright (C) 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/macfont.m b/src/macfont.m
index ee6c173..6cefd00 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -1,5 +1,5 @@
 /* Font driver on macOS Core text.
-   Copyright (C) 2009-2018 Free Software Foundation, Inc.
+   Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -35,6 +35,7 @@ Original author: YAMAMOTO Mitsuharu
 #include "nsterm.h"
 #include "macfont.h"
 #include "macuvs.h"
+#include "pdumper.h"
 
 #include <libkern/OSByteOrder.h>
 
@@ -1037,12 +1038,12 @@ macfont_handle_font_change_notification 
(CFNotificationCenterRef center,
 static void
 macfont_init_font_change_handler (void)
 {
-  static bool initialized = false;
+  static bool xinitialized = false;
 
-  if (initialized)
+  if (xinitialized)
     return;
 
-  initialized = true;
+  xinitialized = true;
   CFNotificationCenterAddObserver
     (CFNotificationCenterGetLocalCenter (), NULL,
      macfont_handle_font_change_notification,
@@ -1654,7 +1655,7 @@ static int macfont_variation_glyphs (struct font *, int c,
                                      unsigned variations[256]);
 static void macfont_filter_properties (Lisp_Object, Lisp_Object);
 
-static struct font_driver const macfont_driver =
+static struct font_driver macfont_driver =
   {
   .type = LISPSYM_INITIALLY (Qmac_ct),
   .get_cache = macfont_get_cache,
@@ -1799,16 +1800,14 @@ macfont_get_open_type_spec (Lisp_Object otf_spec)
   spec->nfeatures[0] = spec->nfeatures[1] = 0;
   for (i = 0; i < 2 && ! NILP (otf_spec); i++, otf_spec = XCDR (otf_spec))
     {
-      Lisp_Object len;
-
       val = XCAR (otf_spec);
       if (NILP (val))
         continue;
-      len = Flength (val);
+      ptrdiff_t len = list_length (val);
       spec->features[i] =
-        (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (int) < XFIXNUM (len)
+        (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (int) < len
          ? 0
-         : malloc (XFIXNUM (len) * sizeof *spec->features[i]));
+         : malloc (len * sizeof *spec->features[i]));
       if (! spec->features[i])
         {
           if (i > 0 && spec->features[0])
@@ -2353,9 +2352,9 @@ macfont_list (struct frame *f, Lisp_Object spec)
                   != (spacing >= FONT_SPACING_MONO)))
             continue;
 
-          /* Don't use a color bitmap font until it is supported on
-            free platforms.  */
-          if (sym_traits & kCTFontTraitColorGlyphs)
+          /* Don't use a color bitmap font unless its family is
+             explicitly specified.  */
+          if ((sym_traits & kCTFontTraitColorGlyphs) && NILP (family))
             continue;
 
           if (j > 0
@@ -4045,12 +4044,14 @@ mac_register_font_driver (struct frame *f)
 }
 
 
+
+static void syms_of_macfont_for_pdumper (void);
+
 void
 syms_of_macfont (void)
 {
   /* Core Text, for macOS.  */
   DEFSYM (Qmac_ct, "mac-ct");
-  register_font_driver (&macfont_driver, NULL);
 
   /* The font property key specifying the font design destination.  The
      value is an unsigned integer code: 0 for WYSIWYG, and 1 for Video
@@ -4065,4 +4066,18 @@ syms_of_macfont (void)
 
   macfont_family_cache = Qnil;
   staticpro (&macfont_family_cache);
+
+  pdumper_do_now_and_after_load (syms_of_macfont_for_pdumper);
+}
+
+static void
+syms_of_macfont_for_pdumper (void)
+{
+  if (dumped_with_pdumper_p ())
+    macfont_family_cache = Qnil;
+  else
+    eassert (NILP (macfont_family_cache));
+
+  macfont_driver.type = Qmac_ct;
+  register_font_driver (&macfont_driver, NULL);
 }
diff --git a/src/macros.c b/src/macros.c
index 0677021..2d927ff 100644
--- a/src/macros.c
+++ b/src/macros.c
@@ -1,6 +1,6 @@
 /* Keyboard macros.
 
-Copyright (C) 1985-1986, 1993, 2000-2018 Free Software Foundation, Inc.
+Copyright (C) 1985-1986, 1993, 2000-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -267,7 +267,7 @@ pop_kbd_macro (Lisp_Object info)
   Lisp_Object tem;
   Vexecuting_kbd_macro = XCAR (info);
   tem = XCDR (info);
-  executing_kbd_macro_index = XFIXNUM (XCAR (tem));
+  integer_to_intmax (XCAR (tem), &executing_kbd_macro_index);
   Vreal_this_command = XCDR (tem);
   run_hook (Qkbd_macro_termination_hook);
 }
@@ -301,7 +301,7 @@ each iteration of the macro.  Iteration stops if LOOPFUNC 
returns nil.  */)
     error ("Keyboard macros must be strings or vectors");
 
   tem = Fcons (Vexecuting_kbd_macro,
-              Fcons (make_fixnum (executing_kbd_macro_index),
+              Fcons (make_int (executing_kbd_macro_index),
                      Vreal_this_command));
   record_unwind_protect (pop_kbd_macro, tem);
 
diff --git a/src/macros.h b/src/macros.h
index c2b1a70..815dd01 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -1,5 +1,5 @@
 /* Definitions for keyboard macro interpretation in GNU Emacs.
-   Copyright (C) 1985, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1985, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/macuvs.h b/src/macuvs.h
index 679e8fa..e83a372 100644
--- a/src/macuvs.h
+++ b/src/macuvs.h
@@ -1,4 +1,5 @@
-/* Automatically generated by uvs.el.  */
+/* This file was automatically generated from admin/unidata/IVD_Sequences.txt
+   by the script admin/unidata/uvs.el  */
 static const unsigned char mac_uvs_table_adobe_japan1_bytes[] =
   {
     0x00, 0x0e, 0x00, 0x01, 0x1f, 0xb2, 0x00, 0x00,
diff --git a/src/marker.c b/src/marker.c
index b9ea5c5..b58051a 100644
--- a/src/marker.c
+++ b/src/marker.c
@@ -1,5 +1,5 @@
 /* Markers: examining, setting and deleting.
-   Copyright (C) 1985, 1997-1998, 2001-2018 Free Software Foundation,
+   Copyright (C) 1985, 1997-1998, 2001-2019 Free Software Foundation,
    Inc.
 
 This file is part of GNU Emacs.
@@ -30,7 +30,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 static ptrdiff_t cached_charpos;
 static ptrdiff_t cached_bytepos;
 static struct buffer *cached_buffer;
-static EMACS_INT cached_modiff;
+static modiff_count cached_modiff;
 
 /* Juanma Barranquero <address@hidden> reported ~3x increased
    bootstrap time when byte_char_debug_check is enabled; so this
diff --git a/src/menu.c b/src/menu.c
index 53272f9..e82c857 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1,6 +1,6 @@
 /* Platform-independent code for terminal communications.
 
-Copyright (C) 1986, 1988, 1993-1994, 1996, 1999-2018 Free Software
+Copyright (C) 1986, 1988, 1993-1994, 1996, 1999-2019 Free Software
 Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -60,9 +60,9 @@ have_boxes (void)
 
 Lisp_Object menu_items;
 
-/* If non-nil, means that the global vars defined here are already in use.
+/* Whether the global vars defined here are already in use.
    Used to detect cases where we try to re-enter this non-reentrant code.  */
-Lisp_Object menu_items_inuse;
+bool menu_items_inuse;
 
 /* Number of slots currently allocated in menu_items.  */
 int menu_items_allocated;
@@ -80,7 +80,7 @@ static int menu_items_submenu_depth;
 void
 init_menu_items (void)
 {
-  if (!NILP (menu_items_inuse))
+  if (menu_items_inuse)
     error ("Trying to use a menu from within a menu-entry");
 
   if (NILP (menu_items))
@@ -89,7 +89,7 @@ init_menu_items (void)
       menu_items = make_nil_vector (menu_items_allocated);
     }
 
-  menu_items_inuse = Qt;
+  menu_items_inuse = true;
   menu_items_used = 0;
   menu_items_n_panes = 0;
   menu_items_submenu_depth = 0;
@@ -105,7 +105,7 @@ finish_menu_items (void)
 void
 unuse_menu_items (void)
 {
-  menu_items_inuse = Qnil;
+  menu_items_inuse = false;
 }
 
 /* Call when finished using the data for the current menu
@@ -121,7 +121,7 @@ discard_menu_items (void)
       menu_items = Qnil;
       menu_items_allocated = 0;
     }
-  eassert (NILP (menu_items_inuse));
+  eassert (!menu_items_inuse);
 }
 
 /* This undoes save_menu_items, and it is called by the specpdl unwind
@@ -131,7 +131,7 @@ static void
 restore_menu_items (Lisp_Object saved)
 {
   menu_items = XCAR (saved);
-  menu_items_inuse = (! NILP (menu_items) ? Qt : Qnil);
+  menu_items_inuse = ! NILP (menu_items);
   menu_items_allocated = (VECTORP (menu_items) ? ASIZE (menu_items) : 0);
   saved = XCDR (saved);
   menu_items_used = XFIXNUM (XCAR (saved));
@@ -147,12 +147,12 @@ restore_menu_items (Lisp_Object saved)
 void
 save_menu_items (void)
 {
-  Lisp_Object saved = list4 (!NILP (menu_items_inuse) ? menu_items : Qnil,
+  Lisp_Object saved = list4 (menu_items_inuse ? menu_items : Qnil,
                             make_fixnum (menu_items_used),
                             make_fixnum (menu_items_n_panes),
                             make_fixnum (menu_items_submenu_depth));
   record_unwind_protect (restore_menu_items, saved);
-  menu_items_inuse = Qnil;
+  menu_items_inuse = false;
   menu_items = Qnil;
 }
 
@@ -170,8 +170,7 @@ ensure_menu_items (int items)
     }
 }
 
-#if (defined USE_X_TOOLKIT || defined USE_GTK || defined HAVE_NS \
-     || defined HAVE_NTGUI)
+#ifdef HAVE_EXT_MENU_BAR
 
 /* Begin a submenu.  */
 
@@ -195,7 +194,7 @@ push_submenu_end (void)
   menu_items_submenu_depth--;
 }
 
-#endif /* USE_X_TOOLKIT || USE_GTK || HAVE_NS || defined HAVE_NTGUI */
+#endif /* HAVE_EXT_MENU_BAR */
 
 /* Indicate boundary between left and right.  */
 
@@ -524,19 +523,15 @@ bool
 parse_single_submenu (Lisp_Object item_key, Lisp_Object item_name,
                      Lisp_Object maps)
 {
-  Lisp_Object length;
-  EMACS_INT len;
   Lisp_Object *mapvec;
-  ptrdiff_t i;
   bool top_level_items = 0;
   USE_SAFE_ALLOCA;
 
-  length = Flength (maps);
-  len = XFIXNUM (length);
+  ptrdiff_t len = list_length (maps);
 
   /* Convert the list MAPS into a vector MAPVEC.  */
   SAFE_ALLOCA_LISP (mapvec, len);
-  for (i = 0; i < len; i++)
+  for (ptrdiff_t i = 0; i < len; i++)
     {
       mapvec[i] = Fcar (maps);
       maps = Fcdr (maps);
@@ -544,7 +539,7 @@ parse_single_submenu (Lisp_Object item_key, Lisp_Object 
item_name,
 
   /* Loop over the given keymaps, making a pane for each map.
      But don't make a pane that is empty--ignore that map instead.  */
-  for (i = 0; i < len; i++)
+  for (ptrdiff_t i = 0; i < len; i++)
     {
       if (!KEYMAPP (mapvec[i]))
        {
@@ -692,7 +687,7 @@ digest_single_submenu (int start, int end, bool 
top_level_items)
 
                  ASET (menu_items, i + MENU_ITEMS_PANE_NAME, pane_name);
                }
-#elif defined (USE_LUCID) && defined (HAVE_XFT)
+#elif defined (USE_LUCID) && (defined USE_CAIRO || defined HAVE_XFT)
              if (STRINGP (pane_name))
                {
                  pane_name = ENCODE_UTF_8 (pane_name);
@@ -1309,7 +1304,7 @@ x_popup_menu_1 (Lisp_Object position, Lisp_Object menu)
   else if (CONSP (menu) && KEYMAPP (XCAR (menu)))
     {
       /* We were given a list of keymaps.  */
-      EMACS_INT nmaps = XFIXNAT (Flength (menu));
+      ptrdiff_t nmaps = list_length (menu);
       Lisp_Object *maps;
       ptrdiff_t i;
       USE_SAFE_ALLOCA;
@@ -1580,9 +1575,8 @@ for instance using the window manager, then this produces 
a quit and
 void
 syms_of_menu (void)
 {
-  staticpro (&menu_items);
   menu_items = Qnil;
-  menu_items_inuse = Qnil;
+  staticpro (&menu_items);
 
   defsubr (&Sx_popup_menu);
   defsubr (&Sx_popup_dialog);
diff --git a/src/menu.h b/src/menu.h
index fa32a86..4412948 100644
--- a/src/menu.h
+++ b/src/menu.h
@@ -1,5 +1,5 @@
 /* Functions to manipulate menus.
-   Copyright (C) 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -35,8 +35,7 @@ extern void discard_menu_items (void);
 extern void save_menu_items (void);
 extern bool parse_single_submenu (Lisp_Object, Lisp_Object, Lisp_Object);
 extern void list_of_panes (Lisp_Object);
-#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NTGUI) \
-  || defined (HAVE_NS)
+#ifdef HAVE_EXT_MENU_BAR
 extern void free_menubar_widget_value_tree (widget_value *);
 extern void update_submenu_strings (widget_value *);
 extern void find_and_call_menu_selection (struct frame *, int,
@@ -48,14 +47,17 @@ extern widget_value *digest_single_submenu (int, int, bool);
 #if defined (HAVE_X_WINDOWS) || defined (MSDOS)
 extern Lisp_Object x_menu_show (struct frame *, int, int, int,
                                Lisp_Object, const char **);
+extern void x_activate_menubar (struct frame *);
 #endif
 #ifdef HAVE_NTGUI
 extern Lisp_Object w32_menu_show (struct frame *, int, int, int,
                                  Lisp_Object, const char **);
+extern void w32_activate_menubar (struct frame *);
 #endif
 #ifdef HAVE_NS
 extern Lisp_Object ns_menu_show (struct frame *, int, int, int,
                                 Lisp_Object, const char **);
+extern void ns_activate_menubar (struct frame *);
 #endif
 extern Lisp_Object tty_menu_show (struct frame *, int, int, int,
                                  Lisp_Object, const char **);
diff --git a/src/mini-gmp-emacs.c b/src/mini-gmp-emacs.c
index 7a1b7ab..051590b 100644
--- a/src/mini-gmp-emacs.c
+++ b/src/mini-gmp-emacs.c
@@ -1,6 +1,6 @@
 /* Tailor mini-gmp.c for GNU Emacs
 
-Copyright 2018 Free Software Foundation, Inc.
+Copyright 2018-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/mini-gmp.c b/src/mini-gmp.c
index c0d5b87..90beb6e 100644
--- a/src/mini-gmp.c
+++ b/src/mini-gmp.c
@@ -2,7 +2,7 @@
 
    Contributed to the GNU project by Niels Möller
 
-Copyright 1991-1997, 1999-2018 Free Software Foundation, Inc.
+Copyright 1991-1997, 1999-2019 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
diff --git a/src/mini-gmp.h b/src/mini-gmp.h
index 27e0c06..2586d32 100644
--- a/src/mini-gmp.h
+++ b/src/mini-gmp.h
@@ -1,6 +1,6 @@
 /* mini-gmp, a minimalistic implementation of a GNU GMP subset.
 
-Copyright 2011-2015, 2017 Free Software Foundation, Inc.
+Copyright 2011-2015, 2017, 2019 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
diff --git a/src/minibuf.c b/src/minibuf.c
index 2b331c6..10fd5e5 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -1,6 +1,6 @@
 /* Minibuffer input and completion.
 
-Copyright (C) 1985-1986, 1993-2018 Free Software Foundation, Inc.
+Copyright (C) 1985-1986, 1993-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -32,6 +32,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "keymap.h"
 #include "sysstdio.h"
 #include "systty.h"
+#include "pdumper.h"
 
 /* List of buffers for use as minibuffers.
    The first element of the list is used for the outermost minibuffer
@@ -780,8 +781,7 @@ read_minibuf_unwind (void)
 
   /* Restore prompt, etc, from outer minibuffer level.  */
   Lisp_Object key_vec = Fcar (minibuf_save_list);
-  eassert (VECTORP (key_vec));
-  this_command_key_count = XFIXNAT (Flength (key_vec));
+  this_command_key_count = ASIZE (key_vec);
   this_command_keys = key_vec;
   minibuf_save_list = Fcdr (minibuf_save_list);
   minibuf_prompt = Fcar (minibuf_save_list);
@@ -995,7 +995,8 @@ the current input method and the setting 
of`enable-multibyte-characters'.  */)
 DEFUN ("read-command", Fread_command, Sread_command, 1, 2, 0,
        doc: /* Read the name of a command and return as a symbol.
 Prompt with PROMPT.  By default, return DEFAULT-VALUE or its first element
-if it is a list.  */)
+if it is a list.  If DEFAULT-VALUE is omitted or nil, and the user enters
+null input, return a symbol whose name is an empty string.  */)
   (Lisp_Object prompt, Lisp_Object default_value)
 {
   Lisp_Object name, default_string;
@@ -1052,20 +1053,21 @@ A user option, or customizable variable, is one for 
which
 }
 
 DEFUN ("read-buffer", Fread_buffer, Sread_buffer, 1, 4, 0,
-       doc: /* Read the name of a buffer and return as a string.
-Prompt with PROMPT.
-Optional second arg DEF is value to return if user enters an empty line.
+       doc: /* Read the name of a buffer and return it as a string.
+Prompt with PROMPT, which should be a string ending with a colon and a space.
+Provides completion on buffer names the user types.
+Optional second arg DEF is value to return if user enters an empty line,
+ instead of that empty string.
  If DEF is a list of default values, return its first element.
-Optional third arg REQUIRE-MATCH determines whether non-existing
- buffer names are allowed.  It has the same meaning as the
+Optional third arg REQUIRE-MATCH has the same meaning as the
  REQUIRE-MATCH argument of `completing-read'.
-The argument PROMPT should be a string ending with a colon and a space.
+Optional arg PREDICATE, if non-nil, is a function limiting the buffers that
+can be considered.  It will be called with each potential candidate, and
+should return non-nil to accept the candidate for completion, nil otherwise.
 If `read-buffer-completion-ignore-case' is non-nil, completion ignores
 case while reading the buffer name.
 If `read-buffer-function' is non-nil, this works by calling it as a
-function, instead of the usual behavior.
-Optional arg PREDICATE if non-nil is a function limiting the buffers that can
-be considered.  */)
+function, instead of the usual behavior.  */)
   (Lisp_Object prompt, Lisp_Object def, Lisp_Object require_match,
    Lisp_Object predicate)
 {
@@ -1199,6 +1201,9 @@ is used to further constrain the set of candidates.  */)
       bucket = AREF (collection, idx);
     }
 
+  if (HASH_TABLE_P (collection))
+    hash_rehash_if_needed (XHASH_TABLE (collection));
+
   while (1)
     {
       /* Get the next element of the alist, obarray, or hash-table.  */
@@ -1783,7 +1788,7 @@ If FLAG is nil, invoke `try-completion'; if it is t, 
invoke
          while (CONSP (bufs) && SREF (XCAR (bufs), 0) == ' ')
            bufs = XCDR (bufs);
          if (NILP (bufs))
-           return (EQ (Flength (res), Flength (Vbuffer_alist))
+           return (list_length (res) == list_length (Vbuffer_alist)
                    /* If all bufs are internal don't strip them out.  */
                    ? res : bufs);
          res = bufs;
@@ -1798,7 +1803,9 @@ If FLAG is nil, invoke `try-completion'; if it is t, 
invoke
   else if (EQ (flag, Qlambda))
     return Ftest_completion (string, Vbuffer_alist, predicate);
   else if (EQ (flag, Qmetadata))
-    return list2 (Qmetadata, Fcons (Qcategory, Qbuffer));
+    return list3 (Qmetadata,
+                  Fcons (Qcategory, Qbuffer),
+                  Fcons (Qcycle_sort_function, Qidentity));
   else
     return Qnil;
 }
@@ -1859,21 +1866,36 @@ If no minibuffer is active, return nil.  */)
 }
 
 
+
+static void init_minibuf_once_for_pdumper (void);
+
 void
 init_minibuf_once (void)
 {
-  Vminibuffer_list = Qnil;
   staticpro (&Vminibuffer_list);
+  pdumper_do_now_and_after_load (init_minibuf_once_for_pdumper);
 }
 
-void
-syms_of_minibuf (void)
+static void
+init_minibuf_once_for_pdumper (void)
 {
+  PDUMPER_IGNORE (minibuf_level);
+  PDUMPER_IGNORE (minibuf_prompt_width);
+
+  /* We run this function on first initialization and whenever we
+     restore from a pdumper image.  pdumper doesn't try to preserve
+     frames, windows, and so on, so reset everything related here.  */
+  Vminibuffer_list = Qnil;
   minibuf_level = 0;
   minibuf_prompt = Qnil;
-  staticpro (&minibuf_prompt);
-
   minibuf_save_list = Qnil;
+  last_minibuf_string = Qnil;
+}
+
+void
+syms_of_minibuf (void)
+{
+  staticpro (&minibuf_prompt);
   staticpro (&minibuf_save_list);
 
   DEFSYM (Qcompletion_ignore_case, "completion-ignore-case");
@@ -1883,7 +1905,6 @@ syms_of_minibuf (void)
   DEFSYM (Qminibuffer_completion_table, "minibuffer-completion-table");
 
   staticpro (&last_minibuf_string);
-  last_minibuf_string = Qnil;
 
   DEFSYM (Qcustom_variable_history, "custom-variable-history");
   Fset (Qcustom_variable_history, Qnil);
@@ -1905,6 +1926,8 @@ syms_of_minibuf (void)
   DEFSYM (Qactivate_input_method, "activate-input-method");
   DEFSYM (Qcase_fold_search, "case-fold-search");
   DEFSYM (Qmetadata, "metadata");
+  DEFSYM (Qcycle_sort_function, "cycle-sort-function");
+
   /* A frame parameter.  */
   DEFSYM (Qminibuffer_exit, "minibuffer-exit");
 
diff --git a/src/module-env-25.h b/src/module-env-25.h
index 675010b..d8f8eb6 100644
--- a/src/module-env-25.h
+++ b/src/module-env-25.h
@@ -88,13 +88,13 @@
     EMACS_ATTRIBUTE_NONNULL(1);
 
   /* Copy the content of the Lisp string VALUE to BUFFER as an utf8
-     null-terminated string.
+     NUL-terminated string.
 
      SIZE must point to the total size of the buffer.  If BUFFER is
      NULL or if SIZE is not big enough, write the required buffer size
      to SIZE and return true.
 
-     Note that SIZE must include the last null byte (e.g. "abc" needs
+     Note that SIZE must include the last NUL byte (e.g. "abc" needs
      a buffer of size 4).
 
      Return true if the string was successfully copied.  */
diff --git a/src/module-env-27.h b/src/module-env-27.h
new file mode 100644
index 0000000..00de300
--- /dev/null
+++ b/src/module-env-27.h
@@ -0,0 +1,18 @@
+  /* Processes pending input events and returns whether the module
+     function should quit.  */
+  enum emacs_process_input_result (*process_input) (emacs_env *env)
+    EMACS_ATTRIBUTE_NONNULL (1);
+
+  struct timespec (*extract_time) (emacs_env *env, emacs_value value)
+    EMACS_ATTRIBUTE_NONNULL (1);
+
+  emacs_value (*make_time) (emacs_env *env, struct timespec time)
+    EMACS_ATTRIBUTE_NONNULL (1);
+
+  void (*extract_big_integer) (emacs_env *env, emacs_value value,
+                               struct emacs_mpz *result)
+    EMACS_ATTRIBUTE_NONNULL (1, 3);
+
+  emacs_value (*make_big_integer) (emacs_env *env,
+                                   const struct emacs_mpz *value)
+    EMACS_ATTRIBUTE_NONNULL (1, 2);
diff --git a/src/msdos.c b/src/msdos.c
index 4031c57..d13f230 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -1,6 +1,6 @@
 /* MS-DOS specific C utilities.          -*- coding: cp850 -*-
 
-Copyright (C) 1993-1997, 1999-2018 Free Software Foundation, Inc.
+Copyright (C) 1993-1997, 1999-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -420,6 +420,9 @@ static unsigned short outside_cursor;
 /* The only display since MS-DOS does not support multiple ones.  */
 struct tty_display_info the_only_display_info;
 
+/* The only tty_output, since MS-DOS supports only 1 display.  */
+struct tty_output the_only_tty_output;
+
 /* Support for DOS/V (allows Japanese characters to be displayed on
    standard, non-Japanese, ATs).  Only supported for DJGPP v2 and later.  */
 
diff --git a/src/msdos.h b/src/msdos.h
index 6b91338..0d15df7 100644
--- a/src/msdos.h
+++ b/src/msdos.h
@@ -1,5 +1,5 @@
 /* MS-DOS specific C utilities, interface.
-   Copyright (C) 1993, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1993, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -93,6 +93,7 @@ typedef int XRectangle;
 typedef struct tty_display_info Display_Info;
 
 extern struct tty_display_info the_only_display_info;
+extern struct tty_output the_only_tty_output;
 
 #define FRAME_X_DISPLAY(f) ((Display *) 0)
 #define FRAME_FONT(f) ((f)->output_data.tty->font)
diff --git a/src/nsfns.m b/src/nsfns.m
index 0ca9743..2470c05 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -1,6 +1,6 @@
 /* Functions for the NeXT/Open/GNUstep and macOS window system.
 
-Copyright (C) 1989, 1992-1994, 2005-2006, 2008-2018 Free Software
+Copyright (C) 1989, 1992-1994, 2005-2006, 2008-2019 Free Software
 Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -49,7 +49,6 @@ GNUstep port and post-20 update by Adrian Robert 
(address@hidden)
 #include "macfont.h"
 #endif
 
-
 #ifdef HAVE_NS
 
 static EmacsTooltip *ns_tooltip = nil;
@@ -234,7 +233,7 @@ interpret_services_menu (NSMenu *menu, Lisp_Object prefix, 
Lisp_Object old)
 
 
 static void
-x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+ns_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   NSColor *col;
   EmacsCGFloat r, g, b, alpha;
@@ -270,7 +269,7 @@ x_set_foreground_color (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
 
 
 static void
-x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+ns_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   struct face *face;
   NSColor *col;
@@ -326,7 +325,7 @@ x_set_background_color (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
 
 
 static void
-x_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+ns_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   NSColor *col;
 
@@ -343,8 +342,8 @@ x_set_cursor_color (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
 
   if (FRAME_VISIBLE_P (f))
     {
-      x_update_cursor (f, 0);
-      x_update_cursor (f, 1);
+      gui_update_cursor (f, 0);
+      gui_update_cursor (f, 1);
     }
   update_face_from_frame_parameter (f, Qcursor_color, arg);
   unblock_input ();
@@ -352,10 +351,10 @@ x_set_cursor_color (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
 
 
 static void
-x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+ns_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   NSView *view = FRAME_NS_VIEW (f);
-  NSTRACE ("x_set_icon_name");
+  NSTRACE ("ns_set_icon_name");
 
   /* See if it's changed.  */
   if (STRINGP (arg))
@@ -509,9 +508,9 @@ ns_set_represented_filename (struct frame *f)
    specified a name for the frame; the name will override any set by the
    redisplay code.  */
 static void
-x_explicitly_set_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+ns_explicitly_set_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
-  NSTRACE ("x_explicitly_set_name");
+  NSTRACE ("ns_explicitly_set_name");
   ns_set_name (f, arg, 1);
 }
 
@@ -520,9 +519,9 @@ x_explicitly_set_name (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
    name; names set this way will never override names set by the user's
    lisp code.  */
 void
-x_implicitly_set_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+ns_implicitly_set_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
-  NSTRACE ("x_implicitly_set_name");
+  NSTRACE ("ns_implicitly_set_name");
 
   if (ns_use_proxy_icon)
     ns_set_represented_filename (f);
@@ -535,9 +534,9 @@ x_implicitly_set_name (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
    If NAME is nil, use the frame name as the title.  */
 
 static void
-x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
+ns_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
 {
-  NSTRACE ("x_set_title");
+  NSTRACE ("ns_set_title");
   /* Don't change the title if it's already NAME.  */
   if (EQ (name, f->title))
     return;
@@ -583,7 +582,7 @@ ns_set_doc_edited (void)
 
 
 static void
-x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
+ns_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
 {
   int nlines;
   if (FRAME_MINIBUF_ONLY_P (f))
@@ -613,7 +612,7 @@ x_set_menu_bar_lines (struct frame *f, Lisp_Object value, 
Lisp_Object oldval)
 
 /* toolbar support */
 static void
-x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
+ns_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
 {
   /* Currently, when the tool bar changes state, the frame is resized.
 
@@ -622,7 +621,7 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, 
Lisp_Object oldval)
      `frame-inhibit-implied-resize'.  */
   int nlines;
 
-  NSTRACE ("x_set_tool_bar_lines");
+  NSTRACE ("ns_set_tool_bar_lines");
 
   if (FRAME_MINIBUF_ONLY_P (f))
     return;
@@ -681,7 +680,7 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, 
Lisp_Object oldval)
 
 
 static void
-x_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval)
+ns_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval)
 {
   int old_width = FRAME_INTERNAL_BORDER_WIDTH (f);
 
@@ -693,7 +692,7 @@ x_set_internal_border_width (struct frame *f, Lisp_Object 
arg, Lisp_Object oldva
   if (FRAME_INTERNAL_BORDER_WIDTH (f) == old_width)
     return;
 
-  if (FRAME_X_WINDOW (f) != 0)
+  if (FRAME_NATIVE_WINDOW (f) != 0)
     adjust_frame_size (f, -1, -1, 3, 0, Qinternal_border_width);
 
   SET_FRAME_GARBAGED (f);
@@ -772,13 +771,13 @@ ns_implicitly_set_icon_type (struct frame *f)
 
 
 static void
-x_set_icon_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+ns_set_icon_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   EmacsView *view = FRAME_NS_VIEW (f);
   id image = nil;
   BOOL setMini = YES;
 
-  NSTRACE ("x_set_icon_type");
+  NSTRACE ("ns_set_icon_type");
 
   if (!NILP (arg) && SYMBOLP (arg))
     {
@@ -812,7 +811,7 @@ x_set_icon_type (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
 
 /* This is the same as the xfns.c definition.  */
 static void
-x_set_cursor_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+ns_set_cursor_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   set_frame_cursor_types (f, arg);
 }
@@ -820,7 +819,7 @@ x_set_cursor_type (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
 /* called to set mouse pointer color, but all other terms use it to
    initialize pointer types (and don't set the color ;) */
 static void
-x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+ns_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   /* Don't think we can do this on Nextstep.  */
 }
@@ -865,7 +864,7 @@ ns_appkit_version_int (void)
 
 
 static void
-x_icon (struct frame *f, Lisp_Object parms)
+ns_icon (struct frame *f, Lisp_Object parms)
 /* --------------------------------------------------------------------------
    Strangely-named function to set icon position parameters in frame.
    This is irrelevant under macOS, but might be needed under GNUstep,
@@ -880,8 +879,10 @@ x_icon (struct frame *f, Lisp_Object parms)
   f->output_data.ns->icon_left = -1;
 
   /* Set the position of the icon.  */
-  icon_x = x_get_arg (dpyinfo, parms, Qicon_left, 0, 0, RES_TYPE_NUMBER);
-  icon_y = x_get_arg (dpyinfo, parms, Qicon_top, 0, 0,  RES_TYPE_NUMBER);
+  icon_x = gui_display_get_arg (dpyinfo, parms, Qicon_left, 0, 0,
+                                RES_TYPE_NUMBER);
+  icon_y = gui_display_get_arg (dpyinfo, parms, Qicon_top, 0, 0,
+                                RES_TYPE_NUMBER);
   if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound))
     {
       CHECK_FIXNUM (icon_x);
@@ -898,56 +899,56 @@ x_icon (struct frame *f, Lisp_Object parms)
    implemented.  */
 frame_parm_handler ns_frame_parm_handlers[] =
 {
-  x_set_autoraise, /* generic OK */
-  x_set_autolower, /* generic OK */
-  x_set_background_color,
+  gui_set_autoraise, /* generic OK */
+  gui_set_autolower, /* generic OK */
+  ns_set_background_color,
   0, /* x_set_border_color,  may be impossible under Nextstep */
   0, /* x_set_border_width,  may be impossible under Nextstep */
-  x_set_cursor_color,
-  x_set_cursor_type,
-  x_set_font, /* generic OK */
-  x_set_foreground_color,
-  x_set_icon_name,
-  x_set_icon_type,
-  x_set_internal_border_width, /* generic OK */
-  x_set_right_divider_width,
-  x_set_bottom_divider_width,
-  x_set_menu_bar_lines,
-  x_set_mouse_color,
-  x_explicitly_set_name,
-  x_set_scroll_bar_width, /* generic OK */
-  x_set_scroll_bar_height, /* generic OK */
-  x_set_title,
-  x_set_unsplittable, /* generic OK */
-  x_set_vertical_scroll_bars, /* generic OK */
-  x_set_horizontal_scroll_bars, /* generic OK */
-  x_set_visibility, /* generic OK */
-  x_set_tool_bar_lines,
+  ns_set_cursor_color,
+  ns_set_cursor_type,
+  gui_set_font, /* generic OK */
+  ns_set_foreground_color,
+  ns_set_icon_name,
+  ns_set_icon_type,
+  ns_set_internal_border_width,
+  gui_set_right_divider_width, /* generic OK */
+  gui_set_bottom_divider_width, /* generic OK */
+  ns_set_menu_bar_lines,
+  ns_set_mouse_color,
+  ns_explicitly_set_name,
+  gui_set_scroll_bar_width, /* generic OK */
+  gui_set_scroll_bar_height, /* generic OK */
+  ns_set_title,
+  gui_set_unsplittable, /* generic OK */
+  gui_set_vertical_scroll_bars, /* generic OK */
+  gui_set_horizontal_scroll_bars, /* generic OK */
+  gui_set_visibility, /* generic OK */
+  ns_set_tool_bar_lines,
   0, /* x_set_scroll_bar_foreground, will ignore (not possible on NS) */
   0, /* x_set_scroll_bar_background,  will ignore (not possible on NS) */
-  x_set_screen_gamma, /* generic OK */
-  x_set_line_spacing, /* generic OK, sets f->extra_line_spacing to int */
-  x_set_left_fringe, /* generic OK */
-  x_set_right_fringe, /* generic OK */
+  gui_set_screen_gamma, /* generic OK */
+  gui_set_line_spacing, /* generic OK, sets f->extra_line_spacing to int */
+  gui_set_left_fringe, /* generic OK */
+  gui_set_right_fringe, /* generic OK */
   0, /* x_set_wait_for_wm, will ignore */
-  x_set_fullscreen, /* generic OK */
-  x_set_font_backend, /* generic OK */
-  x_set_alpha,
+  gui_set_fullscreen, /* generic OK */
+  gui_set_font_backend, /* generic OK */
+  gui_set_alpha,
   0, /* x_set_sticky */
   0, /* x_set_tool_bar_position */
   0, /* x_set_inhibit_double_buffering */
 #ifdef NS_IMPL_COCOA
-  x_set_undecorated,
+  ns_set_undecorated,
 #else
-  0, /* x_set_undecorated */
+  0, /* ns_set_undecorated */
 #endif
-  x_set_parent_frame,
+  ns_set_parent_frame,
   0, /* x_set_skip_taskbar */
-  x_set_no_focus_on_map,
-  x_set_no_accept_focus,
-  x_set_z_group, /* x_set_z_group */
+  ns_set_no_focus_on_map,
+  ns_set_no_accept_focus,
+  ns_set_z_group,
   0, /* x_set_override_redirect */
-  x_set_no_special_glyphs,
+  gui_set_no_special_glyphs,
 #ifdef NS_IMPL_COCOA
   ns_set_appearance,
   ns_set_transparent_titlebar,
@@ -980,14 +981,14 @@ unwind_create_frame (Lisp_Object frame)
         private shadow variable, it means we are unwinding a frame
         for which we didn't yet call init_frame_faces, where the
         refcount is incremented.  Therefore, we increment it here, so
-        that free_frame_faces, called in x_free_frame_resources
+        that free_frame_faces, called in ns_free_frame_resources
         below, will not mistakenly decrement the counter that was not
         incremented yet to account for this new frame.  */
       if (FRAME_IMAGE_CACHE (f) != NULL
          && FRAME_IMAGE_CACHE (f)->refcount == image_cache_refcount)
        FRAME_IMAGE_CACHE (f)->refcount++;
 
-      x_free_frame_resources (f);
+      ns_free_frame_resources (f);
       free_glyphs (f);
 
 #if defined GLYPH_DEBUG && defined ENABLE_CHECKING
@@ -1023,8 +1024,8 @@ get_geometry_from_preferences (struct ns_display_info 
*dpyinfo,
       if (NILP (Fassq (r[i].tem, parms)))
         {
           Lisp_Object value
-            = x_get_arg (dpyinfo, parms, r[i].tem, r[i].val, r[i].cls,
-                         RES_TYPE_NUMBER);
+            = gui_display_get_arg (dpyinfo, parms, r[i].tem, r[i].val, 
r[i].cls,
+                                   RES_TYPE_NUMBER);
           if (! EQ (value, Qunbound))
             parms = Fcons (Fcons (r[i].tem, value), parms);
         }
@@ -1057,14 +1058,15 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
   static int desc_ctr = 1;
   int x_width = 0, x_height = 0;
 
-  /* x_get_arg modifies parms.  */
+  /* gui_display_get_arg modifies parms.  */
   parms = Fcopy_alist (parms);
 
   /* Use this general default value to start with
      until we know if this frame has a specified name.  */
   Vx_resource_name = Vinvocation_name;
 
-  display = x_get_arg (dpyinfo, parms, Qterminal, 0, 0, RES_TYPE_STRING);
+  display = gui_display_get_arg (dpyinfo, parms, Qterminal, 0, 0,
+                                 RES_TYPE_STRING);
   if (EQ (display, Qunbound))
     display = Qnil;
   dpyinfo = check_ns_display_info (display);
@@ -1073,7 +1075,8 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
   if (!dpyinfo->terminal->name)
     error ("Terminal is not live, can't create new frames on it");
 
-  name = x_get_arg (dpyinfo, parms, Qname, 0, 0, RES_TYPE_STRING);
+  name = gui_display_get_arg (dpyinfo, parms, Qname, 0, 0,
+                              RES_TYPE_STRING);
   if (!STRINGP (name)
       && ! EQ (name, Qunbound)
       && ! NILP (name))
@@ -1082,7 +1085,8 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
   if (STRINGP (name))
     Vx_resource_name = name;
 
-  parent = x_get_arg (dpyinfo, parms, Qparent_id, 0, 0, RES_TYPE_NUMBER);
+  parent = gui_display_get_arg (dpyinfo, parms, Qparent_id, 0, 0,
+                                RES_TYPE_NUMBER);
   if (EQ (parent, Qunbound))
     parent = Qnil;
   if (! NILP (parent))
@@ -1092,8 +1096,9 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
   /* No need to protect DISPLAY because that's not used after passing
      it to make_frame_without_minibuffer.  */
   frame = Qnil;
-  tem = x_get_arg (dpyinfo, parms, Qminibuffer, "minibuffer", "Minibuffer",
-                  RES_TYPE_SYMBOL);
+  tem = gui_display_get_arg (dpyinfo, parms, Qminibuffer,
+                             "minibuffer", "Minibuffer",
+                             RES_TYPE_SYMBOL);
   if (EQ (tem, Qnone) || NILP (tem))
       f = make_frame_without_minibuffer (Qnil, kb, display);
   else if (EQ (tem, Qonly))
@@ -1115,9 +1120,9 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
 
   FRAME_FONTSET (f) = -1;
 
-  fset_icon_name (f, x_get_arg (dpyinfo, parms, Qicon_name,
-                               "iconName", "Title",
-                               RES_TYPE_STRING));
+  fset_icon_name (f, gui_display_get_arg (dpyinfo, parms, Qicon_name,
+                                          "iconName", "Title",
+                                          RES_TYPE_STRING));
   if (! STRINGP (f->icon_name))
     fset_icon_name (f, Qnil);
 
@@ -1163,35 +1168,35 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
   image_cache_refcount =
     FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0;
 
-  x_default_parameter (f, parms, Qfont_backend, Qnil,
-                       "fontBackend", "FontBackend", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qfont_backend, Qnil,
+                         "fontBackend", "FontBackend", RES_TYPE_STRING);
 
   {
     /* use for default font name */
     id font = [NSFont userFixedPitchFontOfSize: -1.0]; /* default */
-    x_default_parameter (f, parms, Qfontsize,
-                                    make_fixnum (0 /* (int)[font pointSize] 
*/),
-                                    "fontSize", "FontSize", RES_TYPE_NUMBER);
+    gui_default_parameter (f, parms, Qfontsize,
+                           make_fixnum (0 /* (int)[font pointSize] */),
+                           "fontSize", "FontSize", RES_TYPE_NUMBER);
     // Remove ' Regular', not handled by backends.
     char *fontname = xstrdup ([[font displayName] UTF8String]);
     int len = strlen (fontname);
     if (len > 8 && strcmp (fontname + len - 8, " Regular") == 0)
       fontname[len-8] = '\0';
-    x_default_parameter (f, parms, Qfont,
-                                 build_string (fontname),
-                                 "font", "Font", RES_TYPE_STRING);
+    gui_default_parameter (f, parms, Qfont,
+                           build_string (fontname),
+                           "font", "Font", RES_TYPE_STRING);
     xfree (fontname);
   }
   unblock_input ();
 
-  x_default_parameter (f, parms, Qborder_width, make_fixnum (0),
-                      "borderwidth", "BorderWidth", RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qinternal_border_width, make_fixnum (2),
-                      "internalBorderWidth", "InternalBorderWidth",
-                      RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qright_divider_width, make_fixnum (0),
+  gui_default_parameter (f, parms, Qborder_width, make_fixnum (0),
+                         "borderwidth", "BorderWidth", RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qinternal_border_width, make_fixnum (2),
+                         "internalBorderWidth", "InternalBorderWidth",
+                         RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qright_divider_width, make_fixnum (0),
                       NULL, NULL, RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qbottom_divider_width, make_fixnum (0),
+  gui_default_parameter (f, parms, Qbottom_divider_width, make_fixnum (0),
                       NULL, NULL, RES_TYPE_NUMBER);
 
   /* default vertical scrollbars on right on Mac */
@@ -1202,57 +1207,61 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
 #else
           = Qright;
 #endif
-      x_default_parameter (f, parms, Qvertical_scroll_bars, spos,
-                          "verticalScrollBars", "VerticalScrollBars",
-                          RES_TYPE_SYMBOL);
+      gui_default_parameter (f, parms, Qvertical_scroll_bars, spos,
+                             "verticalScrollBars", "VerticalScrollBars",
+                             RES_TYPE_SYMBOL);
   }
-  x_default_parameter (f, parms, Qhorizontal_scroll_bars, Qnil,
-                      "horizontalScrollBars", "HorizontalScrollBars",
-                      RES_TYPE_SYMBOL);
-  x_default_parameter (f, parms, Qforeground_color, build_string ("Black"),
-                      "foreground", "Foreground", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qbackground_color, build_string ("White"),
-                      "background", "Background", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qline_spacing, Qnil,
-                      "lineSpacing", "LineSpacing", RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qleft_fringe, Qnil,
-                      "leftFringe", "LeftFringe", RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qright_fringe, Qnil,
-                      "rightFringe", "RightFringe", RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qno_special_glyphs, Qnil,
-                      NULL, NULL, RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parms, Qhorizontal_scroll_bars, Qnil,
+                         "horizontalScrollBars", "HorizontalScrollBars",
+                         RES_TYPE_SYMBOL);
+  gui_default_parameter (f, parms, Qforeground_color, build_string ("Black"),
+                         "foreground", "Foreground", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qbackground_color, build_string ("White"),
+                         "background", "Background", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qline_spacing, Qnil,
+                         "lineSpacing", "LineSpacing", RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qleft_fringe, Qnil,
+                         "leftFringe", "LeftFringe", RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qright_fringe, Qnil,
+                         "rightFringe", "RightFringe", RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qno_special_glyphs, Qnil,
+                         NULL, NULL, RES_TYPE_BOOLEAN);
 
   init_frame_faces (f);
 
   /* Read comment about this code in corresponding place in xfns.c.  */
-  tem = x_get_arg (dpyinfo, parms, Qmin_width, NULL, NULL, RES_TYPE_NUMBER);
+  tem = gui_display_get_arg (dpyinfo, parms, Qmin_width, NULL, NULL,
+                             RES_TYPE_NUMBER);
   if (FIXNUMP (tem))
     store_frame_param (f, Qmin_width, tem);
-  tem = x_get_arg (dpyinfo, parms, Qmin_height, NULL, NULL, RES_TYPE_NUMBER);
+  tem = gui_display_get_arg (dpyinfo, parms, Qmin_height, NULL, NULL,
+                             RES_TYPE_NUMBER);
   if (FIXNUMP (tem))
     store_frame_param (f, Qmin_height, tem);
   adjust_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f),
                     FRAME_LINES (f) * FRAME_LINE_HEIGHT (f), 5, 1,
                     Qx_create_frame_1);
 
-  tem = x_get_arg (dpyinfo, parms, Qundecorated, NULL, NULL, RES_TYPE_BOOLEAN);
+  tem = gui_display_get_arg (dpyinfo, parms, Qundecorated, NULL, NULL,
+                             RES_TYPE_BOOLEAN);
   FRAME_UNDECORATED (f) = !NILP (tem) && !EQ (tem, Qunbound);
   store_frame_param (f, Qundecorated, FRAME_UNDECORATED (f) ? Qt : Qnil);
 
 #ifdef NS_IMPL_COCOA
-  tem = x_get_arg (dpyinfo, parms, Qns_appearance, NULL, NULL, 
RES_TYPE_SYMBOL);
+  tem = gui_display_get_arg (dpyinfo, parms, Qns_appearance, NULL, NULL,
+                             RES_TYPE_SYMBOL);
   FRAME_NS_APPEARANCE (f) = EQ (tem, Qdark)
     ? ns_appearance_vibrant_dark : ns_appearance_aqua;
   store_frame_param (f, Qns_appearance, tem);
 
-  tem = x_get_arg (dpyinfo, parms, Qns_transparent_titlebar,
-                   NULL, NULL, RES_TYPE_BOOLEAN);
+  tem = gui_display_get_arg (dpyinfo, parms, Qns_transparent_titlebar,
+                             NULL, NULL, RES_TYPE_BOOLEAN);
   FRAME_NS_TRANSPARENT_TITLEBAR (f) = !NILP (tem) && !EQ (tem, Qunbound);
   store_frame_param (f, Qns_transparent_titlebar, tem);
 #endif
 
-  parent_frame = x_get_arg (dpyinfo, parms, Qparent_frame, NULL, NULL,
-                           RES_TYPE_SYMBOL);
+  parent_frame = gui_display_get_arg (dpyinfo, parms, Qparent_frame, NULL, 
NULL,
+                                      RES_TYPE_SYMBOL);
   /* Accept parent-frame iff parent-id was not specified.  */
   if (!NILP (parent)
       || EQ (parent_frame, Qunbound)
@@ -1264,33 +1273,35 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
   fset_parent_frame (f, parent_frame);
   store_frame_param (f, Qparent_frame, parent_frame);
 
-  x_default_parameter (f, parms, Qz_group, Qnil, NULL, NULL, RES_TYPE_SYMBOL);
-  x_default_parameter (f, parms, Qno_focus_on_map, Qnil,
-                      NULL, NULL, RES_TYPE_BOOLEAN);
-  x_default_parameter (f, parms, Qno_accept_focus, Qnil,
-                       NULL, NULL, RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parms, Qz_group, Qnil, NULL, NULL, 
RES_TYPE_SYMBOL);
+  gui_default_parameter (f, parms, Qno_focus_on_map, Qnil,
+                         NULL, NULL, RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parms, Qno_accept_focus, Qnil,
+                         NULL, NULL, RES_TYPE_BOOLEAN);
 
   /* The resources controlling the menu-bar and tool-bar are
      processed specially at startup, and reflected in the mode
      variables; ignore them here.  */
-  x_default_parameter (f, parms, Qmenu_bar_lines,
-                      NILP (Vmenu_bar_mode)
-                      ? make_fixnum (0) : make_fixnum (1),
-                      NULL, NULL, RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qtool_bar_lines,
-                      NILP (Vtool_bar_mode)
-                      ? make_fixnum (0) : make_fixnum (1),
-                      NULL, NULL, RES_TYPE_NUMBER);
-
-  x_default_parameter (f, parms, Qbuffer_predicate, Qnil, "bufferPredicate",
-                       "BufferPredicate", RES_TYPE_SYMBOL);
-  x_default_parameter (f, parms, Qtitle, Qnil, "title", "Title",
-                       RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qmenu_bar_lines,
+                         NILP (Vmenu_bar_mode)
+                         ? make_fixnum (0) : make_fixnum (1),
+                         NULL, NULL, RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qtool_bar_lines,
+                         NILP (Vtool_bar_mode)
+                         ? make_fixnum (0) : make_fixnum (1),
+                         NULL, NULL, RES_TYPE_NUMBER);
+
+  gui_default_parameter (f, parms, Qbuffer_predicate, Qnil, "bufferPredicate",
+                         "BufferPredicate", RES_TYPE_SYMBOL);
+  gui_default_parameter (f, parms, Qtitle, Qnil, "title", "Title",
+                         RES_TYPE_STRING);
 
   parms = get_geometry_from_preferences (dpyinfo, parms);
-  window_prompting = x_figure_window_size (f, parms, true, &x_width, 
&x_height);
+  window_prompting = gui_figure_window_size (f, parms, true,
+                                             &x_width, &x_height);
 
-  tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
+  tem = gui_display_get_arg (dpyinfo, parms, Qunsplittable, 0, 0,
+                             RES_TYPE_BOOLEAN);
   f->no_split = minibuffer_only || (!EQ (tem, Qunbound) && !NILP (tem));
 
   /* NOTE: on other terms, this is done in set_mouse_color, however this
@@ -1321,7 +1332,7 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
 
   [[EmacsView alloc] initFrameFromEmacs: f];
 
-  x_icon (f, parms);
+  ns_icon (f, parms);
 
   /* ns_display_info does not have a reference_count.  */
   f->terminal->reference_count++;
@@ -1331,28 +1342,28 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
      won't work.  */
   Vframe_list = Fcons (frame, Vframe_list);
 
-  x_default_parameter (f, parms, Qicon_type, Qnil,
-                       "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL);
-
-  x_default_parameter (f, parms, Qauto_raise, Qnil,
-                       "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
-  x_default_parameter (f, parms, Qauto_lower, Qnil,
-                       "autoLower", "AutoLower", RES_TYPE_BOOLEAN);
-  x_default_parameter (f, parms, Qcursor_type, Qbox,
-                       "cursorType", "CursorType", RES_TYPE_SYMBOL);
-  x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
-                       "scrollBarWidth", "ScrollBarWidth",
-                       RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qscroll_bar_height, Qnil,
-                       "scrollBarHeight", "ScrollBarHeight",
-                       RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qalpha, Qnil,
-                       "alpha", "Alpha", RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qfullscreen, Qnil,
-                       "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
-
-  /* Allow x_set_window_size, now.  */
-  f->can_x_set_window_size = true;
+  gui_default_parameter (f, parms, Qicon_type, Qnil,
+                         "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL);
+
+  gui_default_parameter (f, parms, Qauto_raise, Qnil,
+                         "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parms, Qauto_lower, Qnil,
+                         "autoLower", "AutoLower", RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parms, Qcursor_type, Qbox,
+                         "cursorType", "CursorType", RES_TYPE_SYMBOL);
+  gui_default_parameter (f, parms, Qscroll_bar_width, Qnil,
+                         "scrollBarWidth", "ScrollBarWidth",
+                         RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qscroll_bar_height, Qnil,
+                         "scrollBarHeight", "ScrollBarHeight",
+                         RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qalpha, Qnil,
+                         "alpha", "Alpha", RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qfullscreen, Qnil,
+                         "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
+
+  /* Allow set_window_size_hook, now.  */
+  f->can_set_window_size = true;
 
   if (x_width > 0)
     SET_FRAME_WIDTH (f, x_width);
@@ -1366,16 +1377,16 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
     {
       Lisp_Object visibility;
 
-      visibility = x_get_arg (dpyinfo, parms, Qvisibility, 0, 0,
-                              RES_TYPE_SYMBOL);
+      visibility = gui_display_get_arg (dpyinfo, parms, Qvisibility, 0, 0,
+                                        RES_TYPE_SYMBOL);
       if (EQ (visibility, Qunbound))
        visibility = Qt;
 
       if (EQ (visibility, Qicon))
-       x_iconify_frame (f);
+       ns_iconify_frame (f);
       else if (! NILP (visibility))
        {
-         x_make_frame_visible (f);
+         ns_make_frame_visible (f);
          [[FRAME_NS_VIEW (f) window] makeKeyWindow];
        }
       else
@@ -1389,14 +1400,15 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
           || !FRAME_LIVE_P (XFRAME (KVAR (kb, Vdefault_minibuffer_frame)))))
     kset_default_minibuffer_frame (kb, frame);
 
-  /* All remaining specified parameters, which have not been "used"
-     by x_get_arg and friends, now go in the misc. alist of the frame.  */
+  /* All remaining specified parameters, which have not been "used" by
+     gui_display_get_arg and friends, now go in the misc. alist of the
+     frame.  */
   for (tem = parms; CONSP (tem); tem = XCDR (tem))
     if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem))))
       fset_param_alist (f, Fcons (XCAR (tem), f->param_alist));
 
   if (window_prompting & USPosition)
-    x_set_offset (f, f->left_pos, f->top_pos, 1);
+    ns_set_offset (f, f->left_pos, f->top_pos, 1);
 
   /* Make sure windows on this frame appear in calls to next-window
      and similar functions.  */
@@ -1405,21 +1417,6 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
   return unbind_to (count, frame);
 }
 
-void
-x_focus_frame (struct frame *f, bool noactivate)
-{
-  struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
-
-  if (dpyinfo->x_focus_frame != f)
-    {
-      EmacsView *view = FRAME_NS_VIEW (f);
-      block_input ();
-      [NSApp activateIgnoringOtherApps: YES];
-      [[view window] makeKeyAndOrderFront: view];
-      unblock_input ();
-    }
-}
-
 static BOOL
 ns_window_is_ancestor (NSWindow *win, NSWindow *candidate)
 /* Test whether CANDIDATE is an ancestor window of WIN.  */
@@ -1791,7 +1788,7 @@ DEFUN ("x-display-mm-height", Fx_display_mm_height, 
Sx_display_mm_height, 0, 1,
 {
   struct ns_display_info *dpyinfo = check_ns_display_info (terminal);
 
-  return make_fixnum (x_display_pixel_height (dpyinfo) / (92.0/25.4));
+  return make_fixnum (ns_display_pixel_height (dpyinfo) / (92.0/25.4));
 }
 
 
@@ -1801,7 +1798,7 @@ DEFUN ("x-display-mm-width", Fx_display_mm_width, 
Sx_display_mm_width, 0, 1, 0,
 {
   struct ns_display_info *dpyinfo = check_ns_display_info (terminal);
 
-  return make_fixnum (x_display_pixel_width (dpyinfo) / (92.0/25.4));
+  return make_fixnum (ns_display_pixel_width (dpyinfo) / (92.0/25.4));
 }
 
 
@@ -2231,7 +2228,7 @@ check_x_display_info (Lisp_Object frame)
 
 
 void
-x_set_scroll_bar_default_width (struct frame *f)
+ns_set_scroll_bar_default_width (struct frame *f)
 {
   int wid = FRAME_COLUMN_WIDTH (f);
   FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = NS_SCROLL_BAR_WIDTH_DEFAULT;
@@ -2240,7 +2237,7 @@ x_set_scroll_bar_default_width (struct frame *f)
 }
 
 void
-x_set_scroll_bar_default_height (struct frame *f)
+ns_set_scroll_bar_default_height (struct frame *f)
 {
   int height = FRAME_LINE_HEIGHT (f);
   FRAME_CONFIG_SCROLL_BAR_HEIGHT (f) = NS_SCROLL_BAR_WIDTH_DEFAULT;
@@ -2249,8 +2246,8 @@ x_set_scroll_bar_default_height (struct frame *f)
 }
 
 /* Terms implement this instead of x-get-resource directly.  */
-char *
-x_get_string_resource (XrmDatabase rdb, const char *name, const char *class)
+const char *
+ns_get_string_resource (void *_rdb, const char *name, const char *class)
 {
   /* remove appname prefix; TODO: allow for !="Emacs" */
   const char *res, *toCheck = class + (!strncmp (class, "Emacs.", 6) ? 6 : 0);
@@ -2262,24 +2259,10 @@ x_get_string_resource (XrmDatabase rdb, const char 
*name, const char *class)
     return NULL;
 
   res = ns_get_defaults_value (toCheck);
-  return (char *) (!res ? NULL
-                  : !c_strncasecmp (res, "YES", 3) ? "true"
-                  : !c_strncasecmp (res, "NO", 2) ? "false"
-                  : res);
-}
-
-
-Lisp_Object
-x_get_focus_frame (struct frame *frame)
-{
-  struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (frame);
-  Lisp_Object nsfocus;
-
-  if (!dpyinfo->x_focus_frame)
-    return Qnil;
-
-  XSETFRAME (nsfocus, dpyinfo->x_focus_frame);
-  return nsfocus;
+  return (const char *) (!res ? NULL
+                         : !c_strncasecmp (res, "YES", 3) ? "true"
+                         : !c_strncasecmp (res, "NO", 2) ? "false"
+                         : res);
 }
 
 /* ==========================================================================
@@ -2362,7 +2345,7 @@ DEFUN ("x-display-pixel-width", Fx_display_pixel_width, 
Sx_display_pixel_width,
 {
   struct ns_display_info *dpyinfo = check_ns_display_info (terminal);
 
-  return make_fixnum (x_display_pixel_width (dpyinfo));
+  return make_fixnum (ns_display_pixel_width (dpyinfo));
 }
 
 
@@ -2373,7 +2356,7 @@ DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
 {
   struct ns_display_info *dpyinfo = check_ns_display_info (terminal);
 
-  return make_fixnum (x_display_pixel_height (dpyinfo));
+  return make_fixnum (ns_display_pixel_height (dpyinfo));
 }
 
 #ifdef NS_IMPL_COCOA
@@ -2660,7 +2643,7 @@ compute_tip_xy (struct frame *f,
     {
       /* Absolute coordinates.  */
       pt.x = FIXNUMP (left) ? XFIXNUM (left) : XFIXNUM (right);
-      pt.y = (x_display_pixel_height (FRAME_DISPLAY_INFO (f))
+      pt.y = (ns_display_pixel_height (FRAME_DISPLAY_INFO (f))
              - (FIXNUMP (top) ? XFIXNUM (top) : XFIXNUM (bottom))
              - height);
     }
@@ -2749,11 +2732,13 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
   else
     Fx_hide_tip ();
 
-  t = x_get_arg (NULL, parms, Qbackground_color, NULL, NULL, RES_TYPE_STRING);
+  t = gui_display_get_arg (NULL, parms, Qbackground_color, NULL, NULL,
+                           RES_TYPE_STRING);
   if (ns_lisp_to_color (t, &color) == 0)
     [ns_tooltip setBackgroundColor: color];
 
-  t = x_get_arg (NULL, parms, Qforeground_color, NULL, NULL, RES_TYPE_STRING);
+  t = gui_display_get_arg (NULL, parms, Qforeground_color, NULL, NULL,
+                           RES_TYPE_STRING);
   if (ns_lisp_to_color (t, &color) == 0)
     [ns_tooltip setForegroundColor: color];
 
@@ -2812,23 +2797,20 @@ frame_geometry (Lisp_Object frame, Lisp_Object 
attribute)
 
   /* Construct list.  */
   if (EQ (attribute, Qouter_edges))
-    return list4 (make_fixnum (f->left_pos), make_fixnum (f->top_pos),
-                 make_fixnum (f->left_pos + outer_width),
-                 make_fixnum (f->top_pos + outer_height));
+    return list4i (f->left_pos, f->top_pos,
+                  f->left_pos + outer_width,
+                  f->top_pos + outer_height);
   else if (EQ (attribute, Qnative_edges))
-    return list4 (make_fixnum (native_left), make_fixnum (native_top),
-                 make_fixnum (native_right), make_fixnum (native_bottom));
+    return list4i (native_left, native_top,
+                  native_right, native_bottom);
   else if (EQ (attribute, Qinner_edges))
-    return list4 (make_fixnum (native_left + internal_border_width),
-                 make_fixnum (native_top
-                              + tool_bar_height
-                              + internal_border_width),
-                 make_fixnum (native_right - internal_border_width),
-                 make_fixnum (native_bottom - internal_border_width));
+    return list4i (native_left + internal_border_width,
+                  native_top + tool_bar_height + internal_border_width,
+                  native_right - internal_border_width,
+                  native_bottom - internal_border_width);
   else
     return
-      listn (CONSTYPE_HEAP, 10,
-            Fcons (Qouter_position,
+       list (Fcons (Qouter_position,
                    Fcons (make_fixnum (f->left_pos),
                           make_fixnum (f->top_pos))),
             Fcons (Qouter_size,
@@ -3125,7 +3107,6 @@ handlePanelKeys (NSSavePanel *panel, NSEvent *theEvent)
 
    ========================================================================== 
*/
 
-
 void
 syms_of_nsfns (void)
 {
@@ -3215,5 +3196,6 @@ Default is t.  */);
 
   as_status = 0;
   as_script = Qnil;
+  staticpro (&as_script);
   as_result = 0;
 }
diff --git a/src/nsfont.m b/src/nsfont.m
index b1ebb53..9721e48 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -1,6 +1,6 @@
 /* Font back-end driver for the NeXT/Open/GNUstep and macOS window system.
    See font.h
-   Copyright (C) 2006-2018 Free Software Foundation, Inc.
+   Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -36,6 +36,7 @@ Author: Adrian Robert (address@hidden)
 #include "character.h"
 #include "font.h"
 #include "termchar.h"
+#include "pdumper.h"
 
 /* TODO: Drop once we can assume gnustep-gui 0.17.1.  */
 #ifdef NS_IMPL_GNUSTEP
@@ -576,7 +577,7 @@ ns_findfonts (Lisp_Object font_spec, BOOL isMatch)
 
     /* Add synthItal member if needed.  */
     family = [fdesc objectForKey: NSFontFamilyAttribute];
-    if (family != nil && !foundItal && XFIXNUM (Flength (list)) > 0)
+    if (family != nil && !foundItal && !NILP (list))
       {
         NSFontDescriptor *s1 = [NSFontDescriptor new];
         NSFontDescriptor *sDesc
@@ -595,8 +596,8 @@ ns_findfonts (Lisp_Object font_spec, BOOL isMatch)
       return ns_fallback_entity ();
 
     if (NSFONT_TRACE)
-       fprintf (stderr, "    Returning %"pI"d entities.\n",
-                 XFIXNUM (Flength (list)));
+       fprintf (stderr, "    Returning %"pD"d entities.\n",
+                list_length (list));
 
     return list;
 }
@@ -667,8 +668,8 @@ nsfont_list_family (struct frame *f)
   /* FIXME: escape the name?  */
 
   if (NSFONT_TRACE)
-    fprintf (stderr, "nsfont: list families returning %"pI"d entries\n",
-            XFIXNUM (Flength (list)));
+    fprintf (stderr, "nsfont: list families returning %"pD"d entries\n",
+            list_length (list));
 
   unblock_input ();
   return list;
@@ -1483,6 +1484,8 @@ ns_dump_glyphstring (struct glyph_string *s)
   fprintf (stderr, "\n");
 }
 
+static void syms_of_nsfont_for_pdumper (void);
+
 struct font_driver const nsfont_driver =
   {
   .type = LISPSYM_INITIALLY (Qns),
@@ -1502,13 +1505,17 @@ struct font_driver const nsfont_driver =
 void
 syms_of_nsfont (void)
 {
-  register_font_driver (&nsfont_driver, NULL);
   DEFSYM (Qcondensed, "condensed");
   DEFSYM (Qexpanded, "expanded");
   DEFSYM (Qapple, "apple");
   DEFSYM (Qmedium, "medium");
   DEFVAR_LISP ("ns-reg-to-script", Vns_reg_to_script,
                doc: /* Internal use: maps font registry to Unicode script.  
*/);
+  pdumper_do_now_and_after_load (syms_of_nsfont_for_pdumper);
+}
 
-  ascii_printable = NULL;
+static void
+syms_of_nsfont_for_pdumper (void)
+{
+  register_font_driver (&nsfont_driver, NULL);
 }
diff --git a/src/nsgui.h b/src/nsgui.h
index f858fa7..c147f4d 100644
--- a/src/nsgui.h
+++ b/src/nsgui.h
@@ -1,5 +1,5 @@
 /* Definitions and headers for communication on the NeXT/Open/GNUstep API.
-   Copyright (C) 1995, 2005, 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 1995, 2005, 2008-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -117,9 +117,6 @@ typedef void * Color;
 typedef int Window;
 typedef int Display;
 
-/* Xism */
-typedef Lisp_Object XrmDatabase;
-
 
 /* Some sort of attempt to normalize rectangle handling.  Seems a bit
    much for what is accomplished.  */
diff --git a/src/nsimage.m b/src/nsimage.m
index 0ae1b88..33236c4 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -1,5 +1,5 @@
 /* Image support for the NeXT/Open/GNUstep and macOS window system.
-   Copyright (C) 1989, 1992-1994, 2005-2006, 2008-2018 Free Software
+   Copyright (C) 1989, 1992-1994, 2005-2006, 2008-2019 Free Software
    Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -126,8 +126,6 @@ ns_load_image (struct frame *f, struct image *img,
       eImg = temp;
     }
 
-  [eImg setSizeFromSpec:XCDR (img->spec)];
-
   size = [eImg size];
   img->width = size.width;
   img->height = size.height;
@@ -151,6 +149,12 @@ ns_image_height (void *img)
   return [(id)img size].height;
 }
 
+void
+ns_image_set_size (void *img, int width, int height)
+{
+  [(EmacsImage *)img setSize:NSMakeSize (width, height)];
+}
+
 unsigned long
 ns_get_pixel (void *img, int x, int y)
 {
@@ -189,7 +193,7 @@ ns_set_alpha (void *img, int x, int y, unsigned char a)
   EmacsImage *image;
 
   /* Search bitmap-file-path for the file, if appropriate.  */
-  found = x_find_image_file (file);
+  found = image_find_image_file (file);
   if (!STRINGP (found))
     return nil;
   found = ENCODE_FILE (found);
@@ -524,66 +528,6 @@ ns_set_alpha (void *img, int x, int y, unsigned char a)
   return YES;
 }
 
-- (void)setSizeFromSpec: (Lisp_Object) spec
-{
-  NSSize size = [self size];
-  Lisp_Object value;
-  double scale = 1, aspect = size.width / size.height;
-  double width = -1, height = -1, max_width = -1, max_height = -1;
-
-  value = Fplist_get (spec, QCscale);
-  if (NUMBERP (value))
-    scale = XFLOATINT (value) ;
-
-  value = Fplist_get (spec, QCmax_width);
-  if (NUMBERP (value))
-    max_width = XFLOATINT (value);
-
-  value = Fplist_get (spec, QCmax_height);
-  if (NUMBERP (value))
-    max_height = XFLOATINT (value);
-
-  value = Fplist_get (spec, QCwidth);
-  if (NUMBERP (value))
-    {
-      width = XFLOATINT (value) * scale;
-      /* :width overrides :max-width. */
-      max_width = -1;
-    }
-
-  value = Fplist_get (spec, QCheight);
-  if (NUMBERP (value))
-    {
-      height = XFLOATINT (value) * scale;
-      /* :height overrides :max-height. */
-      max_height = -1;
-    }
-
-  if (width <= 0 && height <= 0)
-    {
-      width = size.width * scale;
-      height = size.height * scale;
-    }
-  else if (width > 0 && height <= 0)
-      height = width / aspect;
-  else if (height > 0 && width <= 0)
-      width = height * aspect;
-
-  if (max_width > 0 && width > max_width)
-    {
-      width = max_width;
-      height = max_width / aspect;
-    }
-
-  if (max_height > 0 && height > max_height)
-    {
-      height = max_height;
-      width = max_height * aspect;
-    }
-
-  [self setSize:NSMakeSize(width, height)];
-}
-
 - (instancetype)rotate: (double)rotation
 {
   EmacsImage *new_image;
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 983e777..fd13233 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -1,5 +1,5 @@
 /* NeXT/Open/GNUstep and macOS Cocoa menu and toolbar module.
-   Copyright (C) 2007-2018 Free Software Foundation, Inc.
+   Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -37,6 +37,7 @@ Carbon version by Yamamoto Mitsuharu. */
 #include "termhooks.h"
 #include "keyboard.h"
 #include "menu.h"
+#include "pdumper.h"
 
 #define NSMENUPROFILE 0
 
@@ -469,7 +470,7 @@ set_frame_menubar (struct frame *f, bool first_time, bool 
deep_p)
 }
 
 void
-x_activate_menubar (struct frame *f)
+ns_activate_menubar (struct frame *f)
 {
 #ifdef NS_IMPL_COCOA
   ns_update_menubar (f, true, nil);
@@ -1893,6 +1894,7 @@ syms_of_nsmenu (void)
   /* Don't know how to keep track of this in Next/Open/GNUstep.  Always
      update menus there.  */
   trackingMenu = 1;
+  PDUMPER_REMEMBER_SCALAR (trackingMenu);
 #endif
   defsubr (&Sns_reset_menu);
   defsubr (&Smenu_or_popup_active_p);
diff --git a/src/nsselect.m b/src/nsselect.m
index 35705bf..cf36c86 100644
--- a/src/nsselect.m
+++ b/src/nsselect.m
@@ -1,5 +1,5 @@
 /* NeXT/Open/GNUstep / macOS Cocoa selection processing for emacs.
-   Copyright (C) 1993-1994, 2005-2006, 2008-2018 Free Software
+   Copyright (C) 1993-1994, 2005-2006, 2008-2019 Free Software
    Foundation, Inc.
 
 This file is part of GNU Emacs.
diff --git a/src/nsterm.h b/src/nsterm.h
index 23460ab..683f2dd 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -1,5 +1,5 @@
 /* Definitions and headers for communication with NeXT/Open/GNUstep API.
-   Copyright (C) 1989, 1993, 2005, 2008-2018 Free Software Foundation,
+   Copyright (C) 1989, 1993, 2005, 2008-2019 Free Software Foundation,
    Inc.
 
 This file is part of GNU Emacs.
@@ -648,7 +648,6 @@ typedef id instancetype;
 - (NSColor *)stippleMask;
 - (Lisp_Object)getMetadata;
 - (BOOL)setFrame: (unsigned int) index;
-- (void)setSizeFromSpec: (Lisp_Object) spec;
 - (instancetype)rotate: (double)rotation;
 @end
 
@@ -870,7 +869,7 @@ struct ns_display_info
   Window root_window;
 
   /* Xism */
-  XrmDatabase xrdb;
+  Lisp_Object rdb;
 
   /* The cursor to use for vertical scroll bars.  */
   Cursor vertical_scroll_bar_cursor;
@@ -882,8 +881,8 @@ struct ns_display_info
      mouse-face.  */
   Mouse_HLInfo mouse_highlight;
 
-  struct frame *x_highlight_frame;
-  struct frame *x_focus_frame;
+  struct frame *highlight_frame;
+  struct frame *ns_focus_frame;
 
   /* The frame where the mouse was last time we reported a mouse event.  */
   struct frame *last_mouse_frame;
@@ -994,9 +993,9 @@ struct x_output
 
 /* This gives the ns_display_info structure for the display F is on.  */
 #define FRAME_DISPLAY_INFO(f) ((f)->output_data.ns->display_info)
-#define FRAME_X_OUTPUT(f) ((f)->output_data.ns)
+#define FRAME_OUTPUT_DATA(f) ((f)->output_data.ns)
 #define FRAME_NS_WINDOW(f) ((f)->output_data.ns->window_desc)
-#define FRAME_X_WINDOW(f) ((f)->output_data.ns->window_desc)
+#define FRAME_NATIVE_WINDOW(f) FRAME_NS_WINDOW (f)
 
 /* This is the `Display *' which frame F is on.  */
 #define FRAME_NS_DISPLAY(f) (0)
@@ -1123,6 +1122,9 @@ extern Lisp_Object ns_list_fonts (struct frame *f, 
Lisp_Object pattern,
                                   int size, int maxnames);
 extern void ns_clear_frame (struct frame *f);
 
+extern void ns_set_offset (struct frame *f, int xoff, int yoff,
+                           int change_grav);
+
 extern const char *ns_xlfd_to_fontname (const char *xlfd);
 
 extern Lisp_Object ns_map_event_to_object (void);
@@ -1141,7 +1143,7 @@ ns_defined_color (struct frame *f,
                   XColor *color_def, bool alloc,
                   bool makeIndex);
 extern void
-ns_query_color (void *col, XColor *color_def, int setPixel);
+ns_query_color (void *col, XColor *color_def, bool setPixel);
 
 #ifdef __OBJC__
 extern int ns_lisp_to_color (Lisp_Object color, NSColor **col);
@@ -1152,6 +1154,15 @@ extern void ns_check_menu_open (NSMenu *menu);
 extern void ns_check_pending_open_menu (void);
 #endif
 
+/* Implemented in nsfns, published in nsterm.  */
+extern void ns_implicitly_set_name (struct frame *f, Lisp_Object arg,
+                                    Lisp_Object oldval);
+extern void ns_set_scroll_bar_default_width (struct frame *f);
+extern void ns_set_scroll_bar_default_height (struct frame *f);
+extern const char *ns_get_string_resource (void *_rdb,
+                                           const char *name,
+                                           const char *class);
+
 /* C access to ObjC functionality */
 extern void  ns_release_object (void *obj);
 extern void  ns_retain_object (void *obj);
@@ -1173,6 +1184,8 @@ extern Lisp_Object find_and_return_menu_selection (struct 
frame *f,
 extern Lisp_Object ns_popup_dialog (struct frame *, Lisp_Object header,
                                     Lisp_Object contents);
 
+extern void ns_free_frame_resources (struct frame *);
+
 #define NSAPP_DATA2_RUNASSCRIPT 10
 extern void ns_run_ascript (void);
 
@@ -1197,26 +1210,28 @@ extern bool ns_load_image (struct frame *f, struct 
image *img,
                           Lisp_Object spec_file, Lisp_Object spec_data);
 extern int ns_image_width (void *img);
 extern int ns_image_height (void *img);
+extern void ns_image_set_size (void *img, int width, int height);
 extern unsigned long ns_get_pixel (void *img, int x, int y);
 extern void ns_put_pixel (void *img, int x, int y, unsigned long argb);
 extern void ns_set_alpha (void *img, int x, int y, unsigned char a);
 
-extern int x_display_pixel_height (struct ns_display_info *);
-extern int x_display_pixel_width (struct ns_display_info *);
+extern int ns_display_pixel_height (struct ns_display_info *);
+extern int ns_display_pixel_width (struct ns_display_info *);
 
 /* This in nsterm.m */
 extern float ns_antialias_threshold;
-extern void x_destroy_window (struct frame *f);
-extern void x_set_undecorated (struct frame *f, Lisp_Object new_value,
-                               Lisp_Object old_value);
-extern void x_set_parent_frame (struct frame *f, Lisp_Object new_value,
+extern void ns_make_frame_visible (struct frame *f);
+extern void ns_iconify_frame (struct frame *f);
+extern void ns_set_undecorated (struct frame *f, Lisp_Object new_value,
                                 Lisp_Object old_value);
-extern void x_set_no_focus_on_map (struct frame *f, Lisp_Object new_value,
-                                   Lisp_Object old_value);
-extern void x_set_no_accept_focus (struct frame *f, Lisp_Object new_value,
-                                   Lisp_Object old_value);
-extern void x_set_z_group (struct frame *f, Lisp_Object new_value,
-                           Lisp_Object old_value);
+extern void ns_set_parent_frame (struct frame *f, Lisp_Object new_value,
+                                 Lisp_Object old_value);
+extern void ns_set_no_focus_on_map (struct frame *f, Lisp_Object new_value,
+                                    Lisp_Object old_value);
+extern void ns_set_no_accept_focus (struct frame *f, Lisp_Object new_value,
+                                    Lisp_Object old_value);
+extern void ns_set_z_group (struct frame *f, Lisp_Object new_value,
+                            Lisp_Object old_value);
 #ifdef NS_IMPL_COCOA
 extern void ns_set_appearance (struct frame *f, Lisp_Object new_value,
                                Lisp_Object old_value);
diff --git a/src/nsterm.m b/src/nsterm.m
index 6c285f0..cdf1916 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1,6 +1,6 @@
 /* NeXT/Open/GNUstep / macOS communication module.      -*- coding: utf-8 -*-
 
-Copyright (C) 1989, 1993-1994, 2005-2006, 2008-2018 Free Software
+Copyright (C) 1989, 1993-1994, 2005-2006, 2008-2019 Free Software
 Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -60,6 +60,7 @@ GNUstep port and post-20 update by Adrian Robert 
(address@hidden)
 #include "keyboard.h"
 #include "buffer.h"
 #include "font.h"
+#include "pdumper.h"
 
 #ifdef NS_IMPL_GNUSTEP
 #include "process.h"
@@ -499,7 +500,7 @@ append2 (Lisp_Object list, Lisp_Object item)
    Utility to append to a list
    -------------------------------------------------------------------------- 
*/
 {
-  return CALLN (Fnconc, list, list1 (item));
+  return nconc2 (list, list (item));
 }
 
 
@@ -697,7 +698,7 @@ ns_release_autorelease_pool (void *pool)
    NSDisableScreenUpdates.
 
    We use these functions to prevent the user seeing a blank frame
-   after it has been resized.  x_set_window_size disables updates and
+   after it has been resized.  ns_set_window_size disables updates and
    when redisplay completes unwind_redisplay enables them again
    (bug#30699).  */
 
@@ -1182,9 +1183,9 @@ ns_update_window_end (struct window *w, bool cursor_on_p,
       if (draw_window_fringes (w, 1))
        {
          if (WINDOW_RIGHT_DIVIDER_WIDTH (w))
-           x_draw_right_divider (w);
+           gui_draw_right_divider (w);
          else
-           x_draw_vertical_border (w);
+           gui_draw_vertical_border (w);
        }
 
       unblock_input ();
@@ -1443,6 +1444,40 @@ hide_bell (void)
 
    ========================================================================== 
*/
 
+static Lisp_Object
+ns_get_focus_frame (struct frame *f)
+/* --------------------------------------------------------------------------
+     External (hook)
+   -------------------------------------------------------------------------- 
*/
+{
+  Lisp_Object lisp_focus;
+
+  struct frame *focus =  FRAME_DISPLAY_INFO (f)->ns_focus_frame;
+
+  if (!focus)
+    return Qnil;
+
+  XSETFRAME (lisp_focus, focus);
+  return lisp_focus;
+}
+
+static void
+ns_focus_frame (struct frame *f, bool noactivate)
+/* --------------------------------------------------------------------------
+     External (hook)
+   -------------------------------------------------------------------------- 
*/
+{
+  struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
+
+  if (dpyinfo->ns_focus_frame != f)
+    {
+      EmacsView *view = FRAME_NS_VIEW (f);
+      block_input ();
+      [NSApp activateIgnoringOtherApps: YES];
+      [[view window] makeKeyAndOrderFront: view];
+      unblock_input ();
+    }
+}
 
 static void
 ns_raise_frame (struct frame *f, BOOL make_key)
@@ -1496,6 +1531,7 @@ ns_frame_raise_lower (struct frame *f, bool raise)
     ns_lower_frame (f);
 }
 
+static void ns_set_frame_alpha (struct frame *f);
 
 static void
 ns_frame_rehighlight (struct frame *frame)
@@ -1504,48 +1540,48 @@ ns_frame_rehighlight (struct frame *frame)
    -------------------------------------------------------------------------- 
*/
 {
   struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (frame);
-  struct frame *old_highlight = dpyinfo->x_highlight_frame;
+  struct frame *old_highlight = dpyinfo->highlight_frame;
 
   NSTRACE ("ns_frame_rehighlight");
-  if (dpyinfo->x_focus_frame)
+  if (dpyinfo->ns_focus_frame)
     {
-      dpyinfo->x_highlight_frame
-       = (FRAMEP (FRAME_FOCUS_FRAME (dpyinfo->x_focus_frame))
-           ? XFRAME (FRAME_FOCUS_FRAME (dpyinfo->x_focus_frame))
-           : dpyinfo->x_focus_frame);
-      if (!FRAME_LIVE_P (dpyinfo->x_highlight_frame))
+      dpyinfo->highlight_frame
+       = (FRAMEP (FRAME_FOCUS_FRAME (dpyinfo->ns_focus_frame))
+           ? XFRAME (FRAME_FOCUS_FRAME (dpyinfo->ns_focus_frame))
+           : dpyinfo->ns_focus_frame);
+      if (!FRAME_LIVE_P (dpyinfo->highlight_frame))
         {
-          fset_focus_frame (dpyinfo->x_focus_frame, Qnil);
-          dpyinfo->x_highlight_frame = dpyinfo->x_focus_frame;
+          fset_focus_frame (dpyinfo->ns_focus_frame, Qnil);
+          dpyinfo->highlight_frame = dpyinfo->ns_focus_frame;
         }
     }
   else
-      dpyinfo->x_highlight_frame = 0;
+      dpyinfo->highlight_frame = 0;
 
-  if (dpyinfo->x_highlight_frame &&
-         dpyinfo->x_highlight_frame != old_highlight)
+  if (dpyinfo->highlight_frame &&
+         dpyinfo->highlight_frame != old_highlight)
     {
       if (old_highlight)
        {
-          x_update_cursor (old_highlight, 1);
-         x_set_frame_alpha (old_highlight);
+          gui_update_cursor (old_highlight, 1);
+         ns_set_frame_alpha (old_highlight);
        }
-      if (dpyinfo->x_highlight_frame)
+      if (dpyinfo->highlight_frame)
        {
-          x_update_cursor (dpyinfo->x_highlight_frame, 1);
-          x_set_frame_alpha (dpyinfo->x_highlight_frame);
+          gui_update_cursor (dpyinfo->highlight_frame, 1);
+          ns_set_frame_alpha (dpyinfo->highlight_frame);
        }
     }
 }
 
 
 void
-x_make_frame_visible (struct frame *f)
+ns_make_frame_visible (struct frame *f)
 /* --------------------------------------------------------------------------
      External: Show the window (X11 semantics)
    -------------------------------------------------------------------------- 
*/
 {
-  NSTRACE ("x_make_frame_visible");
+  NSTRACE ("ns_make_frame_visible");
   /* XXX: at some points in past this was not needed, as the only place that
      called this (frame.c:Fraise_frame ()) also called raise_lower;
      if this ends up the case again, comment this out again.  */
@@ -1584,20 +1620,20 @@ x_make_frame_visible (struct frame *f)
           /* If the parent frame moved while the child frame was
              invisible, the child frame's position won't have been
              updated.  Make sure it's in the right place now.  */
-          x_set_offset(f, f->left_pos, f->top_pos, 0);
+          ns_set_offset(f, f->left_pos, f->top_pos, 0);
         }
     }
 }
 
 
-void
-x_make_frame_invisible (struct frame *f)
+static void
+ns_make_frame_invisible (struct frame *f)
 /* --------------------------------------------------------------------------
-     External: Hide the window (X11 semantics)
+     Hide the window (X11 semantics)
    -------------------------------------------------------------------------- 
*/
 {
   NSView *view;
-  NSTRACE ("x_make_frame_invisible");
+  NSTRACE ("ns_make_frame_invisible");
   check_window_system (f);
   view = FRAME_NS_VIEW (f);
   [[view window] orderOut: NSApp];
@@ -1605,23 +1641,34 @@ x_make_frame_invisible (struct frame *f)
   SET_FRAME_ICONIFIED (f, 0);
 }
 
+static void
+ns_make_frame_visible_invisible (struct frame *f, bool visible)
+/* --------------------------------------------------------------------------
+     External (hook)
+   -------------------------------------------------------------------------- 
*/
+{
+  if (visible)
+    ns_make_frame_visible (f);
+  else
+    ns_make_frame_invisible (f);
+}
 
 void
-x_iconify_frame (struct frame *f)
+ns_iconify_frame (struct frame *f)
 /* --------------------------------------------------------------------------
-     External: Iconify window
+     External (hook): Iconify window
    -------------------------------------------------------------------------- 
*/
 {
   NSView *view;
   struct ns_display_info *dpyinfo;
 
-  NSTRACE ("x_iconify_frame");
+  NSTRACE ("ns_iconify_frame");
   check_window_system (f);
   view = FRAME_NS_VIEW (f);
   dpyinfo = FRAME_DISPLAY_INFO (f);
 
-  if (dpyinfo->x_highlight_frame == f)
-    dpyinfo->x_highlight_frame = 0;
+  if (dpyinfo->highlight_frame == f)
+    dpyinfo->highlight_frame = 0;
 
   if ([[view window] windowNumber] <= 0)
     {
@@ -1643,16 +1690,16 @@ x_iconify_frame (struct frame *f)
   unblock_input();
 }
 
-/* Free X resources of frame F.  */
+/* Free resources of frame F.  */
 
 void
-x_free_frame_resources (struct frame *f)
+ns_free_frame_resources (struct frame *f)
 {
   NSView *view;
   struct ns_display_info *dpyinfo;
   Mouse_HLInfo *hlinfo;
 
-  NSTRACE ("x_free_frame_resources");
+  NSTRACE ("ns_free_frame_resources");
   check_window_system (f);
   view = FRAME_NS_VIEW (f);
   dpyinfo = FRAME_DISPLAY_INFO (f);
@@ -1665,10 +1712,10 @@ x_free_frame_resources (struct frame *f)
   free_frame_menubar (f);
   free_frame_faces (f);
 
-  if (f == dpyinfo->x_focus_frame)
-    dpyinfo->x_focus_frame = 0;
-  if (f == dpyinfo->x_highlight_frame)
-    dpyinfo->x_highlight_frame = 0;
+  if (f == dpyinfo->ns_focus_frame)
+    dpyinfo->ns_focus_frame = 0;
+  if (f == dpyinfo->highlight_frame)
+    dpyinfo->highlight_frame = 0;
   if (f == hlinfo->mouse_face_mouse_frame)
     reset_mouse_highlight (hlinfo);
 
@@ -1683,13 +1730,13 @@ x_free_frame_resources (struct frame *f)
   unblock_input ();
 }
 
-void
-x_destroy_window (struct frame *f)
+static void
+ns_destroy_window (struct frame *f)
 /* --------------------------------------------------------------------------
      External: Delete the window
    -------------------------------------------------------------------------- 
*/
 {
-  NSTRACE ("x_destroy_window");
+  NSTRACE ("ns_destroy_window");
 
   /* If this frame has a parent window, detach it as not doing so can
      cause a crash in GNUStep.  */
@@ -1702,13 +1749,13 @@ x_destroy_window (struct frame *f)
     }
 
   check_window_system (f);
-  x_free_frame_resources (f);
+  ns_free_frame_resources (f);
   ns_window_num--;
 }
 
 
 void
-x_set_offset (struct frame *f, int xoff, int yoff, int change_grav)
+ns_set_offset (struct frame *f, int xoff, int yoff, int change_grav)
 /* --------------------------------------------------------------------------
      External: Position the window
    -------------------------------------------------------------------------- 
*/
@@ -1716,7 +1763,7 @@ x_set_offset (struct frame *f, int xoff, int yoff, int 
change_grav)
   NSView *view = FRAME_NS_VIEW (f);
   NSScreen *screen = [[view window] screen];
 
-  NSTRACE ("x_set_offset");
+  NSTRACE ("ns_set_offset");
 
   block_input ();
 
@@ -1773,12 +1820,12 @@ x_set_offset (struct frame *f, int xoff, int yoff, int 
change_grav)
 }
 
 
-void
-x_set_window_size (struct frame *f,
-                   bool change_gravity,
-                   int width,
-                   int height,
-                   bool pixelwise)
+static void
+ns_set_window_size (struct frame *f,
+                    bool change_gravity,
+                    int width,
+                    int height,
+                    bool pixelwise)
 /* --------------------------------------------------------------------------
      Adjust window pixel size based on given character grid size
      Impl is a bit more complex than other terms, need to do some
@@ -1791,7 +1838,7 @@ x_set_window_size (struct frame *f,
   int pixelwidth, pixelheight;
   int orig_height = wr.size.height;
 
-  NSTRACE ("x_set_window_size");
+  NSTRACE ("ns_set_window_size");
 
   if (view == nil)
     return;
@@ -1852,7 +1899,7 @@ x_set_window_size (struct frame *f,
 
 #ifdef NS_IMPL_COCOA
 void
-x_set_undecorated (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
+ns_set_undecorated (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
 /* --------------------------------------------------------------------------
      Set frame F's `undecorated' parameter.  If non-nil, F's window-system
      window is drawn without decorations, title, minimize/maximize boxes
@@ -1867,7 +1914,7 @@ x_set_undecorated (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_value
   EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
   NSWindow *window = [view window];
 
-  NSTRACE ("x_set_undecorated");
+  NSTRACE ("ns_set_undecorated");
 
   if (!EQ (new_value, old_value))
     {
@@ -1902,7 +1949,7 @@ x_set_undecorated (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_value
 #endif /* NS_IMPL_COCOA */
 
 void
-x_set_parent_frame (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
+ns_set_parent_frame (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
 /* --------------------------------------------------------------------------
      Set frame F's `parent-frame' parameter.  If non-nil, make F a child
      frame of the frame specified by that parameter.  Technically, this
@@ -1928,7 +1975,7 @@ x_set_parent_frame (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_valu
   struct frame *p = NULL;
   NSWindow *parent, *child;
 
-  NSTRACE ("x_set_parent_frame");
+  NSTRACE ("ns_set_parent_frame");
 
   if (!NILP (new_value)
       && (!FRAMEP (new_value)
@@ -1976,7 +2023,7 @@ x_set_parent_frame (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_valu
 }
 
 void
-x_set_no_focus_on_map (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
+ns_set_no_focus_on_map (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
 /* Set frame F's `no-focus-on-map' parameter which, if non-nil, means
  * that F's window-system window does not want to receive input focus
  * when it is mapped.  (A frame's window is mapped when the frame is
@@ -1985,7 +2032,7 @@ x_set_no_focus_on_map (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_v
  *
  * Some window managers may not honor this parameter.  */
 {
-  NSTRACE ("x_set_no_focus_on_map");
+  NSTRACE ("ns_set_no_focus_on_map");
 
   if (!EQ (new_value, old_value))
     {
@@ -1994,7 +2041,7 @@ x_set_no_focus_on_map (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_v
 }
 
 void
-x_set_no_accept_focus (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
+ns_set_no_accept_focus (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
 /*  Set frame F's `no-accept-focus' parameter which, if non-nil, hints
  * that F's window-system window does not want to receive input focus
  * via mouse clicks or by moving the mouse into it.
@@ -2004,14 +2051,14 @@ x_set_no_accept_focus (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_v
  *
  * Some window managers may not honor this parameter.  */
 {
-  NSTRACE ("x_set_no_accept_focus");
+  NSTRACE ("ns_set_no_accept_focus");
 
   if (!EQ (new_value, old_value))
     FRAME_NO_ACCEPT_FOCUS (f) = !NILP (new_value);
 }
 
 void
-x_set_z_group (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
+ns_set_z_group (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
 /* Set frame F's `z-group' parameter.  If `above', F's window-system
    window is displayed above all windows that do not have the `above'
    property set.  If nil, F's window is shown below all windows that
@@ -2024,7 +2071,7 @@ x_set_z_group (struct frame *f, Lisp_Object new_value, 
Lisp_Object old_value)
   EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
   NSWindow *window = [view window];
 
-  NSTRACE ("x_set_z_group");
+  NSTRACE ("ns_set_z_group");
 
   if (NILP (new_value))
     {
@@ -2350,7 +2397,7 @@ ns_color_index_to_rgba(int idx, struct frame *f)
 }
 
 void
-ns_query_color(void *col, XColor *color_def, int setPixel)
+ns_query_color(void *col, XColor *color_def, bool setPixel)
 /* --------------------------------------------------------------------------
          Get ARGB values out of NSColor col and put them into color_def.
          If setPixel, set the pixel to a concatenated version.
@@ -2370,7 +2417,6 @@ ns_query_color(void *col, XColor *color_def, int setPixel)
                      (int)(r*255), (int)(g*255), (int)(b*255));
 }
 
-
 bool
 ns_defined_color (struct frame *f,
                   const char *name,
@@ -2401,9 +2447,17 @@ ns_defined_color (struct frame *f,
   return 1;
 }
 
+static void
+ns_query_frame_background_color (struct frame *f, XColor *bgcolor)
+/* --------------------------------------------------------------------------
+     External (hook): Store F's background color into *BGCOLOR
+   -------------------------------------------------------------------------- 
*/
+{
+  ns_query_color (FRAME_BACKGROUND_COLOR (f), bgcolor, true);
+}
 
-void
-x_set_frame_alpha (struct frame *f)
+static void
+ns_set_frame_alpha (struct frame *f)
 /* --------------------------------------------------------------------------
      change the entire-frame transparency
    -------------------------------------------------------------------------- 
*/
@@ -2412,9 +2466,9 @@ x_set_frame_alpha (struct frame *f)
   double alpha = 1.0;
   double alpha_min = 1.0;
 
-  NSTRACE ("x_set_frame_alpha");
+  NSTRACE ("ns_set_frame_alpha");
 
-  if (dpyinfo->x_highlight_frame == f)
+  if (dpyinfo->highlight_frame == f)
     alpha = f->alpha[0];
   else
     alpha = f->alpha[1];
@@ -2466,7 +2520,7 @@ frame_set_mouse_pixel_position (struct frame *f, int 
pix_x, int pix_y)
 }
 
 static int
-note_mouse_movement (struct frame *frame, CGFloat x, CGFloat y)
+ns_note_mouse_movement (struct frame *frame, CGFloat x, CGFloat y)
 /*   ------------------------------------------------------------------------
      Called by EmacsView on mouseMovement events.  Passes on
      to emacs mainstream code if we moved off of a rect of interest
@@ -2540,7 +2594,7 @@ ns_mouse_position (struct frame **fp, int insist, 
Lisp_Object *bar_window,
       && FRAME_LIVE_P (dpyinfo->last_mouse_frame))
     f = dpyinfo->last_mouse_frame;
   else
-    f = dpyinfo->x_focus_frame ? dpyinfo->x_focus_frame : SELECTED_FRAME ();
+    f = dpyinfo->ns_focus_frame ? dpyinfo->ns_focus_frame : SELECTED_FRAME ();
 
   if (f && FRAME_NS_P (f))
     {
@@ -2606,7 +2660,7 @@ ns_define_frame_cursor (struct frame *f, Cursor cursor)
       [[view window] invalidateCursorRectsForView: view];
       /* Redisplay assumes this function also draws the changed frame
          cursor, but this function doesn't, so do it explicitly.  */
-      x_update_cursor (f, 1);
+      gui_update_cursor (f, 1);
     }
 }
 
@@ -2638,14 +2692,14 @@ ns_convert_key (unsigned code)
 
 
 char *
-x_get_keysym_name (int keysym)
+get_keysym_name (int keysym)
 /* --------------------------------------------------------------------------
     Called by keyboard.c.  Not sure if the return val is important, except
     that it be unique.
    -------------------------------------------------------------------------- 
*/
 {
   static char value[16];
-  NSTRACE ("x_get_keysym_name");
+  NSTRACE ("get_keysym_name");
   sprintf (value, "%d", keysym);
   return value;
 }
@@ -2884,7 +2938,7 @@ ns_scroll_run (struct window *w, struct run *run)
 
   block_input ();
 
-  x_clear_cursor (w);
+  gui_clear_cursor (w);
 
   {
     NSRect srcRect = NSMakeRect (x, from_y, width, height);
@@ -3062,7 +3116,7 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row 
*row,
   /* Work out the rectangle we will need to clear.  Because we're
      compositing rather than blitting, we need to clear the area under
      the image regardless of anything else.  */
-  if (!p->overlay_p)
+  if (p->bx >= 0 && !p->overlay_p)
     {
       clearRect = NSMakeRect (p->bx, p->by, p->nx, p->ny);
       clearRect = NSUnionRect (clearRect, imageRect);
@@ -3121,7 +3175,6 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row 
*row,
             [img setXBMColor: bm_color];
           }
 
-#ifdef NS_IMPL_COCOA
           // Note: For periodic images, the full image height is "h + hd".
           // By using the height h, a suitable part of the image is used.
           NSRect fromRect = NSMakeRect(0, 0, p->wd, p->h);
@@ -3134,13 +3187,6 @@ ns_draw_fringe_bitmap (struct window *w, struct 
glyph_row *row,
                  fraction: 1.0
                respectFlipped: YES
                     hints: nil];
-#else
-          {
-            NSPoint pt = imageRect.origin;
-            pt.y += p->h;
-            [img compositeToPoint: pt operation: 
NSCompositingOperationSourceOver];
-          }
-#endif
         }
       ns_reset_clipping (f);
     }
@@ -3269,8 +3315,9 @@ ns_draw_window_cursor (struct window *w, struct glyph_row 
*glyph_row,
           break;
         }
 
-      /* draw the character under the cursor */
-      if (cursor_type != NO_CURSOR)
+      /* Draw the character under the cursor.  Other terms only draw
+         the character on top of box cursors, so do the same here.  */
+      if (cursor_type == FILLED_BOX_CURSOR || cursor_type == HOLLOW_BOX_CURSOR)
         draw_phys_cursor_glyph (w, glyph_row, DRAW_CURSOR);
 
       ns_reset_clipping (f);
@@ -3918,8 +3965,9 @@ ns_dumpglyphs_image (struct glyph_string *s, NSRect r)
     {
       if (s->hl == DRAW_IMAGE_SUNKEN || s->hl == DRAW_IMAGE_RAISED)
         {
-          th = tool_bar_button_relief >= 0 ?
-            tool_bar_button_relief : DEFAULT_TOOL_BAR_BUTTON_RELIEF;
+          th = (tool_bar_button_relief < 0
+               ? DEFAULT_TOOL_BAR_BUTTON_RELIEF
+               : min (tool_bar_button_relief, 1000000));
           raised_p = (s->hl == DRAW_IMAGE_RAISED);
         }
       else
@@ -4995,7 +5043,7 @@ ns_judge_scroll_bars (struct frame *f)
    ========================================================================== 
*/
 
 int
-x_display_pixel_height (struct ns_display_info *dpyinfo)
+ns_display_pixel_height (struct ns_display_info *dpyinfo)
 {
   NSArray *screens = [NSScreen screens];
   NSEnumerator *enumerator = [screens objectEnumerator];
@@ -5010,7 +5058,7 @@ x_display_pixel_height (struct ns_display_info *dpyinfo)
 }
 
 int
-x_display_pixel_width (struct ns_display_info *dpyinfo)
+ns_display_pixel_width (struct ns_display_info *dpyinfo)
 {
   NSArray *screens = [NSScreen screens];
   NSEnumerator *enumerator = [screens objectEnumerator];
@@ -5094,7 +5142,7 @@ ns_initialize_display_info (struct ns_display_info 
*dpyinfo)
     dpyinfo->color_table = xmalloc (sizeof *dpyinfo->color_table);
     dpyinfo->color_table->colors = NULL;
     dpyinfo->root_window = 42; /* A placeholder.  */
-    dpyinfo->x_highlight_frame = dpyinfo->x_focus_frame = NULL;
+    dpyinfo->highlight_frame = dpyinfo->ns_focus_frame = NULL;
     dpyinfo->n_fonts = 0;
     dpyinfo->smallest_font_height = 1;
     dpyinfo->smallest_char_width = 1;
@@ -5104,7 +5152,7 @@ ns_initialize_display_info (struct ns_display_info 
*dpyinfo)
 
 
 /* This and next define (many of the) public functions in this file.  */
-/* x_... are generic versions in xdisp.c that we, and other terms, get away
+/* gui_* are generic versions in xdisp.c that we, and other terms, get away
          with using despite presence in the "system dependent" redisplay
          interface.  In addition, many of the ns_ methods have code that is
          shared with all terms, indicating need for further refactoring.  */
@@ -5112,18 +5160,18 @@ extern frame_parm_handler ns_frame_parm_handlers[];
 static struct redisplay_interface ns_redisplay_interface =
 {
   ns_frame_parm_handlers,
-  x_produce_glyphs,
-  x_write_glyphs,
-  x_insert_glyphs,
-  x_clear_end_of_line,
+  gui_produce_glyphs,
+  gui_write_glyphs,
+  gui_insert_glyphs,
+  gui_clear_end_of_line,
   ns_scroll_run,
   ns_after_update_window_line,
   ns_update_window_begin,
   ns_update_window_end,
   0, /* flush_display */
-  x_clear_window_mouse_face,
-  x_get_glyph_overhangs,
-  x_fix_overlapping_area,
+  gui_clear_window_mouse_face,
+  gui_get_glyph_overhangs,
+  gui_fix_overlapping_area,
   ns_draw_fringe_bitmap,
   0, /* define_fringe_bitmap */ /* FIXME: simplify ns_draw_fringe_bitmap */
   0, /* destroy_fringe_bitmap */
@@ -5131,6 +5179,7 @@ static struct redisplay_interface ns_redisplay_interface =
   ns_draw_glyph_string,
   ns_define_frame_cursor,
   ns_clear_frame_area,
+  0, /* clear_under_internal_border */
   ns_draw_window_cursor,
   ns_draw_vertical_window_border,
   ns_draw_window_divider,
@@ -5162,11 +5211,13 @@ ns_delete_terminal (struct terminal *terminal)
 
   block_input ();
 
-  x_destroy_all_bitmaps (dpyinfo);
+  image_destroy_all_bitmaps (dpyinfo);
   ns_delete_display (dpyinfo);
   unblock_input ();
 }
 
+static Lisp_Object ns_new_font (struct frame *f, Lisp_Object font_object,
+                                int fontset);
 
 static struct terminal *
 ns_create_terminal (struct ns_display_info *dpyinfo)
@@ -5189,18 +5240,33 @@ ns_create_terminal (struct ns_display_info *dpyinfo)
   terminal->update_end_hook = ns_update_end;
   terminal->read_socket_hook = ns_read_socket;
   terminal->frame_up_to_date_hook = ns_frame_up_to_date;
+  terminal->defined_color_hook = ns_defined_color;
+  terminal->query_frame_background_color = ns_query_frame_background_color;
   terminal->mouse_position_hook = ns_mouse_position;
+  terminal->get_focus_frame = ns_get_focus_frame;
+  terminal->focus_frame_hook = ns_focus_frame;
   terminal->frame_rehighlight_hook = ns_frame_rehighlight;
   terminal->frame_raise_lower_hook = ns_frame_raise_lower;
+  terminal->frame_visible_invisible_hook = ns_make_frame_visible_invisible;
   terminal->fullscreen_hook = ns_fullscreen_hook;
+  terminal->iconify_frame_hook = ns_iconify_frame;
+  terminal->set_window_size_hook = ns_set_window_size;
+  terminal->set_frame_offset_hook = ns_set_offset;
+  terminal->set_frame_alpha_hook = ns_set_frame_alpha;
+  terminal->set_new_font_hook = ns_new_font;
+  terminal->implicit_set_name_hook = ns_implicitly_set_name;
   terminal->menu_show_hook = ns_menu_show;
+  terminal->activate_menubar_hook = ns_activate_menubar;
   terminal->popup_dialog_hook = ns_popup_dialog;
   terminal->set_vertical_scroll_bar_hook = ns_set_vertical_scroll_bar;
   terminal->set_horizontal_scroll_bar_hook = ns_set_horizontal_scroll_bar;
+  terminal->set_scroll_bar_default_width_hook = 
ns_set_scroll_bar_default_width;
+  terminal->set_scroll_bar_default_height_hook = 
ns_set_scroll_bar_default_height;
   terminal->condemn_scroll_bars_hook = ns_condemn_scroll_bars;
   terminal->redeem_scroll_bar_hook = ns_redeem_scroll_bar;
   terminal->judge_scroll_bars_hook = ns_judge_scroll_bars;
-  terminal->delete_frame_hook = x_destroy_window;
+  terminal->get_string_resource_hook = ns_get_string_resource;
+  terminal->delete_frame_hook = ns_destroy_window;
   terminal->delete_terminal_hook = ns_delete_terminal;
   /* Other hooks are NULL by default.  */
 
@@ -5663,7 +5729,7 @@ ns_term_shutdown (int sig)
       struct ns_display_info *di;
       BOOL has_focus = NO;
       for (di = x_display_list; ! has_focus && di; di = di->next)
-        has_focus = di->x_focus_frame != 0;
+        has_focus = di->ns_focus_frame != 0;
       if (! has_focus)
         return;
     }
@@ -6895,7 +6961,7 @@ not_in_argv (NSString *arg)
       last_mouse_window = window;
     }
 
-  if (!note_mouse_movement (emacsframe, pt.x, pt.y))
+  if (!ns_note_mouse_movement (emacsframe, pt.x, pt.y))
     help_echo_string = previous_help_echo_string;
 
   XSETFRAME (frame, emacsframe);
@@ -6903,7 +6969,7 @@ not_in_argv (NSString *arg)
     {
       /* NOTE: help_echo_{window,pos,object} are set in xdisp.c
          (note_mouse_highlight), which is called through the
-         note_mouse_movement () call above.  */
+         ns_note_mouse_movement () call above.  */
       any_help_event_p = YES;
       gen_help_event (help_echo_string, frame, help_echo_window,
                       help_echo_object, help_echo_pos);
@@ -7220,12 +7286,12 @@ not_in_argv (NSString *arg)
 - (void)windowDidBecomeKey      /* for direct calls */
 {
   struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (emacsframe);
-  struct frame *old_focus = dpyinfo->x_focus_frame;
+  struct frame *old_focus = dpyinfo->ns_focus_frame;
 
   NSTRACE ("[EmacsView windowDidBecomeKey]");
 
   if (emacsframe != old_focus)
-    dpyinfo->x_focus_frame = emacsframe;
+    dpyinfo->ns_focus_frame = emacsframe;
 
   ns_frame_rehighlight (emacsframe);
 
@@ -7241,11 +7307,11 @@ not_in_argv (NSString *arg)
 /* cf. x_detect_focus_change(), x_focus_changed(), x_new_focus_frame() */
 {
   struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (emacsframe);
-  BOOL is_focus_frame = dpyinfo->x_focus_frame == emacsframe;
+  BOOL is_focus_frame = dpyinfo->ns_focus_frame == emacsframe;
   NSTRACE ("[EmacsView windowDidResignKey:]");
 
   if (is_focus_frame)
-    dpyinfo->x_focus_frame = 0;
+    dpyinfo->ns_focus_frame = 0;
 
   emacsframe->mouse_moved = 0;
   ns_frame_rehighlight (emacsframe);
@@ -7254,8 +7320,8 @@ not_in_argv (NSString *arg)
             from sole-frame Emacs to get hollow box to show.  */
   if (!windowClosing && [[self window] isVisible] == YES)
     {
-      x_update_cursor (emacsframe, 1);
-      x_set_frame_alpha (emacsframe);
+      gui_update_cursor (emacsframe, 1);
+      ns_set_frame_alpha (emacsframe);
     }
 
   if (any_help_event_p)
@@ -7524,7 +7590,7 @@ not_in_argv (NSString *arg)
 
 
 /* Called AFTER method below, but before our windowWillResize call there leads
-   to windowDidResize -> x_set_window_size.  Update emacs' notion of frame
+   to windowDidResize -> ns_set_window_size.  Update emacs' notion of frame
    location so set_window_size moves the frame.  */
 - (BOOL)windowShouldZoom: (NSWindow *)sender toFrame: (NSRect)newFrame
 {
@@ -8162,6 +8228,14 @@ not_in_argv (NSString *arg)
 }
 
 
+- (void)viewWillDraw
+{
+  /* If the frame has been garbaged there's no point in redrawing
+     anything.  */
+  if (FRAME_GARBAGED_P (emacsframe))
+    [self setNeedsDisplay:NO];
+}
+
 - (void)drawRect: (NSRect)rect
 {
   const NSRect *rectList;
@@ -8230,7 +8304,9 @@ not_in_argv (NSString *arg)
   NSEvent *theEvent = [[self window] currentEvent];
   NSPoint position;
   NSDragOperation op = [sender draggingSourceOperationMask];
-  int modifiers = 0;
+  Lisp_Object operations = Qnil;
+  Lisp_Object strings = Qnil;
+  Lisp_Object type_sym;
 
   NSTRACE ("[EmacsView performDragOperation:]");
 
@@ -8243,19 +8319,17 @@ not_in_argv (NSString *arg)
   pb = [sender draggingPasteboard];
   type = [pb availableTypeFromArray: ns_drag_types];
 
-  if (! (op & (NSDragOperationMove|NSDragOperationDelete)) &&
-      // URL drags contain all operations (0xf), don't allow all to be set.
-      (op & 0xf) != 0xf)
-    {
-      if (op & NSDragOperationLink)
-        modifiers |= NSEventModifierFlagControl;
-      if (op & NSDragOperationCopy)
-        modifiers |= NSEventModifierFlagOption;
-      if (op & NSDragOperationGeneric)
-        modifiers |= NSEventModifierFlagCommand;
-    }
+  /* We used to convert these drag operations to keyboard modifiers,
+     but because they can be set by the sending program as well as the
+     keyboard modifiers it was difficult to work out a sensible key
+     mapping for drag and drop.  */
+  if (op & NSDragOperationLink)
+    operations = Fcons (Qns_drag_operation_link, operations);
+  if (op & NSDragOperationCopy)
+    operations = Fcons (Qns_drag_operation_copy, operations);
+  if (op & NSDragOperationGeneric || NILP (operations))
+    operations = Fcons (Qns_drag_operation_generic, operations);
 
-  modifiers = EV_MODIFIERS2 (modifiers);
   if (type == 0)
     {
       return NO;
@@ -8269,39 +8343,20 @@ not_in_argv (NSString *arg)
       if (!(files = [pb propertyListForType: type]))
         return NO;
 
+      type_sym = Qfile;
+
       fenum = [files objectEnumerator];
       while ( (file = [fenum nextObject]) )
-        {
-          emacs_event->kind = DRAG_N_DROP_EVENT;
-          XSETINT (emacs_event->x, x);
-          XSETINT (emacs_event->y, y);
-          emacs_event->modifiers = modifiers;
-          emacs_event->arg =  list2 (Qfile, build_string ([file UTF8String]));
-          EV_TRAILER (theEvent);
-        }
-      return YES;
+        strings = Fcons (build_string ([file UTF8String]), strings);
     }
   else if ([type isEqualToString: NSURLPboardType])
     {
       NSURL *url = [NSURL URLFromPasteboard: pb];
       if (url == nil) return NO;
 
-      emacs_event->kind = DRAG_N_DROP_EVENT;
-      XSETINT (emacs_event->x, x);
-      XSETINT (emacs_event->y, y);
-      emacs_event->modifiers = modifiers;
-      emacs_event->arg =  list2 (Qurl,
-                                 build_string ([[url absoluteString]
-                                                 UTF8String]));
-      EV_TRAILER (theEvent);
+      type_sym = Qurl;
 
-      if ([url isFileURL] != NO)
-        {
-          NSString *file = [url path];
-          ns_input_file = append2 (ns_input_file,
-                                   build_string ([file UTF8String]));
-        }
-      return YES;
+      strings = list1 (build_string ([[url absoluteString] UTF8String]));
     }
   else if ([type isEqualToString: NSStringPboardType]
            || [type isEqualToString: NSTabularTextPboardType])
@@ -8311,19 +8366,27 @@ not_in_argv (NSString *arg)
       if (! (data = [pb stringForType: type]))
         return NO;
 
-      emacs_event->kind = DRAG_N_DROP_EVENT;
-      XSETINT (emacs_event->x, x);
-      XSETINT (emacs_event->y, y);
-      emacs_event->modifiers = modifiers;
-      emacs_event->arg =  list2 (Qnil, build_string ([data UTF8String]));
-      EV_TRAILER (theEvent);
-      return YES;
+      type_sym = Qnil;
+
+      strings = list1 (build_string ([data UTF8String]));
     }
   else
     {
       fprintf (stderr, "Invalid data type in dragging pasteboard");
       return NO;
     }
+
+  emacs_event->kind = DRAG_N_DROP_EVENT;
+  XSETINT (emacs_event->x, x);
+  XSETINT (emacs_event->y, y);
+  emacs_event->modifiers = 0;
+
+  emacs_event->arg = Fcons (type_sym,
+                            Fcons (operations,
+                                   strings));
+  EV_TRAILER (theEvent);
+
+  return YES;
 }
 
 
@@ -9230,9 +9293,12 @@ not_in_argv (NSString *arg)
    ========================================================================== 
*/
 
 
-Lisp_Object
-x_new_font (struct frame *f, Lisp_Object font_object, int fontset)
+static Lisp_Object
+ns_new_font (struct frame *f, Lisp_Object font_object, int fontset)
 {
+  /* --------------------------------------------------------------------------
+     External (hook)
+     
-------------------------------------------------------------------------- */
   struct font *font = XFONT_OBJECT (font_object);
   EmacsView *view = FRAME_NS_VIEW (f);
   int font_ascent, font_descent;
@@ -9345,6 +9411,7 @@ syms_of_nsterm (void)
   NSTRACE ("syms_of_nsterm");
 
   ns_antialias_threshold = 10.0;
+  PDUMPER_REMEMBER_SCALAR (ns_antialias_threshold);
 
   /* From 23+ we need to tell emacs what modifiers there are.  */
   DEFSYM (Qmodifier_value, "modifier-value");
@@ -9358,6 +9425,10 @@ syms_of_nsterm (void)
   DEFSYM (Qfile, "file");
   DEFSYM (Qurl, "url");
 
+  DEFSYM (Qns_drag_operation_copy, "ns-drag-operation-copy");
+  DEFSYM (Qns_drag_operation_link, "ns-drag-operation-link");
+  DEFSYM (Qns_drag_operation_generic, "ns-drag-operation-generic");
+
   Fput (Qalt, Qmodifier_value, make_fixnum (alt_modifier));
   Fput (Qhyper, Qmodifier_value, make_fixnum (hyper_modifier));
   Fput (Qmeta, Qmodifier_value, make_fixnum (meta_modifier));
diff --git a/src/pdumper.c b/src/pdumper.c
new file mode 100644
index 0000000..28045d1
--- /dev/null
+++ b/src/pdumper.c
@@ -0,0 +1,5518 @@
+/* Copyright (C) 2018-2019 Free Software Foundation, Inc.
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <math.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "blockinput.h"
+#include "buffer.h"
+#include "charset.h"
+#include "coding.h"
+#include "fingerprint.h"
+#include "frame.h"
+#include "getpagesize.h"
+#include "intervals.h"
+#include "lisp.h"
+#include "pdumper.h"
+#include "window.h"
+#include "systime.h"
+#include "thread.h"
+#include "bignum.h"
+
+#ifdef CHECK_STRUCTS
+# include "dmpstruct.h"
+#endif
+
+/*
+  TODO:
+
+  - Two-pass dumping: first assemble object list, then write all.
+    This way, we can perform arbitrary reordering or maybe use fancy
+    graph algorithms to get better locality.
+
+  - Don't emit relocations that happen to set Emacs memory locations
+    to values they will already have.
+
+  - Nullify frame_and_buffer_state.
+
+  - Preferred base address for relocation-free non-PIC startup.
+
+  - Compressed dump support.
+
+*/
+
+#ifdef HAVE_PDUMPER
+
+#if GNUC_PREREQ (4, 7, 0)
+# pragma GCC diagnostic error "-Wconversion"
+# pragma GCC diagnostic ignored "-Wsign-conversion"
+# pragma GCC diagnostic error "-Wshadow"
+# define ALLOW_IMPLICIT_CONVERSION                       \
+  _Pragma ("GCC diagnostic push")                        \
+  _Pragma ("GCC diagnostic ignored \"-Wconversion\"")
+# define DISALLOW_IMPLICIT_CONVERSION \
+  _Pragma ("GCC diagnostic pop")
+#else
+# define ALLOW_IMPLICIT_CONVERSION ((void) 0)
+# define DISALLOW_IMPLICIT_CONVERSION ((void) 0)
+#endif
+
+#define VM_POSIX 1
+#define VM_MS_WINDOWS 2
+
+#if defined (HAVE_MMAP) && defined (MAP_FIXED)
+# define VM_SUPPORTED VM_POSIX
+# if !defined (MAP_POPULATE) && defined (MAP_PREFAULT_READ)
+#  define MAP_POPULATE MAP_PREFAULT_READ
+# elif !defined (MAP_POPULATE)
+#  define MAP_POPULATE 0
+# endif
+#elif defined (WINDOWSNT)
+  /* Use a float infinity, to avoid compiler warnings in comparing vs
+     candidates' score.  */
+# undef INFINITY
+# define INFINITY __builtin_inff ()
+# include <windows.h>
+# define VM_SUPPORTED VM_MS_WINDOWS
+#else
+# define VM_SUPPORTED 0
+#endif
+
+#define DANGEROUS 0
+
+/* PDUMPER_CHECK_REHASHING being true causes the portable dumper to
+   check, for each hash table it dumps, that the hash table means the
+   same thing after rehashing.  */
+#ifndef PDUMPER_CHECK_REHASHING
+# if ENABLE_CHECKING
+#  define PDUMPER_CHECK_REHASHING 1
+# else
+#  define PDUMPER_CHECK_REHASHING 0
+# endif
+#endif
+
+/* We require an architecture in which all pointers are the same size
+   and have the same layout, where pointers are either 32 or 64 bits
+   long, and where bytes have eight bits --- that is, a
+   general-purpose computer made after 1990.  */
+verify (sizeof (ptrdiff_t) == sizeof (void *));
+verify (sizeof (intptr_t) == sizeof (ptrdiff_t));
+verify (sizeof (void (*) (void)) == sizeof (void *));
+verify (sizeof (ptrdiff_t) <= sizeof (Lisp_Object));
+verify (sizeof (ptrdiff_t) <= sizeof (EMACS_INT));
+verify (CHAR_BIT == 8);
+
+#define DIVIDE_ROUND_UP(x, y) (((x) + (y) - 1) / (y))
+
+static const char dump_magic[16] = {
+  'D', 'U', 'M', 'P', 'E', 'D',
+  'G', 'N', 'U',
+  'E', 'M', 'A', 'C', 'S'
+};
+
+static pdumper_hook dump_hooks[24];
+static int nr_dump_hooks = 0;
+
+static struct
+{
+  void *mem;
+  int sz;
+} remembered_data[32];
+static int nr_remembered_data = 0;
+
+typedef int_least32_t dump_off;
+#define DUMP_OFF_MIN INT_LEAST32_MIN
+#define DUMP_OFF_MAX INT_LEAST32_MAX
+
+static void ATTRIBUTE_FORMAT ((printf, 1, 2))
+dump_trace (const char *fmt, ...)
+{
+  if (0)
+    {
+      va_list args;
+      va_start (args, fmt);
+      vfprintf (stderr, fmt, args);
+      va_end (args);
+    }
+}
+
+static ssize_t dump_read_all (int fd, void *buf, size_t bytes_to_read);
+
+static dump_off
+ptrdiff_t_to_dump_off (ptrdiff_t value)
+{
+  eassert (DUMP_OFF_MIN <= value);
+  eassert (value <= DUMP_OFF_MAX);
+  return (dump_off) value;
+}
+
+/* Worst-case allocation granularity on any system that might load
+   this dump.  */
+static int
+dump_get_page_size (void)
+{
+#if defined (WINDOWSNT) || defined (CYGWIN)
+  return 64 * 1024;  /* Worst-case allocation granularity.  */
+#else
+  return getpagesize ();
+#endif
+}
+
+#define dump_offsetof(type, member)                             \
+  (ptrdiff_t_to_dump_off (offsetof (type, member)))
+
+enum dump_reloc_type
+  {
+    /* dump_ptr = dump_ptr + emacs_basis()  */
+    RELOC_DUMP_TO_EMACS_PTR_RAW,
+    /* dump_ptr = dump_ptr + dump_base  */
+    RELOC_DUMP_TO_DUMP_PTR_RAW,
+    /* dump_mpz = [rebuild bignum]  */
+    RELOC_BIGNUM,
+    /* dump_lv = make_lisp_ptr (dump_lv + dump_base,
+                               type - RELOC_DUMP_TO_DUMP_LV)
+       (Special case for symbols: make_lisp_symbol)
+       Must be second-last.  */
+    RELOC_DUMP_TO_DUMP_LV,
+    /* dump_lv = make_lisp_ptr (dump_lv + emacs_basis(),
+                               type - RELOC_DUMP_TO_DUMP_LV)
+       (Special case for symbols: make_lisp_symbol.)
+       Must be last.  */
+    RELOC_DUMP_TO_EMACS_LV = RELOC_DUMP_TO_DUMP_LV + 8,
+  };
+
+enum emacs_reloc_type
+  {
+    /* Copy raw bytes from the dump into Emacs.  The length field in
+       the emacs_reloc is the number of bytes to copy.  */
+    RELOC_EMACS_COPY_FROM_DUMP,
+    /* Set a piece of memory in Emacs to a value we store directly in
+       this relocation.  The length field contains the number of bytes
+       we actually copy into Emacs.  */
+    RELOC_EMACS_IMMEDIATE,
+    /* Set an aligned pointer-sized object in Emacs to a pointer into
+       the loaded dump at the given offset.  The length field is
+       always the machine word size.  */
+    RELOC_EMACS_DUMP_PTR_RAW,
+    /* Set an aligned pointer-sized object in Emacs to point to
+       something also in Emacs.  The length field is always
+       the machine word size.  */
+    RELOC_EMACS_EMACS_PTR_RAW,
+    /* Set an aligned Lisp_Object in Emacs to point to a value in the
+       dump.  The length field is the _tag type_ of the Lisp_Object,
+       not a byte count!  */
+    RELOC_EMACS_DUMP_LV,
+    /* Set an aligned Lisp_Object in Emacs to point to a value in the
+       Emacs image.  The length field is the _tag type_ of the
+       Lisp_Object, not a byte count!  */
+    RELOC_EMACS_EMACS_LV,
+  };
+
+#define EMACS_RELOC_TYPE_BITS 3
+#define EMACS_RELOC_LENGTH_BITS                         \
+  (sizeof (dump_off) * CHAR_BIT - EMACS_RELOC_TYPE_BITS)
+
+struct emacs_reloc
+{
+  ENUM_BF (emacs_reloc_type) type : EMACS_RELOC_TYPE_BITS;
+  dump_off length : EMACS_RELOC_LENGTH_BITS;
+  dump_off emacs_offset;
+  union
+  {
+    dump_off dump_offset;
+    dump_off emacs_offset2;
+    intmax_t immediate;
+  } u;
+};
+
+/* Set the type of an Emacs relocation.
+
+   Also make sure that the type fits in the bitfield.  */
+static void
+emacs_reloc_set_type (struct emacs_reloc *reloc,
+                      enum emacs_reloc_type type)
+{
+  reloc->type = type;
+  eassert (reloc->type == type);
+}
+
+struct dump_table_locator
+{
+  /* Offset in dump, in bytes, of the first entry in the dump
+     table.  */
+  dump_off offset;
+  /* Number of entries in the dump table.  We need an explicit end
+     indicator (as opposed to a special sentinel) so we can efficiently
+     binary search over the relocation entries.  */
+  dump_off nr_entries;
+};
+
+#define DUMP_RELOC_TYPE_BITS 5
+verify (RELOC_DUMP_TO_EMACS_LV + 8 < (1 << DUMP_RELOC_TYPE_BITS));
+
+#define DUMP_RELOC_ALIGNMENT_BITS 2
+#define DUMP_RELOC_OFFSET_BITS                          \
+  (sizeof (dump_off) * CHAR_BIT - DUMP_RELOC_TYPE_BITS)
+
+/* Minimum alignment required by dump file format.  */
+#define DUMP_RELOCATION_ALIGNMENT (1<<DUMP_RELOC_ALIGNMENT_BITS)
+
+/* The alignment granularity (in bytes) for objects we store in the
+   dump.  Always suitable for heap objects; may be more aligned.  */
+#define DUMP_ALIGNMENT (max (GCALIGNMENT, DUMP_RELOCATION_ALIGNMENT))
+verify (DUMP_ALIGNMENT >= GCALIGNMENT);
+
+struct dump_reloc
+{
+  unsigned int raw_offset : DUMP_RELOC_OFFSET_BITS;
+  ENUM_BF (dump_reloc_type) type : DUMP_RELOC_TYPE_BITS;
+};
+verify (sizeof (struct dump_reloc) == sizeof (dump_off));
+
+/* Set the type of a dump relocation.
+
+   Also assert that the type fits in the bitfield.  */
+static void
+dump_reloc_set_type (struct dump_reloc *reloc, enum dump_reloc_type type)
+{
+  reloc->type = type;
+  eassert (reloc->type == type);
+}
+
+static dump_off
+dump_reloc_get_offset (struct dump_reloc reloc)
+{
+  return reloc.raw_offset << DUMP_RELOC_ALIGNMENT_BITS;
+}
+
+static void
+dump_reloc_set_offset (struct dump_reloc *reloc, dump_off offset)
+{
+  eassert (offset >= 0);
+  ALLOW_IMPLICIT_CONVERSION;
+  reloc->raw_offset = offset >> DUMP_RELOC_ALIGNMENT_BITS;
+  DISALLOW_IMPLICIT_CONVERSION;
+  if (dump_reloc_get_offset (*reloc) != offset)
+    error ("dump relocation out of range");
+}
+
+static void
+dump_fingerprint (const char *label, unsigned char const *xfingerprint)
+{
+  fprintf (stderr, "%s: ", label);
+  for (int i = 0; i < 32; ++i)
+    fprintf (stderr, "%02x", (unsigned) xfingerprint[i]);
+  fprintf (stderr, "\n");
+}
+
+/* Format of an Emacs portable dump file.  All offsets are relative to
+   the beginning of the file.  An Emacs portable dump file is coupled
+   to exactly the Emacs binary that produced it, so details of
+   alignment and endianness are unimportant.
+
+   An Emacs dump file contains the contents of the Lisp heap.
+   On startup, Emacs can start faster by mapping a dump file into
+   memory and using the objects contained inside it instead of
+   performing initialization from scratch.
+
+   The dump file can be loaded at arbitrary locations in memory, so it
+   includes a table of relocations that let Emacs adjust the pointers
+   embedded in the dump file to account for the location where it was
+   actually loaded.
+
+   Dump files can contain pointers to other objects in the dump file
+   or to parts of the Emacs binary.  */
+struct dump_header
+{
+  /* File type magic.  */
+  char magic[sizeof (dump_magic)];
+
+  /* Associated Emacs binary.  */
+  unsigned char fingerprint[32];
+
+  /* Relocation table for the dump file; each entry is a
+     struct dump_reloc.  */
+  struct dump_table_locator dump_relocs;
+
+  /* "Relocation" table we abuse to hold information about the
+     location and type of each lisp object in the dump.  We need for
+     pdumper_object_type and ultimately for conservative GC
+     correctness.  */
+  struct dump_table_locator object_starts;
+
+  /* Relocation table for Emacs; each entry is a struct
+     emacs_reloc.  */
+  struct dump_table_locator emacs_relocs;
+
+  /* Start of sub-region of hot region that we can discard after load
+     completes.  The discardable region ends at cold_start.
+
+     This region contains objects that we copy into the Emacs image at
+     dump-load time.  */
+  dump_off discardable_start;
+
+  /* Start of the region that does not require relocations and that we
+     expect never to be modified.  This region can be memory-mapped
+     directly from the backing dump file with the reasonable
+     expectation of taking few copy-on-write faults.
+
+     For correctness, however, this region must be modifible, since in
+     rare cases it is possible to see modifications to these bytes.
+     For example, this region contains string data, and it's
+     technically possible for someone to ASET a string character
+     (although nobody tends to do that).
+
+     The start of the cold region is always aligned on a page
+     boundary.  */
+  dump_off cold_start;
+};
+
+/* Double-ended singly linked list.  */
+struct dump_tailq
+{
+  Lisp_Object head;
+  Lisp_Object tail;
+  intptr_t length;
+};
+
+/* Queue of objects to dump.  */
+struct dump_queue
+{
+  /* Objects with no link weights at all.  Kept in dump order.  */
+  struct dump_tailq zero_weight_objects;
+  /* Objects with simple link weight: just one entry of type
+     WEIGHT_NORMAL.  Score in this special case is non-decreasing as
+     position increases, so we can avoid the need to rescan a big list
+     for each object by storing these objects in order.  */
+  struct dump_tailq one_weight_normal_objects;
+  /* Likewise, for objects with one WEIGHT_STRONG weight.  */
+  struct dump_tailq one_weight_strong_objects;
+  /* List of objects with complex link weights --- i.e., not one of
+     the above cases.  Order is irrelevant, since we scan the whole
+     list every time.  Relatively few objects end up here.  */
+  struct dump_tailq fancy_weight_objects;
+  /* Hash table of link weights: maps an object to a list of zero or
+     more (BASIS . WEIGHT) pairs.  As a special case, an object with
+     zero weight is marked by Qt in the hash table --- this way, we
+     can distinguish objects we've seen but that have no weight from
+     ones that we haven't seen at all.  */
+  Lisp_Object link_weights;
+  /* Hash table mapping object to a sequence number --- used to
+     resolve ties.  */
+  Lisp_Object sequence_numbers;
+  dump_off next_sequence_number;
+};
+
+enum cold_op
+  {
+    COLD_OP_OBJECT,
+    COLD_OP_STRING,
+    COLD_OP_CHARSET,
+    COLD_OP_BUFFER,
+    COLD_OP_BIGNUM,
+  };
+
+/* This structure controls what operations we perform inside
+   dump_object.  */
+struct dump_flags
+{
+  /* Actually write object contents to the dump.  Without this flag
+     set, we still scan objects and enqueue pointed-to objects; making
+     this flag false is useful when we want to process an object's
+     referents normally, but dump an object itself separately,
+     later.  */
+  bool_bf dump_object_contents : 1;
+  /* Record object starts. We turn this flag off when writing to the
+     discardable section so that we don't trick conservative GC into
+     thinking we have objects there.  Ignored (we never record object
+     starts) if dump_object_contents is false.  */
+  bool_bf record_object_starts : 1;
+  /* Pack objects tighter than GC memory alignment would normally
+     require.  Useful for objects copied into the Emacs image instead
+     of used directly from the loaded dump.
+  */
+  bool_bf pack_objects : 1;
+  /* Sometimes we dump objects that we've already scanned for outbound
+     references to other objects.  These objects should not cause new
+     objects to enter the object dumping queue.  This flag causes Emacs
+     to assert that no new objects are enqueued while dumping.  */
+  bool_bf assert_already_seen : 1;
+  /* Punt on unstable hash tables: defer them to ctx->deferred_hash_tables.  */
+  bool_bf defer_hash_tables : 1;
+  /* Punt on symbols: defer them to ctx->deferred_symbols.  */
+  bool_bf defer_symbols : 1;
+  /* Punt on cold objects: defer them to ctx->cold_queue.  */
+  bool_bf defer_cold_objects : 1;
+  /* Punt on copied objects: defer them to ctx->copied_queue.  */
+  bool_bf defer_copied_objects : 1;
+};
+
+/* Information we use while we dump.  Note that we're not the garbage
+   collector and can operate under looser constraints: specifically,
+   we allocate memory during the dumping process.  */
+struct dump_context
+{
+  /* Header we'll write to the dump file when done.  */
+  struct dump_header header;
+
+  Lisp_Object old_purify_flag;
+  Lisp_Object old_post_gc_hook;
+  Lisp_Object old_process_environment;
+
+#ifdef REL_ALLOC
+  bool blocked_ralloc;
+#endif
+
+  /* File descriptor for dumpfile; < 0 if closed.  */
+  int fd;
+  /* Name of dump file --- used for error reporting.  */
+  Lisp_Object dump_filename;
+  /* Current offset in dump file.  */
+  dump_off offset;
+
+  /* Starting offset of current object.  */
+  dump_off obj_offset;
+
+  /* Flags currently in effect for dumping.  */
+  struct dump_flags flags;
+
+  dump_off end_heap;
+
+  /* Hash mapping objects we've already dumped to their offsets.  */
+  Lisp_Object objects_dumped;
+
+  /* Hash mapping objects to where we got them.  Used for debugging.  */
+  Lisp_Object referrers;
+  Lisp_Object current_referrer;
+  bool have_current_referrer;
+
+  /* Queue of objects to dump.  */
+  struct dump_queue dump_queue;
+
+  /* Deferred object lists.  */
+  Lisp_Object deferred_hash_tables;
+  Lisp_Object deferred_symbols;
+
+  /* Fixups in the dump file.  */
+  Lisp_Object fixups;
+
+  /* Hash table of staticpro values: avoids double relocations.  */
+  Lisp_Object staticpro_table;
+
+  /* Hash table mapping symbols to their pre-copy-queue fwd or blv
+     structures (which we dump immediately before the start of the
+     discardable section). */
+  Lisp_Object symbol_aux;
+  /* Queue of copied objects for special treatment.  */
+  Lisp_Object copied_queue;
+  /* Queue of cold objects to dump.  */
+  Lisp_Object cold_queue;
+
+  /* Relocations in the dump.  */
+  Lisp_Object dump_relocs;
+
+  /* Object starts.  */
+  Lisp_Object object_starts;
+
+  /* Relocations in Emacs.  */
+  Lisp_Object emacs_relocs;
+
+  /* Hash table mapping bignums to their _data_ blobs, which we store
+     in the cold section.  The actual Lisp_Bignum objects are normal
+     heap objects.  */
+  Lisp_Object bignum_data;
+
+  unsigned number_hot_relocations;
+  unsigned number_discardable_relocations;
+};
+
+/* These special values for use as offsets in dump_remember_object and
+   dump_recall_object indicate that the corresponding object isn't in
+   the dump yet (and so it has no valid offset), but that it's on one
+   of our to-be-dumped-later object queues (or that we haven't seen it
+   at all).  All values must be non-positive, since positive values
+   are physical dump offsets.  */
+enum dump_object_special_offset
+  {
+   DUMP_OBJECT_IS_RUNTIME_MAGIC = -6,
+   DUMP_OBJECT_ON_COPIED_QUEUE = -5,
+   DUMP_OBJECT_ON_HASH_TABLE_QUEUE = -4,
+   DUMP_OBJECT_ON_SYMBOL_QUEUE = -3,
+   DUMP_OBJECT_ON_COLD_QUEUE = -2,
+   DUMP_OBJECT_ON_NORMAL_QUEUE = -1,
+   DUMP_OBJECT_NOT_SEEN = 0,
+  };
+
+/* Weights for score scores for object non-locality.  */
+enum link_weight_enum
+  {
+    WEIGHT_NONE_VALUE = 0,
+    WEIGHT_NORMAL_VALUE = 1000,
+    WEIGHT_STRONG_VALUE = 1200,
+  };
+
+struct link_weight
+{
+  /* Wrapped in a struct to break unwanted implicit conversion.  */
+  enum link_weight_enum value;
+};
+
+#define LINK_WEIGHT_LITERAL(x) ((struct link_weight){.value=(x)})
+#define WEIGHT_NONE LINK_WEIGHT_LITERAL (WEIGHT_NONE_VALUE)
+#define WEIGHT_NORMAL LINK_WEIGHT_LITERAL (WEIGHT_NORMAL_VALUE)
+#define WEIGHT_STRONG LINK_WEIGHT_LITERAL (WEIGHT_STRONG_VALUE)
+
+
+/* Dump file creation */
+
+static dump_off dump_object (struct dump_context *ctx, Lisp_Object object);
+static dump_off dump_object_for_offset (struct dump_context *ctx,
+                                       Lisp_Object object);
+
+/* Like the Lisp function `push'.  Return NEWELT.  */
+static Lisp_Object
+dump_push (Lisp_Object *where, Lisp_Object newelt)
+{
+  *where = Fcons (newelt, *where);
+  return newelt;
+}
+
+/* Like the Lisp function `pop'.  */
+static Lisp_Object
+dump_pop (Lisp_Object *where)
+{
+  Lisp_Object ret = XCAR (*where);
+  *where = XCDR (*where);
+  return ret;
+}
+
+static bool
+dump_tracking_referrers_p (struct dump_context *ctx)
+{
+  return !NILP (ctx->referrers);
+}
+
+static void
+dump_set_have_current_referrer (struct dump_context *ctx, bool have)
+{
+#ifdef ENABLE_CHECKING
+  ctx->have_current_referrer = have;
+#endif
+}
+
+/* Remember the reason objects are enqueued.
+
+   Until DUMP_CLEAR_REFERRER is called, any objects enqueued are being
+   enqueued because OBJECT refers to them.  It is not legal to enqueue
+   objects without a referer set.  We check this constraint
+   at runtime.
+
+   It is illegal to call DUMP_SET_REFERRER twice without an
+   intervening call to DUMP_CLEAR_REFERRER.
+
+   Define as a macro so we can avoid evaluating OBJECT
+   if we dont want referrer tracking.  */
+#define DUMP_SET_REFERRER(ctx, object)                   \
+  do                                                     \
+    {                                                    \
+      struct dump_context *_ctx = (ctx);                 \
+      eassert (!_ctx->have_current_referrer);            \
+      dump_set_have_current_referrer (_ctx, true);       \
+      if (dump_tracking_referrers_p (_ctx))              \
+        ctx->current_referrer = (object);                \
+    }                                                    \
+  while (0)
+
+/* Unset the referer that DUMP_SET_REFERRER set.
+
+   Named with upper-case letters for symmetry with
+   DUMP_SET_REFERRER.  */
+static void
+DUMP_CLEAR_REFERRER (struct dump_context *ctx)
+{
+  eassert (ctx->have_current_referrer);
+  dump_set_have_current_referrer (ctx, false);
+  if (dump_tracking_referrers_p (ctx))
+    ctx->current_referrer = Qnil;
+}
+
+static Lisp_Object
+dump_ptr_referrer (const char *label, void const *address)
+{
+  char buf[128];
+  buf[0] = '\0';
+  sprintf (buf, "%s @ %p", label, address);
+  return build_string (buf);
+}
+
+static void
+print_paths_to_root (struct dump_context *ctx, Lisp_Object object);
+
+static void dump_remember_cold_op (struct dump_context *ctx,
+                                   enum cold_op op,
+                                   Lisp_Object arg);
+
+static AVOID
+error_unsupported_dump_object (struct dump_context *ctx,
+                               Lisp_Object object,
+                              const char *msg)
+{
+  if (dump_tracking_referrers_p (ctx))
+    print_paths_to_root (ctx, object);
+  error ("unsupported object type in dump: %s", msg);
+}
+
+static uintptr_t
+emacs_basis (void)
+{
+  return (uintptr_t) &Vpurify_flag;
+}
+
+static void *
+emacs_ptr_at (const ptrdiff_t offset)
+{
+  /* TODO: assert somehow that the result is actually in the Emacs
+     image.  */
+  return (void *) (emacs_basis () + offset);
+}
+
+static dump_off
+emacs_offset (const void *emacs_ptr)
+{
+  /* TODO: assert that EMACS_PTR is actually in the Emacs image.  */
+  eassert (emacs_ptr != NULL);
+  intptr_t emacs_ptr_value = (intptr_t) emacs_ptr;
+  ptrdiff_t emacs_ptr_relative = emacs_ptr_value - (intptr_t) emacs_basis ();
+  return ptrdiff_t_to_dump_off (emacs_ptr_relative);
+}
+
+/* Return whether OBJECT is a symbol the storage of which is built
+   into Emacs (and so is invariant across ASLR).  */
+static bool
+dump_builtin_symbol_p (Lisp_Object object)
+{
+  if (!SYMBOLP (object))
+    return false;
+  char *bp = (char *) lispsym;
+  struct Lisp_Symbol *s = XSYMBOL (object);
+  char *sp = (char *) s;
+  return bp <= sp && sp < bp + sizeof (lispsym);
+}
+
+/* Return whether OBJECT has the same bit pattern in all Emacs
+   invocations --- i.e., is invariant across a dump.  Note that some
+   self-representing objects still need to be dumped!
+*/
+static bool
+dump_object_self_representing_p (Lisp_Object object)
+{
+  return FIXNUMP (object) || dump_builtin_symbol_p (object);
+}
+
+#define DEFINE_FROMLISP_FUNC(fn, type)          \
+  static type                                   \
+  fn (Lisp_Object value)                        \
+  {                                             \
+    ALLOW_IMPLICIT_CONVERSION;                  \
+    if (FIXNUMP (value))                        \
+      return XFIXNUM (value);                   \
+    eassert (BIGNUMP (value));                  \
+    type result;                               \
+    if (TYPE_SIGNED (type))                    \
+      result = bignum_to_intmax (value);       \
+    else                                       \
+      result = bignum_to_uintmax (value);      \
+    DISALLOW_IMPLICIT_CONVERSION;               \
+    return result;                             \
+  }
+
+#define DEFINE_TOLISP_FUNC(fn, type) \
+  static Lisp_Object                 \
+  fn (type value)                    \
+  {                                  \
+    return INT_TO_INTEGER (value);   \
+  }
+
+DEFINE_FROMLISP_FUNC (intmax_t_from_lisp, intmax_t)
+DEFINE_TOLISP_FUNC (intmax_t_to_lisp, intmax_t)
+DEFINE_FROMLISP_FUNC (dump_off_from_lisp, dump_off)
+DEFINE_TOLISP_FUNC (dump_off_to_lisp, dump_off)
+
+static void
+dump_write (struct dump_context *ctx, const void *buf, dump_off nbyte)
+{
+  eassert (nbyte == 0 || buf != NULL);
+  eassert (ctx->obj_offset == 0);
+  eassert (ctx->flags.dump_object_contents);
+  if (emacs_write (ctx->fd, buf, nbyte) < nbyte)
+    report_file_error ("Could not write to dump file", ctx->dump_filename);
+  ctx->offset += nbyte;
+}
+
+static Lisp_Object
+make_eq_hash_table (void)
+{
+  return CALLN (Fmake_hash_table, QCtest, Qeq);
+}
+
+static void
+dump_tailq_init (struct dump_tailq *tailq)
+{
+  tailq->head = tailq->tail = Qnil;
+  tailq->length = 0;
+}
+
+static intptr_t
+dump_tailq_length (const struct dump_tailq *tailq)
+{
+  return tailq->length;
+}
+
+static void ATTRIBUTE_UNUSED
+dump_tailq_prepend (struct dump_tailq *tailq, Lisp_Object value)
+{
+  Lisp_Object link = Fcons (value, tailq->head);
+  tailq->head = link;
+  if (NILP (tailq->tail))
+    tailq->tail = link;
+  tailq->length += 1;
+}
+
+static void ATTRIBUTE_UNUSED
+dump_tailq_append (struct dump_tailq *tailq, Lisp_Object value)
+{
+  Lisp_Object link = Fcons (value, Qnil);
+  if (NILP (tailq->head))
+    {
+      eassert (NILP (tailq->tail));
+      tailq->head = tailq->tail = link;
+    }
+  else
+    {
+      eassert (!NILP (tailq->tail));
+      XSETCDR (tailq->tail, link);
+      tailq->tail = link;
+    }
+  tailq->length += 1;
+}
+
+static bool
+dump_tailq_empty_p (struct dump_tailq *tailq)
+{
+  return NILP (tailq->head);
+}
+
+static Lisp_Object
+dump_tailq_peek (struct dump_tailq *tailq)
+{
+  eassert (!dump_tailq_empty_p (tailq));
+  return XCAR (tailq->head);
+}
+
+static Lisp_Object
+dump_tailq_pop (struct dump_tailq *tailq)
+{
+  eassert (!dump_tailq_empty_p (tailq));
+  eassert (tailq->length > 0);
+  tailq->length -= 1;
+  Lisp_Object value = XCAR (tailq->head);
+  tailq->head = XCDR (tailq->head);
+  if (NILP (tailq->head))
+    tailq->tail = Qnil;
+  return value;
+}
+
+static void
+dump_seek (struct dump_context *ctx, dump_off offset)
+{
+  eassert (ctx->obj_offset == 0);
+  if (lseek (ctx->fd, offset, SEEK_SET) < 0)
+    report_file_error ("Setting file position",
+                       ctx->dump_filename);
+  ctx->offset = offset;
+}
+
+static void
+dump_write_zero (struct dump_context *ctx, dump_off nbytes)
+{
+  while (nbytes > 0)
+    {
+      uintmax_t zero = 0;
+      dump_off to_write = sizeof (zero);
+      if (to_write > nbytes)
+        to_write = nbytes;
+      dump_write (ctx, &zero, to_write);
+      nbytes -= to_write;
+    }
+}
+
+static void
+dump_align_output (struct dump_context *ctx, int alignment)
+{
+  if (ctx->offset % alignment != 0)
+    dump_write_zero (ctx, alignment - (ctx->offset % alignment));
+}
+
+static dump_off
+dump_object_start (struct dump_context *ctx,
+                   void *out,
+                   dump_off outsz)
+{
+  /* We dump only one object at a time, so obj_offset should be
+     invalid on entry to this function.  */
+  eassert (ctx->obj_offset == 0);
+  int alignment = ctx->flags.pack_objects ? 1 : DUMP_ALIGNMENT;
+  if (ctx->flags.dump_object_contents)
+    dump_align_output (ctx, alignment);
+  ctx->obj_offset = ctx->offset;
+  memset (out, 0, outsz);
+  return ctx->offset;
+}
+
+static dump_off
+dump_object_finish (struct dump_context *ctx,
+                    const void *out,
+                    dump_off sz)
+{
+  dump_off offset = ctx->obj_offset;
+  eassert (offset > 0);
+  eassert (offset == ctx->offset); /* No intervening writes.  */
+  ctx->obj_offset = 0;
+  if (ctx->flags.dump_object_contents)
+    dump_write (ctx, out, sz);
+  return offset;
+}
+
+/* Return offset at which OBJECT has been dumped, or one of the 
dump_object_special_offset
+   negative values, or DUMP_OBJECT_NOT_SEEN.  */
+static dump_off
+dump_recall_object (struct dump_context *ctx, Lisp_Object object)
+{
+  Lisp_Object dumped = ctx->objects_dumped;
+  return dump_off_from_lisp (Fgethash (object, dumped,
+                                       make_fixnum (DUMP_OBJECT_NOT_SEEN)));
+}
+
+static void
+dump_remember_object (struct dump_context *ctx,
+                      Lisp_Object object,
+                      dump_off offset)
+{
+  Fputhash (object,
+            dump_off_to_lisp (offset),
+            ctx->objects_dumped);
+}
+
+static void
+dump_note_reachable (struct dump_context *ctx, Lisp_Object object)
+{
+  eassert (ctx->have_current_referrer);
+  if (!dump_tracking_referrers_p (ctx))
+    return;
+  Lisp_Object referrer = ctx->current_referrer;
+  Lisp_Object obj_referrers = Fgethash (object, ctx->referrers, Qnil);
+  if (NILP (Fmemq (referrer, obj_referrers)))
+    Fputhash (object, Fcons (referrer, obj_referrers), ctx->referrers);
+}
+
+/* If this object lives in the Emacs image and not on the heap, return
+   a pointer to the object data.  Otherwise, return NULL.  */
+static void *
+dump_object_emacs_ptr (Lisp_Object lv)
+{
+  if (SUBRP (lv))
+    return XSUBR (lv);
+  if (dump_builtin_symbol_p (lv))
+    return XSYMBOL (lv);
+  if (XTYPE (lv) == Lisp_Vectorlike
+      && PSEUDOVECTOR_TYPEP (&XVECTOR (lv)->header, PVEC_THREAD)
+      && main_thread_p (XTHREAD (lv)))
+    return XTHREAD (lv);
+  return NULL;
+}
+
+static void
+dump_queue_init (struct dump_queue *dump_queue)
+{
+  dump_tailq_init (&dump_queue->zero_weight_objects);
+  dump_tailq_init (&dump_queue->one_weight_normal_objects);
+  dump_tailq_init (&dump_queue->one_weight_strong_objects);
+  dump_tailq_init (&dump_queue->fancy_weight_objects);
+  dump_queue->link_weights = make_eq_hash_table ();
+  dump_queue->sequence_numbers = make_eq_hash_table ();
+  dump_queue->next_sequence_number = 1;
+}
+
+static bool
+dump_queue_empty_p (struct dump_queue *dump_queue)
+{
+  bool is_empty =
+    EQ (Fhash_table_count (dump_queue->sequence_numbers),
+        make_fixnum (0));
+  eassert (EQ (Fhash_table_count (dump_queue->sequence_numbers),
+               Fhash_table_count (dump_queue->link_weights)));
+  if (!is_empty)
+    {
+      eassert (!dump_tailq_empty_p (&dump_queue->zero_weight_objects)
+              || !dump_tailq_empty_p (&dump_queue->one_weight_normal_objects)
+              || !dump_tailq_empty_p (&dump_queue->one_weight_strong_objects)
+              || !dump_tailq_empty_p (&dump_queue->fancy_weight_objects));
+    }
+  else
+    {
+      /* If we're empty, we can still have a few stragglers on one of
+         the above queues.  */
+    }
+
+  return is_empty;
+}
+
+static void
+dump_queue_push_weight (Lisp_Object *weight_list,
+                        dump_off basis,
+                        struct link_weight weight)
+{
+  if (EQ (*weight_list, Qt))
+    *weight_list = Qnil;
+  dump_push (weight_list, Fcons (dump_off_to_lisp (basis),
+                                 dump_off_to_lisp (weight.value)));
+}
+
+static void
+dump_queue_enqueue (struct dump_queue *dump_queue,
+                    Lisp_Object object,
+                    dump_off basis,
+                    struct link_weight weight)
+{
+  Lisp_Object weights = Fgethash (object, dump_queue->link_weights, Qnil);
+  Lisp_Object orig_weights = weights;
+  /* N.B. want to find the last item of a given weight in each queue
+     due to prepend use.  */
+  bool use_single_queues = true;
+  if (NILP (weights))
+    {
+      /* Object is new.  */
+      dump_trace ("new object %016x weight=%u\n",
+                  (unsigned) XLI (object),
+                  (unsigned) weight.value);
+
+      if (weight.value == WEIGHT_NONE.value)
+        {
+          eassert (weight.value == 0);
+          dump_tailq_prepend (&dump_queue->zero_weight_objects, object);
+          weights = Qt;
+        }
+      else if (!use_single_queues)
+        {
+          dump_tailq_prepend (&dump_queue->fancy_weight_objects, object);
+          dump_queue_push_weight (&weights, basis, weight);
+        }
+      else if (weight.value == WEIGHT_NORMAL.value)
+        {
+          dump_tailq_prepend (&dump_queue->one_weight_normal_objects, object);
+          dump_queue_push_weight (&weights, basis, weight);
+        }
+      else if (weight.value == WEIGHT_STRONG.value)
+        {
+          dump_tailq_prepend (&dump_queue->one_weight_strong_objects, object);
+          dump_queue_push_weight (&weights, basis, weight);
+        }
+      else
+        {
+          emacs_abort ();
+        }
+
+      Fputhash (object,
+                dump_off_to_lisp(dump_queue->next_sequence_number++),
+                dump_queue->sequence_numbers);
+    }
+  else
+    {
+      /* Object was already on the queue.  It's okay for an object to
+         be on multiple queues so long as we maintain order
+         invariants: attempting to dump an object multiple times is
+         harmless, and most of the time, an object is only referenced
+         once before being dumped, making this code path uncommon.  */
+      if (weight.value != WEIGHT_NONE.value)
+        {
+          if (EQ (weights, Qt))
+            {
+              /* Object previously had a zero weight.  Once we
+                 incorporate the link weight attached to this call,
+                 the object will have a single weight.  Put the object
+                 on the appropriate single-weight queue.  */
+              weights = Qnil;
+             struct dump_tailq *tailq;
+              if (!use_single_queues)
+               tailq = &dump_queue->fancy_weight_objects;
+              else if (weight.value == WEIGHT_NORMAL.value)
+               tailq = &dump_queue->one_weight_normal_objects;
+              else if (weight.value == WEIGHT_STRONG.value)
+               tailq = &dump_queue->one_weight_strong_objects;
+              else
+                emacs_abort ();
+             dump_tailq_prepend (tailq, object);
+            }
+          else if (use_single_queues && NILP (XCDR (weights)))
+            dump_tailq_prepend (&dump_queue->fancy_weight_objects, object);
+          dump_queue_push_weight (&weights, basis, weight);
+        }
+    }
+
+  if (!EQ (weights, orig_weights))
+    Fputhash (object, weights, dump_queue->link_weights);
+}
+
+static float
+dump_calc_link_score (dump_off basis,
+                      dump_off link_basis,
+                      dump_off link_weight)
+{
+  float distance = (float)(basis - link_basis);
+  eassert (distance >= 0);
+  float link_score = powf (distance, -0.2f);
+  return powf (link_score, (float) link_weight / 1000.0f);
+}
+
+/* Compute the score score for a queued object.
+
+   OBJECT is the object to query, which must currently be queued for
+   dumping.  BASIS is the offset at which we would be
+   dumping the object; score is computed relative to BASIS and the
+   various BASIS values supplied to dump_add_link_weight --- the
+   further an object is from its referrers, the greater the
+   score.  */
+static float
+dump_queue_compute_score (struct dump_queue *dump_queue,
+                          Lisp_Object object,
+                          dump_off basis)
+{
+  float score = 0;
+  Lisp_Object object_link_weights =
+    Fgethash (object, dump_queue->link_weights, Qnil);
+  if (EQ (object_link_weights, Qt))
+    object_link_weights = Qnil;
+  while (!NILP (object_link_weights))
+    {
+      Lisp_Object basis_weight_pair = dump_pop (&object_link_weights);
+      dump_off link_basis = dump_off_from_lisp (XCAR (basis_weight_pair));
+      dump_off link_weight = dump_off_from_lisp (XCDR (basis_weight_pair));
+      score += dump_calc_link_score (basis, link_basis, link_weight);
+    }
+  return score;
+}
+
+/* Scan the fancy part of the dump queue.
+
+   BASIS is the position at which to evaluate the score function,
+   usually ctx->offset.
+
+   If we have at least one entry in the queue, return the pointer (in
+   the singly-linked list) to the cons containing the object via
+   *OUT_HIGHEST_SCORE_CONS_PTR and return its score.
+
+   If the queue is empty, set *OUT_HIGHEST_SCORE_CONS_PTR to NULL
+   and return negative infinity.  */
+static float
+dump_queue_scan_fancy (struct dump_queue *dump_queue,
+                       dump_off basis,
+                       Lisp_Object **out_highest_score_cons_ptr)
+{
+  Lisp_Object *cons_ptr = &dump_queue->fancy_weight_objects.head;
+  Lisp_Object *highest_score_cons_ptr = NULL;
+  float highest_score = -INFINITY;
+  bool first = true;
+
+  while (!NILP (*cons_ptr))
+    {
+      Lisp_Object queued_object = XCAR (*cons_ptr);
+      float score = dump_queue_compute_score (dump_queue, queued_object, 
basis);
+      if (first || score >= highest_score)
+        {
+          highest_score_cons_ptr = cons_ptr;
+          highest_score = score;
+          if (first)
+            first = false;
+        }
+      cons_ptr = &XCONS (*cons_ptr)->u.s.u.cdr;
+    }
+
+  *out_highest_score_cons_ptr = highest_score_cons_ptr;
+  return highest_score;
+}
+
+/* Return the sequence number of OBJECT.
+
+   Return -1 if object doesn't have a sequence number.  This situation
+   can occur when we've double-queued an object.  If this happens, we
+   discard the errant object and try again.  */
+static dump_off
+dump_queue_sequence (struct dump_queue *dump_queue,
+                     Lisp_Object object)
+{
+  Lisp_Object n = Fgethash (object, dump_queue->sequence_numbers, Qnil);
+  return NILP (n) ? -1 : dump_off_from_lisp (n);
+}
+
+/* Find score and sequence at head of a one-weight object queue.
+
+   Transparently discard stale objects from head of queue.  BASIS
+   is the baseness for score computation.
+
+   We organize these queues so that score is strictly decreasing, so
+   examining the head is sufficient.  */
+static void
+dump_queue_find_score_of_one_weight_queue (struct dump_queue *dump_queue,
+                                          dump_off basis,
+                                          struct dump_tailq *one_weight_queue,
+                                          float *out_score,
+                                          int *out_sequence)
+{
+  /* Transparently discard stale objects from the head of this queue.  */
+  do
+    {
+      if (dump_tailq_empty_p (one_weight_queue))
+        {
+          *out_score = -INFINITY;
+          *out_sequence = 0;
+        }
+      else
+        {
+          Lisp_Object head = dump_tailq_peek (one_weight_queue);
+          *out_sequence = dump_queue_sequence (dump_queue, head);
+          if (*out_sequence < 0)
+            dump_tailq_pop (one_weight_queue);
+          else
+            *out_score =
+              dump_queue_compute_score (dump_queue, head, basis);
+        }
+    }
+  while (*out_sequence < 0);
+}
+
+/* Pop the next object to dump from the dump queue.
+
+   BASIS is the dump offset at which to evaluate score.
+
+   The object returned is the queued object with the greatest score;
+   by side effect, the object is removed from the dump queue.
+   The dump queue must not be empty.  */
+static Lisp_Object
+dump_queue_dequeue (struct dump_queue *dump_queue, dump_off basis)
+{
+  eassert (EQ (Fhash_table_count (dump_queue->sequence_numbers),
+               Fhash_table_count (dump_queue->link_weights)));
+
+  eassert (XFIXNUM (Fhash_table_count (dump_queue->sequence_numbers))
+          <= (dump_tailq_length (&dump_queue->fancy_weight_objects)
+              + dump_tailq_length (&dump_queue->zero_weight_objects)
+              + dump_tailq_length (&dump_queue->one_weight_normal_objects)
+              + dump_tailq_length (&dump_queue->one_weight_strong_objects)));
+
+  bool dump_object_counts = true;
+  if (dump_object_counts)
+    dump_trace
+      ("dump_queue_dequeue basis=%d fancy=%u zero=%u "
+       "normal=%u strong=%u hash=%u\n",
+       basis,
+       (unsigned) dump_tailq_length (&dump_queue->fancy_weight_objects),
+       (unsigned) dump_tailq_length (&dump_queue->zero_weight_objects),
+       (unsigned) dump_tailq_length (&dump_queue->one_weight_normal_objects),
+       (unsigned) dump_tailq_length (&dump_queue->one_weight_strong_objects),
+       (unsigned) XFIXNUM (Fhash_table_count (dump_queue->link_weights)));
+
+  static const int nr_candidates = 3;
+  struct candidate
+  {
+    float score;
+    dump_off sequence;
+  } candidates[nr_candidates];
+
+  Lisp_Object *fancy_cons = NULL;
+  candidates[0].sequence = 0;
+  do
+    {
+      if (candidates[0].sequence < 0)
+        *fancy_cons = XCDR (*fancy_cons);  /* Discard stale object.  */
+      candidates[0].score = dump_queue_scan_fancy (dump_queue, basis,
+                                                  &fancy_cons);
+      candidates[0].sequence =
+        candidates[0].score > -INFINITY
+        ? dump_queue_sequence (dump_queue, XCAR (*fancy_cons))
+        : 0;
+    }
+  while (candidates[0].sequence < 0);
+
+  dump_queue_find_score_of_one_weight_queue
+    (dump_queue, basis,
+     &dump_queue->one_weight_normal_objects,
+     &candidates[1].score,
+     &candidates[1].sequence);
+
+  dump_queue_find_score_of_one_weight_queue
+    (dump_queue, basis,
+     &dump_queue->one_weight_strong_objects,
+     &candidates[2].score,
+     &candidates[2].sequence);
+
+  int best = -1;
+  for (int i = 0; i < nr_candidates; ++i)
+    {
+      eassert (candidates[i].sequence >= 0);
+      if (candidates[i].score > -INFINITY
+         && (best < 0
+             || candidates[i].score > candidates[best].score
+             || (candidates[i].score == candidates[best].score
+                 && candidates[i].sequence < candidates[best].sequence)))
+        best = i;
+    }
+
+  Lisp_Object result;
+  const char *src;
+  if (best < 0)
+    {
+      src = "zero";
+      result = dump_tailq_pop (&dump_queue->zero_weight_objects);
+    }
+  else if (best == 0)
+    {
+      src = "fancy";
+      result = dump_tailq_pop (&dump_queue->fancy_weight_objects);
+    }
+  else if (best == 1)
+    {
+      src = "normal";
+      result = dump_tailq_pop (&dump_queue->one_weight_normal_objects);
+    }
+  else if (best == 2)
+    {
+      src = "strong";
+      result = dump_tailq_pop (&dump_queue->one_weight_strong_objects);
+    }
+  else
+    emacs_abort ();
+
+  dump_trace ("  result score=%f src=%s object=%016x\n",
+              best < 0 ? -1.0 : (double) candidates[best].score,
+              src,
+              (unsigned) XLI (result));
+
+  {
+    Lisp_Object weights = Fgethash (result, dump_queue->link_weights, Qnil);
+    while (!NILP (weights) && CONSP (weights))
+      {
+        Lisp_Object basis_weight_pair = dump_pop (&weights);
+        dump_off link_basis =
+          dump_off_from_lisp (XCAR (basis_weight_pair));
+        dump_off link_weight =
+          dump_off_from_lisp (XCDR (basis_weight_pair));
+       dump_trace
+         ("    link_basis=%d distance=%d weight=%d contrib=%f\n",
+          link_basis,
+          basis - link_basis,
+          link_weight,
+          (double) dump_calc_link_score (basis, link_basis, link_weight));
+      }
+  }
+
+  Fremhash (result, dump_queue->link_weights);
+  Fremhash (result, dump_queue->sequence_numbers);
+  return result;
+}
+
+/* Return whether we need to write OBJECT to the dump file.  */
+static bool
+dump_object_needs_dumping_p (Lisp_Object object)
+{
+  /* Some objects, like symbols, are self-representing because they
+     have invariant bit patterns, but sometimes these objects have
+     associated data too, and these data-carrying objects need to be
+     included in the dump despite all references to them being
+     bitwise-invariant.  */
+  return (!dump_object_self_representing_p (object)
+         || dump_object_emacs_ptr (object));
+}
+
+static void
+dump_enqueue_object (struct dump_context *ctx,
+                     Lisp_Object object,
+                     struct link_weight weight)
+{
+  if (dump_object_needs_dumping_p (object))
+    {
+      dump_off state = dump_recall_object (ctx, object);
+      bool already_dumped_object = state > DUMP_OBJECT_NOT_SEEN;
+      if (ctx->flags.assert_already_seen)
+        eassert (already_dumped_object);
+      if (!already_dumped_object)
+        {
+          if (state == DUMP_OBJECT_NOT_SEEN)
+            {
+              state = DUMP_OBJECT_ON_NORMAL_QUEUE;
+              dump_remember_object (ctx, object, state);
+            }
+          /* Note that we call dump_queue_enqueue even if the object
+             is already on the normal queue: multiple enqueue calls
+             can increase the object's weight.  */
+          if (state == DUMP_OBJECT_ON_NORMAL_QUEUE)
+            dump_queue_enqueue (&ctx->dump_queue,
+                                object,
+                                ctx->offset,
+                                weight);
+        }
+    }
+  /* Always remember the path to this object.  */
+  dump_note_reachable (ctx, object);
+}
+
+static void
+print_paths_to_root_1 (struct dump_context *ctx,
+                       Lisp_Object object,
+                       int level)
+{
+  Lisp_Object referrers = Fgethash (object, ctx->referrers, Qnil);
+  while (!NILP (referrers))
+    {
+      Lisp_Object referrer = XCAR (referrers);
+      referrers = XCDR (referrers);
+      Lisp_Object repr = Fprin1_to_string (referrer, Qnil);
+      for (int i = 0; i < level; ++i)
+        fputc (' ', stderr);
+      fprintf (stderr, "%s\n", SDATA (repr));
+      print_paths_to_root_1 (ctx, referrer, level + 1);
+    }
+}
+
+static void
+print_paths_to_root (struct dump_context *ctx, Lisp_Object object)
+{
+  print_paths_to_root_1 (ctx, object, 0);
+}
+
+static void
+dump_remember_cold_op (struct dump_context *ctx,
+                       enum cold_op op,
+                       Lisp_Object arg)
+{
+  if (ctx->flags.dump_object_contents)
+    dump_push (&ctx->cold_queue, Fcons (make_fixnum (op), arg));
+}
+
+/* Add a dump relocation that points into Emacs.
+
+   Add a relocation that updates the pointer stored at DUMP_OFFSET to
+   point into the Emacs binary upon dump load.  The pointer-sized
+   value at DUMP_OFFSET in the dump file should contain a number
+   relative to emacs_basis().  */
+static void
+dump_reloc_dump_to_emacs_ptr_raw (struct dump_context *ctx,
+                                  dump_off dump_offset)
+{
+  if (ctx->flags.dump_object_contents)
+    dump_push (&ctx->dump_relocs,
+               list2 (make_fixnum (RELOC_DUMP_TO_EMACS_PTR_RAW),
+                      dump_off_to_lisp (dump_offset)));
+}
+
+/* Add a dump relocation that points a Lisp_Object back at the dump.
+
+   Add a relocation that updates the Lisp_Object at DUMP_OFFSET in the
+   dump to point to another object in the dump.  The Lisp_Object-sized
+   value at DUMP_OFFSET in the dump file should contain the offset of
+   the target object relative to the start of the dump.  */
+static void
+dump_reloc_dump_to_dump_lv (struct dump_context *ctx,
+                            dump_off dump_offset,
+                            enum Lisp_Type type)
+{
+  if (!ctx->flags.dump_object_contents)
+    return;
+
+  int reloc_type;
+  switch (type)
+    {
+    case Lisp_Symbol:
+    case Lisp_String:
+    case Lisp_Vectorlike:
+    case Lisp_Cons:
+    case Lisp_Float:
+      reloc_type = RELOC_DUMP_TO_DUMP_LV + type;
+      break;
+    default:
+      emacs_abort ();
+    }
+
+  dump_push (&ctx->dump_relocs,
+             list2 (make_fixnum (reloc_type),
+                    dump_off_to_lisp (dump_offset)));
+}
+
+/* Add a dump relocation that points a raw pointer back at the dump.
+
+   Add a relocation that updates the raw pointer at DUMP_OFFSET in the
+   dump to point to another object in the dump.  The pointer-sized
+   value at DUMP_OFFSET in the dump file should contain the offset of
+   the target object relative to the start of the dump.  */
+static void
+dump_reloc_dump_to_dump_ptr_raw (struct dump_context *ctx,
+                                 dump_off dump_offset)
+{
+  if (ctx->flags.dump_object_contents)
+    dump_push (&ctx->dump_relocs,
+               list2 (make_fixnum (RELOC_DUMP_TO_DUMP_PTR_RAW),
+                      dump_off_to_lisp (dump_offset)));
+}
+
+/* Add a dump relocation that points to a Lisp object in Emacs.
+
+   Add a relocation that updates the Lisp_Object at DUMP_OFFSET in the
+   dump to point to a lisp object in Emacs.  The Lisp_Object-sized
+   value at DUMP_OFFSET in the dump file should contain the offset of
+   the target object relative to emacs_basis().  TYPE is the type of
+   Lisp value.  */
+static void
+dump_reloc_dump_to_emacs_lv (struct dump_context *ctx,
+                             dump_off dump_offset,
+                             enum Lisp_Type type)
+{
+  if (!ctx->flags.dump_object_contents)
+    return;
+
+  int reloc_type;
+  switch (type)
+    {
+    case Lisp_String:
+    case Lisp_Vectorlike:
+    case Lisp_Cons:
+    case Lisp_Float:
+      reloc_type = RELOC_DUMP_TO_EMACS_LV + type;
+      break;
+    default:
+      emacs_abort ();
+    }
+
+  dump_push (&ctx->dump_relocs,
+             list2 (make_fixnum (reloc_type),
+                    dump_off_to_lisp (dump_offset)));
+}
+
+/* Add an Emacs relocation that copies arbitrary bytes from the dump.
+
+   When the dump is loaded, Emacs copies SIZE bytes from OFFSET in
+   dump to LOCATION in the Emacs data section.  This copying happens
+   after other relocations, so it's all right to, say, copy a
+   Lisp_Object (since by the time we copy the Lisp_Object, it'll have
+   been adjusted to account for the location of the running Emacs and
+   dump file).  */
+static void
+dump_emacs_reloc_copy_from_dump (struct dump_context *ctx, dump_off 
dump_offset,
+                                void *emacs_ptr, dump_off size)
+{
+  eassert (size >= 0);
+  eassert (size < (1 << EMACS_RELOC_LENGTH_BITS));
+
+  if (!ctx->flags.dump_object_contents)
+    return;
+
+  if (size == 0)
+    return;
+
+  eassert (dump_offset >= 0);
+  dump_push (&ctx->emacs_relocs,
+             list4 (make_fixnum (RELOC_EMACS_COPY_FROM_DUMP),
+                    dump_off_to_lisp (emacs_offset (emacs_ptr)),
+                    dump_off_to_lisp (dump_offset),
+                    dump_off_to_lisp (size)));
+}
+
+/* Add an Emacs relocation that sets values to arbitrary bytes.
+
+   When the dump is loaded, Emacs copies SIZE bytes from the
+   relocation itself to the adjusted location inside Emacs EMACS_PTR.
+   SIZE is the number of bytes to copy.  See struct emacs_reloc for
+   the maximum size that this mechanism can support.  The value comes
+   from VALUE_PTR.
+ */
+static void
+dump_emacs_reloc_immediate (struct dump_context *ctx,
+                            const void *emacs_ptr,
+                            const void *value_ptr,
+                            dump_off size)
+{
+  if (!ctx->flags.dump_object_contents)
+    return;
+
+  intmax_t value = 0;
+  eassert (size <= sizeof (value));
+  memcpy (&value, value_ptr, size);
+  dump_push (&ctx->emacs_relocs,
+             list4 (make_fixnum (RELOC_EMACS_IMMEDIATE),
+                    dump_off_to_lisp (emacs_offset (emacs_ptr)),
+                    intmax_t_to_lisp (value),
+                    dump_off_to_lisp (size)));
+}
+
+#define DEFINE_EMACS_IMMEDIATE_FN(fnname, type)                         \
+  static void                                                           \
+  fnname (struct dump_context *ctx,                                     \
+          const type *emacs_ptr,                                        \
+          type value)                                                   \
+  {                                                                     \
+    dump_emacs_reloc_immediate (                                        \
+      ctx, emacs_ptr, &value, sizeof (value));                          \
+  }
+
+DEFINE_EMACS_IMMEDIATE_FN (dump_emacs_reloc_immediate_lv, Lisp_Object)
+DEFINE_EMACS_IMMEDIATE_FN (dump_emacs_reloc_immediate_ptrdiff_t, ptrdiff_t)
+DEFINE_EMACS_IMMEDIATE_FN (dump_emacs_reloc_immediate_intmax_t, intmax_t)
+DEFINE_EMACS_IMMEDIATE_FN (dump_emacs_reloc_immediate_int, int)
+DEFINE_EMACS_IMMEDIATE_FN (dump_emacs_reloc_immediate_bool, bool)
+
+/* Add an emacs relocation that makes a raw pointer in Emacs point
+   into the dump.  */
+static void
+dump_emacs_reloc_to_dump_ptr_raw (struct dump_context *ctx,
+                                 const void *emacs_ptr, dump_off dump_offset)
+{
+  if (!ctx->flags.dump_object_contents)
+    return;
+
+  dump_push (&ctx->emacs_relocs,
+             list3 (make_fixnum (RELOC_EMACS_DUMP_PTR_RAW),
+                    dump_off_to_lisp (emacs_offset (emacs_ptr)),
+                    dump_off_to_lisp (dump_offset)));
+}
+
+/* Add an emacs relocation that points into the dump.
+
+   When the dump is loaded, the Lisp_Object at EMACS_ROOT in Emacs to
+   point to VALUE.  VALUE can be any Lisp value; this function
+   automatically queues the value for dumping if necessary.  */
+static void
+dump_emacs_reloc_to_lv (struct dump_context *ctx,
+                       Lisp_Object const *emacs_ptr,
+                        Lisp_Object value)
+{
+  if (dump_object_self_representing_p (value))
+    dump_emacs_reloc_immediate_lv (ctx, emacs_ptr, value);
+  else
+    {
+      if (ctx->flags.dump_object_contents)
+        /* Conditionally use RELOC_EMACS_EMACS_LV or
+           RELOC_EMACS_DUMP_LV depending on where the target object
+           lives.  We could just have decode_emacs_reloc pick the
+           right type, but we might as well maintain the invariant
+           that the types on ctx->emacs_relocs correspond to the types
+           of emacs_relocs we actually emit.  */
+       dump_push (&ctx->emacs_relocs,
+                  list3 (make_fixnum (dump_object_emacs_ptr (value)
+                                      ? RELOC_EMACS_EMACS_LV
+                                      : RELOC_EMACS_DUMP_LV),
+                         dump_off_to_lisp (emacs_offset (emacs_ptr)),
+                         value));
+      dump_enqueue_object (ctx, value, WEIGHT_NONE);
+    }
+}
+
+/* Add an emacs relocation that makes a raw pointer in Emacs point
+   back into the Emacs image.  */
+static void
+dump_emacs_reloc_to_emacs_ptr_raw (struct dump_context *ctx, void *emacs_ptr,
+                                  void const *target_emacs_ptr)
+{
+  if (!ctx->flags.dump_object_contents)
+    return;
+
+  dump_push (&ctx->emacs_relocs,
+             list3 (make_fixnum (RELOC_EMACS_EMACS_PTR_RAW),
+                    dump_off_to_lisp (emacs_offset (emacs_ptr)),
+                    dump_off_to_lisp (emacs_offset (target_emacs_ptr))));
+}
+
+/* Add an Emacs relocation that makes a raw pointer in Emacs point to
+   a different part of Emacs.  */
+
+enum dump_fixup_type
+  {
+    DUMP_FIXUP_LISP_OBJECT,
+    DUMP_FIXUP_LISP_OBJECT_RAW,
+    DUMP_FIXUP_PTR_DUMP_RAW,
+    DUMP_FIXUP_BIGNUM_DATA,
+  };
+
+enum dump_lv_fixup_type
+  {
+    LV_FIXUP_LISP_OBJECT,
+    LV_FIXUP_RAW_POINTER,
+  };
+
+/* Make something in the dump point to a lisp object.
+
+   CTX is a dump context.  DUMP_OFFSET is the location in the dump to
+   fix.  VALUE is the object to which the location in the dump
+   should point.
+
+   If FIXUP_SUBTYPE is LV_FIXUP_LISP_OBJECT, we expect a Lisp_Object
+   at DUMP_OFFSET.  If it's LV_FIXUP_RAW_POINTER, we expect a pointer.
+ */
+static void
+dump_remember_fixup_lv (struct dump_context *ctx,
+                        dump_off dump_offset,
+                        Lisp_Object value,
+                        enum dump_lv_fixup_type fixup_subtype)
+{
+  if (!ctx->flags.dump_object_contents)
+    return;
+
+  dump_push (&ctx->fixups,
+            list3 (make_fixnum (fixup_subtype == LV_FIXUP_LISP_OBJECT
+                                ? DUMP_FIXUP_LISP_OBJECT
+                                : DUMP_FIXUP_LISP_OBJECT_RAW),
+                   dump_off_to_lisp (dump_offset),
+                   value));
+}
+
+/* Remember to fix up the dump file such that the pointer-sized value
+   at DUMP_OFFSET points to NEW_DUMP_OFFSET in the dump file and to
+   its absolute address at runtime.  */
+static void
+dump_remember_fixup_ptr_raw (struct dump_context *ctx,
+                             dump_off dump_offset,
+                             dump_off new_dump_offset)
+{
+  if (!ctx->flags.dump_object_contents)
+    return;
+
+  /* We should not be generating relocations into the
+     to-be-copied-into-Emacs dump region.  */
+  eassert (ctx->header.discardable_start == 0
+          || new_dump_offset < ctx->header.discardable_start
+          || (ctx->header.cold_start != 0
+              && new_dump_offset >= ctx->header.cold_start));
+
+  dump_push (&ctx->fixups,
+            list3 (make_fixnum (DUMP_FIXUP_PTR_DUMP_RAW),
+                   dump_off_to_lisp (dump_offset),
+                   dump_off_to_lisp (new_dump_offset)));
+}
+
+static void
+dump_root_visitor (Lisp_Object const *root_ptr, enum gc_root_type type,
+                  void *data)
+{
+  struct dump_context *ctx = data;
+  Lisp_Object value = *root_ptr;
+  if (type == GC_ROOT_C_SYMBOL)
+    {
+      eassert (dump_builtin_symbol_p (value));
+      /* Remember to dump the object itself later along with all the
+         rest of the copied-to-Emacs objects.  */
+      DUMP_SET_REFERRER (ctx, build_string ("built-in symbol list"));
+      dump_enqueue_object (ctx, value, WEIGHT_NONE);
+      DUMP_CLEAR_REFERRER (ctx);
+    }
+  else
+    {
+      if (type == GC_ROOT_STATICPRO)
+        Fputhash (dump_off_to_lisp (emacs_offset (root_ptr)),
+                  Qt,
+                  ctx->staticpro_table);
+      if (root_ptr != &Vinternal_interpreter_environment)
+        {
+          DUMP_SET_REFERRER (ctx, dump_ptr_referrer ("emacs root", root_ptr));
+          dump_emacs_reloc_to_lv (ctx, root_ptr, *root_ptr);
+          DUMP_CLEAR_REFERRER (ctx);
+        }
+    }
+}
+
+/* Kick off the dump process by queuing up the static GC roots.  */
+static void
+dump_roots (struct dump_context *ctx)
+{
+  struct gc_root_visitor visitor = { .visit = dump_root_visitor,
+                                    .data = ctx };
+  visit_static_gc_roots (visitor);
+}
+
+#define PDUMPER_MAX_OBJECT_SIZE 2048
+
+static dump_off
+field_relpos (const void *in_start, const void *in_field)
+{
+  ptrdiff_t in_start_val = (ptrdiff_t) in_start;
+  ptrdiff_t in_field_val = (ptrdiff_t) in_field;
+  eassert (in_start_val <= in_field_val);
+  ptrdiff_t relpos = in_field_val - in_start_val;
+  /* The following assertion attempts to detect bugs whereby IN_START
+     and IN_FIELD don't point to the same object/structure, on the
+     assumption that a too-large difference between them is
+     suspicious.  As of Apr 2019 the largest object we dump -- 'struct
+     buffer' -- is slightly smaller than 1KB, and we want to leave
+     some margin for future extensions.  If the assertion below is
+     ever violated, make sure the two pointers indeed point into the
+     same object, and if so, enlarge the value of PDUMPER_MAX_OBJECT_SIZE.  */
+  eassert (relpos < PDUMPER_MAX_OBJECT_SIZE);
+  return (dump_off) relpos;
+}
+
+static void
+cpyptr (void *out, const void *in)
+{
+  memcpy (out, in, sizeof (void *));
+}
+
+/* Convenience macro for regular assignment.  */
+#define DUMP_FIELD_COPY(out, in, name) \
+  do                                   \
+    {                                  \
+      (out)->name = (in)->name;        \
+    }                                  \
+  while (0)
+
+static void
+dump_field_lv_or_rawptr (struct dump_context *ctx,
+                         void *out,
+                         const void *in_start,
+                         const void *in_field,
+                         /* opt */ const enum Lisp_Type *ptr_raw_type,
+                         struct link_weight weight)
+{
+  eassert (ctx->obj_offset > 0);
+
+  Lisp_Object value;
+  dump_off relpos = field_relpos (in_start, in_field);
+  void *out_field = (char *) out + relpos;
+  bool is_ptr_raw = (ptr_raw_type != NULL);
+
+  if (!is_ptr_raw)
+    {
+      memcpy (&value, in_field, sizeof (value));
+      if (dump_object_self_representing_p (value))
+        {
+          memcpy (out_field, &value, sizeof (value));
+          return;
+        }
+    }
+  else
+    {
+      void *ptrval;
+      cpyptr (&ptrval, in_field);
+      if (ptrval == NULL)
+        return; /* Nothing to do.  */
+      switch (*ptr_raw_type)
+        {
+        case Lisp_Symbol:
+          value = make_lisp_symbol (ptrval);
+          break;
+        case Lisp_String:
+        case Lisp_Vectorlike:
+        case Lisp_Cons:
+        case Lisp_Float:
+          value = make_lisp_ptr (ptrval, *ptr_raw_type);
+          break;
+        default:
+          emacs_abort ();
+        }
+    }
+
+  /* Now value is the Lisp_Object to which we want to point whether or
+     not the field is a raw pointer (in which case we just synthesized
+     the Lisp_Object outselves) or a Lisp_Object (in which case we
+     just copied the thing).  Add a fixup or relocation.  */
+
+  intptr_t out_value;
+  dump_off out_field_offset = ctx->obj_offset + relpos;
+  dump_off target_offset = dump_recall_object (ctx, value);
+  if (DANGEROUS
+      && target_offset > 0 && dump_object_emacs_ptr (value) == NULL)
+    {
+      /* We've already dumped the referenced object, so we can emit
+         the value and a relocation directly instead of indirecting
+         through a fixup.  */
+      out_value = target_offset;
+      if (is_ptr_raw)
+        dump_reloc_dump_to_dump_ptr_raw (ctx, out_field_offset);
+      else
+        dump_reloc_dump_to_dump_lv (ctx, out_field_offset, XTYPE (value));
+    }
+  else
+    {
+      /* We don't know about the target object yet, so add a fixup.
+         When we process the fixup, we'll have dumped the target
+         object.  */
+      out_value = (intptr_t) 0xDEADF00D;
+      dump_remember_fixup_lv (ctx,
+                              out_field_offset,
+                              value,
+                              ( is_ptr_raw
+                                ? LV_FIXUP_RAW_POINTER
+                                : LV_FIXUP_LISP_OBJECT ));
+      dump_enqueue_object (ctx, value, weight);
+    }
+
+  memcpy (out_field, &out_value, sizeof (out_value));
+}
+
+/* Set a pointer field on an output object during dump.
+
+   CTX is the dump context.  OFFSET is the offset at which the current
+   object starts.  OUT is a pointer to the dump output object.
+   IN_START is the start of the current Emacs object.  IN_FIELD is a
+   pointer to the field in that object.  TYPE is the type of pointer
+   to which IN_FIELD points.
+ */
+static void
+dump_field_lv_rawptr (struct dump_context *ctx,
+                      void *out,
+                      const void *in_start,
+                      const void *in_field,
+                      enum Lisp_Type type,
+                      struct link_weight weight)
+{
+  dump_field_lv_or_rawptr (ctx, out, in_start, in_field, &type, weight);
+}
+
+/* Set a Lisp_Object field on an output object during dump.
+
+   CTX is a dump context.  OFFSET is the offset at which the current
+   object starts.  OUT is a pointer to the dump output object.
+   IN_START is the start of the current Emacs object.  IN_FIELD is a
+   pointer to a Lisp_Object field in that object.
+
+   Arrange for the dump to contain fixups and relocations such that,
+   at load time, the given field of the output object contains a valid
+   Lisp_Object pointing to the same notional object that *IN_FIELD
+   contains now.
+
+   See idomatic usage below.  */
+static void
+dump_field_lv (struct dump_context *ctx,
+               void *out,
+               const void *in_start,
+               const Lisp_Object *in_field,
+               struct link_weight weight)
+{
+  dump_field_lv_or_rawptr (ctx, out, in_start, in_field, NULL, weight);
+}
+
+/* Note that we're going to add a manual fixup for the given field
+   later.  */
+static void
+dump_field_fixup_later (struct dump_context *ctx,
+                        void *out,
+                        const void *in_start,
+                        const void *in_field)
+{
+  /* TODO: more error checking.  */
+  (void) field_relpos (in_start, in_field);
+}
+
+/* Mark an output object field, which is as wide as a poiner, as being
+   fixed up to point to a specific offset in the dump.  */
+static void
+dump_field_ptr_to_dump_offset (struct dump_context *ctx,
+                               void *out,
+                               const void *in_start,
+                               const void *in_field,
+                               dump_off target_dump_offset)
+{
+  eassert (ctx->obj_offset > 0);
+  if (!ctx->flags.dump_object_contents)
+    return;
+
+  dump_off relpos = field_relpos (in_start, in_field);
+  dump_reloc_dump_to_dump_ptr_raw (ctx, ctx->obj_offset + relpos);
+  intptr_t outval = target_dump_offset;
+  memcpy ((char *) out + relpos, &outval, sizeof (outval));
+}
+
+/* Mark a field as pointing to a place inside Emacs.
+
+   CTX is the dump context.  OUT points to the out-object for the
+   current dump function.  IN_START points to the start of the object
+   being dumped.  IN_FIELD points to the field inside the object being
+   dumped that we're dumping.  The contents of this field (which
+   should be as wide as a pointer) are the Emacs pointer to dump.
+
+ */
+static void
+dump_field_emacs_ptr (struct dump_context *ctx,
+                      void *out,
+                      const void *in_start,
+                      const void *in_field)
+{
+  eassert (ctx->obj_offset > 0);
+  if (!ctx->flags.dump_object_contents)
+    return;
+
+  dump_off relpos = field_relpos (in_start, in_field);
+  void *abs_emacs_ptr;
+  cpyptr (&abs_emacs_ptr, in_field);
+  intptr_t rel_emacs_ptr = 0;
+  if (abs_emacs_ptr)
+    {
+      rel_emacs_ptr = emacs_offset ((void *)abs_emacs_ptr);
+      dump_reloc_dump_to_emacs_ptr_raw (ctx, ctx->obj_offset + relpos);
+    }
+  cpyptr ((char *) out + relpos, &rel_emacs_ptr);
+}
+
+static void
+_dump_object_start_pseudovector (struct dump_context *ctx,
+                                union vectorlike_header *out_hdr,
+                                const union vectorlike_header *in_hdr)
+{
+  eassert (in_hdr->size & PSEUDOVECTOR_FLAG);
+  ptrdiff_t vec_size = vectorlike_nbytes (in_hdr);
+  dump_object_start (ctx, out_hdr, (dump_off) vec_size);
+  *out_hdr = *in_hdr;
+}
+
+/* Need a macro for alloca.  */
+#define START_DUMP_PVEC(ctx, hdr, type, out)                  \
+  const union vectorlike_header *_in_hdr = (hdr);             \
+  type *out = alloca (vectorlike_nbytes (_in_hdr));           \
+  _dump_object_start_pseudovector (ctx, &out->header, _in_hdr)
+
+static dump_off
+finish_dump_pvec (struct dump_context *ctx,
+                  union vectorlike_header *out_hdr)
+{
+  ALLOW_IMPLICIT_CONVERSION;
+  dump_off result = dump_object_finish (ctx, out_hdr,
+                                       vectorlike_nbytes (out_hdr));
+  DISALLOW_IMPLICIT_CONVERSION;
+  return result;
+}
+
+static void
+dump_pseudovector_lisp_fields (struct dump_context *ctx,
+                              union vectorlike_header *out_hdr,
+                              const union vectorlike_header *in_hdr)
+{
+  const struct Lisp_Vector *in = (const struct Lisp_Vector *) in_hdr;
+  struct Lisp_Vector *out = (struct Lisp_Vector *) out_hdr;
+  ptrdiff_t size = in->header.size;
+  eassert (size & PSEUDOVECTOR_FLAG);
+  size &= PSEUDOVECTOR_SIZE_MASK;
+  for (ptrdiff_t i = 0; i < size; ++i)
+    dump_field_lv (ctx, out, in, &in->contents[i], WEIGHT_STRONG);
+}
+
+static dump_off
+dump_cons (struct dump_context *ctx, const struct Lisp_Cons *cons)
+{
+#if CHECK_STRUCTS && !defined (HASH_Lisp_Cons_00EEE63F67)
+# error "Lisp_Cons changed. See CHECK_STRUCTS comment."
+#endif
+  struct Lisp_Cons out;
+  dump_object_start (ctx, &out, sizeof (out));
+  dump_field_lv (ctx, &out, cons, &cons->u.s.car, WEIGHT_STRONG);
+  dump_field_lv (ctx, &out, cons, &cons->u.s.u.cdr, WEIGHT_NORMAL);
+  return dump_object_finish (ctx, &out, sizeof (out));
+}
+
+static dump_off
+dump_interval_tree (struct dump_context *ctx,
+                    INTERVAL tree,
+                    dump_off parent_offset)
+{
+#if CHECK_STRUCTS && !defined (HASH_interval_1B38941C37)
+# error "interval changed. See CHECK_STRUCTS comment."
+#endif
+  /* TODO: output tree breadth-first?  */
+  struct interval out;
+  dump_object_start (ctx, &out, sizeof (out));
+  DUMP_FIELD_COPY (&out, tree, total_length);
+  DUMP_FIELD_COPY (&out, tree, position);
+  if (tree->left)
+    dump_field_fixup_later (ctx, &out, tree, &tree->left);
+  if (tree->right)
+    dump_field_fixup_later (ctx, &out, tree, &tree->right);
+  if (!tree->up_obj)
+    {
+      eassert (parent_offset != 0);
+      dump_field_ptr_to_dump_offset (ctx, &out, tree, &tree->up.interval,
+                                    parent_offset);
+    }
+  else
+    dump_field_lv (ctx, &out, tree, &tree->up.obj, WEIGHT_STRONG);
+  DUMP_FIELD_COPY (&out, tree, up_obj);
+  eassert (tree->gcmarkbit == 0);
+  DUMP_FIELD_COPY (&out, tree, write_protect);
+  DUMP_FIELD_COPY (&out, tree, visible);
+  DUMP_FIELD_COPY (&out, tree, front_sticky);
+  DUMP_FIELD_COPY (&out, tree, rear_sticky);
+  dump_field_lv (ctx, &out, tree, &tree->plist, WEIGHT_STRONG);
+  dump_off offset = dump_object_finish (ctx, &out, sizeof (out));
+  if (tree->left)
+      dump_remember_fixup_ptr_raw
+       (ctx,
+        offset + dump_offsetof (struct interval, left),
+        dump_interval_tree (ctx, tree->left, offset));
+  if (tree->right)
+      dump_remember_fixup_ptr_raw
+       (ctx,
+        offset + dump_offsetof (struct interval, right),
+        dump_interval_tree (ctx, tree->right, offset));
+  return offset;
+}
+
+static dump_off
+dump_string (struct dump_context *ctx, const struct Lisp_String *string)
+{
+#if CHECK_STRUCTS && !defined (HASH_Lisp_String_86FEA6EC7C)
+# error "Lisp_String changed. See CHECK_STRUCTS comment."
+#endif
+  /* If we have text properties, write them _after_ the string so that
+     at runtime, the prefetcher and cache will DTRT. (We access the
+     string before its properties.).
+
+     There's special code to dump string data contiguously later on.
+     we seldom write to string data and never relocate it, so lumping
+     it together at the end of the dump saves on COW faults.
+
+     If, however, the string's size_byte field is -1, the string data
+     is actually a pointer to Emacs data segment, so we can do even
+     better by emitting a relocation instead of bothering to copy the
+     string data.  */
+  struct Lisp_String out;
+  dump_object_start (ctx, &out, sizeof (out));
+  DUMP_FIELD_COPY (&out, string, u.s.size);
+  DUMP_FIELD_COPY (&out, string, u.s.size_byte);
+  if (string->u.s.intervals)
+    dump_field_fixup_later (ctx, &out, string, &string->u.s.intervals);
+
+  if (string->u.s.size_byte == -2)
+    /* String literal in Emacs rodata.  */
+    dump_field_emacs_ptr (ctx, &out, string, &string->u.s.data);
+  else
+    {
+      dump_field_fixup_later (ctx, &out, string, &string->u.s.data);
+      dump_remember_cold_op (ctx,
+                             COLD_OP_STRING,
+                            make_lisp_ptr ((void *) string, Lisp_String));
+    }
+
+  dump_off offset = dump_object_finish (ctx, &out, sizeof (out));
+  if (string->u.s.intervals)
+    dump_remember_fixup_ptr_raw
+      (ctx,
+       offset + dump_offsetof (struct Lisp_String, u.s.intervals),
+       dump_interval_tree (ctx, string->u.s.intervals, 0));
+
+  return offset;
+}
+
+static dump_off
+dump_marker (struct dump_context *ctx, const struct Lisp_Marker *marker)
+{
+#if CHECK_STRUCTS && !defined (HASH_Lisp_Marker_642DBAF866)
+# error "Lisp_Marker changed. See CHECK_STRUCTS comment."
+#endif
+
+  START_DUMP_PVEC (ctx, &marker->header, struct Lisp_Marker, out);
+  dump_pseudovector_lisp_fields (ctx, &out->header, &marker->header);
+  DUMP_FIELD_COPY (out, marker, need_adjustment);
+  DUMP_FIELD_COPY (out, marker, insertion_type);
+  if (marker->buffer)
+    {
+      dump_field_lv_rawptr (ctx, out, marker, &marker->buffer,
+                           Lisp_Vectorlike, WEIGHT_NORMAL);
+      dump_field_lv_rawptr (ctx, out, marker, &marker->next,
+                           Lisp_Vectorlike, WEIGHT_STRONG);
+      DUMP_FIELD_COPY (out, marker, charpos);
+      DUMP_FIELD_COPY (out, marker, bytepos);
+    }
+  return finish_dump_pvec (ctx, &out->header);
+}
+
+static dump_off
+dump_overlay (struct dump_context *ctx, const struct Lisp_Overlay *overlay)
+{
+#if CHECK_STRUCTS && !defined (HASH_Lisp_Overlay_72EADA9882)
+# error "Lisp_Overlay changed. See CHECK_STRUCTS comment."
+#endif
+  START_DUMP_PVEC (ctx, &overlay->header, struct Lisp_Overlay, out);
+  dump_pseudovector_lisp_fields (ctx, &out->header, &overlay->header);
+  dump_field_lv_rawptr (ctx, out, overlay, &overlay->next,
+                        Lisp_Vectorlike, WEIGHT_STRONG);
+  return finish_dump_pvec (ctx, &out->header);
+}
+
+static void
+dump_field_finalizer_ref (struct dump_context *ctx,
+                          void *out,
+                          const struct Lisp_Finalizer *finalizer,
+                          struct Lisp_Finalizer *const *field)
+{
+  if (*field == &finalizers || *field == &doomed_finalizers)
+    dump_field_emacs_ptr (ctx, out, finalizer, field);
+  else
+    dump_field_lv_rawptr (ctx, out, finalizer, field,
+                          Lisp_Vectorlike,
+                          WEIGHT_NORMAL);
+}
+
+static dump_off
+dump_finalizer (struct dump_context *ctx,
+                const struct Lisp_Finalizer *finalizer)
+{
+#if CHECK_STRUCTS && !defined (HASH_Lisp_Finalizer_D58E647CB8)
+# error "Lisp_Finalizer changed. See CHECK_STRUCTS comment."
+#endif
+  START_DUMP_PVEC (ctx, &finalizer->header, struct Lisp_Finalizer, out);
+  /* Do _not_ call dump_pseudovector_lisp_fields here: we dump the
+     only Lisp field, finalizer->function, manually, so we can give it
+     a low weight.  */
+  dump_field_lv (ctx, &out, finalizer, &finalizer->function, WEIGHT_NONE);
+  dump_field_finalizer_ref (ctx, &out, finalizer, &finalizer->prev);
+  dump_field_finalizer_ref (ctx, &out, finalizer, &finalizer->next);
+  return finish_dump_pvec (ctx, &out->header);
+}
+
+struct bignum_reload_info
+{
+  dump_off data_location;
+  dump_off nlimbs;
+};
+
+static dump_off
+dump_bignum (struct dump_context *ctx, Lisp_Object object)
+{
+#if CHECK_STRUCTS && !defined (HASH_Lisp_Bignum_661945DE2B)
+# error "Lisp_Bignum changed. See CHECK_STRUCTS comment."
+#endif
+  const struct Lisp_Bignum *bignum = XBIGNUM (object);
+  START_DUMP_PVEC (ctx, &bignum->header, struct Lisp_Bignum, out);
+  verify (sizeof (out->value) >= sizeof (struct bignum_reload_info));
+  dump_field_fixup_later (ctx, out, bignum, &bignum->value);
+  dump_off bignum_offset = finish_dump_pvec (ctx, &out->header);
+  if (ctx->flags.dump_object_contents)
+    {
+      /* Export the bignum into a blob in the cold section.  */
+      dump_remember_cold_op (ctx, COLD_OP_BIGNUM, object);
+
+      /* Write the offset of that exported blob here.  */
+      dump_off value_offset
+       = (bignum_offset
+          + (dump_off) offsetof (struct Lisp_Bignum, value));
+      dump_push (&ctx->fixups,
+                list3 (make_fixnum (DUMP_FIXUP_BIGNUM_DATA),
+                       dump_off_to_lisp (value_offset),
+                       object));
+
+      /* When we load the dump, slurp the data blob and turn it into a
+         real bignum.  Attach the relocation to the start of the
+         Lisp_Bignum instead of the actual mpz field so that the
+         relocation offset is aligned.  The relocation-application
+         code knows to actually advance past the header.  */
+      dump_push (&ctx->dump_relocs,
+                 list2 (make_fixnum (RELOC_BIGNUM),
+                        dump_off_to_lisp (bignum_offset)));
+    }
+
+  return bignum_offset;
+}
+
+static dump_off
+dump_float (struct dump_context *ctx, const struct Lisp_Float *lfloat)
+{
+#if CHECK_STRUCTS && !defined (HASH_Lisp_Float_50A7B216D9)
+# error "Lisp_Float changed. See CHECK_STRUCTS comment."
+#endif
+  eassert (ctx->header.cold_start);
+  struct Lisp_Float out;
+  dump_object_start (ctx, &out, sizeof (out));
+  DUMP_FIELD_COPY (&out, lfloat, u.data);
+  return dump_object_finish (ctx, &out, sizeof (out));
+}
+
+static dump_off
+dump_fwd_int (struct dump_context *ctx, const struct Lisp_Intfwd *intfwd)
+{
+#if CHECK_STRUCTS && !defined HASH_Lisp_Intfwd_4D887A7387
+# error "Lisp_Intfwd changed. See CHECK_STRUCTS comment."
+#endif
+  dump_emacs_reloc_immediate_intmax_t (ctx, intfwd->intvar, *intfwd->intvar);
+  struct Lisp_Intfwd out;
+  dump_object_start (ctx, &out, sizeof (out));
+  DUMP_FIELD_COPY (&out, intfwd, type);
+  dump_field_emacs_ptr (ctx, &out, intfwd, &intfwd->intvar);
+  return dump_object_finish (ctx, &out, sizeof (out));
+}
+
+static dump_off
+dump_fwd_bool (struct dump_context *ctx, const struct Lisp_Boolfwd *boolfwd)
+{
+#if CHECK_STRUCTS && !defined (HASH_Lisp_Boolfwd_0EA1C7ADCC)
+# error "Lisp_Boolfwd changed. See CHECK_STRUCTS comment."
+#endif
+  dump_emacs_reloc_immediate_bool (ctx, boolfwd->boolvar, *boolfwd->boolvar);
+  struct Lisp_Boolfwd out;
+  dump_object_start (ctx, &out, sizeof (out));
+  DUMP_FIELD_COPY (&out, boolfwd, type);
+  dump_field_emacs_ptr (ctx, &out, boolfwd, &boolfwd->boolvar);
+  return dump_object_finish (ctx, &out, sizeof (out));
+}
+
+static dump_off
+dump_fwd_obj (struct dump_context *ctx, const struct Lisp_Objfwd *objfwd)
+{
+#if CHECK_STRUCTS && !defined (HASH_Lisp_Objfwd_45D3E513DC)
+# error "Lisp_Objfwd changed. See CHECK_STRUCTS comment."
+#endif
+  if (NILP (Fgethash (dump_off_to_lisp (emacs_offset (objfwd->objvar)),
+                      ctx->staticpro_table,
+                      Qnil)))
+    dump_emacs_reloc_to_lv (ctx, objfwd->objvar, *objfwd->objvar);
+  struct Lisp_Objfwd out;
+  dump_object_start (ctx, &out, sizeof (out));
+  DUMP_FIELD_COPY (&out, objfwd, type);
+  dump_field_emacs_ptr (ctx, &out, objfwd, &objfwd->objvar);
+  return dump_object_finish (ctx, &out, sizeof (out));
+}
+
+static dump_off
+dump_fwd_buffer_obj (struct dump_context *ctx,
+                     const struct Lisp_Buffer_Objfwd *buffer_objfwd)
+{
+#if CHECK_STRUCTS && !defined (HASH_Lisp_Buffer_Objfwd_13CA6B04FC)
+# error "Lisp_Buffer_Objfwd changed. See CHECK_STRUCTS comment."
+#endif
+  struct Lisp_Buffer_Objfwd out;
+  dump_object_start (ctx, &out, sizeof (out));
+  DUMP_FIELD_COPY (&out, buffer_objfwd, type);
+  DUMP_FIELD_COPY (&out, buffer_objfwd, offset);
+  dump_field_lv (ctx, &out, buffer_objfwd, &buffer_objfwd->predicate,
+                 WEIGHT_NORMAL);
+  return dump_object_finish (ctx, &out, sizeof (out));
+}
+
+static dump_off
+dump_fwd_kboard_obj (struct dump_context *ctx,
+                     const struct Lisp_Kboard_Objfwd *kboard_objfwd)
+{
+#if CHECK_STRUCTS && !defined (HASH_Lisp_Kboard_Objfwd_CAA7E71069)
+# error "Lisp_Intfwd changed. See CHECK_STRUCTS comment."
+#endif
+  struct Lisp_Kboard_Objfwd out;
+  dump_object_start (ctx, &out, sizeof (out));
+  DUMP_FIELD_COPY (&out, kboard_objfwd, type);
+  DUMP_FIELD_COPY (&out, kboard_objfwd, offset);
+  return dump_object_finish (ctx, &out, sizeof (out));
+}
+
+static dump_off
+dump_fwd (struct dump_context *ctx, lispfwd fwd)
+{
+#if CHECK_STRUCTS && !defined (HASH_Lisp_Fwd_Type_9CBA6EE55E)
+# error "Lisp_Fwd_Type changed. See CHECK_STRUCTS comment."
+#endif
+  void const *p = fwd.fwdptr;
+  dump_off offset;
+
+  switch (XFWDTYPE (fwd))
+    {
+    case Lisp_Fwd_Int:
+      offset = dump_fwd_int (ctx, p);
+      break;
+    case Lisp_Fwd_Bool:
+      offset = dump_fwd_bool (ctx, p);
+      break;
+    case Lisp_Fwd_Obj:
+      offset = dump_fwd_obj (ctx, p);
+      break;
+    case Lisp_Fwd_Buffer_Obj:
+      offset = dump_fwd_buffer_obj (ctx, p);
+      break;
+    case Lisp_Fwd_Kboard_Obj:
+      offset = dump_fwd_kboard_obj (ctx, p);
+      break;
+    default:
+      emacs_abort ();
+    }
+
+  return offset;
+}
+
+static dump_off
+dump_blv (struct dump_context *ctx,
+          const struct Lisp_Buffer_Local_Value *blv)
+{
+#if CHECK_STRUCTS && !defined HASH_Lisp_Buffer_Local_Value_3C363FAC3C
+# error "Lisp_Buffer_Local_Value changed. See CHECK_STRUCTS comment."
+#endif
+  struct Lisp_Buffer_Local_Value out;
+  dump_object_start (ctx, &out, sizeof (out));
+  DUMP_FIELD_COPY (&out, blv, local_if_set);
+  DUMP_FIELD_COPY (&out, blv, found);
+  if (blv->fwd.fwdptr)
+    dump_field_fixup_later (ctx, &out, blv, &blv->fwd.fwdptr);
+  dump_field_lv (ctx, &out, blv, &blv->where, WEIGHT_NORMAL);
+  dump_field_lv (ctx, &out, blv, &blv->defcell, WEIGHT_STRONG);
+  dump_field_lv (ctx, &out, blv, &blv->valcell, WEIGHT_STRONG);
+  dump_off offset = dump_object_finish (ctx, &out, sizeof (out));
+  if (blv->fwd.fwdptr)
+    dump_remember_fixup_ptr_raw
+      (ctx,
+       offset + dump_offsetof (struct Lisp_Buffer_Local_Value, fwd),
+       dump_fwd (ctx, blv->fwd));
+  return offset;
+}
+
+static dump_off
+dump_recall_symbol_aux (struct dump_context *ctx, Lisp_Object symbol)
+{
+  Lisp_Object symbol_aux = ctx->symbol_aux;
+  if (NILP (symbol_aux))
+    return 0;
+  return dump_off_from_lisp (Fgethash (symbol, symbol_aux, make_fixnum (0)));
+}
+
+static void
+dump_remember_symbol_aux (struct dump_context *ctx,
+                          Lisp_Object symbol,
+                          dump_off offset)
+{
+  Fputhash (symbol, dump_off_to_lisp (offset), ctx->symbol_aux);
+}
+
+static void
+dump_pre_dump_symbol (struct dump_context *ctx, struct Lisp_Symbol *symbol)
+{
+  Lisp_Object symbol_lv = make_lisp_symbol (symbol);
+  eassert (!dump_recall_symbol_aux (ctx, symbol_lv));
+  DUMP_SET_REFERRER (ctx, symbol_lv);
+  switch (symbol->u.s.redirect)
+    {
+    case SYMBOL_LOCALIZED:
+      dump_remember_symbol_aux (ctx, symbol_lv,
+                               dump_blv (ctx, symbol->u.s.val.blv));
+      break;
+    case SYMBOL_FORWARDED:
+      dump_remember_symbol_aux (ctx, symbol_lv,
+                               dump_fwd (ctx, symbol->u.s.val.fwd));
+      break;
+    default:
+      break;
+    }
+  DUMP_CLEAR_REFERRER (ctx);
+}
+
+static dump_off
+dump_symbol (struct dump_context *ctx,
+             Lisp_Object object,
+             dump_off offset)
+{
+#if CHECK_STRUCTS && !defined HASH_Lisp_Symbol_999DC26DEC
+# error "Lisp_Symbol changed. See CHECK_STRUCTS comment."
+#endif
+#if CHECK_STRUCTS && !defined (HASH_symbol_redirect_ADB4F5B113)
+# error "symbol_redirect changed. See CHECK_STRUCTS comment."
+#endif
+
+  if (ctx->flags.defer_symbols)
+    {
+      if (offset != DUMP_OBJECT_ON_SYMBOL_QUEUE)
+        {
+         eassert (offset == DUMP_OBJECT_ON_NORMAL_QUEUE
+                  || offset == DUMP_OBJECT_NOT_SEEN);
+          DUMP_CLEAR_REFERRER (ctx);
+          struct dump_flags old_flags = ctx->flags;
+          ctx->flags.dump_object_contents = false;
+          ctx->flags.defer_symbols = false;
+          dump_object (ctx, object);
+          ctx->flags = old_flags;
+          DUMP_SET_REFERRER (ctx, object);
+
+          offset = DUMP_OBJECT_ON_SYMBOL_QUEUE;
+          dump_remember_object (ctx, object, offset);
+          dump_push (&ctx->deferred_symbols, object);
+        }
+      return offset;
+    }
+
+  struct Lisp_Symbol *symbol = XSYMBOL (object);
+  struct Lisp_Symbol out;
+  dump_object_start (ctx, &out, sizeof (out));
+  eassert (symbol->u.s.gcmarkbit == 0);
+  DUMP_FIELD_COPY (&out, symbol, u.s.redirect);
+  DUMP_FIELD_COPY (&out, symbol, u.s.trapped_write);
+  DUMP_FIELD_COPY (&out, symbol, u.s.interned);
+  DUMP_FIELD_COPY (&out, symbol, u.s.declared_special);
+  DUMP_FIELD_COPY (&out, symbol, u.s.pinned);
+  dump_field_lv (ctx, &out, symbol, &symbol->u.s.name, WEIGHT_STRONG);
+  switch (symbol->u.s.redirect)
+    {
+    case SYMBOL_PLAINVAL:
+      dump_field_lv (ctx, &out, symbol, &symbol->u.s.val.value,
+                     WEIGHT_NORMAL);
+      break;
+    case SYMBOL_VARALIAS:
+      dump_field_lv_rawptr (ctx, &out, symbol,
+                            &symbol->u.s.val.alias, Lisp_Symbol,
+                            WEIGHT_NORMAL);
+      break;
+    case SYMBOL_LOCALIZED:
+      dump_field_fixup_later (ctx, &out, symbol, &symbol->u.s.val.blv);
+      break;
+    case SYMBOL_FORWARDED:
+      dump_field_fixup_later (ctx, &out, symbol, &symbol->u.s.val.fwd);
+      break;
+    default:
+      emacs_abort ();
+    }
+  dump_field_lv (ctx, &out, symbol, &symbol->u.s.function, WEIGHT_NORMAL);
+  dump_field_lv (ctx, &out, symbol, &symbol->u.s.plist, WEIGHT_NORMAL);
+  dump_field_lv_rawptr (ctx, &out, symbol, &symbol->u.s.next, Lisp_Symbol,
+                        WEIGHT_STRONG);
+
+  offset = dump_object_finish (ctx, &out, sizeof (out));
+  dump_off aux_offset;
+
+  switch (symbol->u.s.redirect)
+    {
+    case SYMBOL_LOCALIZED:
+      aux_offset = dump_recall_symbol_aux (ctx, make_lisp_symbol (symbol));
+      dump_remember_fixup_ptr_raw
+       (ctx,
+        offset + dump_offsetof (struct Lisp_Symbol, u.s.val.blv),
+        (aux_offset
+         ? aux_offset
+         : dump_blv (ctx, symbol->u.s.val.blv)));
+      break;
+    case SYMBOL_FORWARDED:
+      aux_offset = dump_recall_symbol_aux (ctx, make_lisp_symbol (symbol));
+      dump_remember_fixup_ptr_raw
+       (ctx,
+        offset + dump_offsetof (struct Lisp_Symbol, u.s.val.fwd),
+        (aux_offset
+         ? aux_offset
+         : dump_fwd (ctx, symbol->u.s.val.fwd)));
+      break;
+    default:
+      break;
+    }
+  return offset;
+}
+
+static dump_off
+dump_vectorlike_generic (struct dump_context *ctx,
+                        const union vectorlike_header *header)
+{
+#if CHECK_STRUCTS && !defined (HASH_vectorlike_header_00A5A4BFB2)
+# error "vectorlike_header changed. See CHECK_STRUCTS comment."
+#endif
+  const struct Lisp_Vector *v = (const struct Lisp_Vector *) header;
+  ptrdiff_t size = header->size;
+  enum pvec_type pvectype = PSEUDOVECTOR_TYPE (v);
+  dump_off offset;
+
+  if (size & PSEUDOVECTOR_FLAG)
+    {
+      /* Assert that the pseudovector contains only Lisp values ---
+         but see the PVEC_SUB_CHAR_TABLE special case below.  We allow
+         one extra word of non-lisp data when Lisp_Object is shorter
+         than GCALIGN (e.g., on 32-bit builds) to account for
+         GCALIGN-enforcing struct padding.  We can't distinguish
+         between padding and some undumpable data member this way, but
+         we'll count on sizeof(Lisp_Object) >= GCALIGN builds to catch
+         this class of problem.
+         */
+      eassert ((size & PSEUDOVECTOR_REST_MASK) >> PSEUDOVECTOR_REST_BITS
+              <= (sizeof (Lisp_Object) < GCALIGNMENT));
+      size &= PSEUDOVECTOR_SIZE_MASK;
+    }
+
+  dump_align_output (ctx, DUMP_ALIGNMENT);
+  dump_off prefix_start_offset = ctx->offset;
+
+  dump_off skip;
+  if (pvectype == PVEC_SUB_CHAR_TABLE)
+    {
+      /* PVEC_SUB_CHAR_TABLE has a special case because it's a
+         variable-length vector (unlike other pseudovectors, which is
+         why we handle it here) and has its non-Lisp data _before_ the
+         variable-length Lisp part.  */
+      const struct Lisp_Sub_Char_Table *sct =
+        (const struct Lisp_Sub_Char_Table *) header;
+      struct Lisp_Sub_Char_Table out;
+      /* Don't use sizeof(out), since that incorporates unwanted
+         padding.  Instead, use the size through the last non-Lisp
+         field.  */
+      size_t sz = (char *)&out.min_char + sizeof (out.min_char) - (char *)&out;
+      eassert (sz < DUMP_OFF_MAX);
+      dump_object_start (ctx, &out, (dump_off) sz);
+      DUMP_FIELD_COPY (&out, sct, header.size);
+      DUMP_FIELD_COPY (&out, sct, depth);
+      DUMP_FIELD_COPY (&out, sct, min_char);
+      offset = dump_object_finish (ctx, &out, (dump_off) sz);
+      skip = SUB_CHAR_TABLE_OFFSET;
+    }
+  else
+    {
+      union vectorlike_header out;
+      dump_object_start (ctx, &out, sizeof (out));
+      DUMP_FIELD_COPY (&out, header, size);
+      offset = dump_object_finish (ctx, &out, sizeof (out));
+      skip = 0;
+    }
+
+  /* We may have written a non-Lisp vector prefix above.  If we have,
+     pad to the lisp content start with zero, and make sure we didn't
+     scribble beyond that start.  */
+  dump_off prefix_size = ctx->offset - prefix_start_offset;
+  eassert (prefix_size > 0);
+  dump_off skip_start = ptrdiff_t_to_dump_off ((char *) &v->contents[skip]
+                                              - (char *) v);
+  eassert (skip_start >= prefix_size);
+  dump_write_zero (ctx, skip_start - prefix_size);
+
+  /* dump_object_start isn't what records conservative-GC object
+     starts --- dump_object_1 does --- so the hack below of using
+     dump_object_start for each vector word doesn't cause GC problems
+     at runtime.  */
+  struct dump_flags old_flags = ctx->flags;
+  ctx->flags.pack_objects = true;
+  for (dump_off i = skip; i < size; ++i)
+    {
+      Lisp_Object out;
+      const Lisp_Object *vslot = &v->contents[i];
+      /* In the wide case, we're always misaligned.  */
+#ifndef WIDE_EMACS_INT
+      eassert (ctx->offset % sizeof (out) == 0);
+#endif
+      dump_object_start (ctx, &out, sizeof (out));
+      dump_field_lv (ctx, &out, vslot, vslot, WEIGHT_STRONG);
+      dump_object_finish (ctx, &out, sizeof (out));
+    }
+  ctx->flags = old_flags;
+  dump_align_output (ctx, DUMP_ALIGNMENT);
+  return offset;
+}
+
+/* Determine whether the hash table's hash order is stable
+   across dump and load.  If it is, we don't have to trigger
+   a rehash on access.  */
+static bool
+dump_hash_table_stable_p (const struct Lisp_Hash_Table *hash)
+{
+  bool is_eql = hash->test.hashfn == hashfn_eql;
+  bool is_equal = hash->test.hashfn == hashfn_equal;
+  ptrdiff_t size = HASH_TABLE_SIZE (hash);
+  for (ptrdiff_t i = 0; i < size; ++i)
+    if (!NILP (HASH_HASH (hash, i)))
+      {
+        Lisp_Object key =  HASH_KEY (hash, i);
+       bool key_stable = (dump_builtin_symbol_p (key)
+                          || FIXNUMP (key)
+                          || (is_equal && STRINGP (key))
+                          || ((is_equal || is_eql) && FLOATP (key)));
+        if (!key_stable)
+          return false;
+      }
+
+  return true;
+}
+
+/* Return a list of (KEY . VALUE) pairs in the given hash table.  */
+static Lisp_Object
+hash_table_contents (Lisp_Object table)
+{
+  Lisp_Object contents = Qnil;
+  struct Lisp_Hash_Table *h = XHASH_TABLE (table);
+  for (ptrdiff_t i = 0; i < HASH_TABLE_SIZE (h); ++i)
+    if (!NILP (HASH_HASH (h, i)))
+      dump_push (&contents, Fcons (HASH_KEY (h, i), HASH_VALUE (h, i)));
+  return Fnreverse (contents);
+}
+
+/* Copy the given hash table, rehash it, and make sure that we can
+   look up all the values in the original.  */
+static void
+check_hash_table_rehash (Lisp_Object table_orig)
+{
+  hash_rehash_if_needed (XHASH_TABLE (table_orig));
+  Lisp_Object table_rehashed = Fcopy_hash_table (table_orig);
+  eassert (XHASH_TABLE (table_rehashed)->count >= 0);
+  XHASH_TABLE (table_rehashed)->count *= -1;
+  eassert (XHASH_TABLE (table_rehashed)->count <= 0);
+  hash_rehash_if_needed (XHASH_TABLE (table_rehashed));
+  eassert (XHASH_TABLE (table_rehashed)->count >= 0);
+  Lisp_Object expected_contents = hash_table_contents (table_orig);
+  while (!NILP (expected_contents))
+    {
+      Lisp_Object key_value_pair = dump_pop (&expected_contents);
+      Lisp_Object key = XCAR (key_value_pair);
+      Lisp_Object expected_value = XCDR (key_value_pair);
+      Lisp_Object arbitrary = Qdump_emacs_portable__sort_predicate_copied;
+      Lisp_Object found_value = Fgethash (key, table_rehashed, arbitrary);
+      eassert (EQ (expected_value, found_value));
+      Fremhash (key, table_rehashed);
+    }
+
+  eassert (EQ (Fhash_table_count (table_rehashed),
+               make_fixnum (0)));
+}
+
+static dump_off
+dump_hash_table (struct dump_context *ctx,
+                 Lisp_Object object,
+                 dump_off offset)
+{
+#if CHECK_STRUCTS && !defined HASH_Lisp_Hash_Table_EF95ED06FF
+# error "Lisp_Hash_Table changed. See CHECK_STRUCTS comment."
+#endif
+  const struct Lisp_Hash_Table *hash_in = XHASH_TABLE (object);
+  bool is_stable = dump_hash_table_stable_p (hash_in);
+  /* If the hash table is likely to be modified in memory (either
+     because we need to rehash, and thus toggle hash->count, or
+     because we need to assemble a list of weak tables) punt the hash
+     table to the end of the dump, where we can lump all such hash
+     tables together.  */
+  if (!(is_stable || !NILP (hash_in->weak))
+      && ctx->flags.defer_hash_tables)
+    {
+      if (offset != DUMP_OBJECT_ON_HASH_TABLE_QUEUE)
+        {
+         eassert (offset == DUMP_OBJECT_ON_NORMAL_QUEUE
+                  || offset == DUMP_OBJECT_NOT_SEEN);
+          /* We still want to dump the actual keys and values now.  */
+          dump_enqueue_object (ctx, hash_in->key_and_value, WEIGHT_NONE);
+          /* We'll get to the rest later.  */
+          offset = DUMP_OBJECT_ON_HASH_TABLE_QUEUE;
+          dump_remember_object (ctx, object, offset);
+          dump_push (&ctx->deferred_hash_tables, object);
+        }
+      return offset;
+    }
+
+  if (PDUMPER_CHECK_REHASHING)
+    check_hash_table_rehash (make_lisp_ptr ((void *) hash_in, 
Lisp_Vectorlike));
+
+  struct Lisp_Hash_Table hash_munged = *hash_in;
+  struct Lisp_Hash_Table *hash = &hash_munged;
+
+  /* Remember to rehash this hash table on first access.  After a
+     dump reload, the hash table values will have changed, so we'll
+     need to rebuild the index.
+
+     TODO: for EQ and EQL hash tables, it should be possible to rehash
+     here using the preferred load address of the dump, eliminating
+     the need to rehash-on-access if we can load the dump where we
+     want.  */
+  if (hash->count > 0 && !is_stable)
+    hash->count = -hash->count;
+
+  START_DUMP_PVEC (ctx, &hash->header, struct Lisp_Hash_Table, out);
+  dump_pseudovector_lisp_fields (ctx, &out->header, &hash->header);
+  /* TODO: dump the hash bucket vectors synchronously here to keep
+     them as close to the hash table as possible.  */
+  DUMP_FIELD_COPY (out, hash, count);
+  DUMP_FIELD_COPY (out, hash, next_free);
+  DUMP_FIELD_COPY (out, hash, pure);
+  DUMP_FIELD_COPY (out, hash, rehash_threshold);
+  DUMP_FIELD_COPY (out, hash, rehash_size);
+  dump_field_lv (ctx, out, hash, &hash->key_and_value, WEIGHT_STRONG);
+  dump_field_lv (ctx, out, hash, &hash->test.name, WEIGHT_STRONG);
+  dump_field_lv (ctx, out, hash, &hash->test.user_hash_function,
+                 WEIGHT_STRONG);
+  dump_field_lv (ctx, out, hash, &hash->test.user_cmp_function,
+                 WEIGHT_STRONG);
+  dump_field_emacs_ptr (ctx, out, hash, &hash->test.cmpfn);
+  dump_field_emacs_ptr (ctx, out, hash, &hash->test.hashfn);
+  eassert (hash->next_weak == NULL);
+  return finish_dump_pvec (ctx, &out->header);
+}
+
+static dump_off
+dump_buffer (struct dump_context *ctx, const struct buffer *in_buffer)
+{
+#if CHECK_STRUCTS && !defined HASH_buffer_E34A11C6B9
+# error "buffer changed. See CHECK_STRUCTS comment."
+#endif
+  struct buffer munged_buffer = *in_buffer;
+  struct buffer *buffer = &munged_buffer;
+
+  /* Clear some buffer state for correctness upon load.  */
+  if (buffer->base_buffer == NULL)
+    buffer->window_count = 0;
+  else
+    eassert (buffer->window_count == -1);
+  buffer->last_selected_window_ = Qnil;
+  buffer->display_count_ = make_fixnum (0);
+  buffer->clip_changed = 0;
+  buffer->last_window_start = -1;
+  buffer->point_before_scroll_ = Qnil;
+
+  dump_off base_offset = 0;
+  if (buffer->base_buffer)
+    {
+      eassert (buffer->base_buffer->base_buffer == NULL);
+      base_offset = dump_object_for_offset
+       (ctx,
+        make_lisp_ptr (buffer->base_buffer, Lisp_Vectorlike));
+    }
+
+  eassert ((base_offset == 0 && buffer->text == &in_buffer->own_text)
+          || (base_offset > 0 && buffer->text != &in_buffer->own_text));
+
+  START_DUMP_PVEC (ctx, &buffer->header, struct buffer, out);
+  dump_pseudovector_lisp_fields (ctx, &out->header, &buffer->header);
+  if (base_offset == 0)
+    base_offset = ctx->obj_offset;
+  eassert (base_offset > 0);
+  if (buffer->base_buffer == NULL)
+    {
+      eassert (base_offset == ctx->obj_offset);
+
+      if (BUFFER_LIVE_P (buffer))
+        {
+          dump_field_fixup_later (ctx, out, buffer, &buffer->own_text.beg);
+         dump_remember_cold_op (ctx, COLD_OP_BUFFER,
+                                make_lisp_ptr ((void *) in_buffer,
+                                               Lisp_Vectorlike));
+        }
+      else
+        eassert (buffer->own_text.beg == NULL);
+
+      DUMP_FIELD_COPY (out, buffer, own_text.gpt);
+      DUMP_FIELD_COPY (out, buffer, own_text.z);
+      DUMP_FIELD_COPY (out, buffer, own_text.gpt_byte);
+      DUMP_FIELD_COPY (out, buffer, own_text.z_byte);
+      DUMP_FIELD_COPY (out, buffer, own_text.gap_size);
+      DUMP_FIELD_COPY (out, buffer, own_text.modiff);
+      DUMP_FIELD_COPY (out, buffer, own_text.chars_modiff);
+      DUMP_FIELD_COPY (out, buffer, own_text.save_modiff);
+      DUMP_FIELD_COPY (out, buffer, own_text.overlay_modiff);
+      DUMP_FIELD_COPY (out, buffer, own_text.compact);
+      DUMP_FIELD_COPY (out, buffer, own_text.beg_unchanged);
+      DUMP_FIELD_COPY (out, buffer, own_text.end_unchanged);
+      DUMP_FIELD_COPY (out, buffer, own_text.unchanged_modified);
+      DUMP_FIELD_COPY (out, buffer, own_text.overlay_unchanged_modified);
+      if (buffer->own_text.intervals)
+        dump_field_fixup_later (ctx, out, buffer, &buffer->own_text.intervals);
+      dump_field_lv_rawptr (ctx, out, buffer, &buffer->own_text.markers,
+                            Lisp_Vectorlike, WEIGHT_NORMAL);
+      DUMP_FIELD_COPY (out, buffer, own_text.inhibit_shrinking);
+      DUMP_FIELD_COPY (out, buffer, own_text.redisplay);
+    }
+
+  eassert (ctx->obj_offset > 0);
+  dump_remember_fixup_ptr_raw
+    (ctx,
+     ctx->obj_offset + dump_offsetof (struct buffer, text),
+     base_offset + dump_offsetof (struct buffer, own_text));
+
+  dump_field_lv_rawptr (ctx, out, buffer, &buffer->next,
+                        Lisp_Vectorlike, WEIGHT_NORMAL);
+  DUMP_FIELD_COPY (out, buffer, pt);
+  DUMP_FIELD_COPY (out, buffer, pt_byte);
+  DUMP_FIELD_COPY (out, buffer, begv);
+  DUMP_FIELD_COPY (out, buffer, begv_byte);
+  DUMP_FIELD_COPY (out, buffer, zv);
+  DUMP_FIELD_COPY (out, buffer, zv_byte);
+
+  if (buffer->base_buffer)
+    {
+      eassert (ctx->obj_offset != base_offset);
+      dump_field_ptr_to_dump_offset (ctx, out, buffer, &buffer->base_buffer,
+                                    base_offset);
+    }
+
+  DUMP_FIELD_COPY (out, buffer, indirections);
+  DUMP_FIELD_COPY (out, buffer, window_count);
+
+  memcpy (out->local_flags,
+          &buffer->local_flags,
+          sizeof (out->local_flags));
+  DUMP_FIELD_COPY (out, buffer, modtime);
+  DUMP_FIELD_COPY (out, buffer, modtime_size);
+  DUMP_FIELD_COPY (out, buffer, auto_save_modified);
+  DUMP_FIELD_COPY (out, buffer, display_error_modiff);
+  DUMP_FIELD_COPY (out, buffer, auto_save_failure_time);
+  DUMP_FIELD_COPY (out, buffer, last_window_start);
+
+  /* Not worth serializing these caches.  TODO: really? */
+  out->newline_cache = NULL;
+  out->width_run_cache = NULL;
+  out->bidi_paragraph_cache = NULL;
+
+  DUMP_FIELD_COPY (out, buffer, prevent_redisplay_optimizations_p);
+  DUMP_FIELD_COPY (out, buffer, clip_changed);
+  DUMP_FIELD_COPY (out, buffer, inhibit_buffer_hooks);
+
+  dump_field_lv_rawptr (ctx, out, buffer, &buffer->overlays_before,
+                        Lisp_Vectorlike, WEIGHT_NORMAL);
+
+  dump_field_lv_rawptr (ctx, out, buffer, &buffer->overlays_after,
+                        Lisp_Vectorlike, WEIGHT_NORMAL);
+
+  DUMP_FIELD_COPY (out, buffer, overlay_center);
+  dump_field_lv (ctx, out, buffer, &buffer->undo_list_,
+                 WEIGHT_STRONG);
+  dump_off offset = finish_dump_pvec (ctx, &out->header);
+  if (!buffer->base_buffer && buffer->own_text.intervals)
+    dump_remember_fixup_ptr_raw
+      (ctx,
+       offset + dump_offsetof (struct buffer, own_text.intervals),
+       dump_interval_tree (ctx, buffer->own_text.intervals, 0));
+
+  return offset;
+}
+
+static dump_off
+dump_bool_vector (struct dump_context *ctx, const struct Lisp_Vector *v)
+{
+#if CHECK_STRUCTS && !defined (HASH_Lisp_Vector_3091289B35)
+# error "Lisp_Vector changed. See CHECK_STRUCTS comment."
+#endif
+  /* No relocation needed, so we don't need dump_object_start.  */
+  dump_align_output (ctx, DUMP_ALIGNMENT);
+  eassert (ctx->offset >= ctx->header.cold_start);
+  dump_off offset = ctx->offset;
+  ptrdiff_t nbytes = vector_nbytes ((struct Lisp_Vector *) v);
+  if (nbytes > DUMP_OFF_MAX)
+    error ("vector too large");
+  dump_write (ctx, v, ptrdiff_t_to_dump_off (nbytes));
+  return offset;
+}
+
+static dump_off
+dump_subr (struct dump_context *ctx, const struct Lisp_Subr *subr)
+{
+#if CHECK_STRUCTS && !defined (HASH_Lisp_Subr_594AB72B54)
+# error "Lisp_Subr changed. See CHECK_STRUCTS comment."
+#endif
+  struct Lisp_Subr out;
+  dump_object_start (ctx, &out, sizeof (out));
+  DUMP_FIELD_COPY (&out, subr, header.size);
+  dump_field_emacs_ptr (ctx, &out, subr, &subr->function.a0);
+  DUMP_FIELD_COPY (&out, subr, min_args);
+  DUMP_FIELD_COPY (&out, subr, max_args);
+  dump_field_emacs_ptr (ctx, &out, subr, &subr->symbol_name);
+  dump_field_emacs_ptr (ctx, &out, subr, &subr->intspec);
+  DUMP_FIELD_COPY (&out, subr, doc);
+  return dump_object_finish (ctx, &out, sizeof (out));
+}
+
+static void
+fill_pseudovec (union vectorlike_header *header, Lisp_Object item)
+{
+  struct Lisp_Vector *v = (struct Lisp_Vector *) header;
+  eassert (v->header.size & PSEUDOVECTOR_FLAG);
+  ptrdiff_t size = v->header.size & PSEUDOVECTOR_SIZE_MASK;
+  for (ptrdiff_t idx = 0; idx < size; idx++)
+    v->contents[idx] = item;
+}
+
+static dump_off
+dump_nilled_pseudovec (struct dump_context *ctx,
+                       const union vectorlike_header *in)
+{
+  START_DUMP_PVEC (ctx, in, struct Lisp_Vector, out);
+  fill_pseudovec (&out->header, Qnil);
+  return finish_dump_pvec (ctx, &out->header);
+}
+
+static dump_off
+dump_vectorlike (struct dump_context *ctx,
+                 Lisp_Object lv,
+                 dump_off offset)
+{
+#if CHECK_STRUCTS && !defined HASH_pvec_type_E55BD36F8E
+# error "pvec_type changed. See CHECK_STRUCTS comment."
+#endif
+  const struct Lisp_Vector *v = XVECTOR (lv);
+  switch (PSEUDOVECTOR_TYPE (v))
+    {
+    case PVEC_FONT:
+      /* There are three kinds of font objects that all use PVEC_FONT,
+         distinguished by their size.  Font specs and entities are
+         harmless data carriers that we can dump like other Lisp
+         objects.  Fonts themselves are window-system-specific and
+         need to be recreated on each startup.  */
+      if ((v->header.size & PSEUDOVECTOR_SIZE_MASK) != FONT_SPEC_MAX
+         && (v->header.size & PSEUDOVECTOR_SIZE_MASK) != FONT_ENTITY_MAX)
+        error_unsupported_dump_object(ctx, lv, "font");
+      FALLTHROUGH;
+    case PVEC_NORMAL_VECTOR:
+    case PVEC_COMPILED:
+    case PVEC_CHAR_TABLE:
+    case PVEC_SUB_CHAR_TABLE:
+    case PVEC_RECORD:
+      offset = dump_vectorlike_generic (ctx, &v->header);
+      break;
+    case PVEC_BOOL_VECTOR:
+      offset = dump_bool_vector(ctx, v);
+      break;
+    case PVEC_HASH_TABLE:
+      offset = dump_hash_table (ctx, lv, offset);
+      break;
+    case PVEC_BUFFER:
+      offset = dump_buffer (ctx, XBUFFER (lv));
+      break;
+    case PVEC_SUBR:
+      offset = dump_subr (ctx, XSUBR (lv));
+      break;
+    case PVEC_FRAME:
+    case PVEC_WINDOW:
+    case PVEC_PROCESS:
+    case PVEC_TERMINAL:
+      offset = dump_nilled_pseudovec (ctx, &v->header);
+      break;
+    case PVEC_MARKER:
+      offset = dump_marker (ctx, XMARKER (lv));
+      break;
+    case PVEC_OVERLAY:
+      offset = dump_overlay (ctx, XOVERLAY (lv));
+      break;
+    case PVEC_FINALIZER:
+      offset = dump_finalizer (ctx, XFINALIZER (lv));
+      break;
+    case PVEC_BIGNUM:
+      offset = dump_bignum (ctx, lv);
+      break;
+    case PVEC_WINDOW_CONFIGURATION:
+      error_unsupported_dump_object (ctx, lv, "window configuration");
+    case PVEC_OTHER:
+      error_unsupported_dump_object (ctx, lv, "other?!");
+    case PVEC_XWIDGET:
+      error_unsupported_dump_object (ctx, lv, "xwidget");
+    case PVEC_XWIDGET_VIEW:
+      error_unsupported_dump_object (ctx, lv, "xwidget view");
+    case PVEC_MISC_PTR:
+    case PVEC_USER_PTR:
+      error_unsupported_dump_object (ctx, lv, "smuggled pointers");
+    case PVEC_THREAD:
+      if (main_thread_p (v))
+        {
+          eassert (dump_object_emacs_ptr (lv));
+          return DUMP_OBJECT_IS_RUNTIME_MAGIC;
+        }
+      error_unsupported_dump_object (ctx, lv, "thread");
+    case PVEC_MUTEX:
+      error_unsupported_dump_object (ctx, lv, "mutex");
+    case PVEC_CONDVAR:
+      error_unsupported_dump_object (ctx, lv, "condvar");
+    case PVEC_MODULE_FUNCTION:
+      error_unsupported_dump_object (ctx, lv, "module function");
+    default:
+      error_unsupported_dump_object(ctx, lv, "weird pseudovector");
+    }
+
+  return offset;
+}
+
+/* Add an object to the dump.
+
+   CTX is the dump context; OBJECT is the object to add.  Normally,
+   return OFFSET, the location (in bytes, from the start of the dump
+   file) where we wrote the object.  Valid OFFSETs are always greater
+   than zero.
+
+   If we've already dumped an object, return the location where we put
+   it: dump_object is idempotent.
+
+   The object must refer to an actual pointer-ish object of some sort.
+   Some self-representing objects are immediate values rather than
+   tagged pointers to Lisp heap structures and so have no individual
+   representation in the Lisp heap dump.
+
+   May also return one of the DUMP_OBJECT_ON_*_QUEUE constants if we
+   "dumped" the object by remembering to process it specially later.
+   In this case, we don't have a valid offset.
+   Call dump_object_for_offset if you need a valid offset for
+   an object.
+ */
+static dump_off
+dump_object (struct dump_context *ctx, Lisp_Object object)
+{
+#if CHECK_STRUCTS && !defined (HASH_Lisp_Type_E2AD97D3F7)
+# error "Lisp_Type changed. See CHECK_STRUCTS comment."
+#endif
+#ifdef ENABLE_CHECKING
+  /* Vdead is extern only when ENABLE_CHECKING.  */
+  eassert (!EQ (object, Vdead));
+#endif
+
+  dump_off offset = dump_recall_object (ctx, object);
+  if (offset > 0)
+    return offset;  /* Object already dumped.  */
+
+  bool cold = BOOL_VECTOR_P (object) || FLOATP (object);
+  if (cold && ctx->flags.defer_cold_objects)
+    {
+      if (offset != DUMP_OBJECT_ON_COLD_QUEUE)
+        {
+         eassert (offset == DUMP_OBJECT_ON_NORMAL_QUEUE
+                  || offset == DUMP_OBJECT_NOT_SEEN);
+          offset = DUMP_OBJECT_ON_COLD_QUEUE;
+          dump_remember_object (ctx, object, offset);
+          dump_remember_cold_op (ctx, COLD_OP_OBJECT, object);
+        }
+      return offset;
+    }
+
+  void *obj_in_emacs = dump_object_emacs_ptr (object);
+  if (obj_in_emacs && ctx->flags.defer_copied_objects)
+    {
+      if (offset != DUMP_OBJECT_ON_COPIED_QUEUE)
+        {
+         eassert (offset == DUMP_OBJECT_ON_NORMAL_QUEUE
+                  || offset == DUMP_OBJECT_NOT_SEEN);
+          /* Even though we're not going to dump this object right
+             away, we still want to scan and enqueue its
+             referents.  */
+          struct dump_flags old_flags = ctx->flags;
+          ctx->flags.dump_object_contents = false;
+          ctx->flags.defer_copied_objects = false;
+          dump_object (ctx, object);
+          ctx->flags = old_flags;
+
+          offset = DUMP_OBJECT_ON_COPIED_QUEUE;
+          dump_remember_object (ctx, object, offset);
+          dump_push (&ctx->copied_queue, object);
+        }
+      return offset;
+    }
+
+  /* Object needs to be dumped.  */
+  DUMP_SET_REFERRER (ctx, object);
+  switch (XTYPE (object))
+    {
+    case Lisp_String:
+      offset = dump_string (ctx, XSTRING (object));
+      break;
+    case Lisp_Vectorlike:
+      offset = dump_vectorlike (ctx, object, offset);
+      break;
+    case Lisp_Symbol:
+      offset = dump_symbol (ctx, object, offset);
+      break;
+    case Lisp_Cons:
+      offset = dump_cons (ctx, XCONS (object));
+      break;
+    case Lisp_Float:
+      offset = dump_float (ctx, XFLOAT (object));
+      break;
+    case_Lisp_Int:
+      eassert ("should not be dumping int: is self-representing" && 0);
+      abort ();
+    default:
+      emacs_abort ();
+    }
+  DUMP_CLEAR_REFERRER (ctx);
+
+  /* offset can be < 0 if we've deferred an object.  */
+  if (ctx->flags.dump_object_contents && offset > DUMP_OBJECT_NOT_SEEN)
+    {
+      eassert (offset % DUMP_ALIGNMENT == 0);
+      dump_remember_object (ctx, object, offset);
+      if (ctx->flags.record_object_starts)
+        {
+          eassert (!ctx->flags.pack_objects);
+          dump_push (&ctx->object_starts,
+                     list2 (dump_off_to_lisp (XTYPE (object)),
+                            dump_off_to_lisp (offset)));
+        }
+    }
+
+  return offset;
+}
+
+/* Like dump_object(), but assert that we get a valid offset.  */
+static dump_off
+dump_object_for_offset (struct dump_context *ctx, Lisp_Object object)
+{
+  dump_off offset = dump_object (ctx, object);
+  eassert (offset > 0);
+  return offset;
+}
+
+static dump_off
+dump_charset (struct dump_context *ctx, int cs_i)
+{
+#if CHECK_STRUCTS && !defined (HASH_charset_317C49E291)
+# error "charset changed. See CHECK_STRUCTS comment."
+#endif
+  dump_align_output (ctx, alignof (struct charset));
+  const struct charset *cs = charset_table + cs_i;
+  struct charset out;
+  dump_object_start (ctx, &out, sizeof (out));
+  DUMP_FIELD_COPY (&out, cs, id);
+  DUMP_FIELD_COPY (&out, cs, hash_index);
+  DUMP_FIELD_COPY (&out, cs, dimension);
+  memcpy (out.code_space, &cs->code_space, sizeof (cs->code_space));
+  if (cs->code_space_mask)
+    dump_field_fixup_later (ctx, &out, cs, &cs->code_space_mask);
+  DUMP_FIELD_COPY (&out, cs, code_linear_p);
+  DUMP_FIELD_COPY (&out, cs, iso_chars_96);
+  DUMP_FIELD_COPY (&out, cs, ascii_compatible_p);
+  DUMP_FIELD_COPY (&out, cs, supplementary_p);
+  DUMP_FIELD_COPY (&out, cs, compact_codes_p);
+  DUMP_FIELD_COPY (&out, cs, unified_p);
+  DUMP_FIELD_COPY (&out, cs, iso_final);
+  DUMP_FIELD_COPY (&out, cs, iso_revision);
+  DUMP_FIELD_COPY (&out, cs, emacs_mule_id);
+  DUMP_FIELD_COPY (&out, cs, method);
+  DUMP_FIELD_COPY (&out, cs, min_code);
+  DUMP_FIELD_COPY (&out, cs, max_code);
+  DUMP_FIELD_COPY (&out, cs, char_index_offset);
+  DUMP_FIELD_COPY (&out, cs, min_char);
+  DUMP_FIELD_COPY (&out, cs, max_char);
+  DUMP_FIELD_COPY (&out, cs, invalid_code);
+  memcpy (out.fast_map, &cs->fast_map, sizeof (cs->fast_map));
+  DUMP_FIELD_COPY (&out, cs, code_offset);
+  dump_off offset = dump_object_finish (ctx, &out, sizeof (out));
+  if (cs->code_space_mask)
+    dump_remember_cold_op (ctx, COLD_OP_CHARSET,
+                           Fcons (dump_off_to_lisp (cs_i),
+                                  dump_off_to_lisp (offset)));
+  return offset;
+}
+
+static dump_off
+dump_charset_table (struct dump_context *ctx)
+{
+  struct dump_flags old_flags = ctx->flags;
+  ctx->flags.pack_objects = true;
+  dump_align_output (ctx, DUMP_ALIGNMENT);
+  dump_off offset = ctx->offset;
+  /* We are dumping the entire table, not just the used slots, because
+     otherwise when we restore from the pdump file, the actual size of
+     the table will be smaller than charset_table_size, and we will
+     crash if/when a new charset is defined.  */
+  for (int i = 0; i < charset_table_size; ++i)
+    dump_charset (ctx, i);
+  dump_emacs_reloc_to_dump_ptr_raw (ctx, &charset_table, offset);
+  ctx->flags = old_flags;
+  return offset;
+}
+
+static void
+dump_finalizer_list_head_ptr (struct dump_context *ctx,
+                              struct Lisp_Finalizer **ptr)
+{
+  struct Lisp_Finalizer *value = *ptr;
+  if (value != &finalizers && value != &doomed_finalizers)
+    dump_emacs_reloc_to_dump_ptr_raw
+      (ctx, ptr,
+       dump_object_for_offset (ctx,
+                              make_lisp_ptr (value, Lisp_Vectorlike)));
+}
+
+static void
+dump_metadata_for_pdumper (struct dump_context *ctx)
+{
+  for (int i = 0; i < nr_dump_hooks; ++i)
+    dump_emacs_reloc_to_emacs_ptr_raw (ctx, &dump_hooks[i],
+                                      (void const *) dump_hooks[i]);
+  dump_emacs_reloc_immediate_int (ctx, &nr_dump_hooks, nr_dump_hooks);
+
+  for (int i = 0; i < nr_remembered_data; ++i)
+    {
+      dump_emacs_reloc_to_emacs_ptr_raw (ctx, &remembered_data[i].mem,
+                                        remembered_data[i].mem);
+      dump_emacs_reloc_immediate_int (ctx, &remembered_data[i].sz,
+                                     remembered_data[i].sz);
+    }
+  dump_emacs_reloc_immediate_int (ctx, &nr_remembered_data,
+                                 nr_remembered_data);
+}
+
+/* Sort the list of copied objects in CTX.  */
+static void
+dump_sort_copied_objects (struct dump_context *ctx)
+{
+  /* Sort the objects into the order in which they'll appear in the
+     Emacs: this way, on startup, we'll do both the IO from the dump
+     file and the copy into Emacs in-order, where prefetch will be
+     most effective.  */
+  ctx->copied_queue =
+    Fsort (Fnreverse (ctx->copied_queue),
+           Qdump_emacs_portable__sort_predicate_copied);
+}
+
+/* Dump parts of copied objects we need at runtime.  */
+static void
+dump_hot_parts_of_discardable_objects (struct dump_context *ctx)
+{
+  Lisp_Object copied_queue = ctx->copied_queue;
+  while (!NILP (copied_queue))
+    {
+      Lisp_Object copied = dump_pop (&copied_queue);
+      if (SYMBOLP (copied))
+        {
+          eassert (dump_builtin_symbol_p (copied));
+          dump_pre_dump_symbol (ctx, XSYMBOL (copied));
+        }
+    }
+}
+
+static void
+dump_drain_copied_objects (struct dump_context *ctx)
+{
+  Lisp_Object copied_queue = ctx->copied_queue;
+  ctx->copied_queue = Qnil;
+
+  struct dump_flags old_flags = ctx->flags;
+
+  /* We should have already fully scanned these objects, so assert
+     that we're not adding more entries to the dump queue.  */
+  ctx->flags.assert_already_seen = true;
+
+  /* Now we want to actually dump the copied objects, not just record
+     them.  */
+  ctx->flags.defer_copied_objects = false;
+
+  /* Objects that we memcpy into Emacs shouldn't get object-start
+     records (which conservative GC looks at): we usually discard this
+     memory after we're finished memcpying, and even if we don't, the
+     "real" objects in this section all live in the Emacs image, not
+     in the dump.  */
+  ctx->flags.record_object_starts = false;
+
+  /* Dump the objects and generate a copy relocation for each.  Don't
+     bother trying to reduce the number of copy relocations we
+     generate: we'll merge adjacent copy relocations upon output.
+     The overall result is that to the greatest extent possible while
+     maintaining strictly increasing address order, we copy into Emacs
+     in nice big chunks.  */
+  while (!NILP (copied_queue))
+    {
+      Lisp_Object copied = dump_pop (&copied_queue);
+      void *optr = dump_object_emacs_ptr (copied);
+      eassert (optr != NULL);
+      /* N.B. start_offset is beyond any padding we insert.  */
+      dump_off start_offset = dump_object (ctx, copied);
+      if (start_offset != DUMP_OBJECT_IS_RUNTIME_MAGIC)
+        {
+          dump_off size = ctx->offset - start_offset;
+          dump_emacs_reloc_copy_from_dump (ctx, start_offset, optr, size);
+        }
+    }
+
+  ctx->flags = old_flags;
+}
+
+static void
+dump_cold_string (struct dump_context *ctx, Lisp_Object string)
+{
+  /* Dump string contents.  */
+  dump_off string_offset = dump_recall_object (ctx, string);
+  eassert (string_offset > 0);
+  if (SBYTES (string) > DUMP_OFF_MAX - 1)
+    error ("string too large");
+  dump_off total_size = ptrdiff_t_to_dump_off (SBYTES (string) + 1);
+  eassert (total_size > 0);
+  dump_remember_fixup_ptr_raw
+    (ctx,
+     string_offset + dump_offsetof (struct Lisp_String, u.s.data),
+     ctx->offset);
+  dump_write (ctx, XSTRING (string)->u.s.data, total_size);
+}
+
+static void
+dump_cold_charset (struct dump_context *ctx, Lisp_Object data)
+{
+  /* Dump charset lookup tables.  */
+  ALLOW_IMPLICIT_CONVERSION;
+  int cs_i = XFIXNUM (XCAR (data));
+  DISALLOW_IMPLICIT_CONVERSION;
+  dump_off cs_dump_offset = dump_off_from_lisp (XCDR (data));
+  dump_remember_fixup_ptr_raw
+    (ctx,
+     cs_dump_offset + dump_offsetof (struct charset, code_space_mask),
+     ctx->offset);
+  struct charset *cs = charset_table + cs_i;
+  dump_write (ctx, cs->code_space_mask, 256);
+}
+
+static void
+dump_cold_buffer (struct dump_context *ctx, Lisp_Object data)
+{
+  /* Dump buffer text.  */
+  dump_off buffer_offset = dump_recall_object (ctx, data);
+  eassert (buffer_offset > 0);
+  struct buffer *b = XBUFFER (data);
+  eassert (b->text == &b->own_text);
+  /* Zero the gap so we don't dump uninitialized bytes.  */
+  memset (BUF_GPT_ADDR (b), 0, BUF_GAP_SIZE (b));
+  /* See buffer.c for this calculation.  */
+  ptrdiff_t nbytes =
+    BUF_Z_BYTE (b)
+    - BUF_BEG_BYTE (b)
+    + BUF_GAP_SIZE (b)
+    + 1;
+  if (nbytes > DUMP_OFF_MAX)
+    error ("buffer too large");
+  dump_remember_fixup_ptr_raw
+    (ctx,
+     buffer_offset + dump_offsetof (struct buffer, own_text.beg),
+     ctx->offset);
+  dump_write (ctx, b->own_text.beg, ptrdiff_t_to_dump_off (nbytes));
+}
+
+static void
+dump_cold_bignum (struct dump_context *ctx, Lisp_Object object)
+{
+  const struct Lisp_Bignum *bignum = XBIGNUM (object);
+  size_t sz_nlimbs = mpz_size (bignum->value);
+  eassert (sz_nlimbs < DUMP_OFF_MAX);
+  dump_align_output (ctx, alignof (mp_limb_t));
+  dump_off nlimbs = (dump_off) sz_nlimbs;
+  Lisp_Object descriptor
+    = list2 (dump_off_to_lisp (ctx->offset),
+            dump_off_to_lisp ((mpz_sgn (bignum->value) < 0
+                               ? -nlimbs : nlimbs)));
+  Fputhash (object, descriptor, ctx->bignum_data);
+  for (mp_size_t i = 0; i < nlimbs; ++i)
+    {
+      mp_limb_t limb = mpz_getlimbn (bignum->value, i);
+      dump_write (ctx, &limb, sizeof (limb));
+    }
+}
+
+static void
+dump_drain_cold_data (struct dump_context *ctx)
+{
+  Lisp_Object cold_queue = Fnreverse (ctx->cold_queue);
+  ctx->cold_queue = Qnil;
+
+  struct dump_flags old_flags = ctx->flags;
+
+  /* We should have already scanned all objects to which our cold
+     objects refer, so die if an object points to something we haven't
+     seen.  */
+  ctx->flags.assert_already_seen = true;
+
+  /* Actually dump cold objects instead of deferring them.  */
+  ctx->flags.defer_cold_objects = false;
+
+  while (!NILP (cold_queue))
+    {
+      Lisp_Object item = dump_pop (&cold_queue);
+      enum cold_op op = (enum cold_op) XFIXNUM (XCAR (item));
+      Lisp_Object data = XCDR (item);
+      switch (op)
+        {
+        case COLD_OP_STRING:
+          dump_cold_string (ctx, data);
+          break;
+        case COLD_OP_CHARSET:
+          dump_cold_charset (ctx, data);
+          break;
+        case COLD_OP_BUFFER:
+          dump_cold_buffer (ctx, data);
+          break;
+        case COLD_OP_OBJECT:
+          /* Objects that we can put in the cold section
+             must not refer to other objects.  */
+          eassert (dump_queue_empty_p (&ctx->dump_queue));
+          eassert (ctx->flags.dump_object_contents);
+          dump_object (ctx, data);
+          eassert (dump_queue_empty_p (&ctx->dump_queue));
+          break;
+        case COLD_OP_BIGNUM:
+          dump_cold_bignum (ctx, data);
+          break;
+        default:
+          emacs_abort ();
+        }
+    }
+
+  ctx->flags = old_flags;
+}
+
+static void
+read_ptr_raw_and_lv (const void *mem,
+                     enum Lisp_Type type,
+                     void **out_ptr,
+                     Lisp_Object *out_lv)
+{
+  memcpy (out_ptr, mem, sizeof (*out_ptr));
+  if (*out_ptr != NULL)
+    {
+      switch (type)
+        {
+        case Lisp_Symbol:
+          *out_lv = make_lisp_symbol (*out_ptr);
+          break;
+        case Lisp_String:
+        case Lisp_Vectorlike:
+        case Lisp_Cons:
+        case Lisp_Float:
+          *out_lv = make_lisp_ptr (*out_ptr, type);
+          break;
+        default:
+          emacs_abort ();
+        }
+    }
+}
+
+/* Enqueue for dumping objects referenced by static non-Lisp_Object
+   pointers inside Emacs.  */
+static void
+dump_drain_user_remembered_data_hot (struct dump_context *ctx)
+{
+  for (int i = 0; i < nr_remembered_data; ++i)
+    {
+      void *mem = remembered_data[i].mem;
+      int sz = remembered_data[i].sz;
+      if (sz <= 0)
+        {
+          enum Lisp_Type type = -sz;
+          void *value;
+          Lisp_Object lv;
+          read_ptr_raw_and_lv (mem, type, &value, &lv);
+          if (value != NULL)
+            {
+              DUMP_SET_REFERRER (ctx, dump_ptr_referrer ("user data", mem));
+              dump_enqueue_object (ctx, lv, WEIGHT_NONE);
+              DUMP_CLEAR_REFERRER (ctx);
+            }
+        }
+    }
+}
+
+/* Dump user-specified non-relocated data.  */
+static void
+dump_drain_user_remembered_data_cold (struct dump_context *ctx)
+{
+  for (int i = 0; i < nr_remembered_data; ++i)
+    {
+      void *mem = remembered_data[i].mem;
+      int sz = remembered_data[i].sz;
+      if (sz > 0)
+        {
+          /* Scalar: try to inline the value into the relocation if
+             it's small enough; if it's bigger than we can fit in a
+             relocation, we have to copy the data into the dump proper
+             and emit a copy relocation.  */
+          if (sz <= sizeof (intmax_t))
+            dump_emacs_reloc_immediate (ctx, mem, mem, sz);
+          else
+            {
+              dump_emacs_reloc_copy_from_dump (ctx, ctx->offset, mem, sz);
+              dump_write (ctx, mem, sz);
+            }
+        }
+      else
+        {
+          /* *mem is a raw pointer to a Lisp object of some sort.
+             The object to which it points should have already been
+             dumped by dump_drain_user_remembered_data_hot.  */
+          void *value;
+          Lisp_Object lv;
+          enum Lisp_Type type = -sz;
+          read_ptr_raw_and_lv (mem, type, &value, &lv);
+          if (value == NULL)
+            /* We can't just ignore NULL: the variable might have
+               transitioned from non-NULL to NULL, and we want to
+               record this fact.  */
+            dump_emacs_reloc_immediate_ptrdiff_t (ctx, mem, 0);
+          else
+            {
+              if (dump_object_emacs_ptr (lv) != NULL)
+                {
+                  /* We have situation like this:
+
+                     static Lisp_Symbol *foo;
+                     ...
+                     foo = XSYMBOL(Qt);
+                     ...
+                     pdumper_remember_lv_ptr_raw (&foo, Lisp_Symbol);
+
+                     Built-in symbols like Qt aren't in the dump!
+                     They're actually in Emacs proper.  We need a
+                     special case to point this value back at Emacs
+                     instead of to something in the dump that
+                     isn't there.
+
+                     An analogous situation applies to subrs, since
+                     Lisp_Subr structures always live in Emacs, not
+                     the dump.
+                  */
+                 dump_emacs_reloc_to_emacs_ptr_raw
+                   (ctx, mem, dump_object_emacs_ptr (lv));
+                }
+              else
+                {
+                  eassert (!dump_object_self_representing_p (lv));
+                  dump_off dump_offset = dump_recall_object (ctx, lv);
+                  if (dump_offset <= 0)
+                    error ("raw-pointer object not dumped?!");
+                  dump_emacs_reloc_to_dump_ptr_raw (ctx, mem, dump_offset);
+                }
+            }
+        }
+    }
+}
+
+static void
+dump_unwind_cleanup (void *data)
+{
+  struct dump_context *ctx = data;
+  if (ctx->fd >= 0)
+    emacs_close (ctx->fd);
+#ifdef REL_ALLOC
+  if (ctx->blocked_ralloc)
+    r_alloc_inhibit_buffer_relocation (0);
+#endif
+  Vpurify_flag = ctx->old_purify_flag;
+  Vpost_gc_hook = ctx->old_post_gc_hook;
+  Vprocess_environment = ctx->old_process_environment;
+}
+
+/* Return DUMP_OFFSET, making sure it is within the heap.  */
+static dump_off
+dump_check_dump_off (struct dump_context *ctx, dump_off dump_offset)
+{
+  eassert (dump_offset > 0);
+  if (ctx)
+    eassert (dump_offset < ctx->end_heap);
+  return dump_offset;
+}
+
+static void
+dump_check_emacs_off (dump_off emacs_off)
+{
+  eassert (labs (emacs_off) <= 60 * 1024 * 1024);
+}
+
+static struct dump_reloc
+dump_decode_dump_reloc (Lisp_Object lreloc)
+{
+  struct dump_reloc reloc;
+  dump_reloc_set_type (&reloc,
+                      (enum dump_reloc_type) XFIXNUM (dump_pop (&lreloc)));
+  eassert (reloc.type <= RELOC_DUMP_TO_EMACS_LV + Lisp_Float);
+  dump_reloc_set_offset (&reloc, dump_off_from_lisp (dump_pop (&lreloc)));
+  eassert (NILP (lreloc));
+  return reloc;
+}
+
+static void
+dump_emit_dump_reloc (struct dump_context *ctx, Lisp_Object lreloc)
+{
+  eassert (ctx->flags.pack_objects);
+  struct dump_reloc reloc;
+  dump_object_start (ctx, &reloc, sizeof (reloc));
+  reloc = dump_decode_dump_reloc (lreloc);
+  dump_check_dump_off (ctx, dump_reloc_get_offset (reloc));
+  dump_object_finish (ctx, &reloc, sizeof (reloc));
+  if (dump_reloc_get_offset (reloc) < ctx->header.discardable_start)
+    ctx->number_hot_relocations += 1;
+  else
+    ctx->number_discardable_relocations += 1;
+}
+
+#ifdef ENABLE_CHECKING
+static Lisp_Object
+dump_check_overlap_dump_reloc (Lisp_Object lreloc_a,
+                               Lisp_Object lreloc_b)
+{
+  struct dump_reloc reloc_a = dump_decode_dump_reloc (lreloc_a);
+  struct dump_reloc reloc_b = dump_decode_dump_reloc (lreloc_b);
+  eassert (dump_reloc_get_offset (reloc_a) < dump_reloc_get_offset (reloc_b));
+  return Qnil;
+}
+#endif
+
+/* Translate a Lisp Emacs-relocation descriptor (a list whose first
+   element is one of the EMACS_RELOC_* values, encoded as a fixnum)
+   into an emacs_reloc structure value suitable for writing to the
+   dump file.
+*/
+static struct emacs_reloc
+decode_emacs_reloc (struct dump_context *ctx, Lisp_Object lreloc)
+{
+  struct emacs_reloc reloc;
+  memset (&reloc, 0, sizeof (reloc));
+  ALLOW_IMPLICIT_CONVERSION;
+  int type = XFIXNUM (dump_pop (&lreloc));
+  DISALLOW_IMPLICIT_CONVERSION;
+  reloc.emacs_offset = dump_off_from_lisp (dump_pop (&lreloc));
+  dump_check_emacs_off (reloc.emacs_offset);
+  switch (type)
+    {
+    case RELOC_EMACS_COPY_FROM_DUMP:
+      {
+        emacs_reloc_set_type (&reloc, type);
+        reloc.u.dump_offset = dump_off_from_lisp (dump_pop (&lreloc));
+        dump_check_dump_off (ctx, reloc.u.dump_offset);
+        dump_off length = dump_off_from_lisp (dump_pop (&lreloc));
+        ALLOW_IMPLICIT_CONVERSION;
+        reloc.length = length;
+        DISALLOW_IMPLICIT_CONVERSION;
+        if (reloc.length != length)
+          error ("relocation copy length too large");
+      }
+      break;
+    case RELOC_EMACS_IMMEDIATE:
+      {
+        emacs_reloc_set_type (&reloc, type);
+        intmax_t value = intmax_t_from_lisp (dump_pop (&lreloc));
+        dump_off size = dump_off_from_lisp (dump_pop (&lreloc));
+        reloc.u.immediate = value;
+        ALLOW_IMPLICIT_CONVERSION;
+        reloc.length = size;
+        DISALLOW_IMPLICIT_CONVERSION;
+        eassert (reloc.length == size);
+      }
+      break;
+    case RELOC_EMACS_EMACS_PTR_RAW:
+      emacs_reloc_set_type (&reloc, type);
+      reloc.u.emacs_offset2 = dump_off_from_lisp (dump_pop (&lreloc));
+      dump_check_emacs_off (reloc.u.emacs_offset2);
+      break;
+    case RELOC_EMACS_DUMP_PTR_RAW:
+      emacs_reloc_set_type (&reloc, type);
+      reloc.u.dump_offset = dump_off_from_lisp (dump_pop (&lreloc));
+      dump_check_dump_off (ctx, reloc.u.dump_offset);
+      break;
+    case RELOC_EMACS_DUMP_LV:
+    case RELOC_EMACS_EMACS_LV:
+      {
+        emacs_reloc_set_type (&reloc, type);
+        Lisp_Object target_value = dump_pop (&lreloc);
+        /* If the object is self-representing,
+           dump_emacs_reloc_to_lv didn't do its job.
+           dump_emacs_reloc_to_lv should have added a
+           RELOC_EMACS_IMMEDIATE relocation instead.  */
+        eassert (!dump_object_self_representing_p (target_value));
+        int tag_type = XTYPE (target_value);
+        ALLOW_IMPLICIT_CONVERSION;
+        reloc.length = tag_type;
+        DISALLOW_IMPLICIT_CONVERSION;
+        eassert (reloc.length == tag_type);
+
+        if (type == RELOC_EMACS_EMACS_LV)
+          {
+            void *obj_in_emacs = dump_object_emacs_ptr (target_value);
+            eassert (obj_in_emacs);
+            reloc.u.emacs_offset2 = emacs_offset (obj_in_emacs);
+          }
+        else
+          {
+            eassert (!dump_object_emacs_ptr (target_value));
+            reloc.u.dump_offset = dump_recall_object (ctx, target_value);
+            if (reloc.u.dump_offset <= 0)
+              {
+                Lisp_Object repr = Fprin1_to_string (target_value, Qnil);
+                error ("relocation target was not dumped: %s", SDATA (repr));
+              }
+            dump_check_dump_off (ctx, reloc.u.dump_offset);
+          }
+      }
+      break;
+    default:
+      eassume (!"not reached");
+    }
+
+  /* We should have consumed the whole relocation descriptor.  */
+  eassert (NILP (lreloc));
+
+  return reloc;
+}
+
+static void
+dump_emit_emacs_reloc (struct dump_context *ctx, Lisp_Object lreloc)
+{
+  eassert (ctx->flags.pack_objects);
+  struct emacs_reloc reloc;
+  dump_object_start (ctx, &reloc, sizeof (reloc));
+  reloc = decode_emacs_reloc (ctx, lreloc);
+  dump_object_finish (ctx, &reloc, sizeof (reloc));
+}
+
+static Lisp_Object
+dump_merge_emacs_relocs (Lisp_Object lreloc_a, Lisp_Object lreloc_b)
+{
+  /* Combine copy relocations together if they're copying from
+     adjacent chunks to adjacent chunks.  */
+
+#ifdef ENABLE_CHECKING
+  {
+    dump_off off_a = dump_off_from_lisp (XCAR (XCDR (lreloc_a)));
+    dump_off off_b = dump_off_from_lisp (XCAR (XCDR (lreloc_b)));
+    eassert (off_a <= off_b);  /* Catch sort errors.  */
+    eassert (off_a < off_b);  /* Catch duplicate relocations.  */
+  }
+#endif
+
+  if (XFIXNUM (XCAR (lreloc_a)) != RELOC_EMACS_COPY_FROM_DUMP
+      || XFIXNUM (XCAR (lreloc_b)) != RELOC_EMACS_COPY_FROM_DUMP)
+    return Qnil;
+
+  struct emacs_reloc reloc_a = decode_emacs_reloc (NULL, lreloc_a);
+  struct emacs_reloc reloc_b = decode_emacs_reloc (NULL, lreloc_b);
+
+  eassert (reloc_a.type == RELOC_EMACS_COPY_FROM_DUMP);
+  eassert (reloc_b.type == RELOC_EMACS_COPY_FROM_DUMP);
+
+  if (reloc_a.emacs_offset + reloc_a.length != reloc_b.emacs_offset)
+    return Qnil;
+
+  if (reloc_a.u.dump_offset + reloc_a.length != reloc_b.u.dump_offset)
+    return Qnil;
+
+  dump_off new_length = reloc_a.length + reloc_b.length;
+  ALLOW_IMPLICIT_CONVERSION;
+  reloc_a.length = new_length;
+  DISALLOW_IMPLICIT_CONVERSION;
+  if (reloc_a.length != new_length)
+    return Qnil; /* Overflow */
+
+  return list4 (make_fixnum (RELOC_EMACS_COPY_FROM_DUMP),
+                dump_off_to_lisp (reloc_a.emacs_offset),
+                dump_off_to_lisp (reloc_a.u.dump_offset),
+                dump_off_to_lisp (reloc_a.length));
+}
+
+typedef void (*drain_reloc_handler) (struct dump_context *, Lisp_Object);
+typedef Lisp_Object (*drain_reloc_merger) (Lisp_Object a, Lisp_Object b);
+
+static void
+drain_reloc_list (struct dump_context *ctx,
+                  drain_reloc_handler handler,
+                  drain_reloc_merger merger,
+                  Lisp_Object *reloc_list,
+                  struct dump_table_locator *out_locator)
+{
+  struct dump_flags old_flags = ctx->flags;
+  ctx->flags.pack_objects = true;
+  Lisp_Object relocs = Fsort (Fnreverse (*reloc_list),
+                              Qdump_emacs_portable__sort_predicate);
+  *reloc_list = Qnil;
+  dump_align_output (ctx, max (alignof (struct dump_reloc),
+                              alignof (struct emacs_reloc)));
+  struct dump_table_locator locator;
+  memset (&locator, 0, sizeof (locator));
+  locator.offset = ctx->offset;
+  for (; !NILP (relocs); locator.nr_entries += 1)
+    {
+      Lisp_Object reloc = dump_pop (&relocs);
+      Lisp_Object merged;
+      while (merger != NULL
+            && !NILP (relocs)
+            && (merged = merger (reloc, XCAR (relocs)), !NILP (merged)))
+        {
+          reloc = merged;
+          relocs = XCDR (relocs);
+        }
+      handler (ctx, reloc);
+    }
+  *out_locator = locator;
+  ctx->flags = old_flags;
+}
+
+static void
+dump_do_fixup (struct dump_context *ctx,
+               Lisp_Object fixup,
+               Lisp_Object prev_fixup)
+{
+  enum dump_fixup_type type =
+    (enum dump_fixup_type) XFIXNUM (dump_pop (&fixup));
+  dump_off dump_fixup_offset = dump_off_from_lisp (dump_pop (&fixup));
+#ifdef ENABLE_CHECKING
+  if (!NILP (prev_fixup))
+    {
+      dump_off prev_dump_fixup_offset =
+        dump_off_from_lisp (XCAR (XCDR (prev_fixup)));
+      eassert (dump_fixup_offset - prev_dump_fixup_offset
+              >= sizeof (void *));
+    }
+#endif
+  Lisp_Object arg = dump_pop (&fixup);
+  eassert (NILP (fixup));
+  dump_seek (ctx, dump_fixup_offset);
+  intptr_t dump_value;
+  bool do_write = true;
+  switch (type)
+    {
+    case DUMP_FIXUP_LISP_OBJECT:
+    case DUMP_FIXUP_LISP_OBJECT_RAW:
+      /* Dump wants a pointer to a Lisp object.
+         If DUMP_FIXUP_LISP_OBJECT_RAW, we should stick a C pointer in
+         the dump; otherwise, a Lisp_Object.  */
+      if (SUBRP (arg))
+        {
+          dump_value = emacs_offset (XSUBR (arg));
+          if (type == DUMP_FIXUP_LISP_OBJECT)
+            dump_reloc_dump_to_emacs_lv (ctx, ctx->offset, XTYPE (arg));
+          else
+            dump_reloc_dump_to_emacs_ptr_raw (ctx, ctx->offset);
+        }
+      else if (dump_builtin_symbol_p (arg))
+        {
+          eassert (dump_object_self_representing_p (arg));
+          /* These symbols are part of Emacs, so point there.  If we
+             want a Lisp_Object, we're set.  If we want a raw pointer,
+             we need to emit a relocation.  */
+          if (type == DUMP_FIXUP_LISP_OBJECT)
+            {
+              do_write = false;
+              dump_write (ctx, &arg, sizeof (arg));
+            }
+          else
+            {
+              dump_value = emacs_offset (XSYMBOL (arg));
+              dump_reloc_dump_to_emacs_ptr_raw (ctx, ctx->offset);
+            }
+        }
+      else
+        {
+          eassert (dump_object_emacs_ptr (arg) == NULL);
+          dump_value = dump_recall_object (ctx, arg);
+          if (dump_value <= 0)
+            error ("fixup object not dumped");
+          if (type == DUMP_FIXUP_LISP_OBJECT)
+            dump_reloc_dump_to_dump_lv (ctx, ctx->offset, XTYPE (arg));
+          else
+            dump_reloc_dump_to_dump_ptr_raw (ctx, ctx->offset);
+        }
+      break;
+    case DUMP_FIXUP_PTR_DUMP_RAW:
+      /* Dump wants a raw pointer to something that's not a lisp
+         object.  It knows the exact location it wants, so just
+         believe it.  */
+      dump_value = dump_off_from_lisp (arg);
+      dump_reloc_dump_to_dump_ptr_raw (ctx, ctx->offset);
+      break;
+    case DUMP_FIXUP_BIGNUM_DATA:
+      {
+        eassert (BIGNUMP (arg));
+        arg = Fgethash (arg, ctx->bignum_data, Qnil);
+        if (NILP (arg))
+          error ("bignum not dumped");
+        struct bignum_reload_info reload_info = { 0 };
+        reload_info.data_location = dump_off_from_lisp (dump_pop (&arg));
+        reload_info.nlimbs = dump_off_from_lisp (dump_pop (&arg));
+        eassert (NILP (arg));
+        dump_write (ctx, &reload_info, sizeof (reload_info));
+        do_write = false;
+        break;
+      }
+    default:
+      emacs_abort ();
+    }
+  if (do_write)
+    dump_write (ctx, &dump_value, sizeof (dump_value));
+}
+
+static void
+dump_do_fixups (struct dump_context *ctx)
+{
+  dump_off saved_offset = ctx->offset;
+  Lisp_Object fixups = Fsort (Fnreverse (ctx->fixups),
+                              Qdump_emacs_portable__sort_predicate);
+  Lisp_Object prev_fixup = Qnil;
+  ctx->fixups = Qnil;
+  while (!NILP (fixups))
+    {
+      Lisp_Object fixup = dump_pop (&fixups);
+      dump_do_fixup (ctx, fixup, prev_fixup);
+      prev_fixup = fixup;
+    }
+  dump_seek (ctx, saved_offset);
+}
+
+static void
+dump_drain_normal_queue (struct dump_context *ctx)
+{
+  while (!dump_queue_empty_p (&ctx->dump_queue))
+    dump_object (ctx, dump_queue_dequeue (&ctx->dump_queue, ctx->offset));
+}
+
+static void
+dump_drain_deferred_hash_tables (struct dump_context *ctx)
+{
+  struct dump_flags old_flags = ctx->flags;
+
+  /* Now we want to actually write the hash tables.  */
+  ctx->flags.defer_hash_tables = false;
+
+  Lisp_Object deferred_hash_tables = Fnreverse (ctx->deferred_hash_tables);
+  ctx->deferred_hash_tables = Qnil;
+  while (!NILP (deferred_hash_tables))
+    dump_object (ctx, dump_pop (&deferred_hash_tables));
+  ctx->flags = old_flags;
+}
+
+static void
+dump_drain_deferred_symbols (struct dump_context *ctx)
+{
+  struct dump_flags old_flags = ctx->flags;
+
+  /* Now we want to actually write the symbols.  */
+  ctx->flags.defer_symbols = false;
+
+  Lisp_Object deferred_symbols = Fnreverse (ctx->deferred_symbols);
+  ctx->deferred_symbols = Qnil;
+  while (!NILP (deferred_symbols))
+    dump_object (ctx, dump_pop (&deferred_symbols));
+  ctx->flags = old_flags;
+}
+
+DEFUN ("dump-emacs-portable",
+       Fdump_emacs_portable, Sdump_emacs_portable,
+       1, 2, 0,
+       doc: /* Dump current state of Emacs into portable dump file FILENAME.
+If TRACK-REFERRERS is non-nil, keep additional debugging information
+that can help track down the provenance of unsupported object
+types.  */)
+     (Lisp_Object filename, Lisp_Object track_referrers)
+{
+  eassert (initialized);
+
+  if (will_dump_with_unexec_p ())
+    error ("This Emacs instance was started under the assumption "
+           "that it would be dumped with unexec, not the portable "
+           "dumper.  Dumping with the portable dumper may produce "
+           "unexpected results.");
+
+  if (!main_thread_p (current_thread))
+    error ("This function can be called only in the main thread");
+
+  if (!NILP (XCDR (Fall_threads ())))
+    error ("No other Lisp threads can be running when this function is 
called");
+
+  /* Clear out any detritus in memory.  */
+  do
+    {
+      number_finalizers_run = 0;
+      garbage_collect ();
+    }
+  while (number_finalizers_run);
+
+  ptrdiff_t count = SPECPDL_INDEX ();
+
+  /* Bind `command-line-processed' to nil before dumping,
+     so that the dumped Emacs will process its command line
+     and set up to work with X windows if appropriate.  */
+  Lisp_Object symbol = intern ("command-line-processed");
+  specbind (symbol, Qnil);
+
+  CHECK_STRING (filename);
+  filename = Fexpand_file_name (filename, Qnil);
+  filename = ENCODE_FILE (filename);
+
+  struct dump_context ctx_buf;
+  struct dump_context *ctx = &ctx_buf;
+  memset (ctx, 0, sizeof (*ctx));
+  ctx->fd = -1;
+
+  ctx->objects_dumped = make_eq_hash_table ();
+  dump_queue_init (&ctx->dump_queue);
+  ctx->deferred_hash_tables = Qnil;
+  ctx->deferred_symbols = Qnil;
+
+  ctx->fixups = Qnil;
+  ctx->staticpro_table = Fmake_hash_table (0, NULL);
+  ctx->symbol_aux = Qnil;
+  ctx->copied_queue = Qnil;
+  ctx->cold_queue = Qnil;
+  ctx->dump_relocs = Qnil;
+  ctx->object_starts = Qnil;
+  ctx->emacs_relocs = Qnil;
+  ctx->bignum_data = make_eq_hash_table ();
+
+  /* Ordinarily, dump_object should remember where it saw objects and
+     actually write the object contents to the dump file.  In special
+     circumstances below, we temporarily change this default
+     behavior.  */
+  ctx->flags.dump_object_contents = true;
+  ctx->flags.record_object_starts = true;
+
+  /* We want to consolidate certain object types that we know are very likely
+     to be modified.  */
+  ctx->flags.defer_hash_tables = true;
+  /* ctx->flags.defer_symbols = true; XXX  */
+
+  /* These objects go into special sections.  */
+  ctx->flags.defer_cold_objects = true;
+  ctx->flags.defer_copied_objects = true;
+
+  ctx->current_referrer = Qnil;
+  if (!NILP (track_referrers))
+    ctx->referrers = make_eq_hash_table ();
+
+  ctx->dump_filename = filename;
+
+  record_unwind_protect_ptr (dump_unwind_cleanup, ctx);
+  block_input ();
+
+#ifdef REL_ALLOC
+  r_alloc_inhibit_buffer_relocation (1);
+  ctx->blocked_ralloc = true;
+#endif
+
+  ctx->old_purify_flag = Vpurify_flag;
+  Vpurify_flag = Qnil;
+
+  /* Make sure various weird things are less likely to happen.  */
+  ctx->old_post_gc_hook = Vpost_gc_hook;
+  Vpost_gc_hook = Qnil;
+
+  /* Reset process-environment -- this is for when they re-dump a
+     pdump-restored emacs, since set_initial_environment wants always
+     to cons it from scratch.  */
+  ctx->old_process_environment = Vprocess_environment;
+  Vprocess_environment = Qnil;
+
+  ctx->fd = emacs_open (SSDATA (filename),
+                        O_RDWR | O_TRUNC | O_CREAT, 0666);
+  if (ctx->fd < 0)
+    report_file_error ("Opening dump output", filename);
+  verify (sizeof (ctx->header.magic) == sizeof (dump_magic));
+  memcpy (&ctx->header.magic, dump_magic, sizeof (dump_magic));
+  ctx->header.magic[0] = '!'; /* Note that dump is incomplete.  */
+
+  verify (sizeof (fingerprint) == sizeof (ctx->header.fingerprint));
+  memcpy (ctx->header.fingerprint, fingerprint, sizeof (fingerprint));
+
+  const dump_off header_start = ctx->offset;
+  dump_fingerprint ("dumping fingerprint", ctx->header.fingerprint);
+  dump_write (ctx, &ctx->header, sizeof (ctx->header));
+  const dump_off header_end = ctx->offset;
+
+  const dump_off hot_start = ctx->offset;
+  /* Start the dump process by processing the static roots and
+     queuing up the objects to which they refer.   */
+  dump_roots (ctx);
+
+  dump_charset_table (ctx);
+  dump_finalizer_list_head_ptr (ctx, &finalizers.prev);
+  dump_finalizer_list_head_ptr (ctx, &finalizers.next);
+  dump_finalizer_list_head_ptr (ctx, &doomed_finalizers.prev);
+  dump_finalizer_list_head_ptr (ctx, &doomed_finalizers.next);
+  dump_drain_user_remembered_data_hot (ctx);
+
+  /* We've already remembered all the objects to which GC roots point,
+     but we have to manually save the list of GC roots itself.  */
+  dump_metadata_for_pdumper (ctx);
+  for (int i = 0; i < staticidx; ++i)
+    dump_emacs_reloc_to_emacs_ptr_raw (ctx, &staticvec[i], staticvec[i]);
+  dump_emacs_reloc_immediate_int (ctx, &staticidx, staticidx);
+
+  /* Dump until while we keep finding objects to dump.  We add new
+     objects to the queue by side effect during dumping.
+     We accumulate some types of objects in special lists to get more
+     locality for these object types at runtime.  */
+  do
+    {
+      dump_drain_deferred_hash_tables (ctx);
+      dump_drain_deferred_symbols (ctx);
+      dump_drain_normal_queue (ctx);
+    }
+  while (!dump_queue_empty_p (&ctx->dump_queue)
+        || !NILP (ctx->deferred_hash_tables)
+        || !NILP (ctx->deferred_symbols));
+
+  dump_sort_copied_objects (ctx);
+
+  /* While we copy built-in symbols into the Emacs image, these
+     built-in structures refer to non-Lisp heap objects that must live
+     in the dump; we stick these auxiliary data structures at the end
+     of the hot section and use a special hash table to remember them.
+     The actual symbol dump will pick them up below.  */
+  ctx->symbol_aux = make_eq_hash_table ();
+  dump_hot_parts_of_discardable_objects (ctx);
+
+  /* Emacs, after initial dump loading, can forget about the portion
+     of the dump that runs from here to the start of the cold section.
+     This section consists of objects that need to be memcpy()ed into
+     the Emacs data section instead of just used directly.
+
+     We don't need to align hot_end: the loader knows to actually
+     start discarding only at the next page boundary if the loader
+     implements discarding using page manipulation.  */
+  const dump_off hot_end = ctx->offset;
+  ctx->header.discardable_start = hot_end;
+
+  dump_drain_copied_objects (ctx);
+  eassert (dump_queue_empty_p (&ctx->dump_queue));
+
+  dump_off discardable_end = ctx->offset;
+  dump_align_output (ctx, dump_get_page_size ());
+  ctx->header.cold_start = ctx->offset;
+
+  /* Start the cold section.  This section contains bytes that should
+     never change and so can be direct-mapped from the dump without
+     special processing.  */
+  dump_drain_cold_data (ctx);
+   /* dump_drain_user_remembered_data_cold needs to be after
+      dump_drain_cold_data in case dump_drain_cold_data dumps a lisp
+      object to which C code points.
+      dump_drain_user_remembered_data_cold assumes that all lisp
+      objects have been dumped.  */
+  dump_drain_user_remembered_data_cold (ctx);
+
+  /* After this point, the dump file contains no data that can be part
+     of the Lisp heap.  */
+  ctx->end_heap = ctx->offset;
+
+  /* Make remembered modifications to the dump file itself.  */
+  dump_do_fixups (ctx);
+
+  drain_reloc_merger emacs_reloc_merger =
+#ifdef ENABLE_CHECKING
+    dump_check_overlap_dump_reloc
+#else
+    NULL
+#endif
+    ;
+
+  /* Emit instructions for Emacs to execute when loading the dump.
+     Note that this relocation information ends up in the cold section
+     of the dump.  */
+  drain_reloc_list (ctx, dump_emit_dump_reloc, emacs_reloc_merger,
+                   &ctx->dump_relocs, &ctx->header.dump_relocs);
+  unsigned number_hot_relocations = ctx->number_hot_relocations;
+  ctx->number_hot_relocations = 0;
+  unsigned number_discardable_relocations = 
ctx->number_discardable_relocations;
+  ctx->number_discardable_relocations = 0;
+  drain_reloc_list (ctx, dump_emit_dump_reloc, emacs_reloc_merger,
+                   &ctx->object_starts, &ctx->header.object_starts);
+  drain_reloc_list (ctx, dump_emit_emacs_reloc, dump_merge_emacs_relocs,
+                   &ctx->emacs_relocs, &ctx->header.emacs_relocs);
+
+  const dump_off cold_end = ctx->offset;
+
+  eassert (dump_queue_empty_p (&ctx->dump_queue));
+  eassert (NILP (ctx->copied_queue));
+  eassert (NILP (ctx->cold_queue));
+  eassert (NILP (ctx->deferred_symbols));
+  eassert (NILP (ctx->deferred_hash_tables));
+  eassert (NILP (ctx->fixups));
+  eassert (NILP (ctx->dump_relocs));
+  eassert (NILP (ctx->emacs_relocs));
+
+  /* Dump is complete.  Go back to the header and write the magic
+     indicating that the dump is complete and can be loaded.  */
+  ctx->header.magic[0] = dump_magic[0];
+  dump_seek (ctx, 0);
+  dump_write (ctx, &ctx->header, sizeof (ctx->header));
+
+  fprintf (stderr, "Dump complete\n");
+  fprintf (stderr,
+           "Byte counts: header=%lu hot=%lu discardable=%lu cold=%lu\n",
+           (unsigned long) (header_end - header_start),
+           (unsigned long) (hot_end - hot_start),
+           (unsigned long) (discardable_end - ctx->header.discardable_start),
+           (unsigned long) (cold_end - ctx->header.cold_start));
+  fprintf (stderr, "Reloc counts: hot=%u discardable=%u\n",
+           number_hot_relocations,
+           number_discardable_relocations);
+
+  unblock_input ();
+  return unbind_to (count, Qnil);
+}
+
+DEFUN ("dump-emacs-portable--sort-predicate",
+       Fdump_emacs_portable__sort_predicate,
+       Sdump_emacs_portable__sort_predicate,
+       2, 2, 0,
+       doc: /* Internal relocation sorting function.  */)
+     (Lisp_Object a, Lisp_Object b)
+{
+  dump_off a_offset = dump_off_from_lisp (XCAR (XCDR (a)));
+  dump_off b_offset = dump_off_from_lisp (XCAR (XCDR (b)));
+  return a_offset < b_offset ? Qt : Qnil;
+}
+
+DEFUN ("dump-emacs-portable--sort-predicate-copied",
+       Fdump_emacs_portable__sort_predicate_copied,
+       Sdump_emacs_portable__sort_predicate_copied,
+       2, 2, 0,
+       doc: /* Internal relocation sorting function.  */)
+     (Lisp_Object a, Lisp_Object b)
+{
+  eassert (dump_object_emacs_ptr (a));
+  eassert (dump_object_emacs_ptr (b));
+  return dump_object_emacs_ptr (a) < dump_object_emacs_ptr (b) ? Qt : Qnil;
+}
+
+void
+pdumper_do_now_and_after_load_impl (pdumper_hook hook)
+{
+  if (nr_dump_hooks == ARRAYELTS (dump_hooks))
+    fatal ("out of dump hooks: make dump_hooks[] bigger");
+  dump_hooks[nr_dump_hooks++] = hook;
+  hook ();
+}
+
+static void
+pdumper_remember_user_data_1 (void *mem, int nbytes)
+{
+  if (nr_remembered_data == ARRAYELTS (remembered_data))
+    fatal ("out of remembered data slots: make remembered_data[] bigger");
+  remembered_data[nr_remembered_data].mem = mem;
+  remembered_data[nr_remembered_data].sz = nbytes;
+  nr_remembered_data += 1;
+}
+
+void
+pdumper_remember_scalar_impl (void *mem, ptrdiff_t nbytes)
+{
+  eassert (0 <= nbytes && nbytes <= INT_MAX);
+  if (nbytes > 0)
+    pdumper_remember_user_data_1 (mem, (int) nbytes);
+}
+
+void
+pdumper_remember_lv_ptr_raw_impl (void *ptr, enum Lisp_Type type)
+{
+  pdumper_remember_user_data_1 (ptr, -type);
+}
+
+
+/* Dump runtime */
+enum dump_memory_protection
+{
+  DUMP_MEMORY_ACCESS_NONE = 1,
+  DUMP_MEMORY_ACCESS_READ = 2,
+  DUMP_MEMORY_ACCESS_READWRITE = 3,
+};
+
+#if VM_SUPPORTED == VM_MS_WINDOWS
+static void *
+dump_anonymous_allocate_w32 (void *base,
+                             size_t size,
+                             enum dump_memory_protection protection)
+{
+  void *ret;
+  DWORD mem_type;
+  DWORD mem_prot;
+
+  switch (protection)
+    {
+    case DUMP_MEMORY_ACCESS_NONE:
+      mem_type = MEM_RESERVE;
+      mem_prot = PAGE_NOACCESS;
+      break;
+    case DUMP_MEMORY_ACCESS_READ:
+      mem_type = MEM_COMMIT;
+      mem_prot = PAGE_READONLY;
+      break;
+    case DUMP_MEMORY_ACCESS_READWRITE:
+      mem_type = MEM_COMMIT;
+      mem_prot = PAGE_READWRITE;
+      break;
+    default:
+      emacs_abort ();
+    }
+
+  ret = VirtualAlloc (base, size, mem_type, mem_prot);
+  if (ret == NULL)
+    errno = (base && GetLastError () == ERROR_INVALID_ADDRESS)
+      ? EBUSY
+      : EPERM;
+  return ret;
+}
+#endif
+
+#if VM_SUPPORTED == VM_POSIX
+
+/* Old versions of macOS only define MAP_ANON, not MAP_ANONYMOUS.
+   FIXME: This probably belongs elsewhere (gnulib/autoconf?)  */
+# ifndef MAP_ANONYMOUS
+#  define MAP_ANONYMOUS MAP_ANON
+# endif
+
+static void *
+dump_anonymous_allocate_posix (void *base,
+                               size_t size,
+                               enum dump_memory_protection protection)
+{
+  void *ret;
+  int mem_prot;
+
+  switch (protection)
+    {
+    case DUMP_MEMORY_ACCESS_NONE:
+      mem_prot = PROT_NONE;
+      break;
+    case DUMP_MEMORY_ACCESS_READ:
+      mem_prot = PROT_READ;
+      break;
+    case DUMP_MEMORY_ACCESS_READWRITE:
+      mem_prot = PROT_READ | PROT_WRITE;
+      break;
+    default:
+      emacs_abort ();
+    }
+
+  int mem_flags = MAP_PRIVATE | MAP_ANONYMOUS;
+  if (mem_prot != PROT_NONE)
+    mem_flags |= MAP_POPULATE;
+  if (base)
+    mem_flags |= MAP_FIXED;
+
+  bool retry;
+  do
+    {
+      retry = false;
+      ret = mmap (base, size, mem_prot, mem_flags, -1, 0);
+      if (ret == MAP_FAILED
+         && errno == EINVAL
+         && (mem_flags & MAP_POPULATE))
+        {
+          /* This system didn't understand MAP_POPULATE, so try
+             again without it.  */
+          mem_flags &= ~MAP_POPULATE;
+          retry = true;
+        }
+    }
+  while (retry);
+
+  if (ret == MAP_FAILED)
+    ret = NULL;
+  return ret;
+}
+#endif
+
+/* Perform anonymous memory allocation.  */
+static void *
+dump_anonymous_allocate (void *base,
+                         const size_t size,
+                         enum dump_memory_protection protection)
+{
+#if VM_SUPPORTED == VM_POSIX
+  return dump_anonymous_allocate_posix (base, size, protection);
+#elif VM_SUPPORTED == VM_MS_WINDOWS
+  return dump_anonymous_allocate_w32 (base, size, protection);
+#else
+  errno = ENOSYS;
+  return NULL;
+#endif
+}
+
+/* Undo the effect of dump_reserve_address_space().  */
+static void
+dump_anonymous_release (void *addr, size_t size)
+{
+  eassert (size >= 0);
+#if VM_SUPPORTED == VM_MS_WINDOWS
+  (void) size;
+  if (!VirtualFree (addr, 0, MEM_RELEASE))
+    emacs_abort ();
+#elif VM_SUPPORTED == VM_POSIX
+  if (munmap (addr, size) < 0)
+    emacs_abort ();
+#else
+  (void) addr;
+  (void) size;
+  emacs_abort ();
+#endif
+}
+
+#if VM_SUPPORTED == VM_MS_WINDOWS
+static void *
+dump_map_file_w32 (void *base, int fd, off_t offset, size_t size,
+                  enum dump_memory_protection protection)
+{
+  void *ret = NULL;
+  HANDLE section = NULL;
+  HANDLE file;
+
+  uint64_t full_offset = offset;
+  uint32_t offset_high = (uint32_t) (full_offset >> 32);
+  uint32_t offset_low = (uint32_t) (full_offset & 0xffffffff);
+
+  int error;
+  DWORD map_access;
+
+  file = (HANDLE) _get_osfhandle (fd);
+  if (file == INVALID_HANDLE_VALUE)
+    goto out;
+
+  section = CreateFileMapping (file,
+                              /*lpAttributes=*/NULL,
+                              PAGE_READONLY,
+                              /*dwMaximumSizeHigh=*/0,
+                              /*dwMaximumSizeLow=*/0,
+                              /*lpName=*/NULL);
+  if (!section)
+    {
+      errno = EINVAL;
+      goto out;
+    }
+
+  switch (protection)
+    {
+    case DUMP_MEMORY_ACCESS_NONE:
+    case DUMP_MEMORY_ACCESS_READ:
+      map_access = FILE_MAP_READ;
+      break;
+    case DUMP_MEMORY_ACCESS_READWRITE:
+      map_access = FILE_MAP_COPY;
+      break;
+    default:
+      emacs_abort ();
+    }
+
+  ret = MapViewOfFileEx (section,
+                         map_access,
+                         offset_high,
+                         offset_low,
+                         size,
+                         base);
+
+  error = GetLastError ();
+  if (ret == NULL)
+    errno = (error == ERROR_INVALID_ADDRESS ? EBUSY : EPERM);
+ out:
+  if (section && !CloseHandle (section))
+    emacs_abort ();
+  return ret;
+}
+#endif
+
+#if VM_SUPPORTED == VM_POSIX
+static void *
+dump_map_file_posix (void *base, int fd, off_t offset, size_t size,
+                    enum dump_memory_protection protection)
+{
+  void *ret;
+  int mem_prot;
+  int mem_flags;
+
+  switch (protection)
+    {
+    case DUMP_MEMORY_ACCESS_NONE:
+      mem_prot = PROT_NONE;
+      mem_flags = MAP_SHARED;
+      break;
+    case DUMP_MEMORY_ACCESS_READ:
+      mem_prot = PROT_READ;
+      mem_flags = MAP_SHARED;
+      break;
+    case DUMP_MEMORY_ACCESS_READWRITE:
+      mem_prot = PROT_READ | PROT_WRITE;
+      mem_flags = MAP_PRIVATE;
+      break;
+    default:
+      emacs_abort ();
+    }
+
+  if (base)
+    mem_flags |= MAP_FIXED;
+
+  ret = mmap (base, size, mem_prot, mem_flags, fd, offset);
+  if (ret == MAP_FAILED)
+    ret = NULL;
+  return ret;
+}
+#endif
+
+/* Map a file into memory.  */
+static void *
+dump_map_file (void *base, int fd, off_t offset, size_t size,
+              enum dump_memory_protection protection)
+{
+#if VM_SUPPORTED == VM_POSIX
+  return dump_map_file_posix (base, fd, offset, size, protection);
+#elif VM_SUPPORTED == VM_MS_WINDOWS
+  return dump_map_file_w32 (base, fd, offset, size, protection);
+#else
+  errno = ENOSYS;
+  return NULL;
+#endif
+}
+
+/* Remove a virtual memory mapping.
+
+   On failure, abort Emacs.  For maximum platform compatibility, ADDR
+   and SIZE must match the mapping exactly.  */
+static void
+dump_unmap_file (void *addr, size_t size)
+{
+  eassert (size >= 0);
+#if !VM_SUPPORTED
+  (void) addr;
+  (void) size;
+  emacs_abort ();
+#elif defined (WINDOWSNT)
+  (void) size;
+  if (!UnmapViewOfFile (addr))
+    emacs_abort ();
+#else
+  if (munmap (addr, size) < 0)
+    emacs_abort ();
+#endif
+}
+
+struct dump_memory_map_spec
+{
+  int fd;  /* File to map; anon zero if negative.  */
+  size_t size;  /* Number of bytes to map.  */
+  off_t offset;  /* Offset within fd.  */
+  enum dump_memory_protection protection;
+};
+
+struct dump_memory_map
+{
+  struct dump_memory_map_spec spec;
+  void *mapping;  /* Actual mapped memory.  */
+  void (*release) (struct dump_memory_map *);
+  void *private;
+};
+
+/* Mark the pages as unneeded, potentially zeroing them, without
+   releasing the address space reservation.  */
+static void
+dump_discard_mem (void *mem, size_t size)
+{
+#if VM_SUPPORTED == VM_MS_WINDOWS
+      /* Discard COWed pages.  */
+      (void) VirtualFree (mem, size, MEM_DECOMMIT);
+      /* Release the commit charge for the mapping.  */
+      DWORD old_prot;
+      (void) VirtualProtect (mem, size, PAGE_NOACCESS, &old_prot);
+#elif VM_SUPPORTED == VM_POSIX
+# ifdef HAVE_POSIX_MADVISE
+      /* Discard COWed pages.  */
+      (void) posix_madvise (mem, size, POSIX_MADV_DONTNEED);
+# endif
+      /* Release the commit charge for the mapping.  */
+      (void) mprotect (mem, size, PROT_NONE);
+#endif
+}
+
+static void
+dump_mmap_discard_contents (struct dump_memory_map *map)
+{
+  if (map->mapping)
+    dump_discard_mem (map->mapping, map->spec.size);
+}
+
+static void
+dump_mmap_reset (struct dump_memory_map *map)
+{
+  map->mapping = NULL;
+  map->release = NULL;
+  map->private = NULL;
+}
+
+static void
+dump_mmap_release (struct dump_memory_map *map)
+{
+  if (map->release)
+    map->release (map);
+  dump_mmap_reset (map);
+}
+
+/* Allows heap-allocated dump_mmap to "free" maps individually.  */
+struct dump_memory_map_heap_control_block
+{
+  int refcount;
+  void *mem;
+};
+
+static void
+dump_mm_heap_cb_release (struct dump_memory_map_heap_control_block *cb)
+{
+  eassert (cb->refcount > 0);
+  if (--cb->refcount == 0)
+    {
+      free (cb->mem);
+      free (cb);
+    }
+}
+
+static void
+dump_mmap_release_heap (struct dump_memory_map *map)
+{
+  dump_mm_heap_cb_release (map->private);
+}
+
+/* Implement dump_mmap using malloc and read.  */
+static bool
+dump_mmap_contiguous_heap (struct dump_memory_map *maps, int nr_maps,
+                          size_t total_size)
+{
+  bool ret = false;
+
+  /* FIXME: This storage sometimes is never freed.
+     Beware: the simple patch 2019-03-11T15:20:address@hidden
+     is worse, as it sometimes frees this storage twice.  */
+  struct dump_memory_map_heap_control_block *cb = calloc (1, sizeof (*cb));
+
+  char *mem;
+  if (!cb)
+    goto out;
+  cb->refcount = 1;
+  cb->mem = malloc (total_size);
+  if (!cb->mem)
+    goto out;
+  mem = cb->mem;
+  for (int i = 0; i < nr_maps; ++i)
+    {
+      struct dump_memory_map *map = &maps[i];
+      const struct dump_memory_map_spec spec = map->spec;
+      if (!spec.size)
+        continue;
+      map->mapping = mem;
+      mem += spec.size;
+      map->release = dump_mmap_release_heap;
+      map->private = cb;
+      cb->refcount += 1;
+      if (spec.fd < 0)
+        memset (map->mapping, 0, spec.size);
+      else
+        {
+          if (lseek (spec.fd, spec.offset, SEEK_SET) < 0)
+            goto out;
+          ssize_t nb = dump_read_all (spec.fd,
+                                      map->mapping,
+                                      spec.size);
+          if (nb >= 0 && nb != spec.size)
+            errno = EIO;
+          if (nb != spec.size)
+            goto out;
+        }
+    }
+
+  ret = true;
+ out:
+  dump_mm_heap_cb_release (cb);
+  if (!ret)
+    for (int i = 0; i < nr_maps; ++i)
+      dump_mmap_release (&maps[i]);
+  return ret;
+}
+
+static void
+dump_mmap_release_vm (struct dump_memory_map *map)
+{
+  if (map->spec.fd < 0)
+    dump_anonymous_release (map->mapping, map->spec.size);
+  else
+    dump_unmap_file (map->mapping, map->spec.size);
+}
+
+static bool
+needs_mmap_retry_p (void)
+{
+#if defined (CYGWIN) || VM_SUPPORTED == VM_MS_WINDOWS
+  return true;
+#else
+  return false;
+#endif
+}
+
+static bool
+dump_mmap_contiguous_vm (struct dump_memory_map *maps, int nr_maps,
+                        size_t total_size)
+{
+  bool ret = false;
+  void *resv = NULL;
+  bool retry = false;
+  const bool need_retry = needs_mmap_retry_p ();
+
+  do
+    {
+      if (retry)
+        {
+          eassert (need_retry);
+          retry = false;
+          for (int i = 0; i < nr_maps; ++i)
+            dump_mmap_release (&maps[i]);
+        }
+
+      eassert (resv == NULL);
+      resv = dump_anonymous_allocate (NULL,
+                                      total_size,
+                                      DUMP_MEMORY_ACCESS_NONE);
+      if (!resv)
+        goto out;
+
+      char *mem = resv;
+
+      if (need_retry)
+        {
+          /* Windows lacks atomic mapping replace; need to release the
+             reservation so we can allocate within it.  Will retry the
+             loop if someone squats on our address space before we can
+             finish allocation.  On POSIX systems, we leave the
+             reservation around for atomicity.  */
+          dump_anonymous_release (resv, total_size);
+          resv = NULL;
+        }
+
+      for (int i = 0; i < nr_maps; ++i)
+        {
+          struct dump_memory_map *map = &maps[i];
+          const struct dump_memory_map_spec spec = map->spec;
+          if (!spec.size)
+            continue;
+
+          if (spec.fd < 0)
+           map->mapping = dump_anonymous_allocate (mem, spec.size,
+                                                   spec.protection);
+          else
+           map->mapping = dump_map_file (mem, spec.fd, spec.offset,
+                                         spec.size, spec.protection);
+          mem += spec.size;
+         if (need_retry && map->mapping == NULL
+             && (errno == EBUSY
+#ifdef CYGWIN
+                 || errno == EINVAL
+#endif
+                 ))
+            {
+              retry = true;
+              continue;
+            }
+          if (map->mapping == NULL)
+            goto out;
+          map->release = dump_mmap_release_vm;
+        }
+    }
+  while (retry);
+
+  ret = true;
+  resv = NULL;
+ out:
+  if (resv)
+    dump_anonymous_release (resv, total_size);
+  if (!ret)
+    {
+      for (int i = 0; i < nr_maps; ++i)
+       {
+         if (need_retry)
+           dump_mmap_reset (&maps[i]);
+         else
+           dump_mmap_release (&maps[i]);
+       }
+    }
+  return ret;
+}
+
+/* Map a range of addresses into a chunk of contiguous memory.
+
+   Each dump_memory_map structure describes how to fill the
+   corresponding range of memory. On input, all members except MAPPING
+   are valid. On output, MAPPING contains the location of the given
+   chunk of memory. The MAPPING for MAPS[N] is MAPS[N-1].mapping +
+   MAPS[N-1].size.
+
+   Each mapping SIZE must be a multiple of the system page size except
+   for the last mapping.
+
+   Return true on success or false on failure with errno set.  */
+static bool
+dump_mmap_contiguous (struct dump_memory_map *maps, int nr_maps)
+{
+  if (!nr_maps)
+    return true;
+
+  size_t total_size = 0;
+  int worst_case_page_size = dump_get_page_size ();
+
+  for (int i = 0; i < nr_maps; ++i)
+    {
+      eassert (maps[i].mapping == NULL);
+      eassert (maps[i].release == NULL);
+      eassert (maps[i].private == NULL);
+      if (i != nr_maps - 1)
+        eassert (maps[i].spec.size % worst_case_page_size == 0);
+      total_size += maps[i].spec.size;
+    }
+
+  return (VM_SUPPORTED ? dump_mmap_contiguous_vm : dump_mmap_contiguous_heap)
+    (maps, nr_maps, total_size);
+}
+
+typedef uint_fast32_t dump_bitset_word;
+
+struct dump_bitset
+{
+  dump_bitset_word *restrict bits;
+  ptrdiff_t number_words;
+};
+
+static bool
+dump_bitset_init (struct dump_bitset *bitset, size_t number_bits)
+{
+  int xword_size = sizeof (bitset->bits[0]);
+  int bits_per_word = xword_size * CHAR_BIT;
+  ptrdiff_t words_needed = DIVIDE_ROUND_UP (number_bits, bits_per_word);
+  bitset->number_words = words_needed;
+  bitset->bits = calloc (words_needed, xword_size);
+  return bitset->bits != NULL;
+}
+
+static dump_bitset_word *
+dump_bitset__bit_slot (const struct dump_bitset *bitset,
+                       size_t bit_number)
+{
+  int xword_size = sizeof (bitset->bits[0]);
+  int bits_per_word = xword_size * CHAR_BIT;
+  ptrdiff_t word_number = bit_number / bits_per_word;
+  eassert (word_number < bitset->number_words);
+  return &bitset->bits[word_number];
+}
+
+static bool
+dump_bitset_bit_set_p (const struct dump_bitset *bitset,
+                       size_t bit_number)
+{
+  unsigned xword_size = sizeof (bitset->bits[0]);
+  unsigned bits_per_word = xword_size * CHAR_BIT;
+  dump_bitset_word bit = 1;
+  bit <<= bit_number % bits_per_word;
+  return *dump_bitset__bit_slot (bitset, bit_number) & bit;
+}
+
+static void
+dump_bitset__set_bit_value (struct dump_bitset *bitset,
+                            size_t bit_number,
+                            bool bit_is_set)
+{
+  int xword_size = sizeof (bitset->bits[0]);
+  int bits_per_word = xword_size * CHAR_BIT;
+  dump_bitset_word *slot = dump_bitset__bit_slot (bitset, bit_number);
+  dump_bitset_word bit = 1;
+  bit <<= bit_number % bits_per_word;
+  if (bit_is_set)
+    *slot = *slot | bit;
+  else
+    *slot = *slot & ~bit;
+}
+
+static void
+dump_bitset_set_bit (struct dump_bitset *bitset, size_t bit_number)
+{
+  dump_bitset__set_bit_value (bitset, bit_number, true);
+}
+
+static void
+dump_bitset_clear (struct dump_bitset *bitset)
+{
+  int xword_size = sizeof (bitset->bits[0]);
+  if (bitset->number_words)
+    memset (bitset->bits, 0, bitset->number_words * xword_size);
+}
+
+struct pdumper_loaded_dump_private
+{
+  /* Copy of the header we read from the dump.  */
+  struct dump_header header;
+  /* Mark bits for objects in the dump; used during GC.  */
+  struct dump_bitset mark_bits;
+  /* Time taken to load the dump.  */
+  double load_time;
+  /* Dump file name.  */
+  char *dump_filename;
+};
+
+struct pdumper_loaded_dump dump_public;
+static struct pdumper_loaded_dump_private dump_private;
+
+/* Return a pointer to offset OFFSET within the dump, which begins at
+   DUMP_BASE. DUMP_BASE must be equal to the current dump load
+   location; it's passed as a parameter for efficiency.
+
+   The returned pointer points to the primary memory image of the
+   currently-loaded dump file.  The entire dump file is accessible
+   using this function.  */
+static void *
+dump_ptr (uintptr_t dump_base, dump_off offset)
+{
+  eassert (dump_base == dump_public.start);
+  eassert (0 <= offset);
+  eassert (dump_public.start + offset < dump_public.end);
+  return (char *)dump_base + offset;
+}
+
+/* Read a pointer-sized word of memory at OFFSET within the dump,
+   which begins at DUMP_BASE. DUMP_BASE must be equal to the current
+   dump load location; it's passed as a parameter for efficiency.  */
+static uintptr_t
+dump_read_word_from_dump (uintptr_t dump_base, dump_off offset)
+{
+  uintptr_t value;
+  /* The compiler optimizes this memcpy into a read.  */
+  memcpy (&value, dump_ptr (dump_base, offset), sizeof (value));
+  return value;
+}
+
+/* Write a word to the dump. DUMP_BASE and OFFSET are as for
+   dump_read_word_from_dump; VALUE is the word to write at the given
+   offset.  */
+static void
+dump_write_word_to_dump (uintptr_t dump_base,
+                         dump_off offset,
+                         uintptr_t value)
+{
+  /* The compiler optimizes this memcpy into a write.  */
+  memcpy (dump_ptr (dump_base, offset), &value, sizeof (value));
+}
+
+/* Write a Lisp_Object to the dump. DUMP_BASE and OFFSET are as for
+   dump_read_word_from_dump; VALUE is the Lisp_Object to write at the
+   given offset.  */
+static void
+dump_write_lv_to_dump (uintptr_t dump_base,
+                       dump_off offset,
+                       Lisp_Object value)
+{
+  /* The compiler optimizes this memcpy into a write.  */
+  memcpy (dump_ptr (dump_base, offset), &value, sizeof (value));
+}
+
+/* Search for a relocation given a relocation target.
+
+   DUMP is the dump metadata structure.  TABLE is the relocation table
+   to search.  KEY is the dump offset to find.  Return the relocation
+   RELOC such that RELOC.offset is the smallest RELOC.offset that
+   satisfies the constraint KEY <= RELOC.offset --- that is, return
+   the first relocation at KEY or after KEY.  Return NULL if no such
+   relocation exists.  */
+static const struct dump_reloc *
+dump_find_relocation (const struct dump_table_locator *const table,
+                      const dump_off key)
+{
+  const struct dump_reloc *const relocs = dump_ptr (dump_public.start,
+                                                   table->offset);
+  const struct dump_reloc *found = NULL;
+  ptrdiff_t idx_left = 0;
+  ptrdiff_t idx_right = table->nr_entries;
+
+  eassert (key >= 0);
+
+  while (idx_left < idx_right)
+    {
+      const ptrdiff_t idx_mid = idx_left + (idx_right - idx_left) / 2;
+      const struct dump_reloc *mid = &relocs[idx_mid];
+      if (key > dump_reloc_get_offset (*mid))
+        idx_left = idx_mid + 1;
+      else
+        {
+          found = mid;
+          idx_right = idx_mid;
+         if (idx_right <= idx_left
+             || key > dump_reloc_get_offset (relocs[idx_right - 1]))
+            break;
+        }
+   }
+
+  return found;
+}
+
+static bool
+dump_loaded_p (void)
+{
+  return dump_public.start != 0;
+}
+
+bool
+pdumper_cold_object_p_impl (const void *obj)
+{
+  eassert (pdumper_object_p (obj));
+  eassert (pdumper_object_p_precise (obj));
+  dump_off offset = ptrdiff_t_to_dump_off ((uintptr_t) obj - 
dump_public.start);
+  return offset >= dump_private.header.cold_start;
+}
+
+enum Lisp_Type
+pdumper_find_object_type_impl (const void *obj)
+{
+  eassert (pdumper_object_p (obj));
+  dump_off offset = ptrdiff_t_to_dump_off ((uintptr_t) obj - 
dump_public.start);
+  if (offset % DUMP_ALIGNMENT != 0)
+    return PDUMPER_NO_OBJECT;
+  const struct dump_reloc *reloc =
+    dump_find_relocation (&dump_private.header.object_starts, offset);
+  return (reloc != NULL && dump_reloc_get_offset (*reloc) == offset)
+    ? (enum Lisp_Type) reloc->type
+    : PDUMPER_NO_OBJECT;
+}
+
+bool
+pdumper_marked_p_impl (const void *obj)
+{
+  eassert (pdumper_object_p (obj));
+  ptrdiff_t offset = (uintptr_t) obj - dump_public.start;
+  eassert (offset % DUMP_ALIGNMENT == 0);
+  eassert (offset < dump_private.header.cold_start);
+  eassert (offset < dump_private.header.discardable_start);
+  ptrdiff_t bitno = offset / DUMP_ALIGNMENT;
+  return dump_bitset_bit_set_p (&dump_private.mark_bits, bitno);
+}
+
+void
+pdumper_set_marked_impl (const void *obj)
+{
+  eassert (pdumper_object_p (obj));
+  ptrdiff_t offset = (uintptr_t) obj - dump_public.start;
+  eassert (offset % DUMP_ALIGNMENT == 0);
+  eassert (offset < dump_private.header.cold_start);
+  eassert (offset < dump_private.header.discardable_start);
+  ptrdiff_t bitno = offset / DUMP_ALIGNMENT;
+  dump_bitset_set_bit (&dump_private.mark_bits, bitno);
+}
+
+void
+pdumper_clear_marks_impl (void)
+{
+  dump_bitset_clear (&dump_private.mark_bits);
+}
+
+static ssize_t
+dump_read_all (int fd, void *buf, size_t bytes_to_read)
+{
+  /* We don't want to use emacs_read, since that relies on the lisp
+     world, and we're not in the lisp world yet.  */
+  eassert (bytes_to_read <= SSIZE_MAX);
+  size_t bytes_read = 0;
+  while (bytes_read < bytes_to_read)
+    {
+      /* Some platforms accept only int-sized values to read.  */
+      unsigned chunk_to_read = INT_MAX;
+      if (bytes_to_read - bytes_read < chunk_to_read)
+       chunk_to_read = (unsigned) (bytes_to_read - bytes_read);
+      ssize_t chunk = read (fd, (char *) buf + bytes_read, chunk_to_read);
+      if (chunk < 0)
+        return chunk;
+      if (chunk == 0)
+        break;
+      bytes_read += chunk;
+    }
+
+  return bytes_read;
+}
+
+/* Return the number of bytes written when we perform the given
+   relocation.  */
+static int
+dump_reloc_size (const struct dump_reloc reloc)
+{
+  if (sizeof (Lisp_Object) == sizeof (void *))
+    return sizeof (Lisp_Object);
+  if (reloc.type == RELOC_DUMP_TO_EMACS_PTR_RAW
+      || reloc.type == RELOC_DUMP_TO_DUMP_PTR_RAW)
+    return sizeof (void *);
+  return sizeof (Lisp_Object);
+}
+
+static Lisp_Object
+dump_make_lv_from_reloc (const uintptr_t dump_base,
+                        const struct dump_reloc reloc)
+{
+  const dump_off reloc_offset = dump_reloc_get_offset (reloc);
+  uintptr_t value = dump_read_word_from_dump (dump_base, reloc_offset);
+  enum Lisp_Type lisp_type;
+
+  if (RELOC_DUMP_TO_DUMP_LV <= reloc.type
+      && reloc.type < RELOC_DUMP_TO_EMACS_LV)
+    {
+      lisp_type = reloc.type - RELOC_DUMP_TO_DUMP_LV;
+      value += dump_base;
+      eassert (pdumper_object_p ((void *) value));
+    }
+  else
+    {
+      eassert (RELOC_DUMP_TO_EMACS_LV <= reloc.type);
+      eassert (reloc.type < RELOC_DUMP_TO_EMACS_LV + 8);
+      lisp_type = reloc.type - RELOC_DUMP_TO_EMACS_LV;
+      value += emacs_basis ();
+    }
+
+  eassert (lisp_type != Lisp_Int0 && lisp_type != Lisp_Int1);
+
+  Lisp_Object lv;
+  if (lisp_type == Lisp_Symbol)
+    lv = make_lisp_symbol ((void *) value);
+  else
+    lv = make_lisp_ptr ((void *) value, lisp_type);
+
+  return lv;
+}
+
+/* Actually apply a dump relocation.  */
+static inline void
+dump_do_dump_relocation (const uintptr_t dump_base,
+                        const struct dump_reloc reloc)
+{
+  const dump_off reloc_offset = dump_reloc_get_offset (reloc);
+
+  /* We should never generate a relocation in the cold section.  */
+  eassert (reloc_offset < dump_private.header.cold_start);
+
+  switch (reloc.type)
+    {
+    case RELOC_DUMP_TO_EMACS_PTR_RAW:
+      {
+        uintptr_t value = dump_read_word_from_dump (dump_base, reloc_offset);
+        eassert (dump_reloc_size (reloc) == sizeof (value));
+        value += emacs_basis ();
+        dump_write_word_to_dump (dump_base, reloc_offset, value);
+        break;
+      }
+    case RELOC_DUMP_TO_DUMP_PTR_RAW:
+      {
+        uintptr_t value = dump_read_word_from_dump (dump_base, reloc_offset);
+        eassert (dump_reloc_size (reloc) == sizeof (value));
+        value += dump_base;
+        dump_write_word_to_dump (dump_base, reloc_offset, value);
+        break;
+      }
+    case RELOC_BIGNUM:
+      {
+        struct Lisp_Bignum *bignum = dump_ptr (dump_base, reloc_offset);
+        struct bignum_reload_info reload_info;
+        verify (sizeof (reload_info) <= sizeof (bignum->value));
+        memcpy (&reload_info, &bignum->value, sizeof (reload_info));
+        const mp_limb_t *limbs =
+          dump_ptr (dump_base, reload_info.data_location);
+        mpz_roinit_n (bignum->value, limbs, reload_info.nlimbs);
+        break;
+      }
+    default: /* Lisp_Object in the dump; precise type in reloc.type */
+      {
+        Lisp_Object lv = dump_make_lv_from_reloc (dump_base, reloc);
+        eassert (dump_reloc_size (reloc) == sizeof (lv));
+        dump_write_lv_to_dump (dump_base, reloc_offset, lv);
+        break;
+      }
+    }
+}
+
+static void
+dump_do_all_dump_relocations (const struct dump_header *const header,
+                             const uintptr_t dump_base)
+{
+  struct dump_reloc *r = dump_ptr (dump_base, header->dump_relocs.offset);
+  dump_off nr_entries = header->dump_relocs.nr_entries;
+  for (dump_off i = 0; i < nr_entries; ++i)
+    dump_do_dump_relocation (dump_base, r[i]);
+}
+
+static void
+dump_do_emacs_relocation (const uintptr_t dump_base,
+                         const struct emacs_reloc reloc)
+{
+  ptrdiff_t pval;
+  Lisp_Object lv;
+
+  switch (reloc.type)
+    {
+    case RELOC_EMACS_COPY_FROM_DUMP:
+      eassume (reloc.length > 0);
+      memcpy (emacs_ptr_at (reloc.emacs_offset),
+              dump_ptr (dump_base, reloc.u.dump_offset),
+              reloc.length);
+      break;
+    case RELOC_EMACS_IMMEDIATE:
+      eassume (reloc.length > 0);
+      eassume (reloc.length <= sizeof (reloc.u.immediate));
+      memcpy (emacs_ptr_at (reloc.emacs_offset),
+              &reloc.u.immediate,
+              reloc.length);
+      break;
+    case RELOC_EMACS_DUMP_PTR_RAW:
+      pval = reloc.u.dump_offset + dump_base;
+      memcpy (emacs_ptr_at (reloc.emacs_offset), &pval, sizeof (pval));
+      break;
+    case RELOC_EMACS_EMACS_PTR_RAW:
+      pval = reloc.u.emacs_offset2 + emacs_basis ();
+      memcpy (emacs_ptr_at (reloc.emacs_offset), &pval, sizeof (pval));
+      break;
+    case RELOC_EMACS_DUMP_LV:
+    case RELOC_EMACS_EMACS_LV:
+      {
+        /* Lisp_Float is the maximum lisp type.  */
+        eassume (reloc.length <= Lisp_Float);
+        void *obj_ptr = reloc.type == RELOC_EMACS_DUMP_LV
+          ? dump_ptr (dump_base, reloc.u.dump_offset)
+          : emacs_ptr_at (reloc.u.emacs_offset2);
+        if (reloc.length == Lisp_Symbol)
+          lv = make_lisp_symbol (obj_ptr);
+        else
+          lv = make_lisp_ptr (obj_ptr, reloc.length);
+        memcpy (emacs_ptr_at (reloc.emacs_offset), &lv, sizeof (lv));
+        break;
+      }
+    default:
+      fatal ("unrecognied relocation type %d", (int) reloc.type);
+    }
+}
+
+static void
+dump_do_all_emacs_relocations (const struct dump_header *const header,
+                              const uintptr_t dump_base)
+{
+  const dump_off nr_entries = header->emacs_relocs.nr_entries;
+  struct emacs_reloc *r = dump_ptr (dump_base, header->emacs_relocs.offset);
+  for (dump_off i = 0; i < nr_entries; ++i)
+    dump_do_emacs_relocation (dump_base, r[i]);
+}
+
+enum dump_section
+  {
+   DS_HOT,
+   DS_DISCARDABLE,
+   DS_COLD,
+   NUMBER_DUMP_SECTIONS,
+  };
+
+/* Load a dump from DUMP_FILENAME.  Return an error code.
+
+   N.B. We run very early in initialization, so we can't use lisp,
+   unwinding, xmalloc, and so on.  */
+enum pdumper_load_result
+pdumper_load (const char *dump_filename)
+{
+  intptr_t dump_size;
+  struct stat stat;
+  uintptr_t dump_base;
+  int dump_page_size;
+  dump_off adj_discardable_start;
+
+  struct dump_bitset mark_bits;
+  size_t mark_bits_needed;
+
+  struct dump_header header_buf = { 0 };
+  struct dump_header *header = &header_buf;
+  struct dump_memory_map sections[NUMBER_DUMP_SECTIONS] = { 0 };
+
+  const struct timespec start_time = current_timespec ();
+  char *dump_filename_copy;
+
+  /* Overwriting an initialized Lisp universe will not go well.  */
+  eassert (!initialized);
+
+  /* We can load only one dump.  */
+  eassert (!dump_loaded_p ());
+
+  enum pdumper_load_result err = PDUMPER_LOAD_FILE_NOT_FOUND;
+  int dump_fd = emacs_open (dump_filename, O_RDONLY, 0);
+  if (dump_fd < 0)
+    goto out;
+
+  err = PDUMPER_LOAD_FILE_NOT_FOUND;
+  if (fstat (dump_fd, &stat) < 0)
+    goto out;
+
+  err = PDUMPER_LOAD_BAD_FILE_TYPE;
+  if (stat.st_size > INTPTR_MAX)
+    goto out;
+  dump_size = (intptr_t) stat.st_size;
+
+  err = PDUMPER_LOAD_BAD_FILE_TYPE;
+  if (dump_size < sizeof (*header))
+    goto out;
+
+  err = PDUMPER_LOAD_BAD_FILE_TYPE;
+  if (dump_read_all (dump_fd,
+                     header,
+                     sizeof (*header)) < sizeof (*header))
+    goto out;
+
+  if (memcmp (header->magic, dump_magic, sizeof (dump_magic)) != 0)
+    {
+      if (header->magic[0] == '!'
+         && (header->magic[0] = dump_magic[0],
+             memcmp (header->magic, dump_magic, sizeof (dump_magic)) == 0))
+        {
+          err = PDUMPER_LOAD_FAILED_DUMP;
+          goto out;
+        }
+      err = PDUMPER_LOAD_BAD_FILE_TYPE;
+      goto out;
+    }
+
+  err = PDUMPER_LOAD_VERSION_MISMATCH;
+  verify (sizeof (header->fingerprint) == sizeof (fingerprint));
+  if (memcmp (header->fingerprint, fingerprint, sizeof (fingerprint)) != 0)
+    {
+      dump_fingerprint ("desired fingerprint", fingerprint);
+      dump_fingerprint ("found fingerprint", header->fingerprint);
+      goto out;
+    }
+
+  /* FIXME: The comment at the start of this function says it should
+     not use xmalloc, but xstrdup calls xmalloc.  Either fix the
+     comment or fix the following code.  */
+  dump_filename_copy = xstrdup (dump_filename);
+
+  err = PDUMPER_LOAD_OOM;
+
+  adj_discardable_start = header->discardable_start;
+  dump_page_size = dump_get_page_size ();
+  /* Snap to next page boundary.  */
+  adj_discardable_start = ROUNDUP (adj_discardable_start, dump_page_size);
+  eassert (adj_discardable_start % dump_page_size == 0);
+  eassert (adj_discardable_start <= header->cold_start);
+
+  sections[DS_HOT].spec = (struct dump_memory_map_spec)
+    {
+     .fd = dump_fd,
+     .size = adj_discardable_start,
+     .offset = 0,
+     .protection = DUMP_MEMORY_ACCESS_READWRITE,
+    };
+
+  sections[DS_DISCARDABLE].spec = (struct dump_memory_map_spec)
+    {
+     .fd = dump_fd,
+     .size = header->cold_start - adj_discardable_start,
+     .offset = adj_discardable_start,
+     .protection = DUMP_MEMORY_ACCESS_READWRITE,
+    };
+
+  sections[DS_COLD].spec = (struct dump_memory_map_spec)
+    {
+     .fd = dump_fd,
+     .size = dump_size - header->cold_start,
+     .offset = header->cold_start,
+     .protection = DUMP_MEMORY_ACCESS_READWRITE,
+    };
+
+  if (!dump_mmap_contiguous (sections, ARRAYELTS (sections)))
+    goto out;
+
+  err = PDUMPER_LOAD_ERROR;
+  mark_bits_needed =
+    DIVIDE_ROUND_UP (header->discardable_start, DUMP_ALIGNMENT);
+  if (!dump_bitset_init (&mark_bits, mark_bits_needed))
+    goto out;
+
+  /* Point of no return.  */
+  err = PDUMPER_LOAD_SUCCESS;
+  dump_base = (uintptr_t) sections[DS_HOT].mapping;
+  gflags.dumped_with_pdumper_ = true;
+  dump_private.header = *header;
+  dump_private.mark_bits = mark_bits;
+  dump_public.start = dump_base;
+  dump_public.end = dump_public.start + dump_size;
+
+  dump_do_all_dump_relocations (header, dump_base);
+  dump_do_all_emacs_relocations (header, dump_base);
+
+  dump_mmap_discard_contents (&sections[DS_DISCARDABLE]);
+  for (int i = 0; i < ARRAYELTS (sections); ++i)
+    dump_mmap_reset (&sections[i]);
+
+  /* Run the functions Emacs registered for doing post-dump-load
+     initialization.  */
+  for (int i = 0; i < nr_dump_hooks; ++i)
+    dump_hooks[i] ();
+  initialized = true;
+
+  struct timespec load_timespec =
+    timespec_sub (current_timespec (), start_time);
+  dump_private.load_time = timespectod (load_timespec);
+  dump_private.dump_filename = dump_filename_copy;
+
+ out:
+  for (int i = 0; i < ARRAYELTS (sections); ++i)
+    dump_mmap_release (&sections[i]);
+  if (dump_fd >= 0)
+    emacs_close (dump_fd);
+  return err;
+}
+
+/* Prepend the Emacs startup directory to dump_filename, if that is
+   relative, so that we could later make it absolute correctly.  */
+void
+pdumper_record_wd (const char *wd)
+{
+  if (wd && !file_name_absolute_p (dump_private.dump_filename))
+    {
+      char *dfn = xmalloc (strlen (wd) + 1
+                          + strlen (dump_private.dump_filename) + 1);
+      splice_dir_file (dfn, wd, dump_private.dump_filename);
+      xfree (dump_private.dump_filename);
+      dump_private.dump_filename = dfn;
+    }
+}
+
+DEFUN ("pdumper-stats", Fpdumper_stats, Spdumper_stats, 0, 0, 0,
+       doc: /* Return statistics about portable dumping used by this session.
+If this Emacs sesion was started from a portable dump file,
+the return value is an alist of the form:
+
+  ((dumped-with-pdumper . t) (load-time . TIME) (dump-file-name . FILE))
+
+where TIME is the time in seconds it took to restore Emacs state
+from the dump file, and FILE is the name of the dump file.
+Value is nil if this session was not started using a portable dump file.*/)
+     (void)
+{
+  if (!dumped_with_pdumper_p ())
+    return Qnil;
+
+  Lisp_Object dump_fn;
+#ifdef WINDOWSNT
+  char dump_fn_utf8[MAX_UTF8_PATH];
+  if (filename_from_ansi (dump_private.dump_filename, dump_fn_utf8) == 0)
+    dump_fn = DECODE_FILE (build_unibyte_string (dump_fn_utf8));
+  else
+    dump_fn = build_unibyte_string (dump_private.dump_filename);
+#else
+  dump_fn = DECODE_FILE (build_unibyte_string (dump_private.dump_filename));
+#endif
+
+  dump_fn = Fexpand_file_name (dump_fn, Qnil);
+
+  return list3 (Fcons (Qdumped_with_pdumper, Qt),
+               Fcons (Qload_time, make_float (dump_private.load_time)),
+               Fcons (Qdump_file_name, dump_fn));
+}
+
+#endif /* HAVE_PDUMPER */
+
+
+
+void
+syms_of_pdumper (void)
+{
+#ifdef HAVE_PDUMPER
+  defsubr (&Sdump_emacs_portable);
+  defsubr (&Sdump_emacs_portable__sort_predicate);
+  defsubr (&Sdump_emacs_portable__sort_predicate_copied);
+  DEFSYM (Qdump_emacs_portable__sort_predicate,
+          "dump-emacs-portable--sort-predicate");
+  DEFSYM (Qdump_emacs_portable__sort_predicate_copied,
+          "dump-emacs-portable--sort-predicate-copied");
+  DEFSYM (Qdumped_with_pdumper, "dumped-with-pdumper");
+  DEFSYM (Qload_time, "load-time");
+  DEFSYM (Qdump_file_name, "dump-file-name");
+  defsubr (&Spdumper_stats);
+#endif /* HAVE_PDUMPER */
+}
diff --git a/src/pdumper.h b/src/pdumper.h
new file mode 100644
index 0000000..ab2f426
--- /dev/null
+++ b/src/pdumper.h
@@ -0,0 +1,254 @@
+/* Header file for the portable dumper.
+
+Copyright (C) 2016, 2018-2019 Free Software Foundation, Inc.
+
+This file is part of GNU Emacs.
+
+GNU Emacs is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
+
+GNU Emacs is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef EMACS_PDUMPER_H
+#define EMACS_PDUMPER_H
+
+#include "lisp.h"
+
+INLINE_HEADER_BEGIN
+
+#define PDUMPER_NO_OBJECT ((enum Lisp_Type) -1)
+
+/* Indicate in source code that we're deliberately relying on pdumper
+   not preserving the given value.  Compiles to nothing --- for humans
+   only.  */
+#define PDUMPER_IGNORE(thing) ((void) &(thing))
+
+/* The portable dumper automatically preserves the Lisp heap and any C
+   variables to which the Lisp heap points.  It doesn't know anything
+   about other C variables.  The functions below allow code from other
+   parts of Emacs to tell the portable dumper about other bits of
+   information to preserve in dumped images.
+
+   These memory-records are themselves preserved in the dump, so call
+   the functions below only on the !initialized init path, just
+   like staticpro.
+
+   There are no special functions to preserve a global Lisp_Object.
+   You should just staticpro these.  */
+
+/* Remember the value of THING in dumped images.  THING must not
+   contain any pointers or Lisp_Object variables: these values are not
+   valid across dump and load.  */
+#define PDUMPER_REMEMBER_SCALAR(thing)                  \
+  pdumper_remember_scalar (&(thing), sizeof (thing))
+
+extern void pdumper_remember_scalar_impl (void *data, ptrdiff_t nbytes);
+
+INLINE void
+pdumper_remember_scalar (void *data, ptrdiff_t nbytes)
+{
+#ifdef HAVE_PDUMPER
+  pdumper_remember_scalar_impl (data, nbytes);
+#else
+  (void) data;
+  (void) nbytes;
+#endif
+}
+
+extern void pdumper_remember_lv_ptr_raw_impl (void *ptr, enum Lisp_Type type);
+
+/* Remember the pointer at *PTR.  *PTR must be null or point to a Lisp
+   object.  TYPE is the rough type of Lisp object to which *PTR
+   points.  */
+INLINE void
+pdumper_remember_lv_ptr_raw (void *ptr, enum Lisp_Type type)
+{
+#ifdef HAVE_PDUMPER
+  pdumper_remember_lv_ptr_raw_impl (ptr, type);
+#else
+  (void) ptr;
+  (void) type;
+#endif
+}
+
+typedef void (*pdumper_hook)(void);
+extern void pdumper_do_now_and_after_load_impl (pdumper_hook hook);
+
+INLINE void
+pdumper_do_now_and_after_load (pdumper_hook hook)
+{
+#ifdef HAVE_PDUMPER
+  pdumper_do_now_and_after_load_impl (hook);
+#else
+  hook ();
+#endif
+}
+
+/* Macros useful in pdumper callback functions.  Assign a value if
+   we're loading a dump and the value needs to be reset to its
+   original value, and if we're initializing for the first time,
+   assert that the value has the expected original value.  */
+
+#define PDUMPER_RESET(variable, value)         \
+  do {                                         \
+    if (dumped_with_pdumper_p ())              \
+      (variable) = (value);                    \
+    else                                       \
+      eassert ((variable) == (value));         \
+  } while (0)
+
+#define PDUMPER_RESET_LV(variable, value)         \
+  do {                                            \
+    if (dumped_with_pdumper_p ())                 \
+      (variable) = (value);                       \
+    else                                          \
+      eassert (EQ ((variable), (value)));         \
+  } while (0)
+
+/* Actually load a dump.  */
+
+enum pdumper_load_result
+  {
+    PDUMPER_LOAD_SUCCESS,
+    PDUMPER_NOT_LOADED /* Not returned: useful for callers */,
+    PDUMPER_LOAD_FILE_NOT_FOUND,
+    PDUMPER_LOAD_BAD_FILE_TYPE,
+    PDUMPER_LOAD_FAILED_DUMP,
+    PDUMPER_LOAD_OOM,
+    PDUMPER_LOAD_VERSION_MISMATCH,
+    PDUMPER_LOAD_ERROR,
+  };
+
+enum pdumper_load_result pdumper_load (const char *dump_filename);
+
+struct pdumper_loaded_dump
+{
+  uintptr_t start;
+  uintptr_t end;
+};
+
+extern struct pdumper_loaded_dump dump_public;
+
+/* Return whether the OBJ points somewhere into the loaded dump image.
+   Works even when we have no dump loaded --- in this case, it just
+   returns false.  */
+INLINE _GL_ATTRIBUTE_CONST bool
+pdumper_object_p (const void *obj)
+{
+#ifdef HAVE_PDUMPER
+  uintptr_t obj_addr = (uintptr_t) obj;
+  return dump_public.start <= obj_addr && obj_addr < dump_public.end;
+#else
+  (void) obj;
+  return false;
+#endif
+}
+
+extern bool pdumper_cold_object_p_impl (const void *obj);
+
+/* Return whether the OBJ is in the cold section of the dump.
+   Only bool-vectors and floats should end up there.
+   pdumper_object_p() and pdumper_object_p_precise() must have
+   returned true for OBJ before calling this function.  */
+INLINE _GL_ATTRIBUTE_CONST bool
+pdumper_cold_object_p (const void *obj)
+{
+#ifdef HAVE_PDUMPER
+  return pdumper_cold_object_p_impl (obj);
+#else
+  (void) obj;
+  return false;
+#endif
+}
+
+
+extern enum Lisp_Type pdumper_find_object_type_impl (const void *obj);
+
+/* Return the type of the dumped object that starts at OBJ.  It is a
+   programming error to call this routine for an OBJ for which
+   pdumper_object_p would return false.  */
+INLINE _GL_ATTRIBUTE_CONST enum Lisp_Type
+pdumper_find_object_type (const void *obj)
+{
+#ifdef HAVE_PDUMPER
+  return pdumper_find_object_type_impl (obj);
+#else
+  (void) obj;
+  emacs_abort ();
+#endif
+}
+
+/* Return whether OBJ points exactly to the start of some object in
+   the loaded dump image.  It is a programming error to call this
+   routine for an OBJ for which pdumper_object_p would return
+   false.  */
+INLINE _GL_ATTRIBUTE_CONST bool
+pdumper_object_p_precise (const void *obj)
+{
+#ifdef HAVE_PDUMPER
+  return pdumper_find_object_type (obj) != PDUMPER_NO_OBJECT;
+#else
+  (void) obj;
+  emacs_abort ();
+#endif
+}
+
+extern bool pdumper_marked_p_impl (const void *obj);
+
+/* Return whether OBJ is marked according to the portable dumper.
+   It is an error to call this routine for an OBJ for which
+   pdumper_object_p_precise would return false.  */
+INLINE bool
+pdumper_marked_p (const void *obj)
+{
+#ifdef HAVE_PDUMPER
+  return pdumper_marked_p_impl (obj);
+#else
+  (void) obj;
+  emacs_abort ();
+#endif
+}
+
+extern void pdumper_set_marked_impl (const void *obj);
+
+/* Set the pdumper mark bit for OBJ.  It is a programming error to
+   call this function with an OBJ for which pdumper_object_p_precise
+   would return false.  */
+INLINE void
+pdumper_set_marked (const void *obj)
+{
+#ifdef HAVE_PDUMPER
+  pdumper_set_marked_impl (obj);
+#else
+  (void) obj;
+  emacs_abort ();
+#endif
+}
+
+extern void pdumper_clear_marks_impl (void);
+
+/* Clear all the mark bits for pdumper objects.  */
+INLINE void
+pdumper_clear_marks (void)
+{
+#ifdef HAVE_PDUMPER
+  pdumper_clear_marks_impl ();
+#endif
+}
+
+/* Record the Emacs startup directory, relative to which the pdump
+   file was loaded.  */
+extern void pdumper_record_wd (const char *);
+
+void syms_of_pdumper (void);
+
+INLINE_HEADER_END
+#endif
diff --git a/src/print.c b/src/print.c
index d15ff97..68ed678 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1,6 +1,6 @@
 /* Lisp object printing and output streams.
 
-Copyright (C) 1985-1986, 1988, 1993-1995, 1997-2018 Free Software
+Copyright (C) 1985-1986, 1988, 1993-1995, 1997-2019 Free Software
 Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -1410,7 +1410,6 @@ print_vectorlike (Lisp_Object obj, Lisp_Object 
printcharfun, bool escapeflag,
       printchar ('>', printcharfun);
       break;
 
-#ifdef HAVE_MODULES
     case PVEC_USER_PTR:
       {
        print_c_string ("#<user-ptr ", printcharfun);
@@ -1421,7 +1420,6 @@ print_vectorlike (Lisp_Object obj, Lisp_Object 
printcharfun, bool escapeflag,
        printchar ('>', printcharfun);
       }
       break;
-#endif
 
     case PVEC_FINALIZER:
       print_c_string ("#<finalizer", printcharfun);
@@ -1789,8 +1787,8 @@ print_vectorlike (Lisp_Object obj, Lisp_Object 
printcharfun, bool escapeflag,
     case PVEC_MODULE_FUNCTION:
       {
        print_c_string ("#<module function ", printcharfun);
-       void *ptr = XMODULE_FUNCTION (obj)->subr;
-       const char *file = NULL;
+        module_funcptr ptr = module_function_address (XMODULE_FUNCTION (obj));
+        const char *file = NULL;
        const char *symbol = NULL;
        dynlib_addr (ptr, &file, &symbol);
 
diff --git a/src/process.c b/src/process.c
index 8e0b234..6717ccb 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1,6 +1,6 @@
 /* Asynchronous subprocess control for GNU Emacs.
 
-Copyright (C) 1985-1988, 1993-1996, 1998-1999, 2001-2018 Free Software
+Copyright (C) 1985-1988, 1993-1996, 1998-1999, 2001-2019 Free Software
 Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -858,7 +858,8 @@ allocate_pty (char pty_name[PTY_NAME_SIZE])
 static struct Lisp_Process *
 allocate_process (void)
 {
-  return ALLOCATE_ZEROED_PSEUDOVECTOR (struct Lisp_Process, pid, PVEC_PROCESS);
+  return ALLOCATE_ZEROED_PSEUDOVECTOR (struct Lisp_Process, thread,
+                                      PVEC_PROCESS);
 }
 
 static Lisp_Object
@@ -1360,7 +1361,7 @@ If THREAD is nil, the process is unlocked.  */)
 
 DEFUN ("process-thread", Fprocess_thread, Sprocess_thread,
        1, 1, 0,
-       doc: /* Ret the locking thread of PROCESS.
+       doc: /* Return the locking thread of PROCESS.
 If PROCESS is unlocked, this function returns nil.  */)
   (Lisp_Object process)
 {
@@ -1642,10 +1643,11 @@ ENCODING is used for writing.
 :noquery BOOL -- When exiting Emacs, query the user if BOOL is nil and
 the process is running.  If BOOL is not given, query before exiting.
 
-:stop BOOL -- Start process in the `stopped' state if BOOL non-nil.
-In the stopped state, a process does not accept incoming data, but you
-can send outgoing data.  The stopped state is cleared by
-`continue-process' and set by `stop-process'.
+:stop BOOL -- BOOL must be nil.  The `:stop' key is ignored otherwise
+and is retained for compatibility with other process types such as
+pipe processes.  Asynchronous subprocesses never start in the
+`stopped' state.  Use `stop-process' and `continue-process' to send
+signals to stop and continue a process.
 
 :connection-type TYPE -- TYPE is control type of device used to
 communicate with subprocesses.  Values are `pipe' to use a pipe, `pty'
@@ -1661,6 +1663,11 @@ to the standard error of subprocess.  Specifying this 
implies
 `:connection-type' is set to `pipe'.  If STDERR is nil, standard error
 is mixed with standard output and sent to BUFFER or FILTER.
 
+:file-handler FILE-HANDLER -- If FILE-HANDLER is non-nil, then look
+for a file name handler for the current buffer's `default-directory'
+and invoke that file name handler to make the process.  If there is no
+such handler, proceed as if FILE-HANDLER were nil.
+
 usage: (make-process &rest ARGS)  */)
   (ptrdiff_t nargs, Lisp_Object *args)
 {
@@ -1674,6 +1681,15 @@ usage: (make-process &rest ARGS)  */)
   /* Save arguments for process-contact and clone-process.  */
   contact = Flist (nargs, args);
 
+  if (!NILP (Fplist_get (contact, QCfile_handler)))
+    {
+      Lisp_Object file_handler
+        = Ffind_file_name_handler (BVAR (current_buffer, directory),
+                                   Qmake_process);
+      if (!NILP (file_handler))
+        return CALLN (Fapply, file_handler, Qmake_process, contact);
+    }
+
   buffer = Fplist_get (contact, QCbuffer);
   if (!NILP (buffer))
     buffer = Fget_buffer_create (buffer);
@@ -1731,8 +1747,10 @@ usage: (make-process &rest ARGS)  */)
 
   if (!query_on_exit)
     XPROCESS (proc)->kill_without_query = 1;
-  if (tem = Fplist_get (contact, QCstop), !NILP (tem))
-    pset_command (XPROCESS (proc), Qt);
+  tem = Fplist_get (contact, QCstop);
+  /* Normal processes can't be started in a stopped state, see
+     Bug#30460.  */
+  CHECK_TYPE (NILP (tem), Qnull, tem);
 
   tem = Fplist_get (contact, QCconnection_type);
   if (EQ (tem, Qpty))
@@ -1790,7 +1808,7 @@ usage: (make-process &rest ARGS)  */)
       val = Vcoding_system_for_read;
     if (NILP (val))
       {
-       ptrdiff_t nargs2 = 3 + XFIXNUM (Flength (command));
+       ptrdiff_t nargs2 = 3 + list_length (command);
        Lisp_Object tem2;
        SAFE_ALLOCA_LISP (args2, nargs2);
        ptrdiff_t i = 0;
@@ -1820,7 +1838,7 @@ usage: (make-process &rest ARGS)  */)
       {
        if (EQ (coding_systems, Qt))
          {
-           ptrdiff_t nargs2 = 3 + XFIXNUM (Flength (command));
+           ptrdiff_t nargs2 = 3 + list_length (command);
            Lisp_Object tem2;
            SAFE_ALLOCA_LISP (args2, nargs2);
            ptrdiff_t i = 0;
@@ -2218,7 +2236,7 @@ create_process (Lisp_Object process, char **new_argv, 
Lisp_Object current_dir)
   unblock_input ();
 
   if (pid < 0)
-    report_file_errno ("Doing vfork", Qnil, vfork_errno);
+    report_file_errno (CHILD_SETUP_ERROR_DESC, Qnil, vfork_errno);
   else
     {
       /* vfork succeeded.  */
@@ -3719,6 +3737,8 @@ also nil, meaning that this process is not associated 
with any buffer.
 address.  The symbol `local' specifies the local host.  If specified
 for a server process, it must be a valid name or address for the local
 host, and only clients connecting to that address will be accepted.
+`local' will use IPv4 by default, use a FAMILY of 'ipv6 to override
+this.
 
 :service SERVICE -- SERVICE is name of the service desired, or an
 integer specifying a port number to connect to.  If SERVICE is t,
@@ -3969,14 +3989,24 @@ usage: (make-network-process &rest ARGS)  */)
 #ifdef HAVE_LOCAL_SOCKETS
       if (family != AF_LOCAL)
 #endif
-       host = build_string ("127.0.0.1");
+        {
+        if (family == AF_INET6)
+          host = build_string ("::1");
+        else
+          host = build_string ("127.0.0.1");
+        }
     }
   else
     {
       if (EQ (host, Qlocal))
+        {
        /* Depending on setup, "localhost" may map to different IPv4 and/or
           IPv6 addresses, so it's better to be explicit (Bug#6781).  */
-       host = build_string ("127.0.0.1");
+        if (family == AF_INET6)
+          host = build_string ("::1");
+        else
+          host = build_string ("127.0.0.1");
+        }
       CHECK_STRING (host);
     }
 
@@ -4593,8 +4623,8 @@ DEFUN ("accept-process-output", Faccept_process_output, 
Saccept_process_output,
        0, 4, 0,
        doc: /* Allow any pending output from subprocesses to be read by Emacs.
 It is given to their filter functions.
-Optional argument PROCESS means do not return until output has been
-received from PROCESS.
+Optional argument PROCESS means to return only after output is
+received from PROCESS or PROCESS closes the connection.
 
 Optional second argument SECONDS and third argument MILLISEC
 specify a timeout; return after that much time even if there is
@@ -4606,7 +4636,8 @@ If optional fourth argument JUST-THIS-ONE is non-nil, 
accept output
 from PROCESS only, suspending reading output from other processes.
 If JUST-THIS-ONE is an integer, don't run any timers either.
 Return non-nil if we received any output from PROCESS (or, if PROCESS
-is nil, from any process) before the timeout expired.  */)
+is nil, from any process) before the timeout expired or the
+corresponding connection was closed.  */)
   (Lisp_Object process, Lisp_Object seconds, Lisp_Object millisec,
    Lisp_Object just_this_one)
 {
@@ -4726,19 +4757,24 @@ server_accept_connection (Lisp_Object server, int 
channel)
   service = Qnil;
   Lisp_Object args[11];
   int nargs = 0;
-  AUTO_STRING (procname_format_in, "%s <%d.%d.%d.%d:%d>");
-  AUTO_STRING (procname_format_in6, "%s <[%x:%x:%x:%x:%x:%x:%x:%x]:%d>");
+  #define HOST_FORMAT_IN "%d.%d.%d.%d"
+  #define HOST_FORMAT_IN6 "%x:%x:%x:%x:%x:%x:%x:%x"
+  AUTO_STRING (host_format_in, HOST_FORMAT_IN);
+  AUTO_STRING (host_format_in6, HOST_FORMAT_IN6);
+  AUTO_STRING (procname_format_in, "%s <"HOST_FORMAT_IN":%d>");
+  AUTO_STRING (procname_format_in6, "%s <["HOST_FORMAT_IN6"]:%d>");
   AUTO_STRING (procname_format_default, "%s <%d>");
   switch (saddr.sa.sa_family)
     {
     case AF_INET:
       {
        args[nargs++] = procname_format_in;
-       nargs++;
+       args[nargs++] = host_format_in;
        unsigned char *ip = (unsigned char *)&saddr.in.sin_addr.s_addr;
        service = make_fixnum (ntohs (saddr.in.sin_port));
        for (int i = 0; i < 4; i++)
          args[nargs++] = make_fixnum (ip[i]);
+       host = Fformat (5, args + 1);
        args[nargs++] = service;
       }
       break;
@@ -4747,11 +4783,12 @@ server_accept_connection (Lisp_Object server, int 
channel)
     case AF_INET6:
       {
        args[nargs++] = procname_format_in6;
-       nargs++;
+       args[nargs++] = host_format_in6;
        DECLARE_POINTER_ALIAS (ip6, uint16_t, &saddr.in6.sin6_addr);
        service = make_fixnum (ntohs (saddr.in.sin_port));
        for (int i = 0; i < 8; i++)
          args[nargs++] = make_fixnum (ip6[i]);
+       host = Fformat (9, args + 1);
        args[nargs++] = service;
       }
       break;
@@ -5825,7 +5862,8 @@ read_and_dispose_of_process_output (struct Lisp_Process 
*p, char *chars,
 
 /* Read pending output from the process channel,
    starting with our buffered-ahead character if we have one.
-   Yield number of decoded characters read.
+   Yield number of decoded characters read,
+   or -1 (setting errno) if there is a read error.
 
    This function reads at most 4096 characters.
    If you want to read all available subprocess output,
@@ -5855,8 +5893,10 @@ read_process_output (Lisp_Object proc, int channel)
   if (DATAGRAM_CHAN_P (channel))
     {
       socklen_t len = datagram_address[channel].len;
-      nbytes = recvfrom (channel, chars + carryover, readmax,
-                        0, datagram_address[channel].sa, &len);
+      do
+       nbytes = recvfrom (channel, chars + carryover, readmax,
+                          0, datagram_address[channel].sa, &len);
+      while (nbytes < 0 && errno == EINTR);
     }
   else
 #endif
@@ -5906,8 +5946,6 @@ read_process_output (Lisp_Object proc, int channel)
 
   p->decoding_carryover = 0;
 
-  /* At this point, NBYTES holds number of bytes just received
-     (including the one in proc_buffered_char[channel]).  */
   if (nbytes <= 0)
     {
       if (nbytes < 0 || coding->mode & CODING_MODE_LAST_BLOCK)
@@ -5915,6 +5953,9 @@ read_process_output (Lisp_Object proc, int channel)
       coding->mode |= CODING_MODE_LAST_BLOCK;
     }
 
+  /* At this point, NBYTES holds number of bytes just received
+     (including the one in proc_buffered_char[channel]).  */
+
   /* Ignore carryover, it's been added by a previous iteration already.  */
   p->nbytes_read += nbytes;
 
@@ -6357,9 +6398,17 @@ send_process (Lisp_Object proc, const char *buf, 
ptrdiff_t len,
 #ifdef DATAGRAM_SOCKETS
          if (DATAGRAM_CHAN_P (outfd))
            {
-             rv = sendto (outfd, cur_buf, cur_len,
-                          0, datagram_address[outfd].sa,
-                          datagram_address[outfd].len);
+             while (true)
+               {
+                 rv = sendto (outfd, cur_buf, cur_len, 0,
+                              datagram_address[outfd].sa,
+                              datagram_address[outfd].len);
+                 if (! (rv < 0 && errno == EINTR))
+                   break;
+                 if (pending_signals)
+                   process_pending_signals ();
+               }
+
              if (rv >= 0)
                written = rv;
              else if (errno == EMSGSIZE)
@@ -6449,9 +6498,11 @@ DEFUN ("process-send-region", Fprocess_send_region, 
Sprocess_send_region,
 PROCESS may be a process, a buffer, the name of a process or buffer, or
 nil, indicating the current buffer's process.
 Called from program, takes three arguments, PROCESS, START and END.
-If the region is more than 500 characters long,
-it is sent in several bunches.  This may happen even for shorter regions.
-Output from processes can arrive in between bunches.
+If the region is larger than the input buffer of the process (the
+length of which depends on the process connection type and the
+operating system), it is sent in several bunches.  This may happen
+even for shorter regions.  Output from processes can arrive in between
+bunches.
 
 If PROCESS is a non-blocking network process that hasn't been fully
 set up yet, this function will block until socket setup has completed.  */)
@@ -6482,9 +6533,10 @@ DEFUN ("process-send-string", Fprocess_send_string, 
Sprocess_send_string,
        doc: /* Send PROCESS the contents of STRING as input.
 PROCESS may be a process, a buffer, the name of a process or buffer, or
 nil, indicating the current buffer's process.
-If STRING is more than 500 characters long,
-it is sent in several bunches.  This may happen even for shorter strings.
-Output from processes can arrive in between bunches.
+If STRING is larger than the input buffer of the process (the length
+of which depends on the process connection type and the operating
+system), it is sent in several bunches.  This may happen even for
+shorter strings.  Output from processes can arrive in between bunches.
 
 If PROCESS is a non-blocking network process that hasn't been fully
 set up yet, this function will block until socket setup has completed.  */)
@@ -8010,9 +8062,7 @@ init_process_emacs (int sockfd)
 
   inhibit_sentinels = 0;
 
-#ifndef CANNOT_DUMP
-  if (! noninteractive || initialized)
-#endif
+  if (!will_dump_with_unexec_p ())
     {
 #if defined HAVE_GLIB && !defined WINDOWSNT
       /* Tickle glib's child-handling code.  Ask glib to wait for Emacs itself;
@@ -8098,6 +8148,8 @@ init_process_emacs (int sockfd)
 void
 syms_of_process (void)
 {
+  DEFSYM (Qmake_process, "make-process");
+
 #ifdef subprocesses
 
   DEFSYM (Qprocessp, "processp");
@@ -8138,6 +8190,7 @@ syms_of_process (void)
   DEFSYM (Qreal, "real");
   DEFSYM (Qnetwork, "network");
   DEFSYM (Qserial, "serial");
+  DEFSYM (QCfile_handler, ":file-handler");
   DEFSYM (QCbuffer, ":buffer");
   DEFSYM (QChost, ":host");
   DEFSYM (QCservice, ":service");
@@ -8250,6 +8303,8 @@ returns non-`nil'.  */);
          "internal-default-interrupt-process");
   DEFSYM (Qinterrupt_process_functions, "interrupt-process-functions");
 
+  DEFSYM (Qnull, "null");
+
   defsubr (&Sprocessp);
   defsubr (&Sget_process);
   defsubr (&Sdelete_process);
diff --git a/src/process.h b/src/process.h
index 67b7834..5e957c4 100644
--- a/src/process.h
+++ b/src/process.h
@@ -1,5 +1,5 @@
 /* Definitions for asynchronous process control in GNU Emacs.
-   Copyright (C) 1985, 1994, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1994, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -117,9 +117,7 @@ struct Lisp_Process
 
     /* The thread a process is linked to, or nil for any thread.  */
     Lisp_Object thread;
-
-    /* After this point, there are no Lisp_Objects any more.  */
-    /* alloc.c assumes that `pid' is the first such non-Lisp slot.  */
+    /* After this point, there are no Lisp_Objects.  */
 
     /* Process ID.  A positive value is a child process ID.
        Zero is for pseudo-processes such as network or serial connections,
diff --git a/src/profiler.c b/src/profiler.c
index 6d97107..87be30a 100644
--- a/src/profiler.c
+++ b/src/profiler.c
@@ -1,6 +1,6 @@
 /* Profiler implementation.
 
-Copyright (C) 2012-2018 Free Software Foundation, Inc.
+Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -21,6 +21,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "lisp.h"
 #include "syssignal.h"
 #include "systime.h"
+#include "pdumper.h"
 
 /* Return A + B, but return the maximum fixnum if the result would overflow.
    Assume A and B are nonnegative and in fixnum range.  */
@@ -35,15 +36,32 @@ saturated_add (EMACS_INT a, EMACS_INT b)
 
 typedef struct Lisp_Hash_Table log_t;
 
-static struct hash_table_test hashtest_profiler;
+static bool cmpfn_profiler (
+  struct hash_table_test *, Lisp_Object, Lisp_Object);
+
+static EMACS_UINT hashfn_profiler (
+  struct hash_table_test *, Lisp_Object);
+
+static const struct hash_table_test hashtest_profiler =
+  {
+   LISPSYM_INITIALLY (Qprofiler_backtrace_equal),
+   LISPSYM_INITIALLY (Qnil) /* user_hash_function */,
+   LISPSYM_INITIALLY (Qnil) /* user_cmp_function */,
+   cmpfn_profiler,
+   hashfn_profiler,
+  };
 
 static Lisp_Object
-make_log (EMACS_INT heap_size, EMACS_INT max_stack_depth)
+make_log (void)
 {
   /* We use a standard Elisp hash-table object, but we use it in
      a special way.  This is OK as long as the object is not exposed
      to Elisp, i.e. until it is returned by *-profiler-log, after which
      it can't be used any more.  */
+  EMACS_INT heap_size
+    = clip_to_bounds (0, profiler_log_size, MOST_POSITIVE_FIXNUM);
+  ptrdiff_t max_stack_depth
+    = clip_to_bounds (0, profiler_max_stack_depth, PTRDIFF_MAX);;
   Lisp_Object log = make_hash_table (hashtest_profiler, heap_size,
                                     DEFAULT_REHASH_SIZE,
                                     DEFAULT_REHASH_THRESHOLD,
@@ -104,9 +122,8 @@ static void evict_lower_half (log_t *log)
 {
   ptrdiff_t size = ASIZE (log->key_and_value) / 2;
   EMACS_INT median = approximate_median (log, 0, size);
-  ptrdiff_t i;
 
-  for (i = 0; i < size; i++)
+  for (ptrdiff_t i = 0; i < size; i++)
     /* Evict not only values smaller but also values equal to the median,
        so as to make sure we evict something no matter what.  */
     if (XFIXNUM (HASH_VALUE (log, i)) <= median)
@@ -134,17 +151,14 @@ static void evict_lower_half (log_t *log)
 static void
 record_backtrace (log_t *log, EMACS_INT count)
 {
-  Lisp_Object backtrace;
-  ptrdiff_t index;
-
   if (log->next_free < 0)
     /* FIXME: transfer the evicted counts to a special entry rather
        than dropping them on the floor.  */
     evict_lower_half (log);
-  index = log->next_free;
+  ptrdiff_t index = log->next_free;
 
   /* Get a "working memory" vector.  */
-  backtrace = HASH_KEY (log, index);
+  Lisp_Object backtrace = HASH_KEY (log, index);
   get_backtrace (backtrace);
 
   { /* We basically do a `gethash+puthash' here, except that we have to be
@@ -218,12 +232,6 @@ static EMACS_INT current_sampling_interval;
 
 /* Signal handler for sampling profiler.  */
 
-/* timer_getoverrun is not implemented on Cygwin, but the following
-   seems to be good enough for profiling. */
-#ifdef CYGWIN
-#define timer_getoverrun(x) 0
-#endif
-
 static void
 handle_profiler_signal (int signal)
 {
@@ -238,7 +246,7 @@ handle_profiler_signal (int signal)
   else
     {
       EMACS_INT count = 1;
-#ifdef HAVE_ITIMERSPEC
+#if defined HAVE_ITIMERSPEC && defined HAVE_TIMER_GETOVERRUN
       if (profiler_timer_ok)
        {
          int overruns = timer_getoverrun (profiler_timer);
@@ -260,9 +268,6 @@ deliver_profiler_signal (int signal)
 static int
 setup_cpu_timer (Lisp_Object sampling_interval)
 {
-  struct sigaction action;
-  struct itimerval timer;
-  struct timespec interval;
   int billion = 1000000000;
 
   if (! RANGED_FIXNUMP (1, sampling_interval,
@@ -273,8 +278,10 @@ setup_cpu_timer (Lisp_Object sampling_interval)
     return -1;
 
   current_sampling_interval = XFIXNUM (sampling_interval);
-  interval = make_timespec (current_sampling_interval / billion,
-                           current_sampling_interval % billion);
+  struct timespec interval
+    = make_timespec (current_sampling_interval / billion,
+                    current_sampling_interval % billion);
+  struct sigaction action;
   emacs_sigaction_init (&action, deliver_profiler_signal);
   sigaction (SIGPROF, &action, 0);
 
@@ -294,16 +301,15 @@ setup_cpu_timer (Lisp_Object sampling_interval)
 #endif
        CLOCK_REALTIME
       };
-      int i;
       struct sigevent sigev;
       sigev.sigev_value.sival_ptr = &profiler_timer;
       sigev.sigev_signo = SIGPROF;
       sigev.sigev_notify = SIGEV_SIGNAL;
 
-      for (i = 0; i < ARRAYELTS (system_clock); i++)
+      for (int i = 0; i < ARRAYELTS (system_clock); i++)
        if (timer_create (system_clock[i], &sigev, &profiler_timer) == 0)
          {
-           profiler_timer_ok = 1;
+           profiler_timer_ok = true;
            break;
          }
     }
@@ -318,6 +324,7 @@ setup_cpu_timer (Lisp_Object sampling_interval)
 #endif
 
 #ifdef HAVE_SETITIMER
+  struct itimerval timer;
   timer.it_value = timer.it_interval = make_timeval (interval);
   if (setitimer (ITIMER_PROF, &timer, 0) == 0)
     return SETITIMER_RUNNING;
@@ -339,12 +346,11 @@ See also `profiler-log-size' and 
`profiler-max-stack-depth'.  */)
   if (NILP (cpu_log))
     {
       cpu_gc_count = 0;
-      cpu_log = make_log (profiler_log_size,
-                         profiler_max_stack_depth);
+      cpu_log = make_log ();
     }
 
   int status = setup_cpu_timer (sampling_interval);
-  if (status == -1)
+  if (status < 0)
     {
       profiler_cpu_running = NOT_RUNNING;
       error ("Invalid sampling interval");
@@ -373,8 +379,7 @@ Return non-nil if the profiler was running.  */)
 #ifdef HAVE_ITIMERSPEC
     case TIMER_SETTIME_RUNNING:
       {
-       struct itimerspec disable;
-       memset (&disable, 0, sizeof disable);
+       struct itimerspec disable = { 0, };
        timer_settime (profiler_timer, 0, &disable, 0);
       }
       break;
@@ -383,8 +388,7 @@ Return non-nil if the profiler was running.  */)
 #ifdef HAVE_SETITIMER
     case SETITIMER_RUNNING:
       {
-       struct itimerval disable;
-       memset (&disable, 0, sizeof disable);
+       struct itimerval disable = { 0, };
        setitimer (ITIMER_PROF, &disable, 0);
       }
       break;
@@ -418,9 +422,7 @@ Before returning, a new log is allocated for future 
samples.  */)
   /* Here we're making the log visible to Elisp, so it's not safe any
      more for our use afterwards since we can't rely on its special
      pre-allocated keys anymore.  So we have to allocate a new one.  */
-  cpu_log = (profiler_cpu_running
-            ? make_log (profiler_log_size, profiler_max_stack_depth)
-            : Qnil);
+  cpu_log = profiler_cpu_running ? make_log () : Qnil;
   Fputhash (make_vector (1, QAutomatic_GC),
            make_fixnum (cpu_gc_count),
            result);
@@ -449,8 +451,7 @@ See also `profiler-log-size' and 
`profiler-max-stack-depth'.  */)
     error ("Memory profiler is already running");
 
   if (NILP (memory_log))
-    memory_log = make_log (profiler_log_size,
-                          profiler_max_stack_depth);
+    memory_log = make_log ();
 
   profiler_memory_running = true;
 
@@ -493,9 +494,7 @@ Before returning, a new log is allocated for future 
samples.  */)
   /* Here we're making the log visible to Elisp , so it's not safe any
      more for our use afterwards since we can't rely on its special
      pre-allocated keys anymore.  So we have to allocate a new one.  */
-  memory_log = (profiler_memory_running
-               ? make_log (profiler_log_size, profiler_max_stack_depth)
-               : Qnil);
+  memory_log = profiler_memory_running ? make_log () : Qnil;
   return result;
 }
 
@@ -536,10 +535,10 @@ cmpfn_profiler (struct hash_table_test *t,
 {
   if (VECTORP (bt1) && VECTORP (bt2))
     {
-      ptrdiff_t i, l = ASIZE (bt1);
+      ptrdiff_t l = ASIZE (bt1);
       if (l != ASIZE (bt2))
        return false;
-      for (i = 0; i < l; i++)
+      for (ptrdiff_t i = 0; i < l; i++)
        if (NILP (Ffunction_equal (AREF (bt1, i), AREF (bt2, i))))
          return false;
       return true;
@@ -554,8 +553,8 @@ hashfn_profiler (struct hash_table_test *ht, Lisp_Object bt)
   if (VECTORP (bt))
     {
       EMACS_UINT hash = 0;
-      ptrdiff_t i, l = ASIZE (bt);
-      for (i = 0; i < l; i++)
+      ptrdiff_t l = ASIZE (bt);
+      for (ptrdiff_t i = 0; i < l; i++)
        {
          Lisp_Object f = AREF (bt, i);
          EMACS_UINT hash1
@@ -570,6 +569,8 @@ hashfn_profiler (struct hash_table_test *ht, Lisp_Object bt)
     return XHASH (bt);
 }
 
+static void syms_of_profiler_for_pdumper (void);
+
 void
 syms_of_profiler (void)
 {
@@ -584,12 +585,6 @@ to make room for new entries.  */);
 
   DEFSYM (Qprofiler_backtrace_equal, "profiler-backtrace-equal");
 
-  hashtest_profiler.name = Qprofiler_backtrace_equal;
-  hashtest_profiler.user_hash_function = Qnil;
-  hashtest_profiler.user_cmp_function = Qnil;
-  hashtest_profiler.cmpfn = cmpfn_profiler;
-  hashtest_profiler.hashfn = hashfn_profiler;
-
   defsubr (&Sfunction_equal);
 
 #ifdef PROFILER_CPU_SUPPORT
@@ -608,4 +603,26 @@ to make room for new entries.  */);
   defsubr (&Sprofiler_memory_stop);
   defsubr (&Sprofiler_memory_running_p);
   defsubr (&Sprofiler_memory_log);
+
+  pdumper_do_now_and_after_load (syms_of_profiler_for_pdumper);
+}
+
+static void
+syms_of_profiler_for_pdumper (void)
+{
+  if (dumped_with_pdumper_p ())
+    {
+#ifdef PROFILER_CPU_SUPPORT
+      cpu_log = Qnil;
+#endif
+      memory_log = Qnil;
+    }
+  else
+    {
+#ifdef PROFILER_CPU_SUPPORT
+      eassert (NILP (cpu_log));
+#endif
+      eassert (NILP (memory_log));
+    }
+
 }
diff --git a/src/ptr-bounds.h b/src/ptr-bounds.h
index 8cbd58d..b779816 100644
--- a/src/ptr-bounds.h
+++ b/src/ptr-bounds.h
@@ -1,6 +1,6 @@
 /* Pointer bounds checking for GNU Emacs
 
-Copyright 2017-2018 Free Software Foundation, Inc.
+Copyright 2017-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/puresize.h b/src/puresize.h
index b37ab97..f5fad8b 100644
--- a/src/puresize.h
+++ b/src/puresize.h
@@ -1,5 +1,5 @@
 /* How much read-only Lisp storage a dumped Emacs needs.
-   Copyright (C) 1993, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1993, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -77,7 +77,7 @@ INLINE_HEADER_BEGIN
 #define PURESIZE  (BASE_PURESIZE * PURESIZE_RATIO * PURESIZE_CHECKING_RATIO)
 #endif
 
-extern _Noreturn void pure_write_error (Lisp_Object);
+extern AVOID pure_write_error (Lisp_Object);
 
 extern EMACS_INT pure[];
 
diff --git a/src/ralloc.c b/src/ralloc.c
index 046d550..66ea2ec 100644
--- a/src/ralloc.c
+++ b/src/ralloc.c
@@ -1,5 +1,5 @@
 /* Block-relocating memory allocator.
-   Copyright (C) 1993, 1995, 2000-2018 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1995, 2000-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -26,11 +26,9 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #include <stddef.h>
 
-#ifdef emacs
-# include "lisp.h"
-# include "blockinput.h"
-# include <unistd.h>
-#endif
+#include "lisp.h"
+#include "blockinput.h"
+#include <unistd.h>
 
 #include "getpagesize.h"
 
@@ -924,9 +922,7 @@ r_alloc_free (void **ptr)
   free_bloc (dead_bloc);
   *ptr = 0;
 
-#ifdef emacs
   refill_memory_reserve ();
-#endif
 }
 
 /* Given a pointer at address PTR to relocatable data, resize it to SIZE.
@@ -1000,7 +996,7 @@ r_re_alloc (void **ptr, size_t size)
 }
 
 
-#if defined (emacs) && defined (DOUG_LEA_MALLOC)
+#ifdef DOUG_LEA_MALLOC
 
 /* Reinitialize the morecore hook variables after restarting a dumped
    Emacs.  This is needed when using Doug Lea's malloc from GNU libc.  */
diff --git a/src/regex-emacs.c b/src/regex-emacs.c
index d19838a..8dc6980 100644
--- a/src/regex-emacs.c
+++ b/src/regex-emacs.c
@@ -1,6 +1,6 @@
 /* Emacs regular expression matching and search
 
-   Copyright (C) 1993-2018 Free Software Foundation, Inc.
+   Copyright (C) 1993-2019 Free Software Foundation, Inc.
 
    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
@@ -151,8 +151,6 @@
 
 #define ISWORD(c) (SYNTAX (c) == Sword)
 
-#define SIGN_EXTEND_CHAR(c) ((signed char) (c))
-
 /* Use alloca instead of malloc.  This is because using malloc in
    re_search* or re_match* could cause memory leaks when C-g is used
    in Emacs (note that SAFE_ALLOCA could also call malloc, but does so
@@ -182,10 +180,6 @@ ptrdiff_t emacs_re_safe_alloca = MAX_ALLOCA;
 #define FIRST_STRING_P(ptr)                                    \
   (size1 && string1 <= (ptr) && (ptr) <= string1 + size1)
 
-/* (Re)Allocate N items of type T using malloc, or fail.  */
-#define TALLOC(n, t) ((t *) xmalloc ((n) * sizeof (t)))
-#define RETALLOC(addr, n, t) ((addr) = (t *) xrealloc (addr, (n) * sizeof (t)))
-
 #define BYTEWIDTH 8 /* In bits.  */
 
 /* Type of source-pattern and string chars.  */
@@ -193,8 +187,8 @@ typedef const unsigned char re_char;
 
 static void re_compile_fastmap (struct re_pattern_buffer *);
 static ptrdiff_t re_match_2_internal (struct re_pattern_buffer *bufp,
-                                    re_char *string1, size_t size1,
-                                    re_char *string2, size_t size2,
+                                    re_char *string1, ptrdiff_t size1,
+                                    re_char *string2, ptrdiff_t size2,
                                     ptrdiff_t pos,
                                     struct re_registers *regs,
                                     ptrdiff_t stop);
@@ -368,8 +362,8 @@ typedef enum
 static int
 extract_number (re_char *source)
 {
-  unsigned leading_byte = SIGN_EXTEND_CHAR (source[1]);
-  return (leading_byte << 8) + source[0];
+  signed char leading_byte = source[1];
+  return leading_byte * 256 + source[0];
 }
 
 /* Same as EXTRACT_NUMBER, except increment SOURCE to after the number.
@@ -416,7 +410,7 @@ extract_number_and_incr (re_char **source)
 #define CHARSET_BITMAP_SIZE(p) ((p)[1] & 0x7F)
 
 /* Nonzero if charset P has range table.  */
-#define CHARSET_RANGE_TABLE_EXISTS_P(p)         ((p)[1] & 0x80)
+#define CHARSET_RANGE_TABLE_EXISTS_P(p)         (((p)[1] & 0x80) != 0)
 
 /* Return the address of range table of charset P.  But not the start
    of table itself, but the before where the number of ranges is
@@ -460,18 +454,18 @@ static int regex_emacs_debug = -100000;
 static void
 print_fastmap (char *fastmap)
 {
-  unsigned was_a_range = 0;
-  unsigned i = 0;
+  bool was_a_range = false;
+  int i = 0;
 
   while (i < (1 << BYTEWIDTH))
     {
       if (fastmap[i++])
        {
-         was_a_range = 0;
+         was_a_range = false;
          putchar (i - 1);
          while (i < (1 << BYTEWIDTH)  &&  fastmap[i])
            {
-             was_a_range = 1;
+             was_a_range = true;
              i++;
            }
          if (was_a_range)
@@ -545,10 +539,10 @@ print_partial_compiled_pattern (re_char *start, re_char 
*end)
        case charset:
        case charset_not:
          {
-           register int c, last = -100;
-           register int in_range = 0;
+           int c, last = -100;
+           bool in_range = false;
            int length = CHARSET_BITMAP_SIZE (p - 1);
-           int has_range_table = CHARSET_RANGE_TABLE_EXISTS_P (p - 1);
+           bool has_range_table = CHARSET_RANGE_TABLE_EXISTS_P (p - 1);
 
            fprintf (stderr, "/charset [%s",
                     (re_opcode_t) *(p - 1) == charset_not ? "^" : "");
@@ -564,13 +558,13 @@ print_partial_compiled_pattern (re_char *start, re_char 
*end)
                  if (last + 1 == c && ! in_range)
                    {
                      fprintf (stderr, "-");
-                     in_range = 1;
+                     in_range = true;
                    }
                  /* Have we broken a range?  */
                  else if (last + 1 != c && in_range)
                    {
                      fprintf (stderr, "%c", last);
-                     in_range = 0;
+                     in_range = false;
                    }
 
                  if (! in_range)
@@ -698,7 +692,6 @@ print_partial_compiled_pattern (re_char *start, re_char 
*end)
          fprintf (stderr, "/%d", mcnt);
          break;
 
-# ifdef emacs
        case at_dot:
          fprintf (stderr, "/at_dot");
          break;
@@ -714,7 +707,6 @@ print_partial_compiled_pattern (re_char *start, re_char 
*end)
          mcnt = *p++;
          fprintf (stderr, "/%d", mcnt);
          break;
-# endif /* emacs */
 
        case begbuf:
          fprintf (stderr, "/begbuf");
@@ -741,7 +733,7 @@ print_compiled_pattern (struct re_pattern_buffer *bufp)
   re_char *buffer = bufp->buffer;
 
   print_partial_compiled_pattern (buffer, buffer + bufp->used);
-  printf ("%zu bytes used/%zu bytes allocated.\n",
+  printf ("%tu bytes used/%tu bytes allocated.\n",
          bufp->used, bufp->allocated);
 
   if (bufp->fastmap_accurate && bufp->fastmap)
@@ -750,37 +742,29 @@ print_compiled_pattern (struct re_pattern_buffer *bufp)
       print_fastmap (bufp->fastmap);
     }
 
-  printf ("re_nsub: %zu\t", bufp->re_nsub);
+  printf ("re_nsub: %tu\t", bufp->re_nsub);
   printf ("regs_alloc: %d\t", bufp->regs_allocated);
   printf ("can_be_null: %d\t", bufp->can_be_null);
-#ifndef emacs
-  printf ("syntax: %lx\n", bufp->syntax);
-#endif
   fflush (stdout);
   /* Perhaps we should print the translate table?  */
 }
 
 
 static void
-print_double_string (re_char *where, re_char *string1, ssize_t size1,
-                    re_char *string2, ssize_t size2)
+print_double_string (re_char *where, re_char *string1, ptrdiff_t size1,
+                    re_char *string2, ptrdiff_t size2)
 {
-  ssize_t this_char;
-
   if (where == NULL)
     printf ("(null)");
   else
     {
       if (FIRST_STRING_P (where))
        {
-         for (this_char = where - string1; this_char < size1; this_char++)
-           putchar (string1[this_char]);
-
+         fwrite_unlocked (where, 1, string1 + size1 - where, stdout);
          where = string2;
        }
 
-      for (this_char = where - string2; this_char < size2; this_char++)
-       putchar (string2[this_char]);
+      fwrite_unlocked (where, 1, string2 + size2 - where, stdout);
     }
 }
 
@@ -877,13 +861,12 @@ enum { RE_NREGS = 30 };
    whose default stack limit is 2mb.  In order for a larger
    value to work reliably, you have to try to make it accord
    with the process stack limit.  */
-size_t emacs_re_max_failures = 40000;
+ptrdiff_t emacs_re_max_failures = 40000;
 
 union fail_stack_elt
 {
   re_char *pointer;
-  /* This should be the biggest 'int' that's no bigger than a pointer.  */
-  long integer;
+  intptr_t integer;
 };
 
 typedef union fail_stack_elt fail_stack_elt_t;
@@ -891,9 +874,9 @@ typedef union fail_stack_elt fail_stack_elt_t;
 typedef struct
 {
   fail_stack_elt_t *stack;
-  size_t size;
-  size_t avail;        /* Offset of next open position.  */
-  size_t frame;        /* Offset of the cur constructed frame.  */
+  ptrdiff_t size;
+  ptrdiff_t avail;     /* Offset of next open position.  */
+  ptrdiff_t frame;     /* Offset of the cur constructed frame.  */
 } fail_stack_type;
 
 #define FAIL_STACK_EMPTY()     (fail_stack.frame == 0)
@@ -972,17 +955,17 @@ typedef struct
 while (REMAINING_AVAIL_SLOTS <= space) {                               \
   if (!GROW_FAIL_STACK (fail_stack))                                   \
     return -2;                                                         \
-  DEBUG_PRINT ("\n  Doubled stack; size now: %zu\n", (fail_stack).size);\
-  DEBUG_PRINT ("        slots available: %zu\n", REMAINING_AVAIL_SLOTS);\
+  DEBUG_PRINT ("\n  Doubled stack; size now: %tu\n", fail_stack.size); \
+  DEBUG_PRINT ("        slots available: %tu\n", REMAINING_AVAIL_SLOTS);\
 }
 
 /* Push register NUM onto the stack.  */
 #define PUSH_FAILURE_REG(num)                                          \
 do {                                                                   \
   char *destination;                                                   \
-  long n = num;                                                                
\
+  intptr_t n = num;                                                    \
   ENSURE_FAIL_STACK(3);                                                        
\
-  DEBUG_PRINT ("    Push reg %ld (spanning %p -> %p)\n",               \
+  DEBUG_PRINT ("    Push reg %"PRIdPTR" (spanning %p -> %p)\n",                
\
               n, regstart[n], regend[n]);                              \
   PUSH_FAILURE_POINTER (regstart[n]);                                  \
   PUSH_FAILURE_POINTER (regend[n]);                                    \
@@ -1007,7 +990,7 @@ do {                                                       
                \
 /* Pop a saved register off the stack.  */
 #define POP_FAILURE_REG_OR_COUNT()                                     \
 do {                                                                   \
-  long pfreg = POP_FAILURE_INT ();                                     \
+  intptr_t pfreg = POP_FAILURE_INT ();                                 \
   if (pfreg == -1)                                                     \
     {                                                                  \
       /* It's a counter.  */                                           \
@@ -1015,7 +998,7 @@ do {                                                       
                \
       unsigned char *ptr = (unsigned char *) POP_FAILURE_POINTER ();   \
       pfreg = POP_FAILURE_INT ();                                      \
       STORE_NUMBER (ptr, pfreg);                                       \
-      DEBUG_PRINT ("     Pop counter %p = %ld\n", ptr, pfreg);         \
+      DEBUG_PRINT ("     Pop counter %p = %"PRIdPTR"\n", ptr, pfreg);  \
     }                                                                  \
   else                                                                 \
     {                                                                  \
@@ -1039,7 +1022,7 @@ do {                                                      
                \
               && FAILURE_PAT (failure) <= bufp->buffer + bufp->used);  \
       if (FAILURE_PAT (failure) == pat_cur)                            \
        {                                                               \
-         cycle = 1;                                                    \
+         cycle = true;                                                 \
          break;                                                        \
        }                                                               \
       DEBUG_PRINT ("  Other pattern: %p\n", FAILURE_PAT (failure));    \
@@ -1062,14 +1045,14 @@ do {                                                    
                \
   char *destination;                                                   \
   DEBUG_STATEMENT (nfailure_points_pushed++);                          \
   DEBUG_PRINT ("\nPUSH_FAILURE_POINT:\n");                             \
-  DEBUG_PRINT ("  Before push, next avail: %zu\n", (fail_stack).avail);        
\
-  DEBUG_PRINT ("                       size: %zu\n", (fail_stack).size);\
+  DEBUG_PRINT ("  Before push, next avail: %tu\n", fail_stack.avail);  \
+  DEBUG_PRINT ("                       size: %tu\n", fail_stack.size); \
                                                                        \
   ENSURE_FAIL_STACK (NUM_NONREG_ITEMS);                                        
\
                                                                        \
   DEBUG_PRINT ("\n");                                                  \
                                                                        \
-  DEBUG_PRINT ("  Push frame index: %zu\n", fail_stack.frame);         \
+  DEBUG_PRINT ("  Push frame index: %tu\n", fail_stack.frame);         \
   PUSH_FAILURE_INT (fail_stack.frame);                                 \
                                                                        \
   DEBUG_PRINT ("  Push string %p: \"", string_place);                  \
@@ -1111,8 +1094,8 @@ do {                                                      
                \
                                                                        \
   /* Remove failure points and point to how many regs pushed.  */      \
   DEBUG_PRINT ("POP_FAILURE_POINT:\n");                                        
\
-  DEBUG_PRINT ("  Before pop, next avail: %zu\n", fail_stack.avail);   \
-  DEBUG_PRINT ("                    size: %zu\n", fail_stack.size);    \
+  DEBUG_PRINT ("  Before pop, next avail: %tu\n", fail_stack.avail);   \
+  DEBUG_PRINT ("                    size: %tu\n", fail_stack.size);    \
                                                                        \
   /* Pop the saved registers.  */                                      \
   while (fail_stack.frame < fail_stack.avail)                          \
@@ -1146,7 +1129,7 @@ do {                                                      
                \
 
 /* Subroutine declarations and macros for regex_compile.  */
 
-static reg_errcode_t regex_compile (re_char *pattern, size_t size,
+static reg_errcode_t regex_compile (re_char *pattern, ptrdiff_t size,
                                    bool posix_backtracking,
                                    const char *whitespace_regexp,
                                    struct re_pattern_buffer *bufp);
@@ -1160,7 +1143,7 @@ static bool at_begline_loc_p (re_char *pattern, re_char 
*p);
 static bool at_endline_loc_p (re_char *p, re_char *pend);
 static re_char *skip_one_char (re_char *p);
 static int analyze_first (re_char *p, re_char *pend,
-                         char *fastmap, const int multibyte);
+                         char *fastmap, bool multibyte);
 
 /* Fetch the next character in the uncompiled pattern, with no
    translation.  */
@@ -1183,8 +1166,8 @@ static int analyze_first (re_char *p, re_char *pend,
 
 /* Ensure at least N more bytes of space in buffer.  */
 #define GET_BUFFER_SPACE(n)                                            \
-    while ((size_t) (b - bufp->buffer + (n)) > bufp->allocated)                
\
-      EXTEND_BUFFER ()
+    if (bufp->buffer + bufp->allocated - b < (n))                      \
+      EXTEND_BUFFER ((n) - (bufp->buffer + bufp->allocated - b))
 
 /* Ensure one more byte of buffer space and then add C to it.  */
 #define BUF_PUSH(c)                                                    \
@@ -1226,18 +1209,16 @@ static int analyze_first (re_char *p, re_char *pend,
    be too small, many things would have to change.  */
 # define MAX_BUF_SIZE (1 << 15)
 
-/* Extend the buffer by twice its current size via realloc and
+/* Extend the buffer by at least N bytes via realloc and
    reset the pointers that pointed into the old block to point to the
    correct places in the new one.  If extending the buffer results in it
    being larger than MAX_BUF_SIZE, then flag memory exhausted.  */
-#define EXTEND_BUFFER()                                                        
\
+#define EXTEND_BUFFER(n)                                               \
   do {                                                                 \
+    ptrdiff_t requested_extension = n;                                 \
     unsigned char *old_buffer = bufp->buffer;                          \
-    if (bufp->allocated == MAX_BUF_SIZE)                               \
+    if (MAX_BUF_SIZE - bufp->allocated < requested_extension)          \
       return REG_ESIZE;                                                        
\
-    bufp->allocated <<= 1;                                             \
-    if (bufp->allocated > MAX_BUF_SIZE)                                        
\
-      bufp->allocated = MAX_BUF_SIZE;                                  \
     ptrdiff_t b_off = b - old_buffer;                                  \
     ptrdiff_t begalt_off = begalt - old_buffer;                                
\
     bool fixup_alt_jump_set = !!fixup_alt_jump;                                
\
@@ -1247,7 +1228,8 @@ static int analyze_first (re_char *p, re_char *pend,
     if (fixup_alt_jump_set) fixup_alt_jump_off = fixup_alt_jump - old_buffer; \
     if (laststart_set) laststart_off = laststart - old_buffer;         \
     if (pending_exact_set) pending_exact_off = pending_exact - old_buffer; \
-    RETALLOC (bufp->buffer, bufp->allocated, unsigned char);           \
+    bufp->buffer = xpalloc (bufp->buffer, &bufp->allocated,            \
+                           requested_extension, MAX_BUF_SIZE, 1);      \
     unsigned char *new_buffer = bufp->buffer;                          \
     b = new_buffer + b_off;                                            \
     begalt = new_buffer + begalt_off;                                  \
@@ -1269,9 +1251,8 @@ typedef int regnum_t;
 
 /* Macros for the compile stack.  */
 
-/* Since offsets can go either forwards or backwards, this type needs to
-   be able to hold values from -(MAX_BUF_SIZE - 1) to MAX_BUF_SIZE - 1.  */
 typedef long pattern_offset_t;
+verify (LONG_MIN <= -(MAX_BUF_SIZE - 1) && MAX_BUF_SIZE - 1 <= LONG_MAX);
 
 typedef struct
 {
@@ -1285,8 +1266,8 @@ typedef struct
 typedef struct
 {
   compile_stack_elt_t *stack;
-  size_t size;
-  size_t avail;                        /* Offset of next open position.  */
+  ptrdiff_t size;
+  ptrdiff_t avail;             /* Offset of next open position.  */
 } compile_stack_type;
 
 
@@ -1307,9 +1288,7 @@ struct range_table_work_area
   int bits;                    /* flag to record character classes */
 };
 
-/* Make sure that WORK_AREA can hold more N multibyte characters.
-   This is used only in set_image_of_range and set_image_of_range_1.
-   It expects WORK_AREA to be a pointer.
+/* Make sure that WORK_AREA can hold N more multibyte characters.
    If it can't get the space, it returns from the surrounding function.  */
 
 #define EXTEND_RANGE_TABLE(work_area, n)                               \
@@ -1506,7 +1485,7 @@ struct range_table_work_area
    The function can be used on ASCII and multibyte (UTF-8-encoded) strings.
  */
 re_wctype_t
-re_wctype_parse (const unsigned char **strp, unsigned limit)
+re_wctype_parse (const unsigned char **strp, ptrdiff_t limit)
 {
   const char *beg = (const char *)*strp, *it;
 
@@ -1684,13 +1663,13 @@ do {                                                    
                \
      'buffer' is the compiled pattern;
      'syntax' is set to SYNTAX;
      'used' is set to the length of the compiled pattern;
-     'fastmap_accurate' is zero;
+     'fastmap_accurate' is false;
      're_nsub' is the number of subexpressions in PATTERN;
 
    The 'fastmap' field is neither examined nor set.  */
 
 static reg_errcode_t
-regex_compile (re_char *pattern, size_t size,
+regex_compile (re_char *pattern, ptrdiff_t size,
               bool posix_backtracking,
               const char *whitespace_regexp,
               struct re_pattern_buffer *bufp)
@@ -1737,7 +1716,7 @@ regex_compile (re_char *pattern, size_t size,
   /* Work area for range table of charset.  */
   struct range_table_work_area range_table_work;
 
-  /* If the object matched can contain multibyte characters.  */
+  /* If the regular expression is multibyte.  */
   bool multibyte = RE_MULTIBYTE_P (bufp);
 
   /* Nonzero if we have pushed down into a subpattern.  */
@@ -1754,16 +1733,15 @@ regex_compile (re_char *pattern, size_t size,
   DEBUG_PRINT ("\nCompiling pattern: ");
   if (regex_emacs_debug > 0)
     {
-      size_t debug_count;
-
-      for (debug_count = 0; debug_count < size; debug_count++)
+      for (ptrdiff_t debug_count = 0; debug_count < size; debug_count++)
        putchar (pattern[debug_count]);
       putchar ('\n');
     }
 #endif
 
   /* Initialize the compile stack.  */
-  compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t);
+  compile_stack.stack = xmalloc (INIT_COMPILE_STACK_SIZE
+                                * sizeof *compile_stack.stack);
   compile_stack.size = INIT_COMPILE_STACK_SIZE;
   compile_stack.avail = 0;
 
@@ -1771,8 +1749,8 @@ regex_compile (re_char *pattern, size_t size,
   range_table_work.allocated = 0;
 
   /* Initialize the pattern buffer.  */
-  bufp->fastmap_accurate = 0;
-  bufp->used_syntax = 0;
+  bufp->fastmap_accurate = false;
+  bufp->used_syntax = false;
 
   /* Set 'used' to zero, so that if we return an error, the pattern
      printer (for debugging) will think there's no pattern.  We reset it
@@ -1783,16 +1761,9 @@ regex_compile (re_char *pattern, size_t size,
 
   if (bufp->allocated == 0)
     {
-      if (bufp->buffer)
-       { /* If zero allocated, but buffer is non-null, try to realloc
-            enough space.  This loses if buffer's address is bogus, but
-            that is the user's responsibility.  */
-         RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char);
-       }
-      else
-       { /* Caller did not allocate a buffer.  Do it for them.  */
-         bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char);
-       }
+      /* This loses if BUFP->buffer is bogus, but that is the user's
+        responsibility.  */
+      bufp->buffer = xrealloc (bufp->buffer, INIT_BUF_SIZE);
       bufp->allocated = INIT_BUF_SIZE;
     }
 
@@ -1912,10 +1883,10 @@ regex_compile (re_char *pattern, size_t size,
                if (many_times_ok)
                  {
                    bool simple = skip_one_char (laststart) == b;
-                   size_t startoffset = 0;
+                   ptrdiff_t startoffset = 0;
                    re_opcode_t ofj =
                      /* Check if the loop can match the empty string.  */
-                     (simple || !analyze_first (laststart, b, NULL, 0))
+                     (simple || !analyze_first (laststart, b, NULL, false))
                      ? on_failure_jump : on_failure_jump_loop;
                    eassert (skip_one_char (laststart) <= b);
 
@@ -1962,7 +1933,7 @@ regex_compile (re_char *pattern, size_t size,
                GET_BUFFER_SPACE (7); /* We might use less.  */
                if (many_times_ok)
                  {
-                   bool emptyp = analyze_first (laststart, b, NULL, 0);
+                   bool emptyp = !!analyze_first (laststart, b, NULL, false);
 
                    /* The non-greedy multiple match looks like
                       a repeat..until: we only need a conditional jump
@@ -2080,7 +2051,7 @@ regex_compile (re_char *pattern, size_t size,
                       content of the syntax-table is not hardcoded in the
                       range_table.  SPACE and WORD are the two exceptions.  */
                    if ((1 << cc) & ((1 << RECC_SPACE) | (1 << RECC_WORD)))
-                     bufp->used_syntax = 1;
+                     bufp->used_syntax = true;
 
                    /* Repeat the loop. */
                    continue;
@@ -2187,7 +2158,7 @@ regex_compile (re_char *pattern, size_t size,
            {
            case '(':
              {
-               int shy = 0;
+               bool shy = false;
                regnum_t regnum = 0;
                if (p+1 < pend)
                  {
@@ -2200,7 +2171,7 @@ regex_compile (re_char *pattern, size_t size,
                            PATFETCH (c);
                            switch (c)
                              {
-                             case ':': shy = 1; break;
+                             case ':': shy = true; break;
                              case '0':
                                /* An explicitly specified regnum must start
                                   with non-0. */
@@ -2209,7 +2180,11 @@ regex_compile (re_char *pattern, size_t size,
                                FALLTHROUGH;
                              case '1': case '2': case '3': case '4':
                              case '5': case '6': case '7': case '8': case '9':
-                               regnum = 10*regnum + (c - '0'); break;
+                               if (INT_MULTIPLY_WRAPV (regnum, 10, &regnum)
+                                   || INT_ADD_WRAPV (regnum, c - '0',
+                                                     &regnum))
+                                 FREE_STACK_RETURN (REG_ESIZE);
+                               break;
                              default:
                                /* Only (?:...) is supported right now. */
                                FREE_STACK_RETURN (REG_BADPAT);
@@ -2222,7 +2197,7 @@ regex_compile (re_char *pattern, size_t size,
                  regnum = ++bufp->re_nsub;
                else if (regnum)
                  { /* It's actually not shy, but explicitly numbered.  */
-                   shy = 0;
+                   shy = false;
                    if (regnum > bufp->re_nsub)
                      bufp->re_nsub = regnum;
                    else if (regnum > bufp->re_nsub
@@ -2239,11 +2214,9 @@ regex_compile (re_char *pattern, size_t size,
                  regnum = - bufp->re_nsub;
 
                if (COMPILE_STACK_FULL)
-                 {
-                   RETALLOC (compile_stack.stack, compile_stack.size << 1,
-                             compile_stack_elt_t);
-                   compile_stack.size <<= 1;
-                 }
+                 compile_stack.stack
+                   = xpalloc (compile_stack.stack, &compile_stack.size,
+                              1, -1, sizeof *compile_stack.stack);
 
                /* These are the values to restore when we hit end of this
                   group.  They are all relative offsets, so that if the
@@ -2400,9 +2373,8 @@ regex_compile (re_char *pattern, size_t size,
                else
                  { /* If the upper bound is > 1, we need to insert
                       more at the end of the loop.  */
-                   unsigned int nbytes = (upper_bound < 0 ? 3
-                                          : upper_bound > 1 ? 5 : 0);
-                   unsigned int startoffset = 0;
+                   int nbytes = upper_bound < 0 ? 3 : upper_bound > 1 ? 5 : 0;
+                   int startoffset = 0;
 
                    GET_BUFFER_SPACE (20); /* We might use less.  */
 
@@ -2806,8 +2778,7 @@ group_in_compile_stack (compile_stack_type compile_stack, 
regnum_t regnum)
    Return -1 if fastmap was not updated accurately.  */
 
 static int
-analyze_first (re_char *p, re_char *pend, char *fastmap,
-              const int multibyte)
+analyze_first (re_char *p, re_char *pend, char *fastmap, bool multibyte)
 {
   int j, k;
   bool not;
@@ -3109,6 +3080,8 @@ re_compile_fastmap (struct re_pattern_buffer *bufp)
   eassert (fastmap && bufp->buffer);
 
   memset (fastmap, 0, 1 << BYTEWIDTH);  /* Assume nothing's valid.  */
+
+  /* FIXME: Is the following assignment correct even when ANALYSIS < 0?  */
   bufp->fastmap_accurate = 1;      /* It will be when we're done.  */
 
   analysis = analyze_first (bufp->buffer, bufp->buffer + bufp->used,
@@ -3131,7 +3104,7 @@ re_compile_fastmap (struct re_pattern_buffer *bufp)
 
 void
 re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs,
-                 unsigned int num_regs, ptrdiff_t *starts, ptrdiff_t *ends)
+                 ptrdiff_t num_regs, ptrdiff_t *starts, ptrdiff_t *ends)
 {
   if (num_regs)
     {
@@ -3154,7 +3127,7 @@ re_set_registers (struct re_pattern_buffer *bufp, struct 
re_registers *regs,
    doesn't let you say where to stop matching. */
 
 ptrdiff_t
-re_search (struct re_pattern_buffer *bufp, const char *string, size_t size,
+re_search (struct re_pattern_buffer *bufp, const char *string, ptrdiff_t size,
           ptrdiff_t startpos, ptrdiff_t range, struct re_registers *regs)
 {
   return re_search_2 (bufp, NULL, 0, string, size, startpos, range,
@@ -3191,8 +3164,8 @@ re_search (struct re_pattern_buffer *bufp, const char 
*string, size_t size,
    stack overflow).  */
 
 ptrdiff_t
-re_search_2 (struct re_pattern_buffer *bufp, const char *str1, size_t size1,
-            const char *str2, size_t size2,
+re_search_2 (struct re_pattern_buffer *bufp, const char *str1, ptrdiff_t size1,
+            const char *str2, ptrdiff_t size2,
             ptrdiff_t startpos, ptrdiff_t range,
             struct re_registers *regs, ptrdiff_t stop)
 {
@@ -3201,7 +3174,7 @@ re_search_2 (struct re_pattern_buffer *bufp, const char 
*str1, size_t size1,
   re_char *string2 = (re_char *) str2;
   char *fastmap = bufp->fastmap;
   Lisp_Object translate = bufp->translate;
-  size_t total_size = size1 + size2;
+  ptrdiff_t total_size = size1 + size2;
   ptrdiff_t endpos = startpos + range;
   bool anchored_start;
   /* Nonzero if we are searching multibyte string.  */
@@ -3425,10 +3398,8 @@ re_search_2 (struct re_pattern_buffer *bufp, const char 
*str1, size_t size1,
 
 /* Declarations and macros for re_match_2.  */
 
-static int bcmp_translate (re_char *s1, re_char *s2,
-                          ptrdiff_t len,
-                          Lisp_Object translate,
-                          const int multibyte);
+static bool bcmp_translate (re_char *, re_char *, ptrdiff_t,
+                           Lisp_Object, bool);
 
 /* This converts PTR, a pointer into one of the search strings 'string1'
    and 'string2' into an offset from the beginning of that string.  */
@@ -3572,8 +3543,9 @@ skip_noops (re_char *p, re_char *pend)
    character (i.e. without any translations).  UNIBYTE denotes whether c is
    unibyte or multibyte character. */
 static bool
-execute_charset (re_char **pp, unsigned c, unsigned corig, bool unibyte)
+execute_charset (re_char **pp, int c, int corig, bool unibyte)
 {
+  eassume (0 <= c && 0 <= corig);
   re_char *p = *pp, *rtp = NULL;
   bool not = (re_opcode_t) *p == charset_not;
 
@@ -3633,8 +3605,8 @@ execute_charset (re_char **pp, unsigned c, unsigned 
corig, bool unibyte)
   return not;
 }
 
-/* Non-zero if "p1 matches something" implies "p2 fails".  */
-static int
+/* True if "p1 matches something" implies "p2 fails".  */
+static bool
 mutually_exclusive_p (struct re_pattern_buffer *bufp, re_char *p1,
                      re_char *p2)
 {
@@ -3667,7 +3639,7 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, 
re_char *p1,
       if (skip_one_char (p1))
        {
          DEBUG_PRINT ("  End of pattern: fast loop.\n");
-         return 1;
+         return true;
        }
       break;
 
@@ -3683,7 +3655,7 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, 
re_char *p1,
            if (c != RE_STRING_CHAR (p1 + 2, multibyte))
              {
                DEBUG_PRINT ("  '%c' != '%c' => fast loop.\n", c, p1[2]);
-               return 1;
+               return true;
              }
          }
 
@@ -3693,14 +3665,14 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, 
re_char *p1,
            if (!execute_charset (&p1, c, c, !multibyte || ASCII_CHAR_P (c)))
              {
                DEBUG_PRINT ("   No match => fast loop.\n");
-               return 1;
+               return true;
              }
          }
        else if ((re_opcode_t) *p1 == anychar
                 && c == '\n')
          {
            DEBUG_PRINT ("   . != \\n => fast loop.\n");
-           return 1;
+           return true;
          }
       }
       break;
@@ -3743,7 +3715,7 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, 
re_char *p1,
                  || idx == CHARSET_BITMAP_SIZE (p1))
                {
                  DEBUG_PRINT ("         No match => fast loop.\n");
-                 return 1;
+                 return true;
                }
            }
          else if ((re_opcode_t) *p1 == charset_not)
@@ -3760,7 +3732,7 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, 
re_char *p1,
              if (idx == p2[1])
                {
                  DEBUG_PRINT ("         No match => fast loop.\n");
-                 return 1;
+                 return true;
                }
              }
          }
@@ -3814,7 +3786,7 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, 
re_char *p1,
     }
 
   /* Safe default.  */
-  return 0;
+  return false;
 }
 
 
@@ -3833,9 +3805,10 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, 
re_char *p1,
    matched substring.  */
 
 ptrdiff_t
-re_match_2 (struct re_pattern_buffer *bufp, const char *string1,
-           size_t size1, const char *string2, size_t size2, ptrdiff_t pos,
-           struct re_registers *regs, ptrdiff_t stop)
+re_match_2 (struct re_pattern_buffer *bufp,
+           char const *string1, ptrdiff_t size1,
+           char const *string2, ptrdiff_t size2,
+           ptrdiff_t pos, struct re_registers *regs, ptrdiff_t stop)
 {
   ptrdiff_t result;
 
@@ -3854,13 +3827,13 @@ re_match_2 (struct re_pattern_buffer *bufp, const char 
*string1,
 /* This is a separate function so that we can force an alloca cleanup
    afterwards.  */
 static ptrdiff_t
-re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1,
-                    size_t size1, re_char *string2, size_t size2,
+re_match_2_internal (struct re_pattern_buffer *bufp,
+                    re_char *string1, ptrdiff_t size1,
+                    re_char *string2, ptrdiff_t size2,
                     ptrdiff_t pos, struct re_registers *regs, ptrdiff_t stop)
 {
   /* General temporaries.  */
   int mcnt;
-  size_t reg;
 
   /* Just past the end of the corresponding string.  */
   re_char *end1, *end2;
@@ -3900,13 +3873,14 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
      scanning the strings.  */
   fail_stack_type fail_stack;
 #ifdef DEBUG_COMPILES_ARGUMENTS
-  unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0;
+  ptrdiff_t nfailure_points_pushed = 0, nfailure_points_popped = 0;
 #endif
 
   /* We fill all the registers internally, independent of what we
      return, for use in backreferences.  The number here includes
      an element for register zero.  */
-  size_t num_regs = bufp->re_nsub + 1;
+  ptrdiff_t num_regs = bufp->re_nsub + 1;
+  eassume (0 < num_regs);
 
   /* Information on the contents of registers. These are pointers into
      the input strings; they record just what was matched (on this
@@ -3921,7 +3895,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
      variables when we find a match better than any we've seen before.
      This happens as we backtrack through the failure points, which in
      turn happens only if we have not yet matched the entire string. */
-  unsigned best_regs_set = false;
+  bool best_regs_set = false;
   re_char **best_regstart UNINIT, **best_regend UNINIT;
 
   /* Logically, this is 'best_regend[0]'.  But we don't want to have to
@@ -3936,7 +3910,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
 
 #ifdef DEBUG_COMPILES_ARGUMENTS
   /* Counts the total number of registers pushed.  */
-  unsigned num_regs_pushed = 0;
+  ptrdiff_t num_regs_pushed = 0;
 #endif
 
   DEBUG_PRINT ("\n\nEntering re_match_2.\n");
@@ -3966,9 +3940,8 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
     }
 
   /* Initialize subexpression text positions to -1 to mark ones that no
-     start_memory/stop_memory has been seen for. Also initialize the
-     register information struct.  */
-  for (reg = 1; reg < num_regs; reg++)
+     start_memory/stop_memory has been seen for.  */
+  for (ptrdiff_t reg = 1; reg < num_regs; reg++)
     regstart[reg] = regend[reg] = NULL;
 
   /* We move 'string1' into 'string2' if the latter's empty -- but not if
@@ -4075,7 +4048,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
 
                      DEBUG_PRINT ("\nSAVING match as best so far.\n");
 
-                     for (reg = 1; reg < num_regs; reg++)
+                     for (ptrdiff_t reg = 1; reg < num_regs; reg++)
                        {
                          best_regstart[reg] = regstart[reg];
                          best_regend[reg] = regend[reg];
@@ -4101,7 +4074,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
                  dend = ((d >= string1 && d <= end1)
                           ? end_match_1 : end_match_2);
 
-                 for (reg = 1; reg < num_regs; reg++)
+                 for (ptrdiff_t reg = 1; reg < num_regs; reg++)
                    {
                      regstart[reg] = best_regstart[reg];
                      regend[reg] = best_regend[reg];
@@ -4117,23 +4090,25 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
            {
              /* Have the register data arrays been allocated?  */
              if (bufp->regs_allocated == REGS_UNALLOCATED)
-               { /* No.  So allocate them with malloc.  We need one
-                    extra element beyond 'num_regs' for the '-1' marker
-                    GNU code uses.  */
-                 regs->num_regs = max (RE_NREGS, num_regs + 1);
-                 regs->start = TALLOC (regs->num_regs, ptrdiff_t);
-                 regs->end = TALLOC (regs->num_regs, ptrdiff_t);
+               { /* No.  So allocate them with malloc.  */
+                 ptrdiff_t n = max (RE_NREGS, num_regs);
+                 regs->start = xnmalloc (n, sizeof *regs->start);
+                 regs->end = xnmalloc (n, sizeof *regs->end);
+                 regs->num_regs = n;
                  bufp->regs_allocated = REGS_REALLOCATE;
                }
              else if (bufp->regs_allocated == REGS_REALLOCATE)
                { /* Yes.  If we need more elements than were already
                     allocated, reallocate them.  If we need fewer, just
                     leave it alone.  */
-                 if (regs->num_regs < num_regs + 1)
+                 ptrdiff_t n = regs->num_regs;
+                 if (n < num_regs)
                    {
-                     regs->num_regs = num_regs + 1;
-                     RETALLOC (regs->start, regs->num_regs, ptrdiff_t);
-                     RETALLOC (regs->end, regs->num_regs, ptrdiff_t);
+                     n = max (n + (n >> 1), num_regs);
+                     regs->start
+                       = xnrealloc (regs->start, n, sizeof *regs->start);
+                     regs->end = xnrealloc (regs->end, n, sizeof *regs->end);
+                     regs->num_regs = n;
                    }
                }
              else
@@ -4148,9 +4123,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
                  regs->end[0] = POINTER_TO_OFFSET (d);
                }
 
-             /* Go through the first 'min (num_regs, regs->num_regs)'
-                registers, since that is all we initialized.  */
-             for (reg = 1; reg < min (num_regs, regs->num_regs); reg++)
+             for (ptrdiff_t reg = 1; reg < num_regs; reg++)
                {
                  if (REG_UNSET (regstart[reg]) || REG_UNSET (regend[reg]))
                    regs->start[reg] = regs->end[reg] = -1;
@@ -4162,18 +4135,15 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
                }
 
              /* If the regs structure we return has more elements than
-                were in the pattern, set the extra elements to -1.  If
-                we (re)allocated the registers, this is the case,
-                because we always allocate enough to have at least one
-                -1 at the end.  */
-             for (reg = num_regs; reg < regs->num_regs; reg++)
+                were in the pattern, set the extra elements to -1.  */
+             for (ptrdiff_t reg = num_regs; reg < regs->num_regs; reg++)
                regs->start[reg] = regs->end[reg] = -1;
            }
 
-         DEBUG_PRINT ("%u failure points pushed, %u popped (%u remain).\n",
+         DEBUG_PRINT ("%td failure points pushed, %td popped (%td remain).\n",
                       nfailure_points_pushed, nfailure_points_popped,
                       nfailure_points_pushed - nfailure_points_popped);
-         DEBUG_PRINT ("%u registers pushed.\n", num_regs_pushed);
+         DEBUG_PRINT ("%td registers pushed.\n", num_regs_pushed);
 
          ptrdiff_t dcnt = POINTER_TO_OFFSET (d) - pos;
 
@@ -4298,9 +4268,6 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
        case charset:
        case charset_not:
          {
-           register unsigned int c, corig;
-           int len;
-
            /* Whether matching against a unibyte character.  */
            bool unibyte_char = false;
 
@@ -4308,7 +4275,9 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
                         (re_opcode_t) *(p - 1) == charset_not ? "_not" : "");
 
            PREFETCH ();
-           corig = c = RE_STRING_CHAR_AND_LENGTH (d, len, target_multibyte);
+           int len;
+           int corig = RE_STRING_CHAR_AND_LENGTH (d, len, target_multibyte);
+           int c = corig;
            if (target_multibyte)
              {
                int c1;
@@ -4376,7 +4345,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
          /* Strictly speaking, there should be code such as:
 
                eassert (REG_UNSET (regend[*p]));
-               PUSH_FAILURE_REGSTOP ((unsigned int)*p);
+               PUSH_FAILURE_REGSTOP (*p);
 
             But the only info to be pushed is regend[*p] and it is known to
             be UNSET, so there really isn't anything to push.
@@ -4555,7 +4524,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
 
          eassert ((re_opcode_t)p[-4] == no_op);
          {
-           int cycle = 0;
+           bool cycle = false;
            CHECK_INFINITE_LOOP (p - 4, d);
            if (!cycle)
              /* If there's a cycle, just continue without pushing
@@ -4574,7 +4543,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
          DEBUG_PRINT ("EXECUTING on_failure_jump_loop %d (to %p):\n",
                       mcnt, p + mcnt);
          {
-           int cycle = 0;
+           bool cycle = false;
            CHECK_INFINITE_LOOP (p - 3, d);
            if (cycle)
              /* If there's a cycle, get out of the loop, as if the matching
@@ -4737,8 +4706,8 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
                int c1, c2;
                int s1, s2;
                int dummy;
-               ptrdiff_t offset = PTR_TO_OFFSET (d - 1);
-               ptrdiff_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset);
+                ptrdiff_t offset = PTR_TO_OFFSET (d);
+                ptrdiff_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset) - 1;
                UPDATE_SYNTAX_TABLE (charpos);
                GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2);
                s1 = SYNTAX (c1);
@@ -4816,8 +4785,8 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
              int c1, c2;
              int s1, s2;
              int dummy;
-             ptrdiff_t offset = PTR_TO_OFFSET (d) - 1;
-             ptrdiff_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset);
+              ptrdiff_t offset = PTR_TO_OFFSET (d);
+              ptrdiff_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset) - 1;
              UPDATE_SYNTAX_TABLE (charpos);
              GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2);
              s1 = SYNTAX (c1);
@@ -4831,7 +4800,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
                {
                  PREFETCH_NOLIMIT ();
                  GET_CHAR_AFTER (c2, d, dummy);
-                 UPDATE_SYNTAX_TABLE_FORWARD (charpos);
+                  UPDATE_SYNTAX_TABLE_FORWARD (charpos + 1);
                  s2 = SYNTAX (c2);
 
                  /* ... and S2 is Sword, and WORD_BOUNDARY_P (C1, C2)
@@ -4895,8 +4864,8 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
                 is the character at D, and S2 is the syntax of C2.  */
              int c1, c2;
              int s1, s2;
-             ptrdiff_t offset = PTR_TO_OFFSET (d) - 1;
-             ptrdiff_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset);
+              ptrdiff_t offset = PTR_TO_OFFSET (d);
+              ptrdiff_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset) - 1;
              UPDATE_SYNTAX_TABLE (charpos);
              GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2);
              s1 = SYNTAX (c1);
@@ -5032,12 +5001,12 @@ re_match_2_internal (struct re_pattern_buffer *bufp, 
re_char *string1,
 
 /* Subroutine definitions for re_match_2.  */
 
-/* Return zero if TRANSLATE[S1] and TRANSLATE[S2] are identical for LEN
-   bytes; nonzero otherwise.  */
+/* Return true if TRANSLATE[S1] and TRANSLATE[S2] are not identical
+   for LEN bytes.  */
 
-static int
+static bool
 bcmp_translate (re_char *s1, re_char *s2, ptrdiff_t len,
-               Lisp_Object translate, int target_multibyte)
+               Lisp_Object translate, bool target_multibyte)
 {
   re_char *p1 = s1, *p2 = s2;
   re_char *p1_end = s1 + len;
@@ -5055,15 +5024,12 @@ bcmp_translate (re_char *s1, re_char *s2, ptrdiff_t len,
 
       if (RE_TRANSLATE (translate, p1_ch)
          != RE_TRANSLATE (translate, p2_ch))
-       return 1;
+       return true;
 
       p1 += p1_charlen, p2 += p2_charlen;
     }
 
-  if (p1 != p1_end || p2 != p2_end)
-    return 1;
-
-  return 0;
+  return p1 != p1_end || p2 != p2_end;
 }
 
 /* Entry points for GNU code.  */
@@ -5078,17 +5044,14 @@ bcmp_translate (re_char *s1, re_char *s2, ptrdiff_t len,
    We call regex_compile to do the actual compilation.  */
 
 const char *
-re_compile_pattern (const char *pattern, size_t length,
+re_compile_pattern (const char *pattern, ptrdiff_t length,
                    bool posix_backtracking, const char *whitespace_regexp,
                    struct re_pattern_buffer *bufp)
 {
-  reg_errcode_t ret;
-
-  /* GNU code is written to assume at least RE_NREGS registers will be set
-     (and at least one extra will be -1).  */
   bufp->regs_allocated = REGS_UNALLOCATED;
 
-  ret = regex_compile ((re_char *) pattern, length,
+  reg_errcode_t ret
+      = regex_compile ((re_char *) pattern, length,
                       posix_backtracking,
                       whitespace_regexp,
                       bufp);
diff --git a/src/regex-emacs.h b/src/regex-emacs.h
index a849cbe..ddf14e0 100644
--- a/src/regex-emacs.h
+++ b/src/regex-emacs.h
@@ -1,7 +1,7 @@
 /* Emacs regular expression API
 
-   Copyright (C) 1985, 1989-1993, 1995, 2000-2018 Free Software
-   Foundation, Inc.
+   Copyright (C) 1985, 1989-1993, 1995, 2000-2019 Free Software Foundation,
+   Inc.
 
    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
@@ -26,7 +26,7 @@
    uses struct re_registers.  */
 struct re_registers
 {
-  unsigned num_regs;
+  ptrdiff_t num_regs;
   ptrdiff_t *start;
   ptrdiff_t *end;
 };
@@ -50,7 +50,7 @@ struct re_registers
 extern Lisp_Object re_match_object;
 
 /* Roughly the maximum number of failure points on the stack.  */
-extern size_t emacs_re_max_failures;
+extern ptrdiff_t emacs_re_max_failures;
 
 /* Amount of memory that we can safely stack allocate.  */
 extern ptrdiff_t emacs_re_safe_alloca;
@@ -69,10 +69,10 @@ struct re_pattern_buffer
   unsigned char *buffer;
 
        /* Number of bytes to which 'buffer' points.  */
-  size_t allocated;
+  ptrdiff_t allocated;
 
        /* Number of bytes actually used in 'buffer'.  */
-  size_t used;
+  ptrdiff_t used;
 
         /* Charset of unibyte characters at compiling time.  */
   int charset_unibyte;
@@ -89,35 +89,35 @@ struct re_pattern_buffer
   Lisp_Object translate;
 
        /* Number of subexpressions found by the compiler.  */
-  size_t re_nsub;
+  ptrdiff_t re_nsub;
 
         /* True if and only if this pattern can match the empty string.
            Well, in truth it's used only in 're_search_2', to see
            whether or not we should use the fastmap, so we don't set
            this absolutely perfectly; see 're_compile_fastmap'.  */
-  unsigned can_be_null : 1;
+  bool_bf can_be_null : 1;
 
         /* If REGS_UNALLOCATED, allocate space in the 'regs' structure
-             for 'max (RE_NREGS, re_nsub + 1)' groups.
+             for at least (re_nsub + 1) groups.
            If REGS_REALLOCATE, reallocate space if necessary.
            If REGS_FIXED, use what's there.  */
   unsigned regs_allocated : 2;
 
         /* Set to false when 'regex_compile' compiles a pattern; set to true
            by 're_compile_fastmap' if it updates the fastmap.  */
-  unsigned fastmap_accurate : 1;
+  bool_bf fastmap_accurate : 1;
 
   /* If true, the compilation of the pattern had to look up the syntax table,
      so the compiled pattern is valid for the current syntax table only.  */
-  unsigned used_syntax : 1;
+  bool_bf used_syntax : 1;
 
   /* If true, multi-byte form in the regexp pattern should be
      recognized as a multibyte character.  */
-  unsigned multibyte : 1;
+  bool_bf multibyte : 1;
 
   /* If true, multi-byte form in the target of match should be
      recognized as a multibyte character.  */
-  unsigned target_multibyte : 1;
+  bool_bf target_multibyte : 1;
 };
 
 /* Declarations for routines.  */
@@ -125,7 +125,7 @@ struct re_pattern_buffer
 /* Compile the regular expression PATTERN, with length LENGTH
    and syntax given by the global 're_syntax_options', into the buffer
    BUFFER.  Return NULL if successful, and an error string if not.  */
-extern const char *re_compile_pattern (const char *pattern, size_t length,
+extern const char *re_compile_pattern (const char *pattern, ptrdiff_t length,
                                       bool posix_backtracking,
                                       const char *whitespace_regexp,
                                       struct re_pattern_buffer *buffer);
@@ -137,7 +137,7 @@ extern const char *re_compile_pattern (const char *pattern, 
size_t length,
    match, or -2 for an internal error.  Also return register
    information in REGS (if REGS is non-null).  */
 extern ptrdiff_t re_search (struct re_pattern_buffer *buffer,
-                          const char *string, size_t length,
+                          const char *string, ptrdiff_t length,
                           ptrdiff_t start, ptrdiff_t range,
                           struct re_registers *regs);
 
@@ -145,8 +145,8 @@ extern ptrdiff_t re_search (struct re_pattern_buffer 
*buffer,
 /* Like 're_search', but search in the concatenation of STRING1 and
    STRING2.  Also, stop searching at index START + STOP.  */
 extern ptrdiff_t re_search_2 (struct re_pattern_buffer *buffer,
-                            const char *string1, size_t length1,
-                            const char *string2, size_t length2,
+                            const char *string1, ptrdiff_t length1,
+                            const char *string2, ptrdiff_t length2,
                             ptrdiff_t start, ptrdiff_t range,
                             struct re_registers *regs,
                             ptrdiff_t stop);
@@ -155,8 +155,8 @@ extern ptrdiff_t re_search_2 (struct re_pattern_buffer 
*buffer,
 /* Like 're_search_2', but return how many characters in STRING the regexp
    in BUFFER matched, starting at position START.  */
 extern ptrdiff_t re_match_2 (struct re_pattern_buffer *buffer,
-                           const char *string1, size_t length1,
-                           const char *string2, size_t length2,
+                           const char *string1, ptrdiff_t length1,
+                           const char *string2, ptrdiff_t length2,
                            ptrdiff_t start, struct re_registers *regs,
                            ptrdiff_t stop);
 
@@ -175,7 +175,7 @@ extern ptrdiff_t re_match_2 (struct re_pattern_buffer 
*buffer,
    freeing the old data.  */
 extern void re_set_registers (struct re_pattern_buffer *buffer,
                              struct re_registers *regs,
-                             unsigned num_regs,
+                             ptrdiff_t num_regs,
                              ptrdiff_t *starts, ptrdiff_t *ends);
 
 /* Character classes.  */
@@ -192,6 +192,6 @@ typedef enum { RECC_ERROR = 0,
 
 extern bool re_iswctype (int ch, re_wctype_t cc);
 extern re_wctype_t re_wctype_parse (const unsigned char **strp,
-                                   unsigned limit);
+                                   ptrdiff_t limit);
 
 #endif /* EMACS_REGEX_H */
diff --git a/src/region-cache.c b/src/region-cache.c
index f92654c..d2e3d94 100644
--- a/src/region-cache.c
+++ b/src/region-cache.c
@@ -1,6 +1,6 @@
 /* Caching facts about regions of the buffer, for optimization.
 
-Copyright (C) 1985-1989, 1993, 1995, 2001-2018 Free Software Foundation,
+Copyright (C) 1985-1989, 1993, 1995, 2001-2019 Free Software Foundation,
 Inc.
 
 This file is part of GNU Emacs.
diff --git a/src/region-cache.h b/src/region-cache.h
index 4e2d5cc..c528f78 100644
--- a/src/region-cache.h
+++ b/src/region-cache.h
@@ -1,6 +1,6 @@
 /* Header file: Caching facts about regions of the buffer, for optimization.
 
-Copyright (C) 1985-1986, 1993, 1995, 2001-2018 Free Software Foundation,
+Copyright (C) 1985-1986, 1993, 1995, 2001-2019 Free Software Foundation,
 Inc.
 
 This file is part of GNU Emacs.
diff --git a/src/scroll.c b/src/scroll.c
index 5d0f320..8eda510 100644
--- a/src/scroll.c
+++ b/src/scroll.c
@@ -1,6 +1,6 @@
 /* Calculate what line insertion or deletion to do, and do it
 
-Copyright (C) 1985-1986, 1990, 1993-1994, 2001-2018 Free Software
+Copyright (C) 1985-1986, 1990, 1993-1994, 2001-2019 Free Software
 Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -107,10 +107,8 @@ calculate_scrolling (struct frame *frame,
   /* Discourage long scrolls on fast lines.
      Don't scroll nearly a full frame height unless it saves
      at least 1/4 second.  */
-  int extra_cost = baud_rate / (10 * 4 * frame_total_lines);
-
-  if (baud_rate <= 0)
-    extra_cost = 1;
+  int extra_cost
+    = clip_to_bounds (1, baud_rate / (10 * 4) / frame_total_lines, INT_MAX / 
2);
 
   /* initialize the top left corner of the matrix */
   matrix->writecost = 0;
@@ -446,10 +444,8 @@ calculate_direct_scrolling (struct frame *frame,
   /* Discourage long scrolls on fast lines.
      Don't scroll nearly a full frame height unless it saves
      at least 1/4 second.  */
-  int extra_cost = baud_rate / (10 * 4 * frame_total_lines);
-
-  if (baud_rate <= 0)
-    extra_cost = 1;
+  int extra_cost
+    = clip_to_bounds (1, baud_rate / (10 * 4) / frame_total_lines, INT_MAX / 
2);
 
   /* Overhead of setting the scroll window, plus the extra
      cost of scrolling by a distance of one.  The extra cost is
diff --git a/src/search.c b/src/search.c
index f5c7719..dfbae5c 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1,6 +1,6 @@
 /* String search routines for GNU Emacs.
 
-Copyright (C) 1985-1987, 1993-1994, 1997-1999, 2001-2018 Free Software
+Copyright (C) 1985-1987, 1993-1994, 1997-1999, 2001-2019 Free Software
 Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -29,6 +29,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "region-cache.h"
 #include "blockinput.h"
 #include "intervals.h"
+#include "pdumper.h"
 
 #include "regex-emacs.h"
 
@@ -58,31 +59,6 @@ static struct regexp_cache searchbufs[REGEXP_CACHE_SIZE];
 /* The head of the linked list; points to the most recently used buffer.  */
 static struct regexp_cache *searchbuf_head;
 
-
-/* Every call to re_search, etc., must pass &search_regs as the regs
-   argument unless you can show it is unnecessary (i.e., if re_search
-   is certainly going to be called again before region-around-match
-   can be called).
-
-   Since the registers are now dynamically allocated, we need to make
-   sure not to refer to the Nth register before checking that it has
-   been allocated by checking search_regs.num_regs.
-
-   The regex code keeps track of whether it has allocated the search
-   buffer using bits in the re_pattern_buffer.  This means that whenever
-   you compile a new pattern, it completely forgets whether it has
-   allocated any registers, and will allocate new registers the next
-   time you call a searching or matching function.  Therefore, we need
-   to call re_set_registers after compiling a new pattern or after
-   setting the match registers, so that the regex functions will be
-   able to free or re-allocate it properly.  */
-/* static struct re_registers search_regs; */
-
-/* The buffer in which the last search was performed, or
-   Qt if the last search was done in a string;
-   Qnil if no searching has been done yet.  */
-/* static Lisp_Object last_thing_searched; */
-
 static void set_search_regs (ptrdiff_t, ptrdiff_t);
 static void save_search_regs (void);
 static EMACS_INT simple_search (EMACS_INT, unsigned char *, ptrdiff_t,
@@ -97,7 +73,7 @@ static EMACS_INT search_buffer (Lisp_Object, ptrdiff_t, 
ptrdiff_t,
 
 Lisp_Object re_match_object;
 
-static _Noreturn void
+static AVOID
 matcher_overflow (void)
 {
   error ("Stack overflow in regexp matcher");
@@ -222,11 +198,13 @@ static struct regexp_cache *
 compile_pattern (Lisp_Object pattern, struct re_registers *regp,
                 Lisp_Object translate, bool posix, bool multibyte)
 {
-  struct regexp_cache *cp, **cpp;
+  struct regexp_cache *cp, **cpp, **lru_nonbusy;
 
-  for (cpp = &searchbuf_head; ; cpp = &cp->next)
+  for (cpp = &searchbuf_head, lru_nonbusy = NULL; ; cpp = &cp->next)
     {
       cp = *cpp;
+      if (!cp->busy)
+        lru_nonbusy = cpp;
       /* Entries are initialized to nil, and may be set to nil by
         compile_pattern_1 if the pattern isn't valid.  Don't apply
         string accessors in those cases.  However, compile_pattern_1
@@ -246,13 +224,14 @@ compile_pattern (Lisp_Object pattern, struct re_registers 
*regp,
          && cp->buf.charset_unibyte == charset_unibyte)
        break;
 
-      /* If we're at the end of the cache, compile into the nil cell
-        we found, or the last (least recently used) cell with a
-        string value.  */
+      /* If we're at the end of the cache, compile into the last
+        (least recently used) non-busy cell in the cache.  */
       if (cp->next == 0)
        {
-          if (cp->busy)
+          if (!lru_nonbusy)
             error ("Too much matching reentrancy");
+          cpp = lru_nonbusy;
+          cp = *cpp;
        compile_it:
           eassert (!cp->busy);
          compile_pattern_1 (cp, pattern, translate, posix);
@@ -340,7 +319,10 @@ looking_at_1 (Lisp_Object string, bool posix)
                  ZV_BYTE - BEGV_BYTE);
 
   if (i == -2)
-    matcher_overflow ();
+    {
+      unbind_to (count, Qnil);
+      matcher_overflow ();
+    }
 
   val = (i >= 0 ? Qt : Qnil);
   if (preserve_match_data && i >= 0)
@@ -646,14 +628,16 @@ newline_cache_on_off (struct buffer *buf)
    If COUNT is zero, do anything you please; run rogue, for all I care.
 
    If END is zero, use BEGV or ZV instead, as appropriate for the
-   direction indicated by COUNT.
+   direction indicated by COUNT.  If START_BYTE is -1 it is unknown,
+   and similarly for END_BYTE.
 
-   If we find COUNT instances, set *SHORTAGE to zero, and return the
+   If we find COUNT instances, set *COUNTED to COUNT, and return the
    position past the COUNTth match.  Note that for reverse motion
    this is not the same as the usual convention for Emacs motion commands.
 
-   If we don't find COUNT instances before reaching END, set *SHORTAGE
-   to the number of newlines left unfound, and return END.
+   If we don't find COUNT instances before reaching END, set *COUNTED
+   to the number of newlines left found (negated if COUNT is negative),
+   and return END.
 
    If BYTEPOS is not NULL, set *BYTEPOS to the byte position corresponding
    to the returned character position.
@@ -663,23 +647,17 @@ newline_cache_on_off (struct buffer *buf)
 
 ptrdiff_t
 find_newline (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
-             ptrdiff_t end_byte, ptrdiff_t count, ptrdiff_t *shortage,
+             ptrdiff_t end_byte, ptrdiff_t count, ptrdiff_t *counted,
              ptrdiff_t *bytepos, bool allow_quit)
 {
   struct region_cache *newline_cache;
-  int direction;
   struct buffer *cache_buffer;
 
-  if (count > 0)
+  if (!end)
     {
-      direction = 1;
-      if (!end)
+      if (count > 0)
        end = ZV, end_byte = ZV_BYTE;
-    }
-  else
-    {
-      direction = -1;
-      if (!end)
+      else
        end = BEGV, end_byte = BEGV_BYTE;
     }
   if (end_byte == -1)
@@ -691,8 +669,8 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, 
ptrdiff_t end,
   else
     cache_buffer = current_buffer;
 
-  if (shortage != 0)
-    *shortage = 0;
+  if (counted)
+    *counted = count;
 
   if (count > 0)
     while (start != end)
@@ -935,8 +913,8 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, 
ptrdiff_t end,
         }
       }
 
-  if (shortage)
-    *shortage = count * direction;
+  if (counted)
+    *counted -= count;
   if (bytepos)
     {
       *bytepos = start_byte == -1 ? CHAR_TO_BYTE (start) : start_byte;
@@ -951,30 +929,28 @@ find_newline (ptrdiff_t start, ptrdiff_t start_byte, 
ptrdiff_t end,
    We report the resulting position by calling TEMP_SET_PT_BOTH.
 
    If we find COUNT instances. we position after (always after,
-   even if scanning backwards) the COUNTth match, and return 0.
+   even if scanning backwards) the COUNTth match.
 
    If we don't find COUNT instances before reaching the end of the
-   buffer (or the beginning, if scanning backwards), we return
-   the number of line boundaries left unfound, and position at
+   buffer (or the beginning, if scanning backwards), we position at
    the limit we bumped up against.
 
    If ALLOW_QUIT, check for quitting.  That's good to do
    except in special cases.  */
 
-ptrdiff_t
+void
 scan_newline (ptrdiff_t start, ptrdiff_t start_byte,
              ptrdiff_t limit, ptrdiff_t limit_byte,
              ptrdiff_t count, bool allow_quit)
 {
-  ptrdiff_t charpos, bytepos, shortage;
+  ptrdiff_t charpos, bytepos, counted;
 
   charpos = find_newline (start, start_byte, limit, limit_byte,
-                         count, &shortage, &bytepos, allow_quit);
-  if (shortage)
+                         count, &counted, &bytepos, allow_quit);
+  if (counted != count)
     TEMP_SET_PT_BOTH (limit, limit_byte);
   else
     TEMP_SET_PT_BOTH (charpos, bytepos);
-  return shortage;
 }
 
 /* Like above, but always scan from point and report the
@@ -984,19 +960,19 @@ ptrdiff_t
 scan_newline_from_point (ptrdiff_t count, ptrdiff_t *charpos,
                         ptrdiff_t *bytepos)
 {
-  ptrdiff_t shortage;
+  ptrdiff_t counted;
 
   if (count <= 0)
     *charpos = find_newline (PT, PT_BYTE, BEGV, BEGV_BYTE, count - 1,
-                            &shortage, bytepos, 1);
+                            &counted, bytepos, 1);
   else
     *charpos = find_newline (PT, PT_BYTE, ZV, ZV_BYTE, count,
-                            &shortage, bytepos, 1);
-  return shortage;
+                            &counted, bytepos, 1);
+  return counted;
 }
 
 /* Like find_newline, but doesn't allow QUITting and doesn't return
-   SHORTAGE.  */
+   COUNTED.  */
 ptrdiff_t
 find_newline_no_quit (ptrdiff_t from, ptrdiff_t frombyte,
                      ptrdiff_t cnt, ptrdiff_t *bytepos)
@@ -1012,10 +988,10 @@ ptrdiff_t
 find_before_next_newline (ptrdiff_t from, ptrdiff_t to,
                          ptrdiff_t cnt, ptrdiff_t *bytepos)
 {
-  ptrdiff_t shortage;
-  ptrdiff_t pos = find_newline (from, -1, to, -1, cnt, &shortage, bytepos, 1);
+  ptrdiff_t counted;
+  ptrdiff_t pos = find_newline (from, -1, to, -1, cnt, &counted, bytepos, 1);
 
-  if (shortage == 0)
+  if (counted == cnt)
     {
       if (bytepos)
        DEC_BOTH (pos, *bytepos);
@@ -1225,6 +1201,7 @@ search_buffer_re (Lisp_Object string, ptrdiff_t pos, 
ptrdiff_t pos_byte,
                          pos_byte - BEGV_BYTE);
       if (val == -2)
         {
+          unbind_to (count, Qnil);
           matcher_overflow ();
         }
       if (val >= 0)
@@ -1270,6 +1247,7 @@ search_buffer_re (Lisp_Object string, ptrdiff_t pos, 
ptrdiff_t pos_byte,
                          lim_byte - BEGV_BYTE);
       if (val == -2)
         {
+          unbind_to (count, Qnil);
           matcher_overflow ();
         }
       if (val >= 0)
@@ -2768,7 +2746,7 @@ since only regular expressions have distinguished 
subexpressions.  */)
      error out since otherwise this will result in confusing bugs.  */
   ptrdiff_t sub_start = search_regs.start[sub];
   ptrdiff_t sub_end = search_regs.end[sub];
-  unsigned  num_regs = search_regs.num_regs;
+  ptrdiff_t num_regs = search_regs.num_regs;
   newpoint = search_regs.start[sub] + SCHARS (newtext);
 
   /* Replace the old text with the new in the cleanest possible way.  */
@@ -2992,13 +2970,11 @@ If optional arg RESEAT is non-nil, make markers on LIST 
point nowhere.  */)
 
   /* Allocate registers if they don't already exist.  */
   {
-    EMACS_INT length = XFIXNAT (Flength (list)) / 2;
+    ptrdiff_t length = list_length (list) / 2;
 
     if (length > search_regs.num_regs)
       {
        ptrdiff_t num_regs = search_regs.num_regs;
-       if (PTRDIFF_MAX < length)
-         memory_full (SIZE_MAX);
        search_regs.start =
          xpalloc (search_regs.start, &num_regs, length - num_regs,
                   min (PTRDIFF_MAX, UINT_MAX), sizeof *search_regs.start);
@@ -3086,29 +3062,19 @@ If optional arg RESEAT is non-nil, make markers on LIST 
point nowhere.  */)
   return Qnil;
 }
 
-/* If true the match data have been saved in saved_search_regs
-   during the execution of a sentinel or filter. */
-/* static bool search_regs_saved; */
-/* static struct re_registers saved_search_regs; */
-/* static Lisp_Object saved_last_thing_searched; */
-
 /* Called from Flooking_at, Fstring_match, search_buffer, Fstore_match_data
    if asynchronous code (filter or sentinel) is running. */
 static void
 save_search_regs (void)
 {
-  if (!search_regs_saved)
+  if (saved_search_regs.num_regs == 0)
     {
-      saved_search_regs.num_regs = search_regs.num_regs;
-      saved_search_regs.start = search_regs.start;
-      saved_search_regs.end = search_regs.end;
+      saved_search_regs = search_regs;
       saved_last_thing_searched = last_thing_searched;
       last_thing_searched = Qnil;
       search_regs.num_regs = 0;
       search_regs.start = 0;
       search_regs.end = 0;
-
-      search_regs_saved = 1;
     }
 }
 
@@ -3116,19 +3082,17 @@ save_search_regs (void)
 void
 restore_search_regs (void)
 {
-  if (search_regs_saved)
+  if (saved_search_regs.num_regs != 0)
     {
       if (search_regs.num_regs > 0)
        {
          xfree (search_regs.start);
          xfree (search_regs.end);
        }
-      search_regs.num_regs = saved_search_regs.num_regs;
-      search_regs.start = saved_search_regs.start;
-      search_regs.end = saved_search_regs.end;
+      search_regs = saved_search_regs;
       last_thing_searched = saved_last_thing_searched;
       saved_last_thing_searched = Qnil;
-      search_regs_saved = 0;
+      saved_search_regs.num_regs = 0;
     }
 }
 
@@ -3211,7 +3175,7 @@ DEFUN ("regexp-quote", Fregexp_quote, Sregexp_quote, 1, 
1, 0,
 /* Like find_newline, but doesn't use the cache, and only searches forward.  */
 static ptrdiff_t
 find_newline1 (ptrdiff_t start, ptrdiff_t start_byte, ptrdiff_t end,
-              ptrdiff_t end_byte, ptrdiff_t count, ptrdiff_t *shortage,
+              ptrdiff_t end_byte, ptrdiff_t count, ptrdiff_t *counted,
               ptrdiff_t *bytepos, bool allow_quit)
 {
   if (count > 0)
@@ -3227,8 +3191,8 @@ find_newline1 (ptrdiff_t start, ptrdiff_t start_byte, 
ptrdiff_t end,
   if (end_byte == -1)
     end_byte = CHAR_TO_BYTE (end);
 
-  if (shortage != 0)
-    *shortage = 0;
+  if (counted)
+    *counted = count;
 
   if (count > 0)
     while (start != end)
@@ -3285,8 +3249,8 @@ find_newline1 (ptrdiff_t start, ptrdiff_t start_byte, 
ptrdiff_t end,
         }
       }
 
-  if (shortage)
-    *shortage = count;
+  if (counted)
+    *counted -= count;
   if (bytepos)
     {
       *bytepos = start_byte == -1 ? CHAR_TO_BYTE (start) : start_byte;
@@ -3307,7 +3271,7 @@ the buffer.  If the buffer doesn't have a cache, the 
value is nil.  */)
   (Lisp_Object buffer)
 {
   struct buffer *buf, *old = NULL;
-  ptrdiff_t shortage, nl_count_cache, nl_count_buf;
+  ptrdiff_t nl_count_cache, nl_count_buf;
   Lisp_Object cache_newlines, buf_newlines, val;
   ptrdiff_t from, found, i;
 
@@ -3333,8 +3297,7 @@ the buffer.  If the buffer doesn't have a cache, the 
value is nil.  */)
 
   /* How many newlines are there according to the cache?  */
   find_newline (BEGV, BEGV_BYTE, ZV, ZV_BYTE,
-               TYPE_MAXIMUM (ptrdiff_t), &shortage, NULL, true);
-  nl_count_cache = TYPE_MAXIMUM (ptrdiff_t) - shortage;
+               TYPE_MAXIMUM (ptrdiff_t), &nl_count_cache, NULL, true);
 
   /* Create vector and populate it.  */
   cache_newlines = make_uninit_vector (nl_count_cache);
@@ -3343,11 +3306,11 @@ the buffer.  If the buffer doesn't have a cache, the 
value is nil.  */)
     {
       for (from = BEGV, found = from, i = 0; from < ZV; from = found, i++)
        {
-         ptrdiff_t from_byte = CHAR_TO_BYTE (from);
+         ptrdiff_t from_byte = CHAR_TO_BYTE (from), counted;
 
-         found = find_newline (from, from_byte, 0, -1, 1, &shortage,
+         found = find_newline (from, from_byte, 0, -1, 1, &counted,
                                NULL, true);
-         if (shortage != 0 || i >= nl_count_cache)
+         if (counted == 0 || i >= nl_count_cache)
            break;
          ASET (cache_newlines, i, make_fixnum (found - 1));
        }
@@ -3358,18 +3321,17 @@ the buffer.  If the buffer doesn't have a cache, the 
value is nil.  */)
 
   /* Now do the same, but without using the cache.  */
   find_newline1 (BEGV, BEGV_BYTE, ZV, ZV_BYTE,
-                TYPE_MAXIMUM (ptrdiff_t), &shortage, NULL, true);
-  nl_count_buf = TYPE_MAXIMUM (ptrdiff_t) - shortage;
+                TYPE_MAXIMUM (ptrdiff_t), &nl_count_buf, NULL, true);
   buf_newlines = make_uninit_vector (nl_count_buf);
   if (nl_count_buf)
     {
       for (from = BEGV, found = from, i = 0; from < ZV; from = found, i++)
        {
-         ptrdiff_t from_byte = CHAR_TO_BYTE (from);
+         ptrdiff_t from_byte = CHAR_TO_BYTE (from), counted;
 
-         found = find_newline1 (from, from_byte, 0, -1, 1, &shortage,
+         found = find_newline1 (from, from_byte, 0, -1, 1, &counted,
                                 NULL, true);
-         if (shortage != 0 || i >= nl_count_buf)
+         if (counted == 0 || i >= nl_count_buf)
            break;
          ASET (buf_newlines, i, make_fixnum (found - 1));
        }
@@ -3388,26 +3350,17 @@ the buffer.  If the buffer doesn't have a cache, the 
value is nil.  */)
 }
 
 
+static void syms_of_search_for_pdumper (void);
+
 void
 syms_of_search (void)
 {
-  register int i;
-
-  for (i = 0; i < REGEXP_CACHE_SIZE; ++i)
+  for (int i = 0; i < REGEXP_CACHE_SIZE; ++i)
     {
-      searchbufs[i].buf.allocated = 100;
-      searchbufs[i].buf.buffer = xmalloc (100);
-      searchbufs[i].buf.fastmap = searchbufs[i].fastmap;
-      searchbufs[i].regexp = Qnil;
-      searchbufs[i].f_whitespace_regexp = Qnil;
-      searchbufs[i].busy = false;
-      searchbufs[i].syntax_table = Qnil;
       staticpro (&searchbufs[i].regexp);
       staticpro (&searchbufs[i].f_whitespace_regexp);
       staticpro (&searchbufs[i].syntax_table);
-      searchbufs[i].next = (i == REGEXP_CACHE_SIZE-1 ? 0 : &searchbufs[i+1]);
     }
-  searchbuf_head = &searchbufs[0];
 
   /* Error condition used for failing searches.  */
   DEFSYM (Qsearch_failed, "search-failed");
@@ -3420,27 +3373,20 @@ syms_of_search (void)
   DEFSYM (Qinvalid_regexp, "invalid-regexp");
 
   Fput (Qsearch_failed, Qerror_conditions,
-       listn (CONSTYPE_PURE, 2, Qsearch_failed, Qerror));
+       pure_list (Qsearch_failed, Qerror));
   Fput (Qsearch_failed, Qerror_message,
        build_pure_c_string ("Search failed"));
 
   Fput (Quser_search_failed, Qerror_conditions,
-        listn (CONSTYPE_PURE, 4,
-               Quser_search_failed, Quser_error, Qsearch_failed, Qerror));
+       pure_list (Quser_search_failed, Quser_error, Qsearch_failed, Qerror));
   Fput (Quser_search_failed, Qerror_message,
         build_pure_c_string ("Search failed"));
 
   Fput (Qinvalid_regexp, Qerror_conditions,
-       listn (CONSTYPE_PURE, 2, Qinvalid_regexp, Qerror));
+       pure_list (Qinvalid_regexp, Qerror));
   Fput (Qinvalid_regexp, Qerror_message,
        build_pure_c_string ("Invalid regexp"));
 
-  last_thing_searched = Qnil;
-  staticpro (&last_thing_searched);
-
-  saved_last_thing_searched = Qnil;
-  staticpro (&saved_last_thing_searched);
-
   re_match_object = Qnil;
   staticpro (&re_match_object);
 
@@ -3478,4 +3424,23 @@ is to bind it with `let' around a small expression.  */);
   defsubr (&Sset_match_data);
   defsubr (&Sregexp_quote);
   defsubr (&Snewline_cache_check);
+
+  pdumper_do_now_and_after_load (syms_of_search_for_pdumper);
+}
+
+static void
+syms_of_search_for_pdumper (void)
+{
+  for (int i = 0; i < REGEXP_CACHE_SIZE; ++i)
+    {
+      searchbufs[i].buf.allocated = 100;
+      searchbufs[i].buf.buffer = xmalloc (100);
+      searchbufs[i].buf.fastmap = searchbufs[i].fastmap;
+      searchbufs[i].regexp = Qnil;
+      searchbufs[i].f_whitespace_regexp = Qnil;
+      searchbufs[i].busy = false;
+      searchbufs[i].syntax_table = Qnil;
+      searchbufs[i].next = (i == REGEXP_CACHE_SIZE-1 ? 0 : &searchbufs[i+1]);
+    }
+  searchbuf_head = &searchbufs[0];
 }
diff --git a/src/sheap.c b/src/sheap.c
index 882cb02..015ee57 100644
--- a/src/sheap.c
+++ b/src/sheap.c
@@ -1,7 +1,7 @@
 /* simulate `sbrk' with an array in .bss, for `unexec' support for Cygwin;
    complete rewrite of xemacs Cygwin `unexec' code
 
-   Copyright (C) 2004-2018 Free Software Foundation, Inc.
+   Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -31,7 +31,6 @@ static int debug_sheap;
 
 char bss_sbrk_buffer[STATIC_HEAP_SIZE];
 char *max_bss_sbrk_ptr;
-bool bss_sbrk_did_unexec;
 
 void *
 bss_sbrk (ptrdiff_t request_size)
diff --git a/src/sheap.h b/src/sheap.h
index e17fd52..a565328 100644
--- a/src/sheap.h
+++ b/src/sheap.h
@@ -1,6 +1,6 @@
 /* Static heap allocation for GNU Emacs.
 
-Copyright 2016-2018 Free Software Foundation, Inc.
+Copyright 2016-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -27,5 +27,4 @@ enum { STATIC_HEAP_SIZE = sizeof (Lisp_Object) << 22 };
 
 extern char bss_sbrk_buffer[STATIC_HEAP_SIZE];
 extern char *max_bss_sbrk_ptr;
-extern bool bss_sbrk_did_unexec;
 extern void *bss_sbrk (ptrdiff_t);
diff --git a/src/sound.c b/src/sound.c
index 6f15f5d..4ba826e 100644
--- a/src/sound.c
+++ b/src/sound.c
@@ -1,6 +1,6 @@
 /* sound.c -- sound support.
 
-Copyright (C) 1998-1999, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1998-1999, 2001-2019 Free Software Foundation, Inc.
 
 Author: Gerd Moellmann <address@hidden>
 
@@ -297,7 +297,7 @@ static int do_play_sound (const char *, unsigned long);
 #ifndef WINDOWSNT
 /* Like perror, but signals an error.  */
 
-static _Noreturn void
+static AVOID
 sound_perror (const char *msg)
 {
   int saved_errno = errno;
@@ -874,7 +874,7 @@ vox_write (struct sound_device *sd, const char *buffer, 
ptrdiff_t nbytes)
 #define DEFAULT_ALSA_SOUND_DEVICE "default"
 #endif
 
-static _Noreturn void
+static AVOID
 alsa_sound_perror (const char *msg, int err)
 {
   error ("%s: %s", msg, snd_strerror (err));
diff --git a/src/syntax.c b/src/syntax.c
index 432d82c..edfdae2 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -1,5 +1,5 @@
 /* GNU Emacs routines to deal with syntax tables; also word and list parsing.
-   Copyright (C) 1985, 1987, 1993-1995, 1997-1999, 2001-2018 Free
+   Copyright (C) 1985, 1987, 1993-1995, 1997-1999, 2001-2019 Free
    Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -175,7 +175,7 @@ static ptrdiff_t find_start_value;
 static ptrdiff_t find_start_value_byte;
 static struct buffer *find_start_buffer;
 static ptrdiff_t find_start_begv;
-static EMACS_INT find_start_modiff;
+static modiff_count find_start_modiff;
 
 
 static Lisp_Object skip_chars (bool, Lisp_Object, Lisp_Object, bool);
@@ -309,7 +309,7 @@ SETUP_SYNTAX_TABLE_FOR_OBJECT (Lisp_Object object,
 }
 
 /* Update gl_state to an appropriate interval which contains CHARPOS.  The
-   sign of COUNT give the relative position of CHARPOS wrt the previously
+   sign of COUNT gives the relative position of CHARPOS wrt the previously
    valid interval.  If INIT, only [be]_property fields of gl_state are
    valid at start, the rest is filled basing on OBJECT.
 
@@ -340,59 +340,46 @@ update_syntax_table (ptrdiff_t charpos, EMACS_INT count, 
bool init,
       invalidate = false;
       if (!i)
        return;
-      /* interval_of updates only ->position of the return value, so
-        update the parents manually to speed up update_interval.  */
-      while (!NULL_PARENT (i))
-       {
-         if (AM_RIGHT_CHILD (i))
-           INTERVAL_PARENT (i)->position = i->position
-             - LEFT_TOTAL_LENGTH (i) + TOTAL_LENGTH (i) /* right end */
-             - TOTAL_LENGTH (INTERVAL_PARENT (i))
-             + LEFT_TOTAL_LENGTH (INTERVAL_PARENT (i));
-         else
-           INTERVAL_PARENT (i)->position = i->position - LEFT_TOTAL_LENGTH (i)
-             + TOTAL_LENGTH (i);
-         i = INTERVAL_PARENT (i);
-       }
       i = gl_state.forward_i;
       gl_state.b_property = i->position - gl_state.offset;
       gl_state.e_property = INTERVAL_LAST_POS (i) - gl_state.offset;
-      goto update;
-    }
-  i = count > 0 ? gl_state.forward_i : gl_state.backward_i;
-
-  /* We are guaranteed to be called with CHARPOS either in i,
-     or further off.  */
-  if (!i)
-    error ("Error in syntax_table logic for to-the-end intervals");
-  else if (charpos < i->position)              /* Move left.  */
-    {
-      if (count > 0)
-       error ("Error in syntax_table logic for intervals <-");
-      /* Update the interval.  */
-      i = update_interval (i, charpos);
-      if (INTERVAL_LAST_POS (i) != gl_state.b_property)
-       {
-         invalidate = false;
-         gl_state.forward_i = i;
-         gl_state.e_property = INTERVAL_LAST_POS (i) - gl_state.offset;
-       }
     }
-  else if (charpos >= INTERVAL_LAST_POS (i)) /* Move right.  */
+  else
     {
-      if (count < 0)
-       error ("Error in syntax_table logic for intervals ->");
-      /* Update the interval.  */
-      i = update_interval (i, charpos);
-      if (i->position != gl_state.e_property)
-       {
-         invalidate = false;
-         gl_state.backward_i = i;
-         gl_state.b_property = i->position - gl_state.offset;
-       }
+      i = count > 0 ? gl_state.forward_i : gl_state.backward_i;
+
+      /* We are guaranteed to be called with CHARPOS either in i,
+         or further off.  */
+      if (!i)
+        error ("Error in syntax_table logic for to-the-end intervals");
+      else if (charpos < i->position)          /* Move left.  */
+        {
+          if (count > 0)
+           error ("Error in syntax_table logic for intervals <-");
+          /* Update the interval.  */
+          i = update_interval (i, charpos);
+          if (INTERVAL_LAST_POS (i) != gl_state.b_property)
+           {
+             invalidate = false;
+             gl_state.forward_i = i;
+             gl_state.e_property = INTERVAL_LAST_POS (i) - gl_state.offset;
+           }
+        }
+      else if (charpos >= INTERVAL_LAST_POS (i)) /* Move right.  */
+        {
+          if (count < 0)
+           error ("Error in syntax_table logic for intervals ->");
+          /* Update the interval.  */
+          i = update_interval (i, charpos);
+          if (i->position != gl_state.e_property)
+           {
+             invalidate = false;
+             gl_state.backward_i = i;
+             gl_state.b_property = i->position - gl_state.offset;
+           }
+        }
     }
 
-  update:
   tmp_table = textget (i->plist, Qsyntax_table);
 
   if (invalidate)
@@ -489,7 +476,7 @@ parse_sexp_propertize (ptrdiff_t charpos)
   if (syntax_propertize__done <= charpos
       && syntax_propertize__done < zv)
     {
-      EMACS_INT modiffs = CHARS_MODIFF;
+      modiff_count modiffs = CHARS_MODIFF;
       safe_call1 (Qinternal__syntax_propertize,
                  make_fixnum (min (zv, 1 + charpos)));
       if (modiffs != CHARS_MODIFF)
@@ -608,7 +595,7 @@ find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte)
 
   if (!NILP (Vcomment_use_syntax_ppss))
     {
-      EMACS_INT modiffs = CHARS_MODIFF;
+      modiff_count modiffs = CHARS_MODIFF;
       Lisp_Object ppss = call1 (Qsyntax_ppss, make_fixnum (pos));
       if (modiffs != CHARS_MODIFF)
        error ("syntax-ppss modified the buffer!");
@@ -3490,10 +3477,7 @@ internalize_parse_state (Lisp_Object external, struct 
lisp_parse_state *state)
   else
     {
       tem = Fcar (external);
-      if (!NILP (tem))
-       state->depth = XFIXNUM (tem);
-      else
-       state->depth = 0;
+      state->depth = FIXNUMP (tem) ? XFIXNUM (tem) : 0;
 
       external = Fcdr (external);
       external = Fcdr (external);
@@ -3730,12 +3714,9 @@ syms_of_syntax (void)
   staticpro (&gl_state.current_syntax_table);
   staticpro (&gl_state.old_prop);
 
-  /* Defined in regex-emacs.c.  */
-  staticpro (&re_match_object);
-
   DEFSYM (Qscan_error, "scan-error");
   Fput (Qscan_error, Qerror_conditions,
-       listn (CONSTYPE_PURE, 2, Qscan_error, Qerror));
+       pure_list (Qscan_error, Qerror));
   Fput (Qscan_error, Qerror_message,
        build_pure_c_string ("Scan error"));
 
diff --git a/src/syntax.h b/src/syntax.h
index d971c74..6d3851f 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -1,6 +1,6 @@
 /* Declarations having to do with GNU Emacs syntax tables.
 
-Copyright (C) 1985, 1993-1994, 1997-1998, 2001-2018 Free Software
+Copyright (C) 1985, 1993-1994, 1997-1998, 2001-2019 Free Software
 Foundation, Inc.
 
 This file is part of GNU Emacs.
diff --git a/src/sysdep.c b/src/sysdep.c
index 9901d6a..bc88e70 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -1,5 +1,5 @@
 /* Interfaces to system-dependent kernel and library entries.
-   Copyright (C) 1985-1988, 1993-1995, 1999-2018 Free Software
+   Copyright (C) 1985-1988, 1993-1995, 1999-2019 Free Software
    Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -257,12 +257,12 @@ get_current_dir_name_or_unreachable (void)
 
   char *pwd;
 
-  /* The maximum size of a directory name, including the terminating null.
+  /* The maximum size of a directory name, including the terminating NUL.
      Leave room so that the caller can append a trailing slash.  */
   ptrdiff_t dirsize_max = min (PTRDIFF_MAX, SIZE_MAX) - 1;
 
   /* The maximum size of a buffer for a file name, including the
-     terminating null.  This is bounded by MAXPATHLEN, if available.  */
+     terminating NUL.  This is bounded by MAXPATHLEN, if available.  */
   ptrdiff_t bufsize_max = dirsize_max;
 #ifdef MAXPATHLEN
   bufsize_max = min (bufsize_max, MAXPATHLEN);
@@ -270,7 +270,7 @@ get_current_dir_name_or_unreachable (void)
 
 # if HAVE_GET_CURRENT_DIR_NAME && !BROKEN_GET_CURRENT_DIR_NAME
 #  ifdef HYBRID_MALLOC
-  bool use_libc = bss_sbrk_did_unexec;
+  bool use_libc = will_dump_with_unexec_p ();
 #  else
   bool use_libc = true;
 #  endif
@@ -1805,7 +1805,7 @@ deliver_fatal_thread_signal (int sig)
   deliver_thread_signal (sig, handle_fatal_signal);
 }
 
-static _Noreturn void
+static AVOID
 handle_arith_signal (int sig)
 {
   pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
@@ -1850,8 +1850,8 @@ stack_overflow (siginfo_t *siginfo)
 
   /* The known top and bottom of the stack.  The actual stack may
      extend a bit beyond these boundaries.  */
-  char *bot = stack_bottom;
-  char *top = current_thread->stack_top;
+  char const *bot = stack_bottom;
+  char const *top = current_thread->stack_top;
 
   /* Log base 2 of the stack heuristic ratio.  This ratio is the size
      of the known stack divided by the size of the guard area past the
@@ -1908,7 +1908,10 @@ init_sigsegv (void)
   sigfillset (&sa.sa_mask);
   sa.sa_sigaction = handle_sigsegv;
   sa.sa_flags = SA_SIGINFO | SA_ONSTACK | emacs_sigaction_flags ();
-  return sigaction (SIGSEGV, &sa, NULL) < 0 ? 0 : 1;
+  if (sigaction (SIGSEGV, &sa, NULL) < 0)
+    return 0;
+
+  return 1;
 }
 
 #else /* not HAVE_STACK_OVERFLOW_HANDLING or WINDOWSNT */
@@ -1963,7 +1966,7 @@ maybe_fatal_sig (int sig)
 }
 
 void
-init_signals (bool dumping)
+init_signals (void)
 {
   struct sigaction thread_fatal_action;
   struct sigaction action;
@@ -2114,7 +2117,7 @@ init_signals (bool dumping)
   /* Don't alter signal handlers if dumping.  On some machines,
      changing signal handlers sets static data that would make signals
      fail to work right when the dumped Emacs is run.  */
-  if (dumping)
+  if (will_dump_p ())
     return;
 
   sigfillset (&process_fatal_action.sa_mask);
@@ -3432,7 +3435,7 @@ system_process_attributes (Lisp_Object pid)
 
       if (nread)
        {
-         /* We don't want trailing null characters.  */
+         /* We don't want trailing NUL characters.  */
          for (p = cmdline + nread; cmdline < p && !p[-1]; p--)
            continue;
 
diff --git a/src/sysselect.h b/src/sysselect.h
index c7bce3c..25e8f51 100644
--- a/src/sysselect.h
+++ b/src/sysselect.h
@@ -1,5 +1,5 @@
 /* sysselect.h - System-dependent definitions for the select function.
-   Copyright (C) 1995, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1995, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/syssignal.h b/src/syssignal.h
index 0887eac..82e3761 100644
--- a/src/syssignal.h
+++ b/src/syssignal.h
@@ -1,6 +1,6 @@
 /* syssignal.h - System-dependent definitions for signals.
 
-Copyright (C) 1993, 1999, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1993, 1999, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -22,7 +22,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #include <signal.h>
 
-extern void init_signals (bool);
+extern void init_signals (void);
 extern void block_child_signal (sigset_t *);
 extern void unblock_child_signal (sigset_t const *);
 extern void block_interrupt_signal (sigset_t *);
diff --git a/src/sysstdio.h b/src/sysstdio.h
index 9462338..3ff1d6a 100644
--- a/src/sysstdio.h
+++ b/src/sysstdio.h
@@ -1,6 +1,6 @@
 /* Standard I/O for Emacs.
 
-Copyright 2013-2018 Free Software Foundation, Inc.
+Copyright 2013-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/systhread.c b/src/systhread.c
index d53b5c2..6f4de53 100644
--- a/src/systhread.c
+++ b/src/systhread.c
@@ -1,5 +1,5 @@
 /* System thread definitions
-Copyright (C) 2012-2018 Free Software Foundation, Inc.
+Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/systhread.h b/src/systhread.h
index 3805cb2..8070bcd 100644
--- a/src/systhread.h
+++ b/src/systhread.h
@@ -1,5 +1,5 @@
 /* System thread definitions
-Copyright (C) 2012-2018 Free Software Foundation, Inc.
+Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -21,12 +21,8 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #include <stdbool.h>
 
-#ifndef __has_attribute
-# define __has_attribute(a) false
-#endif
-
-#if __has_attribute (__warn_unused_result__)
-# define ATTRIBUTE_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
+#if __has_attribute (warn_unused_result)
+# define ATTRIBUTE_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
 #else
 # define ATTRIBUTE_WARN_UNUSED_RESULT
 #endif
diff --git a/src/systime.h b/src/systime.h
index 0bc1e90..125b2f1 100644
--- a/src/systime.h
+++ b/src/systime.h
@@ -1,5 +1,5 @@
 /* systime.h - System-dependent definitions for time manipulations.
-   Copyright (C) 1993-1994, 2002-2018 Free Software Foundation, Inc.
+   Copyright (C) 1993-1994, 2002-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -89,11 +89,12 @@ struct lisp_time
 /* defined in timefns.c */
 extern struct timeval make_timeval (struct timespec) ATTRIBUTE_CONST;
 extern Lisp_Object make_lisp_time (struct timespec);
+extern Lisp_Object timespec_to_lisp (struct timespec);
 extern bool list4_to_timespec (Lisp_Object, Lisp_Object, Lisp_Object,
                               Lisp_Object, struct timespec *);
 extern struct timespec lisp_time_argument (Lisp_Object);
-extern _Noreturn void time_overflow (void);
-extern void init_timefns (bool);
+extern AVOID time_overflow (void);
+extern void init_timefns (void);
 extern void syms_of_timefns (void);
 
 INLINE_HEADER_END
diff --git a/src/systty.h b/src/systty.h
index b82dc6c..f2cd231 100644
--- a/src/systty.h
+++ b/src/systty.h
@@ -1,5 +1,5 @@
 /* systty.h - System-dependent definitions for terminals.
-   Copyright (C) 1993-1994, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1993-1994, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/syswait.h b/src/syswait.h
index 8f0357f..f631b71 100644
--- a/src/syswait.h
+++ b/src/syswait.h
@@ -1,5 +1,5 @@
 /* Define wait system call interface for Emacs.
-   Copyright (C) 1993-1995, 2000-2018 Free Software Foundation, Inc.
+   Copyright (C) 1993-1995, 2000-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/term.c b/src/term.c
index 3465908..6a8fc2e 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1,5 +1,5 @@
 /* Terminal control module for terminals described by TERMCAP
-   Copyright (C) 1985-1987, 1993-1995, 1998, 2000-2018 Free Software
+   Copyright (C) 1985-1987, 1993-1995, 1998, 2000-2019 Free Software
    Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -73,11 +73,10 @@ static void clear_tty_hooks (struct terminal *terminal);
 static void set_tty_hooks (struct terminal *terminal);
 static void dissociate_if_controlling_tty (int fd);
 static void delete_tty (struct terminal *);
-static _Noreturn void maybe_fatal (bool, struct terminal *,
-                                  const char *, const char *, ...)
+static AVOID maybe_fatal (bool, struct terminal *, const char *, const char *,
+                         ...)
   ATTRIBUTE_FORMAT_PRINTF (3, 5) ATTRIBUTE_FORMAT_PRINTF (4, 5);
-static _Noreturn void vfatal (const char *str, va_list ap)
-  ATTRIBUTE_FORMAT_PRINTF (1, 0);
+static AVOID vfatal (const char *, va_list) ATTRIBUTE_FORMAT_PRINTF (1, 0);
 
 
 #define OUTPUT(tty, a)                                          \
@@ -1201,7 +1200,9 @@ calculate_costs (struct frame *frame)
       calculate_ins_del_char_costs (frame);
 
       /* Don't use TS_repeat if its padding is worse than sending the chars */
-      if (tty->TS_repeat && per_line_cost (tty->TS_repeat) * baud_rate < 9000)
+      if (tty->TS_repeat
+         && (baud_rate <= 0
+             || per_line_cost (tty->TS_repeat) < 9000 / baud_rate))
         tty->RPov = string_cost (tty->TS_repeat);
       else
         tty->RPov = FRAME_COLS (frame) * 2;
@@ -1350,7 +1351,8 @@ term_get_fkeys_1 (void)
   char **address = term_get_fkeys_address;
   KBOARD *kboard = term_get_fkeys_kboard;
 
-  /* This can happen if CANNOT_DUMP or with strange options.  */
+  /* This can happen if Emacs is starting up from scratch, or with
+     strange options.  */
   if (!KEYMAPP (KVAR (kboard, Vinput_decode_map)))
     kset_input_decode_map (kboard, Fmake_sparse_keymap (Qnil));
 
@@ -2434,15 +2436,14 @@ term_mouse_movement (struct frame *frame, Gpm_Event 
*event)
   return 0;
 }
 
-/* Return the Time that corresponds to T.  Wrap around on overflow.  */
+/* Return the current time, as a Time value.  Wrap around on overflow.  */
 static Time
-timeval_to_Time (struct timeval const *t)
+current_Time (void)
 {
-  Time s_1000, ms;
-
-  s_1000 = t->tv_sec;
+  struct timespec now = current_timespec ();
+  Time s_1000 = now.tv_sec;
   s_1000 *= 1000;
-  ms = t->tv_usec / 1000;
+  Time ms = now.tv_nsec / 1000000;
   return s_1000 + ms;
 }
 
@@ -2464,8 +2465,6 @@ term_mouse_position (struct frame **fp, int insist, 
Lisp_Object *bar_window,
                     enum scroll_bar_part *part, Lisp_Object *x,
                     Lisp_Object *y, Time *timeptr)
 {
-  struct timeval now;
-
   *fp = SELECTED_FRAME ();
   (*fp)->mouse_moved = 0;
 
@@ -2474,8 +2473,7 @@ term_mouse_position (struct frame **fp, int insist, 
Lisp_Object *bar_window,
 
   XSETINT (*x, last_mouse_x);
   XSETINT (*y, last_mouse_y);
-  gettimeofday(&now, 0);
-  *timeptr = timeval_to_Time (&now);
+  *timeptr = current_Time ();
 }
 
 /* Prepare a mouse-event in *RESULT for placement in the input queue.
@@ -2487,7 +2485,6 @@ static Lisp_Object
 term_mouse_click (struct input_event *result, Gpm_Event *event,
                  struct frame *f)
 {
-  struct timeval now;
   int i, j;
 
   result->kind = GPM_CLICK_EVENT;
@@ -2498,8 +2495,7 @@ term_mouse_click (struct input_event *result, Gpm_Event 
*event,
        break;
       }
     }
-  gettimeofday(&now, 0);
-  result->timestamp = timeval_to_Time (&now);
+  result->timestamp = current_Time ();
 
   if (event->type & GPM_UP)
     result->modifiers = up_modifier;
@@ -3842,6 +3838,7 @@ clear_tty_hooks (struct terminal *terminal)
   terminal->update_begin_hook = 0;
   terminal->update_end_hook = 0;
   terminal->set_terminal_window_hook = 0;
+  terminal->defined_color_hook = 0;
   terminal->mouse_position_hook = 0;
   terminal->frame_rehighlight_hook = 0;
   terminal->frame_raise_lower_hook = 0;
@@ -3885,6 +3882,7 @@ set_tty_hooks (struct terminal *terminal)
   terminal->menu_show_hook = &tty_menu_show;
 #endif
   terminal->set_terminal_window_hook = &tty_set_terminal_window;
+  terminal->defined_color_hook = &tty_defined_color; /* xfaces.c */
   terminal->read_socket_hook = &tty_read_avail_input; /* keyboard.c */
   terminal->delete_frame_hook = &tty_free_frame_resources;
   terminal->delete_terminal_hook = &delete_tty;
diff --git a/src/termcap.c b/src/termcap.c
index 4d85323..7dc0d57 100644
--- a/src/termcap.c
+++ b/src/termcap.c
@@ -1,5 +1,5 @@
 /* Work-alike for termcap, plus extra features.
-   Copyright (C) 1985-1986, 1993-1995, 2000-2008, 2011, 2013-2018 Free
+   Copyright (C) 1985-1986, 1993-1995, 2000-2008, 2011, 2013-2019 Free
    Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify
@@ -20,10 +20,14 @@ along with this program.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 /* Emacs config.h may rename various library functions such as malloc.  */
 #include <config.h>
+
+#include <stdlib.h>
 #include <sys/file.h>
 #include <fcntl.h>
 #include <unistd.h>
 
+#include <intprops.h>
+
 #include "lisp.h"
 #include "tparam.h"
 #ifdef MSDOS
@@ -158,7 +162,7 @@ tgetst1 (char *ptr, char **area)
   else
     ret = *area;
 
-  /* Copy the string value, stopping at null or colon.
+  /* Copy the string value, stopping at NUL or colon.
      Also process ^ and \ abbreviations.  */
   p = ptr;
   r = ret;
@@ -265,14 +269,7 @@ char PC;
 void
 tputs (register const char *str, int nlines, int (*outfun) (int))
 {
-  register int padcount = 0;
-  register int speed;
-
-  speed = baud_rate;
-  /* For quite high speeds, convert to the smaller
-     units to avoid overflow.  */
-  if (speed > 10000)
-    speed = - speed / 100;
+  int padcount = 0;
 
   if (!str)
     return;
@@ -296,21 +293,13 @@ tputs (register const char *str, int nlines, int 
(*outfun) (int))
     (*outfun) (*str++);
 
   /* PADCOUNT is now in units of tenths of msec.
-     SPEED is measured in characters per 10 seconds
-     or in characters per .1 seconds (if negative).
-     We use the smaller units for larger speeds to avoid overflow.  */
-  padcount *= speed;
-  padcount += 500;
-  padcount /= 1000;
-  if (speed < 0)
-    padcount = -padcount;
-  else
-    {
-      padcount += 50;
-      padcount /= 100;
-    }
+     BAUD_RATE is measured in characters per 10 seconds.
+     Compute PADFACTOR = 100000 * (how many padding bytes are needed).  */
+  intmax_t padfactor;
+  if (INT_MULTIPLY_WRAPV (padcount, baud_rate, &padfactor))
+    padfactor = baud_rate < 0 ? INTMAX_MIN : INTMAX_MAX;
 
-  while (padcount-- > 0)
+  for (; 50000 <= padfactor; padfactor -= 100000)
     (*outfun) (PC);
 }
 
@@ -426,7 +415,7 @@ tgetent (char *bp, const char *name)
     }
 
   if (!termcap_name || !filep)
-    termcap_name = TERMCAP_FILE;
+    termcap_name = (char *) TERMCAP_FILE;
 
   /* Here we know we must search a file and termcap_name has its name.  */
 
@@ -435,7 +424,7 @@ tgetent (char *bp, const char *name)
     return -1;
 
   buf.size = BUFSIZE;
-  /* Add 1 to size to ensure room for terminating null.  */
+  /* Add 1 to size to ensure room for terminating NUL.  */
   buf.beg = xmalloc (buf.size + 1);
   term = indirect ? indirect : (char *)name;
 
@@ -491,7 +480,7 @@ tgetent (char *bp, const char *name)
       *bp1 = '\0';
 
       /* Does this entry refer to another terminal type's entry?
-        If something is found, copy it into heap and null-terminate it.  */
+        If something is found, copy it into heap and NUL-terminate it.  */
       tc_search_point = find_capability (tc_search_point, "tc");
       term = tgetst1 (tc_search_point, 0);
     }
@@ -629,7 +618,7 @@ gobble_line (int fd, register struct termcap_buffer *bufp, 
char *append_end)
            {
              ptrdiff_t ptr_offset = bufp->ptr - buf;
              ptrdiff_t append_end_offset = append_end - buf;
-             /* Add 1 to size to ensure room for terminating null.  */
+             /* Add 1 to size to ensure room for terminating NUL.  */
              ptrdiff_t size = bufp->size + 1;
              bufp->beg = buf = xpalloc (buf, &size, 1, -1, 1);
              bufp->size = size - 1;
diff --git a/src/termchar.h b/src/termchar.h
index 3b6be54..796453d 100644
--- a/src/termchar.h
+++ b/src/termchar.h
@@ -1,5 +1,5 @@
 /* Flags and parameters describing terminal's characteristics.
-   Copyright (C) 1985-1986, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1985-1986, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/termhooks.h b/src/termhooks.h
index 4e34105..54f09e0 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -1,6 +1,6 @@
 /* Parameters and display hooks for terminal devices.
 
-Copyright (C) 1985-1986, 1993-1994, 2001-2018 Free Software Foundation,
+Copyright (C) 1985-1986, 1993-1994, 2001-2019 Free Software Foundation,
 Inc.
 
 This file is part of GNU Emacs.
@@ -24,6 +24,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 /* Miscellanea.   */
 
 #include "lisp.h"
+#include "dispextern.h"
 #include "systime.h" /* for Time */
 
 struct glyph;
@@ -408,7 +409,7 @@ struct terminal
      whether the mapping is available.  */
   Lisp_Object glyph_code_table;
 
-  /* All fields before `next_terminal' should be Lisp_Object and are traced
+  /* All earlier fields should be Lisp_Objects and are traced
      by the GC.  All fields afterwards are ignored by the GC.  */
 
   /* Chain of all terminal devices. */
@@ -488,8 +489,40 @@ struct terminal
   void (*update_end_hook) (struct frame *);
   void (*set_terminal_window_hook) (struct frame *, int);
 
+  /* Decide if color named COLOR_NAME is valid for the display
+   associated with the frame F; if so, return the RGB values in
+   COLOR_DEF.  If ALLOC (and MAKEINDEX for NS), allocate a new
+   colormap cell.
+
+   If MAKEINDEX (on NS), set COLOR_DEF pixel to ARGB.  */
+  bool (*defined_color_hook) (struct frame *f, const char *color_name,
+                              XColor *color_def,
+                              bool alloc,
+                              bool makeIndex);
+
   /* Multi-frame and mouse support hooks.  */
 
+  /* Graphical window systems are expected to define all of the
+     following hooks with the possible exception of:
+
+   * query_colors
+   * activate_menubar_hook
+   * change_tool_bar_height_hook
+   * set_bitmap_icon_hook
+   * buffer_flipping_unblocked_hook
+
+   */
+
+  /* This hook is called to store the frame's background color into
+     BGCOLOR.  */
+  void (*query_frame_background_color) (struct frame *f, XColor *bgcolor);
+
+#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
+  /* On frame F, translate pixel colors to RGB values for the NCOLORS
+     colors in COLORS.  Use cached information, if available.  */
+
+  void (*query_colors) (struct frame *f, XColor *colors, int ncolors);
+#endif
   /* Return the current position of the mouse.
 
      Set *f to the frame the mouse is in, or zero if the mouse is in no
@@ -512,6 +545,12 @@ struct terminal
                                Lisp_Object *y,
                                Time *);
 
+  /* This hook is called to get the focus frame.  */
+  Lisp_Object (*get_focus_frame) (struct frame *f);
+
+  /* This hook is called to shift frame focus.  */
+  void (*focus_frame_hook) (struct frame *f, bool noactivate);
+
   /* When a frame's focus redirection is changed, this hook tells the
      window system code to re-decide where to put the highlight.  Under
      X, this means that Emacs lies about where the focus is.  */
@@ -529,19 +568,65 @@ struct terminal
      windows.  */
   void (*frame_raise_lower_hook) (struct frame *f, bool raise_flag);
 
+  /* This hook is called to make the frame F visible if VISIBLE is
+     true, or invisible otherwise. */
+  void (*frame_visible_invisible_hook) (struct frame *f, bool visible);
+
   /* If the value of the frame parameter changed, this hook is called.
      For example, if going from fullscreen to not fullscreen this hook
      may do something OS dependent, like extended window manager hints on X11. 
 */
   void (*fullscreen_hook) (struct frame *f);
 
+  /* This hook is called to iconify the frame.  */
+  void (*iconify_frame_hook) (struct frame *f);
+
+  /* This hook is called to change the size of frame F's native
+   (underlying) window.  If CHANGE_GRAVITY, change to top-left-corner
+   window gravity for this size change and subsequent size changes.
+   Otherwise we leave the window gravity unchanged.  */
+  void (*set_window_size_hook) (struct frame *f, bool change_gravity,
+                                int width, int height, bool pixelwise);
+
+  /* CHANGE_GRAVITY is 1 when calling from Fset_frame_position,
+   to really change the position, and 0 when calling from
+   *_make_frame_visible (in that case, XOFF and YOFF are the current
+   position values).  It is -1 when calling from gui_set_frame_parameters,
+   which means, do adjust for borders but don't change the gravity.  */
+
+  void (*set_frame_offset_hook) (struct frame *f, register int xoff,
+                                 register int yoff, int change_gravity);
+
+  /* This hook is called to set the frame's transparency.  */
+  void (*set_frame_alpha_hook) (struct frame *f);
+
+  /* This hook is called to set a new font for the frame.  */
+  Lisp_Object (*set_new_font_hook) (struct frame *f, Lisp_Object font_object,
+                                    int fontset);
+
+  /* This hook is called to set the GUI window icon of F using FILE.  */
+  bool (*set_bitmap_icon_hook) (struct frame *f, Lisp_Object file);
+
+  /* This hook is called to set the name of the GUI window of F by
+     redisplay unless another name was explicitly requested.  */
+  void (*implicit_set_name_hook) (struct frame *f, Lisp_Object arg,
+                                  Lisp_Object oldval);
+
   /* This hook is called to display menus.  */
   Lisp_Object (*menu_show_hook) (struct frame *f, int x, int y, int menuflags,
                                 Lisp_Object title, const char **error_name);
 
+#ifdef HAVE_EXT_MENU_BAR
+  /* This hook is called to activate the menu bar.  */
+  void (*activate_menubar_hook) (struct frame *f);
+#endif
+
   /* This hook is called to display popup dialog.  */
   Lisp_Object (*popup_dialog_hook) (struct frame *f, Lisp_Object header,
                                    Lisp_Object contents);
 
+  /* This hook is called to change the frame's (internal) tool-bar.  */
+  void (*change_tool_bar_height_hook) (struct frame *f, int height);
+
   /* Scroll bar hooks.  */
 
   /* The representation of scroll bars is determined by the code which
@@ -583,6 +668,11 @@ struct terminal
                                          int portion, int whole,
                                          int position);
 
+  /* Set the default scroll bar width on FRAME.  */
+  void (*set_scroll_bar_default_width_hook) (struct frame *frame);
+
+  /* Set the default scroll bar height on FRAME.  */
+  void (*set_scroll_bar_default_height_hook) (struct frame *frame);
 
   /* The following three hooks are used when we're doing a thorough
      redisplay of the frame.  We don't explicitly know which scroll bars
@@ -645,6 +735,11 @@ struct terminal
      while it runs.  */
   void (*buffer_flipping_unblocked_hook) (struct frame *);
 
+  /* Retrieve the string resource specified by NAME with CLASS from
+     database RDB. */
+  const char * (*get_string_resource_hook) (void *rdb,
+                                            const char *name,
+                                            const char *class);
 
   /* Called to delete the device-specific portions of a frame that is
      on this terminal device. */
diff --git a/src/terminal.c b/src/terminal.c
index e480359..0ee0121 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -1,5 +1,5 @@
 /* Functions related to terminal devices.
-   Copyright (C) 2005-2018 Free Software Foundation, Inc.
+   Copyright (C) 2005-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -264,8 +264,8 @@ get_named_terminal (const char *name)
 static struct terminal *
 allocate_terminal (void)
 {
-  return ALLOCATE_ZEROED_PSEUDOVECTOR
-    (struct terminal, next_terminal, PVEC_TERMINAL);
+  return ALLOCATE_ZEROED_PSEUDOVECTOR (struct terminal, glyph_code_table,
+                                      PVEC_TERMINAL);
 }
 
 /* Create a new terminal object of TYPE and add it to the terminal list.  RIF
diff --git a/src/terminfo.c b/src/terminfo.c
index d8a148e..7ca2548 100644
--- a/src/terminfo.c
+++ b/src/terminfo.c
@@ -1,5 +1,5 @@
 /* Interface from Emacs to terminfo.
-   Copyright (C) 1985-1986, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1985-1986, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/termopts.h b/src/termopts.h
index 4ac75ba..a7a825b 100644
--- a/src/termopts.h
+++ b/src/termopts.h
@@ -1,5 +1,5 @@
 /* Flags and parameters describing user options for handling the terminal.
-   Copyright (C) 1985-1986, 1990, 2001-2018 Free Software Foundation,
+   Copyright (C) 1985-1986, 1990, 2001-2019 Free Software Foundation,
    Inc.
 
 This file is part of GNU Emacs.
diff --git a/src/textprop.c b/src/textprop.c
index 8e8baf4..ae42c44 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -1,5 +1,5 @@
 /* Interface code for dealing with text properties.
-   Copyright (C) 1993-1995, 1997, 1999-2018 Free Software Foundation,
+   Copyright (C) 1993-1995, 1997, 1999-2019 Free Software Foundation,
    Inc.
 
 This file is part of GNU Emacs.
@@ -65,7 +65,7 @@ static Lisp_Object interval_insert_in_front_hooks;
 /* Signal a `text-read-only' error.  This function makes it easier
    to capture that error in GDB by putting a breakpoint on it.  */
 
-static _Noreturn void
+static AVOID
 text_read_only (Lisp_Object propval)
 {
   if (STRINGP (propval))
@@ -89,7 +89,7 @@ modify_text_properties (Lisp_Object buffer, Lisp_Object 
start, Lisp_Object end)
   BUF_COMPUTE_UNCHANGED (buf, b - 1, e);
   if (MODIFF <= SAVE_MODIFF)
     record_first_change ();
-  MODIFF++;
+  modiff_incr (&MODIFF);
 
   bset_point_before_scroll (current_buffer, Qnil);
 
@@ -111,9 +111,6 @@ CHECK_STRING_OR_BUFFER (Lisp_Object x)
    to by BEGIN and END may be integers or markers; if the latter, they
    are coerced to integers.
 
-   When OBJECT is a string, we increment *BEGIN and *END
-   to make them origin-one.
-
    Note that buffer points don't correspond to interval indices.
    For example, point-max is 1 greater than the index of the last
    character.  This difference is handled in the caller, which uses
@@ -175,9 +172,6 @@ validate_interval_range (Lisp_Object object, Lisp_Object 
*begin,
       if (! (0 <= XFIXNUM (*begin) && XFIXNUM (*begin) <= XFIXNUM (*end)
             && XFIXNUM (*end) <= len))
        args_out_of_range (*begin, *end);
-      XSETFASTINT (*begin, XFIXNAT (*begin));
-      if (begin != end)
-       XSETFASTINT (*end, XFIXNAT (*end));
       i = string_intervals (object);
 
       if (len == 0)
@@ -1348,13 +1342,9 @@ Lisp_Object
 set_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object 
properties,
                     Lisp_Object object, Lisp_Object coherent_change_p)
 {
-  register INTERVAL i;
-  Lisp_Object ostart, oend;
+  INTERVAL i;
   bool first_time = true;
 
-  ostart = start;
-  oend = end;
-
   properties = validate_plist (properties);
 
   if (NILP (object))
@@ -1382,11 +1372,6 @@ set_text_properties (Lisp_Object start, Lisp_Object end, 
Lisp_Object properties,
       if (NILP (properties))
        return Qnil;
 
-      /* Restore the original START and END values
-        because validate_interval_range increments them for strings.  */
-      start = ostart;
-      end = oend;
-
       i = validate_interval_range (object, &start, &end, hard);
       /* This can return if start == end.  */
       if (!i)
@@ -1421,34 +1406,25 @@ set_text_properties (Lisp_Object start, Lisp_Object 
end, Lisp_Object properties,
 /* Replace properties of text from START to END with new list of
    properties PROPERTIES.  OBJECT is the buffer or string containing
    the text.  This does not obey any hooks.
-   You should provide the interval that START is located in as I.
-   START and END can be in any order.  */
+   I is the interval that START is located in.  */
 
 void
-set_text_properties_1 (Lisp_Object start, Lisp_Object end, Lisp_Object 
properties, Lisp_Object object, INTERVAL i)
+set_text_properties_1 (Lisp_Object start, Lisp_Object end,
+                      Lisp_Object properties, Lisp_Object object, INTERVAL i)
 {
-  register INTERVAL prev_changed = NULL;
-  register ptrdiff_t s, len;
-  INTERVAL unchanged;
+  INTERVAL prev_changed = NULL;
+  ptrdiff_t s = XFIXNUM (start);
+  ptrdiff_t len = XFIXNUM (end) - s;
 
-  if (XFIXNUM (start) < XFIXNUM (end))
-    {
-      s = XFIXNUM (start);
-      len = XFIXNUM (end) - s;
-    }
-  else if (XFIXNUM (end) < XFIXNUM (start))
-    {
-      s = XFIXNUM (end);
-      len = XFIXNUM (start) - s;
-    }
-  else
+  if (len == 0)
     return;
+  eassert (0 < len);
 
   eassert (i);
 
   if (i->position != s)
     {
-      unchanged = i;
+      INTERVAL unchanged = i;
       i = split_interval_right (unchanged, s - unchanged->position);
 
       if (LENGTH (i) > len)
@@ -1896,45 +1872,30 @@ Lisp_Object
 copy_text_properties (Lisp_Object start, Lisp_Object end, Lisp_Object src,
                      Lisp_Object pos, Lisp_Object dest, Lisp_Object prop)
 {
-  INTERVAL i;
-  Lisp_Object res;
-  Lisp_Object stuff;
-  Lisp_Object plist;
-  ptrdiff_t s, e, e2, p, len;
-  bool modified = false;
-
-  i = validate_interval_range (src, &start, &end, soft);
+  INTERVAL i = validate_interval_range (src, &start, &end, soft);
   if (!i)
     return Qnil;
 
   CHECK_FIXNUM_COERCE_MARKER (pos);
-  {
-    Lisp_Object dest_start, dest_end;
-
-    e = XFIXNUM (pos) + (XFIXNUM (end) - XFIXNUM (start));
-    if (MOST_POSITIVE_FIXNUM < e)
-      args_out_of_range (pos, end);
-    dest_start = pos;
-    XSETFASTINT (dest_end, e);
-    /* Apply this to a copy of pos; it will try to increment its arguments,
-       which we don't want.  */
-    validate_interval_range (dest, &dest_start, &dest_end, soft);
-  }
 
-  s = XFIXNUM (start);
-  e = XFIXNUM (end);
-  p = XFIXNUM (pos);
+  EMACS_INT dest_e = XFIXNUM (pos) + (XFIXNUM (end) - XFIXNUM (start));
+  if (MOST_POSITIVE_FIXNUM < dest_e)
+    args_out_of_range (pos, end);
+  Lisp_Object dest_end = make_fixnum (dest_e);
+  validate_interval_range (dest, &pos, &dest_end, soft);
+
+  ptrdiff_t s = XFIXNUM (start), e = XFIXNUM (end), p = XFIXNUM (pos);
 
-  stuff = Qnil;
+  Lisp_Object stuff = Qnil;
 
   while (s < e)
     {
-      e2 = i->position + LENGTH (i);
+      ptrdiff_t e2 = i->position + LENGTH (i);
       if (e2 > e)
        e2 = e;
-      len = e2 - s;
+      ptrdiff_t len = e2 - s;
 
-      plist = i->plist;
+      Lisp_Object plist = i->plist;
       if (! NILP (prop))
        while (! NILP (plist))
          {
@@ -1959,9 +1920,11 @@ copy_text_properties (Lisp_Object start, Lisp_Object 
end, Lisp_Object src,
       s = i->position;
     }
 
+  bool modified = false;
+
   while (! NILP (stuff))
     {
-      res = Fcar (stuff);
+      Lisp_Object res = Fcar (stuff);
       res = Fadd_text_properties (Fcar (res), Fcar (Fcdr (res)),
                                  Fcar (Fcdr (Fcdr (res))), dest);
       if (! NILP (res))
@@ -2356,11 +2319,10 @@ inherits it if NONSTICKINESS is nil.  The 
`front-sticky' and
   Vtext_property_default_nonsticky
     = list2 (Fcons (Qsyntax_table, Qt), Fcons (Qdisplay, Qt));
 
-  staticpro (&interval_insert_behind_hooks);
-  staticpro (&interval_insert_in_front_hooks);
   interval_insert_behind_hooks = Qnil;
   interval_insert_in_front_hooks = Qnil;
-
+  staticpro (&interval_insert_behind_hooks);
+  staticpro (&interval_insert_in_front_hooks);
 
   /* Common attributes one might give text.  */
 
diff --git a/src/thread.c b/src/thread.c
index 6612697..e2deadd 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -1,5 +1,5 @@
 /* Threading code.
-Copyright (C) 2012-2018 Free Software Foundation, Inc.
+Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -25,6 +25,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "process.h"
 #include "coding.h"
 #include "syssignal.h"
+#include "pdumper.h"
 #include "keyboard.h"
 
 union aligned_thread_state
@@ -34,7 +35,21 @@ union aligned_thread_state
 };
 verify (GCALIGNED (union aligned_thread_state));
 
-static union aligned_thread_state main_thread;
+static union aligned_thread_state main_thread
+  = {{
+      .header.size = PVECHEADERSIZE (PVEC_THREAD,
+                                    PSEUDOVECSIZE (struct thread_state,
+                                                   event_object),
+                                    VECSIZE (struct thread_state)),
+      .m_last_thing_searched = LISPSYM_INITIALLY (Qnil),
+      .m_saved_last_thing_searched = LISPSYM_INITIALLY (Qnil),
+      .name = LISPSYM_INITIALLY (Qnil),
+      .function = LISPSYM_INITIALLY (Qnil),
+      .result = LISPSYM_INITIALLY (Qnil),
+      .error_symbol = LISPSYM_INITIALLY (Qnil),
+      .error_data = LISPSYM_INITIALLY (Qnil),
+      .event_object = LISPSYM_INITIALLY (Qnil),
+    }};
 
 struct thread_state *current_thread = &main_thread.s;
 
@@ -260,19 +275,15 @@ NAME, if given, is used as the name of the mutex.  The 
name is
 informational only.  */)
   (Lisp_Object name)
 {
-  struct Lisp_Mutex *mutex;
-  Lisp_Object result;
-
   if (!NILP (name))
     CHECK_STRING (name);
 
-  mutex = ALLOCATE_PSEUDOVECTOR (struct Lisp_Mutex, mutex, PVEC_MUTEX);
-  memset ((char *) mutex + offsetof (struct Lisp_Mutex, mutex),
-         0, sizeof (struct Lisp_Mutex) - offsetof (struct Lisp_Mutex,
-                                                   mutex));
+  struct Lisp_Mutex *mutex
+    = ALLOCATE_ZEROED_PSEUDOVECTOR (struct Lisp_Mutex, name, PVEC_MUTEX);
   mutex->name = name;
   lisp_mutex_init (&mutex->mutex);
 
+  Lisp_Object result;
   XSETMUTEX (result, mutex);
   return result;
 }
@@ -378,21 +389,17 @@ NAME, if given, is the name of this condition variable.  
The name is
 informational only.  */)
   (Lisp_Object mutex, Lisp_Object name)
 {
-  struct Lisp_CondVar *condvar;
-  Lisp_Object result;
-
   CHECK_MUTEX (mutex);
   if (!NILP (name))
     CHECK_STRING (name);
 
-  condvar = ALLOCATE_PSEUDOVECTOR (struct Lisp_CondVar, cond, PVEC_CONDVAR);
-  memset ((char *) condvar + offsetof (struct Lisp_CondVar, cond),
-         0, sizeof (struct Lisp_CondVar) - offsetof (struct Lisp_CondVar,
-                                                     cond));
+  struct Lisp_CondVar *condvar
+    = ALLOCATE_ZEROED_PSEUDOVECTOR (struct Lisp_CondVar, name, PVEC_CONDVAR);
   condvar->mutex = mutex;
   condvar->name = name;
   sys_cond_init (&condvar->cond);
 
+  Lisp_Object result;
   XSETCONDVAR (result, condvar);
   return result;
 }
@@ -616,7 +623,7 @@ static void
 mark_one_thread (struct thread_state *thread)
 {
   /* Get the stack top now, in case mark_specpdl changes it.  */
-  void *stack_top = thread->stack_top;
+  void const *stack_top = thread->stack_top;
 
   mark_specpdl (thread->m_specpdl, thread->m_specpdl_ptr);
 
@@ -636,10 +643,8 @@ mark_one_thread (struct thread_state *thread)
       mark_object (tem);
     }
 
-  mark_object (thread->m_last_thing_searched);
-
-  if (!NILP (thread->m_saved_last_thing_searched))
-    mark_object (thread->m_saved_last_thing_searched);
+  /* No need to mark Lisp_Object members like m_last_thing_searched,
+     as mark_threads_callback does that by calling mark_object.  */
 }
 
 static void
@@ -767,9 +772,21 @@ run_thread (void *state)
   return NULL;
 }
 
+static void
+free_search_regs (struct re_registers *regs)
+{
+  if (regs->num_regs != 0)
+    {
+      xfree (regs->start);
+      xfree (regs->end);
+    }
+}
+
 void
 finalize_one_thread (struct thread_state *state)
 {
+  free_search_regs (&state->m_search_regs);
+  free_search_regs (&state->m_saved_search_regs);
   sys_cond_destroy (&state->thread_condvar);
 }
 
@@ -779,12 +796,6 @@ When the function exits, the thread dies.
 If NAME is given, it must be a string; it names the new thread.  */)
   (Lisp_Object function, Lisp_Object name)
 {
-  sys_thread_t thr;
-  struct thread_state *new_thread;
-  Lisp_Object result;
-  const char *c_name = NULL;
-  size_t offset = offsetof (struct thread_state, m_stack_bottom);
-
   /* Can't start a thread in temacs.  */
   if (!initialized)
     emacs_abort ();
@@ -792,20 +803,13 @@ If NAME is given, it must be a string; it names the new 
thread.  */)
   if (!NILP (name))
     CHECK_STRING (name);
 
-  new_thread = ALLOCATE_PSEUDOVECTOR (struct thread_state, m_stack_bottom,
-                                     PVEC_THREAD);
-  memset ((char *) new_thread + offset, 0,
-         sizeof (struct thread_state) - offset);
-
+  struct thread_state *new_thread
+    = ALLOCATE_ZEROED_PSEUDOVECTOR (struct thread_state, event_object,
+                                   PVEC_THREAD);
   new_thread->function = function;
   new_thread->name = name;
-  new_thread->m_last_thing_searched = Qnil; /* copy from parent? */
-  new_thread->m_saved_last_thing_searched = Qnil;
+  /* Perhaps copy m_last_thing_searched from parent?  */
   new_thread->m_current_buffer = current_thread->m_current_buffer;
-  new_thread->result = Qnil;
-  new_thread->error_symbol = Qnil;
-  new_thread->error_data = Qnil;
-  new_thread->event_object = Qnil;
 
   new_thread->m_specpdl_size = 50;
   new_thread->m_specpdl = xmalloc ((1 + new_thread->m_specpdl_size)
@@ -820,9 +824,8 @@ If NAME is given, it must be a string; it names the new 
thread.  */)
   new_thread->next_thread = all_threads;
   all_threads = new_thread;
 
-  if (!NILP (name))
-    c_name = SSDATA (ENCODE_UTF_8 (name));
-
+  char const *c_name = !NILP (name) ? SSDATA (ENCODE_UTF_8 (name)) : NULL;
+  sys_thread_t thr;
   if (! sys_thread_create (&thr, c_name, run_thread, new_thread))
     {
       /* Restore the previous situation.  */
@@ -835,6 +838,7 @@ If NAME is given, it must be a string; it names the new 
thread.  */)
     }
 
   /* FIXME: race here where new thread might not be filled in?  */
+  Lisp_Object result;
   XSETTHREAD (result, new_thread);
   return result;
 }
@@ -1047,24 +1051,8 @@ thread_check_current_buffer (struct buffer *buffer)
 
 
 
-static void
-init_main_thread (void)
-{
-  main_thread.s.header.size
-    = PSEUDOVECSIZE (struct thread_state, m_stack_bottom);
-  XSETPVECTYPE (&main_thread.s, PVEC_THREAD);
-  main_thread.s.m_last_thing_searched = Qnil;
-  main_thread.s.m_saved_last_thing_searched = Qnil;
-  main_thread.s.name = Qnil;
-  main_thread.s.function = Qnil;
-  main_thread.s.result = Qnil;
-  main_thread.s.error_symbol = Qnil;
-  main_thread.s.error_data = Qnil;
-  main_thread.s.event_object = Qnil;
-}
-
 bool
-main_thread_p (void *ptr)
+main_thread_p (const void *ptr)
 {
   return ptr == &main_thread.s;
 }
@@ -1078,15 +1066,8 @@ in_current_thread (void)
 }
 
 void
-init_threads_once (void)
-{
-  init_main_thread ();
-}
-
-void
 init_threads (void)
 {
-  init_main_thread ();
   sys_cond_init (&main_thread.s.thread_condvar);
   sys_mutex_init (&global_lock);
   sys_mutex_lock (&global_lock);
diff --git a/src/thread.h b/src/thread.h
index 464506d..498b990 100644
--- a/src/thread.h
+++ b/src/thread.h
@@ -1,5 +1,5 @@
 /* Thread definitions
-Copyright (C) 2012-2018 Free Software Foundation, Inc.
+Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -61,11 +61,11 @@ struct thread_state
   /* If we are waiting for some event, this holds the object we are
      waiting on.  */
   Lisp_Object event_object;
+  /* event_object must be the last Lisp field.  */
 
-  /* m_stack_bottom must be the first non-Lisp field.  */
   /* An address near the bottom of the stack.
      Tells GC how to save a copy of the stack.  */
-  char *m_stack_bottom;
+  char const *m_stack_bottom;
 #define stack_bottom (current_thread->m_stack_bottom)
 
   /* The address of an object near the C stack top, used to determine
@@ -75,7 +75,7 @@ struct thread_state
      error in Emacs.  If the C function F calls G which calls H which
      calls ... F, then at least one of the functions in the chain
      should set this to the address of a local variable.  */
-  void *stack_top;
+  void const *stack_top;
 
   struct catchtag *m_catchlist;
 #define catchlist (current_thread->m_catchlist)
@@ -104,15 +104,15 @@ struct thread_state
 #define specpdl_ptr (current_thread->m_specpdl_ptr)
 
   /* Depth in Lisp evaluations and function calls.  */
-  EMACS_INT m_lisp_eval_depth;
+  intmax_t m_lisp_eval_depth;
 #define lisp_eval_depth (current_thread->m_lisp_eval_depth)
 
   /* This points to the current buffer.  */
   struct buffer *m_current_buffer;
 #define current_buffer (current_thread->m_current_buffer)
 
-  /* Every call to re_match_2, etc., must pass &search_regs as the regs
-     argument unless you can show it is unnecessary (i.e., if re_match_2
+  /* Every call to re_search, etc., must pass &search_regs as the regs
+     argument unless you can show it is unnecessary (i.e., if re_search
      is certainly going to be called again before region-around-match
      can be called).
 
@@ -131,11 +131,6 @@ struct thread_state
   struct re_registers m_search_regs;
 #define search_regs (current_thread->m_search_regs)
 
-  /* If non-zero the match data have been saved in saved_search_regs
-     during the execution of a sentinel or filter. */
-  bool m_search_regs_saved;
-#define search_regs_saved (current_thread->m_search_regs_saved)
-
   struct re_registers m_saved_search_regs;
 #define saved_search_regs (current_thread->m_saved_search_regs)
 
@@ -292,10 +287,9 @@ extern void finalize_one_mutex (struct Lisp_Mutex *);
 extern void finalize_one_condvar (struct Lisp_CondVar *);
 extern void maybe_reacquire_global_lock (void);
 
-extern void init_threads_once (void);
 extern void init_threads (void);
 extern void syms_of_threads (void);
-extern bool main_thread_p (void *);
+extern bool main_thread_p (const void *);
 extern bool in_current_thread (void);
 
 typedef int select_func (int, fd_set *, fd_set *, fd_set *,
diff --git a/src/timefns.c b/src/timefns.c
index f527d5e..5005c73 100644
--- a/src/timefns.c
+++ b/src/timefns.c
@@ -1,6 +1,6 @@
 /* Timestamp functions for Emacs
 
-Copyright (C) 1985-1987, 1989, 1993-2018 Free Software Foundation, Inc.
+Copyright (C) 1985-1987, 1989, 1993-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -25,6 +25,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "bignum.h"
 #include "coding.h"
 #include "lisp.h"
+#include "pdumper.h"
 
 #include <strftime.h>
 
@@ -44,7 +45,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 # define HAVE_TZALLOC_BUG false
 #endif
 
-#define TM_YEAR_BASE 1900
+enum { TM_YEAR_BASE = 1900 };
 
 #ifndef HAVE_TM_GMTOFF
 # define HAVE_TM_GMTOFF false
@@ -171,7 +172,7 @@ emacs_localtime_rz (timezone_t tz, time_t const *t, struct 
tm *tm)
   return tm;
 }
 
-static _Noreturn void
+static AVOID
 invalid_time_zone_specification (Lisp_Object zone)
 {
   xsignal2 (Qerror, build_string ("Invalid time zone specification"), zone);
@@ -291,16 +292,16 @@ tzlookup (Lisp_Object zone, bool settz)
 }
 
 void
-init_timefns (bool dumping)
+init_timefns (void)
 {
-#ifndef CANNOT_DUMP
+#ifdef HAVE_UNEXEC
   /* A valid but unlikely setting for the TZ environment variable.
      It is OK (though a bit slower) if the user chooses this value.  */
   static char dump_tz_string[] = "TZ=UtC0";
 
   /* When just dumping out, set the time zone to a known unlikely value
      and skip the rest of this function.  */
-  if (dumping)
+  if (will_dump_with_unexec_p ())
     {
       xputenv (dump_tz_string);
       tzset ();
@@ -310,7 +311,7 @@ init_timefns (bool dumping)
 
   char *tz = getenv ("TZ");
 
-#if !defined CANNOT_DUMP
+#ifdef HAVE_UNEXEC
   /* If the execution TZ happens to be the same as the dump TZ,
      change it to some other value and then change it back,
      to force the underlying implementation to reload the TZ info.
@@ -336,7 +337,7 @@ time_overflow (void)
   error ("Specified time is not representable");
 }
 
-static _Noreturn void
+static AVOID
 time_error (int err)
 {
   switch (err)
@@ -347,7 +348,7 @@ time_error (int err)
     }
 }
 
-static _Noreturn void
+static AVOID
 invalid_hz (Lisp_Object hz)
 {
   xsignal2 (Qerror, build_string ("Invalid time frequency"), hz);
@@ -527,7 +528,14 @@ make_lisp_time (struct timespec t)
                    make_fixnum (ns / 1000), make_fixnum (ns % 1000 * 1000));
     }
   else
-    return Fcons (timespec_ticks (t), timespec_hz);
+    return timespec_to_lisp (t);
+}
+
+/* Return (TICKS . HZ) for time T.  */
+Lisp_Object
+timespec_to_lisp (struct timespec t)
+{
+  return Fcons (timespec_ticks (t), timespec_hz);
 }
 
 /* Convert T to a Lisp timestamp.  FORM specifies the timestamp format.  */
@@ -1132,7 +1140,7 @@ or (if you need time as a string) `format-time-string'.  
*/)
    determine how many bytes would be written, use NULL for S and
    ((size_t) -1) for MAXSIZE.
 
-   This function behaves like nstrftime, except it allows null
+   This function behaves like nstrftime, except it allows NUL
    bytes in FORMAT and it does not support nanoseconds.  */
 static size_t
 emacs_nmemftime (char *s, size_t maxsize, const char *format,
@@ -1140,8 +1148,8 @@ emacs_nmemftime (char *s, size_t maxsize, const char 
*format,
 {
   size_t total = 0;
 
-  /* Loop through all the null-terminated strings in the format
-     argument.  Normally there's just one null-terminated string, but
+  /* Loop through all the NUL-terminated strings in the format
+     argument.  Normally there's just one NUL-terminated string, but
      there can be arbitrarily many, concatenated together, if the
      format contains '\0' bytes.  nstrftime stops at the first
      '\0' byte so we must invoke it separately for each such string.  */
@@ -1266,7 +1274,7 @@ by text that describes the specified date and time in 
TIME:
 %c is the locale's date and time format.
 %x is the locale's "preferred" date format.
 %D is like "%m/%d/%y".
-%F is the ISO 8601 date format (like "%Y-%m-%d").
+%F is the ISO 8601 date format (like "%+4Y-%m-%d").
 
 %R is like "%H:%M", %T is like "%H:%M:%S", %r is like "%I:%M:%S %p".
 %X is the locale's "preferred" time format.
@@ -1274,17 +1282,23 @@ by text that describes the specified date and time in 
TIME:
 Finally, %n is a newline, %t is a tab, %% is a literal %, and
 unrecognized %-sequences stand for themselves.
 
-Certain flags and modifiers are available with some format controls.
-The flags are `_', `-', `^' and `#'.  For certain characters X,
-%_X is like %X, but padded with blanks; %-X is like %X,
-but without padding.  %^X is like %X, but with all textual
-characters up-cased; %#X is like %X, but with letter-case of
-all textual characters reversed.
-%NX (where N stands for an integer) is like %X,
-but takes up at least N (a number) positions.
-The modifiers are `E' and `O'.  For certain characters X,
-%EX is a locale's alternative version of %X;
-%OX is like %X, but uses the locale's number symbols.
+A %-sequence can contain optional flags, field width, and a modifier
+(in that order) after the `%'.  The flags are:
+
+`-' Do not pad the field.
+`_' Pad with spaces.
+`0' Pad with zeros.
+`+' Pad with zeros and put `+' before nonnegative year numbers with >4 digits.
+`^' Use upper case characters if possible.
+`#' Use opposite case characters if possible.
+
+A field width N is an unsigned decimal integer with a leading digit nonzero.
+%NX is like %X, but takes up at least N positions.
+
+The modifiers are:
+
+`E' Use the locale's alternative version.
+`O' Use the locale's number symbols.
 
 For example, to produce full ISO 8601 format, use "%FT%T%z".
 
@@ -1336,12 +1350,22 @@ usage: (decode-time &optional TIME ZONE)  */)
 
   if (!tm)
     time_error (localtime_errno);
-  if (! (MOST_NEGATIVE_FIXNUM - TM_YEAR_BASE <= local_tm.tm_year
-        && local_tm.tm_year <= MOST_POSITIVE_FIXNUM - TM_YEAR_BASE))
-    time_overflow ();
 
-  /* Avoid overflow when INT_MAX < EMACS_INT_MAX.  */
-  EMACS_INT tm_year_base = TM_YEAR_BASE;
+  Lisp_Object year;
+  if (FASTER_TIMEFNS
+      && MOST_NEGATIVE_FIXNUM - TM_YEAR_BASE <= local_tm.tm_year
+      && local_tm.tm_year <= MOST_POSITIVE_FIXNUM - TM_YEAR_BASE)
+    {
+      /* Avoid overflow when INT_MAX - TM_YEAR_BASE < local_tm.tm_year.  */
+      EMACS_INT tm_year_base = TM_YEAR_BASE;
+      year = make_fixnum (local_tm.tm_year + tm_year_base);
+    }
+  else
+    {
+      mpz_set_si (mpz[0], local_tm.tm_year);
+      mpz_add_ui (mpz[0], mpz[0], TM_YEAR_BASE);
+      year = make_integer_mpz ();
+    }
 
   return CALLN (Flist,
                make_fixnum (local_tm.tm_sec),
@@ -1349,7 +1373,7 @@ usage: (decode-time &optional TIME ZONE)  */)
                make_fixnum (local_tm.tm_hour),
                make_fixnum (local_tm.tm_mday),
                make_fixnum (local_tm.tm_mon + 1),
-               make_fixnum (local_tm.tm_year + tm_year_base),
+               year,
                make_fixnum (local_tm.tm_wday),
                (local_tm.tm_isdst < 0 ? make_fixnum (-1)
                 : local_tm.tm_isdst == 0 ? Qnil : Qt),
@@ -1360,7 +1384,7 @@ usage: (decode-time &optional TIME ZONE)  */)
                 : Qnil));
 }
 
-/* Return OBJ - OFFSET, checking that OBJ is a valid fixnum and that
+/* Return OBJ - OFFSET, checking that OBJ is a valid integer and that
    the result is representable as an int.  0 <= OFFSET <= TM_YEAR_BASE.  */
 static int
 check_tm_member (Lisp_Object obj, int offset)
@@ -1475,7 +1499,6 @@ usage: (encode-time &optional TIME FORM &rest 
OBSOLESCENT-ARGUMENTS)  */)
     {
       if (6 < nargs)
        zone = args[nargs - 1];
-      form = Qnil;
       tm.tm_sec  = check_tm_member (a, 0);
       tm.tm_min  = check_tm_member (args[1], 0);
       tm.tm_hour = check_tm_member (args[2], 0);
@@ -1720,6 +1743,19 @@ emacs_setenv_TZ (const char *tzstring)
   return 0;
 }
 
+#if (ULONG_MAX < TRILLION || !FASTER_TIMEFNS) && !defined ztrillion
+# define NEED_ZTRILLION_INIT 1
+#endif
+
+#ifdef NEED_ZTRILLION_INIT
+static void
+syms_of_timefns_for_pdumper (void)
+{
+  mpz_init_set_ui (ztrillion, 1000000);
+  mpz_mul_ui (ztrillion, ztrillion, 1000000);
+}
+#endif
+
 void
 syms_of_timefns (void)
 {
@@ -1731,10 +1767,6 @@ syms_of_timefns (void)
   trillion = make_int (1000000000000);
   staticpro (&trillion);
 #endif
-#if (ULONG_MAX < TRILLION || !FASTER_TIMEFNS) && !defined ztrillion
-  mpz_init_set_ui (ztrillion, 1000000);
-  mpz_mul_ui (ztrillion, ztrillion, 1000000);
-#endif
 
   DEFSYM (Qencode_time, "encode-time");
 
@@ -1750,4 +1782,7 @@ syms_of_timefns (void)
   defsubr (&Scurrent_time_string);
   defsubr (&Scurrent_time_zone);
   defsubr (&Sset_time_zone_rule);
+#ifdef NEED_ZTRILLION_INIT
+  pdumper_do_now_and_after_load (syms_of_timefns_for_pdumper);
+#endif
 }
diff --git a/src/tparam.c b/src/tparam.c
index 0896740..9f17785 100644
--- a/src/tparam.c
+++ b/src/tparam.c
@@ -1,5 +1,5 @@
 /* Merge parameters into a termcap entry string.
-   Copyright (C) 1985, 1987, 1993, 1995, 2000-2008, 2013-2018 Free
+   Copyright (C) 1985, 1987, 1993, 1995, 2000-2008, 2013-2019 Free
    Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify
diff --git a/src/tparam.h b/src/tparam.h
index 79c55b9..6918c9e 100644
--- a/src/tparam.h
+++ b/src/tparam.h
@@ -1,6 +1,6 @@
 /* Interface definitions for termcap entries.
 
-Copyright (C) 2011-2018 Free Software Foundation, Inc.
+Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/undo.c b/src/undo.c
index 1975e38..3c1251d 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -1,5 +1,5 @@
 /* undo handling for GNU Emacs.
-   Copyright (C) 1990, 1993-1994, 2000-2018 Free Software Foundation,
+   Copyright (C) 1990, 1993-1994, 2000-2019 Free Software Foundation,
    Inc.
 
 This file is part of GNU Emacs.
@@ -291,7 +291,7 @@ truncate_undo_list (struct buffer *b)
 {
   Lisp_Object list;
   Lisp_Object prev, next, last_boundary;
-  EMACS_INT size_so_far = 0;
+  intmax_t size_so_far = 0;
 
   /* Make sure that calling undo-outer-limit-function
      won't cause another GC.  */
@@ -348,14 +348,17 @@ truncate_undo_list (struct buffer *b)
 
   /* If by the first boundary we have already passed undo_outer_limit,
      we're heading for memory full, so offer to clear out the list.  */
-  if (FIXNUMP (Vundo_outer_limit)
-      && size_so_far > XFIXNUM (Vundo_outer_limit)
+  intmax_t undo_outer_limit;
+  if ((INTEGERP (Vundo_outer_limit)
+       && (integer_to_intmax (Vundo_outer_limit, &undo_outer_limit)
+          ? undo_outer_limit < size_so_far
+          : NILP (Fnatnump (Vundo_outer_limit))))
       && !NILP (Vundo_outer_limit_function))
     {
       Lisp_Object tem;
 
       /* Normally the function this calls is undo-outer-limit-truncate.  */
-      tem = call1 (Vundo_outer_limit_function, make_fixnum (size_so_far));
+      tem = call1 (Vundo_outer_limit_function, make_int (size_so_far));
       if (! NILP (tem))
        {
          /* The function is responsible for making
diff --git a/src/unexaix.c b/src/unexaix.c
index 126fc8b..349d365 100644
--- a/src/unexaix.c
+++ b/src/unexaix.c
@@ -1,5 +1,5 @@
 /* Dump an executable image.
-   Copyright (C) 1985-1988, 1999, 2001-2018 Free Software Foundation,
+   Copyright (C) 1985-1988, 1999, 2001-2019 Free Software Foundation,
    Inc.
 
 This file is part of GNU Emacs.
diff --git a/src/unexcoff.c b/src/unexcoff.c
index f310d92..220ce70 100644
--- a/src/unexcoff.c
+++ b/src/unexcoff.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1985-1988, 1992-1994, 2001-2018 Free Software
+/* Copyright (C) 1985-1988, 1992-1994, 2001-2019 Free Software
  * Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -56,7 +56,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #define PERROR(file) report_error (file, new)
 
-#ifndef CANNOT_DUMP  /* all rest of file!  */
+#ifdef HAVE_UNEXEC  /* all rest of file!  */
 
 #ifdef HAVE_COFF_H
 #include <coff.h>
@@ -538,4 +538,4 @@ unexec (const char *new_name, const char *a_name)
     emacs_close (a_out);
 }
 
-#endif /* not CANNOT_DUMP */
+#endif /* HAVE_UNEXEC */
diff --git a/src/unexcw.c b/src/unexcw.c
index dea9f6a..a6e30f6 100644
--- a/src/unexcw.c
+++ b/src/unexcw.c
@@ -1,7 +1,7 @@
 /* unexec() support for Cygwin;
    complete rewrite of xemacs Cygwin unexec() code
 
-   Copyright (C) 2004-2018 Free Software Foundation, Inc.
+   Copyright (C) 2004-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/unexelf.c b/src/unexelf.c
index 4b9292f..c63a8d0 100644
--- a/src/unexelf.c
+++ b/src/unexelf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1985-1988, 1990, 1992, 1999-2018 Free Software
+/* Copyright (C) 1985-1988, 1990, 1992, 1999-2019 Free Software
    Foundation, Inc.
 
 This file is part of GNU Emacs.
diff --git a/src/unexmacosx.c b/src/unexmacosx.c
index 2439102..a94c0cc 100644
--- a/src/unexmacosx.c
+++ b/src/unexmacosx.c
@@ -1,5 +1,5 @@
 /* Dump Emacs in Mach-O format for use on macOS.
-   Copyright (C) 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -447,7 +447,7 @@ unexec_regions_recorder (task_t task, void *rr, unsigned 
type,
 
   while (num && num_unexec_regions < MAX_UNEXEC_REGIONS)
     {
-      /* Subtract the size of trailing null bytes from filesize.  It
+      /* Subtract the size of trailing NUL bytes from filesize.  It
         can be smaller than vmsize in segment commands.  In such a
         case, trailing bytes are initialized with zeros.  */
       for (p = ranges->address + ranges->size; p > ranges->address; p--)
diff --git a/src/unexw32.c b/src/unexw32.c
index 41d6ccf..59feaa7 100644
--- a/src/unexw32.c
+++ b/src/unexw32.c
@@ -1,5 +1,5 @@
 /* unexec for GNU Emacs on Windows NT.
-   Copyright (C) 1994, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1994, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -39,17 +39,12 @@ PIMAGE_NT_HEADERS (__stdcall * pfnCheckSumMappedFile) 
(LPVOID BaseAddress,
                                                       LPDWORD HeaderSum,
                                                       LPDWORD CheckSum);
 
-extern BOOL ctrl_c_handler (unsigned long type);
-
 extern char my_begdata[];
 extern char my_begbss[];
 extern char *my_begbss_static;
 
 #include "w32heap.h"
 
-/* Basically, our "initialized" flag.  */
-BOOL using_dynamic_heap = FALSE;
-
 void get_section_info (file_data *p_file);
 void copy_executable_and_dump_data (file_data *, file_data *);
 void dump_bss_and_heap (file_data *p_infile, file_data *p_outfile);
@@ -70,84 +65,10 @@ PCHAR  bss_start_static = 0;
 DWORD_PTR  bss_size_static = 0;
 DWORD_PTR  extra_bss_size_static = 0;
 
-/* MinGW64 doesn't add a leading underscore to external symbols,
-   whereas configure.ac sets up LD_SWITCH_SYSTEM_TEMACS to force the
-   entry point at __start, with two underscores.  */
-#ifdef __MINGW64__
-#define _start __start
-#endif
-
-extern void mainCRTStartup (void);
-
-/* Startup code for running on NT.  When we are running as the dumped
-   version, we need to bootstrap our heap and .bss section into our
-   address space before we can actually hand off control to the startup
-   code supplied by NT (primarily because that code relies upon malloc ()).  */
-void _start (void);
-
-void
-_start (void)
-{
-
-#if 1
-  /* Give us a way to debug problems with crashes on startup when
-     running under the MSVC profiler. */
-  if (GetEnvironmentVariable ("EMACS_DEBUG", NULL, 0) > 0)
-    DebugBreak ();
-#endif
-
-  /* Cache system info, e.g., the NT page size.  */
-  cache_system_info ();
-
-  /* Grab our malloc arena space now, before CRT starts up. */
-  init_heap ();
-
-  /* This prevents ctrl-c's in shells running while we're suspended from
-     having us exit.  */
-  SetConsoleCtrlHandler ((PHANDLER_ROUTINE) ctrl_c_handler, TRUE);
-
-  /* Prevent Emacs from being locked up (eg. in batch mode) when
-     accessing devices that aren't mounted (eg. removable media drives).  */
-  SetErrorMode (SEM_FAILCRITICALERRORS);
-  mainCRTStartup ();
-}
-
-
 /* File handling.  */
 
 /* Implementation note: this and the next functions work with ANSI
    codepage encoded file names!  */
-int
-open_input_file (file_data *p_file, char *filename)
-{
-  HANDLE file;
-  HANDLE file_mapping;
-  void  *file_base;
-  unsigned long size, upper_size;
-
-  file = CreateFileA (filename, GENERIC_READ, FILE_SHARE_READ, NULL,
-                     OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
-  if (file == INVALID_HANDLE_VALUE)
-    return FALSE;
-
-  size = GetFileSize (file, &upper_size);
-  file_mapping = CreateFileMapping (file, NULL, PAGE_READONLY,
-                                   0, size, NULL);
-  if (!file_mapping)
-    return FALSE;
-
-  file_base = MapViewOfFile (file_mapping, FILE_MAP_READ, 0, 0, size);
-  if (file_base == 0)
-    return FALSE;
-
-  p_file->name = filename;
-  p_file->size = size;
-  p_file->file = file;
-  p_file->file_mapping = file_mapping;
-  p_file->file_base = file_base;
-
-  return TRUE;
-}
 
 int
 open_output_file (file_data *p_file, char *filename, unsigned long size)
@@ -187,18 +108,6 @@ open_output_file (file_data *p_file, char *filename, 
unsigned long size)
   return TRUE;
 }
 
-/* Close the system structures associated with the given file.  */
-void
-close_file_data (file_data *p_file)
-{
-  UnmapViewOfFile (p_file->file_base);
-  CloseHandle (p_file->file_mapping);
-  /* For the case of output files, set final size.  */
-  SetFilePointer (p_file->file, p_file->size, NULL, FILE_BEGIN);
-  SetEndOfFile (p_file->file);
-  CloseHandle (p_file->file);
-}
-
 
 /* Routines to manipulate NT executable file sections.  */
 
@@ -220,34 +129,6 @@ find_section (const char * name, IMAGE_NT_HEADERS * 
nt_header)
   return NULL;
 }
 
-/* Return pointer to section header for section containing the given
-   relative virtual address. */
-IMAGE_SECTION_HEADER *
-rva_to_section (DWORD_PTR rva, IMAGE_NT_HEADERS * nt_header)
-{
-  PIMAGE_SECTION_HEADER section;
-  int i;
-
-  section = IMAGE_FIRST_SECTION (nt_header);
-
-  for (i = 0; i < nt_header->FileHeader.NumberOfSections; i++)
-    {
-      /* Some linkers (eg. the NT SDK linker I believe) swapped the
-        meaning of these two values - or rather, they ignored
-        VirtualSize entirely and always set it to zero.  This affects
-        some very old exes (eg. gzip dated Dec 1993).  Since
-        w32_executable_type relies on this function to work reliably,
-        we need to cope with this.  */
-      DWORD_PTR real_size = max (section->SizeOfRawData,
-                            section->Misc.VirtualSize);
-      if (rva >= section->VirtualAddress
-         && rva < section->VirtualAddress + real_size)
-       return section;
-      section++;
-    }
-  return NULL;
-}
-
 #if 0  /* unused */
 /* Return pointer to section header for section containing the given
    offset in its raw data area. */
@@ -765,15 +646,8 @@ unexec (const char *new_name, const char *old_name)
       exit (1);
     }
 
-  /* Set the flag (before dumping).  */
-  using_dynamic_heap = TRUE;
-
   copy_executable_and_dump_data (&in_file, &out_file);
 
-  /* Unset it because it is plain wrong to keep it after dumping.
-     Malloc can still occur!  */
-  using_dynamic_heap = FALSE;
-
   /* Patch up header fields; profiler is picky about this. */
   {
     PIMAGE_DOS_HEADER dos_header;
diff --git a/src/vm-limit.c b/src/vm-limit.c
index cb06e05..20ddaa9 100644
--- a/src/vm-limit.c
+++ b/src/vm-limit.c
@@ -1,5 +1,5 @@
 /* Functions for memory limit warnings.
-   Copyright (C) 1990, 1992, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1990, 1992, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/w16select.c b/src/w16select.c
index a5f0757..3eb2199 100644
--- a/src/w16select.c
+++ b/src/w16select.c
@@ -1,6 +1,6 @@
 /* 16-bit Windows Selection processing for emacs on MS-Windows
 
-Copyright (C) 1996-1997, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1996-1997, 2001-2019 Free Software Foundation, Inc.
 
 Author: Dale P. Smith <address@hidden>
 
@@ -220,7 +220,7 @@ set_clipboard_data (unsigned Format, void *Data, unsigned 
Size, int Raw)
   /* need to know final size after '\r' chars are inserted (the
      standard CF_OEMTEXT clipboard format uses CRLF line endings,
      while Emacs uses just LF internally).  */
-  truelen = Size + 1;          /* +1 for the terminating null */
+  truelen = Size + 1;          /* +1 for the terminating NUL */
 
   if (!Raw)
     {
@@ -243,7 +243,7 @@ set_clipboard_data (unsigned Format, void *Data, unsigned 
Size, int Raw)
     {
       dosmemput (Data, Size, xbuf_addr);
 
-      /* Terminate with a null, otherwise Windows does strange things
+      /* Terminate with a NUL, otherwise Windows does strange things
         when the text size is an integral multiple of 32 bytes. */
       _farpokeb (_dos_ds, xbuf_addr + Size, '\0');
     }
@@ -255,7 +255,7 @@ set_clipboard_data (unsigned Format, void *Data, unsigned 
Size, int Raw)
       while (Size--)
        {
          /* Don't allow them to put binary data into the clipboard, since
-            it will cause yanked data to be truncated at the first null.  */
+            it will cause yanked data to be truncated at the first NUL.  */
          if (*dp == '\0')
            return 2;
          if (*dp == '\n')
@@ -263,7 +263,7 @@ set_clipboard_data (unsigned Format, void *Data, unsigned 
Size, int Raw)
          _farnspokeb (buf_offset++, *dp++);
        }
 
-      /* Terminate with a null, otherwise Windows does strange things
+      /* Terminate with a NUL, otherwise Windows does strange things
         when the text size is an integral multiple of 32 bytes. */
       _farnspokeb (buf_offset, '\0');
     }
@@ -354,13 +354,13 @@ get_clipboard_data (unsigned Format, void *Data, unsigned 
Size, int Raw)
   __dpmi_int (0x2f, &regs);
   if (regs.x.ax != 0)
     {
-      unsigned char null_char = '\0';
+      unsigned char nul_char = '\0';
       unsigned long xbuf_beg = xbuf_addr;
 
       /* If last_clipboard_text is NULL, we don't want to slow down
         the next loop by an additional test.  */
       register unsigned char *lcdp =
-       last_clipboard_text == NULL ? &null_char : last_clipboard_text;
+       last_clipboard_text == NULL ? &nul_char : last_clipboard_text;
 
       /* Copy data from low memory, remove CR
         characters before LF if needed.  */
@@ -383,7 +383,7 @@ get_clipboard_data (unsigned Format, void *Data, unsigned 
Size, int Raw)
          /* Windows reportedly rounds up the size of clipboard data
             (passed in SIZE) to a multiple of 32, and removes trailing
             spaces from each line without updating SIZE.  We therefore
-            bail out when we see the first null character.  */
+            bail out when we see the first NUL character.  */
          else if (c == '\0')
            break;
        }
@@ -392,7 +392,7 @@ get_clipboard_data (unsigned Format, void *Data, unsigned 
Size, int Raw)
         last time set_clipboard_data was called, pretend there's no
         data in the clipboard.  This is so we don't pass our own text
         from the clipboard (which might be troublesome if the killed
-        text includes null characters).  */
+        text includes NUL characters).  */
       if (last_clipboard_text &&
          xbuf_addr - xbuf_beg == (long)(lcdp - last_clipboard_text))
        dp = (unsigned char *)Data + 1;
diff --git a/src/w32.c b/src/w32.c
index dc8bed5..082a66b 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -1,6 +1,6 @@
 /* Utility and Unix shadow routines for GNU Emacs on the Microsoft Windows API.
 
-Copyright (C) 1994-1995, 2000-2018 Free Software Foundation, Inc.
+Copyright (C) 1994-1995, 2000-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -2091,7 +2091,29 @@ getpwnam (char *name)
     return pw;
 
   if (xstrcasecmp (name, pw->pw_name))
-    return NULL;
+    {
+      /* Mimic what init_editfns does with these environment
+        variables, so that the likes of ~USER is recognized by
+        expand-file-name even if $LOGNAME gives a name different from
+        the real username produced by the process token.  */
+      char *logname = getenv ("LOGNAME");
+      char *username = getenv ("USERNAME");
+      if ((logname || username)
+         && xstrcasecmp (name, logname ? logname : username) == 0)
+       {
+         static struct passwd alias_user;
+         static char alias_name[PASSWD_FIELD_SIZE];
+
+         memcpy (&alias_user, &dflt_passwd, sizeof dflt_passwd);
+         alias_name[0] = '\0';
+         strncat (alias_name, logname ? logname : username,
+                  PASSWD_FIELD_SIZE - 1);
+         alias_user.pw_name = alias_name;
+         pw = &alias_user;
+       }
+      else
+       return NULL;
+    }
 
   return pw;
 }
@@ -2960,8 +2982,7 @@ init_environment (char ** argv)
                if (strcmp (env_vars[i].name, "HOME") == 0 && !appdata)
                  Vdelayed_warnings_list
                     = Fcons
-                    (listn (CONSTYPE_HEAP, 2,
-                            intern ("initialization"), build_string
+                   (list2 (intern ("initialization"), build_string
                             ("Use of `C:\\.emacs' without defining `HOME'\n"
                              "in the environment is deprecated, "
                              "see `Windows HOME' in the Emacs manual.")),
@@ -5920,7 +5941,7 @@ is_symlink (const char *filename)
 
 /* If NAME identifies a symbolic link, copy into BUF the file name of
    the symlink's target.  Copy at most BUF_SIZE bytes, and do NOT
-   null-terminate the target name, even if it fits.  Return the number
+   NUL-terminate the target name, even if it fits.  Return the number
    of bytes copied, or -1 if NAME is not a symlink or any error was
    encountered while resolving it.  The file name copied into BUF is
    encoded in the current ANSI codepage.  */
@@ -6024,10 +6045,10 @@ readlink (const char *name, char *buf, size_t buf_size)
          size_t size_to_copy = buf_size;
 
          /* According to MSDN, PrintNameLength does not include the
-            terminating null character.  */
+            terminating NUL character.  */
          lwname = alloca ((lwname_len + 1) * sizeof(WCHAR));
          memcpy (lwname, lwname_src, lwname_len);
-         lwname[lwname_len/sizeof(WCHAR)] = 0; /* null-terminate */
+         lwname[lwname_len/sizeof(WCHAR)] = 0; /* NUL-terminate */
          filename_from_utf16 (lwname, resolved);
          dostounix_filename (resolved);
          lname_size = strlen (resolved) + 1;
@@ -9363,7 +9384,7 @@ w32_read_registry (HKEY rootkey, Lisp_Object lkey, 
Lisp_Object lname)
       /* Convert input strings to UTF-16.  */
       encoded_key = code_convert_string_norecord (lkey, Qutf_16le, 1);
       memcpy (key_w, SSDATA (encoded_key), SBYTES (encoded_key));
-      /* wchar_t strings need to be terminated by 2 null bytes.  */
+      /* wchar_t strings need to be terminated by 2 NUL bytes.  */
       key_w [SBYTES (encoded_key)/2] = L'\0';
       encoded_vname = code_convert_string_norecord (lname, Qutf_16le, 1);
       memcpy (value_w, SSDATA (encoded_vname), SBYTES (encoded_vname));
@@ -9455,7 +9476,7 @@ w32_read_registry (HKEY rootkey, Lisp_Object lkey, 
Lisp_Object lname)
       case REG_SZ:
        if (use_unicode)
          {
-           /* pvalue ends with 2 null bytes, but we need only one,
+           /* pvalue ends with 2 NUL bytes, but we need only one,
               and AUTO_STRING_WITH_LEN will add it.  */
            if (pvalue[vsize - 1] == '\0')
              vsize -= 2;
@@ -9464,7 +9485,7 @@ w32_read_registry (HKEY rootkey, Lisp_Object lkey, 
Lisp_Object lname)
          }
        else
          {
-           /* Don't waste a byte on the terminating null character,
+           /* Don't waste a byte on the terminating NUL character,
               since make_unibyte_string will add one anyway.  */
            if (pvalue[vsize - 1] == '\0')
              vsize--;
@@ -9926,6 +9947,40 @@ maybe_load_unicows_dll (void)
     }
 }
 
+/* Relocate a directory specified by epaths.h, using the location of
+   our binary as an anchor.  Note: this runs early during startup, so
+   we cannot rely on the usual file-related facilities, and in
+   particular the argument is assumed to be a unibyte string in system
+   codepage encoding.  */
+const char *
+w32_relocate (const char *epath_dir)
+{
+  if (strncmp (epath_dir, "%emacs_dir%/", 12) == 0)
+    {
+      static char relocated_dir[MAX_PATH];
+
+      /* Replace "%emacs_dir%" with the parent of the directory where
+        our binary lives.  Note that init_environment was not yet
+        called, so we cannot rely on emacs_dir being set in the
+        environment.  */
+      if (GetModuleFileNameA (NULL, relocated_dir, MAX_PATH))
+       {
+         char *p = _mbsrchr (relocated_dir, '\\');
+
+         if (p)
+           {
+             *p = '\0';
+             if ((p = _mbsrchr (relocated_dir, '\\')) != NULL)
+               {
+                 strcpy (p, epath_dir + 11);
+                 epath_dir = relocated_dir;
+               }
+           }
+       }
+    }
+  return epath_dir;
+}
+
 /*
        globals_of_w32 is used to initialize those global variables that
        must always be initialized on startup even when the global variable
diff --git a/src/w32.h b/src/w32.h
index 5054b40..3790583 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -2,7 +2,7 @@
 #define EMACS_W32_H
 
 /* Support routines for the NT version of Emacs.
-   Copyright (C) 1994, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1994, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -185,6 +185,8 @@ extern MultiByteToWideChar_Proc pMultiByteToWideChar;
 extern WideCharToMultiByte_Proc pWideCharToMultiByte;
 extern DWORD multiByteToWideCharFlags;
 
+extern const char *w32_relocate (const char *);
+
 extern void init_environment (char **);
 extern void check_windows_init_file (void);
 extern void syms_of_ntproc (void);
diff --git a/src/w32common.h b/src/w32common.h
index e860dbc..bca5244 100644
--- a/src/w32common.h
+++ b/src/w32common.h
@@ -1,5 +1,5 @@
 /* Common functions for Microsoft Windows builds of Emacs
-   Copyright (C) 2012-2018 Free Software Foundation, Inc.
+   Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/w32console.c b/src/w32console.c
index 9f9db68..8575c93 100644
--- a/src/w32console.c
+++ b/src/w32console.c
@@ -1,5 +1,5 @@
 /* Terminal hooks for GNU Emacs on the Microsoft Windows API.
-   Copyright (C) 1992, 1999, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1992, 1999, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -30,6 +30,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "lisp.h"
 #include "coding.h"
 #include "termchar.h"  /* for FRAME_TTY */
+#include "dispextern.h"        /* for tty_defined_color */
 #include "menu.h"      /* for tty_menu_show */
 #include "w32term.h"
 #include "w32common.h" /* for os_subtype */
@@ -673,6 +674,7 @@ initialize_w32_display (struct terminal *term, int *width, 
int *height)
   term->update_begin_hook      = w32con_update_begin;
   term->update_end_hook                = w32con_update_end;
 
+  term->defined_color_hook = &tty_defined_color; /* xfaces.c */
   term->read_socket_hook = w32_console_read_socket;
   term->mouse_position_hook = w32_console_mouse_position;
   term->menu_show_hook = tty_menu_show;
diff --git a/src/w32cygwinx.c b/src/w32cygwinx.c
index bc40123..3b994b1 100644
--- a/src/w32cygwinx.c
+++ b/src/w32cygwinx.c
@@ -1,6 +1,6 @@
 /* Common functions for the Microsoft Windows and Cygwin builds.
 
-Copyright (C) 2018 Free Software Foundation, Inc.
+Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -115,8 +115,7 @@ The following %-sequences are provided:
          remain = format_string ("%ld:%02ld", m / 60, m % 60);
        }
 
-      status = listn (CONSTYPE_HEAP, 8,
-                     Fcons (make_fixnum ('L'), line_status),
+      status =  list (Fcons (make_fixnum ('L'), line_status),
                      Fcons (make_fixnum ('B'), battery_status),
                      Fcons (make_fixnum ('b'), battery_status_symbol),
                      Fcons (make_fixnum ('p'), load_percentage),
diff --git a/src/w32fns.c b/src/w32fns.c
index 9a9789d..525642b 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -1,6 +1,6 @@
 /* Graphical user interface functions for the Microsoft Windows API.
 
-Copyright (C) 1989, 1992-2018 Free Software Foundation, Inc.
+Copyright (C) 1989, 1992-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -48,6 +48,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #ifdef WINDOWSNT
 #include <mbstring.h>
+#include <mbctype.h>   /* for _getmbcp */
 #endif /* WINDOWSNT */
 
 #if CYGWIN
@@ -56,6 +57,8 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "w32.h"
 #endif
 
+#include "pdumper.h"
+
 #include <basetyps.h>
 #include <unknwn.h>
 #include <commctrl.h>
@@ -285,6 +288,8 @@ typedef BOOL (WINAPI *IsDebuggerPresent_Proc) (void);
 /* stdin, from w32console.c */
 extern HANDLE keyboard_handle;
 
+static struct w32_display_info *w32_display_info_for_name (Lisp_Object);
+
 /* Let the user specify a display with a frame.
    nil stands for the selected frame--or, if that is not a w32 frame,
    the first display on the list.  */
@@ -311,7 +316,7 @@ check_x_display_info (Lisp_Object object)
       return t->display_info.w32;
     }
   else if (STRINGP (object))
-    return x_display_info_for_name (object);
+    return w32_display_info_for_name (object);
   else
     {
       struct frame *f;
@@ -328,7 +333,7 @@ check_x_display_info (Lisp_Object object)
    It could be the frame's main window or an icon window.  */
 
 struct frame *
-x_window_to_frame (struct w32_display_info *dpyinfo, HWND wdesc)
+w32_window_to_frame (struct w32_display_info *dpyinfo, HWND wdesc)
 {
   Lisp_Object tail, frame;
   struct frame *f;
@@ -352,16 +357,16 @@ static void my_create_window (struct frame *);
 static void my_create_tip_window (struct frame *);
 
 /* TODO: Native Input Method support; see x_create_im.  */
-void x_set_foreground_color (struct frame *, Lisp_Object, Lisp_Object);
-void x_set_background_color (struct frame *, Lisp_Object, Lisp_Object);
-void x_set_mouse_color (struct frame *, Lisp_Object, Lisp_Object);
-void x_set_cursor_color (struct frame *, Lisp_Object, Lisp_Object);
-void x_set_border_color (struct frame *, Lisp_Object, Lisp_Object);
-void x_set_cursor_type (struct frame *, Lisp_Object, Lisp_Object);
-void x_set_icon_type (struct frame *, Lisp_Object, Lisp_Object);
-void x_set_icon_name (struct frame *, Lisp_Object, Lisp_Object);
-void x_explicitly_set_name (struct frame *, Lisp_Object, Lisp_Object);
-void x_set_title (struct frame *, Lisp_Object, Lisp_Object);
+static void w32_set_foreground_color (struct frame *, Lisp_Object, 
Lisp_Object);
+static void w32_set_background_color (struct frame *, Lisp_Object, 
Lisp_Object);
+static void w32_set_mouse_color (struct frame *, Lisp_Object, Lisp_Object);
+static void w32_set_border_color (struct frame *, Lisp_Object, Lisp_Object);
+static void w32_set_cursor_color (struct frame *, Lisp_Object, Lisp_Object);
+static void w32_set_cursor_type (struct frame *, Lisp_Object, Lisp_Object);
+static void w32_set_icon_type (struct frame *, Lisp_Object, Lisp_Object);
+static void w32_set_icon_name (struct frame *, Lisp_Object, Lisp_Object);
+static void w32_explicitly_set_name (struct frame *, Lisp_Object, Lisp_Object);
+static void w32_set_title (struct frame *, Lisp_Object, Lisp_Object);
 
 
 /* Store the screen positions of frame F into XPTR and YPTR.
@@ -369,7 +374,7 @@ void x_set_title (struct frame *, Lisp_Object, Lisp_Object);
    not Emacs's own window.  */
 
 void
-x_real_positions (struct frame *f, int *xptr, int *yptr)
+w32_real_positions (struct frame *f, int *xptr, int *yptr)
 {
   RECT rect;
 
@@ -1168,9 +1173,9 @@ gamma_correct (struct frame *f, COLORREF *color)
    the selected frame; if so, return the rgb values in COLOR_DEF.
    If ALLOC is nonzero, allocate a new colormap cell.  */
 
-int
+bool
 w32_defined_color (struct frame *f, const char *color, XColor *color_def,
-                  bool alloc_p)
+                  bool alloc_p, bool _makeIndex)
 {
   register Lisp_Object tem;
   COLORREF w32_color_ref;
@@ -1241,7 +1246,7 @@ w32_defined_color (struct frame *f, const char *color, 
XColor *color_def,
    ARG says.  */
 
 static int
-x_decode_color (struct frame *f, Lisp_Object arg, int def)
+w32_decode_color (struct frame *f, Lisp_Object arg, int def)
 {
   XColor cdef;
 
@@ -1257,7 +1262,7 @@ x_decode_color (struct frame *f, Lisp_Object arg, int def)
 
   /* w32_defined_color is responsible for coping with failures
      by looking for a near-miss.  */
-  if (w32_defined_color (f, SSDATA (arg), &cdef, true))
+  if (w32_defined_color (f, SSDATA (arg), &cdef, true, false))
     return cdef.pixel;
 
   /* defined_color failed; return an ultimate default.  */
@@ -1266,7 +1271,7 @@ x_decode_color (struct frame *f, Lisp_Object arg, int def)
 
 
 
-/* Functions called only from `x_set_frame_param'
+/* Functions called only from `gui_set_frame_parameters'
    to set individual parameters.
 
    If FRAME_W32_WINDOW (f) is 0,
@@ -1274,13 +1279,13 @@ x_decode_color (struct frame *f, Lisp_Object arg, int 
def)
    In that case, just record the parameter's new value
    in the standard place; do not attempt to change the window.  */
 
-void
-x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+static void
+w32_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   struct w32_output *x = f->output_data.w32;
   PIX_TYPE fg, old_fg;
 
-  fg = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
+  fg = w32_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
   old_fg = FRAME_FOREGROUND_PIXEL (f);
   FRAME_FOREGROUND_PIXEL (f) = fg;
 
@@ -1298,11 +1303,11 @@ x_set_foreground_color (struct frame *f, Lisp_Object 
arg, Lisp_Object oldval)
     }
 }
 
-void
-x_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+static void
+w32_set_background_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   FRAME_BACKGROUND_PIXEL (f)
-    = x_decode_color (f, arg, WHITE_PIX_DEFAULT (f));
+    = w32_decode_color (f, arg, WHITE_PIX_DEFAULT (f));
 
   if (FRAME_W32_WINDOW (f) != 0)
     {
@@ -1316,8 +1321,8 @@ x_set_background_color (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
     }
 }
 
-void
-x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+static void
+w32_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
 #if 0
   Cursor cursor, nontext_cursor, mode_cursor, hand_cursor;
@@ -1327,7 +1332,7 @@ x_set_mouse_color (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
 
   if (!EQ (Qnil, arg))
     f->output_data.w32->mouse_pixel
-      = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
+      = w32_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
   mask_color = FRAME_BACKGROUND_PIXEL (f);
 
   /* Don't let pointers be invisible.  */
@@ -1476,18 +1481,18 @@ x_set_mouse_color (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
 #endif /* TODO */
 }
 
-void
-x_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+static void
+w32_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   unsigned long fore_pixel, pixel;
 
   if (!NILP (Vx_cursor_fore_pixel))
-    fore_pixel = x_decode_color (f, Vx_cursor_fore_pixel,
+    fore_pixel = w32_decode_color (f, Vx_cursor_fore_pixel,
                                 WHITE_PIX_DEFAULT (f));
   else
     fore_pixel = FRAME_BACKGROUND_PIXEL (f);
 
-  pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
+  pixel = w32_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
 
   /* Make sure that the cursor color differs from the background color.  */
   if (pixel == FRAME_BACKGROUND_PIXEL (f))
@@ -1511,8 +1516,8 @@ x_set_cursor_color (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
 
       if (FRAME_VISIBLE_P (f))
        {
-         x_update_cursor (f, 0);
-         x_update_cursor (f, 1);
+         gui_update_cursor (f, 0);
+         gui_update_cursor (f, 1);
        }
     }
 
@@ -1524,7 +1529,7 @@ x_set_cursor_color (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
    F has a window.  */
 
 static void
-x_set_border_pixel (struct frame *f, int pix)
+w32_set_border_pixel (struct frame *f, int pix)
 {
 
   f->output_data.w32->border_pixel = pix;
@@ -1542,26 +1547,26 @@ x_set_border_pixel (struct frame *f, int pix)
    Note that this does not fully take effect if done before
    F has a window; it must be redone when the window is created.  */
 
-void
-x_set_border_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+static void
+w32_set_border_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   int pix;
 
   CHECK_STRING (arg);
-  pix = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
-  x_set_border_pixel (f, pix);
+  pix = w32_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
+  w32_set_border_pixel (f, pix);
   update_face_from_frame_parameter (f, Qborder_color, arg);
 }
 
 
-void
-x_set_cursor_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+static void
+w32_set_cursor_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   set_frame_cursor_types (f, arg);
 }
 
-void
-x_set_icon_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+static void
+w32_set_icon_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   bool result;
 
@@ -1577,7 +1582,7 @@ x_set_icon_type (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
 
   block_input ();
 
-  result = x_bitmap_icon (f, arg);
+  result = FRAME_TERMINAL (f)->set_bitmap_icon_hook (f, arg);
   if (result)
     {
       unblock_input ();
@@ -1587,8 +1592,8 @@ x_set_icon_type (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
   unblock_input ();
 }
 
-void
-x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+static void
+w32_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
   if (STRINGP (arg))
     {
@@ -1635,25 +1640,29 @@ x_set_icon_name (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
 }
 
 /**
- * x_clear_under_internal_border:
+ * w32_clear_under_internal_border:
  *
  * Clear area of frame F's internal border.  If the internal border face
  * of F has been specified (is not null), fill the area with that face.
  */
 void
-x_clear_under_internal_border (struct frame *f)
+w32_clear_under_internal_border (struct frame *f)
 {
   int border = FRAME_INTERNAL_BORDER_WIDTH (f);
 
   /* Clear border if it's larger than before.  */
   if (border != 0)
     {
-      HDC hdc = get_frame_dc (f);
       int width = FRAME_PIXEL_WIDTH (f);
       int height = FRAME_PIXEL_HEIGHT (f);
-      struct face *face = FACE_FROM_ID_OR_NULL (f, INTERNAL_BORDER_FACE_ID);
+      int face_id =
+       !NILP (Vface_remapping_alist)
+       ? lookup_basic_face (NULL, f, INTERNAL_BORDER_FACE_ID)
+       : INTERNAL_BORDER_FACE_ID;
+      struct face *face = FACE_FROM_ID_OR_NULL (f, face_id);
 
       block_input ();
+      HDC hdc = get_frame_dc (f);
       if (face)
        {
          /* Fill border with internal border face.  */
@@ -1678,13 +1687,13 @@ x_clear_under_internal_border (struct frame *f)
 
 
 /**
- * x_set_internal_border_width:
+ * w32_set_internal_border_width:
  *
  * Set width of frame F's internal border to ARG pixels.  ARG < 0 is
  * treated like ARG = 0.
  */
-void
-x_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval)
+static void
+w32_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object 
oldval)
 {
   int border;
 
@@ -1695,27 +1704,27 @@ x_set_internal_border_width (struct frame *f, 
Lisp_Object arg, Lisp_Object oldva
     {
       f->internal_border_width = border;
 
-      if (FRAME_X_WINDOW (f) != 0)
+      if (FRAME_NATIVE_WINDOW (f) != 0)
        {
          adjust_frame_size (f, -1, -1, 3, false, Qinternal_border_width);
 
          if (FRAME_VISIBLE_P (f))
-           x_clear_under_internal_border (f);
+           w32_clear_under_internal_border (f);
        }
     }
 }
 
 
 /**
- * x_set_menu_bar_lines:
+ * w32_set_menu_bar_lines:
  *
  * Set number of lines of frame F's menu bar to VALUE.  An integer
  * greater zero specifies 1 line and turns the menu bar on if it was off
  * before.  Any other value specifies 0 lines and turns the menu bar off
  * if it was on before.
  */
-void
-x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
+static void
+w32_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
 {
   /* Right now, menu bars don't work properly in minibuf-only frames;
      most of the commands try to apply themselves to the minibuffer
@@ -1754,7 +1763,7 @@ x_set_menu_bar_lines (struct frame *f, Lisp_Object value, 
Lisp_Object oldval)
            }
 
          if (FRAME_W32_WINDOW (f))
-           x_clear_under_internal_border (f);
+           w32_clear_under_internal_border (f);
 
          /* Don't store anything but 1 or 0 in the parameter.  */
          store_frame_param (f, Qmenu_bar_lines, make_fixnum (new ? 1 : 0));
@@ -1770,8 +1779,8 @@ x_set_menu_bar_lines (struct frame *f, Lisp_Object value, 
Lisp_Object oldval)
    height.  By design, the frame's height doesn't change (but maybe it
    should if we don't get enough space otherwise).  */
 
-void
-x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
+static void
+w32_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
 {
   int nlines;
 
@@ -1785,13 +1794,13 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object 
value, Lisp_Object oldval)
   else
     nlines = 0;
 
-  x_change_tool_bar_height (f, nlines * FRAME_LINE_HEIGHT (f));
+  w32_change_tool_bar_height (f, nlines * FRAME_LINE_HEIGHT (f));
 }
 
 
 /* Set the pixel height of the tool bar of frame F to HEIGHT.  */
 void
-x_change_tool_bar_height (struct frame *f, int height)
+w32_change_tool_bar_height (struct frame *f, int height)
 {
   int unit = FRAME_LINE_HEIGHT (f);
   int old_height = FRAME_TOOL_BAR_HEIGHT (f);
@@ -1842,7 +1851,7 @@ x_change_tool_bar_height (struct frame *f, int height)
   adjust_frame_glyphs (f);
   SET_FRAME_GARBAGED (f);
   if (FRAME_W32_WINDOW (f))
-    x_clear_under_internal_border (f);
+    w32_clear_under_internal_border (f);
 }
 
 static void
@@ -1902,7 +1911,7 @@ w32_set_title_bar_text (struct frame *f, Lisp_Object name)
        F->explicit_name is set, ignore the new name; otherwise, set it.  */
 
 static void
-x_set_name (struct frame *f, Lisp_Object name, bool explicit)
+w32_set_name (struct frame *f, Lisp_Object name, bool explicit)
 {
   /* Make sure that requests from lisp code override requests from
      Emacs redisplay code.  */
@@ -1948,26 +1957,26 @@ x_set_name (struct frame *f, Lisp_Object name, bool 
explicit)
 /* This function should be called when the user's lisp code has
    specified a name for the frame; the name will override any set by the
    redisplay code.  */
-void
-x_explicitly_set_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+static void
+w32_explicitly_set_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
-  x_set_name (f, arg, true);
+  w32_set_name (f, arg, true);
 }
 
 /* This function should be called by Emacs redisplay code to set the
    name; names set this way will never override names set by the user's
    lisp code.  */
 void
-x_implicitly_set_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+w32_implicitly_set_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 {
-  x_set_name (f, arg, false);
+  w32_set_name (f, arg, false);
 }
 
 /* Change the title of frame F to NAME.
    If NAME is nil, use the frame name as the title.  */
 
-void
-x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
+static void
+w32_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
 {
   /* Don't change the title if it's already NAME.  */
   if (EQ (name, f->title))
@@ -1984,7 +1993,7 @@ x_set_title (struct frame *f, Lisp_Object name, 
Lisp_Object old_name)
 }
 
 void
-x_set_scroll_bar_default_width (struct frame *f)
+w32_set_scroll_bar_default_width (struct frame *f)
 {
   int unit = FRAME_COLUMN_WIDTH (f);
 
@@ -1995,7 +2004,7 @@ x_set_scroll_bar_default_width (struct frame *f)
 
 
 void
-x_set_scroll_bar_default_height (struct frame *f)
+w32_set_scroll_bar_default_height (struct frame *f)
 {
   int unit = FRAME_LINE_HEIGHT (f);
 
@@ -2005,7 +2014,7 @@ x_set_scroll_bar_default_height (struct frame *f)
 }
 
 /**
- * x_set_undecorated:
+ * w32_set_undecorated:
  *
  * Set frame F's `undecorated' parameter.  If non-nil, F's window-system
  * window is drawn without decorations, title, minimize/maximize boxes
@@ -2017,7 +2026,7 @@ x_set_scroll_bar_default_height (struct frame *f)
  * Some window managers may not honor this parameter.
  */
 static void
-x_set_undecorated (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
+w32_set_undecorated (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
 {
   HWND hwnd = FRAME_W32_WINDOW (f);
   DWORD dwStyle = GetWindowLong (hwnd, GWL_STYLE);
@@ -2048,7 +2057,7 @@ x_set_undecorated (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_value
 }
 
 /**
- * x_set_parent_frame:
+ * w32_set_parent_frame:
  *
  * Set frame F's `parent-frame' parameter.  If non-nil, make F a child
  * frame of the frame specified by that parameter.  Technically, this
@@ -2076,7 +2085,7 @@ x_set_undecorated (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_value
  * Some window managers may not honor this parameter.
  */
 static void
-x_set_parent_frame (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
+w32_set_parent_frame (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
 {
   struct frame *p = NULL;
 
@@ -2110,7 +2119,7 @@ x_set_parent_frame (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_valu
 }
 
 /**
- * x_set_skip_taskbar:
+ * w32_set_skip_taskbar:
  *
  * Set frame F's `skip-taskbar' parameter.  If non-nil, this should
  * remove F's icon from the taskbar associated with the display of F's
@@ -2121,7 +2130,7 @@ x_set_parent_frame (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_valu
  * Some window managers may not honor this parameter.
  */
 static void
-x_set_skip_taskbar (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
+w32_set_skip_taskbar (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
 {
   if (!EQ (new_value, old_value))
     {
@@ -2144,7 +2153,7 @@ x_set_skip_taskbar (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_valu
 }
 
 /**
- * x_set_no_focus_on_map:
+ * w32_set_no_focus_on_map:
  *
  * Set frame F's `no-focus-on-map' parameter which, if non-nil, means
  * that F's window-system window does not want to receive input focus
@@ -2155,14 +2164,14 @@ x_set_skip_taskbar (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_valu
  * Some window managers may not honor this parameter.
  */
 static void
-x_set_no_focus_on_map (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
+w32_set_no_focus_on_map (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
 {
   if (!EQ (new_value, old_value))
     FRAME_NO_FOCUS_ON_MAP (f) = !NILP (new_value);
 }
 
 /**
- * x_set_no_accept_focus:
+ * w32_set_no_accept_focus:
  *
  * Set frame F's `no-accept-focus' parameter which, if non-nil, hints
  * that F's window-system window does not want to receive input focus
@@ -2174,14 +2183,14 @@ x_set_no_focus_on_map (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_v
  * Some window managers may not honor this parameter.
  */
 static void
-x_set_no_accept_focus (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
+w32_set_no_accept_focus (struct frame *f, Lisp_Object new_value, Lisp_Object 
old_value)
 {
   if (!EQ (new_value, old_value))
     FRAME_NO_ACCEPT_FOCUS (f) = !NILP (new_value);
 }
 
 /**
- * x_set_z_group:
+ * w32_set_z_group:
  *
  * Set frame F's `z-group' parameter.  If `above', F's window-system
  * window is displayed above all windows that do not have the `above'
@@ -2199,7 +2208,7 @@ x_set_no_accept_focus (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_v
  * progress.
  */
 static void
-x_set_z_group (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
+w32_set_z_group (struct frame *f, Lisp_Object new_value, Lisp_Object old_value)
 {
   HWND hwnd = FRAME_W32_WINDOW (f);
 
@@ -3054,7 +3063,7 @@ w32_get_modifiers (void)
    and window input.  */
 
 static int
-construct_console_modifiers (void)
+w32_construct_console_modifiers (void)
 {
   int mods;
 
@@ -3080,7 +3089,7 @@ w32_get_key_modifiers (unsigned int wparam, unsigned int 
lparam)
   int mods;
 
   /* Convert to emacs modifiers.  */
-  mods = w32_kbd_mods_to_emacs (construct_console_modifiers (), wparam);
+  mods = w32_kbd_mods_to_emacs (w32_construct_console_modifiers (), wparam);
 
   return mods;
 }
@@ -3712,7 +3721,7 @@ deliver_wm_chars (int do_translate, HWND hwnd, UINT msg, 
UINT wParam,
   if (count)
     {
       W32Msg wmsg;
-      DWORD console_modifiers = construct_console_modifiers ();
+      DWORD console_modifiers = w32_construct_console_modifiers ();
       int *b = buf, strip_ExtraMods = 1, hairy = 0;
       const char *type_CtrlAlt = NULL;
 
@@ -4011,7 +4020,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM 
lParam)
   int windows_translate;
   int key;
 
-  /* Note that it is okay to call x_window_to_frame, even though we are
+  /* Note that it is okay to call w32_window_to_frame, even though we are
      not running in the main lisp thread, because frame deletion
      requires the lisp thread to synchronize with this thread.  Thus, if
      a frame struct is returned, it can be used without concern that the
@@ -4030,7 +4039,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM 
lParam)
   switch (msg)
     {
     case WM_ERASEBKGND:
-      f = x_window_to_frame (dpyinfo, hwnd);
+      f = w32_window_to_frame (dpyinfo, hwnd);
       if (f)
        {
          HDC hdc = get_frame_dc (f);
@@ -4050,7 +4059,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM 
lParam)
       /* ignore our own changes */
       if ((HWND)wParam != hwnd)
        {
-         f = x_window_to_frame (dpyinfo, hwnd);
+         f = w32_window_to_frame (dpyinfo, hwnd);
          if (f)
            /* get_frame_dc will realize our palette and force all
               frames to be redrawn if needed. */
@@ -4063,7 +4072,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM 
lParam)
        RECT update_rect;
        memset (&update_rect, 0, sizeof (update_rect));
 
-       f = x_window_to_frame (dpyinfo, hwnd);
+       f = w32_window_to_frame (dpyinfo, hwnd);
        if (f == 0)
          {
            DebPrint (("WM_PAINT received for unknown window %p\n", hwnd));
@@ -4344,7 +4353,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM 
lParam)
          /* If not defined as a function key, change it to a WM_CHAR message.  
*/
          if (wParam > 255 || !lispy_function_keys[wParam])
            {
-             DWORD modifiers = construct_console_modifiers ();
+             DWORD modifiers = w32_construct_console_modifiers ();
 
              if (!NILP (Vw32_recognize_altgr)
                  && modifier_set (VK_LCONTROL) && modifier_set (VK_RMENU))
@@ -4515,7 +4524,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM 
lParam)
             careful not to move the IME window if the window
             described by W was deleted, as indicated by its buffer
             field being reset to nil.  */
-         f = x_window_to_frame (dpyinfo, hwnd);
+         f = w32_window_to_frame (dpyinfo, hwnd);
          if (!(f && FRAME_LIVE_P (f)))
            goto dflt;
          w = XWINDOW (FRAME_SELECTED_WINDOW (f));
@@ -4691,7 +4700,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM 
lParam)
        int button;
 
        /* Ignore middle and extra buttons as long as the menu is active.  */
-       f = x_window_to_frame (dpyinfo, hwnd);
+       f = w32_window_to_frame (dpyinfo, hwnd);
        if (f && f->output_data.w32->menubar_active)
          return 0;
 
@@ -4733,7 +4742,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM 
lParam)
       return (msg == WM_XBUTTONDOWN || msg == WM_XBUTTONUP);
 
     case WM_MOUSEMOVE:
-      f = x_window_to_frame (dpyinfo, hwnd);
+      f = w32_window_to_frame (dpyinfo, hwnd);
       if (f)
        {
          /* Ignore mouse movements as long as the menu is active.
@@ -4871,7 +4880,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM 
lParam)
        {
          KillTimer (hwnd, menu_free_timer);
          menu_free_timer = 0;
-         f = x_window_to_frame (dpyinfo, hwnd);
+         f = w32_window_to_frame (dpyinfo, hwnd);
          /* If a popup menu is active, don't wipe its strings.  */
          if (menubar_in_use
              && current_popup_menu == NULL)
@@ -4913,7 +4922,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM 
lParam)
         this (there is no possibility of confusion with real menubar
         being active).  */
 
-      f = x_window_to_frame (dpyinfo, hwnd);
+      f = w32_window_to_frame (dpyinfo, hwnd);
       if (f
          && (f->output_data.w32->menubar_active
              /* We can receive this message even in the absence of a
@@ -4938,7 +4947,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM 
lParam)
       }
 
     case WM_EXITMENULOOP:
-      f = x_window_to_frame (dpyinfo, hwnd);
+      f = w32_window_to_frame (dpyinfo, hwnd);
 
       /* If a menu is still active, check again after a short delay,
         since Windows often (always?) sends the WM_EXITMENULOOP
@@ -4969,7 +4978,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM 
lParam)
       return 0;
 
     case WM_MEASUREITEM:
-      f = x_window_to_frame (dpyinfo, hwnd);
+      f = w32_window_to_frame (dpyinfo, hwnd);
       if (f)
        {
          MEASUREITEMSTRUCT * pMis = (MEASUREITEMSTRUCT *) lParam;
@@ -5015,7 +5024,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM 
lParam)
       return 0;
 
     case WM_DRAWITEM:
-      f = x_window_to_frame (dpyinfo, hwnd);
+      f = w32_window_to_frame (dpyinfo, hwnd);
       if (f)
        {
          DRAWITEMSTRUCT * pDis = (DRAWITEMSTRUCT *) lParam;
@@ -5076,7 +5085,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM 
lParam)
         user to click anywhere without changing point (or worse!).
         Don't eat mouse clicks on scrollbars though!!  */
 
-      if ((f = x_window_to_frame (dpyinfo, hwnd))
+      if ((f = w32_window_to_frame (dpyinfo, hwnd))
          && FRAME_NO_ACCEPT_FOCUS (f)
          /* Ignore child frames, they don't accept focus anyway.  */
          && !FRAME_PARENT_FRAME (f))
@@ -5125,7 +5134,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM 
lParam)
       goto command;
     case WM_COMMAND:
       menubar_in_use = 0;
-      f = x_window_to_frame (dpyinfo, hwnd);
+      f = w32_window_to_frame (dpyinfo, hwnd);
       if (f && HIWORD (wParam) == 0)
        {
          if (menu_free_timer)
@@ -5190,7 +5199,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM 
lParam)
     case WM_SETCURSOR:
       if (LOWORD (lParam) == HTCLIENT)
        {
-         f = x_window_to_frame (dpyinfo, hwnd);
+         f = w32_window_to_frame (dpyinfo, hwnd);
          if (f)
            {
              if (f->output_data.w32->hourglass_p
@@ -5209,7 +5218,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM 
lParam)
     case WM_EMACS_SETCURSOR:
       {
        Cursor cursor = (Cursor) wParam;
-       f = x_window_to_frame (dpyinfo, hwnd);
+       f = w32_window_to_frame (dpyinfo, hwnd);
        if (f && cursor)
          {
            f->output_data.w32->current_cursor = cursor;
@@ -5348,7 +5357,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM 
lParam)
 
        /* Use menubar_active to indicate that WM_INITMENU is from
           TrackPopupMenu below, and should be ignored.  */
-       f = x_window_to_frame (dpyinfo, hwnd);
+       f = w32_window_to_frame (dpyinfo, hwnd);
        if (f)
          f->output_data.w32->menubar_active = 1;
 
@@ -5406,10 +5415,12 @@ my_create_window (struct frame * f)
   Lisp_Object left, top;
   struct w32_display_info *dpyinfo = &one_w32_display_info;
 
-  /* When called with RES_TYPE_NUMBER, x_get_arg will return zero for
-     anything that is not a number and is not Qunbound.  */
-  left = x_get_arg (dpyinfo, Qnil, Qleft, "left", "Left", RES_TYPE_NUMBER);
-  top = x_get_arg (dpyinfo, Qnil, Qtop, "top", "Top", RES_TYPE_NUMBER);
+  /* When called with RES_TYPE_NUMBER, gui_display_get_arg will return
+     zero for anything that is not a number and is not Qunbound.  */
+  left = gui_display_get_arg (dpyinfo, Qnil, Qleft, "left", "Left",
+                              RES_TYPE_NUMBER);
+  top = gui_display_get_arg (dpyinfo, Qnil, Qtop, "top", "Top",
+                             RES_TYPE_NUMBER);
   if (EQ (left, Qunbound))
     coords[0] = CW_USEDEFAULT;
   else
@@ -5489,7 +5500,7 @@ w32_window (struct frame *f, long window_prompting, bool 
minibuffer_only)
 
   validate_x_resource_name ();
 
-  /* x_set_name normally ignores requests to set the name if the
+  /* w32_set_name normally ignores requests to set the name if the
      requested name is the same as the current name.  This is the one
      place where that assumption isn't correct; f->name is set, but
      the server hasn't been told.  */
@@ -5500,7 +5511,7 @@ w32_window (struct frame *f, long window_prompting, bool 
minibuffer_only)
     f->explicit_name = 0;
     name = f->name;
     fset_name (f, Qnil);
-    x_set_name (f, name, explicit);
+    w32_set_name (f, name, explicit);
   }
 
   unblock_input ();
@@ -5518,15 +5529,17 @@ w32_window (struct frame *f, long window_prompting, 
bool minibuffer_only)
    well.  */
 
 static void
-x_icon (struct frame *f, Lisp_Object parms)
+w32_icon (struct frame *f, Lisp_Object parms)
 {
   Lisp_Object icon_x, icon_y;
   struct w32_display_info *dpyinfo = &one_w32_display_info;
 
   /* Set the position of the icon.  Note that Windows 95 groups all
      icons in the tray.  */
-  icon_x = x_get_arg (dpyinfo, parms, Qicon_left, 0, 0, RES_TYPE_NUMBER);
-  icon_y = x_get_arg (dpyinfo, parms, Qicon_top, 0, 0, RES_TYPE_NUMBER);
+  icon_x = gui_display_get_arg (dpyinfo, parms, Qicon_left, 0, 0,
+                                RES_TYPE_NUMBER);
+  icon_y = gui_display_get_arg (dpyinfo, parms, Qicon_top, 0, 0,
+                                RES_TYPE_NUMBER);
   if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound))
     {
       CHECK_FIXNUM (icon_x);
@@ -5537,24 +5550,14 @@ x_icon (struct frame *f, Lisp_Object parms)
 
   block_input ();
 
-#if 0 /* TODO */
-  /* Start up iconic or window? */
-  x_wm_set_window_state
-    (f, (EQ (x_get_arg (dpyinfo, parms, Qvisibility, 0, 0, RES_TYPE_SYMBOL), 
Qicon)
-        ? IconicState
-        : NormalState));
-
-  x_text_icon (f, SSDATA ((!NILP (f->icon_name)
-                          ? f->icon_name
-                          : f->name)));
-#endif
+  /* TODO: Start up iconic or window? */
 
   unblock_input ();
 }
 
 
 static void
-x_make_gc (struct frame *f)
+w32_make_gc (struct frame *f)
 {
   XGCValues gc_values;
 
@@ -5582,8 +5585,8 @@ x_make_gc (struct frame *f)
 }
 
 
-/* Handler for signals raised during x_create_frame and
-   x_create_tip_frame.  FRAME is the frame which is partially
+/* Handler for signals raised during Fx_create_frame and
+   w32_create_tip_frame.  FRAME is the frame which is partially
    constructed.  */
 
 static Lisp_Object
@@ -5601,7 +5604,7 @@ unwind_create_frame (Lisp_Object frame)
         private shadow variable, it means we are unwinding a frame
         for which we didn't yet call init_frame_faces, where the
         refcount is incremented.  Therefore, we increment it here, so
-        that free_frame_faces, called in x_free_frame_resources
+        that free_frame_faces, called in w32_free_frame_resources
         below, will not mistakenly decrement the counter that was not
         incremented yet to account for this new frame.  */
       if (FRAME_IMAGE_CACHE (f) != NULL
@@ -5609,7 +5612,7 @@ unwind_create_frame (Lisp_Object frame)
        FRAME_IMAGE_CACHE (f)->refcount++;
 #endif
 
-      x_free_frame_resources (f);
+      w32_free_frame_resources (f);
       free_glyphs (f);
 
 #ifdef GLYPH_DEBUG
@@ -5633,16 +5636,18 @@ do_unwind_create_frame (Lisp_Object frame)
 }
 
 static void
-x_default_font_parameter (struct frame *f, Lisp_Object parms)
+w32_default_font_parameter (struct frame *f, Lisp_Object parms)
 {
   struct w32_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
-  Lisp_Object font_param = x_get_arg (dpyinfo, parms, Qfont, NULL, NULL,
-                               RES_TYPE_STRING);
+  Lisp_Object font_param = gui_display_get_arg (dpyinfo,
+                                                parms, Qfont, NULL, NULL,
+                                                RES_TYPE_STRING);
   Lisp_Object font;
   if (EQ (font_param, Qunbound))
     font_param = Qnil;
   font = !NILP (font_param) ? font_param
-    : x_get_arg (dpyinfo, parms, Qfont, "font", "Font", RES_TYPE_STRING);
+    : gui_display_get_arg (dpyinfo, parms, Qfont, "font", "Font",
+                           RES_TYPE_STRING);
 
   if (!STRINGP (font))
     {
@@ -5667,10 +5672,10 @@ x_default_font_parameter (struct frame *f, Lisp_Object 
parms)
     {
       /* Remember the explicit font parameter, so we can re-apply it after
         we've applied the `default' face settings.  */
-      x_set_frame_parameters (f, Fcons (Fcons (Qfont_parameter, font_param),
-                                       Qnil));
+      gui_set_frame_parameters (f, Fcons (Fcons (Qfont_parameter, font_param),
+                                          Qnil));
     }
-  x_default_parameter (f, parms, Qfont, font, "font", "Font", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qfont, font, "font", "Font", 
RES_TYPE_STRING);
 }
 
 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
@@ -5702,9 +5707,11 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
      until we know if this frame has a specified name.  */
   Vx_resource_name = Vinvocation_name;
 
-  display = x_get_arg (dpyinfo, parameters, Qterminal, 0, 0, RES_TYPE_NUMBER);
+  display = gui_display_get_arg (dpyinfo, parameters, Qterminal, 0, 0,
+                                 RES_TYPE_NUMBER);
   if (EQ (display, Qunbound))
-    display = x_get_arg (dpyinfo, parameters, Qdisplay, 0, 0, RES_TYPE_STRING);
+    display = gui_display_get_arg (dpyinfo, parameters, Qdisplay, 0, 0,
+                                   RES_TYPE_STRING);
   if (EQ (display, Qunbound))
     display = Qnil;
   dpyinfo = check_x_display_info (display);
@@ -5713,7 +5720,8 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
   if (!dpyinfo->terminal->name)
     error ("Terminal is not live, can't create new frames on it");
 
-  name = x_get_arg (dpyinfo, parameters, Qname, "name", "Name", 
RES_TYPE_STRING);
+  name = gui_display_get_arg (dpyinfo, parameters, Qname, "name", "Name",
+                              RES_TYPE_STRING);
   if (!STRINGP (name)
       && ! EQ (name, Qunbound)
       && ! NILP (name))
@@ -5723,8 +5731,8 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
     Vx_resource_name = name;
 
   /* See if parent window is specified.  */
-  parent = x_get_arg (dpyinfo, parameters, Qparent_id, NULL, NULL,
-                     RES_TYPE_NUMBER);
+  parent = gui_display_get_arg (dpyinfo, parameters, Qparent_id, NULL, NULL,
+                                RES_TYPE_NUMBER);
   if (EQ (parent, Qunbound))
     parent = Qnil;
   else if (!NILP (parent))
@@ -5734,8 +5742,9 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
   /* No need to protect DISPLAY because that's not used after passing
      it to make_frame_without_minibuffer.  */
   frame = Qnil;
-  tem = x_get_arg (dpyinfo, parameters, Qminibuffer, "minibuffer", 
"Minibuffer",
-                  RES_TYPE_SYMBOL);
+  tem = gui_display_get_arg (dpyinfo, parameters, Qminibuffer,
+                             "minibuffer", "Minibuffer",
+                             RES_TYPE_SYMBOL);
   if (EQ (tem, Qnone) || NILP (tem))
     f = make_frame_without_minibuffer (Qnil, kb, display);
   else if (EQ (tem, Qonly))
@@ -5750,8 +5759,9 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
 
   XSETFRAME (frame, f);
 
-  parent_frame = x_get_arg (dpyinfo, parameters, Qparent_frame, NULL, NULL,
-                           RES_TYPE_SYMBOL);
+  parent_frame = gui_display_get_arg (dpyinfo, parameters, Qparent_frame,
+                                      NULL, NULL,
+                                      RES_TYPE_SYMBOL);
   /* Apply `parent-frame' parameter only when no `parent-id' was
      specified.  */
   if (!NILP (parent_frame)
@@ -5764,13 +5774,13 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
   fset_parent_frame (f, parent_frame);
   store_frame_param (f, Qparent_frame, parent_frame);
 
-  tem = x_get_arg (dpyinfo, parameters, Qundecorated, NULL, NULL,
-                  RES_TYPE_BOOLEAN);
+  tem = gui_display_get_arg (dpyinfo, parameters, Qundecorated, NULL, NULL,
+                             RES_TYPE_BOOLEAN);
   FRAME_UNDECORATED (f) = !NILP (tem) && !EQ (tem, Qunbound);
   store_frame_param (f, Qundecorated, FRAME_UNDECORATED (f) ? Qt : Qnil);
 
-  tem = x_get_arg (dpyinfo, parameters, Qskip_taskbar, NULL, NULL,
-                  RES_TYPE_BOOLEAN);
+  tem = gui_display_get_arg (dpyinfo, parameters, Qskip_taskbar, NULL, NULL,
+                             RES_TYPE_BOOLEAN);
   FRAME_SKIP_TASKBAR (f) = !NILP (tem) && !EQ (tem, Qunbound);
   store_frame_param (f, Qskip_taskbar,
                     (NILP (tem) || EQ (tem, Qunbound)) ? Qnil : Qt);
@@ -5785,9 +5795,12 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
   f->output_data.w32 = xzalloc (sizeof (struct w32_output));
   FRAME_FONTSET (f) = -1;
 
-  fset_icon_name
-    (f, x_get_arg (dpyinfo, parameters, Qicon_name, "iconName", "Title",
-                  RES_TYPE_STRING));
+  fset_icon_name (f, gui_display_get_arg (dpyinfo,
+                                          parameters,
+                                          Qicon_name,
+                                          "iconName",
+                                          "Title",
+                                          RES_TYPE_STRING));
   if (! STRINGP (f->icon_name))
     fset_icon_name (f, Qnil);
 
@@ -5837,16 +5850,16 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
     register_font_driver (&uniscribe_font_driver, f);
   register_font_driver (&w32font_driver, f);
 
-  x_default_parameter (f, parameters, Qfont_backend, Qnil,
-                      "fontBackend", "FontBackend", RES_TYPE_STRING);
+  gui_default_parameter (f, parameters, Qfont_backend, Qnil,
+                         "fontBackend", "FontBackend", RES_TYPE_STRING);
 
   /* Extract the window parameters from the supplied values
      that are needed to determine window geometry.  */
-  x_default_font_parameter (f, parameters);
+  w32_default_font_parameter (f, parameters);
 
   /* Default BorderWidth to 0 to match other platforms.  */
-  x_default_parameter (f, parameters, Qborder_width, make_fixnum (0),
-                      "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
+  gui_default_parameter (f, parameters, Qborder_width, make_fixnum (0),
+                         "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
 
   /* We recognize either internalBorderWidth or internalBorder
      (which is what xterm calls it).  */
@@ -5854,53 +5867,54 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
     {
       Lisp_Object value;
 
-      value = x_get_arg (dpyinfo, parameters, Qinternal_border_width,
-                        "internalBorder", "InternalBorder", RES_TYPE_NUMBER);
+      value = gui_display_get_arg (dpyinfo, parameters, Qinternal_border_width,
+                                   "internalBorder", "InternalBorder",
+                                   RES_TYPE_NUMBER);
       if (! EQ (value, Qunbound))
        parameters = Fcons (Fcons (Qinternal_border_width, value),
                            parameters);
     }
 
-  x_default_parameter (f, parameters, Qinternal_border_width, make_fixnum (0),
-                      "internalBorderWidth", "InternalBorder", 
RES_TYPE_NUMBER);
-  x_default_parameter (f, parameters, Qright_divider_width, make_fixnum (0),
-                      NULL, NULL, RES_TYPE_NUMBER);
-  x_default_parameter (f, parameters, Qbottom_divider_width, make_fixnum (0),
-                      NULL, NULL, RES_TYPE_NUMBER);
-  x_default_parameter (f, parameters, Qvertical_scroll_bars, Qright,
-                      "verticalScrollBars", "ScrollBars", RES_TYPE_SYMBOL);
-  x_default_parameter (f, parameters, Qhorizontal_scroll_bars, Qnil,
-                      "horizontalScrollBars", "ScrollBars", RES_TYPE_SYMBOL);
+  gui_default_parameter (f, parameters, Qinternal_border_width, make_fixnum 
(0),
+                         "internalBorderWidth", "InternalBorder", 
RES_TYPE_NUMBER);
+  gui_default_parameter (f, parameters, Qright_divider_width, make_fixnum (0),
+                         NULL, NULL, RES_TYPE_NUMBER);
+  gui_default_parameter (f, parameters, Qbottom_divider_width, make_fixnum (0),
+                         NULL, NULL, RES_TYPE_NUMBER);
+  gui_default_parameter (f, parameters, Qvertical_scroll_bars, Qright,
+                         "verticalScrollBars", "ScrollBars", RES_TYPE_SYMBOL);
+  gui_default_parameter (f, parameters, Qhorizontal_scroll_bars, Qnil,
+                         "horizontalScrollBars", "ScrollBars", 
RES_TYPE_SYMBOL);
 
   /* Also do the stuff which must be set before the window exists.  */
-  x_default_parameter (f, parameters, Qforeground_color, build_string 
("black"),
-                      "foreground", "Foreground", RES_TYPE_STRING);
-  x_default_parameter (f, parameters, Qbackground_color, build_string 
("white"),
-                      "background", "Background", RES_TYPE_STRING);
-  x_default_parameter (f, parameters, Qmouse_color, build_string ("black"),
-                      "pointerColor", "Foreground", RES_TYPE_STRING);
-  x_default_parameter (f, parameters, Qborder_color, build_string ("black"),
-                      "borderColor", "BorderColor", RES_TYPE_STRING);
-  x_default_parameter (f, parameters, Qscreen_gamma, Qnil,
-                      "screenGamma", "ScreenGamma", RES_TYPE_FLOAT);
-  x_default_parameter (f, parameters, Qline_spacing, Qnil,
-                      "lineSpacing", "LineSpacing", RES_TYPE_NUMBER);
-  x_default_parameter (f, parameters, Qleft_fringe, Qnil,
-                      "leftFringe", "LeftFringe", RES_TYPE_NUMBER);
-  x_default_parameter (f, parameters, Qright_fringe, Qnil,
-                      "rightFringe", "RightFringe", RES_TYPE_NUMBER);
-  x_default_parameter (f, parameters, Qno_focus_on_map, Qnil,
-                      NULL, NULL, RES_TYPE_BOOLEAN);
-  x_default_parameter (f, parameters, Qno_accept_focus, Qnil,
-                      NULL, NULL, RES_TYPE_BOOLEAN);
-  x_default_parameter (f, parameters, Qno_special_glyphs, Qnil,
-                      NULL, NULL, RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parameters, Qforeground_color, build_string 
("black"),
+                         "foreground", "Foreground", RES_TYPE_STRING);
+  gui_default_parameter (f, parameters, Qbackground_color, build_string 
("white"),
+                         "background", "Background", RES_TYPE_STRING);
+  gui_default_parameter (f, parameters, Qmouse_color, build_string ("black"),
+                         "pointerColor", "Foreground", RES_TYPE_STRING);
+  gui_default_parameter (f, parameters, Qborder_color, build_string ("black"),
+                         "borderColor", "BorderColor", RES_TYPE_STRING);
+  gui_default_parameter (f, parameters, Qscreen_gamma, Qnil,
+                         "screenGamma", "ScreenGamma", RES_TYPE_FLOAT);
+  gui_default_parameter (f, parameters, Qline_spacing, Qnil,
+                         "lineSpacing", "LineSpacing", RES_TYPE_NUMBER);
+  gui_default_parameter (f, parameters, Qleft_fringe, Qnil,
+                         "leftFringe", "LeftFringe", RES_TYPE_NUMBER);
+  gui_default_parameter (f, parameters, Qright_fringe, Qnil,
+                         "rightFringe", "RightFringe", RES_TYPE_NUMBER);
+  gui_default_parameter (f, parameters, Qno_focus_on_map, Qnil,
+                         NULL, NULL, RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parameters, Qno_accept_focus, Qnil,
+                         NULL, NULL, RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parameters, Qno_special_glyphs, Qnil,
+                         NULL, NULL, RES_TYPE_BOOLEAN);
 
   /* Process alpha here (Bug#16619).  On XP this fails with child
      frames.  For `no-focus-on-map' frames delay processing of alpha
      until the frame becomes visible.  */
   if (!FRAME_NO_FOCUS_ON_MAP (f))
-    x_default_parameter (f, parameters, Qalpha, Qnil,
+    gui_default_parameter (f, parameters, Qalpha, Qnil,
                         "alpha", "Alpha", RES_TYPE_NUMBER);
 
   /* Init faces first since we need the frame's column width/line
@@ -5908,7 +5922,7 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
   init_frame_faces (f);
 
   /* We have to call adjust_frame_size here since otherwise
-     x_set_tool_bar_lines will already work with the character sizes
+     w32_set_tool_bar_lines will already work with the character sizes
      installed by init_frame_faces while the frame's pixel size is still
      calculated from a character size of 1 and we subsequently hit the
      (height >= 0) assertion in window_box_height.
@@ -5919,12 +5933,12 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
 
      Also process `min-width' and `min-height' parameters right here
      because `frame-windows-min-size' needs them.  */
-  tem = x_get_arg (dpyinfo, parameters, Qmin_width, NULL, NULL,
-                  RES_TYPE_NUMBER);
+  tem = gui_display_get_arg (dpyinfo, parameters, Qmin_width, NULL, NULL,
+                             RES_TYPE_NUMBER);
   if (FIXNUMP (tem))
     store_frame_param (f, Qmin_width, tem);
-  tem = x_get_arg (dpyinfo, parameters, Qmin_height, NULL, NULL,
-                  RES_TYPE_NUMBER);
+  tem = gui_display_get_arg (dpyinfo, parameters, Qmin_height, NULL, NULL,
+                             RES_TYPE_NUMBER);
   if (FIXNUMP (tem))
     store_frame_param (f, Qmin_height, tem);
   adjust_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f),
@@ -5936,24 +5950,24 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
      variables; ignore them here.  */
   if (NILP (parent_frame))
     {
-      x_default_parameter (f, parameters, Qmenu_bar_lines,
-                          NILP (Vmenu_bar_mode)
-                          ? make_fixnum (0) : make_fixnum (1),
-                          NULL, NULL, RES_TYPE_NUMBER);
+      gui_default_parameter (f, parameters, Qmenu_bar_lines,
+                             NILP (Vmenu_bar_mode)
+                             ? make_fixnum (0) : make_fixnum (1),
+                             NULL, NULL, RES_TYPE_NUMBER);
     }
   else
     /* No menu bar for child frames.  */
     store_frame_param (f, Qmenu_bar_lines, make_fixnum (0));
 
-  x_default_parameter (f, parameters, Qtool_bar_lines,
-                      NILP (Vtool_bar_mode)
-                      ? make_fixnum (0) : make_fixnum (1),
-                      NULL, NULL, RES_TYPE_NUMBER);
+  gui_default_parameter (f, parameters, Qtool_bar_lines,
+                         NILP (Vtool_bar_mode)
+                         ? make_fixnum (0) : make_fixnum (1),
+                         NULL, NULL, RES_TYPE_NUMBER);
 
-  x_default_parameter (f, parameters, Qbuffer_predicate, Qnil,
-                      "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL);
-  x_default_parameter (f, parameters, Qtitle, Qnil,
-                      "title", "Title", RES_TYPE_STRING);
+  gui_default_parameter (f, parameters, Qbuffer_predicate, Qnil,
+                         "bufferPredicate", "BufferPredicate", 
RES_TYPE_SYMBOL);
+  gui_default_parameter (f, parameters, Qtitle, Qnil,
+                         "title", "Title", RES_TYPE_STRING);
 
   f->output_data.w32->parent_desc = FRAME_DISPLAY_INFO (f)->root_window;
   f->output_data.w32->text_cursor = w32_load_cursor (IDC_IBEAM);
@@ -5974,15 +5988,17 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
 
   f->output_data.w32->current_cursor = f->output_data.w32->nontext_cursor;
 
-  window_prompting = x_figure_window_size (f, parameters, true, &x_width, 
&x_height);
+  window_prompting = gui_figure_window_size (f, parameters, true,
+                                             &x_width, &x_height);
 
-  tem = x_get_arg (dpyinfo, parameters, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
+  tem = gui_display_get_arg (dpyinfo, parameters, Qunsplittable, 0, 0,
+                             RES_TYPE_BOOLEAN);
   f->no_split = minibuffer_only || EQ (tem, Qt);
 
   w32_window (f, window_prompting, minibuffer_only);
-  x_icon (f, parameters);
+  w32_icon (f, parameters);
 
-  x_make_gc (f);
+  w32_make_gc (f);
 
   /* Now consider the frame official.  */
   f->terminal->reference_count++;
@@ -5991,22 +6007,22 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
 
   /* We need to do this after creating the window, so that the
      icon-creation functions can say whose icon they're describing.  */
-  x_default_parameter (f, parameters, Qicon_type, Qnil,
-                      "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL);
-
-  x_default_parameter (f, parameters, Qauto_raise, Qnil,
-                      "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
-  x_default_parameter (f, parameters, Qauto_lower, Qnil,
-                      "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
-  x_default_parameter (f, parameters, Qcursor_type, Qbox,
-                      "cursorType", "CursorType", RES_TYPE_SYMBOL);
-  x_default_parameter (f, parameters, Qscroll_bar_width, Qnil,
-                      "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER);
-  x_default_parameter (f, parameters, Qscroll_bar_height, Qnil,
-                      "scrollBarHeight", "ScrollBarHeight", RES_TYPE_NUMBER);
-
-  /* Allow x_set_window_size, now.  */
-  f->can_x_set_window_size = true;
+  gui_default_parameter (f, parameters, Qicon_type, Qnil,
+                         "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL);
+
+  gui_default_parameter (f, parameters, Qauto_raise, Qnil,
+                         "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parameters, Qauto_lower, Qnil,
+                         "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parameters, Qcursor_type, Qbox,
+                         "cursorType", "CursorType", RES_TYPE_SYMBOL);
+  gui_default_parameter (f, parameters, Qscroll_bar_width, Qnil,
+                         "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER);
+  gui_default_parameter (f, parameters, Qscroll_bar_height, Qnil,
+                         "scrollBarHeight", "ScrollBarHeight", 
RES_TYPE_NUMBER);
+
+  /* Allow set_window_size_hook, now.  */
+  f->can_set_window_size = true;
 
   if (x_width > 0)
     SET_FRAME_WIDTH (f, x_width);
@@ -6017,7 +6033,7 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
      badly we want them.  This should be done after we have the menu
      bar so that its size can be taken into account.  */
   block_input ();
-  x_wm_set_size_hint (f, window_prompting, false);
+  w32_wm_set_size_hint (f, window_prompting, false);
   unblock_input ();
 
   adjust_frame_size (f, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f), 0, true,
@@ -6026,10 +6042,10 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
   /* Process fullscreen parameter here in the hope that normalizing a
      fullheight/fullwidth frame will produce the size set by the last
      adjust_frame_size call.  */
-  x_default_parameter (f, parameters, Qfullscreen, Qnil,
-                      "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
-  x_default_parameter (f, parameters, Qz_group, Qnil,
-                      NULL, NULL, RES_TYPE_SYMBOL);
+  gui_default_parameter (f, parameters, Qfullscreen, Qnil,
+                         "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
+  gui_default_parameter (f, parameters, Qz_group, Qnil,
+                         NULL, NULL, RES_TYPE_SYMBOL);
 
   /* Make the window appear on the frame and enable display, unless
      the caller says not to.  However, with explicit parent, Emacs
@@ -6037,17 +6053,18 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
   if (!f->output_data.w32->explicit_parent)
     {
       Lisp_Object visibility
-       = x_get_arg (dpyinfo, parameters, Qvisibility, 0, 0, RES_TYPE_SYMBOL);
+       = gui_display_get_arg (dpyinfo, parameters, Qvisibility, 0, 0,
+                               RES_TYPE_SYMBOL);
 
       if (EQ (visibility, Qicon))
-       x_iconify_frame (f);
+       w32_iconify_frame (f);
       else
        {
          if (EQ (visibility, Qunbound))
            visibility = Qt;
 
          if (!NILP (visibility))
-           x_make_frame_visible (f);
+           w32_make_frame_visible (f);
        }
 
       store_frame_param (f, Qvisibility, visibility);
@@ -6055,8 +6072,8 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
 
   /* For `no-focus-on-map' frames set alpha here.  */
   if (FRAME_NO_FOCUS_ON_MAP (f))
-    x_default_parameter (f, parameters, Qalpha, Qnil,
-                        "alpha", "Alpha", RES_TYPE_NUMBER);
+    gui_default_parameter (f, parameters, Qalpha, Qnil,
+                           "alpha", "Alpha", RES_TYPE_NUMBER);
 
   /* Initialize `default-minibuffer-frame' in case this is the first
      frame on this terminal.  */
@@ -6065,8 +6082,9 @@ DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
          || !FRAME_LIVE_P (XFRAME (KVAR (kb, Vdefault_minibuffer_frame)))))
     kset_default_minibuffer_frame (kb, frame);
 
-  /* All remaining specified parameters, which have not been "used"
-     by x_get_arg and friends, now go in the misc. alist of the frame.  */
+  /* All remaining specified parameters, which have not been "used" by
+     gui_display_get_arg and friends, now go in the misc. alist of the
+     frame.  */
   for (tem = parameters; CONSP (tem); tem = XCDR (tem))
     if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem))))
       fset_param_alist (f, Fcons (XCAR (tem), f->param_alist));
@@ -6078,21 +6096,6 @@ DEFUN ("x-create-frame", Fx_create_frame, 
Sx_create_frame,
   return unbind_to (count, frame);
 }
 
-/* FRAME is used only to get a handle on the X display.  We don't pass the
-   display info directly because we're called from frame.c, which doesn't
-   know about that structure.  */
-Lisp_Object
-x_get_focus_frame (struct frame *frame)
-{
-  struct w32_display_info *dpyinfo = FRAME_DISPLAY_INFO (frame);
-  Lisp_Object xfocus;
-  if (! dpyinfo->w32_focus_frame)
-    return Qnil;
-
-  XSETFRAME (xfocus, dpyinfo->w32_focus_frame);
-  return xfocus;
-}
-
 DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
        doc: /* SKIP: real doc in xfns.c.  */)
   (Lisp_Object color, Lisp_Object frame)
@@ -6102,7 +6105,7 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, 
Sxw_color_defined_p, 1, 2, 0,
 
   CHECK_STRING (color);
 
-  if (w32_defined_color (f, SSDATA (color), &foo, false))
+  if (w32_defined_color (f, SSDATA (color), &foo, false, false))
     return Qt;
   else
     return Qnil;
@@ -6117,7 +6120,7 @@ DEFUN ("xw-color-values", Fxw_color_values, 
Sxw_color_values, 1, 2, 0,
 
   CHECK_STRING (color);
 
-  if (w32_defined_color (f, SSDATA (color), &foo, false))
+  if (w32_defined_color (f, SSDATA (color), &foo, false, false))
     return list3i ((GetRValue (foo.pixel) << 8) | GetRValue (foo.pixel),
                   (GetGValue (foo.pixel) << 8) | GetGValue (foo.pixel),
                   (GetBValue (foo.pixel) << 8) | GetBValue (foo.pixel));
@@ -6157,7 +6160,7 @@ DEFUN ("x-display-pixel-width", Fx_display_pixel_width,
 {
   struct w32_display_info *dpyinfo = check_x_display_info (display);
 
-  return make_fixnum (x_display_pixel_width (dpyinfo));
+  return make_fixnum (w32_display_pixel_width (dpyinfo));
 }
 
 DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
@@ -6167,7 +6170,7 @@ DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
 {
   struct w32_display_info *dpyinfo = check_x_display_info (display);
 
-  return make_fixnum (x_display_pixel_height (dpyinfo));
+  return make_fixnum (w32_display_pixel_height (dpyinfo));
 }
 
 DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes,
@@ -6241,7 +6244,7 @@ DEFUN ("x-display-mm-height", Fx_display_mm_height,
                  / GetDeviceCaps (hdc, VERTRES));
   ReleaseDC (NULL, hdc);
 
-  return make_fixnum (x_display_pixel_height (dpyinfo) * mm_per_pixel + 0.5);
+  return make_fixnum (w32_display_pixel_height (dpyinfo) * mm_per_pixel + 0.5);
 }
 
 DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
@@ -6257,7 +6260,7 @@ DEFUN ("x-display-mm-width", Fx_display_mm_width, 
Sx_display_mm_width, 0, 1, 0,
                  / GetDeviceCaps (hdc, HORZRES));
   ReleaseDC (NULL, hdc);
 
-  return make_fixnum (x_display_pixel_width (dpyinfo) * mm_per_pixel + 0.5);
+  return make_fixnum (w32_display_pixel_width (dpyinfo) * mm_per_pixel + 0.5);
 }
 
 DEFUN ("x-display-backing-store", Fx_display_backing_store,
@@ -6431,8 +6434,8 @@ w32_display_monitor_attributes_list_fallback (struct 
w32_display_info *dpyinfo)
     }
   attributes = Fcons (Fcons (Qframes, frames), attributes);
 
-  pixel_width = x_display_pixel_width (dpyinfo);
-  pixel_height = x_display_pixel_height (dpyinfo);
+  pixel_width = w32_display_pixel_width (dpyinfo);
+  pixel_height = w32_display_pixel_height (dpyinfo);
 
   hdc = GetDC (NULL);
   mm_per_pixel = ((double) GetDeviceCaps (hdc, HORZSIZE)
@@ -6517,19 +6520,12 @@ SOUND is nil to use the normal beep.  */)
   return sound;
 }
 
-#if 0  /* unused */
-int
-x_screen_planes (register struct frame *f)
-{
-  return FRAME_DISPLAY_INFO (f)->n_planes;
-}
-#endif
 
 /* Return the display structure for the display named NAME.
    Open a new connection if necessary.  */
 
-struct w32_display_info *
-x_display_info_for_name (Lisp_Object name)
+static struct w32_display_info *
+w32_display_info_for_name (Lisp_Object name)
 {
   struct w32_display_info *dpyinfo;
 
@@ -6646,9 +6642,9 @@ DEFUN ("x-close-connection", Fx_close_connection,
     error ("Display still has frames on it");
 
   block_input ();
-  x_destroy_all_bitmaps (dpyinfo);
+  image_destroy_all_bitmaps (dpyinfo);
 
-  x_delete_display (dpyinfo);
+  w32_delete_display (dpyinfo);
   unblock_input ();
 
   return Qnil;
@@ -6824,13 +6820,13 @@ unwind_create_tip_frame (Lisp_Object frame)
 /* Create a frame for a tooltip on the display described by DPYINFO.
    PARMS is a list of frame parameters.  Value is the frame.
 
-   Note that functions called here, esp. x_default_parameter can
+   Note that functions called here, esp. gui_default_parameter can
    signal errors, for instance when a specified color name is
    undefined.  We have to make sure that we're in a consistent state
    when this happens.  */
 
 static Lisp_Object
-x_create_tip_frame (struct w32_display_info *dpyinfo, Lisp_Object parms)
+w32_create_tip_frame (struct w32_display_info *dpyinfo, Lisp_Object parms)
 {
   struct frame *f;
   Lisp_Object frame;
@@ -6847,12 +6843,14 @@ x_create_tip_frame (struct w32_display_info *dpyinfo, 
Lisp_Object parms)
 
   kb = dpyinfo->terminal->kboard;
 
-  /* The calls to x_get_arg remove elements from PARMS, so copy it to
-     avoid destructive changes behind our caller's back.  */
+  /* The calls to gui_display_get_arg remove elements from PARMS, so
+     copy it to avoid destructive changes behind our caller's
+     back.  */
   parms = Fcopy_alist (parms);
 
   /* Get the name of the frame to use for resource lookup.  */
-  name = x_get_arg (dpyinfo, parms, Qname, "name", "Name", RES_TYPE_STRING);
+  name = gui_display_get_arg (dpyinfo, parms, Qname, "name", "Name",
+                              RES_TYPE_STRING);
   if (!STRINGP (name)
       && !EQ (name, Qunbound)
       && !NILP (name))
@@ -6869,7 +6867,7 @@ x_create_tip_frame (struct w32_display_info *dpyinfo, 
Lisp_Object parms)
 
   /* By setting the output method, we're essentially saying that
      the frame is live, as per FRAME_LIVE_P.  If we get a signal
-     from this point on, x_destroy_window might screw up reference
+     from this point on, w32_destroy_window might screw up reference
      counts etc.  */
   f->terminal = dpyinfo->terminal;
   f->output_method = output_w32;
@@ -6905,15 +6903,15 @@ x_create_tip_frame (struct w32_display_info *dpyinfo, 
Lisp_Object parms)
     register_font_driver (&uniscribe_font_driver, f);
   register_font_driver (&w32font_driver, f);
 
-  x_default_parameter (f, parms, Qfont_backend, Qnil,
-                      "fontBackend", "FontBackend", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qfont_backend, Qnil,
+                         "fontBackend", "FontBackend", RES_TYPE_STRING);
 
   /* Extract the window parameters from the supplied values
      that are needed to determine window geometry.  */
-  x_default_font_parameter (f, parms);
+  w32_default_font_parameter (f, parms);
 
-  x_default_parameter (f, parms, Qborder_width, make_fixnum (2),
-                      "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qborder_width, make_fixnum (2),
+                         "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
   /* This defaults to 2 in order to match xterm.  We recognize either
      internalBorderWidth or internalBorder (which is what xterm calls
      it).  */
@@ -6921,31 +6919,32 @@ x_create_tip_frame (struct w32_display_info *dpyinfo, 
Lisp_Object parms)
     {
       Lisp_Object value;
 
-      value = x_get_arg (dpyinfo, parms, Qinternal_border_width,
-                        "internalBorder", "internalBorder", RES_TYPE_NUMBER);
+      value = gui_display_get_arg (dpyinfo, parms, Qinternal_border_width,
+                                   "internalBorder", "internalBorder",
+                                   RES_TYPE_NUMBER);
       if (! EQ (value, Qunbound))
        parms = Fcons (Fcons (Qinternal_border_width, value),
                       parms);
     }
 
-  x_default_parameter (f, parms, Qinternal_border_width, make_fixnum (1),
-                      "internalBorderWidth", "internalBorderWidth",
-                      RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qinternal_border_width, make_fixnum (1),
+                         "internalBorderWidth", "internalBorderWidth",
+                         RES_TYPE_NUMBER);
   /* Also do the stuff which must be set before the window exists.  */
-  x_default_parameter (f, parms, Qforeground_color, build_string ("black"),
-                      "foreground", "Foreground", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qbackground_color, build_string ("white"),
-                      "background", "Background", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qmouse_color, build_string ("black"),
-                      "pointerColor", "Foreground", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qcursor_color, build_string ("black"),
-                      "cursorColor", "Foreground", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qborder_color, build_string ("black"),
-                      "borderColor", "BorderColor", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qno_special_glyphs, Qt,
-                      NULL, NULL, RES_TYPE_BOOLEAN);
-
-  /* Init faces before x_default_parameter is called for the
+  gui_default_parameter (f, parms, Qforeground_color, build_string ("black"),
+                         "foreground", "Foreground", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qbackground_color, build_string ("white"),
+                         "background", "Background", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qmouse_color, build_string ("black"),
+                         "pointerColor", "Foreground", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qcursor_color, build_string ("black"),
+                         "cursorColor", "Foreground", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qborder_color, build_string ("black"),
+                         "borderColor", "BorderColor", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qno_special_glyphs, Qt,
+                         NULL, NULL, RES_TYPE_BOOLEAN);
+
+  /* Init faces before gui_default_parameter is called for the
      scroll-bar-width parameter because otherwise we end up in
      init_iterator with a null face cache, which should not happen.  */
   init_frame_faces (f);
@@ -6954,7 +6953,7 @@ x_create_tip_frame (struct w32_display_info *dpyinfo, 
Lisp_Object parms)
   f->output_data.w32->parent_desc = FRAME_DISPLAY_INFO (f)->root_window;
   f->output_data.w32->explicit_parent = false;
 
-  x_figure_window_size (f, parms, true, &x_width, &x_height);
+  gui_figure_window_size (f, parms, true, &x_width, &x_height);
 
   /* No fringes on tip frame.  */
   f->fringe_cols = 0;
@@ -6968,17 +6967,17 @@ x_create_tip_frame (struct w32_display_info *dpyinfo, 
Lisp_Object parms)
   my_create_tip_window (f);
   unblock_input ();
 
-  x_make_gc (f);
+  w32_make_gc (f);
 
-  x_default_parameter (f, parms, Qauto_raise, Qnil,
-                      "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
-  x_default_parameter (f, parms, Qauto_lower, Qnil,
-                      "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
-  x_default_parameter (f, parms, Qcursor_type, Qbox,
-                      "cursorType", "CursorType", RES_TYPE_SYMBOL);
+  gui_default_parameter (f, parms, Qauto_raise, Qnil,
+                         "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parms, Qauto_lower, Qnil,
+                         "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parms, Qcursor_type, Qbox,
+                         "cursorType", "CursorType", RES_TYPE_SYMBOL);
   /* Process alpha here (Bug#17344).  */
-  x_default_parameter (f, parms, Qalpha, Qnil,
-                      "alpha", "Alpha", RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qalpha, Qnil,
+                         "alpha", "Alpha", RES_TYPE_NUMBER);
 
   /* Dimensions, especially FRAME_LINES (f), must be done via
      change_frame_size.  Change will not be effected unless different
@@ -7028,7 +7027,7 @@ x_create_tip_frame (struct w32_display_info *dpyinfo, 
Lisp_Object parms)
      below.  And the frame needs to be on Vframe_list or making it
      visible won't work.  */
   Vframe_list = Fcons (frame, Vframe_list);
-  f->can_x_set_window_size = true;
+  f->can_set_window_size = true;
 
   /* Setting attributes of faces of the tooltip frame from resources
      and similar will set face_change, which leads to the
@@ -7072,8 +7071,8 @@ compute_tip_xy (struct frame *f,
       /* Default min and max values.  */
       min_x = 0;
       min_y = 0;
-      max_x = x_display_pixel_width (FRAME_DISPLAY_INFO (f));
-      max_y = x_display_pixel_height (FRAME_DISPLAY_INFO (f));
+      max_x = w32_display_pixel_width (FRAME_DISPLAY_INFO (f));
+      max_y = w32_display_pixel_height (FRAME_DISPLAY_INFO (f));
 
       block_input ();
       GetCursorPos (&pt);
@@ -7138,7 +7137,7 @@ compute_tip_xy (struct frame *f,
 }
 
 /**
- * x_hide_tip:
+ * w32_hide_tip:
  *
  * Hide currently visible tooltip and cancel its timer.
  *
@@ -7149,7 +7148,7 @@ compute_tip_xy (struct frame *f,
  * otherwise.
  */
 static Lisp_Object
-x_hide_tip (bool delete)
+w32_hide_tip (bool delete)
 {
   if (!NILP (tip_timer))
     {
@@ -7180,7 +7179,7 @@ x_hide_tip (bool delete)
                  tip_frame = Qnil;
                }
              else
-               x_make_frame_invisible (XFRAME (tip_frame));
+               w32_make_frame_invisible (XFRAME (tip_frame));
 
              was_open = Qt;
            }
@@ -7322,13 +7321,13 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
                }
            }
 
-         x_hide_tip (delete);
+         w32_hide_tip (delete);
        }
       else
-       x_hide_tip (true);
+       w32_hide_tip (true);
     }
   else
-    x_hide_tip (true);
+    w32_hide_tip (true);
 
   tip_last_frame = frame;
   tip_last_string = string;
@@ -7357,7 +7356,7 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
       /* Create a frame for the tooltip and record it in the global
         variable tip_frame.  */
       struct frame *f;         /* The value is unused.  */
-      if (NILP (tip_frame = x_create_tip_frame (FRAME_DISPLAY_INFO (f), 
parms)))
+      if (NILP (tip_frame = w32_create_tip_frame (FRAME_DISPLAY_INFO (f), 
parms)))
        {
          /* Creating the tip frame failed.  */
          unblock_input ();
@@ -7478,7 +7477,7 @@ DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0,
        doc: /* SKIP: real doc in xfns.c.  */)
   (void)
 {
-  return x_hide_tip (!tooltip_reuse_hidden_frame);
+  return w32_hide_tip (!tooltip_reuse_hidden_frame);
 }
 
 /***********************************************************************
@@ -7614,9 +7613,9 @@ w32_dialog_in_progress (Lisp_Object in_progress)
       struct frame *f = XFRAME (frame);
 
       if (!NILP (in_progress) && FRAME_Z_GROUP_ABOVE (f))
-       x_set_z_group (f, Qabove_suspended, Qabove);
+       w32_set_z_group (f, Qabove_suspended, Qabove);
       else if (NILP (in_progress) && FRAME_Z_GROUP_ABOVE_SUSPENDED (f))
-       x_set_z_group (f, Qabove, Qabove_suspended);
+       w32_set_z_group (f, Qabove, Qabove_suspended);
     }
 }
 
@@ -7958,7 +7957,7 @@ DEFUN ("system-move-file-to-trash", 
Fsystem_move_file_to_trash,
        {
          SHFILEOPSTRUCTW file_op_w;
          /* We need one more element beyond MAX_PATH because this is
-            a list of file names, with the last element double-null
+            a list of file names, with the last element double-NUL
             terminated. */
          wchar_t tmp_path_w[MAX_PATH + 1];
 
@@ -8219,7 +8218,7 @@ a ShowWindow flag:
      URL, for example.  So we make it absolute only if it is an
      existing file; if it is a file that does not exist, tough.  */
   absdoc = Fexpand_file_name (document, Qnil);
-  /* Don't call file handlers for file-exists-p, since they might
+  /* Don't call file name handlers for file-exists-p, since they might
      attempt to access the file, which could fail or produce undesired
      consequences, see bug#16558 for an example.  */
   handler = Ffind_file_name_handler (absdoc, Qfile_exists_p);
@@ -8785,8 +8784,7 @@ and width values are in pixels.
     /* A single line menu bar.  */
     menu_bar_height = single_menu_bar_height;
 
-  return listn (CONSTYPE_HEAP, 10,
-               Fcons (Qouter_position,
+  return  list (Fcons (Qouter_position,
                       Fcons (make_fixnum (left), make_fixnum (top))),
                Fcons (Qouter_size,
                       Fcons (make_fixnum (right - left),
@@ -8918,7 +8916,7 @@ w32_frame_list_z_order (struct w32_display_info *dpyinfo, 
HWND window)
 
   while (window)
     {
-      struct frame *f = x_window_to_frame (dpyinfo, window);
+      struct frame *f = w32_window_to_frame (dpyinfo, window);
 
       if (f)
        {
@@ -9097,7 +9095,7 @@ DEFUN ("file-system-info", Ffile_system_info, 
Sfile_system_info, 1, 1, 0,
   encoded = ENCODE_FILE (filename);
 
   /* If the file name has special constructs in it,
-     call the corresponding file handler.  */
+     call the corresponding file name handler.  */
   Lisp_Object handler = Ffind_file_name_handler (encoded, Qfile_system_info);
   if (!NILP (handler))
     {
@@ -9718,7 +9716,7 @@ get_dll_version (const char *dll_name)
 /* Return the number of bytes in UTF-8 encoded string STR that
    corresponds to at most LIM characters.  If STR ends before LIM
    characters, return the number of bytes in STR including the
-   terminating null byte.  */
+   terminating NUL byte.  */
 static int
 utf8_mbslen_lim (const char *str, int lim)
 {
@@ -10093,6 +10091,8 @@ It can also be nil, which means try `HKCU', and if that 
fails, try `HKLM'.
 
 KEY and NAME must be strings, and NAME must not include slashes.
 KEY can use either forward- or back-slashes.
+To access the default value of KEY (if it is defined), use NAME
+that is an empty string.
 
 If the the named KEY or its subkey called NAME don't exist, or cannot
 be accessed by the current user, the function returns nil.  Otherwise,
@@ -10154,52 +10154,52 @@ to be converted to forward slashes by the caller.  */)
 
 frame_parm_handler w32_frame_parm_handlers[] =
 {
-  x_set_autoraise,
-  x_set_autolower,
-  x_set_background_color,
-  x_set_border_color,
-  x_set_border_width,
-  x_set_cursor_color,
-  x_set_cursor_type,
-  x_set_font,
-  x_set_foreground_color,
-  x_set_icon_name,
-  x_set_icon_type,
-  x_set_internal_border_width,
-  x_set_right_divider_width,
-  x_set_bottom_divider_width,
-  x_set_menu_bar_lines,
-  x_set_mouse_color,
-  x_explicitly_set_name,
-  x_set_scroll_bar_width,
-  x_set_scroll_bar_height,
-  x_set_title,
-  x_set_unsplittable,
-  x_set_vertical_scroll_bars,
-  x_set_horizontal_scroll_bars,
-  x_set_visibility,
-  x_set_tool_bar_lines,
+  gui_set_autoraise,
+  gui_set_autolower,
+  w32_set_background_color,
+  w32_set_border_color,
+  gui_set_border_width,
+  w32_set_cursor_color,
+  w32_set_cursor_type,
+  gui_set_font,
+  w32_set_foreground_color,
+  w32_set_icon_name,
+  w32_set_icon_type,
+  w32_set_internal_border_width,
+  gui_set_right_divider_width,
+  gui_set_bottom_divider_width,
+  w32_set_menu_bar_lines,
+  w32_set_mouse_color,
+  w32_explicitly_set_name,
+  gui_set_scroll_bar_width,
+  gui_set_scroll_bar_height,
+  w32_set_title,
+  gui_set_unsplittable,
+  gui_set_vertical_scroll_bars,
+  gui_set_horizontal_scroll_bars,
+  gui_set_visibility,
+  w32_set_tool_bar_lines,
   0, /* x_set_scroll_bar_foreground, */
   0, /* x_set_scroll_bar_background, */
-  x_set_screen_gamma,
-  x_set_line_spacing,
-  x_set_left_fringe,
-  x_set_right_fringe,
+  gui_set_screen_gamma,
+  gui_set_line_spacing,
+  gui_set_left_fringe,
+  gui_set_right_fringe,
   0, /* x_set_wait_for_wm, */
-  x_set_fullscreen,
-  x_set_font_backend,
-  x_set_alpha,
+  gui_set_fullscreen,
+  gui_set_font_backend,
+  gui_set_alpha,
   0, /* x_set_sticky */
   0, /* x_set_tool_bar_position */
   0, /* x_set_inhibit_double_buffering */
-  x_set_undecorated,
-  x_set_parent_frame,
-  x_set_skip_taskbar,
-  x_set_no_focus_on_map,
-  x_set_no_accept_focus,
-  x_set_z_group,
+  w32_set_undecorated,
+  w32_set_parent_frame,
+  w32_set_skip_taskbar,
+  w32_set_no_focus_on_map,
+  w32_set_no_accept_focus,
+  w32_set_z_group,
   0, /* x_set_override_redirect */
-  x_set_no_special_glyphs,
+  gui_set_no_special_glyphs,
 };
 
 void
@@ -10209,6 +10209,7 @@ syms_of_w32fns (void)
   track_mouse_window = NULL;
 
   w32_visible_system_caret_hwnd = NULL;
+  PDUMPER_IGNORE (w32_visible_system_caret_hwnd);
 
   DEFSYM (Qundefined_color, "undefined-color");
   DEFSYM (Qcancel_timer, "cancel-timer");
@@ -10254,7 +10255,7 @@ syms_of_w32fns (void)
   DEFSYM (Qjson, "json");
 
   Fput (Qundefined_color, Qerror_conditions,
-       listn (CONSTYPE_PURE, 2, Qundefined_color, Qerror));
+       pure_list (Qundefined_color, Qerror));
   Fput (Qundefined_color, Qerror_message,
        build_pure_c_string ("Undefined color"));
 
@@ -10902,6 +10903,15 @@ globals_of_w32fns (void)
              doc: /* The ANSI code page used by the system.  */);
   w32_ansi_code_page = GetACP ();
 
+#ifndef CYGWIN
+  DEFVAR_INT ("w32-multibyte-code-page",
+             w32_multibyte_code_page,
+             doc: /* The current multibyte code page used by the system.
+A value of zero indicates that the single-byte code page is in use,
+see `w32-ansi-code-page'.  */);
+  w32_multibyte_code_page = _getmbcp ();
+#endif
+
   if (os_subtype == OS_NT)
     w32_unicode_gui = 1;
   else
diff --git a/src/w32font.c b/src/w32font.c
index 798869b..848016d 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -1,5 +1,5 @@
 /* Font backend for the Microsoft Windows API.
-   Copyright (C) 2007-2018 Free Software Foundation, Inc.
+   Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -33,6 +33,8 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "w32.h"
 #endif
 
+#include "pdumper.h"
+
 /* Cleartype available on Windows XP, cleartype_natural from XP SP1.
    The latter does not try to fit cleartype smoothed fonts into the
    same bounding box as the non-antialiased version of the font.
@@ -676,7 +678,7 @@ w32font_draw (struct glyph_string *s, int from, int to,
         characters, because drawing background with font dimensions
         in those cases makes the display illegible.  There's only one
         more call to the draw method with with_background set to
-        true, and that's in x_draw_glyph_string_foreground, when
+        true, and that's in w32_draw_glyph_string_foreground, when
         drawing the cursor, where we have no such heuristics
         available.  FIXME.  */
       if (s->first_glyph->type == GLYPHLESS_GLYPH
@@ -2624,6 +2626,9 @@ struct font_driver w32font_driver =
 
 /* Initialize state that does not change between invocations. This is only
    called when Emacs is dumped.  */
+
+static void syms_of_w32font_for_pdumper (void);
+
 void
 syms_of_w32font (void)
 {
@@ -2803,6 +2808,12 @@ versions of Windows) characters.  */);
 
   defsubr (&Sx_select_font);
 
+  pdumper_do_now_and_after_load (syms_of_w32font_for_pdumper);
+}
+
+static void
+syms_of_w32font_for_pdumper (void)
+{
   register_font_driver (&w32font_driver, NULL);
 }
 
diff --git a/src/w32font.h b/src/w32font.h
index 5c216cb..65f42a3 100644
--- a/src/w32font.h
+++ b/src/w32font.h
@@ -1,5 +1,5 @@
 /* Shared GDI and Uniscribe Font backend declarations for the Windows API.
-   Copyright (C) 2007-2018 Free Software Foundation, Inc.
+   Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/w32gui.h b/src/w32gui.h
index ddef433..5dcbbd9 100644
--- a/src/w32gui.h
+++ b/src/w32gui.h
@@ -1,5 +1,5 @@
 /* Definitions and headers for communication on the Microsoft Windows API.
-   Copyright (C) 1995, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1995, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -42,8 +42,6 @@ typedef struct _XGCValues
 typedef HBITMAP Pixmap;
 typedef HBITMAP Bitmap;
 
-typedef char * XrmDatabase;
-
 typedef XGCValues * GC;
 typedef COLORREF Color;
 typedef HWND Window;
diff --git a/src/w32heap.c b/src/w32heap.c
index 8c94682..9a59a1f 100644
--- a/src/w32heap.c
+++ b/src/w32heap.c
@@ -1,5 +1,5 @@
 /* Heap management routines for GNU Emacs on the Microsoft Windows API.
-   Copyright (C) 1994, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1994, 2001-2019 Free Software Foundation, Inc.
 
    This file is part of GNU Emacs.
 
@@ -28,7 +28,7 @@
   Memory allocation scheme for w32/w64:
 
   - Buffers are mmap'ed using a very simple emulation of mmap/munmap
-  - During the temacs phase:
+  - During the temacs phase, if unexec is to be used:
     * we use a private heap declared to be stored into the `dumped_data'
     * unfortunately, this heap cannot be made growable, so the size of
       blocks it can allocate is limited to (0x80000 - pagesize)
@@ -37,7 +37,7 @@
       We use a very simple first-fit scheme to reuse those blocks.
     * we check that the private heap does not cross the area used
       by the bigger chunks.
-  - During the emacs phase:
+  - During the emacs phase, or always if pdumper is used:
     * we create a private heap for new memory blocks
     * we make sure that we never free a block that has been dumped.
       Freeing a dumped block could work in principle, but may prove
@@ -115,10 +115,16 @@ typedef struct _RTL_HEAP_PARAMETERS {
    than half of the size stated below.  It would be nice to find a way
    to build only the first bootstrap-emacs.exe with the large size,
    and reset that to a lower value afterwards.  */
-#if defined _WIN64 || defined WIDE_EMACS_INT
-# define DUMPED_HEAP_SIZE (23*1024*1024)
+#ifndef HAVE_UNEXEC
+/* We don't use dumped_data[], so define to a small size that won't
+   matter.  */
+# define DUMPED_HEAP_SIZE 10
 #else
-# define DUMPED_HEAP_SIZE (13*1024*1024)
+# if defined _WIN64 || defined WIDE_EMACS_INT
+#  define DUMPED_HEAP_SIZE (23*1024*1024)
+# else
+#  define DUMPED_HEAP_SIZE (13*1024*1024)
+# endif
 #endif
 
 static unsigned char dumped_data[DUMPED_HEAP_SIZE];
@@ -173,8 +179,8 @@ static DWORD          blocks_number = 0;
 static unsigned char *bc_limit;
 
 /* Handle for the private heap:
-    - inside the dumped_data[] array before dump,
-    - outside of it after dump.
+    - inside the dumped_data[] array before dump with unexec,
+    - outside of it after dump, or always if pdumper is used.
 */
 HANDLE heap = NULL;
 
@@ -188,8 +194,8 @@ free_fn the_free_fn;
      
http://stackoverflow.com/questions/307060/what-is-the-purpose-of-allocating-pages-in-the-pagefile-with-createfilemapping
  */
 
 /* This is the function to commit memory when the heap allocator
-   claims for new memory.  Before dumping, we allocate space
-   from the fixed size dumped_data[] array.
+   claims for new memory.  Before dumping with unexec, we allocate
+   space from the fixed size dumped_data[] array.
 */
 static NTSTATUS NTAPI
 dumped_data_commit (PVOID Base, PVOID *CommitAddress, PSIZE_T CommitSize)
@@ -224,14 +230,13 @@ typedef WINBASEAPI BOOL (WINAPI * 
HeapSetInformation_Proc)(HANDLE,HEAP_INFORMATI
 #endif
 
 void
-init_heap (void)
+init_heap (bool use_dynamic_heap)
 {
-  if (using_dynamic_heap)
+  /* FIXME: Remove the condition, the 'else' branch below, and all the
+     related definitions and code, including dumped_data[], when unexec
+     support is removed from Emacs.  */
+  if (use_dynamic_heap)
     {
-#ifndef MINGW_W64
-      unsigned long enable_lfh = 2;
-#endif
-
       /* After dumping, use a new private heap.  We explicitly enable
          the low fragmentation heap (LFH) here, for the sake of pre
          Vista versions.  Note: this will harmlessly fail on Vista and
@@ -248,6 +253,7 @@ init_heap (void)
       heap = HeapCreate (0, 0, 0);
 
 #ifndef MINGW_W64
+      unsigned long enable_lfh = 2;
       /* Set the low-fragmentation heap for OS before Vista.  */
       HMODULE hm_kernel32dll = LoadLibrary ("kernel32.dll");
       HeapSetInformation_Proc s_pfn_Heap_Set_Information =
@@ -276,7 +282,7 @@ init_heap (void)
           the_free_fn = free_after_dump;
         }
     }
-  else
+  else /* Before dumping with unexec: use static heap.  */
     {
       /* Find the RtlCreateHeap function.  Headers for this function
          are provided with the w32 DDK, but the function is available
@@ -355,6 +361,8 @@ malloc_after_dump (size_t size)
   return p;
 }
 
+/* FIXME: The *_before_dump functions should be removed when pdumper
+   becomes the only dumping method.  */
 void *
 malloc_before_dump (size_t size)
 {
@@ -589,7 +597,7 @@ free_after_dump_9x (void *ptr)
     }
 }
 
-#ifdef ENABLE_CHECKING
+#if defined HAVE_UNEXEC && defined ENABLE_CHECKING
 void
 report_temacs_memory_usage (void)
 {
diff --git a/src/w32heap.h b/src/w32heap.h
index fdf2e2c..13f7a63 100644
--- a/src/w32heap.h
+++ b/src/w32heap.h
@@ -1,5 +1,5 @@
 /* Heap management routines (including unexec) for GNU Emacs on Windows NT.
-   Copyright (C) 1994, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1994, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -31,7 +31,6 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.
 extern unsigned char *get_data_start (void);
 extern unsigned char *get_data_end (void);
 extern size_t         reserved_heap_size;
-extern BOOL           using_dynamic_heap;
 
 extern void *mmap_realloc (void **, size_t);
 extern void  mmap_free (void **);
@@ -43,7 +42,7 @@ extern void report_temacs_memory_usage (void);
 extern void *sbrk (ptrdiff_t size);
 
 /* Initialize heap structures for sbrk on startup.  */
-extern void init_heap (void);
+extern void init_heap (bool);
 
 /* ----------------------------------------------------------------- */
 /* Useful routines for manipulating memory-mapped files.  */
diff --git a/src/w32inevt.c b/src/w32inevt.c
index f5558bb..fc1f90c 100644
--- a/src/w32inevt.c
+++ b/src/w32inevt.c
@@ -1,5 +1,5 @@
 /* Input event support for Emacs on the Microsoft Windows API.
-   Copyright (C) 1992-1993, 1995, 2001-2018 Free Software Foundation,
+   Copyright (C) 1992-1993, 1995, 2001-2019 Free Software Foundation,
    Inc.
 
 This file is part of GNU Emacs.
@@ -680,7 +680,7 @@ handle_file_notifications (struct input_event *hold_quit)
                     already be defined at this point.  */
                  Lisp_Object fname
                    = code_convert_string_norecord (utf_16_fn, cs, 0);
-                 Lisp_Object action = lispy_file_action (fni->Action);
+                 Lisp_Object action = w32_lispy_file_action (fni->Action);
 
                  inev.kind = FILE_NOTIFY_EVENT;
                  inev.timestamp = GetTickCount ();
diff --git a/src/w32inevt.h b/src/w32inevt.h
index 0628b20..5832c3f 100644
--- a/src/w32inevt.h
+++ b/src/w32inevt.h
@@ -1,5 +1,5 @@
 /* Input routines for GNU Emacs on the Microsoft Windows API.
-   Copyright (C) 1995, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1995, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/w32menu.c b/src/w32menu.c
index a2d39c5..669161c 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -1,5 +1,5 @@
 /* Menu support for GNU Emacs on the Microsoft Windows API.
-   Copyright (C) 1986, 1988, 1993-1994, 1996, 1998-1999, 2001-2018 Free
+   Copyright (C) 1986, 1988, 1993-1994, 1996, 1998-1999, 2001-2019 Free
    Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -30,6 +30,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "buffer.h"
 #include "coding.h"    /* for ENCODE_SYSTEM */
 #include "menu.h"
+#include "pdumper.h"
 
 /* This may include sys/types.h, and that somehow loses
    if this is not done before the other system files.  */
@@ -152,7 +153,7 @@ w32_popup_dialog (struct frame *f, Lisp_Object header, 
Lisp_Object contents)
    This way we can safely execute Lisp code.  */
 
 void
-x_activate_menubar (struct frame *f)
+w32_activate_menubar (struct frame *f)
 {
   set_frame_menubar (f, false, true);
 
@@ -1468,7 +1469,7 @@ w32_menu_display_help (HWND owner, HMENU menu, UINT item, 
UINT flags)
 {
   if (get_menu_item_info)
     {
-      struct frame *f = x_window_to_frame (&one_w32_display_info, owner);
+      struct frame *f = w32_window_to_frame (&one_w32_display_info, owner);
       Lisp_Object frame, help;
 
       /* No help echo on owner-draw menu items, or when the keyboard
@@ -1586,6 +1587,7 @@ syms_of_w32menu (void)
   globals_of_w32menu ();
 
   current_popup_menu = NULL;
+  PDUMPER_IGNORE (current_popup_menu);
 
   DEFSYM (Qdebug_on_next_call, "debug-on-next-call");
   DEFSYM (Qunsupported__w32_dialog, "unsupported--w32-dialog");
diff --git a/src/w32notify.c b/src/w32notify.c
index 67385b8..53787fd 100644
--- a/src/w32notify.c
+++ b/src/w32notify.c
@@ -1,6 +1,6 @@
 /* Filesystem notifications support for GNU Emacs on the Microsoft Windows API.
 
-Copyright (C) 2012-2018 Free Software Foundation, Inc.
+Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 Author: Eli Zaretskii <address@hidden>
 
diff --git a/src/w32proc.c b/src/w32proc.c
index cb02ba6..75e345a 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -1,6 +1,6 @@
 /* Process support for GNU Emacs on the Microsoft Windows API.
 
-Copyright (C) 1992, 1995, 1999-2018 Free Software Foundation, Inc.
+Copyright (C) 1992, 1995, 1999-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -81,6 +81,82 @@ static sigset_t sig_mask;
 
 static CRITICAL_SECTION crit_sig;
 
+/* Catch memory allocation before the heap allocation scheme is set
+   up.  These functions should never be called, unless code is added
+   early on in 'main' that runs before init_heap is called.  */
+_Noreturn void * malloc_before_init (size_t);
+_Noreturn void * realloc_before_init (void *, size_t);
+_Noreturn void   free_before_init (void *);
+
+_Noreturn void *
+malloc_before_init (size_t size)
+{
+  fprintf (stderr,
+          "error: 'malloc' called before setting up heap allocation; 
exiting.\n");
+  exit (-1);
+}
+
+_Noreturn void *
+realloc_before_init (void *ptr, size_t size)
+{
+  fprintf (stderr,
+          "error: 'realloc' called before setting up heap allocation; 
exiting.\n");
+  exit (-1);
+}
+
+_Noreturn void
+free_before_init (void *ptr)
+{
+  fprintf (stderr,
+          "error: 'free' called before setting up heap allocation; 
exiting.\n");
+  exit (-1);
+}
+
+extern BOOL ctrl_c_handler (unsigned long type);
+
+/* MinGW64 doesn't add a leading underscore to external symbols,
+   whereas configure.ac sets up LD_SWITCH_SYSTEM_TEMACS to force the
+   entry point at __start, with two underscores.  */
+#ifdef __MINGW64__
+#define _start __start
+#endif
+
+extern void mainCRTStartup (void);
+
+/* Startup code for running on NT.  When we are running as the dumped
+   version, we need to bootstrap our heap and .bss section into our
+   address space before we can actually hand off control to the startup
+   code supplied by NT (primarily because that code relies upon malloc ()).  */
+void _start (void);
+
+void
+_start (void)
+{
+
+#if 1
+  /* Give us a way to debug problems with crashes on startup when
+     running under the MSVC profiler. */
+  if (GetEnvironmentVariable ("EMACS_DEBUG", NULL, 0) > 0)
+    DebugBreak ();
+#endif
+
+  the_malloc_fn = malloc_before_init;
+  the_realloc_fn = realloc_before_init;
+  the_free_fn = free_before_init;
+
+  /* Cache system info, e.g., the NT page size.  */
+  cache_system_info ();
+
+  /* This prevents ctrl-c's in shells running while we're suspended from
+     having us exit.  */
+  SetConsoleCtrlHandler ((PHANDLER_ROUTINE) ctrl_c_handler, TRUE);
+
+  /* Prevent Emacs from being locked up (eg. in batch mode) when
+     accessing devices that aren't mounted (eg. removable media drives).  */
+  SetErrorMode (SEM_FAILCRITICALERRORS);
+  mainCRTStartup ();
+}
+
 /* Improve on the CRT 'signal' implementation so that we could record
    the SIGCHLD handler and fake interval timers.  */
 signal_handler
@@ -1528,6 +1604,78 @@ waitpid (pid_t pid, int *status, int options)
   return pid;
 }
 
+int
+open_input_file (file_data *p_file, char *filename)
+{
+  HANDLE file;
+  HANDLE file_mapping;
+  void  *file_base;
+  unsigned long size, upper_size;
+
+  file = CreateFileA (filename, GENERIC_READ, FILE_SHARE_READ, NULL,
+                     OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
+  if (file == INVALID_HANDLE_VALUE)
+    return FALSE;
+
+  size = GetFileSize (file, &upper_size);
+  file_mapping = CreateFileMapping (file, NULL, PAGE_READONLY,
+                                   0, size, NULL);
+  if (!file_mapping)
+    return FALSE;
+
+  file_base = MapViewOfFile (file_mapping, FILE_MAP_READ, 0, 0, size);
+  if (file_base == 0)
+    return FALSE;
+
+  p_file->name = filename;
+  p_file->size = size;
+  p_file->file = file;
+  p_file->file_mapping = file_mapping;
+  p_file->file_base = file_base;
+
+  return TRUE;
+}
+
+/* Return pointer to section header for section containing the given
+   relative virtual address. */
+IMAGE_SECTION_HEADER *
+rva_to_section (DWORD_PTR rva, IMAGE_NT_HEADERS * nt_header)
+{
+  PIMAGE_SECTION_HEADER section;
+  int i;
+
+  section = IMAGE_FIRST_SECTION (nt_header);
+
+  for (i = 0; i < nt_header->FileHeader.NumberOfSections; i++)
+    {
+      /* Some linkers (eg. the NT SDK linker I believe) swapped the
+        meaning of these two values - or rather, they ignored
+        VirtualSize entirely and always set it to zero.  This affects
+        some very old exes (eg. gzip dated Dec 1993).  Since
+        w32_executable_type relies on this function to work reliably,
+        we need to cope with this.  */
+      DWORD_PTR real_size = max (section->SizeOfRawData,
+                            section->Misc.VirtualSize);
+      if (rva >= section->VirtualAddress
+         && rva < section->VirtualAddress + real_size)
+       return section;
+      section++;
+    }
+  return NULL;
+}
+
+/* Close the system structures associated with the given file.  */
+void
+close_file_data (file_data *p_file)
+{
+  UnmapViewOfFile (p_file->file_base);
+  CloseHandle (p_file->file_mapping);
+  /* For the case of output files, set final size.  */
+  SetFilePointer (p_file->file, p_file->size, NULL, FILE_BEGIN);
+  SetEndOfFile (p_file->file);
+  CloseHandle (p_file->file);
+}
+
 /* Old versions of w32api headers don't have separate 32-bit and
    64-bit defines, but the one they have matches the 32-bit variety.  */
 #ifndef IMAGE_NT_OPTIONAL_HDR32_MAGIC
@@ -1628,22 +1776,27 @@ w32_executable_type (char * filename,
           if (data_dir)
             {
               /* Look for Cygwin DLL in the DLL import list. */
-              IMAGE_DATA_DIRECTORY import_dir =
-                data_dir[IMAGE_DIRECTORY_ENTRY_IMPORT];
+              IMAGE_DATA_DIRECTORY import_dir
+                = data_dir[IMAGE_DIRECTORY_ENTRY_IMPORT];
 
              /* Import directory can be missing in .NET DLLs.  */
              if (import_dir.VirtualAddress != 0)
                {
+                 IMAGE_SECTION_HEADER *section
+                   = rva_to_section (import_dir.VirtualAddress, nt_header);
+                 if (!section)
+                   emacs_abort ();
+
                  IMAGE_IMPORT_DESCRIPTOR * imports =
-                   RVA_TO_PTR (import_dir.VirtualAddress,
-                               rva_to_section (import_dir.VirtualAddress,
-                                               nt_header),
+                   RVA_TO_PTR (import_dir.VirtualAddress, section,
                                executable);
 
                  for ( ; imports->Name; imports++)
                    {
-                     IMAGE_SECTION_HEADER * section =
-                       rva_to_section (imports->Name, nt_header);
+                     section = rva_to_section (imports->Name, nt_header);
+                     if (!section)
+                       emacs_abort ();
+
                      char * dllname = RVA_TO_PTR (imports->Name, section,
                                                   executable);
 
@@ -1854,9 +2007,9 @@ sys_spawnve (int mode, char *cmdname, char **argv, char 
**envp)
     }
 
   /* we have to do some conjuring here to put argv and envp into the
-     form CreateProcess wants...  argv needs to be a space separated/null
-     terminated list of parameters, and envp is a null
-     separated/double-null terminated list of parameters.
+     form CreateProcess wants...  argv needs to be a space separated/NUL
+     terminated list of parameters, and envp is a NUL
+     separated/double-NUL terminated list of parameters.
 
      Additionally, zero-length args and args containing whitespace or
      quote chars need to be wrapped in double quotes - for this to work,
@@ -3100,6 +3253,12 @@ such programs cannot be invoked by Emacs anyway.  */)
 }
 
 #ifdef HAVE_LANGINFO_CODESET
+
+/* If we are compiling for compatibility with older 32-bit Windows
+   versions, this might not be defined by the Windows headers.  */
+#ifndef LOCALE_IPAPERSIZE
+# define LOCALE_IPAPERSIZE 0x100A
+#endif
 /* Emulation of nl_langinfo.  Used in fns.c:Flocale_info.  */
 char *
 nl_langinfo (nl_item item)
@@ -3112,7 +3271,8 @@ nl_langinfo (nl_item item)
     LOCALE_SMONTHNAME1, LOCALE_SMONTHNAME2, LOCALE_SMONTHNAME3,
     LOCALE_SMONTHNAME4, LOCALE_SMONTHNAME5, LOCALE_SMONTHNAME6,
     LOCALE_SMONTHNAME7, LOCALE_SMONTHNAME8, LOCALE_SMONTHNAME9,
-    LOCALE_SMONTHNAME10, LOCALE_SMONTHNAME11, LOCALE_SMONTHNAME12
+    LOCALE_SMONTHNAME10, LOCALE_SMONTHNAME11, LOCALE_SMONTHNAME12,
+    LOCALE_IPAPERSIZE, LOCALE_IPAPERSIZE
   };
 
   static char *nl_langinfo_buf = NULL;
@@ -3121,6 +3281,8 @@ nl_langinfo (nl_item item)
   if (nl_langinfo_len <= 0)
     nl_langinfo_buf = xmalloc (nl_langinfo_len = 1);
 
+  char *retval = nl_langinfo_buf;
+
   if (item < 0 || item >= _NL_NUM)
     nl_langinfo_buf[0] = 0;
   else
@@ -3142,6 +3304,8 @@ nl_langinfo (nl_item item)
          if (nl_langinfo_len <= need_len)
            nl_langinfo_buf = xrealloc (nl_langinfo_buf,
                                        nl_langinfo_len = need_len);
+         retval = nl_langinfo_buf;
+
          if (!GetLocaleInfo (cloc, w32item[item] | LOCALE_USE_CP_ACP,
                              nl_langinfo_buf, nl_langinfo_len))
            nl_langinfo_buf[0] = 0;
@@ -3158,9 +3322,32 @@ nl_langinfo (nl_item item)
                  nl_langinfo_buf[1] = 'p';
                }
            }
+         else if (item == _NL_PAPER_WIDTH || item == _NL_PAPER_HEIGHT)
+           {
+             static const int paper_size[][2] =
+               {
+                { -1, -1 },
+                { 216, 279 },
+                { -1, -1 },
+                { -1, -1 },
+                { -1, -1 },
+                { 216, 356 },
+                { -1, -1 },
+                { -1, -1 },
+                { 297, 420 },
+                { 210, 297 }
+               };
+             int idx = atoi (nl_langinfo_buf);
+             if (0 <= idx && idx < ARRAYELTS (paper_size))
+               retval = (char *)(intptr_t) (item == _NL_PAPER_WIDTH
+                                            ? paper_size[idx][0]
+                                            : paper_size[idx][1]);
+             else
+               retval = (char *)(intptr_t) -1;
+           }
        }
     }
-  return nl_langinfo_buf;
+  return retval;
 }
 #endif /* HAVE_LANGINFO_CODESET */
 
@@ -3211,10 +3398,10 @@ If LCID (a 16-bit number) is not a valid locale, the 
result is nil.  */)
       got_full = GetLocaleInfo (XFIXNUM (lcid),
                                XFIXNUM (longform),
                                full_name, sizeof (full_name));
-      /* GetLocaleInfo's return value includes the terminating null
+      /* GetLocaleInfo's return value includes the terminating NUL
         character, when the returned information is a string, whereas
         make_unibyte_string needs the string length without the
-        terminating null.  */
+        terminating NUL.  */
       if (got_full)
        return make_unibyte_string (full_name, got_full - 1);
     }
@@ -3476,8 +3663,8 @@ If successful, the new layout id is returned, otherwise 
nil.  */)
   HKL kl;
 
   CHECK_CONS (layout);
-  CHECK_FIXNUM_CAR (layout);
-  CHECK_FIXNUM_CDR (layout);
+  CHECK_FIXNUM (XCAR (layout));
+  CHECK_FIXNUM (XCDR (layout));
 
   kl = (HKL) (UINT_PTR) ((XFIXNUM (XCAR (layout)) & 0xffff)
                         | (XFIXNUM (XCDR (layout)) << 16));
diff --git a/src/w32reg.c b/src/w32reg.c
index 4ddbaa3..844e561 100644
--- a/src/w32reg.c
+++ b/src/w32reg.c
@@ -1,6 +1,6 @@
 /* Emulate the X Resource Manager through the registry.
 
-Copyright (C) 1990, 1993-1994, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1990, 1993-1994, 2001-2019 Free Software Foundation, Inc.
 
 Author: Kevin Gallo
 
@@ -21,8 +21,8 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 #include "lisp.h"
-#include "w32term.h"   /* for XrmDatabase, xrdb */
 #include "blockinput.h"
+#include "w32term.h"
 
 #include <stdio.h>
 
@@ -73,8 +73,8 @@ w32_get_rdb_resource (const char *rdb, const char *resource)
   return NULL;
 }
 
-static char *
-w32_get_string_resource (const char *name, const char *class, DWORD dwexptype)
+static const char *
+w32_get_string_resource_1 (const char *name, const char *class, DWORD 
dwexptype)
 {
   LPBYTE lpvalue = NULL;
   HKEY hrootkey = NULL;
@@ -134,15 +134,17 @@ w32_get_string_resource (const char *name, const char 
*class, DWORD dwexptype)
       /* Check if there are Windows specific defaults defined.  */
       return w32_get_rdb_resource (SYSTEM_DEFAULT_RESOURCES, name);
     }
-  return (char *)lpvalue;
+  return (const char *)lpvalue;
 }
 
 /* Retrieve the string resource specified by NAME with CLASS from
    database RDB. */
 
-char *
-x_get_string_resource (XrmDatabase rdb, const char *name, const char *class)
+const char *
+w32_get_string_resource (void *v_rdb, const char *name, const char *class)
 {
+  const char *rdb = v_rdb;
+
   if (rdb)
     {
       char *resource;
@@ -157,5 +159,5 @@ x_get_string_resource (XrmDatabase rdb, const char *name, 
const char *class)
     /* --quick was passed, so this is a no-op.  */
     return NULL;
 
-  return w32_get_string_resource (name, class, REG_SZ);
+  return w32_get_string_resource_1 (name, class, REG_SZ);
 }
diff --git a/src/w32select.c b/src/w32select.c
index dc568d4..af4f049 100644
--- a/src/w32select.c
+++ b/src/w32select.c
@@ -1,6 +1,6 @@
 /* Selection processing for Emacs on the Microsoft Windows API.
 
-Copyright (C) 1993-1994, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1993-1994, 2001-2019 Free Software Foundation, Inc.
 
 Author: Kevin Gallo
        Benjamin Riefenstahl
@@ -803,7 +803,7 @@ DEFUN ("w32-get-clipboard-data", Fw32_get_clipboard_data,
   (void) ignored;
 
   /* Don't pass our own text from the clipboard (which might be
-     troublesome if the killed text includes null characters).  */
+     troublesome if the killed text includes NUL characters).  */
   if (!NILP (current_text))
     return ret;
 
diff --git a/src/w32select.h b/src/w32select.h
index 3b8a9ac..3f8f469 100644
--- a/src/w32select.h
+++ b/src/w32select.h
@@ -1,6 +1,6 @@
 /* Selection processing for Emacs on the Microsoft W32 API.
 
-Copyright (C) 1993-1994, 2001-2018 Free Software Foundation, Inc.
+Copyright (C) 1993-1994, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/w32term.c b/src/w32term.c
index 8d189ae..451dd54 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -1,6 +1,6 @@
 /* Implementation of GUI terminal on the Microsoft Windows API.
 
-Copyright (C) 1989, 1993-2018 Free Software Foundation, Inc.
+Copyright (C) 1989, 1993-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -87,9 +87,6 @@ extern unsigned int msh_mousewheel;
 extern int w32_codepage_for_font (char *fontname);
 extern Cursor w32_load_cursor (LPCTSTR name);
 
-#define x_any_window_to_frame x_window_to_frame
-#define x_top_window_to_frame x_window_to_frame
-
 
 /* This is display since w32 does not support multiple ones.  */
 struct w32_display_info one_w32_display_info;
@@ -171,27 +168,25 @@ static void w32_handle_tool_bar_click (struct frame *,
                                        struct input_event *);
 static void w32_define_cursor (Window, Cursor);
 
-void x_lower_frame (struct frame *);
-void x_scroll_bar_clear (struct frame *);
-void x_raise_frame (struct frame *);
-void x_wm_set_window_state (struct frame *, int);
-void x_wm_set_icon_pixmap (struct frame *, int);
+static void w32_scroll_bar_clear (struct frame *);
+static void w32_raise_frame (struct frame *);
+static void w32_lower_frame (struct frame *);
 static void w32_initialize (void);
-static void x_update_end (struct frame *);
+static void w32_update_end (struct frame *);
 static void w32_frame_up_to_date (struct frame *);
-static void x_clear_frame (struct frame *);
-static void frame_highlight (struct frame *);
-static void frame_unhighlight (struct frame *);
-static void x_new_focus_frame (struct w32_display_info *,
-                               struct frame *);
-static void x_focus_changed (int, int, struct w32_display_info *,
+static void w32_clear_frame (struct frame *);
+static void w32_frame_highlight (struct frame *);
+static void w32_frame_unhighlight (struct frame *);
+static void w32_new_focus_frame (struct w32_display_info *,
+                                 struct frame *);
+static void w32_focus_changed (int, int, struct w32_display_info *,
                              struct frame *, struct input_event *);
 static void w32_detect_focus_change (struct w32_display_info *,
                                      W32Msg *, struct input_event *);
 static void w32_frame_rehighlight (struct frame *);
-static void x_frame_rehighlight (struct w32_display_info *);
-static void x_draw_hollow_cursor (struct window *, struct glyph_row *);
-static void x_draw_bar_cursor (struct window *, struct glyph_row *, int,
+static void w32_frame_rehighlight_1 (struct w32_display_info *);
+static void w32_draw_hollow_cursor (struct window *, struct glyph_row *);
+static void w32_draw_bar_cursor (struct window *, struct glyph_row *, int,
                                enum text_cursor_kinds);
 static void w32_clip_to_row (struct window *, struct glyph_row *,
                             enum glyph_row_area, HDC);
@@ -205,7 +200,7 @@ static void my_destroy_window (struct frame *, HWND);
 static void w32fullscreen_hook (struct frame *);
 
 #ifdef GLYPH_DEBUG
-static void x_check_font (struct frame *, struct font *);
+static void w32_check_font (struct frame *, struct font *);
 #endif
 
 
@@ -263,7 +258,7 @@ XCreateGC (void *ignore, HWND wignore, unsigned long mask, 
XGCValues *xgcv)
   return gc;
 }
 
-#if 0  /* unused for now, see x_draw_image_glyph_string below */
+#if 0  /* unused for now, see w32_draw_image_glyph_string below */
 static void
 XGetGCValues (void *ignore, XGCValues *gc,
              unsigned long mask, XGCValues *xgcv)
@@ -306,7 +301,7 @@ w32_restore_glyph_string_clip (struct glyph_string *s)
 }
 
 static void
-x_get_scale_factor(struct w32_display_info *dpyinfo, int *scale_x, int 
*scale_y)
+w32_get_scale_factor(struct w32_display_info *dpyinfo, int *scale_x, int 
*scale_y)
 {
   const int base_res = 96;
 
@@ -338,7 +333,7 @@ w32_draw_underwave (struct glyph_string *s, COLORREF color)
   struct w32_display_info *dpyinfo = FRAME_DISPLAY_INFO (s->f);
 
   int scale_x, scale_y;
-  x_get_scale_factor (dpyinfo, &scale_x, &scale_y);
+  w32_get_scale_factor (dpyinfo, &scale_x, &scale_y);
 
   int wave_height = 3 * scale_y, wave_length = 2 * scale_x, thickness = 
scale_y;
   int dx, dy, x0, y0, width, x1, y1, x2, y2, odd, xmax;
@@ -363,7 +358,7 @@ w32_draw_underwave (struct glyph_string *s, COLORREF color)
   get_glyph_string_clip_rect (s, &w32_string_clip);
   CONVERT_TO_XRECT (string_clip, w32_string_clip);
 
-  if (!x_intersect_rectangles (&wave_clip, &string_clip, &final_clip))
+  if (!gui_intersect_rectangles (&wave_clip, &string_clip, &final_clip))
     return;
 
   hp = CreatePen (PS_SOLID, thickness, color);
@@ -457,8 +452,8 @@ w32_clear_window (struct frame *f)
 
 #define OPAQUE_FRAME 255
 
-void
-x_set_frame_alpha (struct frame *f)
+static void
+w32_set_frame_alpha (struct frame *f)
 {
   struct w32_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
   double alpha = 1.0;
@@ -504,7 +499,7 @@ x_set_frame_alpha (struct frame *f)
 }
 
 int
-x_display_pixel_height (struct w32_display_info *dpyinfo)
+w32_display_pixel_height (struct w32_display_info *dpyinfo)
 {
   int pixels = GetSystemMetrics (SM_CYVIRTUALSCREEN);
 
@@ -516,7 +511,7 @@ x_display_pixel_height (struct w32_display_info *dpyinfo)
 }
 
 int
-x_display_pixel_width (struct w32_display_info *dpyinfo)
+w32_display_pixel_width (struct w32_display_info *dpyinfo)
 {
   int pixels = GetSystemMetrics (SM_CXVIRTUALSCREEN);
 
@@ -534,11 +529,11 @@ x_display_pixel_width (struct w32_display_info *dpyinfo)
 
 /* Start an update of frame F.  This function is installed as a hook
    for update_begin, i.e. it is called when update_begin is called.
-   This function is called prior to calls to x_update_window_begin for
-   each window being updated.  */
+   This function is called prior to calls to w32_update_window_begin
+   for each window being updated.  */
 
 static void
-x_update_begin (struct frame *f)
+w32_update_begin (struct frame *f)
 {
   struct w32_display_info *display_info = FRAME_DISPLAY_INFO (f);
 
@@ -558,7 +553,7 @@ x_update_begin (struct frame *f)
 /* Start update of window W.  */
 
 static void
-x_update_window_begin (struct window *w)
+w32_update_window_begin (struct window *w)
 {
   struct frame *f = XFRAME (WINDOW_FRAME (w));
   Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
@@ -698,7 +693,7 @@ w32_draw_window_divider (struct window *w, int x0, int x1, 
int y0, int y1)
    here. */
 
 static void
-x_update_window_end (struct window *w, bool cursor_on_p,
+w32_update_window_end (struct window *w, bool cursor_on_p,
                     bool mouse_face_overwritten_p)
 {
   if (!w->pseudo_window_p)
@@ -713,9 +708,9 @@ x_update_window_end (struct window *w, bool cursor_on_p,
       if (draw_window_fringes (w, true))
        {
          if (WINDOW_RIGHT_DIVIDER_WIDTH (w))
-           x_draw_right_divider (w);
+           gui_draw_right_divider (w);
          else
-           x_draw_vertical_border (w);
+           gui_draw_vertical_border (w);
        }
 
       unblock_input ();
@@ -734,7 +729,7 @@ x_update_window_end (struct window *w, bool cursor_on_p,
 
   /* Unhide the caret.  This won't actually show the cursor, unless it
      was visible before the corresponding call to HideCaret in
-     x_update_window_begin.  */
+     w32_update_window_begin.  */
   if (w32_use_visible_system_caret && w32_system_caret_hwnd)
     {
       SendMessageTimeout (w32_system_caret_hwnd, WM_EMACS_SHOW_CARET, 0, 0,
@@ -747,7 +742,7 @@ x_update_window_end (struct window *w, bool cursor_on_p,
    update_end.  */
 
 static void
-x_update_end (struct frame *f)
+w32_update_end (struct frame *f)
 {
   if (! FRAME_W32_P (f))
     return;
@@ -775,7 +770,7 @@ w32_frame_up_to_date (struct frame *f)
    between bitmaps to be drawn between current row and DESIRED_ROW.  */
 
 static void
-x_after_update_window_line (struct window *w, struct glyph_row *desired_row)
+w32_after_update_window_line (struct window *w, struct glyph_row *desired_row)
 {
   struct frame *f;
   int width, height;
@@ -800,29 +795,32 @@ x_after_update_window_line (struct window *w, struct 
glyph_row *desired_row)
          height > 0))
     {
       int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y));
+      int face_id =
+       !NILP (Vface_remapping_alist)
+       ? lookup_basic_face (NULL, f, INTERNAL_BORDER_FACE_ID)
+       : INTERNAL_BORDER_FACE_ID;
+      struct face *face = FACE_FROM_ID_OR_NULL (f, face_id);
 
       block_input ();
-      {
-       HDC hdc = get_frame_dc (f);
-       struct face *face = FACE_FROM_ID_OR_NULL (f, INTERNAL_BORDER_FACE_ID);
 
-       if (face)
-         {
-           /* Fill border with internal border face.  */
-           unsigned long color = face->background;
+      HDC hdc = get_frame_dc (f);
+      if (face)
+       {
+         /* Fill border with internal border face.  */
+         unsigned long color = face->background;
+
+         w32_fill_area (f, hdc, color, 0, y, width, height);
+         w32_fill_area (f, hdc, color, FRAME_PIXEL_WIDTH (f) - width,
+                        y, width, height);
+       }
+      else
+       {
+         w32_clear_area (f, hdc, 0, y, width, height);
+         w32_clear_area (f, hdc, FRAME_PIXEL_WIDTH (f) - width,
+                         y, width, height);
+       }
+      release_frame_dc (f, hdc);
 
-           w32_fill_area (f, hdc, color, 0, y, width, height);
-           w32_fill_area (f, hdc, color, FRAME_PIXEL_WIDTH (f) - width,
-                          y, width, height);
-         }
-       else
-         {
-           w32_clear_area (f, hdc, 0, y, width, height);
-           w32_clear_area (f, hdc, FRAME_PIXEL_WIDTH (f) - width,
-                           y, width, height);
-         }
-       release_frame_dc (f, hdc);
-      }
       unblock_input ();
     }
 }
@@ -939,27 +937,27 @@ w32_destroy_fringe_bitmap (int which)
 
 /* Function prototypes of this page.  */
 
-static void x_set_glyph_string_clipping (struct glyph_string *);
-static void x_set_glyph_string_gc (struct glyph_string *);
-static void x_draw_glyph_string_background (struct glyph_string *,
-                                            bool);
-static void x_draw_glyph_string_foreground (struct glyph_string *);
-static void x_draw_composite_glyph_string_foreground (struct glyph_string *);
-static void x_draw_glyph_string_box (struct glyph_string *);
-static void x_draw_glyph_string  (struct glyph_string *);
-static void x_set_cursor_gc (struct glyph_string *);
-static void x_set_mode_line_face_gc (struct glyph_string *);
-static void x_set_mouse_face_gc (struct glyph_string *);
+static void w32_set_glyph_string_clipping (struct glyph_string *);
+static void w32_set_glyph_string_gc (struct glyph_string *);
+static void w32_draw_glyph_string_background (struct glyph_string *,
+                                              bool);
+static void w32_draw_glyph_string_foreground (struct glyph_string *);
+static void w32_draw_composite_glyph_string_foreground (struct glyph_string *);
+static void w32_draw_glyph_string_box (struct glyph_string *);
+static void w32_draw_glyph_string  (struct glyph_string *);
+static void w32_set_cursor_gc (struct glyph_string *);
+static void w32_set_mode_line_face_gc (struct glyph_string *);
+static void w32_set_mouse_face_gc (struct glyph_string *);
 static int w32_alloc_lighter_color (struct frame *, COLORREF *, double, int);
 static void w32_setup_relief_color (struct frame *, struct relief *,
                                     double, int, COLORREF);
-static void x_setup_relief_colors (struct glyph_string *);
-static void x_draw_image_glyph_string (struct glyph_string *);
-static void x_draw_image_relief (struct glyph_string *);
-static void x_draw_image_foreground (struct glyph_string *);
+static void w32_setup_relief_colors (struct glyph_string *);
+static void w32_draw_image_glyph_string (struct glyph_string *);
+static void w32_draw_image_relief (struct glyph_string *);
+static void w32_draw_image_foreground (struct glyph_string *);
 static void w32_draw_image_foreground_1 (struct glyph_string *, HBITMAP);
-static void x_clear_glyph_string_rect (struct glyph_string *, int,
-                                       int, int, int);
+static void w32_clear_glyph_string_rect (struct glyph_string *, int,
+                                         int, int, int);
 static void w32_draw_relief_rect (struct frame *, int, int, int, int,
                                   int, int, int, int, int, int,
                                   RECT *);
@@ -971,7 +969,7 @@ static void w32_draw_box_rect (struct glyph_string *, int, 
int, int, int,
    face.  */
 
 static void
-x_set_cursor_gc (struct glyph_string *s)
+w32_set_cursor_gc (struct glyph_string *s)
 {
   if (s->font == FRAME_FONT (s->f)
       && s->face->background == FRAME_BACKGROUND_PIXEL (s->f)
@@ -1007,7 +1005,7 @@ x_set_cursor_gc (struct glyph_string *s)
          xgcv.foreground = s->face->background;
        }
 
-      IF_DEBUG (x_check_font (s->f, s->font));
+      IF_DEBUG (w32_check_font (s->f, s->font));
       xgcv.font = s->font;
       mask = GCForeground | GCBackground | GCFont;
 
@@ -1026,7 +1024,7 @@ x_set_cursor_gc (struct glyph_string *s)
 /* Set up S->gc of glyph string S for drawing text in mouse face.  */
 
 static void
-x_set_mouse_face_gc (struct glyph_string *s)
+w32_set_mouse_face_gc (struct glyph_string *s)
 {
   int face_id;
   struct face *face;
@@ -1056,7 +1054,7 @@ x_set_mouse_face_gc (struct glyph_string *s)
 
       xgcv.background = s->face->background;
       xgcv.foreground = s->face->foreground;
-      IF_DEBUG (x_check_font (s->f, s->font));
+      IF_DEBUG (w32_check_font (s->f, s->font));
       xgcv.font = s->font;
       mask = GCForeground | GCBackground | GCFont;
 
@@ -1079,7 +1077,7 @@ x_set_mouse_face_gc (struct glyph_string *s)
    matrix was built, so there isn't much to do, here.  */
 
 static inline void
-x_set_mode_line_face_gc (struct glyph_string *s)
+w32_set_mode_line_face_gc (struct glyph_string *s)
 {
   s->gc = s->face->gc;
 }
@@ -1090,7 +1088,7 @@ x_set_mode_line_face_gc (struct glyph_string *s)
    pattern.  */
 
 static inline void
-x_set_glyph_string_gc (struct glyph_string *s)
+w32_set_glyph_string_gc (struct glyph_string *s)
 {
   prepare_face_for_display (s->f, s->face);
 
@@ -1101,17 +1099,17 @@ x_set_glyph_string_gc (struct glyph_string *s)
     }
   else if (s->hl == DRAW_INVERSE_VIDEO)
     {
-      x_set_mode_line_face_gc (s);
+      w32_set_mode_line_face_gc (s);
       s->stippled_p = s->face->stipple != 0;
     }
   else if (s->hl == DRAW_CURSOR)
     {
-      x_set_cursor_gc (s);
+      w32_set_cursor_gc (s);
       s->stippled_p = false;
     }
   else if (s->hl == DRAW_MOUSE_FACE)
     {
-      x_set_mouse_face_gc (s);
+      w32_set_mouse_face_gc (s);
       s->stippled_p = s->face->stipple != 0;
     }
   else if (s->hl == DRAW_IMAGE_RAISED
@@ -1132,7 +1130,7 @@ x_set_glyph_string_gc (struct glyph_string *s)
    line or menu if we don't have X toolkit support.  */
 
 static inline void
-x_set_glyph_string_clipping (struct glyph_string *s)
+w32_set_glyph_string_clipping (struct glyph_string *s)
 {
   RECT *r = s->clip;
   int n = get_glyph_string_clip_rects (s, r, 2);
@@ -1156,8 +1154,8 @@ x_set_glyph_string_clipping (struct glyph_string *s)
    the area of SRC.  */
 
 static void
-x_set_glyph_string_clipping_exactly (struct glyph_string *src,
-                                    struct glyph_string *dst)
+w32_set_glyph_string_clipping_exactly (struct glyph_string *src,
+                                       struct glyph_string *dst)
 {
   RECT r;
 
@@ -1202,7 +1200,7 @@ w32_compute_glyph_string_overhangs (struct glyph_string 
*s)
 /* Fill rectangle X, Y, W, H with background color of glyph string S.  */
 
 static inline void
-x_clear_glyph_string_rect (struct glyph_string *s,
+w32_clear_glyph_string_rect (struct glyph_string *s,
                           int x, int y, int w, int h)
 {
   int real_x = x;
@@ -1233,7 +1231,7 @@ x_clear_glyph_string_rect (struct glyph_string *s,
    contains the first component of a composition.  */
 
 static void
-x_draw_glyph_string_background (struct glyph_string *s, bool force_p)
+w32_draw_glyph_string_background (struct glyph_string *s, bool force_p)
 {
   /* Nothing to do if background has already been drawn or if it
      shouldn't be drawn in the first place.  */
@@ -1265,7 +1263,7 @@ x_draw_glyph_string_background (struct glyph_string *s, 
bool force_p)
               || s->extends_to_end_of_line_p
               || force_p)
        {
-         x_clear_glyph_string_rect (s, s->x, s->y + box_line_width,
+         w32_clear_glyph_string_rect (s, s->x, s->y + box_line_width,
                                     s->background_width,
                                     s->height - 2 * box_line_width);
          s->background_filled_p = true;
@@ -1277,7 +1275,7 @@ x_draw_glyph_string_background (struct glyph_string *s, 
bool force_p)
 /* Draw the foreground of glyph string S.  */
 
 static void
-x_draw_glyph_string_foreground (struct glyph_string *s)
+w32_draw_glyph_string_foreground (struct glyph_string *s)
 {
   int i, x;
 
@@ -1334,7 +1332,7 @@ x_draw_glyph_string_foreground (struct glyph_string *s)
 /* Draw the foreground of composite glyph string S.  */
 
 static void
-x_draw_composite_glyph_string_foreground (struct glyph_string *s)
+w32_draw_composite_glyph_string_foreground (struct glyph_string *s)
 {
   int i, j, x;
   struct font *font = s->font;
@@ -1429,7 +1427,7 @@ x_draw_composite_glyph_string_foreground (struct 
glyph_string *s)
 /* Draw the foreground of glyph string S for glyphless characters.  */
 
 static void
-x_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
+w32_draw_glyphless_glyph_string_foreground (struct glyph_string *s)
 {
   struct glyph *glyph = s->first_glyph;
   XChar2b char2b[8];
@@ -1595,8 +1593,8 @@ w32_alloc_lighter_color (struct frame *f, COLORREF *color,
 /* On frame F, translate pixel colors to RGB values for the NCOLORS
    colors in COLORS.  On W32, we no longer try to map colors to
    a palette.  */
-void
-x_query_colors (struct frame *f, XColor *colors, int ncolors)
+static void
+w32_query_colors (struct frame *f, XColor *colors, int ncolors)
 {
   int i;
 
@@ -1610,13 +1608,15 @@ x_query_colors (struct frame *f, XColor *colors, int 
ncolors)
     }
 }
 
-void
-x_query_color (struct frame *f, XColor *color)
+/* Store F's background color into *BGCOLOR.  */
+
+static void
+w32_query_frame_background_color (struct frame *f, XColor *bgcolor)
 {
-  x_query_colors (f, color, 1);
+  bgcolor->pixel = FRAME_BACKGROUND_PIXEL (f);
+  w32_query_colors (f, bgcolor, 1);
 }
 
-
 /* Set up the foreground color for drawing relief lines of glyph
    string S.  RELIEF is a pointer to a struct relief containing the GC
    with which lines will be drawn.  Use a color that is FACTOR or
@@ -1662,7 +1662,7 @@ w32_setup_relief_color (struct frame *f, struct relief 
*relief, double factor,
 /* Set up colors for the relief lines around glyph string S.  */
 
 static void
-x_setup_relief_colors (struct glyph_string *s)
+w32_setup_relief_colors (struct glyph_string *s)
 {
   struct w32_output *di = s->f->output_data.w32;
   COLORREF color;
@@ -1796,7 +1796,7 @@ w32_draw_box_rect (struct glyph_string *s,
 /* Draw a box around glyph string S.  */
 
 static void
-x_draw_glyph_string_box (struct glyph_string *s)
+w32_draw_glyph_string_box (struct glyph_string *s)
 {
   int width, left_x, right_x, top_y, bottom_y, last_x;
   bool left_p, right_p, raised_p;
@@ -1837,7 +1837,7 @@ x_draw_glyph_string_box (struct glyph_string *s)
                        left_p, right_p, &clip_rect);
   else
     {
-      x_setup_relief_colors (s);
+      w32_setup_relief_colors (s);
       w32_draw_relief_rect (s->f, left_x, top_y, right_x, bottom_y,
                             width, raised_p, 1, 1, left_p, right_p, 
&clip_rect);
     }
@@ -1847,7 +1847,7 @@ x_draw_glyph_string_box (struct glyph_string *s)
 /* Draw foreground of image glyph string S.  */
 
 static void
-x_draw_image_foreground (struct glyph_string *s)
+w32_draw_image_foreground (struct glyph_string *s)
 {
   int x = s->x;
   int y = s->ybase - image_ascent (s->img, s->face, &s->slice);
@@ -1874,9 +1874,42 @@ x_draw_image_foreground (struct glyph_string *s)
       HBRUSH fg_brush = CreateSolidBrush (s->gc->foreground);
       HBRUSH orig_brush = SelectObject (s->hdc, fg_brush);
       HGDIOBJ orig_obj = SelectObject (compat_hdc, s->img->pixmap);
+      LONG orig_width, orig_height;
+      DIBSECTION dib;
       SetBkColor (compat_hdc, RGB (255, 255, 255));
       SetTextColor (s->hdc, RGB (0, 0, 0));
-      x_set_glyph_string_clipping (s);
+      w32_set_glyph_string_clipping (s);
+      /* Extract the original dimensions of the bitmap.  */
+      if (GetObject (s->img->pixmap, sizeof (dib), &dib) > 0)
+       {
+         BITMAP bmp = dib.dsBm;
+         orig_width = bmp.bmWidth;
+         orig_height = bmp.bmHeight;
+       }
+      else
+       {
+         DebPrint (("w32_draw_image_foreground: GetObject failed!\n"));
+         orig_width = s->slice.width;
+         orig_height = s->slice.height;
+       }
+
+      double w_factor = 1.0, h_factor = 1.0;
+      bool scaled = false;
+      int orig_slice_width  = s->slice.width,
+         orig_slice_height = s->slice.height;
+      int orig_slice_x = s->slice.x, orig_slice_y = s->slice.y;
+      /* For scaled images we need to restore the original slice's
+        dimensions and origin coordinates, from before the scaling.  */
+      if (s->img->width != orig_width || s->img->height != orig_height)
+       {
+         scaled = true;
+         w_factor = (double) orig_width  / (double) s->img->width;
+         h_factor = (double) orig_height / (double) s->img->height;
+         orig_slice_width = s->slice.width * w_factor + 0.5;
+         orig_slice_height = s->slice.height * h_factor + 0.5;
+         orig_slice_x = s->slice.x * w_factor + 0.5;
+         orig_slice_y = s->slice.y * h_factor + 0.5;
+       }
 
       if (s->img->mask)
        {
@@ -1885,14 +1918,36 @@ x_draw_image_foreground (struct glyph_string *s)
 
          SetTextColor (s->hdc, RGB (255, 255, 255));
          SetBkColor (s->hdc, RGB (0, 0, 0));
-
-         BitBlt (s->hdc, x, y, s->slice.width, s->slice.height,
-                 compat_hdc, s->slice.x, s->slice.y, SRCINVERT);
-         BitBlt (s->hdc, x, y, s->slice.width, s->slice.height,
-                 mask_dc, s->slice.x, s->slice.y, SRCAND);
-         BitBlt (s->hdc, x, y, s->slice.width, s->slice.height,
-                 compat_hdc, s->slice.x, s->slice.y, SRCINVERT);
-
+         if (!scaled)
+           {
+             BitBlt (s->hdc, x, y, s->slice.width, s->slice.height,
+                     compat_hdc, s->slice.x, s->slice.y, SRCINVERT);
+             BitBlt (s->hdc, x, y, s->slice.width, s->slice.height,
+                     mask_dc, s->slice.x, s->slice.y, SRCAND);
+             BitBlt (s->hdc, x, y, s->slice.width, s->slice.height,
+                     compat_hdc, s->slice.x, s->slice.y, SRCINVERT);
+           }
+         else
+           {
+             int pmode = 0;
+             /* HALFTONE produces better results, especially when
+                scaling to a larger size, but Windows 9X doesn't
+                support HALFTONE.  */
+             if (os_subtype == OS_NT
+                 && (pmode = SetStretchBltMode (s->hdc, HALFTONE)) != 0)
+               SetBrushOrgEx (s->hdc, 0, 0, NULL);
+             StretchBlt (s->hdc, x, y, s->slice.width, s->slice.height,
+                         compat_hdc, orig_slice_x, orig_slice_y,
+                         orig_slice_width, orig_slice_height, SRCINVERT);
+             StretchBlt (s->hdc, x, y, s->slice.width, s->slice.height,
+                         mask_dc, orig_slice_x, orig_slice_y,
+                         orig_slice_width, orig_slice_height, SRCAND);
+             StretchBlt (s->hdc, x, y, s->slice.width, s->slice.height,
+                         compat_hdc, orig_slice_x, orig_slice_y,
+                         orig_slice_width, orig_slice_height, SRCINVERT);
+             if (pmode)
+               SetStretchBltMode (s->hdc, pmode);
+           }
          SelectObject (mask_dc, mask_orig_obj);
          DeleteDC (mask_dc);
        }
@@ -1900,9 +1955,22 @@ x_draw_image_foreground (struct glyph_string *s)
        {
          SetTextColor (s->hdc, s->gc->foreground);
          SetBkColor (s->hdc, s->gc->background);
-
-          BitBlt (s->hdc, x, y, s->slice.width, s->slice.height,
-                  compat_hdc, s->slice.x, s->slice.y, SRCCOPY);
+         if (!scaled)
+           BitBlt (s->hdc, x, y, s->slice.width, s->slice.height,
+                   compat_hdc, s->slice.x, s->slice.y, SRCCOPY);
+         else
+           {
+             int pmode = 0;
+             /* Windows 9X doesn't support HALFTONE.  */
+             if (os_subtype == OS_NT
+                 && (pmode = SetStretchBltMode (s->hdc, HALFTONE)) != 0)
+               SetBrushOrgEx (s->hdc, 0, 0, NULL);
+             StretchBlt (s->hdc, x, y, s->slice.width, s->slice.height,
+                         compat_hdc, orig_slice_x, orig_slice_y,
+                         orig_slice_width, orig_slice_height, SRCCOPY);
+             if (pmode)
+               SetStretchBltMode (s->hdc, pmode);
+           }
 
          /* When the image has a mask, we can expect that at
             least part of a mouse highlight or a block cursor will
@@ -1937,7 +2005,7 @@ x_draw_image_foreground (struct glyph_string *s)
 /* Draw a relief around the image glyph string S.  */
 
 static void
-x_draw_image_relief (struct glyph_string *s)
+w32_draw_image_relief (struct glyph_string *s)
 {
   int x1, y1, thick, raised_p, top_p, bot_p, left_p, right_p;
   int extra_x, extra_y;
@@ -2000,7 +2068,7 @@ x_draw_image_relief (struct glyph_string *s)
   if (s->slice.y + s->slice.height == s->img->height)
     y1 += thick + extra_y, bot_p = 1;
 
-  x_setup_relief_colors (s);
+  w32_setup_relief_colors (s);
   get_glyph_string_clip_rect (s, &r);
   w32_draw_relief_rect (s->f, x, y, x1, y1, thick, raised_p,
                        top_p, bot_p, left_p, right_p, &r);
@@ -2031,6 +2099,10 @@ w32_draw_image_foreground_1 (struct glyph_string *s, 
HBITMAP pixmap)
   if (s->slice.y == 0)
     y += s->img->vmargin;
 
+  /* FIXME (maybe): The below doesn't support image scaling.  But it
+     seems to never be called, because the conditions for its call in
+     w32_draw_image_glyph_string are never fulfilled (they will be if
+     the #ifdef'ed away part of that function is ever activated).  */
   if (s->img->pixmap)
     {
       HDC compat_hdc = CreateCompatibleDC (hdc);
@@ -2097,7 +2169,7 @@ w32_draw_image_foreground_1 (struct glyph_string *s, 
HBITMAP pixmap)
    give the rectangle to draw.  */
 
 static void
-x_draw_glyph_string_bg_rect (struct glyph_string *s, int x, int y, int w, int 
h)
+w32_draw_glyph_string_bg_rect (struct glyph_string *s, int x, int y, int w, 
int h)
 {
 #if 0 /* TODO: stipple */
   if (s->stippled_p)
@@ -2109,7 +2181,7 @@ x_draw_glyph_string_bg_rect (struct glyph_string *s, int 
x, int y, int w, int h)
     }
   else
 #endif
-    x_clear_glyph_string_rect (s, x, y, w, h);
+    w32_clear_glyph_string_rect (s, x, y, w, h);
 }
 
 
@@ -2128,7 +2200,7 @@ x_draw_glyph_string_bg_rect (struct glyph_string *s, int 
x, int y, int w, int h)
  */
 
 static void
-x_draw_image_glyph_string (struct glyph_string *s)
+w32_draw_image_glyph_string (struct glyph_string *s)
 {
   int x, y;
   int box_line_hwidth = eabs (s->face->box_line_width);
@@ -2206,7 +2278,7 @@ x_draw_image_glyph_string (struct glyph_string *s)
        }
       else
 #endif
-       x_draw_glyph_string_bg_rect (s, x, y, width, height);
+       w32_draw_glyph_string_bg_rect (s, x, y, width, height);
 
       s->background_filled_p = true;
     }
@@ -2215,7 +2287,7 @@ x_draw_image_glyph_string (struct glyph_string *s)
   if (pixmap != 0)
     {
       w32_draw_image_foreground_1 (s, pixmap);
-      x_set_glyph_string_clipping (s);
+      w32_set_glyph_string_clipping (s);
       {
         HDC compat_hdc = CreateCompatibleDC (s->hdc);
         HBRUSH fg_brush = CreateSolidBrush (s->gc->foreground);
@@ -2236,20 +2308,20 @@ x_draw_image_glyph_string (struct glyph_string *s)
       pixmap = 0;
     }
   else
-    x_draw_image_foreground (s);
+    w32_draw_image_foreground (s);
 
   /* If we must draw a relief around the image, do it.  */
   if (s->img->relief
       || s->hl == DRAW_IMAGE_RAISED
       || s->hl == DRAW_IMAGE_SUNKEN)
-    x_draw_image_relief (s);
+    w32_draw_image_relief (s);
 }
 
 
 /* Draw stretch glyph string S.  */
 
 static void
-x_draw_stretch_glyph_string (struct glyph_string *s)
+w32_draw_stretch_glyph_string (struct glyph_string *s)
 {
   eassert (s->first_glyph->type == STRETCH_GLYPH);
 
@@ -2286,7 +2358,7 @@ x_draw_stretch_glyph_string (struct glyph_string *s)
        x -= width;
 
       /* Draw cursor.  */
-      x_draw_glyph_string_bg_rect (s, x, s->y, width, s->height);
+      w32_draw_glyph_string_bg_rect (s, x, s->y, width, s->height);
 
       /* Clear rest using the GC of the original non-cursor face.  */
       if (width < background_width)
@@ -2304,7 +2376,7 @@ x_draw_stretch_glyph_string (struct glyph_string *s)
          if (s->row->mouse_face_p
              && cursor_in_mouse_face_p (s->w))
            {
-             x_set_mouse_face_gc (s);
+             w32_set_mouse_face_gc (s);
              gc = s->gc;
            }
          else
@@ -2341,7 +2413,7 @@ x_draw_stretch_glyph_string (struct glyph_string *s)
          x = left_x;
        }
       if (background_width > 0)
-       x_draw_glyph_string_bg_rect (s, x, s->y, background_width, s->height);
+       w32_draw_glyph_string_bg_rect (s, x, s->y, background_width, s->height);
     }
 
   s->background_filled_p = true;
@@ -2351,7 +2423,7 @@ x_draw_stretch_glyph_string (struct glyph_string *s)
 /* Draw glyph string S.  */
 
 static void
-x_draw_glyph_string (struct glyph_string *s)
+w32_draw_glyph_string (struct glyph_string *s)
 {
   bool relief_drawn_p = 0;
 
@@ -2367,18 +2439,18 @@ x_draw_glyph_string (struct glyph_string *s)
            width += next->width, next = next->next)
         if (next->first_glyph->type != IMAGE_GLYPH)
           {
-            x_set_glyph_string_gc (next);
-            x_set_glyph_string_clipping (next);
+            w32_set_glyph_string_gc (next);
+            w32_set_glyph_string_clipping (next);
            if (next->first_glyph->type == STRETCH_GLYPH)
-             x_draw_stretch_glyph_string (next);
+             w32_draw_stretch_glyph_string (next);
            else
-             x_draw_glyph_string_background (next, true);
+             w32_draw_glyph_string_background (next, true);
             next->num_clips = 0;
           }
     }
 
   /* Set up S->gc, set clipping and draw S.  */
-  x_set_glyph_string_gc (s);
+  w32_set_glyph_string_gc (s);
 
   /* Draw relief (if any) in advance for char/composition so that the
      glyph string can be drawn over it.  */
@@ -2388,10 +2460,10 @@ x_draw_glyph_string (struct glyph_string *s)
          || s->first_glyph->type == COMPOSITE_GLYPH))
 
     {
-      x_set_glyph_string_clipping (s);
-      x_draw_glyph_string_background (s, true);
-      x_draw_glyph_string_box (s);
-      x_set_glyph_string_clipping (s);
+      w32_set_glyph_string_clipping (s);
+      w32_draw_glyph_string_background (s, true);
+      w32_draw_glyph_string_box (s);
+      w32_set_glyph_string_clipping (s);
       relief_drawn_p = 1;
     }
   else if (!s->clip_head /* draw_glyphs didn't specify a clip mask.  */
@@ -2401,26 +2473,26 @@ x_draw_glyph_string (struct glyph_string *s)
     /* We must clip just this glyph.  left_overhang part has already
        drawn when s->prev was drawn, and right_overhang part will be
        drawn later when s->next is drawn. */
-    x_set_glyph_string_clipping_exactly (s, s);
+    w32_set_glyph_string_clipping_exactly (s, s);
   else
-    x_set_glyph_string_clipping (s);
+    w32_set_glyph_string_clipping (s);
 
   switch (s->first_glyph->type)
     {
     case IMAGE_GLYPH:
-      x_draw_image_glyph_string (s);
+      w32_draw_image_glyph_string (s);
       break;
 
     case STRETCH_GLYPH:
-      x_draw_stretch_glyph_string (s);
+      w32_draw_stretch_glyph_string (s);
       break;
 
     case CHAR_GLYPH:
       if (s->for_overlaps)
        s->background_filled_p = true;
       else
-        x_draw_glyph_string_background (s, false);
-      x_draw_glyph_string_foreground (s);
+        w32_draw_glyph_string_background (s, false);
+      w32_draw_glyph_string_foreground (s);
       break;
 
     case COMPOSITE_GLYPH:
@@ -2428,16 +2500,16 @@ x_draw_glyph_string (struct glyph_string *s)
                              && ! s->first_glyph->u.cmp.automatic))
        s->background_filled_p = true;
       else
-       x_draw_glyph_string_background (s, true);
-      x_draw_composite_glyph_string_foreground (s);
+       w32_draw_glyph_string_background (s, true);
+      w32_draw_composite_glyph_string_foreground (s);
       break;
 
     case GLYPHLESS_GLYPH:
       if (s->for_overlaps)
        s->background_filled_p = true;
       else
-       x_draw_glyph_string_background (s, false);
-      x_draw_glyphless_glyph_string_foreground (s);
+       w32_draw_glyph_string_background (s, false);
+      w32_draw_glyphless_glyph_string_foreground (s);
       break;
 
     default:
@@ -2590,7 +2662,7 @@ x_draw_glyph_string (struct glyph_string *s)
 
       /* Draw relief if not yet drawn.  */
       if (!relief_drawn_p && s->face->box != FACE_NO_BOX)
-        x_draw_glyph_string_box (s);
+        w32_draw_glyph_string_box (s);
 
       if (s->prev)
         {
@@ -2605,12 +2677,12 @@ x_draw_glyph_string (struct glyph_string *s)
                enum draw_glyphs_face save = prev->hl;
 
                prev->hl = s->hl;
-               x_set_glyph_string_gc (prev);
-               x_set_glyph_string_clipping_exactly (s, prev);
+               w32_set_glyph_string_gc (prev);
+               w32_set_glyph_string_clipping_exactly (s, prev);
                if (prev->first_glyph->type == CHAR_GLYPH)
-                 x_draw_glyph_string_foreground (prev);
+                 w32_draw_glyph_string_foreground (prev);
                else
-                 x_draw_composite_glyph_string_foreground (prev);
+                 w32_draw_composite_glyph_string_foreground (prev);
                 w32_set_clip_rectangle (prev->hdc, NULL);
                prev->hl = save;
                prev->num_clips = 0;
@@ -2630,12 +2702,12 @@ x_draw_glyph_string (struct glyph_string *s)
                enum draw_glyphs_face save = next->hl;
 
                next->hl = s->hl;
-               x_set_glyph_string_gc (next);
-               x_set_glyph_string_clipping_exactly (s, next);
+               w32_set_glyph_string_gc (next);
+               w32_set_glyph_string_clipping_exactly (s, next);
                if (next->first_glyph->type == CHAR_GLYPH)
-                 x_draw_glyph_string_foreground (next);
+                 w32_draw_glyph_string_foreground (next);
                else
-                 x_draw_composite_glyph_string_foreground (next);
+                 w32_draw_composite_glyph_string_foreground (next);
                 w32_set_clip_rectangle (next->hdc, NULL);
                next->hl = save;
                next->num_clips = 0;
@@ -2670,7 +2742,7 @@ w32_shift_glyphs_for_insert (struct frame *f, int x, int 
y,
    for X frames.  */
 
 static void
-x_delete_glyphs (struct frame *f, register int n)
+w32_delete_glyphs (struct frame *f, register int n)
 {
   if (! FRAME_W32_P (f))
     return;
@@ -2682,7 +2754,7 @@ x_delete_glyphs (struct frame *f, register int n)
 /* Clear entire frame.  */
 
 static void
-x_clear_frame (struct frame *f)
+w32_clear_frame (struct frame *f)
 {
   if (! FRAME_W32_P (f))
     return;
@@ -2697,7 +2769,7 @@ x_clear_frame (struct frame *f)
 
   /* We have to clear the scroll bars, too.  If we have changed
      colors or something like that, then they should be notified.  */
-  x_scroll_bar_clear (f);
+  w32_scroll_bar_clear (f);
 
   unblock_input ();
 }
@@ -2736,7 +2808,7 @@ w32_ring_bell (struct frame *f)
    lines or deleting -N lines at vertical position VPOS.  */
 
 static void
-x_ins_del_lines (struct frame *f, int vpos, int n)
+w32_ins_del_lines (struct frame *f, int vpos, int n)
 {
   if (! FRAME_W32_P (f))
     return;
@@ -2748,7 +2820,7 @@ x_ins_del_lines (struct frame *f, int vpos, int n)
 /* Scroll part of the display as described by RUN.  */
 
 static void
-x_scroll_run (struct window *w, struct run *run)
+w32_scroll_run (struct window *w, struct run *run)
 {
   struct frame *f = XFRAME (w->frame);
   int x, y, width, height, from_y, to_y, bottom_y;
@@ -2787,8 +2859,8 @@ x_scroll_run (struct window *w, struct run *run)
 
   block_input ();
 
-  /* Cursor off.  Will be switched on again in x_update_window_end.  */
-  x_clear_cursor (w);
+  /* Cursor off.  Will be switched on again in w32_update_window_end.  */
+  gui_clear_cursor (w);
 
   {
     RECT from;
@@ -2829,17 +2901,17 @@ x_scroll_run (struct window *w, struct run *run)
  ***********************************************************************/
 
 static void
-frame_highlight (struct frame *f)
+w32_frame_highlight (struct frame *f)
 {
-  x_update_cursor (f, 1);
-  x_set_frame_alpha (f);
+  gui_update_cursor (f, 1);
+  w32_set_frame_alpha (f);
 }
 
 static void
-frame_unhighlight (struct frame *f)
+w32_frame_unhighlight (struct frame *f)
 {
-  x_update_cursor (f, 1);
-  x_set_frame_alpha (f);
+  gui_update_cursor (f, 1);
+  w32_set_frame_alpha (f);
 }
 
 /* The focus has changed.  Update the frames as necessary to reflect
@@ -2849,7 +2921,7 @@ frame_unhighlight (struct frame *f)
    Lisp code can tell when the switch took place by examining the events.  */
 
 static void
-x_new_focus_frame (struct w32_display_info *dpyinfo, struct frame *frame)
+w32_new_focus_frame (struct w32_display_info *dpyinfo, struct frame *frame)
 {
   struct frame *old_focus = dpyinfo->w32_focus_frame;
 
@@ -2860,7 +2932,7 @@ x_new_focus_frame (struct w32_display_info *dpyinfo, 
struct frame *frame)
       dpyinfo->w32_focus_frame = frame;
 
       if (old_focus && old_focus->auto_lower)
-       x_lower_frame (old_focus);
+       w32_lower_frame (old_focus);
 
       if (dpyinfo->w32_focus_frame && dpyinfo->w32_focus_frame->auto_raise)
        dpyinfo->w32_pending_autoraise_frame = dpyinfo->w32_focus_frame;
@@ -2868,7 +2940,7 @@ x_new_focus_frame (struct w32_display_info *dpyinfo, 
struct frame *frame)
        dpyinfo->w32_pending_autoraise_frame = NULL;
     }
 
-  x_frame_rehighlight (dpyinfo);
+  w32_frame_rehighlight_1 (dpyinfo);
 }
 
 
@@ -2877,14 +2949,14 @@ x_new_focus_frame (struct w32_display_info *dpyinfo, 
struct frame *frame)
    a FOCUS_IN_EVENT into *BUFP.  */
 
 static void
-x_focus_changed (int type, int state, struct w32_display_info *dpyinfo,
+w32_focus_changed (int type, int state, struct w32_display_info *dpyinfo,
                 struct frame *frame, struct input_event *bufp)
 {
   if (type == WM_SETFOCUS)
     {
       if (dpyinfo->w32_focus_event_frame != frame)
         {
-          x_new_focus_frame (dpyinfo, frame);
+          w32_new_focus_frame (dpyinfo, frame);
           dpyinfo->w32_focus_event_frame = frame;
           bufp->kind = FOCUS_IN_EVENT;
           XSETFRAME (bufp->frame_or_window, frame);
@@ -2901,7 +2973,7 @@ x_focus_changed (int type, int state, struct 
w32_display_info *dpyinfo,
       if (dpyinfo->w32_focus_event_frame == frame)
         {
           dpyinfo->w32_focus_event_frame = 0;
-          x_new_focus_frame (dpyinfo, 0);
+          w32_new_focus_frame (dpyinfo, 0);
 
           bufp->kind = FOCUS_OUT_EVENT;
           XSETFRAME (bufp->frame_or_window, frame);
@@ -2923,15 +2995,15 @@ w32_detect_focus_change (struct w32_display_info 
*dpyinfo, W32Msg *event,
 {
   struct frame *frame;
 
-  frame = x_any_window_to_frame (dpyinfo, event->msg.hwnd);
+  frame = w32_window_to_frame (dpyinfo, event->msg.hwnd);
   if (! frame)
     return;
 
   /* On w32, this is only called from focus events, so no switch needed.  */
-  x_focus_changed (event->msg.message,
-                  (event->msg.message == WM_KILLFOCUS ?
-                   FOCUS_IMPLICIT : FOCUS_EXPLICIT),
-                  dpyinfo, frame, bufp);
+  w32_focus_changed (event->msg.message,
+                     (event->msg.message == WM_KILLFOCUS ?
+                      FOCUS_IMPLICIT : FOCUS_EXPLICIT),
+                     dpyinfo, frame, bufp);
 }
 
 
@@ -2939,9 +3011,9 @@ w32_detect_focus_change (struct w32_display_info 
*dpyinfo, W32Msg *event,
 /* Handle an event saying the mouse has moved out of an Emacs frame.  */
 
 static void
-x_mouse_leave (struct w32_display_info *dpyinfo)
+w32_mouse_leave (struct w32_display_info *dpyinfo)
 {
-  x_new_focus_frame (dpyinfo, dpyinfo->w32_focus_event_frame);
+  w32_new_focus_frame (dpyinfo, dpyinfo->w32_focus_event_frame);
 }
 #endif
 
@@ -2958,35 +3030,35 @@ w32_frame_rehighlight (struct frame *frame)
 {
   if (! FRAME_W32_P (frame))
     return;
-  x_frame_rehighlight (FRAME_DISPLAY_INFO (frame));
+  w32_frame_rehighlight_1 (FRAME_DISPLAY_INFO (frame));
 }
 
 static void
-x_frame_rehighlight (struct w32_display_info *dpyinfo)
+w32_frame_rehighlight_1 (struct w32_display_info *dpyinfo)
 {
-  struct frame *old_highlight = dpyinfo->x_highlight_frame;
+  struct frame *old_highlight = dpyinfo->highlight_frame;
 
   if (dpyinfo->w32_focus_frame)
     {
-      dpyinfo->x_highlight_frame
+      dpyinfo->highlight_frame
        = ((FRAMEP (FRAME_FOCUS_FRAME (dpyinfo->w32_focus_frame)))
           ? XFRAME (FRAME_FOCUS_FRAME (dpyinfo->w32_focus_frame))
           : dpyinfo->w32_focus_frame);
-      if (! FRAME_LIVE_P (dpyinfo->x_highlight_frame))
+      if (! FRAME_LIVE_P (dpyinfo->highlight_frame))
        {
          fset_focus_frame (dpyinfo->w32_focus_frame, Qnil);
-         dpyinfo->x_highlight_frame = dpyinfo->w32_focus_frame;
+         dpyinfo->highlight_frame = dpyinfo->w32_focus_frame;
        }
     }
   else
-    dpyinfo->x_highlight_frame = 0;
+    dpyinfo->highlight_frame = 0;
 
-  if (dpyinfo->x_highlight_frame != old_highlight)
+  if (dpyinfo->highlight_frame != old_highlight)
     {
       if (old_highlight)
-       frame_unhighlight (old_highlight);
-      if (dpyinfo->x_highlight_frame)
-       frame_highlight (dpyinfo->x_highlight_frame);
+       w32_frame_unhighlight (old_highlight);
+      if (dpyinfo->highlight_frame)
+       w32_frame_highlight (dpyinfo->highlight_frame);
     }
 }
 
@@ -2995,7 +3067,7 @@ x_frame_rehighlight (struct w32_display_info *dpyinfo)
 /* Convert a keysym to its name.  */
 
 char *
-x_get_keysym_name (int keysym)
+get_keysym_name (int keysym)
 {
   /* Make static so we can always return it */
   static char value[100];
@@ -3093,7 +3165,8 @@ parse_button (int message, int xbutton, int * pbutton, 
int * pup)
    the mouse.  */
 
 static Lisp_Object
-construct_mouse_click (struct input_event *result, W32Msg *msg, struct frame 
*f)
+w32_construct_mouse_click (struct input_event *result, W32Msg *msg,
+                           struct frame *f)
 {
   int button = 0;
   int up = 0;
@@ -3119,7 +3192,8 @@ construct_mouse_click (struct input_event *result, W32Msg 
*msg, struct frame *f)
 }
 
 static Lisp_Object
-construct_mouse_wheel (struct input_event *result, W32Msg *msg, struct frame 
*f)
+w32_construct_mouse_wheel (struct input_event *result, W32Msg *msg,
+                           struct frame *f)
 {
   POINT p;
   int delta;
@@ -3153,7 +3227,8 @@ construct_mouse_wheel (struct input_event *result, W32Msg 
*msg, struct frame *f)
 }
 
 static Lisp_Object
-construct_drag_n_drop (struct input_event *result, W32Msg *msg, struct frame 
*f)
+w32_construct_drag_n_drop (struct input_event *result, W32Msg *msg,
+                           struct frame *f)
 {
   Lisp_Object files;
   Lisp_Object frame;
@@ -3232,7 +3307,7 @@ construct_drag_n_drop (struct input_event *result, W32Msg 
*msg, struct frame *f)
 /* File event notifications (see w32notify.c).  */
 
 Lisp_Object
-lispy_file_action (DWORD action)
+w32_lispy_file_action (DWORD action)
 {
   static char unknown_fmt[] = "unknown-action(%d)";
   Lisp_Object retval;
@@ -3272,8 +3347,8 @@ lispy_file_action (DWORD action)
    function runs when the WM_EMACS_FILENOTIFY message arrives from a
    watcher thread.  */
 static void
-queue_notifications (struct input_event *event, W32Msg *msg, struct frame *f,
-                    int *evcount)
+w32_queue_notifications (struct input_event *event, W32Msg *msg,
+                         struct frame *f, int *evcount)
 {
   struct notifications_set *ns = NULL;
   Lisp_Object frame;
@@ -3332,7 +3407,7 @@ queue_notifications (struct input_event *event, W32Msg 
*msg, struct frame *f,
                     already be defined at this point.  */
                  Lisp_Object fname
                    = code_convert_string_norecord (utf_16_fn, cs, 0);
-                 Lisp_Object action = lispy_file_action (fni->Action);
+                 Lisp_Object action = w32_lispy_file_action (fni->Action);
 
                  event->kind = FILE_NOTIFY_EVENT;
                  event->timestamp = msg->msg.time;
@@ -3370,14 +3445,14 @@ queue_notifications (struct input_event *event, W32Msg 
*msg, struct frame *f,
    another motion event, so we can check again the next time it moves.  */
 
 static int
-note_mouse_movement (struct frame *frame, MSG *msg)
+w32_note_mouse_movement (struct frame *frame, MSG *msg)
 {
   struct w32_display_info *dpyinfo;
   int mouse_x = LOWORD (msg->lParam);
   int mouse_y = HIWORD (msg->lParam);
   RECT *r;
 
-  if (!FRAME_X_OUTPUT (frame))
+  if (!FRAME_OUTPUT_DATA (frame))
     return 0;
 
   dpyinfo = FRAME_DISPLAY_INFO (frame);
@@ -3421,15 +3496,15 @@ note_mouse_movement (struct frame *frame, MSG *msg)
                              Mouse Face
  ************************************************************************/
 
-static struct scroll_bar *x_window_to_scroll_bar (Window, int);
-static void x_scroll_bar_report_motion (struct frame **, Lisp_Object *,
-                                       enum scroll_bar_part *,
-                                       Lisp_Object *, Lisp_Object *,
-                                       Time *);
-static void x_horizontal_scroll_bar_report_motion (struct frame **, 
Lisp_Object *,
-                                                  enum scroll_bar_part *,
-                                                  Lisp_Object *, Lisp_Object *,
-                                                  Time *);
+static struct scroll_bar *w32_window_to_scroll_bar (Window, int);
+static void w32_scroll_bar_report_motion (struct frame **, Lisp_Object *,
+                                          enum scroll_bar_part *,
+                                          Lisp_Object *, Lisp_Object *,
+                                          Time *);
+static void w32_horizontal_scroll_bar_report_motion (struct frame **, 
Lisp_Object *,
+                                                     enum scroll_bar_part *,
+                                                     Lisp_Object *, 
Lisp_Object *,
+                                                     Time *);
 static void
 w32_define_cursor (Window window, Cursor cursor)
 {
@@ -3470,9 +3545,9 @@ w32_mouse_position (struct frame **fp, int insist, 
Lisp_Object *bar_window,
       struct scroll_bar *bar = dpyinfo->last_mouse_scroll_bar;
 
       if (bar->horizontal)
-       x_horizontal_scroll_bar_report_motion (fp, bar_window, part, x, y, 
time);
+       w32_horizontal_scroll_bar_report_motion (fp, bar_window, part, x, y, 
time);
       else
-       x_scroll_bar_report_motion (fp, bar_window, part, x, y, time);
+       w32_scroll_bar_report_motion (fp, bar_window, part, x, y, time);
     }
   else
     {
@@ -3494,7 +3569,7 @@ w32_mouse_position (struct frame **fp, int insist, 
Lisp_Object *bar_window,
        /* If mouse was grabbed on a frame, give coords for that
           frame even if the mouse is now outside it.  Otherwise
           check for window under mouse on one of our frames.  */
-       if (x_mouse_grabbed (dpyinfo))
+       if (gui_mouse_grabbed (dpyinfo))
          f1 = dpyinfo->last_mouse_frame;
        else
          {
@@ -3502,14 +3577,14 @@ w32_mouse_position (struct frame **fp, int insist, 
Lisp_Object *bar_window,
 
            if (wfp)
              {
-               f1 = x_any_window_to_frame (dpyinfo, wfp);
+               f1 = w32_window_to_frame (dpyinfo, wfp);
                if (f1)
                  {
                    HWND cwfp = ChildWindowFromPoint (wfp, pt);
 
                    if (cwfp)
                      {
-                       struct frame *f2 = x_any_window_to_frame (dpyinfo, 
cwfp);
+                       struct frame *f2 = w32_window_to_frame (dpyinfo, cwfp);
 
                        /* If a child window was found, make sure that its
                           frame is a child frame (Bug#26615, maybe).  */
@@ -3524,7 +3599,7 @@ w32_mouse_position (struct frame **fp, int insist, 
Lisp_Object *bar_window,
        if (! f1)
          {
            struct scroll_bar *bar
-              = x_window_to_scroll_bar (WindowFromPoint (pt), 2);
+              = w32_window_to_scroll_bar (WindowFromPoint (pt), 2);
 
            if (bar)
              f1 = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
@@ -3596,7 +3671,7 @@ w32_handle_tool_bar_click (struct frame *f, struct 
input_event *button_event)
    strip off mark bits.  */
 
 static struct scroll_bar *
-x_window_to_scroll_bar (Window window_id, int type)
+w32_window_to_scroll_bar (Window window_id, int type)
 {
   Lisp_Object tail, frame;
 
@@ -3615,7 +3690,7 @@ x_window_to_scroll_bar (Window window_id, int type)
                               ! NILP (bar));
           bar = XSCROLL_BAR (bar)->next)
        if (SCROLL_BAR_W32_WINDOW (XSCROLL_BAR (bar)) == window_id
-           && (type = 2
+           && (type == 2
                || (type == 1 && XSCROLL_BAR (bar)->horizontal)
                || (type == 0 && !XSCROLL_BAR (bar)->horizontal)))
          return XSCROLL_BAR (bar);
@@ -3815,13 +3890,14 @@ my_bring_window_to_top (HWND hwnd)
    scroll bar. */
 
 static struct scroll_bar *
-x_scroll_bar_create (struct window *w, int left, int top, int width, int 
height, bool horizontal)
+w32_scroll_bar_create (struct window *w, int left, int top,
+                       int width, int height, bool horizontal)
 {
   struct frame *f = XFRAME (WINDOW_FRAME (w));
   HWND hwnd;
   SCROLLINFO si;
   struct scroll_bar *bar
-    = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, top, PVEC_OTHER);
+    = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, w32_widget_high, PVEC_OTHER);
   Lisp_Object barobj;
 
   block_input ();
@@ -3877,7 +3953,7 @@ x_scroll_bar_create (struct window *w, int left, int top, 
int width, int height,
    nil. */
 
 static void
-x_scroll_bar_remove (struct scroll_bar *bar)
+w32_scroll_bar_remove (struct scroll_bar *bar)
 {
   struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
 
@@ -3931,7 +4007,7 @@ w32_set_vertical_scroll_bar (struct window *w,
        }
       unblock_input ();
 
-      bar = x_scroll_bar_create (w, left, top, width, height, false);
+      bar = w32_scroll_bar_create (w, left, top, width, height, false);
     }
   else
     {
@@ -3964,7 +4040,7 @@ w32_set_vertical_scroll_bar (struct window *w,
                 for them on the frame, we have to clear "under" them.  */
              w32_clear_area (f, hdc, left, top, width, height);
              release_frame_dc (f, hdc);
-             x_clear_under_internal_border (f);
+             w32_clear_under_internal_border (f);
            }
           /* Make sure scroll bar is "visible" before moving, to ensure the
              area of the parent window now exposed will be refreshed.  */
@@ -4035,7 +4111,7 @@ w32_set_horizontal_scroll_bar (struct window *w,
        }
       unblock_input ();
 
-      bar = x_scroll_bar_create (w, left, top, width, height, true);
+      bar = w32_scroll_bar_create (w, left, top, width, height, true);
     }
   else
     {
@@ -4066,7 +4142,7 @@ w32_set_horizontal_scroll_bar (struct window *w,
                 for them on the frame, we have to clear "under" them.  */
              w32_clear_area (f, hdc, clear_left, top, clear_width, height);
              release_frame_dc (f, hdc);
-             x_clear_under_internal_border (f);
+             w32_clear_under_internal_border (f);
            }
           /* Make sure scroll bar is "visible" before moving, to ensure the
              area of the parent window now exposed will be refreshed.  */
@@ -4241,7 +4317,7 @@ w32_judge_scroll_bars (struct frame *f)
     {
       struct scroll_bar *b = XSCROLL_BAR (bar);
 
-      x_scroll_bar_remove (b);
+      w32_scroll_bar_remove (b);
 
       next = b->next;
       b->next = b->prev = Qnil;
@@ -4485,7 +4561,7 @@ w32_horizontal_scroll_bar_handle_click (struct scroll_bar 
*bar, W32Msg *msg,
 /* Return information to the user about the current position of the mouse
    on the vertical scroll bar.  */
 static void
-x_scroll_bar_report_motion (struct frame **fp, Lisp_Object *bar_window,
+w32_scroll_bar_report_motion (struct frame **fp, Lisp_Object *bar_window,
                            enum scroll_bar_part *part,
                            Lisp_Object *x, Lisp_Object *y,
                            Time *time)
@@ -4535,10 +4611,10 @@ x_scroll_bar_report_motion (struct frame **fp, 
Lisp_Object *bar_window,
 /* Return information to the user about the current position of the mouse
    on the horizontal scroll bar.  */
 static void
-x_horizontal_scroll_bar_report_motion (struct frame **fp, Lisp_Object 
*bar_window,
-                                      enum scroll_bar_part *part,
-                                      Lisp_Object *x, Lisp_Object *y,
-                                      Time *time)
+w32_horizontal_scroll_bar_report_motion (struct frame **fp, Lisp_Object 
*bar_window,
+                                         enum scroll_bar_part *part,
+                                         Lisp_Object *x, Lisp_Object *y,
+                                         Time *time)
 {
   struct w32_display_info *dpyinfo = FRAME_DISPLAY_INFO (*fp);
   struct scroll_bar *bar = dpyinfo->last_mouse_scroll_bar;
@@ -4589,8 +4665,8 @@ x_horizontal_scroll_bar_report_motion (struct frame **fp, 
Lisp_Object *bar_windo
    Clear out the scroll bars, and ask for expose events, so we can
    redraw them.  */
 
-void
-x_scroll_bar_clear (struct frame *f)
+static void
+w32_scroll_bar_clear (struct frame *f)
 {
   Lisp_Object bar;
 
@@ -4613,7 +4689,7 @@ x_scroll_bar_clear (struct frame *f)
         GetClientRect (window, &rect);
         select_palette (f, hdc);
         w32_clear_rect (f, hdc, &rect);
-       x_clear_under_internal_border (f);
+       w32_clear_under_internal_border (f);
         deselect_palette (f, hdc);
 
         ReleaseDC (window, hdc);
@@ -4685,7 +4761,7 @@ w32_read_socket (struct terminal *terminal,
       switch (msg.msg.message)
        {
        case WM_EMACS_PAINT:
-         f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+         f = w32_window_to_frame (dpyinfo, msg.msg.hwnd);
 
          if (f)
            {
@@ -4740,14 +4816,14 @@ w32_read_socket (struct terminal *terminal,
                                msg.rect.top,
                                msg.rect.right - msg.rect.left,
                                msg.rect.bottom - msg.rect.top);
-                 x_clear_under_internal_border (f);
+                 w32_clear_under_internal_border (f);
                }
            }
          break;
 
        case WM_INPUTLANGCHANGE:
          /* Generate a language change event.  */
-         f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+         f = w32_window_to_frame (dpyinfo, msg.msg.hwnd);
 
          /* lParam contains the input language ID in its low 16 bits.
             Use it to update our record of the keyboard codepage.  */
@@ -4765,7 +4841,7 @@ w32_read_socket (struct terminal *terminal,
 
        case WM_KEYDOWN:
        case WM_SYSKEYDOWN:
-         f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+         f = w32_window_to_frame (dpyinfo, msg.msg.hwnd);
 
          if (f && !FRAME_ICONIFIED_P (f))
            {
@@ -4790,7 +4866,7 @@ w32_read_socket (struct terminal *terminal,
         case WM_UNICHAR:
        case WM_SYSCHAR:
        case WM_CHAR:
-         f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+         f = w32_window_to_frame (dpyinfo, msg.msg.hwnd);
 
          if (f && !FRAME_ICONIFIED_P (f))
            {
@@ -4868,7 +4944,7 @@ w32_read_socket (struct terminal *terminal,
          break;
 
         case WM_APPCOMMAND:
-         f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+         f = w32_window_to_frame (dpyinfo, msg.msg.hwnd);
 
          if (f && !FRAME_ICONIFIED_P (f))
            {
@@ -4904,8 +4980,8 @@ w32_read_socket (struct terminal *terminal,
           previous_help_echo_string = help_echo_string;
          help_echo_string = Qnil;
 
-         f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
-              : x_window_to_frame (dpyinfo, msg.msg.hwnd));
+         f = (gui_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
+              : w32_window_to_frame (dpyinfo, msg.msg.hwnd));
 
          if (hlinfo->mouse_face_hidden)
            {
@@ -4945,7 +5021,7 @@ w32_read_socket (struct terminal *terminal,
                  last_mouse_window = window;
                }
 
-             if (!note_mouse_movement (f, &msg.msg))
+             if (!w32_note_mouse_movement (f, &msg.msg))
                help_echo_string = previous_help_echo_string;
            }
          else
@@ -4984,12 +5060,12 @@ w32_read_socket (struct terminal *terminal,
            int button = 0;
            int up = 0;
 
-           f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
-                : x_window_to_frame (dpyinfo, msg.msg.hwnd));
+           f = (gui_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
+                : w32_window_to_frame (dpyinfo, msg.msg.hwnd));
 
            if (f)
              {
-                construct_mouse_click (&inev, &msg, f);
+                w32_construct_mouse_click (&inev, &msg, f);
 
                 /* Is this in the tool-bar?  */
                 if (WINDOWP (f->tool_bar_window)
@@ -5045,8 +5121,8 @@ w32_read_socket (struct terminal *terminal,
        case WM_MOUSEWHEEL:
         case WM_MOUSEHWHEEL:
          {
-           f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
-                : x_window_to_frame (dpyinfo, msg.msg.hwnd));
+           f = (gui_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
+                : w32_window_to_frame (dpyinfo, msg.msg.hwnd));
 
            if (f)
              {
@@ -5054,7 +5130,7 @@ w32_read_socket (struct terminal *terminal,
                    || f == dpyinfo->w32_focus_frame)
                  /* Emit an Emacs wheel-up/down event.  */
                  {
-                   construct_mouse_wheel (&inev, &msg, f);
+                   w32_construct_mouse_wheel (&inev, &msg, f);
 
                    /* Ignore any mouse motion that happened before this
                       event; any subsequent mouse-movement Emacs events
@@ -5064,14 +5140,14 @@ w32_read_socket (struct terminal *terminal,
                    dpyinfo->last_mouse_frame = f;
                  }
                else if (FRAME_NO_ACCEPT_FOCUS (f)
-                        && !x_mouse_grabbed (dpyinfo))
+                        && !gui_mouse_grabbed (dpyinfo))
                  {
                    Lisp_Object frame1 = get_frame_param (f, 
Qmouse_wheel_frame);
                    struct frame *f1 = FRAMEP (frame1) ? XFRAME (frame1) : NULL;
 
                    if (f1 && FRAME_LIVE_P (f1) && FRAME_W32_P (f1))
                      {
-                       construct_mouse_wheel (&inev, &msg, f1);
+                       w32_construct_mouse_wheel (&inev, &msg, f1);
                        f1->mouse_moved = false;
                        f1->last_tool_bar_item = -1;
                        dpyinfo->last_mouse_frame = f1;
@@ -5088,16 +5164,16 @@ w32_read_socket (struct terminal *terminal,
          break;
 
        case WM_DROPFILES:
-         f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+         f = w32_window_to_frame (dpyinfo, msg.msg.hwnd);
 
          if (f)
-           construct_drag_n_drop (&inev, &msg, f);
+           w32_construct_drag_n_drop (&inev, &msg, f);
          break;
 
        case WM_HSCROLL:
          {
            struct scroll_bar *bar =
-             x_window_to_scroll_bar ((HWND)msg.msg.lParam, 1);
+             w32_window_to_scroll_bar ((HWND)msg.msg.lParam, 1);
 
            if (bar)
              w32_horizontal_scroll_bar_handle_click (bar, &msg, &inev);
@@ -5107,7 +5183,7 @@ w32_read_socket (struct terminal *terminal,
        case WM_VSCROLL:
          {
            struct scroll_bar *bar =
-             x_window_to_scroll_bar ((HWND)msg.msg.lParam, 0);
+             w32_window_to_scroll_bar ((HWND)msg.msg.lParam, 0);
 
            if (bar)
              w32_scroll_bar_handle_click (bar, &msg, &inev);
@@ -5115,7 +5191,7 @@ w32_read_socket (struct terminal *terminal,
          }
 
        case WM_WINDOWPOSCHANGED:
-         f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+         f = w32_window_to_frame (dpyinfo, msg.msg.hwnd);
 
          if (f)
            {
@@ -5162,13 +5238,13 @@ w32_read_socket (struct terminal *terminal,
 
        case WM_ACTIVATE:
        case WM_ACTIVATEAPP:
-         f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+         f = w32_window_to_frame (dpyinfo, msg.msg.hwnd);
          if (f)
            {
              /* Run the full-screen hook function also when we are
                 being activated, to actually install the required
                 size in effect, if the WAIT flag is set.  This is
-                because when the hook is run from x_set_fullscreen,
+                because when the hook is run from gui_set_fullscreen,
                 the frame might not yet be visible, if that call is a
                 result of make-frame, and in that case the hook just
                 sets the WAIT flag.  */
@@ -5186,11 +5262,11 @@ w32_read_socket (struct terminal *terminal,
          break;
 
        case WM_MOVE:
-         f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+         f = w32_window_to_frame (dpyinfo, msg.msg.hwnd);
 
          if (f && FRAME_VISIBLE_P (f) && !FRAME_ICONIFIED_P(f))
            {
-             x_real_positions (f, &f->left_pos, &f->top_pos);
+             w32_real_positions (f, &f->left_pos, &f->top_pos);
              inev.kind = MOVE_FRAME_EVENT;
              XSETFRAME (inev.frame_or_window, f);
            }
@@ -5205,7 +5281,7 @@ w32_read_socket (struct terminal *terminal,
          if (!msg.msg.wParam && msg.msg.hwnd == tip_window)
            {
              tip_window = NULL;
-             x_redo_mouse_highlight (dpyinfo);
+             gui_redo_mouse_highlight (dpyinfo);
            }
 
          /* If window has been obscured or exposed by another window
@@ -5217,20 +5293,20 @@ w32_read_socket (struct terminal *terminal,
            check_visibility = 1;
          else
            {
-             f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+             f = w32_window_to_frame (dpyinfo, msg.msg.hwnd);
              f->async_visible = msg.msg.wParam;
            }
 #endif
 
-         f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+         f = w32_window_to_frame (dpyinfo, msg.msg.hwnd);
          if (f)
-           x_clear_under_internal_border (f);
+           w32_clear_under_internal_border (f);
 
          check_visibility = 1;
          break;
 
        case WM_SIZE:
-         f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+         f = w32_window_to_frame (dpyinfo, msg.msg.hwnd);
 
          /* Inform lisp of whether frame has been iconified etc. */
          if (f)
@@ -5266,7 +5342,7 @@ w32_read_socket (struct terminal *terminal,
                           BEFORE telling us the Window is minimized
                           when the Window is iconified, with 3000,3000
                           as the co-ords. */
-                       x_real_positions (f, &x, &y);
+                       w32_real_positions (f, &x, &y);
                        f->left_pos = x;
                        f->top_pos = y;
 
@@ -5290,7 +5366,7 @@ w32_read_socket (struct terminal *terminal,
                      {
                        int x, y;
 
-                       x_real_positions (f, &x, &y);
+                       w32_real_positions (f, &x, &y);
                        if (x < 0 && y < 0)
                          store_frame_param (f, Qfullscreen, Qmaximized);
                      }
@@ -5321,7 +5397,7 @@ w32_read_socket (struct terminal *terminal,
                           BEFORE telling us the Window is minimized
                           when the Window is iconified, with 3000,3000
                           as the co-ords.  */
-                       x_real_positions (f, &f->left_pos, &f->top_pos);
+                       w32_real_positions (f, &f->left_pos, &f->top_pos);
 
                        inev.kind = DEICONIFY_EVENT;
                        XSETFRAME (inev.frame_or_window, f);
@@ -5385,7 +5461,7 @@ w32_read_socket (struct terminal *terminal,
          break;
 
        case WM_MOUSELEAVE:
-         f = x_any_window_to_frame (dpyinfo, msg.msg.hwnd);
+         f = w32_window_to_frame (dpyinfo, msg.msg.hwnd);
          if (f)
            {
              if (f == hlinfo->mouse_face_mouse_frame)
@@ -5414,7 +5490,7 @@ w32_read_socket (struct terminal *terminal,
 
        case WM_KILLFOCUS:
          w32_detect_focus_change (dpyinfo, &msg, &inev);
-         f = x_top_window_to_frame (dpyinfo, msg.msg.hwnd);
+         f = w32_window_to_frame (dpyinfo, msg.msg.hwnd);
 
           if (f)
             {
@@ -5439,7 +5515,7 @@ w32_read_socket (struct terminal *terminal,
          break;
 
        case WM_CLOSE:
-         f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+         f = w32_window_to_frame (dpyinfo, msg.msg.hwnd);
 
          if (f)
            {
@@ -5453,7 +5529,7 @@ w32_read_socket (struct terminal *terminal,
          break;
 
        case WM_INITMENU:
-         f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+         f = w32_window_to_frame (dpyinfo, msg.msg.hwnd);
 
          if (f)
            {
@@ -5463,7 +5539,7 @@ w32_read_socket (struct terminal *terminal,
          break;
 
        case WM_COMMAND:
-         f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+         f = w32_window_to_frame (dpyinfo, msg.msg.hwnd);
 
          if (f)
            {
@@ -5474,7 +5550,7 @@ w32_read_socket (struct terminal *terminal,
          break;
 
        case WM_DISPLAYCHANGE:
-         f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+         f = w32_window_to_frame (dpyinfo, msg.msg.hwnd);
 
          if (f)
            {
@@ -5486,7 +5562,7 @@ w32_read_socket (struct terminal *terminal,
                 The following code is untested yet.  */
              if (!NILP (fullscreen))
                {
-                 x_set_fullscreen (f, fullscreen, fullscreen);
+                 gui_set_fullscreen (f, fullscreen, fullscreen);
                  w32fullscreen_hook (f);
                }
 
@@ -5500,9 +5576,9 @@ w32_read_socket (struct terminal *terminal,
 
 #if HAVE_W32NOTIFY
        case WM_EMACS_FILENOTIFY:
-         f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+         f = w32_window_to_frame (dpyinfo, msg.msg.hwnd);
          if (f)
-           queue_notifications (&inev, &msg, f, &count);
+           w32_queue_notifications (&inev, &msg, f, &count);
          break;
 #endif
 
@@ -5558,7 +5634,7 @@ w32_read_socket (struct terminal *terminal,
      raise it now.  FIXME: handle more than one such frame.  */
   if (dpyinfo->w32_pending_autoraise_frame)
     {
-      x_raise_frame (dpyinfo->w32_pending_autoraise_frame);
+      w32_raise_frame (dpyinfo->w32_pending_autoraise_frame);
       dpyinfo->w32_pending_autoraise_frame = NULL;
     }
 
@@ -5670,7 +5746,7 @@ w32_clip_to_row (struct window *w, struct glyph_row *row,
 /* Draw a hollow box cursor on window W in glyph row ROW.  */
 
 static void
-x_draw_hollow_cursor (struct window *w, struct glyph_row *row)
+w32_draw_hollow_cursor (struct window *w, struct glyph_row *row)
 {
   struct frame *f = XFRAME (WINDOW_FRAME (w));
   HDC hdc;
@@ -5719,7 +5795,7 @@ x_draw_hollow_cursor (struct window *w, struct glyph_row 
*row)
    --gerd.  */
 
 static void
-x_draw_bar_cursor (struct window *w, struct glyph_row *row,
+w32_draw_bar_cursor (struct window *w, struct glyph_row *row,
                   int width, enum text_cursor_kinds kind)
 {
   struct frame *f = XFRAME (w->frame);
@@ -5898,7 +5974,7 @@ w32_draw_window_cursor (struct window *w, struct 
glyph_row *glyph_row,
       switch (cursor_type)
        {
        case HOLLOW_BOX_CURSOR:
-         x_draw_hollow_cursor (w, glyph_row);
+         w32_draw_hollow_cursor (w, glyph_row);
          break;
 
        case FILLED_BOX_CURSOR:
@@ -5906,11 +5982,11 @@ w32_draw_window_cursor (struct window *w, struct 
glyph_row *glyph_row,
          break;
 
        case BAR_CURSOR:
-         x_draw_bar_cursor (w, glyph_row, cursor_width, BAR_CURSOR);
+         w32_draw_bar_cursor (w, glyph_row, cursor_width, BAR_CURSOR);
          break;
 
        case HBAR_CURSOR:
-         x_draw_bar_cursor (w, glyph_row, cursor_width, HBAR_CURSOR);
+         w32_draw_bar_cursor (w, glyph_row, cursor_width, HBAR_CURSOR);
          break;
 
        case NO_CURSOR:
@@ -5927,8 +6003,8 @@ w32_draw_window_cursor (struct window *w, struct 
glyph_row *glyph_row,
 
 /* Icons.  */
 
-bool
-x_bitmap_icon (struct frame *f, Lisp_Object icon)
+static bool
+w32_bitmap_icon (struct frame *f, Lisp_Object icon)
 {
   HANDLE main_icon;
   HANDLE small_icon = NULL;
@@ -6015,8 +6091,8 @@ x_io_error_quitter (display)
 
 /* Changing the font of the frame.  */
 
-Lisp_Object
-x_new_font (struct frame *f, Lisp_Object font_object, int fontset)
+static Lisp_Object
+w32_new_font (struct frame *f, Lisp_Object font_object, int fontset)
 {
   struct font *font = XFONT_OBJECT (font_object);
   int unit, font_ascent, font_descent;
@@ -6048,7 +6124,7 @@ x_new_font (struct frame *f, Lisp_Object font_object, int 
fontset)
     }
 
   /* Now make the frame display the given font.  */
-  if (FRAME_X_WINDOW (f) != 0)
+  if (FRAME_NATIVE_WINDOW (f) != 0)
     {
       /* Don't change the size of a tip frame; there's no point in
         doing it because it's done in Fx_show_tip, and it leads to
@@ -6084,7 +6160,7 @@ xim_close_dpy (dpyinfo)
    from its current recorded position values and gravity.  */
 
 static void
-x_calc_absolute_position (struct frame *f)
+w32_calc_absolute_position (struct frame *f)
 {
   int flags = f->size_hint_flags;
 
@@ -6167,7 +6243,7 @@ x_calc_absolute_position (struct frame *f)
                       + f->left_pos
                       - left_right_borders_width);
       else
-       f->left_pos = (x_display_pixel_width (FRAME_DISPLAY_INFO (f))
+       f->left_pos = (w32_display_pixel_width (FRAME_DISPLAY_INFO (f))
                       + display_left
                       - FRAME_PIXEL_WIDTH (f)
                       + f->left_pos
@@ -6182,7 +6258,7 @@ x_calc_absolute_position (struct frame *f)
                      + f->top_pos
                      - top_bottom_borders_height);
       else
-       f->top_pos = (x_display_pixel_height (FRAME_DISPLAY_INFO (f))
+       f->top_pos = (w32_display_pixel_height (FRAME_DISPLAY_INFO (f))
                      + display_top
                      - FRAME_PIXEL_HEIGHT (f)
                      + f->top_pos
@@ -6196,13 +6272,13 @@ x_calc_absolute_position (struct frame *f)
 
 /* CHANGE_GRAVITY is 1 when calling from Fset_frame_position,
    to really change the position, and 0 when calling from
-   x_make_frame_visible (in that case, XOFF and YOFF are the current
-   position values).  It is -1 when calling from x_set_frame_parameters,
+   w32_make_frame_visible (in that case, XOFF and YOFF are the current
+   position values).  It is -1 when calling from gui_set_frame_parameters,
    which means, do adjust for borders but don't change the gravity.  */
 
-void
-x_set_offset (struct frame *f, register int xoff, register int yoff,
-             int change_gravity)
+static void
+w32_set_offset (struct frame *f, register int xoff, register int yoff,
+                int change_gravity)
 {
   int modified_top, modified_left;
 
@@ -6217,10 +6293,10 @@ x_set_offset (struct frame *f, register int xoff, 
register int yoff,
        f->size_hint_flags |= YNegative;
       f->win_gravity = NorthWestGravity;
     }
-  x_calc_absolute_position (f);
+  w32_calc_absolute_position (f);
 
   block_input ();
-  x_wm_set_size_hint (f, (long) 0, false);
+  w32_wm_set_size_hint (f, (long) 0, false);
 
   modified_left = f->left_pos;
   modified_top = f->top_pos;
@@ -6339,13 +6415,13 @@ w32fullscreen_hook (struct frame *f)
     f->want_fullscreen |= FULLSCREEN_WAIT;
 }
 
-/* Call this to change the size of frame F's x-window.
+/* Call this to change the size of frame F's native window.
    If CHANGE_GRAVITY, change to top-left-corner window gravity
    for this size change and subsequent size changes.
    Otherwise we leave the window gravity unchanged.  */
 
-void
-x_set_window_size (struct frame *f, bool change_gravity,
+static void
+w32_set_window_size (struct frame *f, bool change_gravity,
                   int width, int height, bool pixelwise)
 {
   int pixelwidth, pixelheight;
@@ -6394,7 +6470,7 @@ x_set_window_size (struct frame *f, bool change_gravity,
     }
 
   f->win_gravity = NorthWestGravity;
-  x_wm_set_size_hint (f, (long) 0, false);
+  w32_wm_set_size_hint (f, (long) 0, false);
 
   rect.left = rect.top = 0;
   rect.right = pixelwidth;
@@ -6504,6 +6580,20 @@ frame_set_mouse_pixel_position (struct frame *f, int 
pix_x, int pix_y)
   unblock_input ();
 }
 
+static Lisp_Object
+w32_get_focus_frame (struct frame *f)
+{
+  Lisp_Object lisp_focus;
+
+  struct frame *focus = FRAME_DISPLAY_INFO (f)->w32_focus_frame;
+
+  if (!focus)
+    return Qnil;
+
+  XSETFRAME (lisp_focus, focus);
+  return lisp_focus;
+}
+
 
 /* Focus shifting, raising and lowering.  */
 
@@ -6511,8 +6601,8 @@ frame_set_mouse_pixel_position (struct frame *f, int 
pix_x, int pix_y)
    Windows API: An application cannot activate an inactive window
    without also bringing it to the top of the Z order.  */
 
-void
-x_focus_frame (struct frame *f, bool noactivate)
+static void
+w32_focus_frame (struct frame *f, bool noactivate)
 {
 #if 0
   struct w32_display_info *dpyinfo = &one_w32_display_info;
@@ -6522,7 +6612,7 @@ x_focus_frame (struct frame *f, bool noactivate)
   block_input ();
 #if 0
   /* Try not to change its Z-order if possible.  */
-  if (x_window_to_frame (dpyinfo, GetForegroundWindow ()))
+  if (w32_window_to_frame (dpyinfo, GetForegroundWindow ()))
     my_set_focus (f, FRAME_W32_WINDOW (f));
   else
 #endif
@@ -6531,8 +6621,8 @@ x_focus_frame (struct frame *f, bool noactivate)
 }
 
 /* Raise frame F.  */
-void
-x_raise_frame (struct frame *f)
+static void
+w32_raise_frame (struct frame *f)
 {
   block_input ();
 
@@ -6593,8 +6683,8 @@ x_raise_frame (struct frame *f)
 }
 
 /* Lower frame F.  */
-void
-x_lower_frame (struct frame *f)
+static void
+w32_lower_frame (struct frame *f)
 {
   block_input ();
   my_set_window_pos (FRAME_W32_WINDOW (f),
@@ -6611,9 +6701,9 @@ w32_frame_raise_lower (struct frame *f, bool raise_flag)
     return;
 
   if (raise_flag)
-    x_raise_frame (f);
+    w32_raise_frame (f);
   else
-    x_lower_frame (f);
+    w32_lower_frame (f);
 }
 
 /* Change of visibility.  */
@@ -6627,17 +6717,17 @@ w32_frame_raise_lower (struct frame *f, bool raise_flag)
    finishes with it.  */
 
 void
-x_make_frame_visible (struct frame *f)
+w32_make_frame_visible (struct frame *f)
 {
   block_input ();
 
-  x_set_bitmap_icon (f);
+  gui_set_bitmap_icon (f);
 
   if (! FRAME_VISIBLE_P (f))
     {
       /* We test FRAME_GARBAGED_P here to make sure we don't
-        call x_set_offset a second time
-        if we get to x_make_frame_visible a second time
+        call w32_set_offset a second time
+        if we get to w32_make_frame_visible a second time
         before the window gets really visible.  */
       if (! FRAME_ICONIFIED_P (f)
          && ! f->output_data.w32->asked_for_visible)
@@ -6658,7 +6748,7 @@ x_make_frame_visible (struct frame *f)
                                  workarea_rect.top);
            }
 
-         x_set_offset (f, f->left_pos, f->top_pos, 0);
+         w32_set_offset (f, f->left_pos, f->top_pos, 0);
        }
 
       f->output_data.w32->asked_for_visible = 1;
@@ -6679,7 +6769,10 @@ x_make_frame_visible (struct frame *f)
     }
 
   if (!FLOATP (Vx_wait_for_event_timeout))
+    {
+      unblock_input ();
       return;
+    }
 
   /* Synchronize to ensure Emacs knows the frame is visible
      before we do anything else.  We do this loop with input not blocked
@@ -6726,11 +6819,11 @@ x_make_frame_visible (struct frame *f)
 /* Make the frame visible (mapped and not iconified).  */
 
 void
-x_make_frame_invisible (struct frame *f)
+w32_make_frame_invisible (struct frame *f)
 {
   /* Don't keep the highlight on an invisible frame.  */
-  if (FRAME_DISPLAY_INFO (f)->x_highlight_frame == f)
-    FRAME_DISPLAY_INFO (f)->x_highlight_frame = 0;
+  if (FRAME_DISPLAY_INFO (f)->highlight_frame == f)
+    FRAME_DISPLAY_INFO (f)->highlight_frame = 0;
 
   block_input ();
 
@@ -6747,21 +6840,30 @@ x_make_frame_invisible (struct frame *f)
   unblock_input ();
 }
 
+static void
+w32_make_frame_visible_invisible (struct frame *f, bool visible)
+{
+  if (visible)
+    w32_make_frame_visible (f);
+  else
+    w32_make_frame_invisible (f);
+}
+
 /* Change window state from mapped to iconified. */
 
 void
-x_iconify_frame (struct frame *f)
+w32_iconify_frame (struct frame *f)
 {
   /* Don't keep the highlight on an invisible frame.  */
-  if (FRAME_DISPLAY_INFO (f)->x_highlight_frame == f)
-    FRAME_DISPLAY_INFO (f)->x_highlight_frame = 0;
+  if (FRAME_DISPLAY_INFO (f)->highlight_frame == f)
+    FRAME_DISPLAY_INFO (f)->highlight_frame = 0;
 
   if (FRAME_ICONIFIED_P (f))
     return;
 
   block_input ();
 
-  x_set_bitmap_icon (f);
+  gui_set_bitmap_icon (f);
 
   /* Simulate the user minimizing the frame.  */
   SendMessageTimeout (FRAME_W32_WINDOW (f), WM_SYSCOMMAND, SC_MINIMIZE, 0,
@@ -6774,10 +6876,10 @@ x_iconify_frame (struct frame *f)
 }
 
 
-/* Free X resources of frame F.  */
+/* Free resources of frame F.  */
 
 void
-x_free_frame_resources (struct frame *f)
+w32_free_frame_resources (struct frame *f)
 {
   struct w32_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
   Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
@@ -6801,8 +6903,8 @@ x_free_frame_resources (struct frame *f)
     dpyinfo->w32_focus_frame = 0;
   if (f == dpyinfo->w32_focus_event_frame)
     dpyinfo->w32_focus_event_frame = 0;
-  if (f == dpyinfo->x_highlight_frame)
-    dpyinfo->x_highlight_frame = 0;
+  if (f == dpyinfo->highlight_frame)
+    dpyinfo->highlight_frame = 0;
   if (f == hlinfo->mouse_face_mouse_frame)
     reset_mouse_highlight (hlinfo);
 
@@ -6812,11 +6914,11 @@ x_free_frame_resources (struct frame *f)
 
 /* Destroy the window of frame F.  */
 static void
-x_destroy_window (struct frame *f)
+w32_destroy_window (struct frame *f)
 {
   struct w32_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
 
-  x_free_frame_resources (f);
+  w32_free_frame_resources (f);
   dpyinfo->reference_count--;
 }
 
@@ -6829,7 +6931,7 @@ x_destroy_window (struct frame *f)
    If USER_POSITION, set the USPosition
    flag (this is useful when FLAGS is 0).  */
 void
-x_wm_set_size_hint (struct frame *f, long flags, bool user_position)
+w32_wm_set_size_hint (struct frame *f, long flags, bool user_position)
 {
   Window window = FRAME_W32_WINDOW (f);
 
@@ -6854,7 +6956,7 @@ x_wm_set_size_hint (struct frame *f, long flags, bool 
user_position)
    font table.  */
 
 static void
-x_check_font (struct frame *f, struct font *font)
+w32_check_font (struct frame *f, struct font *font)
 {
   eassert (font != NULL && ! NILP (font->props[FONT_TYPE_INDEX]));
   if (font->driver->check)
@@ -6870,7 +6972,7 @@ w32_show_hourglass (struct frame *f)
 {
   if (!menubar_in_use && !current_popup_menu)
     {
-      struct w32_output *w32 = FRAME_X_OUTPUT (f);
+      struct w32_output *w32 = FRAME_OUTPUT_DATA (f);
 
       w32->hourglass_p = 1;
       SetCursor (w32->hourglass_cursor);
@@ -6882,7 +6984,7 @@ w32_show_hourglass (struct frame *f)
 static void
 w32_hide_hourglass (struct frame *f)
 {
-  struct w32_output *w32 = FRAME_X_OUTPUT (f);
+  struct w32_output *w32 = FRAME_OUTPUT_DATA (f);
 
   w32->hourglass_p = 0;
   if (f->pointer_invisible)
@@ -7014,25 +7116,26 @@ extern frame_parm_handler w32_frame_parm_handlers[];
 static struct redisplay_interface w32_redisplay_interface =
 {
   w32_frame_parm_handlers,
-  x_produce_glyphs,
-  x_write_glyphs,
-  x_insert_glyphs,
-  x_clear_end_of_line,
-  x_scroll_run,
-  x_after_update_window_line,
-  x_update_window_begin,
-  x_update_window_end,
+  gui_produce_glyphs,
+  gui_write_glyphs,
+  gui_insert_glyphs,
+  gui_clear_end_of_line,
+  w32_scroll_run,
+  w32_after_update_window_line,
+  w32_update_window_begin,
+  w32_update_window_end,
   0, /* flush_display */
-  x_clear_window_mouse_face,
-  x_get_glyph_overhangs,
-  x_fix_overlapping_area,
+  gui_clear_window_mouse_face,
+  gui_get_glyph_overhangs,
+  gui_fix_overlapping_area,
   w32_draw_fringe_bitmap,
   w32_define_fringe_bitmap,
   w32_destroy_fringe_bitmap,
   w32_compute_glyph_string_overhangs,
-  x_draw_glyph_string,
+  w32_draw_glyph_string,
   w32_define_frame_cursor,
   w32_clear_frame_area,
+  w32_clear_under_internal_border,
   w32_draw_window_cursor,
   w32_draw_vertical_window_border,
   w32_draw_window_divider,
@@ -7041,7 +7144,7 @@ static struct redisplay_interface w32_redisplay_interface 
=
   w32_hide_hourglass
 };
 
-static void x_delete_terminal (struct terminal *term);
+static void w32_delete_terminal (struct terminal *term);
 
 static struct terminal *
 w32_create_terminal (struct w32_display_info *dpyinfo)
@@ -7055,28 +7158,46 @@ w32_create_terminal (struct w32_display_info *dpyinfo)
 
   /* MSVC does not type K&R functions with no arguments correctly, and
      so we must explicitly cast them.  */
-  terminal->clear_frame_hook = x_clear_frame;
-  terminal->ins_del_lines_hook = x_ins_del_lines;
-  terminal->delete_glyphs_hook = x_delete_glyphs;
+  terminal->clear_frame_hook = w32_clear_frame;
+  terminal->ins_del_lines_hook = w32_ins_del_lines;
+  terminal->delete_glyphs_hook = w32_delete_glyphs;
   terminal->ring_bell_hook = w32_ring_bell;
   terminal->toggle_invisible_pointer_hook = w32_toggle_invisible_pointer;
-  terminal->update_begin_hook = x_update_begin;
-  terminal->update_end_hook = x_update_end;
+  terminal->update_begin_hook = w32_update_begin;
+  terminal->update_end_hook = w32_update_end;
   terminal->read_socket_hook = w32_read_socket;
   terminal->frame_up_to_date_hook = w32_frame_up_to_date;
+  terminal->defined_color_hook = w32_defined_color;
+  terminal->query_frame_background_color = w32_query_frame_background_color;
+  terminal->query_colors = w32_query_colors;
   terminal->mouse_position_hook = w32_mouse_position;
+  terminal->get_focus_frame = w32_get_focus_frame;
+  terminal->focus_frame_hook = w32_focus_frame;
   terminal->frame_rehighlight_hook = w32_frame_rehighlight;
   terminal->frame_raise_lower_hook = w32_frame_raise_lower;
+  terminal->frame_visible_invisible_hook = w32_make_frame_visible_invisible;
   terminal->fullscreen_hook = w32fullscreen_hook;
+  terminal->iconify_frame_hook = w32_iconify_frame;
+  terminal->set_window_size_hook = w32_set_window_size;
+  terminal->set_frame_offset_hook = w32_set_offset;
+  terminal->set_frame_alpha_hook = w32_set_frame_alpha;
+  terminal->set_new_font_hook = w32_new_font;
+  terminal->set_bitmap_icon_hook = w32_bitmap_icon;
+  terminal->implicit_set_name_hook = w32_implicitly_set_name;
   terminal->menu_show_hook = w32_menu_show;
+  terminal->activate_menubar_hook = w32_activate_menubar;
   terminal->popup_dialog_hook = w32_popup_dialog;
+  terminal->change_tool_bar_height_hook = w32_change_tool_bar_height;
   terminal->set_vertical_scroll_bar_hook = w32_set_vertical_scroll_bar;
   terminal->set_horizontal_scroll_bar_hook = w32_set_horizontal_scroll_bar;
+  terminal->set_scroll_bar_default_width_hook = 
w32_set_scroll_bar_default_width;
+  terminal->set_scroll_bar_default_height_hook = 
w32_set_scroll_bar_default_height;
   terminal->condemn_scroll_bars_hook = w32_condemn_scroll_bars;
   terminal->redeem_scroll_bar_hook = w32_redeem_scroll_bar;
   terminal->judge_scroll_bars_hook = w32_judge_scroll_bars;
-  terminal->delete_frame_hook = x_destroy_window;
-  terminal->delete_terminal_hook = x_delete_terminal;
+  terminal->get_string_resource_hook = w32_get_string_resource;
+  terminal->delete_frame_hook = w32_destroy_window;
+  terminal->delete_terminal_hook = w32_delete_terminal;
   /* Other hooks are NULL by default.  */
 
   /* We don't yet support separate terminals on W32, so don't try to share
@@ -7094,7 +7215,7 @@ w32_create_terminal (struct w32_display_info *dpyinfo)
 }
 
 static void
-x_delete_terminal (struct terminal *terminal)
+w32_delete_terminal (struct terminal *terminal)
 {
   struct w32_display_info *dpyinfo = terminal->display_info.w32;
 
@@ -7105,7 +7226,7 @@ x_delete_terminal (struct terminal *terminal)
 
   block_input ();
 
-  x_delete_display (dpyinfo);
+  w32_delete_display (dpyinfo);
   unblock_input ();
 }
 
@@ -7132,7 +7253,7 @@ w32_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
   /* Set the name of the terminal. */
   terminal->name = xlispstrdup (display_name);
 
-  dpyinfo->xrdb = xrm_option ? w32_make_rdb (xrm_option) : NULL;
+  dpyinfo->rdb = xrm_option ? w32_make_rdb (xrm_option) : NULL;
 
   /* Put this display on the chain.  */
   dpyinfo->next = x_display_list;
@@ -7151,8 +7272,8 @@ w32_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
   /* initialize palette with white and black */
   {
     XColor color;
-    w32_defined_color (0, "white", &color, 1);
-    w32_defined_color (0, "black", &color, 1);
+    w32_defined_color (0, "white", &color, true, false);
+    w32_defined_color (0, "black", &color, true, false);
   }
 
 #ifdef WINDOWSNT
@@ -7181,7 +7302,7 @@ w32_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
 
 /* Get rid of display DPYINFO, assuming all frames are already gone.  */
 void
-x_delete_display (struct w32_display_info *dpyinfo)
+w32_delete_display (struct w32_display_info *dpyinfo)
 {
   /* FIXME: the only display info apparently can't be deleted.  */
   /* free palette table */
diff --git a/src/w32term.h b/src/w32term.h
index ebdab04..de372d7 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -1,5 +1,5 @@
 /* Definitions and headers for communication on the Microsoft Windows API.
-   Copyright (C) 1995, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1995, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -120,7 +120,7 @@ struct w32_display_info
   Cursor horizontal_scroll_bar_cursor;
 
   /* Resource data base */
-  XrmDatabase xrdb;
+  const char *rdb;
 
   /* color palette information.  */
   int has_palette;
@@ -182,7 +182,7 @@ struct w32_display_info
      event).  It points to the focus frame's selected window's
      frame.  It differs from w32_focus_frame when we're using a global
      minibuffer.  */
-  struct frame *x_highlight_frame;
+  struct frame *highlight_frame;
 
   /* The frame waiting to be auto-raised in w32_read_socket.  */
   struct frame *w32_pending_autoraise_frame;
@@ -227,28 +227,33 @@ extern struct w32_display_info one_w32_display_info;
 extern HMENU current_popup_menu;
 extern int menubar_in_use;
 
-extern struct frame *x_window_to_frame (struct w32_display_info *, HWND);
+extern struct frame *w32_window_to_frame (struct w32_display_info *, HWND);
 
-struct w32_display_info *x_display_info_for_name (Lisp_Object);
+extern void w32_real_positions (struct frame *f, int *xptr, int *yptr);
+
+extern void w32_clear_under_internal_border (struct frame *);
+
+extern void w32_change_tool_bar_height (struct frame *, int);
+extern void w32_implicitly_set_name (struct frame *, Lisp_Object, Lisp_Object);
+extern void w32_set_scroll_bar_default_width (struct frame *);
+extern void w32_set_scroll_bar_default_height (struct frame *);
 
-/* also defined in xterm.h XXX: factor out to common header */
 
 extern struct w32_display_info *w32_term_init (Lisp_Object,
                                               char *, char *);
-extern int w32_defined_color (struct frame *f, const char *color,
-                              XColor *color_def, bool alloc_p);
-extern int x_display_pixel_height (struct w32_display_info *);
-extern int x_display_pixel_width (struct w32_display_info *);
-extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
-extern void x_set_tool_bar_lines (struct frame *f,
-                                  Lisp_Object value,
-                                  Lisp_Object oldval);
-extern void x_set_internal_border_width (struct frame *f,
-                                        Lisp_Object value,
-                                        Lisp_Object oldval);
+extern bool w32_defined_color (struct frame *, const char *, XColor *,
+                               bool, bool);
+extern int w32_display_pixel_height (struct w32_display_info *);
+extern int w32_display_pixel_width (struct w32_display_info *);
 extern void initialize_frame_menubar (struct frame *);
 extern void w32_dialog_in_progress (Lisp_Object in_progress);
 
+extern void w32_make_frame_visible (struct frame *f);
+extern void w32_make_frame_invisible (struct frame *f);
+extern void w32_iconify_frame (struct frame *f);
+extern void w32_free_frame_resources (struct frame *);
+extern void w32_wm_set_size_hint (struct frame *, long, bool);
+
 /* w32inevt.c */
 extern int w32_kbd_patch_key (KEY_EVENT_RECORD *event, int cpId);
 extern int w32_kbd_mods_to_emacs (DWORD mods, WORD key);
@@ -257,6 +262,10 @@ extern int w32_kbd_mods_to_emacs (DWORD mods, WORD key);
 extern void w32con_hide_cursor (void);
 extern void w32con_show_cursor (void);
 
+/* w32reg.c */
+extern const char *w32_get_string_resource (void *v_rdb,
+                                            const char *name,
+                                            const char *class);
 
 #define PIX_TYPE COLORREF
 
@@ -397,12 +406,12 @@ struct w32_output
 
 extern struct w32_output w32term_display;
 
-/* Return the X output data for frame F.  */
-#define FRAME_X_OUTPUT(f) ((f)->output_data.w32)
+/* Return the output data for frame F.  */
+#define FRAME_OUTPUT_DATA(f) ((f)->output_data.w32)
 
 /* Return the window associated with the frame F.  */
 #define FRAME_W32_WINDOW(f) ((f)->output_data.w32->window_desc)
-#define FRAME_X_WINDOW(f) FRAME_W32_WINDOW (f)
+#define FRAME_NATIVE_WINDOW(f) FRAME_W32_WINDOW (f)
 
 #define FRAME_FONT(f) ((f)->output_data.w32->font)
 #define FRAME_FONTSET(f) ((f)->output_data.w32->fontset)
@@ -715,9 +724,8 @@ extern void complete_deferred_msg (HWND hwnd, UINT msg, 
LRESULT result);
 extern BOOL parse_button (int, int, int *, int *);
 
 extern void w32_sys_ring_bell (struct frame *f);
-extern void x_delete_display (struct w32_display_info *dpyinfo);
-extern void x_clear_under_internal_border (struct frame *f);
-extern void x_query_color (struct frame *, XColor *);
+extern void w32_query_color (struct frame *, XColor *);
+extern void w32_delete_display (struct w32_display_info *dpyinfo);
 
 #define FILE_NOTIFICATIONS_SIZE 16384
 /* Notifications come in sets.  We use a doubly linked list with a
@@ -732,7 +740,7 @@ struct notifications_set {
 };
 extern struct notifications_set *notifications_set_head;
 extern Lisp_Object w32_get_watch_object (void *);
-extern Lisp_Object lispy_file_action (DWORD);
+extern Lisp_Object w32_lispy_file_action (DWORD);
 extern int handle_file_notifications (struct input_event *);
 
 extern void w32_initialize_display_info (Lisp_Object);
diff --git a/src/w32uniscribe.c b/src/w32uniscribe.c
index 3c400f3..693e4a4 100644
--- a/src/w32uniscribe.c
+++ b/src/w32uniscribe.c
@@ -1,5 +1,5 @@
 /* Font backend for the Microsoft W32 Uniscribe API.
-   Copyright (C) 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -36,6 +36,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "composite.h"
 #include "font.h"
 #include "w32font.h"
+#include "pdumper.h"
 #include "w32common.h"
 
 struct uniscribe_font_info
@@ -177,6 +178,11 @@ uniscribe_otf_capability (struct font *font)
   Lisp_Object features;
 
   f = XFRAME (selected_frame);
+  /* Prevent quitting while we cons the lists in otf_features.
+     That's because get_frame_dc acquires the critical section, so we
+     cannot quit before we release it in release_frame_dc.  */
+  Lisp_Object prev_quit = Vinhibit_quit;
+  Vinhibit_quit = Qt;
   context = get_frame_dc (f);
   old_font = SelectObject (context, FONT_HANDLE (font));
 
@@ -187,6 +193,7 @@ uniscribe_otf_capability (struct font *font)
 
   SelectObject (context, old_font);
   release_frame_dc (f, context);
+  Vinhibit_quit = prev_quit;
 
   return capability;
 }
@@ -1181,9 +1188,17 @@ struct font_driver uniscribe_font_driver =
    as it needs to test for the existence of the Uniscribe library.  */
 void syms_of_w32uniscribe (void);
 
+static void syms_of_w32uniscribe_for_pdumper (void);
+
 void
 syms_of_w32uniscribe (void)
 {
+  pdumper_do_now_and_after_load (syms_of_w32uniscribe_for_pdumper);
+}
+
+static void
+syms_of_w32uniscribe_for_pdumper (void)
+{
   HMODULE uniscribe;
 
   /* Don't init uniscribe when dumping */
diff --git a/src/w32xfns.c b/src/w32xfns.c
index e9261b0..a5966b2 100644
--- a/src/w32xfns.c
+++ b/src/w32xfns.c
@@ -1,5 +1,5 @@
 /* Functions taken directly from X sources for use with the Microsoft Windows 
API.
-   Copyright (C) 1989, 1992-1995, 1999, 2001-2018 Free Software
+   Copyright (C) 1989, 1992-1995, 1999, 2001-2019 Free Software
    Foundation, Inc.
 
 This file is part of GNU Emacs.
diff --git a/src/widget.c b/src/widget.c
index 2e9295f..e662dd3 100644
--- a/src/widget.c
+++ b/src/widget.c
@@ -1,5 +1,5 @@
 /* The emacs frame widget.
-   Copyright (C) 1992-1993, 2000-2018 Free Software Foundation, Inc.
+   Copyright (C) 1992-1993, 2000-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -282,7 +282,7 @@ set_frame_size (EmacsFrame ew)
 
   frame_size_history_add
     (f, Qset_frame_size, FRAME_TEXT_WIDTH (f), FRAME_TEXT_HEIGHT (f),
-     list2 (make_fixnum (ew->core.width), make_fixnum (ew->core.height)));
+     list2i (ew->core.width, ew->core.height));
 }
 
 static void
@@ -297,7 +297,6 @@ update_wm_hints (EmacsFrame ew)
   int char_height;
   int base_width;
   int base_height;
-  int min_rows = 0, min_cols = 0;
 
   /* This happens when the frame is just created.  */
   if (! wmshell) return;
@@ -323,8 +322,8 @@ update_wm_hints (EmacsFrame ew)
                 XtNbaseHeight, (XtArgVal) base_height,
                 XtNwidthInc, (XtArgVal) (frame_resize_pixelwise ? 1 : cw),
                 XtNheightInc, (XtArgVal) (frame_resize_pixelwise ? 1 : ch),
-                XtNminWidth, (XtArgVal) (base_width + min_cols * cw),
-                XtNminHeight, (XtArgVal) (base_height + min_rows * ch),
+                XtNminWidth, (XtArgVal) base_width,
+                XtNminHeight, (XtArgVal) base_height,
                 NULL);
 }
 
@@ -435,21 +434,20 @@ EmacsFrameResize (Widget widget)
 }
 
 static XtGeometryResult
-EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry *request, 
XtWidgetGeometry *result)
+EmacsFrameQueryGeometry (Widget widget, XtWidgetGeometry *request,
+                        XtWidgetGeometry *result)
 {
-  EmacsFrame ew = (EmacsFrame) widget;
-
   int mask = request->request_mode;
-  Dimension ok_width, ok_height;
 
-  if (mask & (CWWidth | CWHeight))
+  if (mask & (CWWidth | CWHeight) && !frame_resize_pixelwise)
     {
-      if (!frame_resize_pixelwise)
-       round_size_to_char (ew,
-                           (mask & CWWidth) ? request->width : ew->core.width,
-                           ((mask & CWHeight) ? request->height
-                            : ew->core.height),
-                           &ok_width, &ok_height);
+      EmacsFrame ew = (EmacsFrame) widget;
+      Dimension ok_width, ok_height;
+
+      round_size_to_char (ew,
+                         mask & CWWidth ? request->width : ew->core.width,
+                         mask & CWHeight ? request->height : ew->core.height,
+                         &ok_width, &ok_height);
       if ((mask & CWWidth) && (ok_width != request->width))
        {
          result->request_mode |= CWWidth;
diff --git a/src/widget.h b/src/widget.h
index 68e4ef1..00b538f 100644
--- a/src/widget.h
+++ b/src/widget.h
@@ -1,5 +1,5 @@
 /* The emacs frame widget public header file.
-   Copyright (C) 1993, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1993, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/widgetprv.h b/src/widgetprv.h
index fc9b446..075fd60 100644
--- a/src/widgetprv.h
+++ b/src/widgetprv.h
@@ -1,5 +1,5 @@
 /* The emacs frame widget private header file.
-   Copyright (C) 1993, 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 1993, 2001-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/window.c b/src/window.c
index 9da77ff..30ffad0 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1,6 +1,6 @@
 /* Window creation, deletion and examination for GNU Emacs.
    Does not include redisplay.
-   Copyright (C) 1985-1987, 1993-1998, 2000-2018 Free Software
+   Copyright (C) 1985-1987, 1993-1998, 2000-2019 Free Software
    Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -42,6 +42,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #ifdef MSDOS
 #include "msdos.h"
 #endif
+#include "pdumper.h"
 
 static ptrdiff_t count_windows (struct window *);
 static ptrdiff_t get_leaf_windows (struct window *, struct window **,
@@ -77,11 +78,19 @@ static void apply_window_adjustment (struct window *);
    FRAME_SELECTED_WINDOW (selected_frame).  */
 Lisp_Object selected_window;
 
+/* The value of selected_window at the last time window change
+   functions were run.  This is always the same as
+   FRAME_OLD_SELECTED_WINDOW (old_selected_frame).  */
+static Lisp_Object old_selected_window;
+
 /* A list of all windows for use by next_window and Fwindow_list.
    Functions creating or deleting windows should invalidate this cache
    by setting it to nil.  */
 Lisp_Object Vwindow_list;
 
+/* True mean window_change_record has to record all live frames.  */
+static bool window_change_record_frames;
+
 /* The mini-buffer window of the selected frame.
    Note that you cannot test for mini-bufferness of an arbitrary window
    by comparing against this; but you can test for mini-bufferness of
@@ -211,7 +220,7 @@ static void
 wset_update_mode_line (struct window *w)
 {
   /* If this window is the selected window on its frame, set the
-     global variable update_mode_lines, so that x_consider_frame_title
+     global variable update_mode_lines, so that gui_consider_frame_title
      will consider this frame's title for redisplay.  */
   Lisp_Object fselected_window = XFRAME (WINDOW_FRAME (w))->selected_window;
 
@@ -304,6 +313,12 @@ wset_buffer (struct window *w, Lisp_Object val)
   adjust_window_count (w, 1);
 }
 
+static void
+wset_old_buffer (struct window *w, Lisp_Object val)
+{
+  w->old_buffer = val;
+}
+
 DEFUN ("windowp", Fwindowp, Swindowp, 1, 1, 0,
        doc: /* Return t if OBJECT is a window and nil otherwise.  */)
   (Lisp_Object object)
@@ -428,6 +443,22 @@ return the selected window of that frame.  */)
   return window;
 }
 
+DEFUN ("frame-old-selected-window", Fframe_old_selected_window,
+       Sframe_old_selected_window, 0, 1, 0,
+       doc: /* Return old selected window of FRAME.
+FRAME must be a live frame and defaults to the selected one.
+
+The return value is the window selected on FRAME the last time window
+change functions were run for FRAME.  */)
+  (Lisp_Object frame)
+{
+  if (NILP (frame))
+    frame = selected_frame;
+  CHECK_LIVE_FRAME (frame);
+
+  return XFRAME (frame)->old_selected_window;
+}
+
 DEFUN ("set-frame-selected-window", Fset_frame_selected_window,
        Sset_frame_selected_window, 2, 3, 0,
        doc: /* Set selected window of FRAME to WINDOW.
@@ -465,6 +496,16 @@ selected windows appears and to which many commands apply. 
 */)
   return selected_window;
 }
 
+DEFUN ("old-selected-window", Fold_selected_window,
+       Sold_selected_window, 0, 0, 0,
+       doc: /* Return the old selected window.
+The return value is the window selected the last time window change
+functions were run.  */)
+  (void)
+{
+  return old_selected_window;
+}
+
 EMACS_INT window_select_count;
 
 /* If select_window is called with inhibit_point_swap true it will
@@ -597,9 +638,33 @@ Return nil for an internal window or a deleted window.  */)
   (Lisp_Object window)
 {
   struct window *w = decode_any_window (window);
+
   return WINDOW_LEAF_P (w) ? w->contents : Qnil;
 }
 
+DEFUN ("window-old-buffer", Fwindow_old_buffer, Swindow_old_buffer, 0, 1, 0,
+       doc: /* Return the old buffer displayed by WINDOW.
+WINDOW must be a live window and defaults to the selected one.
+
+The return value is the buffer shown in WINDOW at the last time window
+change functions were run.  It is nil if WINDOW was created after
+that.  It is t if WINDOW has been restored from a window configuration
+after that.  */)
+  (Lisp_Object window)
+{
+  struct window *w = decode_live_window (window);
+
+  return (NILP (w->old_buffer)
+         /* A new window.  */
+         ? Qnil
+         : (w->change_stamp != WINDOW_XFRAME (w)->change_stamp)
+         /* A window restored from a configuration.  */
+         ? Qt
+         /* A window that was live the last time seen by window
+            change functions.  */
+         : w->old_buffer);
+}
+
 DEFUN ("window-parent", Fwindow_parent, Swindow_parent, 0, 1, 0,
        doc: /* Return the parent window of window WINDOW.
 WINDOW must be a valid window and defaults to the selected one.
@@ -723,34 +788,32 @@ the height of the screen areas spanned by its children.  
*/)
   return make_fixnum (decode_valid_window (window)->pixel_height);
 }
 
-DEFUN ("window-pixel-width-before-size-change",
-       Fwindow_pixel_width_before_size_change,
-       Swindow_pixel_width_before_size_change, 0, 1, 0,
-       doc: /* Return pixel width of window WINDOW before last size changes.
+DEFUN ("window-old-pixel-width", Fwindow_old_pixel_width,
+       Swindow_old_pixel_width, 0, 1, 0,
+       doc: /* Return old total pixel width of WINDOW.
 WINDOW must be a valid window and defaults to the selected one.
 
-The return value is the pixel width of WINDOW at the last time
-`window-size-change-functions' was run.  It's zero if WINDOW was made
-after that.  */)
+The return value is the total pixel width of WINDOW after the last
+time window change functions found WINDOW live on its frame.  It is
+zero if WINDOW was created after that.  */)
   (Lisp_Object window)
 {
   return (make_fixnum
-         (decode_valid_window (window)->pixel_width_before_size_change));
+         (decode_valid_window (window)->old_pixel_width));
 }
 
-DEFUN ("window-pixel-height-before-size-change",
-       Fwindow_pixel_height_before_size_change,
-       Swindow_pixel_height_before_size_change, 0, 1, 0,
-       doc: /* Return pixel height of window WINDOW before last size changes.
+DEFUN ("window-old-pixel-height", Fwindow_old_pixel_height,
+       Swindow_old_pixel_height, 0, 1, 0,
+       doc: /* Return old total pixel height of WINDOW.
 WINDOW must be a valid window and defaults to the selected one.
 
-The return value is the pixel height of WINDOW at the last time
-`window-size-change-functions' was run.  It's zero if WINDOW was made
-after that.  */)
+The return value is the total pixel height of WINDOW after the last
+time window change functions found WINDOW live on its frame.  It is
+zero if WINDOW was created after that.  */)
   (Lisp_Object window)
 {
   return (make_fixnum
-         (decode_valid_window (window)->pixel_height_before_size_change));
+         (decode_valid_window (window)->old_pixel_height));
 }
 
 DEFUN ("window-total-height", Fwindow_total_height, Swindow_total_height, 0, 
2, 0,
@@ -984,6 +1047,26 @@ window_body_width (struct window *w, bool pixelwise)
              0);
 }
 
+DEFUN ("window-body-width", Fwindow_body_width, Swindow_body_width, 0, 2, 0,
+       doc: /* Return the width of WINDOW's text area.
+WINDOW must be a live window and defaults to the selected one.  Optional
+argument PIXELWISE non-nil means return the width in pixels.  The return
+value does not include any vertical dividers, fringes or marginal areas,
+or scroll bars.
+
+If PIXELWISE is nil, return the largest integer smaller than WINDOW's
+pixel width divided by the character width of WINDOW's frame.  This
+means that if a column at the right of the text area is only partially
+visible, that column is not counted.
+
+Note that the returned value includes the column reserved for the
+continuation glyph.  */)
+  (Lisp_Object window, Lisp_Object pixelwise)
+{
+  return make_fixnum (window_body_width (decode_live_window (window),
+                                        !NILP (pixelwise)));
+}
+
 DEFUN ("window-body-height", Fwindow_body_height, Swindow_body_height, 0, 2, 0,
        doc: /* Return the height of WINDOW's text area.
 WINDOW must be a live window and defaults to the selected one.  Optional
@@ -1001,24 +1084,34 @@ visible, that line is not counted.  */)
                                          !NILP (pixelwise)));
 }
 
-DEFUN ("window-body-width", Fwindow_body_width, Swindow_body_width, 0, 2, 0,
-       doc: /* Return the width of WINDOW's text area.
-WINDOW must be a live window and defaults to the selected one.  Optional
-argument PIXELWISE non-nil means return the width in pixels.  The return
-value does not include any vertical dividers, fringes or marginal areas,
-or scroll bars.
+DEFUN ("window-old-body-pixel-width",
+       Fwindow_old_body_pixel_width,
+       Swindow_old_body_pixel_width, 0, 1, 0,
+       doc: /* Return old width of WINDOW's text area in pixels.
+WINDOW must be a live window and defaults to the selected one.
 
-If PIXELWISE is nil, return the largest integer smaller than WINDOW's
-pixel width divided by the character width of WINDOW's frame.  This
-means that if a column at the right of the text area is only partially
-visible, that column is not counted.
+The return value is the pixel width of WINDOW's text area after the
+last time window change functions found WINDOW live on its frame.  It
+is zero if WINDOW was created after that.  */)
+  (Lisp_Object window)
+{
+  return (make_fixnum
+         (decode_live_window (window)->old_body_pixel_width));
+}
 
-Note that the returned value includes the column reserved for the
-continuation glyph.  */)
-  (Lisp_Object window, Lisp_Object pixelwise)
+DEFUN ("window-old-body-pixel-height",
+       Fwindow_old_body_pixel_height,
+       Swindow_old_body_pixel_height, 0, 1, 0,
+       doc: /* Return old height of WINDOW's text area in pixels.
+WINDOW must be a live window and defaults to the selected one.
+
+The return value is the pixel height of WINDOW's text area after the
+last time window change functions found WINDOW live on its frame.  It
+is zero if WINDOW was created after that.  */)
+  (Lisp_Object window)
 {
-  return make_fixnum (window_body_width (decode_live_window (window),
-                                        !NILP (pixelwise)));
+  return (make_fixnum
+         (decode_live_window (window)->old_body_pixel_height));
 }
 
 DEFUN ("window-mode-line-height", Fwindow_mode_line_height,
@@ -1506,7 +1599,7 @@ window_from_coordinates (struct frame *f, int x, int y,
   cw.window = &window, cw.x = x, cw.y = y; cw.part = part;
   foreach_window (f, check_window_containing, &cw);
 
-#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
   /* If not found above, see if it's in the tool bar window, if a tool
      bar exists.  */
   if (NILP (window)
@@ -1703,7 +1796,12 @@ DEFUN ("set-window-start", Fset_window_start, 
Sset_window_start, 2, 3, 0,
        doc: /* Make display in WINDOW start at position POS in WINDOW's buffer.
 WINDOW must be a live window and defaults to the selected one.  Return
 POS.  Optional third arg NOFORCE non-nil inhibits next redisplay from
-overriding motion of point in order to display at this exact start.  */)
+overriding motion of point in order to display at this exact start.
+
+For reliable setting of WINDOW start position, make sure point is
+at a position that will be visible when that start is in effect,
+otherwise there's a chance POS will be disregarded, e.g., if point
+winds up in a partially-visible line.  */)
   (Lisp_Object window, Lisp_Object pos, Lisp_Object noforce)
 {
   register struct window *w = decode_live_window (window);
@@ -2435,7 +2533,7 @@ window_list (void)
             have to reverse this list at the end.  */
          foreach_window (XFRAME (frame), add_window_to_list, &arglist);
          arglist = Fnreverse (arglist);
-         Vwindow_list = CALLN (Fnconc, Vwindow_list, arglist);
+         Vwindow_list = nconc2 (Vwindow_list, arglist);
        }
     }
 
@@ -3264,7 +3362,7 @@ window-start value is reasonable when this function is 
called.  */)
   adjust_frame_glyphs (f);
   unblock_input ();
 
-  run_window_configuration_change_hook (f);
+  FRAME_WINDOW_CHANGE (f) = true;
 
   return Qnil;
 }
@@ -3318,6 +3416,15 @@ select_frame_norecord (Lisp_Object frame)
     Fselect_frame (frame, Qt);
 }
 
+/**
+ * run_window_configuration_change_hook:
+ *
+ * Run any functions on 'window-configuration-change-hook' for the
+ * frame specified by F.  The buffer-local values are run with the
+ * window showing the buffer selected.  The default value is run with
+ * the frame specified by F selected.  All functions are called with
+ * the selected window's buffer current.
+ */
 static void
 run_window_configuration_change_hook (struct frame *f)
 {
@@ -3327,8 +3434,8 @@ run_window_configuration_change_hook (struct frame *f)
   XSETFRAME (frame, f);
 
   if (NILP (Vrun_hooks)
-      || !(f->can_x_set_window_size)
-      || !(f->after_make_frame))
+      || !f->can_set_window_size
+      || !f->after_make_frame)
     return;
 
   /* Use the right buffer.  Matters when running the local hooks.  */
@@ -3371,7 +3478,10 @@ run_window_configuration_change_hook (struct frame *f)
 DEFUN ("run-window-configuration-change-hook", 
Frun_window_configuration_change_hook,
        Srun_window_configuration_change_hook, 0, 1, 0,
        doc: /* Run `window-configuration-change-hook' for FRAME.
-If FRAME is omitted or nil, it defaults to the selected frame.  */)
+If FRAME is omitted or nil, it defaults to the selected frame.
+
+This function should not be needed any more and will be therefore
+considered obsolete.  */)
   (Lisp_Object frame)
 {
   run_window_configuration_change_hook (decode_live_frame (frame));
@@ -3381,131 +3491,438 @@ If FRAME is omitted or nil, it defaults to the 
selected frame.  */)
 DEFUN ("run-window-scroll-functions", Frun_window_scroll_functions,
        Srun_window_scroll_functions, 0, 1, 0,
        doc: /* Run `window-scroll-functions' for WINDOW.
-If WINDOW is omitted or nil, it defaults to the selected window.  */)
+If WINDOW is omitted or nil, it defaults to the selected window.
+
+This function is curently only called by 'split-window' for the new
+window after it has established the size of the new window.  */)
   (Lisp_Object window)
 {
-  if (! NILP (Vwindow_scroll_functions))
+  struct window *w = decode_live_window (window);
+  ptrdiff_t count = SPECPDL_INDEX ();
+
+  record_unwind_current_buffer ();
+  Fset_buffer (w->contents);
+  if (!NILP (Vwindow_scroll_functions))
     run_hook_with_args_2 (Qwindow_scroll_functions, window,
-                         Fmarker_position (decode_live_window 
(window)->start));
+                         Fmarker_position (w->start));
+  unbind_to (count, Qnil);
+
   return Qnil;
 }
 
 
-/* Compare old and present pixel sizes of windows in tree rooted at W.
-   Return true iff any of these windows differs in size.  */
+/**
+ * window_sub_list:
+ *
+ * Return list of live windows constructed by traversing any window
+ * sub-tree rooted at WINDOW in preorder followed by right siblings of
+ * WINDOW.  Called from outside with second argument WINDOWS nil.  The
+ * returned list is in reverse order.
+ */
+static Lisp_Object
+window_sub_list (Lisp_Object window, Lisp_Object windows)
+{
 
-static bool
-window_size_changed (struct window *w)
+  struct window *w = XWINDOW (window);
+
+  while (w)
+    {
+      if (WINDOW_INTERNAL_P (w))
+       windows = window_sub_list (w->contents, windows);
+      else
+       windows = Fcons (window, windows);
+
+      window = w->next;
+      w = NILP (window) ? 0 : XWINDOW (window);
+    }
+
+  return windows;
+}
+
+
+/**
+ * window_change_record_windows:
+ *
+ * Record changes for all live windows found by traversing any window
+ * sub-tree rooted at WINDOW in preorder followed by any right
+ * siblings of WINDOW.  This sets the old buffer, old pixel and old
+ * body pixel sizes of each live window found to the respective
+ * current values.  It also sets the change stamp of each window found
+ * to STAMP.  Return the number of live windows found.
+ *
+ * When not called by itself recursively, WINDOW is its frame's root
+ * window, STAMP is the current change stamp of WINDOW's frame and
+ * NUMBER is 0.
+ */
+static ptrdiff_t
+window_change_record_windows (Lisp_Object window, int stamp, ptrdiff_t number)
 {
-  if (w->pixel_width != w->pixel_width_before_size_change
-      || w->pixel_height != w->pixel_height_before_size_change)
-    return true;
+  struct window *w = XWINDOW (window);
 
-  if (WINDOW_INTERNAL_P (w))
+  while (w)
     {
-      w = XWINDOW (w->contents);
-      while (w)
+      if (WINDOW_INTERNAL_P (w))
+       number = window_change_record_windows (w->contents, stamp, number);
+      else
        {
-         if (window_size_changed (w))
-           return true;
-
-         w = NILP (w->next) ? 0 : XWINDOW (w->next);
+         number += 1;
+         w->change_stamp = stamp;
+         wset_old_buffer (w, w->contents);
+         w->old_pixel_width = w->pixel_width;
+         w->old_pixel_height = w->pixel_height;
+         w->old_body_pixel_width = window_body_width (w, true);
+         w->old_body_pixel_height = window_body_height (w, true);
        }
+
+      w = NILP (w->next) ? 0 : XWINDOW (w->next);
     }
 
-  return false;
+  return number;
 }
 
-/* Set before size change pixel sizes of windows in tree rooted at W to
-   their present pixel sizes.  */
 
+/**
+ * window_change_record:
+ *
+ * For each frame that has recorded changes, record its selected
+ * window, update Fchange stamp, record the states of all its live
+ * windows via window_change_record_windows and reset its
+ * window_change and window_state_change flags.
+ *
+ * Record selected window in old_selected_window and selected frame in
+ * old_selected_frame.
+ */
 static void
-window_set_before_size_change_sizes (struct window *w)
+window_change_record (void)
 {
-  w->pixel_width_before_size_change = w->pixel_width;
-  w->pixel_height_before_size_change = w->pixel_height;
-
-  if (WINDOW_INTERNAL_P (w))
+  if (window_change_record_frames)
     {
-      w = XWINDOW (w->contents);
-      while (w)
+      Lisp_Object tail, frame;
+
+      FOR_EACH_FRAME (tail, frame)
        {
-         window_set_before_size_change_sizes (w);
-         w = NILP (w->next) ? 0 : XWINDOW (w->next);
+         struct frame *f = XFRAME (frame);
+
+         /* Record FRAME's selected window.  */
+         fset_old_selected_window (f, FRAME_SELECTED_WINDOW (f));
+
+         /* Bump up FRAME's change stamp.  If this wraps, make it 1 to avoid
+            that a new window (whose change stamp is always set to 0) gets
+            reported as "existing before".  */
+         f->change_stamp += 1;
+         if (f->change_stamp == 0)
+           f->change_stamp = 1;
+
+         /* Bump up the change stamps of all live windows on this frame so
+            the next call of this function can tell whether any of them
+            "existed before" and record state for each of these windows.  */
+         f->number_of_windows
+           = window_change_record_windows (f->root_window, f->change_stamp, 0);
+
+         /* Reset our flags.  */
+         FRAME_WINDOW_CHANGE (f) = false;
+         FRAME_WINDOW_STATE_CHANGE (f) = false;
        }
     }
+
+  /* Strictly spoken we don't need old_selected_window at all - its
+     value is the old selected window of old_selected_frame.  */
+  old_selected_window = selected_window;
+  old_selected_frame = selected_frame;
 }
 
 
-void
-run_window_size_change_functions (Lisp_Object frame)
+/**
+ * run_window_change_functions_1:
+ *
+ * Run window change functions specified by SYMBOL with argument
+ * WINDOW_OR_FRAME.  If BUFFER is nil, WINDOW_OR_FRAME specifies a
+ * frame.  In this case, run the default value of SYMBOL.  Otherwise,
+ * WINDOW_OR_FRAME denotes a window showing BUFFER.  In this case, run
+ * the buffer local value of SYMBOL in BUFFER, if any.
+ */
+static void
+run_window_change_functions_1 (Lisp_Object symbol, Lisp_Object buffer,
+                              Lisp_Object window_or_frame)
 {
-  struct frame *f = XFRAME (frame);
-  struct window *r = XWINDOW (FRAME_ROOT_WINDOW (f));
+  Lisp_Object funs = Qnil;
 
-  if (NILP (Vrun_hooks)
-      || !(f->can_x_set_window_size)
-      || !(f->after_make_frame))
-    return;
+  if (NILP (buffer))
+    funs = Fdefault_value (symbol);
+  else if (!NILP (Fassoc (symbol, BVAR (XBUFFER (buffer), local_var_alist),
+                         Qnil)))
+    /* Don't run global value buffer-locally.  */
+    funs = buffer_local_value (symbol, buffer);
 
-  if (FRAME_WINDOW_CONFIGURATION_CHANGED (f)
-      /* Here we implicitly exclude the possibility that the height of
-        FRAME and its minibuffer window both change leaving the height
-        of FRAME's root window alone.  */
-      || window_size_changed (r))
+  while (CONSP (funs))
     {
-      Lisp_Object globals = Fdefault_value (Qwindow_size_change_functions);
-      Lisp_Object windows = Fwindow_list (frame, Qlambda, Qnil);
-      /* The buffers for which the local hook was already run.  */
-      Lisp_Object buffers = Qnil;
+      if (!EQ (XCAR (funs), Qt)
+         && (NILP (buffer)
+             ? FRAME_LIVE_P (XFRAME (window_or_frame))
+             : WINDOW_LIVE_P (window_or_frame)))
+       {
+         /* Any function called here may change the state of any
+            frame.  Make sure to record changes for each live frame
+            in window_change_record later.  */
+         window_change_record_frames = true;
+         safe_call1 (XCAR (funs), window_or_frame);
+       }
 
+      funs = XCDR (funs);
+    }
+}
+
+
+/**
+ * run_window_change_functions:
+ *
+ * Run window change functions for each live frame.  This function
+ * must be called from a "safe" position in redisplay_internal.
+ *
+ * Do not run any functions for a frame whose window_change flag is
+ * nil, where no window selection happened and whose window state
+ * change flag was not set since the last time this function was
+ * called.  Never run any functions for tooltip frames.
+ *
+ * The change functions run are, in this order:
+ *
+ * 'window-buffer-change-functions' which are run for a window that
+ * changed its buffer or that was not shown the last time window
+ * change functions were run.  The default value is also run when a
+ * window was deleted since the last time window change functions were
+ * run.
+ *
+ * `window-size-change-functions' run for a window that changed its
+ * body or total size, a window that changed its buffer or a window
+ * that was not shown the last time window change functions were run.
+ *
+ * `window-selected-change-functions' run for a window that was
+ * (de-)selected since the last time window change functions were run.
+ *
+ * `window-state-change-functions' run for a window for which any of
+ * the above three changes occurred.
+ *
+ * A buffer-local value of these functions is run if and only if the
+ * window for which the functions are run currently shows the buffer.
+ * Each call gets one argument - the window showing the buffer.  This
+ * means that the buffer-local value of these functions may be called
+ * as many times as the buffer is shown on the frame.
+ *
+ * The default values of these functions are called only after all
+ * buffer-local values for all of these functions have been run.  Each
+ * such call receives one argument - the frame for which a change
+ * occurred.  Functions on `window-state-change-functions' are run
+ * also if the corresponding frame's window state change flag has been
+ * set.
+ *
+ * After the four change functions cited above have been run in the
+ * indicated way, functions on 'window-configuration-change-hook' are
+ * run.  A buffer-local value is run if a window shows that buffer and
+ * has either changed its buffer or its body or total size or did not
+ * appear on this frame since the last time window change functions
+ * were run.  The functions are called without argument and with the
+ * buffer's window selected.  The default value is run without
+ * argument and with the frame for which the function is run selected.
+ *
+ * In a final step, functions on `window-state-change-hook' are run
+ * provided a window state change has occurred or the window state
+ * change flag has been set on at least one frame.  Each of these
+ * functions is called without argument.
+ *
+ * This function does not save and restore match data.  Any functions
+ * it calls are responsible for doing that themselves.
+ */
+void
+run_window_change_functions (void)
+{
+  Lisp_Object tail, frame;
+  bool selected_frame_change = !EQ (selected_frame, old_selected_frame);
+  bool run_window_state_change_hook = false;
+  ptrdiff_t count = SPECPDL_INDEX ();
+
+  window_change_record_frames = false;
+  record_unwind_protect_void (window_change_record);
+  specbind (Qinhibit_redisplay, Qt);
+
+  FOR_EACH_FRAME (tail, frame)
+    {
+      struct frame *f = XFRAME (frame);
+      Lisp_Object root = FRAME_ROOT_WINDOW (f);
+      bool frame_window_change = FRAME_WINDOW_CHANGE (f);
+      bool window_buffer_change, window_size_change;
+      bool frame_buffer_change = false, frame_size_change = false;
+      bool frame_selected_change
+       = (selected_frame_change
+          && (EQ (frame, old_selected_frame)
+              || EQ (frame, selected_frame)));
+      bool frame_selected_window_change
+       = !EQ (FRAME_OLD_SELECTED_WINDOW (f), FRAME_SELECTED_WINDOW (f));
+      bool frame_window_state_change = FRAME_WINDOW_STATE_CHANGE (f);
+      bool window_deleted = false;
+      Lisp_Object windows;
+      ptrdiff_t number_of_windows;
+
+      if (!FRAME_LIVE_P (f)
+         || !f->can_set_window_size
+         || !f->after_make_frame
+         || FRAME_TOOLTIP_P (f)
+         || !(frame_window_change
+              || frame_selected_change
+              || frame_selected_window_change
+              || frame_window_state_change))
+       /* Either we are not allowed to run hooks for this frame or no
+          window change has been reported for it since the last time
+          we ran window change functions on it.  */
+       continue;
+
+      /* Analyze windows and run buffer locals hooks in pre-order.  */
+      windows = Fnreverse (window_sub_list (root, Qnil));
+      number_of_windows = 0;
+
+      /* The following loop collects all data needed to tell whether
+        the default value of a hook shall be run and runs any buffer
+        local hooks right away.  */
       for (; CONSP (windows); windows = XCDR (windows))
        {
          Lisp_Object window = XCAR (windows);
-         Lisp_Object buffer = Fwindow_buffer (window);
-
-         /* Run a buffer-local value only once for that buffer and
-            only if at least one window showing that buffer on FRAME
-            actually changed its size.  Note that the function is run
-            with FRAME as its argument and as such oblivious to the
-            window checked below.  */
-         if (window_size_changed (XWINDOW (window))
-             && !NILP (Flocal_variable_p (Qwindow_size_change_functions, 
buffer))
-             && NILP (Fmemq (buffer, buffers)))
-           {
-             Lisp_Object locals
-               = Fbuffer_local_value (Qwindow_size_change_functions, buffer);
-
-             while (CONSP (locals))
-               {
-                 if (!EQ (XCAR (locals), Qt))
-                   safe_call1 (XCAR (locals), frame);
-                 locals = XCDR (locals);
-               }
-
-             buffers = Fcons (buffer, buffers);
-           }
+         struct window *w = XWINDOW (window);
+         Lisp_Object buffer = WINDOW_BUFFER (w);
+
+         /* Count this window even if it has been deleted while
+            running a hook.  */
+         number_of_windows += 1;
+
+         if (!WINDOW_LIVE_P (window))
+           continue;
+
+         /* A "buffer change" means either the window's buffer
+            changed or the window was not part of this frame the last
+            time window change functions were run for it.  */
+         window_buffer_change =
+           (frame_window_change
+            && (!EQ (buffer, w->old_buffer)
+                || w->change_stamp != f->change_stamp));
+         /* A "size change" means either a buffer change or that the
+            total or body size of the window has changed.
+
+            Note: A buffer change implies a size change because either
+            this window didn't show the buffer before or this window
+            didn't show the buffer the last time the window change
+            functions were run.  In either case, an application
+            tracing size changes in a buffer-locally fashion might
+            want to be informed about that change.  */
+         window_size_change =
+           (frame_window_change
+            && (window_buffer_change
+                || w->pixel_width != w->old_pixel_width
+                || w->pixel_height != w->old_pixel_height
+                || window_body_width (w, true) != w->old_body_pixel_width
+                || window_body_height (w, true) != w->old_body_pixel_height));
+
+         /* The following two are needed when running the default
+            values for this frame below.  */
+         frame_buffer_change = frame_buffer_change || window_buffer_change;
+         frame_size_change = frame_size_change || window_size_change;
+
+         if (window_buffer_change)
+           run_window_change_functions_1
+             (Qwindow_buffer_change_functions, buffer, window);
+
+         if (window_size_change && WINDOW_LIVE_P (window))
+           run_window_change_functions_1
+             (Qwindow_size_change_functions, buffer, window);
+
+         /* This window's selection has changed when it was
+            (de-)selected as its frame's or the globally selected
+            window.  */
+         if (((frame_selected_change
+               && (EQ (window, old_selected_window)
+                   || EQ (window, selected_window)))
+              || (frame_selected_window_change
+                  && (EQ (window, FRAME_OLD_SELECTED_WINDOW (f))
+                      || EQ (window, FRAME_SELECTED_WINDOW (f)))))
+             && WINDOW_LIVE_P (window))
+           run_window_change_functions_1
+             (Qwindow_selection_change_functions, buffer, window);
+
+         /* This window's state has changed when its buffer or size
+            changed or it was (de-)selected as its frame's or the
+            globally selected window.  */
+         if ((window_buffer_change
+              || window_size_change
+              || ((frame_selected_change
+                   && (EQ (window, old_selected_window)
+                       || EQ (window, selected_window)))
+                  || (frame_selected_window_change
+                      && (EQ (window, FRAME_OLD_SELECTED_WINDOW (f))
+                          || EQ (window, FRAME_SELECTED_WINDOW (f))))))
+             && WINDOW_LIVE_P (window))
+           run_window_change_functions_1
+             (Qwindow_state_change_functions, buffer, window);
        }
 
-      while (CONSP (globals))
+      /* When the number of windows on a frame has decreased, at least
+        one window of that frame was deleted.  In that case, we want
+        to run the default buffer and configuration change hooks.  The
+        default size change hook is not necessarily run in that case,
+        but usually will be unless the deletion was "compensated" by
+        a reduction of the frame size or an increase of a minibuffer
+        window size.  */
+      window_deleted = number_of_windows < f->number_of_windows;
+      /* A frame changed buffers when one of its windows has changed
+        its buffer or at least one window was deleted.  */
+      if ((frame_buffer_change || window_deleted) && FRAME_LIVE_P (f))
+       run_window_change_functions_1
+         (Qwindow_buffer_change_functions, Qnil, frame);
+
+      /* A size change occurred when at least one of the frame's
+        windows has changed size.  */
+      if (frame_size_change && FRAME_LIVE_P (f))
+       run_window_change_functions_1
+         (Qwindow_size_change_functions, Qnil, frame);
+
+      /* A frame has changed its window selection when its selected
+        window has changed or when it was (de-)selected.  */
+      if ((frame_selected_change || frame_selected_window_change)
+         && FRAME_LIVE_P (f))
+       run_window_change_functions_1
+         (Qwindow_selection_change_functions, Qnil, frame);
+
+      /* A frame has changed state when a size or buffer change
+        occurred, its selected window has changed, when it was
+        (de-)selected or its window state change flag was set.  */
+      if ((frame_selected_change || frame_selected_window_change
+          || frame_buffer_change || window_deleted
+          || frame_size_change || frame_window_state_change)
+         && FRAME_LIVE_P (f))
        {
-         if (!EQ (XCAR (globals), Qt))
-           safe_call1 (XCAR (globals), frame);
-         globals = XCDR (globals);
+         run_window_change_functions_1
+           (Qwindow_state_change_functions, Qnil, frame);
+         /* Make sure to run 'window-state-change-hook' later.  */
+         run_window_state_change_hook = true;
+         /*  Make sure to record changes for each live frame in
+            window_change_record later.  */
+         window_change_record_frames = true;
        }
 
-      window_set_before_size_change_sizes (r);
+      /* A frame's configuration changed when one of its windows has
+        changed buffer or size or at least one window was deleted.  */
+      if ((frame_size_change || window_deleted) && FRAME_LIVE_P (f))
+       /* This will run any buffer local window configuration change
+          hook as well.  */
+       run_window_configuration_change_hook (f);
+    }
 
-      if (FRAME_HAS_MINIBUF_P (f) && !FRAME_MINIBUF_ONLY_P (f))
-       /* Record size of FRAME's minibuffer window too.  */
-       window_set_before_size_change_sizes
-         (XWINDOW (FRAME_MINIBUF_WINDOW (f)));
+  /* Run 'window-state-change-hook' if at least one frame has changed
+     state.  */
+  if (run_window_state_change_hook && !NILP (Vwindow_state_change_hook))
+    safe_run_hooks (Qwindow_state_change_hook);
 
-      FRAME_WINDOW_CONFIGURATION_CHANGED (f) = false;
-    }
+  /* Record changes for all frames (if asked for), selected window and
+     frame.  */
+  unbind_to (count, Qnil);
 }
 
-
 /* Make WINDOW display BUFFER.  RUN_HOOKS_P means it's allowed
    to run hooks.  See make_frame for a case where it's not allowed.
    KEEP_MARGINS_P means that the current margins, fringes, and
@@ -3581,14 +3998,18 @@ set_window_buffer (Lisp_Object window, Lisp_Object 
buffer,
       apply_window_adjustment (w);
     }
 
-  if (run_hooks_p)
-    {
-      if (!NILP (Vwindow_scroll_functions))
-       run_hook_with_args_2 (Qwindow_scroll_functions, window,
-                             Fmarker_position (w->start));
-      if (!samebuf)
-       run_window_configuration_change_hook (XFRAME (WINDOW_FRAME (w)));
-    }
+  if (run_hooks_p && !NILP (Vwindow_scroll_functions))
+    run_hook_with_args_2 (Qwindow_scroll_functions, window,
+                         Fmarker_position (w->start));
+
+  /* Ensure that window change functions are run later if the buffer
+     differs and the window is neither a mini nor a pseudo window.
+
+     Note: Running window change functions for the minibuffer is noisy
+     and was generally suppressed in the past.  Is there any reason we
+     should run them?  */
+  if (!samebuf && !MINI_WINDOW_P (w) && !WINDOW_PSEUDO_P (w))
+    FRAME_WINDOW_CHANGE (XFRAME (w->frame)) = true;
 
   unbind_to (count, Qnil);
 }
@@ -3754,8 +4175,8 @@ temp_output_buffer_show (register Lisp_Object buf)
 static struct window *
 allocate_window (void)
 {
-  return ALLOCATE_ZEROED_PSEUDOVECTOR
-    (struct window, current_matrix, PVEC_WINDOW);
+  return ALLOCATE_ZEROED_PSEUDOVECTOR (struct window, mode_line_help_echo,
+                                      PVEC_WINDOW);
 }
 
 /* Make new window, have it replace WINDOW in window-tree, and make
@@ -3828,8 +4249,6 @@ make_window (void)
   w->phys_cursor_width = -1;
 #endif
   w->sequence_number = ++sequence_number;
-  w->pixel_width_before_size_change = 0;
-  w->pixel_height_before_size_change = 0;
   w->scroll_bar_width = -1;
   w->scroll_bar_height = -1;
   w->column_number_displayed = -1;
@@ -4095,6 +4514,9 @@ window_resize_apply (struct window *w, bool horflag)
   else
     /* Bug#15957.  */
     w->window_end_valid = false;
+
+  if (!WINDOW_PSEUDO_P (w))
+    FRAME_WINDOW_CHANGE (WINDOW_XFRAME (w)) = true;
 }
 
 
@@ -4261,7 +4683,7 @@ resize_frame_windows (struct frame *f, int size, bool 
horflag, bool pixelwise)
   int unit = horflag ? FRAME_COLUMN_WIDTH (f) : FRAME_LINE_HEIGHT (f);
 
   /* Don't let the size drop below one unit.  This is more comforting
-     when we are called from x_set_tool_bar_lines since the latter may
+     when we are called from *_set_tool_bar_lines since the latter may
      have implicitly given us a zero or negative height.  */
   if (pixelwise)
     {
@@ -4292,16 +4714,26 @@ resize_frame_windows (struct frame *f, int size, bool 
horflag, bool pixelwise)
     /* For a leaf root window just set the size.  */
     if (horflag)
       {
+       bool changed = r->pixel_width != new_pixel_size;
+
        r->total_cols = new_size;
        r->pixel_width = new_pixel_size;
+
+       if (changed && !WINDOW_PSEUDO_P (r))
+         FRAME_WINDOW_CHANGE (f) = true;
       }
     else
       {
+       bool changed = r->pixel_height != new_pixel_size;
+
        r->top_line = FRAME_TOP_MARGIN (f);
        r->pixel_top = FRAME_TOP_MARGIN_HEIGHT (f);
 
        r->total_lines = new_size;
        r->pixel_height = new_pixel_size;
+
+       if (changed && !WINDOW_PSEUDO_P (r))
+         FRAME_WINDOW_CHANGE (f) = true;
       }
   else
     {
@@ -4559,17 +4991,11 @@ set correctly.  See the code of `split-window' for how 
this is done.  */)
   block_input ();
   window_resize_apply (p, horflag);
   adjust_frame_glyphs (f);
-  /* Set buffer of NEW to buffer of reference window.  Don't run
-     any hooks.  */
-  set_window_buffer (new, r->contents, false, true);
+  /* Set buffer of NEW to buffer of reference window.  */
+  set_window_buffer (new, r->contents, true, true);
+  FRAME_WINDOW_CHANGE (f) = true;
   unblock_input ();
 
-  /* Maybe we should run the scroll functions in Elisp (which already
-     runs the configuration change hook).  */
-  if (! NILP (Vwindow_scroll_functions))
-    run_hook_with_args_2 (Qwindow_scroll_functions, new,
-                         Fmarker_position (n->start));
-  /* Return NEW.  */
   return new;
 }
 
@@ -4720,6 +5146,8 @@ Signal an error when WINDOW is the only window on its 
frame.  */)
        }
       else
        unblock_input ();
+
+      FRAME_WINDOW_CHANGE (f) = true;
     }
   else
     /* We failed: Relink WINDOW into window tree.  */
@@ -4745,118 +5173,111 @@ Signal an error when WINDOW is the only window on its 
frame.  */)
                        Resizing Mini-Windows
  ***********************************************************************/
 
-/* Grow mini-window W by DELTA lines, DELTA >= 0, or as much as we
-   can.  */
+/**
+ * resize_mini_window_apply:
+ *
+ * Assign new window sizes after resizing a mini window W by DELTA
+ * pixels.  No error checking performed.
+  */
+static void
+resize_mini_window_apply (struct window *w, int delta)
+{
+  struct frame *f = XFRAME (w->frame);
+  Lisp_Object root = FRAME_ROOT_WINDOW (f);
+  struct window *r = XWINDOW (root);
+
+  block_input ();
+  w->pixel_height = w->pixel_height + delta;
+  w->total_lines = w->pixel_height / FRAME_LINE_HEIGHT (f);
+
+  window_resize_apply (r, false);
+
+  w->pixel_top = r->pixel_top + r->pixel_height;
+  w->top_line = r->top_line + r->total_lines;
+
+  /* Enforce full redisplay of the frame.  */
+  /* FIXME: Shouldn't some of the caller do it?  */
+  fset_redisplay (f);
+  adjust_frame_glyphs (f);
+  unblock_input ();
+}
+
+/**
+ * grow_mini_window:
+ *
+ * Grow mini-window W by DELTA pixels.  If DELTA is negative, this may
+ * shrink the minibuffer window to the minimum height to display one
+ * line of text.
+ */
 void
-grow_mini_window (struct window *w, int delta, bool pixelwise)
+grow_mini_window (struct window *w, int delta)
 {
   struct frame *f = XFRAME (w->frame);
-  struct window *r;
-  Lisp_Object root, height;
-  int line_height, pixel_height;
+  int old_height = WINDOW_PIXEL_HEIGHT (w);
+  int min_height = FRAME_LINE_HEIGHT (f);
 
   eassert (MINI_WINDOW_P (w));
-  eassert (delta >= 0);
 
-  if (delta > 0)
-    {
-      root = FRAME_ROOT_WINDOW (f);
-      r = XWINDOW (root);
-      height = call3 (Qwindow__resize_root_window_vertically,
-                     root, make_fixnum (- delta), pixelwise ? Qt : Qnil);
-      if (FIXNUMP (height) && window_resize_check (r, false))
-       {
-         block_input ();
-         window_resize_apply (r, false);
+  if (old_height + delta < min_height)
+    /* Never shrink mini-window to less than its minimum
+       height.  */
+    delta = old_height > min_height ? min_height - old_height : 0;
 
-         if (pixelwise)
-           {
-             pixel_height = min (-XFIXNUM (height), INT_MAX - w->pixel_height);
-             line_height = pixel_height / FRAME_LINE_HEIGHT (f);
-           }
-         else
-           {
-             line_height = min (-XFIXNUM (height),
-                                ((INT_MAX - w->pixel_height)
-                                 / FRAME_LINE_HEIGHT (f)));
-             pixel_height = line_height * FRAME_LINE_HEIGHT (f);
-           }
+  if (delta != 0)
+    {
+      Lisp_Object root = FRAME_ROOT_WINDOW (f);
+      struct window *r = XWINDOW (root);
+      Lisp_Object grow;
 
-         /* Grow the mini-window.  */
-         w->pixel_top = r->pixel_top + r->pixel_height;
-         w->top_line = r->top_line + r->total_lines;
-         /* Make sure the mini-window has always at least one line.  */
-         w->pixel_height = max (w->pixel_height + pixel_height,
-                                FRAME_LINE_HEIGHT (f));
-         w->total_lines = max (w->total_lines + line_height, 1);
-
-         /* Enforce full redisplay of the frame.  */
-         /* FIXME: Shouldn't window--resize-root-window-vertically do it?  */
-         fset_redisplay (f);
-         adjust_frame_glyphs (f);
-         unblock_input ();
-       }
-      else
-       error ("Failed to grow minibuffer window");
+      FRAME_WINDOWS_FROZEN (f) = true;
+      grow = call3 (Qwindow__resize_root_window_vertically,
+                   root, make_fixnum (- delta), Qt);
 
+      if (FIXNUMP (grow) && window_resize_check (r, false))
+       resize_mini_window_apply (w, -XFIXNUM (grow));
     }
 }
 
-/* Shrink mini-window W to one line.  */
+/**
+ * shrink_mini_window:
+ *
+ * Shrink mini-window W to the minimum height needed to display one
+ * line of text.
+ */
 void
-shrink_mini_window (struct window *w, bool pixelwise)
+shrink_mini_window (struct window *w)
 {
   struct frame *f = XFRAME (w->frame);
-  struct window *r;
-  Lisp_Object root, delta;
-  EMACS_INT height, unit;
+  int delta = WINDOW_PIXEL_HEIGHT (w) - FRAME_LINE_HEIGHT (f);
 
   eassert (MINI_WINDOW_P (w));
 
-  height = pixelwise ? w->pixel_height : w->total_lines;
-  unit = pixelwise ? FRAME_LINE_HEIGHT (f) : 1;
-  if (height > unit)
+  if (delta > 0)
     {
-      root = FRAME_ROOT_WINDOW (f);
-      r = XWINDOW (root);
-      delta = call3 (Qwindow__resize_root_window_vertically,
-                    root, make_fixnum (height - unit),
-                    pixelwise ? Qt : Qnil);
-      if (FIXNUMP (delta) && window_resize_check (r, false))
-       {
-         block_input ();
-         window_resize_apply (r, false);
-
-         /* Shrink the mini-window.  */
-         w->top_line = r->top_line + r->total_lines;
-         w->total_lines = 1;
-         w->pixel_top = r->pixel_top + r->pixel_height;
-         w->pixel_height = FRAME_LINE_HEIGHT (f);
-         /* Enforce full redisplay of the frame.  */
-         /* FIXME: Shouldn't window--resize-root-window-vertically do it?  */
-         fset_redisplay (f);
-         adjust_frame_glyphs (f);
-         unblock_input ();
-       }
-      /* If the above failed for whatever strange reason we must make a
-        one window frame here.  The same routine will be needed when
-        shrinking the frame (and probably when making the initial
-        *scratch* window).  For the moment leave things as they are.  */
-      else
-       error ("Failed to shrink minibuffer window");
+      Lisp_Object root = FRAME_ROOT_WINDOW (f);
+      struct window *r = XWINDOW (root);
+      Lisp_Object grow;
+
+      FRAME_WINDOWS_FROZEN (f) = false;
+      grow = call3 (Qwindow__resize_root_window_vertically,
+                   root, make_fixnum (delta), Qt);
+
+      if (FIXNUMP (grow) && window_resize_check (r, false))
+       resize_mini_window_apply (w, -XFIXNUM (grow));
     }
 }
 
-DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal, 
Sresize_mini_window_internal, 1, 1, 0,
-       doc: /* Resize minibuffer window WINDOW.  */)
+DEFUN ("resize-mini-window-internal", Fresize_mini_window_internal,
+       Sresize_mini_window_internal, 1, 1, 0,
+       doc: /* Resize mini window WINDOW.  */)
      (Lisp_Object window)
 {
   struct window *w = XWINDOW (window);
   struct window *r;
   struct frame *f;
-  int height;
+  int old_height, delta;
 
-  CHECK_WINDOW (window);
+  CHECK_LIVE_WINDOW (window);
   f = XFRAME (w->frame);
 
   if (!EQ (FRAME_MINIBUF_WINDOW (XFRAME (w->frame)), window))
@@ -4865,26 +5286,18 @@ DEFUN ("resize-mini-window-internal", 
Fresize_mini_window_internal, Sresize_mini
     error ("Cannot resize a minibuffer-only frame");
 
   r = XWINDOW (FRAME_ROOT_WINDOW (f));
-  height = r->pixel_height + w->pixel_height;
+  old_height = r->pixel_height + w->pixel_height;
+  delta = XFIXNUM (w->new_pixel) - w->pixel_height;
   if (window_resize_check (r, false)
       && XFIXNUM (w->new_pixel) > 0
-      && height == XFIXNUM (r->new_pixel) + XFIXNUM (w->new_pixel))
+      && old_height == XFIXNUM (r->new_pixel) + XFIXNUM (w->new_pixel))
     {
-      block_input ();
-      window_resize_apply (r, false);
-
-      w->pixel_height = XFIXNAT (w->new_pixel);
-      w->total_lines = w->pixel_height / FRAME_LINE_HEIGHT (f);
-      w->pixel_top = r->pixel_top + r->pixel_height;
-      w->top_line = r->top_line + r->total_lines;
+      resize_mini_window_apply (w, delta);
 
-      fset_redisplay (f);
-      adjust_frame_glyphs (f);
-      unblock_input ();
       return Qt;
     }
   else
-    error ("Failed to resize minibuffer window");
+    error ("Cannot resize mini window");
 }
 
 /* Mark window cursors off for all windows in the window tree rooted
@@ -5056,6 +5469,11 @@ window_scroll_margin (struct window *window, enum 
margin_unit unit)
     return 0;
 }
 
+static int
+sanitize_next_screen_context_lines (void)
+{
+  return clip_to_bounds (0, next_screen_context_lines, 1000000);
+}
 
 /* Implementation of window_scroll that works based on pixel line
    heights.  See the comment of window_scroll for parameter
@@ -5126,9 +5544,11 @@ window_scroll_pixel_based (Lisp_Object window, int n, 
bool whole, bool noerror)
             height.  This is important to ensure we get back to the
             same position when scrolling up, then down.  */
          if (whole)
-           dy = max ((window_box_height (w) / dy
-                      - next_screen_context_lines) * dy,
-                     dy);
+           {
+             int ht = window_box_height (w);
+             int nscls = sanitize_next_screen_context_lines ();
+             dy = max (dy, (ht / dy - nscls) * dy);
+           }
          dy *= n;
 
          if (n < 0)
@@ -5209,13 +5629,14 @@ window_scroll_pixel_based (Lisp_Object window, int n, 
bool whole, bool noerror)
     {
       ptrdiff_t start_pos = IT_CHARPOS (it);
       int dy = frame_line_height;
+      int ht = window_box_height (w);
+      int nscls = sanitize_next_screen_context_lines ();
       /* In the below we divide the window box height by the frame's
         line height to make the result predictable when the window
         box is not an integral multiple of the line height.  This is
         important to ensure we get back to the same position when
         scrolling up, then down.  */
-      dy = max ((window_box_height (w) / dy - next_screen_context_lines) * dy,
-               dy) * n;
+      dy = n * max (dy, (ht / dy - nscls) * dy);
 
       /* Note that move_it_vertically always moves the iterator to the
          start of a line.  So, if the last line doesn't have a newline,
@@ -5513,7 +5934,10 @@ window_scroll_line_based (Lisp_Object window, int n, 
bool whole, bool noerror)
   /* If scrolling screen-fulls, compute the number of lines to
      scroll from the window's height.  */
   if (whole)
-    n *= max (1, ht - next_screen_context_lines);
+    {
+      int nscls = sanitize_next_screen_context_lines ();
+      n *= max (1, ht - nscls);
+    }
 
   if (!NILP (Vscroll_preserve_screen_position))
     {
@@ -5979,7 +6403,7 @@ and redisplay normally--don't erase and redraw the frame. 
 */)
          /* Invalidate pixel data calculated for all compositions.  */
          for (i = 0; i < n_compositions; i++)
            composition_table[i]->font = NULL;
-#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
          WINDOW_XFRAME (w)->minimize_tool_bar_window_p = 1;
 #endif
          Fredraw_frame (WINDOW_FRAME (w));
@@ -6291,7 +6715,8 @@ struct save_window_data
     Lisp_Object saved_windows;
 
     /* All fields above are traced by the GC.
-       From `frame-cols' down, the fields are ignored by the GC.  */
+       After saved_windows, the fields are ignored by the GC.  */
+
     /* We should be able to do without the following two.  */
     int frame_cols, frame_lines;
     /* These two should get eventually replaced by their pixel
@@ -6310,7 +6735,6 @@ struct saved_window
 
   Lisp_Object window, buffer, start, pointm, old_pointm;
   Lisp_Object pixel_left, pixel_top, pixel_height, pixel_width;
-  Lisp_Object pixel_height_before_size_change, pixel_width_before_size_change;
   Lisp_Object left_col, top_line, total_cols, total_lines;
   Lisp_Object normal_cols, normal_lines;
   Lisp_Object hscroll, min_hscroll, hscroll_whole, suspend_auto_hscroll;
@@ -6426,12 +6850,6 @@ the return value is nil.  Otherwise the value is t.  */)
       struct window *root_window;
       struct window **leaf_windows;
       ptrdiff_t i, k, n_leaf_windows;
-      /* Records whether a window has been added or removed wrt the
-        original configuration.  */
-      bool window_changed = false;
-      /* Records whether a window has changed its buffer wrt the
-        original configuration.  */
-      bool buffer_changed = false;
 
       /* Don't do this within the main loop below: This may call Lisp
         code and is thus potentially unsafe while input is blocked.  */
@@ -6441,11 +6859,6 @@ the return value is nil.  Otherwise the value is t.  */)
          window = p->window;
          w = XWINDOW (window);
 
-         if (NILP (w->contents))
-           /* A dead window that will be resurrected, the window
-              configuration will change.  */
-           window_changed = true;
-
          if (BUFFERP (w->contents)
              && !EQ (w->contents, p->buffer)
              && BUFFER_LIVE_P (XBUFFER (p->buffer)))
@@ -6454,8 +6867,8 @@ the return value is nil.  Otherwise the value is t.  */)
            call1 (Qrecord_window_buffer, window);
        }
 
-      /* Disallow x_set_window_size, temporarily.  */
-      f->can_x_set_window_size = false;
+      /* Disallow set_window_size_hook, temporarily.  */
+      f->can_set_window_size = false;
       /* The mouse highlighting code could get screwed up
         if it runs during this.  */
       block_input ();
@@ -6530,10 +6943,6 @@ the return value is nil.  Otherwise the value is t.  */)
          w->pixel_top = XFIXNAT (p->pixel_top);
          w->pixel_width = XFIXNAT (p->pixel_width);
          w->pixel_height = XFIXNAT (p->pixel_height);
-         w->pixel_width_before_size_change
-           = XFIXNAT (p->pixel_width_before_size_change);
-         w->pixel_height_before_size_change
-           = XFIXNAT (p->pixel_height_before_size_change);
          w->left_col = XFIXNAT (p->left_col);
          w->top_line = XFIXNAT (p->top_line);
          w->total_cols = XFIXNAT (p->total_cols);
@@ -6581,9 +6990,6 @@ the return value is nil.  Otherwise the value is t.  */)
          if (BUFFERP (p->buffer) && BUFFER_LIVE_P (XBUFFER (p->buffer)))
            /* If saved buffer is alive, install it.  */
            {
-             if (!EQ (w->contents, p->buffer))
-               /* Record buffer configuration change.  */
-               buffer_changed = true;
              wset_buffer (w, p->buffer);
              w->start_at_line_beg = !NILP (p->start_at_line_beg);
              set_marker_restricted (w->start, p->start, w->contents);
@@ -6617,8 +7023,6 @@ the return value is nil.  Otherwise the value is t.  */)
          else if (!NILP (w->start))
            /* Leaf window has no live buffer, get one.  */
            {
-             /* Record buffer configuration change.  */
-             buffer_changed = true;
              /* Get the buffer via other_buffer_safely in order to
                 avoid showing an unimportant buffer and, if necessary, to
                 recreate *scratch* in the course (part of Juanma's bs-show
@@ -6666,14 +7070,11 @@ the return value is nil.  Otherwise the value is t.  */)
       /* Now, free glyph matrices in windows that were not reused.  */
       for (i = 0; i < n_leaf_windows; i++)
        if (NILP (leaf_windows[i]->contents))
-         {
-           free_window_matrices (leaf_windows[i]);
-           window_changed = true;
-         }
+         free_window_matrices (leaf_windows[i]);
 
-      /* Allow x_set_window_size again and apply frame size changes if
-        needed.  */
-      f->can_x_set_window_size = true;
+      /* Allow set_window_size_hook again and apply frame size changes
+        if needed.  */
+      f->can_set_window_size = true;
       adjust_frame_size (f, -1, -1, 1, false, Qset_window_configuration);
 
       adjust_frame_glyphs (f);
@@ -6699,35 +7100,10 @@ the return value is nil.  Otherwise the value is t.  */)
         selected window.  */
       if (FRAME_LIVE_P (XFRAME (data->selected_frame)))
        do_switch_frame (data->selected_frame, 0, 0, Qnil);
-
-      if (window_changed)
-       /* At least one window has been added or removed.  Run
-          `window-configuration-change-hook' and make sure
-          `window-size-change-functions' get run later.
-
-          We have to do this in order to capture the following
-          scenario: Suppose our frame contains two live windows W1 and
-          W2 and 'set-window-configuration' replaces them by two
-          windows W3 and W4 that were dead the last time
-          run_window_size_change_functions was run.  If W3 and W4 have
-          the same values for their old and new pixel sizes but these
-          values differ from those of W1 and W2, the sizes of our
-          frame's two live windows changed but window_size_changed has
-          no means to detect that fact.
-
-          Obviously, this will get us false positives, for example,
-          when we restore the original configuration with W1 and W2
-          before run_window_size_change_functions gets called.  */
-       {
-         run_window_configuration_change_hook (f);
-         FRAME_WINDOW_CONFIGURATION_CHANGED (f) = true;
-       }
-      else if (buffer_changed)
-       /* At least one window has changed its buffer.  Run
-          `window-configuration-change-hook' only.  */
-       run_window_configuration_change_hook (f);
     }
 
+  FRAME_WINDOW_CHANGE (f) = true;
+
   if (!NILP (new_current_buffer))
     {
       Fset_buffer (new_current_buffer);
@@ -6889,10 +7265,6 @@ save_window_save (Lisp_Object window, struct Lisp_Vector 
*vector, ptrdiff_t i)
       p->pixel_top = make_fixnum (w->pixel_top);
       p->pixel_width = make_fixnum (w->pixel_width);
       p->pixel_height = make_fixnum (w->pixel_height);
-      p->pixel_width_before_size_change
-       = make_fixnum (w->pixel_width_before_size_change);
-      p->pixel_height_before_size_change
-       = make_fixnum (w->pixel_height_before_size_change);
       p->left_col = make_fixnum (w->left_col);
       p->top_line = make_fixnum (w->top_line);
       p->total_cols = make_fixnum (w->total_cols);
@@ -6965,6 +7337,10 @@ save_window_save (Lisp_Object window, struct Lisp_Vector 
*vector, ptrdiff_t i)
 
       if (BUFFERP (w->contents))
        {
+         bool window_point_insertion_type
+           = !NILP (buffer_local_value
+                      (Qwindow_point_insertion_type, w->contents));
+
          /* Save w's value of point in the window configuration.  If w
             is the selected window, then get the value of point from
             the buffer; pointm is garbage in the selected window.  */
@@ -6975,12 +7351,8 @@ save_window_save (Lisp_Object window, struct Lisp_Vector 
*vector, ptrdiff_t i)
          else
            p->pointm = Fcopy_marker (w->pointm, Qnil);
          p->old_pointm = Fcopy_marker (w->old_pointm, Qnil);
-         XMARKER (p->pointm)->insertion_type
-           = !NILP (buffer_local_value /* Don't signal error if void.  */
-                    (Qwindow_point_insertion_type, w->contents));
-         XMARKER (p->old_pointm)->insertion_type
-           = !NILP (buffer_local_value /* Don't signal error if void.  */
-                    (Qwindow_point_insertion_type, w->contents));
+         XMARKER (p->pointm)->insertion_type = window_point_insertion_type;
+         XMARKER (p->old_pointm)->insertion_type = window_point_insertion_type;
 
          p->start = Fcopy_marker (w->start, Qnil);
          p->start_at_line_beg = w->start_at_line_beg ? Qt : Qnil;
@@ -7017,15 +7389,11 @@ redirection (see `redirect-frame-focus').  The variable
 saved by this function.  */)
   (Lisp_Object frame)
 {
-  Lisp_Object tem;
-  ptrdiff_t i, n_windows;
-  struct save_window_data *data;
   struct frame *f = decode_live_frame (frame);
-
-  n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f)));
-  data = ALLOCATE_PSEUDOVECTOR (struct save_window_data, frame_cols,
-                              PVEC_WINDOW_CONFIGURATION);
-
+  ptrdiff_t n_windows = count_windows (XWINDOW (FRAME_ROOT_WINDOW (f)));
+  struct save_window_data *data
+    = ALLOCATE_PSEUDOVECTOR (struct save_window_data, saved_windows,
+                            PVEC_WINDOW_CONFIGURATION);
   data->frame_cols = FRAME_COLS (f);
   data->frame_lines = FRAME_LINES (f);
   data->frame_menu_bar_lines = FRAME_MENU_BAR_LINES (f);
@@ -7041,9 +7409,9 @@ saved by this function.  */)
   data->minibuf_selected_window = minibuf_level > 0 ? minibuf_selected_window 
: Qnil;
   data->root_window = FRAME_ROOT_WINDOW (f);
   data->focus_frame = FRAME_FOCUS_FRAME (f);
-  tem = make_uninit_vector (n_windows);
+  Lisp_Object tem = make_uninit_vector (n_windows);
   data->saved_windows = tem;
-  for (i = 0; i < n_windows; i++)
+  for (ptrdiff_t i = 0; i < n_windows; i++)
     ASET (tem, i, make_nil_vector (VECSIZE (struct saved_window)));
   save_window_save (FRAME_ROOT_WINDOW (f), XVECTOR (tem), 0);
   XSETWINDOW_CONFIGURATION (tem, data);
@@ -7115,7 +7483,9 @@ reserve for the left marginal area.  Optional third arg 
RIGHT-WIDTH
 does the same for the right marginal area.  A nil width parameter
 means no margin.
 
-Return t if any margin was actually changed and nil otherwise.  */)
+Leave margins unchanged if WINDOW is not large enough to accommodate
+margins of the desired width.  Return t if any margin was actually
+changed and nil otherwise.  */)
   (Lisp_Object window, Lisp_Object left_width, Lisp_Object right_width)
 {
   struct window *w = set_window_margins (decode_live_window (window),
@@ -7176,6 +7546,11 @@ set_window_fringes (struct window *w, Lisp_Object 
left_width,
       w->right_fringe_width = right;
       w->fringes_outside_margins = outside;
 
+      /* This is needed to trigger immediate redisplay of the window
+        when its fringes are changed, because fringes are redrawn
+        only if update_window is called, so we must trigger that even
+        if the window's glyph matrices did not change at all.  */
+      windows_or_buffers_changed = 35;
       return w;
     }
   else
@@ -7192,11 +7567,14 @@ the left fringe.  Optional third arg RIGHT-WIDTH 
specifies the right
 fringe width.  If a fringe width arg is nil, that means to use the
 frame's default fringe width.  Default fringe widths can be set with
 the command `set-fringe-style'.
+
 If optional fourth arg OUTSIDE-MARGINS is non-nil, draw the fringes
 outside of the display margins.  By default, fringes are drawn between
 display marginal areas and the text area.
 
-Return t if any fringe was actually changed and nil otherwise.  */)
+Leave fringes unchanged if WINDOW is not large enough to accommodate
+fringes of the desired width.  Return t if any fringe was actually
+changed and nil otherwise.  */)
   (Lisp_Object window, Lisp_Object left_width,
    Lisp_Object right_width, Lisp_Object outside_margins)
 {
@@ -7293,6 +7671,12 @@ set_window_scroll_bars (struct window *w, Lisp_Object 
width,
   wset_horizontal_scroll_bar_type (w, Qnil);
 #endif
 
+  /* This is needed to trigger immediate redisplay of the window when
+     scroll bars are changed, because scroll bars are redisplayed only
+     if more than a single window needs to be considered, see
+     redisplay_internal.  */
+  if (changed)
+    windows_or_buffers_changed = 31;
   return changed ? w : NULL;
 }
 
@@ -7315,6 +7699,8 @@ horizontal scroll bar: bottom, nil, or t where nil means 
to not display
 a horizontal scroll bar on WINDOW and t means to use WINDOW frame's
 horizontal scroll bar type.
 
+If WINDOW is not large enough to accommodate a scroll bar of the
+desired dimension, leave the corresponding scroll bar unchanged.
 Return t if scroll bars were actually changed and nil otherwise.  */)
   (Lisp_Object window, Lisp_Object width, Lisp_Object vertical_type,
    Lisp_Object height, Lisp_Object horizontal_type)
@@ -7565,14 +7951,63 @@ and scrolling positions.  */)
   return Qnil;
 }
 
+
+static void init_window_once_for_pdumper (void);
+
 void
 init_window_once (void)
 {
+  minibuf_window = Qnil;
+  staticpro (&minibuf_window);
+
+  selected_window = Qnil;
+  staticpro (&selected_window);
+
+  Vwindow_list = Qnil;
+  staticpro (&Vwindow_list);
+
+  minibuf_selected_window = Qnil;
+  staticpro (&minibuf_selected_window);
+
+  pdumper_do_now_and_after_load (init_window_once_for_pdumper);
+}
+
+static void init_window_once_for_pdumper (void)
+{
+  window_scroll_pixel_based_preserve_x = -1;
+  window_scroll_pixel_based_preserve_y = -1;
+  window_scroll_preserve_hpos = -1;
+  window_scroll_preserve_vpos = -1;
+  PDUMPER_IGNORE (sequence_number);
+
+  PDUMPER_RESET_LV (minibuf_window, Qnil);
+  PDUMPER_RESET_LV (selected_window, Qnil);
+  PDUMPER_RESET_LV (Vwindow_list, Qnil);
+  PDUMPER_RESET_LV (minibuf_selected_window, Qnil);
+
+  /* Hack: if mode_line_in_non_selected_windows is true (which it may
+     be, if we're restoring from a dump) the guts of
+     make_initial_frame will try to access selected_window, which is
+     invalid at this point, and lose.  For the purposes of creating
+     the initial frame and window, this variable must be false.  */
+  bool old_mode_line_in_non_selected_windows;
+
+  /* Snapshot dumped_with_pdumper to suppress compiler warning.  */
+  bool saved_dumped_with_pdumper = dumped_with_pdumper_p ();
+  if (saved_dumped_with_pdumper)
+    {
+      old_mode_line_in_non_selected_windows
+        = mode_line_in_non_selected_windows;
+      mode_line_in_non_selected_windows = false;
+    }
   struct frame *f = make_initial_frame ();
+  if (saved_dumped_with_pdumper)
+    mode_line_in_non_selected_windows =
+      old_mode_line_in_non_selected_windows;
   XSETFRAME (selected_frame, f);
-  Vterminal_frame = selected_frame;
+  old_selected_frame = Vterminal_frame = selected_frame;
   minibuf_window = f->minibuffer_window;
-  selected_window = f->selected_window;
+  old_selected_window = selected_window = f->selected_window;
 }
 
 void
@@ -7592,7 +8027,11 @@ syms_of_window (void)
   Fput (Qscroll_down, Qscroll_command, Qt);
 
   DEFSYM (Qwindow_configuration_change_hook, 
"window-configuration-change-hook");
+  DEFSYM (Qwindow_state_change_hook, "window-state-change-hook");
+  DEFSYM (Qwindow_state_change_functions, "window-state-change-functions");
   DEFSYM (Qwindow_size_change_functions, "window-size-change-functions");
+  DEFSYM (Qwindow_buffer_change_functions, "window-buffer-change-functions");
+  DEFSYM (Qwindow_selection_change_functions, 
"window-selection-change-functions");
   DEFSYM (Qwindowp, "windowp");
   DEFSYM (Qwindow_configuration_p, "window-configuration-p");
   DEFSYM (Qwindow_live_p, "window-live-p");
@@ -7602,6 +8041,7 @@ syms_of_window (void)
   DEFSYM (Qwindow__resize_root_window, "window--resize-root-window");
   DEFSYM (Qwindow__resize_root_window_vertically,
          "window--resize-root-window-vertically");
+  DEFSYM (Qwindow__resize_mini_frame, "window--resize-mini-frame");
   DEFSYM (Qwindow__sanitize_window_sizes, "window--sanitize-window-sizes");
   DEFSYM (Qwindow__pixel_to_total, "window--pixel-to-total");
   DEFSYM (Qsafe, "safe");
@@ -7619,16 +8059,6 @@ syms_of_window (void)
   DEFSYM (Qmode_line_format, "mode-line-format");
   DEFSYM (Qheader_line_format, "header-line-format");
 
-  staticpro (&Vwindow_list);
-
-  minibuf_selected_window = Qnil;
-  staticpro (&minibuf_selected_window);
-
-  window_scroll_pixel_based_preserve_x = -1;
-  window_scroll_pixel_based_preserve_y = -1;
-  window_scroll_preserve_hpos = -1;
-  window_scroll_preserve_vpos = -1;
-
   DEFVAR_LISP ("temp-buffer-show-function", Vtemp_buffer_show_function,
               doc: /* Non-nil means call as function to display a help buffer.
 The function is called with one argument, the buffer to be displayed.
@@ -7675,26 +8105,98 @@ on their symbols to be controlled by this variable.  
*/);
   DEFVAR_LISP ("window-point-insertion-type", Vwindow_point_insertion_type,
               doc: /* Type of marker to use for `window-point'.  */);
   Vwindow_point_insertion_type = Qnil;
-  DEFSYM (Qwindow_point_insertion_type, "window_point_insertion_type");
-
-  DEFVAR_LISP ("window-configuration-change-hook",
-              Vwindow_configuration_change_hook,
-              doc: /* Functions to call when window configuration changes.
-The buffer-local value is run once per window, with the relevant window
-selected; while the global value is run only once for the modified frame,
-with the relevant frame selected.  */);
-  Vwindow_configuration_change_hook = Qnil;
+  DEFSYM (Qwindow_point_insertion_type, "window-point-insertion-type");
+
+  DEFVAR_LISP ("window-buffer-change-functions", 
Vwindow_buffer_change_functions,
+              doc: /* Functions called during redisplay when window buffers 
have changed.
+The value should be a list of functions that take one argument.
+
+Functions specified buffer-locally are called for each window showing
+the corresponding buffer if and only if that window has been added or
+changed its buffer since the last redisplay.  In this case the window
+is passed as argument.
+
+Functions specified by the default value are called for each frame if
+at least one window on that frame has been added, deleted or changed
+its buffer since the last redisplay.  In this case the frame is passed
+as argument.  */);
+  Vwindow_buffer_change_functions = Qnil;
 
   DEFVAR_LISP ("window-size-change-functions", Vwindow_size_change_functions,
-    doc: /* Functions called during redisplay, if window sizes have changed.
+              doc: /* Functions called during redisplay when window sizes have 
changed.
 The value should be a list of functions that take one argument.
-During the first part of redisplay, for each frame, if any of its windows
-have changed size since the last redisplay, or have been split or deleted,
-all the functions in the list are called, with the frame as argument.
-If redisplay decides to resize the minibuffer window, it calls these
-functions on behalf of that as well.  */);
+
+Functions specified buffer-locally are called for each window showing
+the corresponding buffer if and only if that window has been added or
+changed its buffer or its total or body size since the last redisplay.
+In this case the window is passed as argument.
+
+Functions specified by the default value are called for each frame if
+at least one window on that frame has been added or changed its buffer
+or its total or body size since the last redisplay.  In this case the
+frame is passed as argument.  */);
   Vwindow_size_change_functions = Qnil;
 
+  DEFVAR_LISP ("window-selection-change-functions", 
Vwindow_selection_change_functions,
+              doc: /* Functions called during redisplay when the selected 
window has changed.
+The value should be a list of functions that take one argument.
+
+Functions specified buffer-locally are called for each window showing
+the corresponding buffer if and only if that window has been selected
+or deselected since the last redisplay.  In this case the window is
+passed as argument.
+
+Functions specified by the default value are called for each frame if
+the frame's selected window has changed since the last redisplay.  In
+this case the frame is passed as argument.  */);
+  Vwindow_selection_change_functions = Qnil;
+
+  DEFVAR_LISP ("window-state-change-functions", Vwindow_state_change_functions,
+              doc: /* Functions called during redisplay when the window state 
changed.
+The value should be a list of functions that take one argument.
+
+Functions specified buffer-locally are called for each window showing
+the corresponding buffer if and only if that window has been added,
+resized, changed its buffer or has been (de-)selected since the last
+redisplay.  In this case the window is passed as argument.
+
+Functions specified by the default value are called for each frame if
+at least one window on that frame has been added, deleted, changed its
+buffer or its total or body size or the frame has been (de-)selected,
+its selected window has changed or the window state change flag has
+been set for this frame since the last redisplay.  In this case the
+frame is passed as argument.  */);
+  Vwindow_state_change_functions = Qnil;
+
+  DEFVAR_LISP ("window-state-change-hook", Vwindow_state_change_hook,
+              doc: /* Functions called during redisplay when the window state 
changed.
+The value should be a list of functions that take no argument.
+
+This hook is called during redisplay when at least one window has been
+added, deleted, (de-)selected, changed its buffer or its total or body
+size or the window state change flag has been set for at least one
+frame.  This hook is called after all other window change functions
+have been run and should be used only if a function should react to
+changes that happened on at least two frames since last redisplay or
+the function intends to change the window configuration.  */);
+  Vwindow_state_change_hook = Qnil;
+
+  DEFVAR_LISP ("window-configuration-change-hook", 
Vwindow_configuration_change_hook,
+              doc: /* Functions called during redisplay when window 
configuration has changed.
+The value should be a list of functions that take no argument.
+
+Functions specified buffer-locally are called for each window showing
+the corresponding buffer if at least one window on that frame has been
+added, deleted or changed its buffer or its total or body size since
+the last redisplay.  Each call is performed with the window showing
+the buffer temporarily selected.
+
+Functions specified by the default value are called for each frame if
+at least one window on that frame has been added, deleted or changed
+its buffer or its total or body size since the last redisplay.  Each
+call is performed with the frame temporarily selected.  */);
+  Vwindow_configuration_change_hook = Qnil;
+
   DEFVAR_LISP ("recenter-redisplay", Vrecenter_redisplay,
               doc: /* Non-nil means `recenter' redraws entire frame.
 If this option is non-nil, then the `recenter' command with a nil
@@ -7806,6 +8308,7 @@ displayed after a scrolling operation to be somewhat 
inaccurate.  */);
   Vfast_but_imprecise_scrolling = false;
 
   defsubr (&Sselected_window);
+  defsubr (&Sold_selected_window);
   defsubr (&Sminibuffer_window);
   defsubr (&Swindow_minibuffer_p);
   defsubr (&Swindowp);
@@ -7815,10 +8318,12 @@ displayed after a scrolling operation to be somewhat 
inaccurate.  */);
   defsubr (&Sframe_root_window);
   defsubr (&Sframe_first_window);
   defsubr (&Sframe_selected_window);
+  defsubr (&Sframe_old_selected_window);
   defsubr (&Sset_frame_selected_window);
   defsubr (&Spos_visible_in_window_p);
   defsubr (&Swindow_line_height);
   defsubr (&Swindow_buffer);
+  defsubr (&Swindow_old_buffer);
   defsubr (&Swindow_parent);
   defsubr (&Swindow_top_child);
   defsubr (&Swindow_left_child);
@@ -7829,8 +8334,10 @@ displayed after a scrolling operation to be somewhat 
inaccurate.  */);
   defsubr (&Swindow_use_time);
   defsubr (&Swindow_pixel_width);
   defsubr (&Swindow_pixel_height);
-  defsubr (&Swindow_pixel_width_before_size_change);
-  defsubr (&Swindow_pixel_height_before_size_change);
+  defsubr (&Swindow_old_pixel_width);
+  defsubr (&Swindow_old_pixel_height);
+  defsubr (&Swindow_old_body_pixel_width);
+  defsubr (&Swindow_old_body_pixel_height);
   defsubr (&Swindow_total_width);
   defsubr (&Swindow_total_height);
   defsubr (&Swindow_normal_size);
diff --git a/src/window.h b/src/window.h
index b3673a0..fdef407 100644
--- a/src/window.h
+++ b/src/window.h
@@ -1,5 +1,5 @@
 /* Window definitions for GNU Emacs.
-   Copyright (C) 1985-1986, 1993, 1995, 1997-2018 Free Software
+   Copyright (C) 1985-1986, 1993, 1995, 1997-2019 Free Software
    Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -24,57 +24,69 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 
 INLINE_HEADER_BEGIN
 
-/* Windows are allocated as if they were vectors, but then the
-Lisp data type is changed to Lisp_Window.  They are garbage
-collected along with the vectors.
+/* Windows are allocated as if they were vectors, but then the Lisp
+data type is changed to Lisp_Window.  They are garbage collected along
+with the vectors.
 
 All windows in use are arranged into a tree, with pointers up and down.
 
-Windows that are leaves of the tree are actually displayed
-and show the contents of buffers.  Windows that are not leaves
-are used for representing the way groups of leaf windows are
-arranged on the frame.  Leaf windows never become non-leaves.
-They are deleted only by calling delete-window on them (but
-this can be done implicitly).  Combination windows can be created
-and deleted at any time.
-
-A leaf window has a buffer stored in contents field and markers in its start
-and pointm fields.  Non-leaf windows have nil in the latter two fields.
-
-Non-leaf windows are either vertical or horizontal combinations.
-
-A vertical combination window has children that are arranged on the frame
-one above the next.  Its contents field points to the uppermost child.
-The parent field of each of the children points to the vertical
-combination window.  The next field of each child points to the
-child below it, or is nil for the lowest child.  The prev field
-of each child points to the child above it, or is nil for the
-highest child.
-
-A horizontal combination window has children that are side by side.
-Its contents field points to the leftmost child.  In each child
-the next field points to the child to the right and the prev field
-points to the child to the left.
-
-The children of a vertical combination window may be leaf windows
-or horizontal combination windows.  The children of a horizontal
-combination window may be leaf windows or vertical combination windows.
-
-At the top of the tree are two windows which have nil as parent.
-The second of these is minibuf_window.  The first one manages all
-the frame area that is not minibuffer, and is called the root window.
-Different windows can be the root at different times;
-initially the root window is a leaf window, but if more windows
-are created then that leaf window ceases to be root and a newly
-made combination window becomes root instead.
-
-In any case, on screens which have an ordinary window and a
-minibuffer, prev of the minibuf window is the root window and next of
-the root window is the minibuf window.  On minibufferless screens or
-minibuffer-only screens, the root window and the minibuffer window are
-one and the same, so its prev and next members are nil.
-
-A dead window has its contents field set to nil.  */
+Windows that are leaves of the tree are actually displayed and show
+the contents of buffers.  Windows that are not leaves are used for
+representing the way groups of leaf windows are arranged on the frame.
+Leaf windows never become non-leaves.  They are deleted only by
+calling `delete-window' on them (but this can be done implicitly).
+Non-leaf windows never become leaf windows and can be created and
+deleted at any time by the window management code.  Non-leaf windows
+can be seen but not directly manipulated by Lisp functions.
+
+A leaf window has a buffer stored in its contents field and markers in
+its 'start' and 'pointm' fields.  Non-leaf windows have nil in the
+latter two fields.  Non-leaf windows are either vertical or horizontal
+combinations.
+
+A vertical combination window has children that are arranged on the
+frame one above the next.  Its 'contents' field points to the
+uppermost child.  The 'parent' field of each of the children points to
+the vertical combination window.  The 'next' field of each child
+points to the child below it, or is nil for the lowest child.  The
+'prev' field of each child points to the child above it, or is nil for
+the highest child.
+
+A horizontal combination window has children that are arranged side by
+side.  Its 'contents' field points to the leftmost child.  In each
+child the 'next' field points to the child to the right and the 'prev'
+field points to the child to the left.
+
+On each frame there are at least one and at most two windows which
+have nil as parent.  The second of these, if present, is the frame's
+minibuffer window and shows the minibuffer or the echo area.  The
+first one manages the remaining frame area and is called the frame's
+root window.  Different windows can be the root at different times;
+initially the root window is a leaf window, but if more windows are
+created, then that leaf window ceases to be root and a newly made
+combination window becomes the root instead.
+
+On frames which have an ordinary window and a minibuffer window,
+'prev' of the minibuffer window is the root window and 'next' of the
+root window is the minibuffer window.  On minibuffer-less frames there
+is only a root window and 'next' of the root window is nil.  On
+minibuffer-only frames, the root window and the minibuffer window are
+one and the same, so its 'prev' and 'next' members are nil.  In any
+case, 'prev' of a root window and 'next' of a minibuffer window are
+always nil.
+
+In Lisp parlance, leaf windows are called "live windows" and non-leaf
+windows are called "internal windows".  Together, live and internal
+windows form the set of "valid windows".  A window that has been
+deleted is considered "dead" regardless of whether it formerly was a
+leaf or a non-leaf window.  A dead window has its 'contents' field set
+to nil.
+
+Frames may also contain pseudo windows, windows that are not exposed
+directly to Lisp code.  Pseudo windows are currently either used to
+display the menu bar or the tool bar (when Emacs uses toolkits that
+don't display their own menu bar and tool bar) or a tooltip in a
+tooltip frame (when tooltips are not display by the toolkit).  */
 
 struct cursor_pos
 {
@@ -95,31 +107,46 @@ struct window
 
     /* Following (to right or down) and preceding (to left or up)
        child at same level of tree.  Whether this is left/right or
-       up/down is determined by the 'horizontal' flag, see below.
-       A minibuffer window has the frame's root window pointed by 'prev'.  */
+       up/down is determined by the parent window's 'horizontal' flag,
+       see below.  On a frame that is neither a minibuffer-only nor a
+       minibuffer-less frame, 'next' of the root window points to the
+       frame's minibuffer window and 'prev' of the minibuffer window
+       points to the frame's root window.  In all other cases, 'next'
+       of the root window and 'prev' of the minibuffer window, if
+       present, are nil.  'prev' of the root window and 'next' of the
+       minibuffer window are always nil.  */
     Lisp_Object next;
     Lisp_Object prev;
 
-    /* The window this one is a child of.  For a minibuffer window: nil.  */
+    /* The window this one is a child of.  For the root and a
+       minibuffer window this is always nil.  */
     Lisp_Object parent;
 
-    /* The normal size of the window.  These are fractions, but we do
-       not use C doubles to avoid creating new Lisp_Float objects while
-       interfacing Lisp in Fwindow_normal_size.  */
+    /* The "normal" size of the window.  These are fractions, but we
+       do not use C doubles to avoid creating new Lisp_Float objects
+       while interfacing Lisp in Fwindow_normal_size.  */
     Lisp_Object normal_lines;
     Lisp_Object normal_cols;
 
-    /* New sizes of the window.  Note that Lisp code may set new_normal
-       to something beyond an integer, so C int can't be used here.  */
+    /* The new sizes of the window as proposed by the window resizing
+       functions.  Note that Lisp code may set new_normal to something
+       beyond an integer, so C int can't be used here.  */
     Lisp_Object new_total;
     Lisp_Object new_normal;
     Lisp_Object new_pixel;
 
-    /* For a leaf window: a buffer; for an internal window: a window;
-       for a pseudo-window (such as menu bar or tool bar): nil.  It is
-       a buffer for a minibuffer window as well.  */
+    /* For a leaf window or a tooltip window this is the buffer shown
+       in the window; for a combination window this is the first of
+       its child windows; for a pseudo window showing the menu bar or
+       tool bar this is nil.  It is a buffer for a minibuffer window
+       as well.  */
     Lisp_Object contents;
 
+    /* The old buffer of this window, set to this window's buffer by
+       run_window_change_functions every time it sees this window.
+       Unused for internal windows.  */
+    Lisp_Object old_buffer;
+
     /* A marker pointing to where in the text to start displaying.
        BIDI Note: This is the _logical-order_ start, i.e. the smallest
        buffer position visible in the window, not necessarily the
@@ -185,9 +212,8 @@ struct window
     /* The help echo text for this window.  Qnil if there's none.  */
     Lisp_Object mode_line_help_echo;
 
-    /* No Lisp data may follow below this point without changing
-       mark_object in alloc.c.  The member current_matrix must be the
-       first non-Lisp member.  */
+    /* No Lisp data may follow this point; mode_line_help_echo must be
+       the last Lisp member.  */
 
     /* Glyph matrices.  */
     struct glyph_matrix *current_matrix;
@@ -195,7 +221,7 @@ struct window
 
     /* The two Lisp_Object fields below are marked in a special way,
        which is why they're placed after `current_matrix'.  */
-    /* Alist of <buffer, window-start, window-point> triples listing
+    /* A list of <buffer, window-start, window-point> triples listing
        buffers previously shown in this window.  */
     Lisp_Object prev_buffers;
     /* List of buffers re-shown in this window.  */
@@ -207,6 +233,14 @@ struct window
     /* Unique number of window assigned when it was created.  */
     EMACS_INT sequence_number;
 
+    /* The change stamp of this window.  Set to 0 when the window is
+       created, it is set to its frame's change stamp every time
+       run_window_change_functions is run on that frame with this
+       window live.  It is left alone when the window exists only
+       within a window configuration.  Not useful for internal
+       windows.  */
+    int change_stamp;
+
     /* The upper left corner pixel coordinates of this window, as
        integers relative to upper left corner of frame = 0, 0.  */
     int pixel_left;
@@ -221,10 +255,13 @@ struct window
     int pixel_width;
     int pixel_height;
 
-    /* The pixel sizes of the window at the last time
-       `window-size-change-functions' was run.  */
-    int pixel_width_before_size_change;
-    int pixel_height_before_size_change;
+    /* The pixel and pixel body sizes of the window at the last time
+       run_window_change_functions was run with this window live.  Not
+       useful for internal windows.  */
+    int old_pixel_width;
+    int old_pixel_height;
+    int old_body_pixel_width;
+    int old_body_pixel_height;
 
     /* The size of the window.  */
     int total_cols;
@@ -243,11 +280,11 @@ struct window
 
     /* Displayed buffer's text modification events counter as of last time
        display completed.  */
-    EMACS_INT last_modified;
+    modiff_count last_modified;
 
     /* Displayed buffer's overlays modification events counter as of last
        complete update.  */
-    EMACS_INT last_overlay_modified;
+    modiff_count last_overlay_modified;
 
     /* Value of point at that time.  Since this is a position in a buffer,
        it should be positive.  */
@@ -701,7 +738,7 @@ wset_next_buffers (struct window *w, Lisp_Object val)
 #endif
 
 /* True if W is a tool bar window.  */
-#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
 #define WINDOW_TOOL_BAR_P(W) \
   (WINDOWP (WINDOW_XFRAME (W)->tool_bar_window) \
    && (W) == XWINDOW (WINDOW_XFRAME (W)->tool_bar_window))
@@ -1025,11 +1062,11 @@ extern Lisp_Object window_from_coordinates (struct 
frame *, int, int,
 extern void resize_frame_windows (struct frame *, int, bool, bool);
 extern void restore_window_configuration (Lisp_Object);
 extern void delete_all_child_windows (Lisp_Object);
-extern void grow_mini_window (struct window *, int, bool);
-extern void shrink_mini_window (struct window *, bool);
+extern void grow_mini_window (struct window *, int);
+extern void shrink_mini_window (struct window *);
 extern int window_relative_x_coord (struct window *, enum window_part, int);
 
-void run_window_size_change_functions (Lisp_Object);
+void run_window_change_functions (void);
 
 /* Make WINDOW display BUFFER.  RUN_HOOKS_P means it's allowed
    to run hooks.  See make_frame for a case where it's not allowed.  */
diff --git a/src/xdisp.c b/src/xdisp.c
index 665ab2e..c677831 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -1,6 +1,6 @@
 /* Display generation from window structure and buffer text.
 
-Copyright (C) 1985-1988, 1993-1995, 1997-2018 Free Software Foundation,
+Copyright (C) 1985-1988, 1993-1995, 1997-2019 Free Software Foundation,
 Inc.
 
 This file is part of GNU Emacs.
@@ -336,8 +336,8 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include TERM_HEADER
 #endif /* HAVE_WINDOW_SYSTEM */
 
-#ifndef FRAME_X_OUTPUT
-#define FRAME_X_OUTPUT(f) ((f)->output_data.x)
+#ifndef FRAME_OUTPUT_DATA
+#define FRAME_OUTPUT_DATA(f) (NULL)
 #endif
 
 #define DISP_INFINITY 10000000
@@ -491,7 +491,7 @@ int windows_or_buffers_changed;
 
    Since the frame title uses the same %-constructs as the mode line
    (except %c, %C, and %l), if this variable is non-zero, we also consider
-   redisplaying the title of each frame, see x_consider_frame_title.
+   redisplaying the title of each frame, see gui_consider_frame_title.
 
    The `redisplay' bits are the same as those used for
    windows_or_buffers_changed, and setting windows_or_buffers_changed also
@@ -900,7 +900,7 @@ static int underlying_face_id (struct it *);
 #ifdef HAVE_WINDOW_SYSTEM
 
 static void update_tool_bar (struct frame *, bool);
-static void x_draw_bottom_divider (struct window *w);
+static void gui_draw_bottom_divider (struct window *w);
 static void notice_overwritten_cursor (struct window *,
                                        enum glyph_row_area,
                                        int, int, int, int);
@@ -1623,6 +1623,12 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int 
*x, int *y,
                      set_iterator_to_next (&it3, false);
                    }
                  top_x = it3.current_x - it3.pixel_width;
+                 /* Account for line-number display, if IT3 still
+                    didn't.  This can happen if START - 1 is the
+                    first character on its display line.  */
+                 if (!it3.line_number_produced_p
+                     && it.line_number_produced_p)
+                   top_x += it.lnum_pixel_width;
                  /* Normally, we would exit the above loop because we
                     found the display element whose character
                     position is CHARPOS.  For the contingency that we
@@ -2133,7 +2139,7 @@ get_glyph_string_clip_rects (struct glyph_string *s, 
NativeRectangle *rects, int
          rc.width = s->w->phys_cursor_width;
          rc.height = s->w->phys_cursor_height;
 
-         x_intersect_rectangles (&r_save, &rc, &r);
+         gui_intersect_rectangles (&r_save, &rc, &r);
        }
     }
   else
@@ -2194,7 +2200,7 @@ get_glyph_string_clip_rects (struct glyph_string *s, 
NativeRectangle *rects, int
     {
       XRectangle r_save = r;
 
-      if (! x_intersect_rectangles (&r_save, s->row->clip, &r))
+      if (! gui_intersect_rectangles (&r_save, s->row->clip, &r))
        r.width = 0;
     }
 
@@ -2786,6 +2792,7 @@ init_iterator (struct it *it, struct window *w,
               struct glyph_row *row, enum face_id base_face_id)
 {
   enum face_id remapped_base_face_id = base_face_id;
+  int body_width = 0, body_height = 0;
 
   /* Some precondition checks.  */
   eassert (w != NULL && it != NULL);
@@ -2962,7 +2969,7 @@ init_iterator (struct it *it, struct window *w,
     {
       /* Mode lines, menu bar in terminal frames.  */
       it->first_visible_x = 0;
-      it->last_visible_x = WINDOW_PIXEL_WIDTH (w);
+      it->last_visible_x = body_width = WINDOW_PIXEL_WIDTH (w);
     }
   else
     {
@@ -2982,8 +2989,12 @@ init_iterator (struct it *it, struct window *w,
       else
        it->first_visible_x =
          window_hscroll_limited (w, it->f) * FRAME_COLUMN_WIDTH (it->f);
-      it->last_visible_x = (it->first_visible_x
-                           + window_box_width (w, TEXT_AREA));
+
+      body_width = window_box_width (w, TEXT_AREA);
+      if (!w->pseudo_window_p && !MINI_WINDOW_P (w)
+         && body_width != w->old_body_pixel_width)
+       FRAME_WINDOW_CHANGE (it->f) = true;
+      it->last_visible_x = it->first_visible_x + body_width;
 
       /* If we truncate lines, leave room for the truncation glyph(s) at
         the right margin.  Otherwise, leave room for the continuation
@@ -2997,7 +3008,8 @@ init_iterator (struct it *it, struct window *w,
        }
 
       it->header_line_p = window_wants_header_line (w);
-      it->current_y = WINDOW_HEADER_LINE_HEIGHT (w) + w->vscroll;
+      body_height = WINDOW_HEADER_LINE_HEIGHT (w);
+      it->current_y =  body_height + w->vscroll;
     }
 
   /* Leave room for a border glyph.  */
@@ -3006,6 +3018,10 @@ init_iterator (struct it *it, struct window *w,
     it->last_visible_x -= 1;
 
   it->last_visible_y = window_text_bottom_y (w);
+  body_height += it->last_visible_y;
+  if (!w->pseudo_window_p && !MINI_WINDOW_P (w)
+      && body_height != w->old_body_pixel_height)
+    FRAME_WINDOW_CHANGE (it->f) = true;
 
   /* For mode lines and alike, arrange for the first glyph having a
      left box line if the face specifies a box.  */
@@ -3751,7 +3767,7 @@ compute_display_string_pos (struct text_pos *position,
          || !EQ (Fget_char_property (make_fixnum (charpos - 1), Qdisplay,
                                      object),
                  spec))
-      && (rv = handle_display_spec (NULL, spec, object, Qnil, &tpos, bufpos,
+      && (rv = handle_display_spec (NULL, spec, object1, Qnil, &tpos, bufpos,
                                    frame_window_p)))
     {
       if (rv == 2)
@@ -3778,7 +3794,7 @@ compute_display_string_pos (struct text_pos *position,
     if (!STRINGP (object))
       bufpos = CHARPOS (tpos);
   } while (NILP (spec)
-          || !(rv = handle_display_spec (NULL, spec, object, Qnil, &tpos,
+          || !(rv = handle_display_spec (NULL, spec, object1, Qnil, &tpos,
                                          bufpos, frame_window_p)));
   if (rv == 2)
     *disp_prop = 2;
@@ -6917,7 +6933,7 @@ static next_element_function const 
get_next_element[NUM_IT_METHODS] =
    method symbol.  By side-effect, update it->what and
    it->glyphless_method.  This function is called from
    get_next_display_element for each character element, and from
-   x_produce_glyphs when no suitable font was found.  */
+   gui_produce_glyphs when no suitable font was found.  */
 
 Lisp_Object
 lookup_glyphless_char_display (int c, struct it *it)
@@ -9615,7 +9631,7 @@ move_it_to (struct it *it, ptrdiff_t to_charpos, int 
to_x, int to_y, int to_vpos
                      /* When display_line produces a continued line
                         that ends in a TAB, it skips a tab stop that
                         is closer than the font's space character
-                        width (see x_produce_glyphs where it produces
+                        width (see gui_produce_glyphs where it produces
                         the stretch glyph which represents a TAB).
                         We need to reproduce the same logic here.  */
                      eassert (face_font);
@@ -10559,7 +10575,7 @@ message_log_check_duplicate (ptrdiff_t prev_bol_byte, 
ptrdiff_t this_bol_byte)
 
 
 /* Display an echo area message M with a specified length of NBYTES
-   bytes.  The string may include null characters.  If M is not a
+   bytes.  The string may include NUL characters.  If M is not a
    string, clear out any existing message, and let the mini-buffer
    text show through.
 
@@ -10663,7 +10679,7 @@ message3_nolog (Lisp_Object m)
 }
 
 
-/* Display a null-terminated echo area message M.  If M is 0, clear
+/* Display a NUL-terminated echo area message M.  If M is 0, clear
    out any existing message, and let the mini-buffer text show through.
 
    The buffer M must continue to exist until after the echo area gets
@@ -11026,15 +11042,15 @@ unwind_with_echo_area_buffer (Lisp_Object vector)
       buffer = AREF (vector, 4);
 
       wset_buffer (w, buffer);
-      set_marker_both (w->pointm, buffer,
-                      XFIXNAT (AREF (vector, 5)),
-                      XFIXNAT (AREF (vector, 6)));
-      set_marker_both (w->old_pointm, buffer,
-                      XFIXNAT (AREF (vector, 7)),
-                      XFIXNAT (AREF (vector, 8)));
-      set_marker_both (w->start, buffer,
-                      XFIXNAT (AREF (vector, 9)),
-                      XFIXNAT (AREF (vector, 10)));
+      set_marker_restricted_both (w->pointm, buffer,
+                                 XFIXNAT (AREF (vector, 5)),
+                                 XFIXNAT (AREF (vector, 6)));
+      set_marker_restricted_both (w->old_pointm, buffer,
+                                 XFIXNAT (AREF (vector, 7)),
+                                 XFIXNAT (AREF (vector, 8)));
+      set_marker_restricted_both (w->start, buffer,
+                                 XFIXNAT (AREF (vector, 9)),
+                                 XFIXNAT (AREF (vector, 10)));
     }
 
   Vwith_echo_area_save_vector = vector;
@@ -11250,15 +11266,10 @@ bool
 resize_mini_window (struct window *w, bool exact_p)
 {
   struct frame *f = XFRAME (w->frame);
-  bool window_height_changed_p = false;
+  int old_height = WINDOW_PIXEL_HEIGHT (w);
 
   eassert (MINI_WINDOW_P (w));
 
-  /* By default, start display at the beginning.  */
-  set_marker_both (w->start, w->contents,
-                  BUF_BEGV (XBUFFER (w->contents)),
-                  BUF_BEGV_BYTE (XBUFFER (w->contents)));
-
   /* Don't resize windows while redisplaying a window; it would
      confuse redisplay functions when the size of the window they are
      displaying changes from under them.  Such a resizing can happen,
@@ -11269,19 +11280,30 @@ resize_mini_window (struct window *w, bool exact_p)
     return false;
 
   /* Nil means don't try to resize.  */
-  if (NILP (Vresize_mini_windows)
-      || (FRAME_X_P (f) && FRAME_X_OUTPUT (f) == NULL))
+  if ((NILP (Vresize_mini_windows)
+       && (NILP (resize_mini_frames) || !FRAME_MINIBUF_ONLY_P (f)))
+      || (FRAME_X_P (f) && FRAME_OUTPUT_DATA (f) == NULL))
     return false;
 
-  if (!FRAME_MINIBUF_ONLY_P (f))
+  /* By default, start display at the beginning.  */
+  set_marker_both (w->start, w->contents,
+                  BUF_BEGV (XBUFFER (w->contents)),
+                  BUF_BEGV_BYTE (XBUFFER (w->contents)));
+
+  if (FRAME_MINIBUF_ONLY_P (f))
+    {
+      if (!NILP (resize_mini_frames))
+       safe_call1 (Qwindow__resize_mini_frame, WINDOW_FRAME (w));
+    }
+  else
     {
       struct it it;
-      int total_height = (WINDOW_PIXEL_HEIGHT (XWINDOW (FRAME_ROOT_WINDOW (f)))
-                         + WINDOW_PIXEL_HEIGHT (w));
+      int old_height = WINDOW_PIXEL_HEIGHT (w);
       int unit = FRAME_LINE_HEIGHT (f);
       int height, max_height;
       struct text_pos start;
       struct buffer *old_current_buffer = NULL;
+      int windows_height = FRAME_WINDOWS_HEIGHT (f);
 
       if (current_buffer != XBUFFER (w->contents))
        {
@@ -11293,14 +11315,14 @@ resize_mini_window (struct window *w, bool exact_p)
 
       /* Compute the max. number of lines specified by the user.  */
       if (FLOATP (Vmax_mini_window_height))
-       max_height = XFLOAT_DATA (Vmax_mini_window_height) * total_height;
+       max_height = XFLOAT_DATA (Vmax_mini_window_height) * windows_height;
       else if (FIXNUMP (Vmax_mini_window_height))
        max_height = XFIXNUM (Vmax_mini_window_height) * unit;
       else
-       max_height = total_height / 4;
+       max_height = windows_height / 4;
 
       /* Correct that max. height if it's bogus.  */
-      max_height = clip_to_bounds (unit, max_height, total_height);
+      max_height = clip_to_bounds (unit, max_height, windows_height);
 
       /* Find out the height of the text in the window.  */
       if (it.line_wrap == TRUNCATE)
@@ -11326,63 +11348,27 @@ resize_mini_window (struct window *w, bool exact_p)
        }
       else
        SET_TEXT_POS (start, BEGV, BEGV_BYTE);
+
       SET_MARKER_FROM_TEXT_POS (w->start, start);
 
       if (EQ (Vresize_mini_windows, Qgrow_only))
        {
          /* Let it grow only, until we display an empty message, in which
             case the window shrinks again.  */
-         if (height > WINDOW_PIXEL_HEIGHT (w))
-           {
-             int old_height = WINDOW_PIXEL_HEIGHT (w);
-
-             FRAME_WINDOWS_FROZEN (f) = true;
-             grow_mini_window (w, height - WINDOW_PIXEL_HEIGHT (w), true);
-             window_height_changed_p = WINDOW_PIXEL_HEIGHT (w) != old_height;
-           }
-         else if (height < WINDOW_PIXEL_HEIGHT (w)
-                  && (exact_p || BEGV == ZV))
-           {
-             int old_height = WINDOW_PIXEL_HEIGHT (w);
-
-             FRAME_WINDOWS_FROZEN (f) = false;
-             shrink_mini_window (w, true);
-             window_height_changed_p = WINDOW_PIXEL_HEIGHT (w) != old_height;
-           }
-       }
-      else
-       {
-         /* Always resize to exact size needed.  */
-         if (height > WINDOW_PIXEL_HEIGHT (w))
-           {
-             int old_height = WINDOW_PIXEL_HEIGHT (w);
-
-             FRAME_WINDOWS_FROZEN (f) = true;
-             grow_mini_window (w, height - WINDOW_PIXEL_HEIGHT (w), true);
-             window_height_changed_p = WINDOW_PIXEL_HEIGHT (w) != old_height;
-           }
-         else if (height < WINDOW_PIXEL_HEIGHT (w))
-           {
-             int old_height = WINDOW_PIXEL_HEIGHT (w);
-
-             FRAME_WINDOWS_FROZEN (f) = false;
-             shrink_mini_window (w, true);
-
-             if (height)
-               {
-                 FRAME_WINDOWS_FROZEN (f) = true;
-                 grow_mini_window (w, height - WINDOW_PIXEL_HEIGHT (w), true);
-               }
-
-             window_height_changed_p = WINDOW_PIXEL_HEIGHT (w) != old_height;
-           }
+         if (height > old_height)
+           grow_mini_window (w, height - old_height);
+         else if (height < old_height && (exact_p || BEGV == ZV))
+           shrink_mini_window (w);
        }
+      else if (height != old_height)
+       /* Always resize to exact size needed.  */
+       grow_mini_window (w, height - old_height);
 
       if (old_current_buffer)
        set_buffer_internal (old_current_buffer);
     }
 
-  return window_height_changed_p;
+  return WINDOW_PIXEL_HEIGHT (w) != old_height;
 }
 
 
@@ -11613,10 +11599,11 @@ clear_garbaged_frames (void)
              else
                clear_current_matrices (f);
 
-#if defined (HAVE_WINDOW_SYSTEM) && !defined (HAVE_NS)
-             x_clear_under_internal_border (f);
-#endif /* HAVE_WINDOW_SYSTEM && !HAVE_NS */
-
+#ifdef HAVE_WINDOW_SYSTEM
+              if (FRAME_WINDOW_P (f)
+                  && FRAME_RIF (f)->clear_under_internal_border)
+                FRAME_RIF (f)->clear_under_internal_border (f);
+#endif
              fset_redisplay (f);
              f->garbaged = false;
              f->resized_p = false;
@@ -11685,10 +11672,11 @@ echo_area_display (bool update_frame_p)
            {
              n = redisplay_mode_lines (FRAME_ROOT_WINDOW (f), false);
 
-#if defined (HAVE_WINDOW_SYSTEM) && !defined (HAVE_NS)
-             x_clear_under_internal_border (f);
-#endif /* HAVE_WINDOW_SYSTEM && !HAVE_NS */
-
+#ifdef HAVE_WINDOW_SYSTEM
+              if (FRAME_WINDOW_P (f)
+                  && FRAME_RIF (f)->clear_under_internal_border)
+                FRAME_RIF (f)->clear_under_internal_border (f);
+#endif
            }
 
          if (window_height_changed_p
@@ -11851,7 +11839,7 @@ format_mode_line_unwind_data (struct frame 
*target_frame,
   Vmode_line_unwind_vector = Qnil;
 
   if (NILP (vector))
-    vector = make_nil_vector (10);
+    vector = make_nil_vector (12);
 
   ASET (vector, 0, make_fixnum (mode_line_target));
   ASET (vector, 1, make_fixnum (MODE_LINE_NOPROP_LEN (0)));
@@ -11868,12 +11856,24 @@ format_mode_line_unwind_data (struct frame 
*target_frame,
   ASET (vector, 7, owin);
   if (target_frame)
     {
+      Lisp_Object buffer = XWINDOW (target_frame->selected_window)->contents;
+      struct buffer *b = XBUFFER (buffer);
+      struct buffer *cb = current_buffer;
+
       /* Similarly to `with-selected-window', if the operation selects
         a window on another frame, we must restore that frame's
         selected window, and (for a tty) the top-frame.  */
       ASET (vector, 8, target_frame->selected_window);
       if (FRAME_TERMCAP_P (target_frame))
        ASET (vector, 9, FRAME_TTY (target_frame)->top_frame);
+
+      /* If we select a window on another frame, make sure that that
+        selection does not leave its buffer's point modified when
+        unwinding (Bug#32777).  */
+      ASET (vector, 10, buffer);
+      current_buffer = b;
+      ASET (vector, 11, build_marker (current_buffer, PT, PT_BYTE));
+      current_buffer = cb;
     }
 
   return vector;
@@ -11913,6 +11913,24 @@ unwind_format_mode_line (Lisp_Object vector)
        }
 
       Fselect_window (old_window, Qt);
+
+      /* Restore point of target_frame_window's buffer (Bug#32777).
+        But do this only after old_window has been reselected to
+        avoid that the window point of target_frame_window moves.  */
+      if (!NILP (target_frame_window))
+       {
+         Lisp_Object buffer = AREF (vector, 10);
+
+         if (BUFFER_LIVE_P (XBUFFER (buffer)))
+           {
+             struct buffer *cb = current_buffer;
+
+             current_buffer = XBUFFER (buffer);
+             set_point_from_marker (AREF (vector, 11));
+             ASET (vector, 11, Qnil);
+             current_buffer = cb;
+           }
+       }
     }
 
   if (!NILP (AREF (vector, 6)))
@@ -11990,7 +12008,7 @@ store_mode_line_noprop (const char *string, int 
field_width, int precision)
    frame_title_format.  */
 
 static void
-x_consider_frame_title (Lisp_Object frame)
+gui_consider_frame_title (Lisp_Object frame)
 {
   struct frame *f = XFRAME (frame);
 
@@ -12023,19 +12041,26 @@ x_consider_frame_title (Lisp_Object frame)
       /* Set global variable indicating that multiple frames exist.  */
       multiple_frames = CONSP (tail);
 
-      /* Switch to the buffer of selected window of the frame.  Set up
-        mode_line_target so that display_mode_element will output into
-        mode_line_noprop_buf; then display the title.  */
-      record_unwind_protect (unwind_format_mode_line,
-                            format_mode_line_unwind_data
-                              (f, current_buffer, selected_window, false));
       /* select-frame calls resize_mini_window, which could resize the
         mini-window and by that undo the effect of this redisplay
         cycle wrt minibuffer and echo-area display.  Binding
         inhibit-redisplay to t makes the call to resize_mini_window a
         no-op, thus avoiding the adverse side effects.  */
+
+      /* The following was moved before the record_unwind_protect form
+        below to inhibit redisplay also when restoring the selected
+        window/frame: This avoids that resize_mini_window sizes back
+        the minibuffer window of a temporarily selected frame.  See
+        Bug#34317.  */
       specbind (Qinhibit_redisplay, Qt);
 
+      /* Switch to the buffer of selected window of the frame.  Set up
+        mode_line_target so that display_mode_element will output into
+        mode_line_noprop_buf; then display the title.  */
+      record_unwind_protect (unwind_format_mode_line,
+                            format_mode_line_unwind_data
+                              (f, current_buffer, selected_window, false));
+
       Fselect_window (f->selected_window, Qt);
       set_buffer_internal_1
        (XBUFFER (XWINDOW (f->selected_window)->contents));
@@ -12055,10 +12080,13 @@ x_consider_frame_title (Lisp_Object frame)
         already wasted too much time by walking through the list with
         display_mode_element, then we might need to optimize at a
         higher level than this.)  */
-      if (! STRINGP (f->name)
-         || SBYTES (f->name) != len
-         || memcmp (title, SDATA (f->name), len) != 0)
-       x_implicitly_set_name (f, make_string (title, len), Qnil);
+      if ((! STRINGP (f->name)
+           || SBYTES (f->name) != len
+           || memcmp (title, SDATA (f->name), len) != 0)
+          && FRAME_TERMINAL (f)->implicit_set_name_hook)
+       FRAME_TERMINAL (f)->implicit_set_name_hook (f,
+                                                    make_string (title, len),
+                                                    Qnil);
     }
 }
 
@@ -12130,7 +12158,7 @@ prepare_menu_bars (void)
                  || FRAME_VISIBLE_P (f) == 1
                  /* Exclude TTY frames that are obscured because they
                     are not the top frame on their console.  This is
-                    because x_consider_frame_title actually switches
+                    because gui_consider_frame_title actually switches
                     to the frame, which for TTY frames means it is
                     marked as garbaged, and will be completely
                     redrawn on the next redisplay cycle.  This causes
@@ -12138,7 +12166,7 @@ prepare_menu_bars (void)
                     are more than one of them, even though nothing
                     should be changed on display.  */
                  || (FRAME_VISIBLE_P (f) == 2 && FRAME_WINDOW_P (f))))
-           x_consider_frame_title (frame);
+           gui_consider_frame_title (frame);
        }
     }
 #endif /* HAVE_WINDOW_SYSTEM */
@@ -12171,8 +12199,6 @@ prepare_menu_bars (void)
              && !XBUFFER (w->contents)->text->redisplay)
            continue;
 
-         run_window_size_change_functions (frame);
-
          if (FRAME_PARENT_FRAME (f))
            continue;
 
@@ -12223,8 +12249,7 @@ update_menu_bar (struct frame *f, bool save_match_data, 
bool hooks_run)
 
   if (FRAME_WINDOW_P (f)
       ?
-#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
-    || defined (HAVE_NS) || defined (USE_GTK)
+#ifdef HAVE_EXT_MENU_BAR
       FRAME_EXTERNAL_MENU_BAR (f)
 #else
       FRAME_MENU_BAR_LINES (f) > 0
@@ -12277,8 +12302,7 @@ update_menu_bar (struct frame *f, bool save_match_data, 
bool hooks_run)
          fset_menu_bar_items (f, menu_bar_items (FRAME_MENU_BAR_ITEMS (f)));
 
          /* Redisplay the menu bar in case we changed it.  */
-#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
-    || defined (HAVE_NS) || defined (USE_GTK)
+#ifdef HAVE_EXT_MENU_BAR
          if (FRAME_WINDOW_P (f))
             {
 #if defined (HAVE_NS)
@@ -12292,11 +12316,11 @@ update_menu_bar (struct frame *f, bool 
save_match_data, bool hooks_run)
            /* On a terminal screen, the menu bar is an ordinary screen
               line, and this makes it get updated.  */
            w->update_mode_line = true;
-#else /* ! (USE_X_TOOLKIT || HAVE_NTGUI || HAVE_NS || USE_GTK) */
+#else /* ! (HAVE_EXT_MENU_BAR) */
          /* In the non-toolkit version, the menu bar is an ordinary screen
             line, and this makes it get updated.  */
          w->update_mode_line = true;
-#endif /* ! (USE_X_TOOLKIT || HAVE_NTGUI || HAVE_NS || USE_GTK) */
+#endif /* HAVE_EXT_MENU_BAR */
 
          unbind_to (count, Qnil);
          set_buffer_internal_1 (prev);
@@ -12334,7 +12358,7 @@ fast_set_selected_frame (Lisp_Object frame)
 static void
 update_tool_bar (struct frame *f, bool save_match_data)
 {
-#if defined (USE_GTK) || defined (HAVE_NS)
+#ifdef HAVE_EXT_TOOL_BAR
   bool do_update = FRAME_EXTERNAL_TOOL_BAR (f);
 #else
   bool do_update = (WINDOWP (f->tool_bar_window)
@@ -12419,7 +12443,7 @@ update_tool_bar (struct frame *f, bool save_match_data)
     }
 }
 
-#if ! defined (USE_GTK) && ! defined (HAVE_NS)
+#ifndef HAVE_EXT_TOOL_BAR
 
 /* Set F->desired_tool_bar_string to a Lisp string representing frame
    F's desired tool-bar contents.  F->tool_bar_items must have
@@ -12496,7 +12520,8 @@ build_desired_tool_bar_string (struct frame *f)
 
       /* Compute margin and relief to draw.  */
       relief = (tool_bar_button_relief >= 0
-               ? tool_bar_button_relief
+               ? min (tool_bar_button_relief,
+                      min (INT_MAX, MOST_POSITIVE_FIXNUM))
                : DEFAULT_TOOL_BAR_BUTTON_RELIEF);
       hmargin = vmargin = relief;
 
@@ -12753,7 +12778,7 @@ tool_bar_height (struct frame *f, int *n_rows, bool 
pixelwise)
     return (it.current_y + FRAME_LINE_HEIGHT (f) - 1) / FRAME_LINE_HEIGHT (f);
 }
 
-#endif /* !USE_GTK && !HAVE_NS */
+#endif /* ! (HAVE_EXT_TOOL_BAR) */
 
 DEFUN ("tool-bar-height", Ftool_bar_height, Stool_bar_height,
        0, 2, 0,
@@ -12764,7 +12789,7 @@ PIXELWISE non-nil means return the height of the tool 
bar in pixels.  */)
 {
   int height = 0;
 
-#if ! defined (USE_GTK) && ! defined (HAVE_NS)
+#ifndef HAVE_EXT_TOOL_BAR
   struct frame *f = decode_any_frame (frame);
 
   if (WINDOWP (f->tool_bar_window)
@@ -12789,13 +12814,13 @@ static bool
 redisplay_tool_bar (struct frame *f)
 {
   f->tool_bar_redisplayed = true;
-#if defined (USE_GTK) || defined (HAVE_NS)
+#ifdef HAVE_EXT_TOOL_BAR
 
   if (FRAME_EXTERNAL_TOOL_BAR (f))
     update_frame_tool_bar (f);
   return false;
 
-#else /* !USE_GTK && !HAVE_NS */
+#else /* ! (HAVE_EXT_TOOL_BAR) */
 
   struct window *w;
   struct it it;
@@ -12835,7 +12860,8 @@ redisplay_tool_bar (struct frame *f)
 
       if (new_height != WINDOW_PIXEL_HEIGHT (w))
        {
-         x_change_tool_bar_height (f, new_height);
+          if (FRAME_TERMINAL (f)->change_tool_bar_height_hook)
+            FRAME_TERMINAL (f)->change_tool_bar_height_hook (f, new_height);
          frame_default_tool_bar_height = new_height;
          /* Always do that now.  */
          clear_glyph_matrix (w->desired_matrix);
@@ -12930,7 +12956,8 @@ redisplay_tool_bar (struct frame *f)
 
          if (change_height_p)
            {
-             x_change_tool_bar_height (f, new_height);
+              if (FRAME_TERMINAL (f)->change_tool_bar_height_hook)
+                FRAME_TERMINAL (f)->change_tool_bar_height_hook (f, 
new_height);
              frame_default_tool_bar_height = new_height;
              clear_glyph_matrix (w->desired_matrix);
              f->n_tool_bar_rows = nrows;
@@ -12944,10 +12971,10 @@ redisplay_tool_bar (struct frame *f)
   f->minimize_tool_bar_window_p = false;
   return false;
 
-#endif /* USE_GTK || HAVE_NS */
+#endif /* HAVE_EXT_TOOL_BAR */
 }
 
-#if ! defined (USE_GTK) && ! defined (HAVE_NS)
+#ifndef HAVE_EXT_TOOL_BAR
 
 /* Get information about the tool-bar item which is displayed in GLYPH
    on frame F.  Return in *PROP_IDX the index where tool-bar item
@@ -13140,7 +13167,7 @@ note_tool_bar_highlight (struct frame *f, int x, int y)
   clear_mouse_face (hlinfo);
 
   /* Mouse is down, but on different tool-bar item?  */
-  mouse_down_p = (x_mouse_grabbed (dpyinfo)
+  mouse_down_p = (gui_mouse_grabbed (dpyinfo)
                  && f == dpyinfo->last_mouse_frame);
 
   if (mouse_down_p && f->last_tool_bar_item != prop_idx)
@@ -13185,7 +13212,7 @@ note_tool_bar_highlight (struct frame *f, int x, int y)
     help_echo_string = AREF (f->tool_bar_items, prop_idx + 
TOOL_BAR_ITEM_CAPTION);
 }
 
-#endif /* !USE_GTK && !HAVE_NS */
+#endif /* ! (HAVE_EXT_TOOL_BAR) */
 
 #endif /* HAVE_WINDOW_SYSTEM */
 
@@ -13297,7 +13324,8 @@ hscroll_window_tree (Lisp_Object window)
          text_area_width = window_box_width (w, TEXT_AREA);
 
          /* Scroll when cursor is inside this scroll margin.  */
-         h_margin = hscroll_margin * WINDOW_FRAME_COLUMN_WIDTH (w);
+         h_margin = (clip_to_bounds (0, hscroll_margin, 1000000)
+                     * WINDOW_FRAME_COLUMN_WIDTH (w));
 
          /* If the position of this window's point has explicitly
             changed, no more suspend auto hscrolling.  */
@@ -14090,20 +14118,6 @@ redisplay_internal (void)
     {
       echo_area_display (false);
 
-      /* If echo_area_display resizes the mini-window, the redisplay and
-        window_sizes_changed flags of the selected frame are set, but
-        it's too late for the hooks in window-size-change-functions,
-        which have been examined already in prepare_menu_bars.  So in
-        that case we call the hooks here only for the selected frame.  */
-      if (sf->redisplay)
-       {
-         ptrdiff_t count1 = SPECPDL_INDEX ();
-
-         record_unwind_save_match_data ();
-         run_window_size_change_functions (selected_frame);
-         unbind_to (count1, Qnil);
-       }
-
       if (message_cleared_p)
        update_miniwindow_p = true;
 
@@ -14120,15 +14134,6 @@ redisplay_internal (void)
           && (current_buffer->clip_changed || window_outdated (w))
           && resize_mini_window (w, false))
     {
-      if (sf->redisplay)
-       {
-         ptrdiff_t count1 = SPECPDL_INDEX ();
-
-         record_unwind_save_match_data ();
-         run_window_size_change_functions (selected_frame);
-         unbind_to (count1, Qnil);
-       }
-
       /* Resized active mini-window to fit the size of what it is
          showing if its contents might have changed.  */
       must_finish = true;
@@ -14139,6 +14144,9 @@ redisplay_internal (void)
       clear_garbaged_frames ();
     }
 
+  if (!NILP (Vrun_hooks))
+    run_window_change_functions ();
+
   if (windows_or_buffers_changed && !update_mode_lines)
     /* Code that sets windows_or_buffers_changed doesn't distinguish whether
        only the windows's contents needs to be refreshed, or whether the
@@ -14318,7 +14326,7 @@ redisplay_internal (void)
                  && (w = XWINDOW (selected_window)) != sw)
                goto retry;
 
-             /* We used to always goto end_of_redisplay here, but this
+               /* We used to always goto end_of_redisplay here, but this
                 isn't enough if we have a blinking cursor.  */
              if (w->cursor_off_p == w->last_cursor_off_p)
                goto end_of_redisplay;
@@ -14414,7 +14422,17 @@ redisplay_internal (void)
                FRAME_TERMINAL (f)->condemn_scroll_bars_hook (f);
 
              if (FRAME_VISIBLE_P (f) && !FRAME_OBSCURED_P (f))
-               redisplay_windows (FRAME_ROOT_WINDOW (f));
+               {
+
+                 /* Don't allow freeing images for this frame as long
+                    as the frame's update wasn't completed.  This
+                    prevents crashes when some Lisp that runs from
+                    the various hooks or font-lock decides to clear
+                    the frame's image cache, when the images in that
+                    cache are referenced by the desired matrix.  */
+                 f->inhibit_clear_image_cache = true;
+                 redisplay_windows (FRAME_ROOT_WINDOW (f));
+               }
              /* Remember that the invisible frames need to be redisplayed next
                 time they're visible.  */
              else if (!REDISPLAY_SOME_P ())
@@ -14481,10 +14499,11 @@ redisplay_internal (void)
                      && garbaged_frame_retries++ < MAX_GARBAGED_FRAME_RETRIES)
                     goto retry;
 
-#if defined (HAVE_WINDOW_SYSTEM) && !defined (HAVE_NS)
-                 x_clear_under_internal_border (f);
-#endif /* HAVE_WINDOW_SYSTEM && !HAVE_NS */
-
+#ifdef HAVE_WINDOW_SYSTEM
+                  if (FRAME_WINDOW_P (f)
+                      && FRAME_RIF (f)->clear_under_internal_border)
+                    FRAME_RIF (f)->clear_under_internal_border (f);
+#endif
                  /* Prevent various kinds of signals during display
                     update.  stdio is not robust about handling
                     signals, which can cause an apparent I/O error.  */
@@ -14495,6 +14514,7 @@ redisplay_internal (void)
                  pending |= update_frame (f, false, false);
                  f->cursor_type_changed = false;
                  f->updated_p = true;
+                 f->inhibit_clear_image_cache = false;
                }
            }
        }
@@ -14522,6 +14542,7 @@ redisplay_internal (void)
     }
   else if (FRAME_VISIBLE_P (sf) && !FRAME_OBSCURED_P (sf))
     {
+      sf->inhibit_clear_image_cache = true;
       displayed_buffer = XBUFFER (XWINDOW (selected_window)->contents);
       /* Use list_of_error, not Qerror, so that
         we catch only errors and don't run the debugger.  */
@@ -14577,6 +14598,7 @@ redisplay_internal (void)
          XWINDOW (selected_window)->must_be_updated_p = true;
          pending = update_frame (sf, false, false);
          sf->cursor_type_changed = false;
+         sf->inhibit_clear_image_cache = false;
        }
 
       /* We may have called echo_area_display at the top of this
@@ -14677,7 +14699,8 @@ redisplay_internal (void)
   /* If we just did a pending size change, or have additional
      visible frames, or selected_window changed, redisplay again.  */
   if ((windows_or_buffers_changed && !pending)
-      || (WINDOWP (selected_window) && (w = XWINDOW (selected_window)) != sw))
+      || (WINDOWP (selected_window)
+         && (w = XWINDOW (selected_window)) != sw))
     goto retry;
 
   /* Clear the face and image caches.
@@ -15734,7 +15757,7 @@ enum
 
 static int
 try_scrolling (Lisp_Object window, bool just_this_one_p,
-              ptrdiff_t arg_scroll_conservatively, ptrdiff_t scroll_step,
+              intmax_t arg_scroll_conservatively, intmax_t scroll_step,
               bool temp_scroll_step, bool last_line_misfit)
 {
   struct window *w = XWINDOW (window);
@@ -15766,12 +15789,15 @@ try_scrolling (Lisp_Object window, bool 
just_this_one_p,
       arg_scroll_conservatively = scroll_limit + 1;
       scroll_max = scroll_limit * frame_line_height;
     }
-  else if (scroll_step || arg_scroll_conservatively || temp_scroll_step)
+  else if (0 < scroll_step || 0 < arg_scroll_conservatively || 
temp_scroll_step)
     /* Compute how much we should try to scroll maximally to bring
        point into view.  */
-    scroll_max = (max (scroll_step,
-                      max (arg_scroll_conservatively, temp_scroll_step))
-                 * frame_line_height);
+    {
+      intmax_t scroll_lines_max
+       = max (scroll_step, max (arg_scroll_conservatively, temp_scroll_step));
+      int scroll_lines = clip_to_bounds (0, scroll_lines_max, 1000000);
+      scroll_max = scroll_lines * frame_line_height;
+    }
   else if (NUMBERP (BVAR (current_buffer, scroll_down_aggressively))
           || NUMBERP (BVAR (current_buffer, scroll_up_aggressively)))
     /* We're trying to scroll because of aggressive scrolling but no
@@ -17264,8 +17290,8 @@ redisplay_window (Lisp_Object window, bool 
just_this_one_p)
     }
 
   /* Try to scroll by specified few lines.  */
-  if ((scroll_conservatively
-       || emacs_scroll_step
+  if ((0 < scroll_conservatively
+       || 0 < emacs_scroll_step
        || temp_scroll_step
        || NUMBERP (BVAR (current_buffer, scroll_up_aggressively))
        || NUMBERP (BVAR (current_buffer, scroll_down_aggressively)))
@@ -17645,8 +17671,7 @@ redisplay_window (Lisp_Object window, bool 
just_this_one_p)
 
       if (FRAME_WINDOW_P (f))
        {
-#if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
-    || defined (HAVE_NS) || defined (USE_GTK)
+#ifdef HAVE_EXT_MENU_BAR
          redisplay_menu_p = FRAME_EXTERNAL_MENU_BAR (f);
 #else
          redisplay_menu_p = FRAME_MENU_BAR_LINES (f) > 0;
@@ -17661,7 +17686,7 @@ redisplay_window (Lisp_Object window, bool 
just_this_one_p)
 #ifdef HAVE_WINDOW_SYSTEM
       if (FRAME_WINDOW_P (f))
         {
-#if defined (USE_GTK) || defined (HAVE_NS)
+#ifdef HAVE_EXT_TOOL_BAR
          if (FRAME_EXTERNAL_TOOL_BAR (f))
            redisplay_tool_bar (f);
 #else
@@ -17672,7 +17697,7 @@ redisplay_window (Lisp_Object window, bool 
just_this_one_p)
            ignore_mouse_drag_p = true;
 #endif
         }
-      x_consider_frame_title (w->frame);
+      gui_consider_frame_title (w->frame);
 #endif
     }
 
@@ -17687,16 +17712,16 @@ redisplay_window (Lisp_Object window, bool 
just_this_one_p)
       if (draw_window_fringes (w, true))
        {
          if (WINDOW_RIGHT_DIVIDER_WIDTH (w))
-           x_draw_right_divider (w);
+           gui_draw_right_divider (w);
          else
-           x_draw_vertical_border (w);
+           gui_draw_vertical_border (w);
        }
       unblock_input ();
       update_end (f);
     }
 
   if (WINDOW_BOTTOM_DIVIDER_WIDTH (w))
-    x_draw_bottom_divider (w);
+    gui_draw_bottom_divider (w);
 #endif /* HAVE_WINDOW_SYSTEM */
 
   /* We go to this label, with fonts_changed set, if it is
@@ -19140,7 +19165,7 @@ try_window_id (struct window *w)
                     + window_internal_height (w));
 
 #if defined (HAVE_GPM) || defined (MSDOS)
-         x_clear_window_mouse_face (w);
+         gui_clear_window_mouse_face (w);
 #endif
          /* Perform the operation on the screen.  */
          if (dvpos > 0)
@@ -19696,7 +19721,7 @@ If there's no tool-bar, or if the tool-bar is not drawn 
by Emacs,
 do nothing.  */)
   (Lisp_Object row, Lisp_Object glyphs)
 {
-#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
   struct frame *sf = SELECTED_FRAME ();
   struct glyph_matrix *m = XWINDOW (sf->tool_bar_window)->current_matrix;
   EMACS_INT vpos;
@@ -20164,7 +20189,7 @@ append_space_for_newline (struct it *it, bool 
default_face_p)
              it->object = saved_object; /* get_it_property needs this */
              normal_char_ascent_descent (font, -1, &it->ascent, &it->descent);
              /* Must do a subset of line height processing from
-                x_produce_glyph for newline characters.  */
+                gui_produce_glyph for newline characters.  */
              height = get_it_property (it, Qline_height);
              if (CONSP (height)
                  && CONSP (XCDR (height))
@@ -20322,7 +20347,7 @@ extend_face_to_end_of_line (struct it *it)
       /* Mode line and the header line don't have margins, and
         likewise the frame's tool-bar window, if there is any.  */
       if (!(it->glyph_row->mode_line_p
-#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
            || (WINDOWP (f->tool_bar_window)
                && it->w == XWINDOW (f->tool_bar_window))
 #endif
@@ -20565,7 +20590,7 @@ highlight_trailing_whitespace (struct it *it)
       else
        {
          while (glyph <= start
-                && glyph->type == CHAR_GLYPH
+                && (glyph->type == CHAR_GLYPH || glyph->type == STRETCH_GLYPH)
                 && NILP (glyph->object))
            ++glyph;
        }
@@ -21243,7 +21268,10 @@ maybe_produce_line_number (struct it *it)
       if (lnum_face_id != current_lnum_face_id
          && (EQ (Vdisplay_line_numbers, Qvisual)
              ? this_line == 0
-             : this_line == it->pt_lnum))
+             : this_line == it->pt_lnum)
+         /* Avoid displaying the line-number-current-line face on
+            empty lines beyond EOB.  */
+         && it->what != IT_EOB)
        tem_it.face_id = current_lnum_face_id;
       else
        tem_it.face_id = lnum_face_id;
@@ -23042,7 +23070,7 @@ Emacs UBA implementation, in particular with the test 
suite.  */)
     }
   else
     {
-      CHECK_FIXNUM_COERCE_MARKER (vpos);
+      CHECK_FIXNUM (vpos);
       nrow = XFIXNUM (vpos);
     }
 
@@ -24105,7 +24133,7 @@ store_mode_line_string (const char *string, Lisp_Object 
lisp_string,
     }
   else
     {
-      len = XFIXNAT (Flength (lisp_string));
+      len = SCHARS (lisp_string);
       if (precision > 0 && len > precision)
        {
          len = precision;
@@ -24259,7 +24287,7 @@ are the selected window and the WINDOW's buffer).  */)
   return unbind_to (count, str);
 }
 
-/* Write a null-terminated, right justified decimal representation of
+/* Write a NUL-terminated, right justified decimal representation of
    the positive integer D to BUF using a minimal field width WIDTH.  */
 
 static void
@@ -24289,7 +24317,7 @@ pint2str (register char *buf, register int width, 
register ptrdiff_t d)
     }
 }
 
-/* Write a null-terminated, right justified decimal and "human
+/* Write a NUL-terminated, right justified decimal and "human
    readable" representation of the nonnegative integer D to BUF using
    a minimal field width WIDTH.  D should be smaller than 999.5e24. */
 
@@ -24509,7 +24537,7 @@ decode_mode_spec (struct window *w, register int c, int 
field_width,
      produce strings from numerical values, so limit preposterously
      large values of FIELD_WIDTH to avoid overrunning the buffer's
      end.  The size of the buffer is enough for FRAME_MESSAGE_BUF_SIZE
-     bytes plus the terminating null.  */
+     bytes plus the terminating NUL.  */
   int width = min (field_width, FRAME_MESSAGE_BUF_SIZE (f));
   struct buffer *b = current_buffer;
 
@@ -24715,8 +24743,12 @@ decode_mode_spec (struct window *w, register int c, 
int field_width,
            ptrdiff_t limit = BUF_BEGV (b);
            ptrdiff_t limit_byte = BUF_BEGV_BYTE (b);
            ptrdiff_t position;
-           ptrdiff_t distance =
-             (height * 2 + 30) * line_number_display_limit_width;
+           ptrdiff_t distance
+             = (line_number_display_limit_width < 0 ? 0
+                : INT_MULTIPLY_WRAPV (line_number_display_limit_width,
+                                      height * 2 + 30,
+                                      &distance)
+                ? PTRDIFF_MAX : distance);
 
            if (startpos - distance > limit)
              {
@@ -25705,22 +25737,28 @@ dump_glyph_string (struct glyph_string *s)
    face-override for drawing S.  */
 
 #ifdef HAVE_NTGUI
-#define OPTIONAL_HDC(hdc)  HDC hdc,
-#define DECLARE_HDC(hdc)   HDC hdc;
-#define ALLOCATE_HDC(hdc, f) hdc = get_frame_dc ((f))
-#define RELEASE_HDC(hdc, f)  release_frame_dc ((f), (hdc))
-#endif
-
-#ifndef OPTIONAL_HDC
-#define OPTIONAL_HDC(hdc)
-#define DECLARE_HDC(hdc)
-#define ALLOCATE_HDC(hdc, f)
-#define RELEASE_HDC(hdc, f)
+/* We set inhibit-quit here due to paranoia: get_frame_dc acquires the
+   critical section, and we cannot QUIT while we hold the critical
+   section.  If any of the code run by callers of ALLOCATE_HDC happens
+   to call Lisp (might be possible due to all the hooks lying around),
+   we must prevent it from quitting.  */
+# define ALLOCATE_HDC(hdc, f)                  \
+  Lisp_Object prev_quit = Vinhibit_quit;       \
+  Vinhibit_quit = Qt;                          \
+  HDC hdc = get_frame_dc ((f))
+# define RELEASE_HDC(hdc, f)                   \
+  release_frame_dc ((f), (hdc));               \
+  Vinhibit_quit = prev_quit
+#else
+# define ALLOCATE_HDC(hdc, f)
+# define RELEASE_HDC(hdc, f)
 #endif
 
 static void
 init_glyph_string (struct glyph_string *s,
-                  OPTIONAL_HDC (hdc)
+#ifdef HAVE_NTGUI
+                  HDC hdc,
+#endif
                   XChar2b *char2b, struct window *w, struct glyph_row *row,
                   enum glyph_row_area area, int start, enum draw_glyphs_face 
hl)
 {
@@ -26237,7 +26275,7 @@ normal_char_height (struct font *font, int c)
    assumed to be zero.  */
 
 void
-x_get_glyph_overhangs (struct glyph *glyph, struct frame *f, int *left, int 
*right)
+gui_get_glyph_overhangs (struct glyph *glyph, struct frame *f, int *left, int 
*right)
 {
   *left = *right = 0;
 
@@ -26327,7 +26365,7 @@ left_overwriting (struct glyph_string *s)
   for (i = first - 1; i >= 0; --i)
     {
       int left, right;
-      x_get_glyph_overhangs (glyphs + i, s->f, &left, &right);
+      gui_get_glyph_overhangs (glyphs + i, s->f, &left, &right);
       if (x + right > 0)
        k = i;
       x -= glyphs[i].pixel_width;
@@ -26382,7 +26420,7 @@ right_overwriting (struct glyph_string *s)
   for (i = first; i < end; ++i)
     {
       int left, right;
-      x_get_glyph_overhangs (glyphs + i, s->f, &left, &right);
+      gui_get_glyph_overhangs (glyphs + i, s->f, &left, &right);
       if (x - left < 0)
        k = i;
       x += glyphs[i].pixel_width;
@@ -26760,7 +26798,6 @@ draw_glyphs (struct window *w, int x, struct glyph_row 
*row,
   struct glyph_string *clip_head = NULL, *clip_tail = NULL;
   int i, j, x_reached, last_x, area_left = 0;
   struct frame *f = XFRAME (WINDOW_FRAME (w));
-  DECLARE_HDC (hdc);
 
   ALLOCATE_HDC (hdc, f);
 
@@ -27045,7 +27082,7 @@ font_for_underline_metrics (struct glyph_string *s)
   }
 
 /* Store one glyph for IT->char_to_display in IT->glyph_row.
-   Called from x_produce_glyphs when IT->glyph_row is non-null.  */
+   Called from gui_produce_glyphs when IT->glyph_row is non-null.  */
 
 static void
 append_glyph (struct it *it)
@@ -27127,9 +27164,8 @@ append_glyph (struct it *it)
     IT_EXPAND_MATRIX_WIDTH (it, area);
 }
 
-/* Store one glyph for the composition IT->cmp_it.id in
-   IT->glyph_row.  Called from x_produce_glyphs when IT->glyph_row is
-   non-null.  */
+/* Store one glyph for the composition IT->cmp_it.id in IT->glyph_row.
+   Called from gui_produce_glyphs when IT->glyph_row is non-null.  */
 
 static void
 append_composite_glyph (struct it *it)
@@ -27959,7 +27995,7 @@ calc_line_height_property (struct it *it, Lisp_Object 
val, struct font *font,
   /* FIXME: Check for overflow in multiplication or conversion.  */
   if (FLOATP (val))
     height = (int)(XFLOAT_DATA (val) * height);
-  else
+  else if (INTEGERP (val))
     {
       intmax_t v;
       if (integer_to_intmax (val, &v))
@@ -28205,7 +28241,7 @@ produce_glyphless_glyph (struct it *it, bool 
for_no_font, Lisp_Object acronym)
    for an overview of struct it.  */
 
 void
-x_produce_glyphs (struct it *it)
+gui_produce_glyphs (struct it *it)
 {
   int extra_line_spacing = it->extra_line_spacing;
 
@@ -28338,7 +28374,7 @@ x_produce_glyphs (struct it *it)
          /* If face has an overline, add the height of the overline
             (1 pixel) and a 1 pixel margin to the character height.  */
          if (face->overline_p)
-           it->ascent += overline_margin;
+           it->ascent += clip_to_bounds (0, overline_margin, 1000000);
 
          if (it->constrain_row_ascent_descent_p)
            {
@@ -28879,7 +28915,7 @@ x_produce_glyphs (struct it *it)
       /* If face has an overline, add the height of the overline
         (1 pixel) and a 1 pixel margin to the character height.  */
       if (face->overline_p)
-       it->ascent += overline_margin;
+       it->ascent += clip_to_bounds (0, overline_margin, 1000000);
 
       take_vertical_position_into_account (it);
       if (it->ascent < 0)
@@ -28928,7 +28964,7 @@ x_produce_glyphs (struct it *it)
       /* If face has an overline, add the height of the overline
         (1 pixel) and a 1 pixel margin to the character height.  */
       if (face->overline_p)
-       it->ascent += overline_margin;
+       it->ascent += clip_to_bounds (0, overline_margin, 1000000);
       take_vertical_position_into_account (it);
       if (it->ascent < 0)
        it->ascent = 0;
@@ -28973,7 +29009,7 @@ x_produce_glyphs (struct it *it)
    being updated, and UPDATED_AREA is the area of that row being updated.  */
 
 void
-x_write_glyphs (struct window *w, struct glyph_row *updated_row,
+gui_write_glyphs (struct window *w, struct glyph_row *updated_row,
                struct glyph *start, enum glyph_row_area updated_area, int len)
 {
   int x, hpos, chpos = w->phys_cursor.hpos;
@@ -29017,7 +29053,7 @@ x_write_glyphs (struct window *w, struct glyph_row 
*updated_row,
    Insert LEN glyphs from START at the nominal cursor position.  */
 
 void
-x_insert_glyphs (struct window *w, struct glyph_row *updated_row,
+gui_insert_glyphs (struct window *w, struct glyph_row *updated_row,
                 struct glyph *start, enum glyph_row_area updated_area, int len)
 {
   struct frame *f;
@@ -29074,7 +29110,7 @@ x_insert_glyphs (struct window *w, struct glyph_row 
*updated_row,
    updated window W.  TO_X == -1 means clear to the end of this area.  */
 
 void
-x_clear_end_of_line (struct window *w, struct glyph_row *updated_row,
+gui_clear_end_of_line (struct window *w, struct glyph_row *updated_row,
                     enum glyph_row_area updated_area, int to_x)
 {
   struct frame *f;
@@ -29274,7 +29310,7 @@ get_window_cursor_type (struct window *w, struct glyph 
*glyph, int *width,
 
   /* Detect a nonselected window or nonselected frame.  */
   else if (w != XWINDOW (f->selected_window)
-          || f != FRAME_DISPLAY_INFO (f)->x_highlight_frame)
+          || f != FRAME_DISPLAY_INFO (f)->highlight_frame)
     {
       *active_cursor = false;
 
@@ -29461,7 +29497,7 @@ notice_overwritten_cursor (struct window *w, enum 
glyph_row_area area,
    with respect to the overlapping part OVERLAPS.  */
 
 void
-x_fix_overlapping_area (struct window *w, struct glyph_row *row,
+gui_fix_overlapping_area (struct window *w, struct glyph_row *row,
                        enum glyph_row_area area, int overlaps)
 {
   int i, x;
@@ -29540,12 +29576,12 @@ draw_phys_cursor_glyph (struct window *w, struct 
glyph_row *row,
 
          if (row > w->current_matrix->rows
              && MATRIX_ROW_OVERLAPS_SUCC_P (row - 1))
-           x_fix_overlapping_area (w, row - 1, TEXT_AREA,
+           gui_fix_overlapping_area (w, row - 1, TEXT_AREA,
                                    OVERLAPS_ERASED_CURSOR);
 
          if (MATRIX_ROW_BOTTOM_Y (row) < window_text_bottom_y (w)
              && MATRIX_ROW_OVERLAPS_PRED_P (row + 1))
-           x_fix_overlapping_area (w, row + 1, TEXT_AREA,
+           gui_fix_overlapping_area (w, row + 1, TEXT_AREA,
                                    OVERLAPS_ERASED_CURSOR);
        }
     }
@@ -29835,7 +29871,7 @@ update_cursor_in_window_tree (struct window *w, bool 
on_p)
    Don't change the cursor's position.  */
 
 void
-x_update_cursor (struct frame *f, bool on_p)
+gui_update_cursor (struct frame *f, bool on_p)
 {
   update_cursor_in_window_tree (XWINDOW (f->root_window), on_p);
 }
@@ -29847,7 +29883,7 @@ x_update_cursor (struct frame *f, bool on_p)
    is about to be rewritten.  */
 
 void
-x_clear_cursor (struct window *w)
+gui_clear_cursor (struct window *w)
 {
   if (FRAME_VISIBLE_P (XFRAME (w->frame)) && w->phys_cursor_on_p)
     update_window_cursor (w, false);
@@ -29995,16 +30031,16 @@ show_mouse_face (Mouse_HLInfo *hlinfo, enum 
draw_glyphs_face draw)
   /* Change the mouse cursor.  */
   if (FRAME_WINDOW_P (f) && NILP (do_mouse_tracking))
     {
-#if ! defined (USE_GTK) && ! defined (HAVE_NS)
+#ifndef HAVE_EXT_TOOL_BAR
       if (draw == DRAW_NORMAL_TEXT
          && !EQ (hlinfo->mouse_face_window, f->tool_bar_window))
-       FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->text_cursor);
+       FRAME_RIF (f)->define_frame_cursor (f, FRAME_OUTPUT_DATA 
(f)->text_cursor);
       else
 #endif
       if (draw == DRAW_MOUSE_FACE)
-       FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->hand_cursor);
+       FRAME_RIF (f)->define_frame_cursor (f, FRAME_OUTPUT_DATA 
(f)->hand_cursor);
       else
-       FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT 
(f)->nontext_cursor);
+       FRAME_RIF (f)->define_frame_cursor (f, FRAME_OUTPUT_DATA 
(f)->nontext_cursor);
     }
 #endif /* HAVE_WINDOW_SYSTEM */
 }
@@ -30946,25 +30982,25 @@ define_frame_cursor1 (struct frame *f, Cursor cursor, 
Lisp_Object pointer)
   if (!NILP (pointer))
     {
       if (EQ (pointer, Qarrow))
-       cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+       cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
       else if (EQ (pointer, Qhand))
-       cursor = FRAME_X_OUTPUT (f)->hand_cursor;
+       cursor = FRAME_OUTPUT_DATA (f)->hand_cursor;
       else if (EQ (pointer, Qtext))
-       cursor = FRAME_X_OUTPUT (f)->text_cursor;
+       cursor = FRAME_OUTPUT_DATA (f)->text_cursor;
       else if (EQ (pointer, intern ("hdrag")))
-       cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor;
+       cursor = FRAME_OUTPUT_DATA (f)->horizontal_drag_cursor;
       else if (EQ (pointer, intern ("nhdrag")))
-       cursor = FRAME_X_OUTPUT (f)->vertical_drag_cursor;
+       cursor = FRAME_OUTPUT_DATA (f)->vertical_drag_cursor;
 # ifdef HAVE_X_WINDOWS
       else if (EQ (pointer, intern ("vdrag")))
        cursor = FRAME_DISPLAY_INFO (f)->vertical_scroll_bar_cursor;
 # endif
       else if (EQ (pointer, intern ("hourglass")))
-       cursor = FRAME_X_OUTPUT (f)->hourglass_cursor;
+       cursor = FRAME_OUTPUT_DATA (f)->hourglass_cursor;
       else if (EQ (pointer, Qmodeline))
-       cursor = FRAME_X_OUTPUT (f)->modeline_cursor;
+       cursor = FRAME_OUTPUT_DATA (f)->modeline_cursor;
       else
-       cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+       cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
     }
 
   if (cursor != No_Cursor)
@@ -31116,7 +31152,7 @@ note_mode_line_or_margin_highlight (Lisp_Object window, 
int x, int y,
 
          if (STRINGP (string))
            {
-             cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+             cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
 
              if (NILP (pointer))
                pointer = Fget_text_property (pos, Qpointer, string);
@@ -31131,13 +31167,13 @@ note_mode_line_or_margin_highlight (Lisp_Object 
window, int x, int y,
                  if (!KEYMAPP (map))
                    map = Fget_text_property (pos, Qkeymap, string);
                  if (!KEYMAPP (map) && draggable && area == ON_MODE_LINE)
-                   cursor = FRAME_X_OUTPUT (f)->vertical_drag_cursor;
+                   cursor = FRAME_OUTPUT_DATA (f)->vertical_drag_cursor;
                }
            }
          else if (draggable && area == ON_MODE_LINE)
-           cursor = FRAME_X_OUTPUT (f)->vertical_drag_cursor;
+           cursor = FRAME_OUTPUT_DATA (f)->vertical_drag_cursor;
          else
-           cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+           cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
        }
 #endif
     }
@@ -31346,41 +31382,41 @@ note_mouse_highlight (struct frame *f, int x, int y)
       switch (part)
        {
        case INTERNAL_BORDER_NONE:
-         if (cursor != FRAME_X_OUTPUT (f)->nontext_cursor)
+         if (cursor != FRAME_OUTPUT_DATA (f)->nontext_cursor)
            /* Reset cursor.  */
-           cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+           cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
          break;
        case INTERNAL_BORDER_LEFT_EDGE:
-         cursor = FRAME_X_OUTPUT (f)->left_edge_cursor;
+         cursor = FRAME_OUTPUT_DATA (f)->left_edge_cursor;
          break;
        case INTERNAL_BORDER_TOP_LEFT_CORNER:
-         cursor = FRAME_X_OUTPUT (f)->top_left_corner_cursor;
+         cursor = FRAME_OUTPUT_DATA (f)->top_left_corner_cursor;
          break;
        case INTERNAL_BORDER_TOP_EDGE:
-         cursor = FRAME_X_OUTPUT (f)->top_edge_cursor;
+         cursor = FRAME_OUTPUT_DATA (f)->top_edge_cursor;
          break;
        case INTERNAL_BORDER_TOP_RIGHT_CORNER:
-         cursor = FRAME_X_OUTPUT (f)->top_right_corner_cursor;
+         cursor = FRAME_OUTPUT_DATA (f)->top_right_corner_cursor;
          break;
        case INTERNAL_BORDER_RIGHT_EDGE:
-         cursor = FRAME_X_OUTPUT (f)->right_edge_cursor;
+         cursor = FRAME_OUTPUT_DATA (f)->right_edge_cursor;
          break;
        case INTERNAL_BORDER_BOTTOM_RIGHT_CORNER:
-         cursor = FRAME_X_OUTPUT (f)->bottom_right_corner_cursor;
+         cursor = FRAME_OUTPUT_DATA (f)->bottom_right_corner_cursor;
          break;
        case INTERNAL_BORDER_BOTTOM_EDGE:
-         cursor = FRAME_X_OUTPUT (f)->bottom_edge_cursor;
+         cursor = FRAME_OUTPUT_DATA (f)->bottom_edge_cursor;
          break;
        case INTERNAL_BORDER_BOTTOM_LEFT_CORNER:
-         cursor = FRAME_X_OUTPUT (f)->bottom_left_corner_cursor;
+         cursor = FRAME_OUTPUT_DATA (f)->bottom_left_corner_cursor;
          break;
        default:
          /* This should not happen.  */
-         if (cursor != FRAME_X_OUTPUT (f)->nontext_cursor)
-           cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+         if (cursor != FRAME_OUTPUT_DATA (f)->nontext_cursor)
+           cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
        }
 
-      if (cursor != FRAME_X_OUTPUT (f)->nontext_cursor)
+      if (cursor != FRAME_OUTPUT_DATA (f)->nontext_cursor)
        {
          /* Do we really want a help echo here?  */
          help_echo_string = build_string ("drag-mouse-1: resize frame");
@@ -31397,7 +31433,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
   w = XWINDOW (window);
   frame_to_window_pixel_xy (w, &x, &y);
 
-#if defined (HAVE_WINDOW_SYSTEM) && ! defined (USE_GTK) && ! defined (HAVE_NS)
+#if defined (HAVE_WINDOW_SYSTEM) && ! defined (HAVE_EXT_TOOL_BAR)
   /* Handle tool-bar window differently since it doesn't display a
      buffer.  */
   if (EQ (window, f->tool_bar_window))
@@ -31416,7 +31452,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
 #ifdef HAVE_WINDOW_SYSTEM
       if (part == ON_LEFT_MARGIN || part == ON_RIGHT_MARGIN)
        {
-         cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+         cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
          /* Show non-text cursor (Bug#16647).  */
          goto set_cursor;
        }
@@ -31428,13 +31464,13 @@ note_mouse_highlight (struct frame *f, int x, int y)
 #ifdef HAVE_WINDOW_SYSTEM
   if (part == ON_VERTICAL_BORDER)
     {
-      cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor;
+      cursor = FRAME_OUTPUT_DATA (f)->horizontal_drag_cursor;
       help_echo_string = build_string ("drag-mouse-1: resize");
       goto set_cursor;
     }
   else if (part == ON_RIGHT_DIVIDER)
     {
-      cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor;
+      cursor = FRAME_OUTPUT_DATA (f)->horizontal_drag_cursor;
       help_echo_string = build_string ("drag-mouse-1: resize");
       goto set_cursor;
     }
@@ -31443,18 +31479,18 @@ note_mouse_highlight (struct frame *f, int x, int y)
        || minibuf_level
        || NILP (Vresize_mini_windows))
       {
-       cursor = FRAME_X_OUTPUT (f)->vertical_drag_cursor;
+       cursor = FRAME_OUTPUT_DATA (f)->vertical_drag_cursor;
        help_echo_string = build_string ("drag-mouse-1: resize");
        goto set_cursor;
       }
     else
-      cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+      cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
   else if (part == ON_LEFT_FRINGE || part == ON_RIGHT_FRINGE
           || part == ON_VERTICAL_SCROLL_BAR
           || part == ON_HORIZONTAL_SCROLL_BAR)
-    cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+    cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
   else
-    cursor = FRAME_X_OUTPUT (f)->text_cursor;
+    cursor = FRAME_OUTPUT_DATA (f)->text_cursor;
 #endif
 
   /* Are we in a window whose display is up to date?
@@ -31545,7 +31581,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
            {
 #ifdef HAVE_WINDOW_SYSTEM
              if (area != TEXT_AREA)
-               cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
+               cursor = FRAME_OUTPUT_DATA (f)->nontext_cursor;
              else
                pointer = Vvoid_text_area_pointer;
 #endif
@@ -31875,7 +31911,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
    functions to ensure the mouse-highlight is off.  */
 
 void
-x_clear_window_mouse_face (struct window *w)
+gui_clear_window_mouse_face (struct window *w)
 {
   Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame));
   Lisp_Object window;
@@ -32019,13 +32055,13 @@ expose_overlaps (struct window *w,
 
        row->clip = r;
        if (row->used[LEFT_MARGIN_AREA])
-         x_fix_overlapping_area (w, row, LEFT_MARGIN_AREA, OVERLAPS_BOTH);
+         gui_fix_overlapping_area (w, row, LEFT_MARGIN_AREA, OVERLAPS_BOTH);
 
        if (row->used[TEXT_AREA])
-         x_fix_overlapping_area (w, row, TEXT_AREA, OVERLAPS_BOTH);
+         gui_fix_overlapping_area (w, row, TEXT_AREA, OVERLAPS_BOTH);
 
        if (row->used[RIGHT_MARGIN_AREA])
-         x_fix_overlapping_area (w, row, RIGHT_MARGIN_AREA, OVERLAPS_BOTH);
+         gui_fix_overlapping_area (w, row, RIGHT_MARGIN_AREA, OVERLAPS_BOTH);
        row->clip = NULL;
       }
 }
@@ -32054,7 +32090,7 @@ phys_cursor_in_rect_p (struct window *w, XRectangle *r)
       cr.y = row->y;
       cr.width = WINDOW_RIGHT_FRINGE_WIDTH (w);
       cr.height = row->height;
-      return x_intersect_rectangles (&cr, r, &result);
+      return gui_intersect_rectangles (&cr, r, &result);
     }
 
   cursor_glyph = get_phys_cursor_glyph (w);
@@ -32068,7 +32104,7 @@ phys_cursor_in_rect_p (struct window *w, XRectangle *r)
       cr.height = w->phys_cursor_height;
       /* ++KFS: W32 version used W32-specific IntersectRect here, but
         I assume the effect is the same -- and this is portable.  */
-      return x_intersect_rectangles (&cr, r, &result);
+      return gui_intersect_rectangles (&cr, r, &result);
     }
   /* If we don't understand the format, pretend we're not in the hot-spot.  */
   return false;
@@ -32080,7 +32116,7 @@ phys_cursor_in_rect_p (struct window *w, XRectangle *r)
    have vertical scroll bars.  */
 
 void
-x_draw_vertical_border (struct window *w)
+gui_draw_vertical_border (struct window *w)
 {
   struct frame *f = XFRAME (WINDOW_FRAME (w));
 
@@ -32131,7 +32167,7 @@ x_draw_vertical_border (struct window *w)
 /* Draw window dividers for window W.  */
 
 void
-x_draw_right_divider (struct window *w)
+gui_draw_right_divider (struct window *w)
 {
   struct frame *f = WINDOW_XFRAME (w);
 
@@ -32157,7 +32193,7 @@ x_draw_right_divider (struct window *w)
 }
 
 static void
-x_draw_bottom_divider (struct window *w)
+gui_draw_bottom_divider (struct window *w)
 {
   struct frame *f = XFRAME (WINDOW_FRAME (w));
 
@@ -32222,7 +32258,7 @@ expose_window (struct window *w, XRectangle *fr)
   wr.width = WINDOW_PIXEL_WIDTH (w);
   wr.height = WINDOW_PIXEL_HEIGHT (w);
 
-  if (x_intersect_rectangles (fr, &wr, &r))
+  if (gui_intersect_rectangles (fr, &wr, &r))
     {
       int yb = window_text_bottom_y (w);
       struct glyph_row *row;
@@ -32239,7 +32275,7 @@ expose_window (struct window *w, XRectangle *fr)
       bool cursor_cleared_p = (!w->pseudo_window_p
                               && phys_cursor_in_rect_p (w, &r));
       if (cursor_cleared_p)
-       x_clear_cursor (w);
+       gui_clear_cursor (w);
 
       /* If the row containing the cursor extends face to end of line,
         then expose_area might overwrite the cursor outside the
@@ -32332,12 +32368,12 @@ expose_window (struct window *w, XRectangle *fr)
 
          /* Draw border between windows.  */
          if (WINDOW_RIGHT_DIVIDER_WIDTH (w))
-           x_draw_right_divider (w);
+           gui_draw_right_divider (w);
          else
-           x_draw_vertical_border (w);
+           gui_draw_vertical_border (w);
 
          if (WINDOW_BOTTOM_DIVIDER_WIDTH (w))
-           x_draw_bottom_divider (w);
+           gui_draw_bottom_divider (w);
 
          /* Turn the cursor on again.  */
          if (cursor_cleared_p
@@ -32361,14 +32397,7 @@ expose_window_tree (struct window *w, XRectangle *r)
   struct frame *f = XFRAME (w->frame);
   bool mouse_face_overwritten_p = false;
 
-  /* NS toolkits may have aleady modified the frame in expectation of
-     a successful redraw, so don't bail out here if the frame is
-     garbaged.  */
-  while (w
-#if !defined (HAVE_NS)
-         && !FRAME_GARBAGED_P (f)
-#endif
-         )
+  while (w && !FRAME_GARBAGED_P (f))
     {
       mouse_face_overwritten_p
        |= (WINDOWP (w->contents)
@@ -32396,16 +32425,11 @@ expose_frame (struct frame *f, int x, int y, int w, 
int h)
 
   TRACE ((stderr, "expose_frame "));
 
-#if !defined (HAVE_NS)
-  /* No need to redraw if frame will be redrawn soon except under NS
-     where the toolkit may have already modified the frame in
-     expectation of us redrawing it.  */
   if (FRAME_GARBAGED_P (f))
     {
       TRACE ((stderr, " garbaged\n"));
       return;
     }
-#endif
 
   /* If basic faces haven't been realized yet, there is no point in
      trying to redraw anything.  This can happen when we get an expose
@@ -32434,7 +32458,7 @@ expose_frame (struct frame *f, int x, int y, int w, int 
h)
   TRACE ((stderr, "(%d, %d, %d, %d)\n", r.x, r.y, r.width, r.height));
   mouse_face_overwritten_p = expose_window_tree (XWINDOW (f->root_window), &r);
 
-#if ! defined (USE_GTK) && ! defined (HAVE_NS)
+#ifndef HAVE_EXT_TOOL_BAR
   if (WINDOWP (f->tool_bar_window))
     mouse_face_overwritten_p
       |= expose_window (XWINDOW (f->tool_bar_window), &r);
@@ -32483,7 +32507,7 @@ expose_frame (struct frame *f, int x, int y, int w, int 
h)
    empty.  */
 
 bool
-x_intersect_rectangles (XRectangle *r1, XRectangle *r2, XRectangle *result)
+gui_intersect_rectangles (XRectangle *r1, XRectangle *r2, XRectangle *result)
 {
   XRectangle *left, *right;
   XRectangle *upper, *lower;
@@ -32894,16 +32918,18 @@ which no explicit name has been set (see 
`modify-frame-parameters').  */);
 This variable has the same structure as `mode-line-format' (which see),
 and is used only on frames for which no explicit name has been set
 \(see `modify-frame-parameters').  */);
+  /* Do not nest calls to pure_list.  This works around a bug in
+     Oracle Developer Studio 12.6.  */
+  Lisp_Object icon_title_name_format
+    = pure_list (empty_unibyte_string,
+                intern_c_string ("invocation-name"),
+                build_pure_c_string ("@"),
+                intern_c_string ("system-name"));
   Vicon_title_format
     = Vframe_title_format
-    = listn (CONSTYPE_PURE, 3,
-            intern_c_string ("multiple-frames"),
-            build_pure_c_string ("%b"),
-            listn (CONSTYPE_PURE, 4,
-                   empty_unibyte_string,
-                   intern_c_string ("invocation-name"),
-                   build_pure_c_string ("@"),
-                   intern_c_string ("system-name")));
+    = pure_list (intern_c_string ("multiple-frames"),
+                build_pure_c_string ("%b"),
+                icon_title_name_format);
 
   DEFVAR_LISP ("message-log-max", Vmessage_log_max,
     doc: /* Maximum number of lines to keep in the message log buffer.
@@ -33050,7 +33076,11 @@ A value of nil means don't automatically resize 
mini-windows.
 A value of t means resize them to fit the text displayed in them.
 A value of `grow-only', the default, means let mini-windows grow only;
 they return to their normal size when the minibuffer is closed, or the
-echo area becomes empty.  */);
+echo area becomes empty.
+
+This variable does not affect resizing of the minibuffer window of
+minibuffer-only frames.  These are handled by 'resize-mini-frames'
+only.  */);
   /* Contrary to the doc string, we initialize this to nil, so that
      loading loadup.el won't try to resize windows before loading
      window.el, where some functions we need to call for this live.
diff --git a/src/xfaces.c b/src/xfaces.c
index 11feaec..7e04c0e 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -1,6 +1,6 @@
 /* xfaces.c -- "Face" primitives.
 
-Copyright (C) 1993-1994, 1998-2018 Free Software Foundation, Inc.
+Copyright (C) 1993-1994, 1998-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -321,11 +321,6 @@ bool face_change;
 
 static bool tty_suppress_bold_inverse_default_colors_p;
 
-/* A list of the form `((x . y))' used to avoid consing in
-   Finternal_set_lisp_face_attribute.  */
-
-static Lisp_Object Vparam_value_alist;
-
 /* The total number of colors currently allocated.  */
 
 #ifdef GLYPH_DEBUG
@@ -343,7 +338,7 @@ struct named_merge_point;
 
 static struct face *realize_face (struct face_cache *, Lisp_Object *,
                                  int);
-static struct face *realize_x_face (struct face_cache *, Lisp_Object *);
+static struct face *realize_gui_face (struct face_cache *, Lisp_Object *);
 static struct face *realize_tty_face (struct face_cache *, Lisp_Object *);
 static bool realize_basic_faces (struct frame *);
 static bool realize_default_face (struct frame *);
@@ -777,13 +772,13 @@ load_pixmap (struct frame *f, Lisp_Object name)
       h = XFIXNUM (Fcar (Fcdr (name)));
       bits = Fcar (Fcdr (Fcdr (name)));
 
-      bitmap_id = x_create_bitmap_from_data (f, SSDATA (bits),
-                                            w, h);
+      bitmap_id = image_create_bitmap_from_data (f, SSDATA (bits),
+                                                 w, h);
     }
   else
     {
       /* It must be a string -- a file name.  */
-      bitmap_id = x_create_bitmap_from_file (f, name);
+      bitmap_id = image_create_bitmap_from_file (f, name);
     }
   unblock_input ();
 
@@ -898,11 +893,11 @@ tty_lookup_color (struct frame *f, Lisp_Object color, 
XColor *tty_color,
     return false;
 }
 
-/* A version of defined_color for non-X frames.  */
+/* An implementation of defined_color_hook for tty frames.  */
 
-static bool
+bool
 tty_defined_color (struct frame *f, const char *color_name,
-                  XColor *color_def, bool alloc)
+                  XColor *color_def, bool alloc, bool _makeIndex)
 {
   bool status = true;
 
@@ -929,36 +924,6 @@ tty_defined_color (struct frame *f, const char *color_name,
   return status;
 }
 
-
-/* Decide if color named COLOR_NAME is valid for the display
-   associated with the frame F; if so, return the rgb values in
-   COLOR_DEF.  If ALLOC, allocate a new colormap cell.
-
-   This does the right thing for any type of frame.  */
-
-static bool
-defined_color (struct frame *f, const char *color_name, XColor *color_def,
-              bool alloc)
-{
-  if (!FRAME_WINDOW_P (f))
-    return tty_defined_color (f, color_name, color_def, alloc);
-#ifdef HAVE_X_WINDOWS
-  else if (FRAME_X_P (f))
-    return x_defined_color (f, color_name, color_def, alloc);
-#endif
-#ifdef HAVE_NTGUI
-  else if (FRAME_W32_P (f))
-    return w32_defined_color (f, color_name, color_def, alloc);
-#endif
-#ifdef HAVE_NS
-  else if (FRAME_NS_P (f))
-    return ns_defined_color (f, color_name, color_def, alloc, true);
-#endif
-  else
-    emacs_abort ();
-}
-
-
 /* Given the index IDX of a tty color on frame F, return its name, a
    Lisp string.  */
 
@@ -1003,7 +968,8 @@ face_color_gray_p (struct frame *f, const char *color_name)
   XColor color;
   bool gray_p;
 
-  if (defined_color (f, color_name, &color, false))
+  if (FRAME_TERMINAL (f)->defined_color_hook
+      (f, color_name, &color, false, true))
     gray_p = (/* Any color sufficiently close to black counts as gray.  */
              (color.red < 5000 && color.green < 5000 && color.blue < 5000)
              ||
@@ -1043,7 +1009,7 @@ face_color_supported_p (struct frame *f, const char 
*color_name,
           && face_color_gray_p (f, color_name)))
     :
 #endif
-    tty_defined_color (f, color_name, &not_used, false);
+    tty_defined_color (f, color_name, &not_used, false, false);
 }
 
 
@@ -1087,9 +1053,10 @@ load_color2 (struct frame *f, struct face *face, 
Lisp_Object name,
           || target_index == LFACE_STRIKE_THROUGH_INDEX
           || target_index == LFACE_BOX_INDEX);
 
-  /* if the color map is full, defined_color will return a best match
+  /* if the color map is full, defined_color_hook will return a best match
      to the values in an existing cell. */
-  if (!defined_color (f, SSDATA (name), color, true))
+  if (!FRAME_TERMINAL (f)->defined_color_hook
+      (f, SSDATA (name), color, true, true))
     {
       add_to_log ("Unable to load color \"%s\"", name);
 
@@ -1157,8 +1124,6 @@ load_color (struct frame *f, struct face *face, 
Lisp_Object name,
 
 #ifdef HAVE_WINDOW_SYSTEM
 
-#define NEAR_SAME_COLOR_THRESHOLD 30000
-
 /* Load colors for face FACE which is used on frame F.  Colors are
    specified by slots LFACE_BACKGROUND_INDEX and LFACE_FOREGROUND_INDEX
    of ATTRS.  If the background color specified is not supported on F,
@@ -1190,7 +1155,7 @@ load_face_colors (struct frame *f, struct face *face,
   if (!face_color_supported_p (f, SSDATA (bg), false)
       && !NILP (Fbitmap_spec_p (Vface_default_stipple)))
     {
-      x_destroy_bitmap (f, face->stipple);
+      image_destroy_bitmap (f, face->stipple);
       face->stipple = load_pixmap (f, Vface_default_stipple);
     }
 
@@ -1199,7 +1164,7 @@ load_face_colors (struct frame *f, struct face *face,
 
   dfg = attrs[LFACE_DISTANT_FOREGROUND_INDEX];
   if (!NILP (dfg) && !UNSPECIFIEDP (dfg)
-      && color_distance (&xbg, &xfg) < NEAR_SAME_COLOR_THRESHOLD)
+      && color_distance (&xbg, &xfg) < face_near_same_color_threshold)
     {
       if (EQ (attrs[LFACE_INVERSE_INDEX], Qt))
         face->background = load_color (f, face, dfg, LFACE_BACKGROUND_INDEX);
@@ -1424,7 +1389,6 @@ the face font sort order.  */)
   Lisp_Object font_spec, list, *drivers, vec;
   struct frame *f = decode_live_frame (frame);
   ptrdiff_t i, nfonts;
-  EMACS_INT ndrivers;
   Lisp_Object result;
   USE_SAFE_ALLOCA;
 
@@ -1457,7 +1421,7 @@ the face font sort order.  */)
   font_props_for_sorting[i++] = FONT_ADSTYLE_INDEX;
   font_props_for_sorting[i++] = FONT_REGISTRY_INDEX;
 
-  ndrivers = XFIXNUM (Flength (list));
+  ptrdiff_t ndrivers = list_length (list);
   SAFE_ALLOCA_LISP (drivers, ndrivers);
   for (i = 0; i < ndrivers; i++, list = XCDR (list))
     drivers[i] = XCAR (list);
@@ -1600,7 +1564,7 @@ the WIDTH times as wide as FACE on FRAME.  */)
     /* We don't have to check fontsets.  */
     return fonts;
   Lisp_Object fontsets = list_fontsets (f, pattern, size);
-  return CALLN (Fnconc, fonts, fontsets);
+  return nconc2 (fonts, fontsets);
 }
 
 #endif /* HAVE_WINDOW_SYSTEM */
@@ -3351,11 +3315,8 @@ FRAME 0 means change the face on all frames, and change 
the default
          else
            /* Update the current frame's parameters.  */
            {
-             Lisp_Object cons;
-             cons = XCAR (Vparam_value_alist);
-             XSETCAR (cons, param);
-             XSETCDR (cons, value);
-             Fmodify_frame_parameters (frame, Vparam_value_alist);
+             AUTO_FRAME_ARG (arg, param, value);
+             Fmodify_frame_parameters (frame, arg);
            }
        }
     }
@@ -3487,8 +3448,8 @@ ordinary `x-get-resource' doesn't take a frame argument.  
*/)
   CHECK_STRING (class);
   f = decode_live_frame (frame);
   block_input ();
-  value = display_x_get_resource (FRAME_DISPLAY_INFO (f),
-                                 resource, class, Qnil, Qnil);
+  value = gui_display_get_resource (FRAME_DISPLAY_INFO (f),
+                                    resource, class, Qnil, Qnil);
   unblock_input ();
   return value;
 }
@@ -4156,7 +4117,7 @@ free_realized_face (struct frame *f, struct face *face)
 #ifdef HAVE_X_WINDOWS
          free_face_colors (f, face);
 #endif /* HAVE_X_WINDOWS */
-         x_destroy_bitmap (f, face->stipple);
+         image_destroy_bitmap (f, face->stipple);
        }
 #endif /* HAVE_WINDOW_SYSTEM */
 
@@ -4191,7 +4152,7 @@ prepare_face_for_display (struct frame *f, struct face 
*face)
       if (face->stipple)
        {
          xgcv.fill_style = FillOpaqueStippled;
-         xgcv.stipple = x_bitmap_pixmap (f, face->stipple);
+         xgcv.stipple = image_bitmap_pixmap (f, face->stipple);
          mask |= GCFillStyle | GCStipple;
        }
 #endif
@@ -4246,23 +4207,27 @@ two lists of the form (RED GREEN BLUE) aforementioned. 
*/)
 
   if (!(CONSP (color1) && parse_rgb_list (color1, &cdef1))
       && !(STRINGP (color1)
-          && defined_color (f, SSDATA (color1), &cdef1, false)))
+           && FRAME_TERMINAL (f)->defined_color_hook (f,
+                                                      SSDATA (color1),
+                                                      &cdef1,
+                                                      false,
+                                                      true)))
     signal_error ("Invalid color", color1);
   if (!(CONSP (color2) && parse_rgb_list (color2, &cdef2))
       && !(STRINGP (color2)
-          && defined_color (f, SSDATA (color2), &cdef2, false)))
+           && FRAME_TERMINAL (f)->defined_color_hook (f,
+                                                      SSDATA (color2),
+                                                      &cdef2,
+                                                      false,
+                                                      true)))
     signal_error ("Invalid color", color2);
 
   if (NILP (metric))
     return make_fixnum (color_distance (&cdef1, &cdef2));
   else
     return call2 (metric,
-                  list3 (make_fixnum (cdef1.red),
-                         make_fixnum (cdef1.green),
-                         make_fixnum (cdef1.blue)),
-                  list3 (make_fixnum (cdef2.red),
-                         make_fixnum (cdef2.green),
-                         make_fixnum (cdef2.blue)));
+                 list3i (cdef1.red, cdef1.green, cdef1.blue),
+                 list3i (cdef2.red, cdef2.green, cdef2.blue));
 }
 
 
@@ -4806,9 +4771,9 @@ DEFUN ("face-attributes-as-vector", 
Fface_attributes_as_vector,
     (2) `close in spirit' to what the attributes specify, if not exact.  */
 
 static bool
-x_supports_face_attributes_p (struct frame *f,
-                             Lisp_Object attrs[LFACE_VECTOR_SIZE],
-                             struct face *def_face)
+gui_supports_face_attributes_p (struct frame *f,
+                                Lisp_Object attrs[LFACE_VECTOR_SIZE],
+                                struct face *def_face)
 {
   Lisp_Object *def_attrs = def_face->lface;
 
@@ -5145,7 +5110,7 @@ face for italic.  */)
     supports = tty_supports_face_attributes_p (f, attrs, def_face);
 #ifdef HAVE_WINDOW_SYSTEM
   else
-    supports = x_supports_face_attributes_p (f, attrs, def_face);
+    supports = gui_supports_face_attributes_p (f, attrs, def_face);
 #endif
 
   return supports ? Qt : Qnil;
@@ -5465,7 +5430,7 @@ realize_default_face (struct frame *f)
         acceptable as a font for the default face (perhaps because
         auto-scaled fonts are rejected), so we must adjust the frame
         font.  */
-      x_set_font (f, LFACE_FONT (lface), Qnil);
+      gui_set_font (f, LFACE_FONT (lface), Qnil);
     }
 #endif
   return true;
@@ -5531,7 +5496,7 @@ realize_face (struct face_cache *cache, Lisp_Object 
attrs[LFACE_VECTOR_SIZE],
     }
 
   if (FRAME_WINDOW_P (cache->f))
-    face = realize_x_face (cache, attrs);
+    face = realize_gui_face (cache, attrs);
   else if (FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f))
     face = realize_tty_face (cache, attrs);
   else if (FRAME_INITIAL_P (cache->f))
@@ -5582,14 +5547,14 @@ realize_non_ascii_face (struct frame *f, Lisp_Object 
font_object,
 
 
 /* Realize the fully-specified face with attributes ATTRS in face
-   cache CACHE for ASCII characters.  Do it for X frame CACHE->f.  If
-   the new face doesn't share font with the default face, a fontname
-   is allocated from the heap and set in `font_name' of the new face,
-   but it is not yet loaded here.  Value is a pointer to the newly
-   created realized face.  */
+   cache CACHE for ASCII characters.  Do it for GUI frame CACHE->f.
+   If the new face doesn't share font with the default face, a
+   fontname is allocated from the heap and set in `font_name' of the
+   new face, but it is not yet loaded here.  Value is a pointer to the
+   newly created realized face.  */
 
 static struct face *
-realize_x_face (struct face_cache *cache, Lisp_Object attrs[LFACE_VECTOR_SIZE])
+realize_gui_face (struct face_cache *cache, Lisp_Object 
attrs[LFACE_VECTOR_SIZE])
 {
   struct face *face = NULL;
 #ifdef HAVE_WINDOW_SYSTEM
@@ -6508,6 +6473,37 @@ DEFUN ("show-face-resources", Fshow_face_resources, 
Sshow_face_resources,
                            Initialization
  ***********************************************************************/
 
+#ifdef HAVE_PDUMPER
+/* All the faces defined during loadup are recorded in
+   face-new-frame-defaults, with the last face first in the list.  We
+   need to set next_lface_id to the next face ID number, so that any
+   new faces defined in this session will have face IDs different from
+   those defined during loadup.  We also need to set up the
+   lface_id_to_name[] array for the faces that were defined during
+   loadup.  */
+void
+init_xfaces (void)
+{
+  if (CONSP (Vface_new_frame_defaults))
+    {
+      /* Allocate the lface_id_to_name[] array.  */
+      lface_id_to_name_size = next_lface_id =
+       XFIXNAT (Flength (Vface_new_frame_defaults));
+      lface_id_to_name = xnmalloc (next_lface_id, sizeof *lface_id_to_name);
+
+      /* Store the faces.  */
+      Lisp_Object tail;
+      int i = next_lface_id - 1;
+      for (tail = Vface_new_frame_defaults; CONSP (tail); tail = XCDR (tail))
+       {
+         Lisp_Object lface = XCAR (tail);
+         eassert (i >= 0);
+         lface_id_to_name[i--] = XCAR (lface);
+       }
+    }
+}
+#endif
+
 void
 syms_of_xfaces (void)
 {
@@ -6609,8 +6605,6 @@ syms_of_xfaces (void)
   /* The name of the function used to compute colors on TTYs.  */
   DEFSYM (Qtty_color_alist, "tty-color-alist");
 
-  Vparam_value_alist = list1 (Fcons (Qnil, Qnil));
-  staticpro (&Vparam_value_alist);
   Vface_alternative_font_family_alist = Qnil;
   staticpro (&Vface_alternative_font_family_alist);
   Vface_alternative_font_registry_alist = Qnil;
@@ -6769,6 +6763,20 @@ RESCALE-RATIO is a floating point number to specify how 
much larger
 a font of 10 point, we actually use a font of 10 * RESCALE-RATIO point.  */);
   Vface_font_rescale_alist = Qnil;
 
+  DEFVAR_INT ("face-near-same-color-threshold", face_near_same_color_threshold,
+             doc: /* Threshold for using distant-foreground color instead of 
foreground.
+
+The value should be an integer number providing the minimum distance
+between two colors that will still qualify them to be used as foreground
+and background.  If the value of `color-distance', invoked with a nil
+METRIC argument, for the foreground and background colors of a face is
+less than this threshold, the distant-foreground color, if defined,
+will be used for the face instead of the foreground color.
+
+Lisp programs that change the value of this variable should also
+clear the face cache, see `clear-face-cache'.  */);
+  face_near_same_color_threshold = 30000;
+
 #ifdef HAVE_WINDOW_SYSTEM
   defsubr (&Sbitmap_spec_p);
   defsubr (&Sx_list_fonts);
diff --git a/src/xfns.c b/src/xfns.c
index de177bf..2ceb55a 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1,6 +1,6 @@
 /* Functions for the X window system.
 
-Copyright (C) 1989, 1992-2018 Free Software Foundation, Inc.
+Copyright (C) 1989, 1992-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -653,7 +653,7 @@ gamma_correct (struct frame *f, XColor *color)
 
 bool
 x_defined_color (struct frame *f, const char *color_name,
-                XColor *color, bool alloc_p)
+                XColor *color, bool alloc_p, bool _makeIndex)
 {
   bool success_p = false;
   Colormap cmap = FRAME_X_COLORMAP (f);
@@ -698,7 +698,7 @@ x_decode_color (struct frame *f, Lisp_Object color_name, 
int mono_color)
 
   /* x_defined_color is responsible for coping with failures
      by looking for a near-miss.  */
-  if (x_defined_color (f, SSDATA (color_name), &cdef, true))
+  if (x_defined_color (f, SSDATA (color_name), &cdef, true, false))
     return cdef.pixel;
 
   signal_error ("Undefined color", color_name);
@@ -978,7 +978,7 @@ xg_set_icon (struct frame *f, Lisp_Object file)
   bool result = false;
   Lisp_Object found;
 
-  found = x_find_image_file (file);
+  found = image_find_image_file (file);
 
   if (! NILP (found))
     {
@@ -1021,7 +1021,7 @@ xg_set_icon_from_xpm_data (struct frame *f, const char 
**data)
 #endif /* USE_GTK */
 
 
-/* Functions called only from `x_set_frame_param'
+/* Functions called only from `gui_set_frame_parameters'
    to set individual parameters.
 
    If FRAME_X_WINDOW (f) is 0,
@@ -1388,8 +1388,8 @@ x_set_cursor_color (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
 
       if (FRAME_VISIBLE_P (f))
        {
-         x_update_cursor (f, false);
-         x_update_cursor (f, true);
+         gui_update_cursor (f, false);
+         gui_update_cursor (f, true);
        }
     }
 
@@ -1466,7 +1466,7 @@ x_set_icon_type (struct frame *f, Lisp_Object arg, 
Lisp_Object oldval)
                                   ? f->icon_name
                                   : f->name)));
   else
-    result = x_bitmap_icon (f, arg);
+    result = FRAME_TERMINAL (f)->set_bitmap_icon_hook (f, arg);
 
   if (result)
     {
@@ -2115,7 +2115,8 @@ x_default_scroll_bar_color_parameter (struct frame *f,
   struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
   Lisp_Object tem;
 
-  tem = x_get_arg (dpyinfo, alist, prop, xprop, xclass, RES_TYPE_STRING);
+  tem = gui_display_get_arg (dpyinfo, alist, prop, xprop, xclass,
+                             RES_TYPE_STRING);
   if (EQ (tem, Qunbound))
     {
 #ifdef USE_TOOLKIT_SCROLL_BARS
@@ -2125,7 +2126,7 @@ x_default_scroll_bar_color_parameter (struct frame *f,
       AUTO_STRING (foreground, "foreground");
       AUTO_STRING (background, "foreground");
       AUTO_STRING (verticalScrollBar, "verticalScrollBar");
-      tem = (display_x_get_resource
+      tem = (gui_display_get_resource
             (dpyinfo, foreground_p ? foreground : background,
              empty_unibyte_string,
              verticalScrollBar,
@@ -2148,7 +2149,7 @@ x_default_scroll_bar_color_parameter (struct frame *f,
     }
 
   AUTO_FRAME_ARG (arg, prop, tem);
-  x_set_frame_parameters (f, arg);
+  gui_set_frame_parameters (f, arg);
   return tem;
 }
 
@@ -3257,8 +3258,8 @@ x_icon_verify (struct frame *f, Lisp_Object parms)
 
   /* Set the position of the icon.  Note that twm groups all
      icons in an icon window.  */
-  icon_x = x_frame_get_and_record_arg (f, parms, Qicon_left, 0, 0, 
RES_TYPE_NUMBER);
-  icon_y = x_frame_get_and_record_arg (f, parms, Qicon_top, 0, 0, 
RES_TYPE_NUMBER);
+  icon_x = gui_frame_get_and_record_arg (f, parms, Qicon_left, 0, 0, 
RES_TYPE_NUMBER);
+  icon_y = gui_frame_get_and_record_arg (f, parms, Qicon_top, 0, 0, 
RES_TYPE_NUMBER);
   if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound))
     {
       CHECK_FIXNUM (icon_x);
@@ -3278,9 +3279,9 @@ x_icon (struct frame *f, Lisp_Object parms)
   /* Set the position of the icon.  Note that twm groups all
      icons in an icon window.  */
   Lisp_Object icon_x
-    = x_frame_get_and_record_arg (f, parms, Qicon_left, 0, 0, RES_TYPE_NUMBER);
+    = gui_frame_get_and_record_arg (f, parms, Qicon_left, 0, 0, 
RES_TYPE_NUMBER);
   Lisp_Object icon_y
-    = x_frame_get_and_record_arg (f, parms, Qicon_top, 0, 0, RES_TYPE_NUMBER);
+    = gui_frame_get_and_record_arg (f, parms, Qicon_top, 0, 0, 
RES_TYPE_NUMBER);
   if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound))
     {
       CHECK_TYPE_RANGED_INTEGER (int, icon_x);
@@ -3294,12 +3295,13 @@ x_icon (struct frame *f, Lisp_Object parms)
   if (! EQ (icon_x, Qunbound))
     x_wm_set_icon_position (f, XFIXNUM (icon_x), XFIXNUM (icon_y));
 
-#if false /* x_get_arg removes the visibility parameter as a side effect,
-            but x_create_frame still needs it.  */
+#if false /* gui_display_get_arg removes the visibility parameter as a
+            side effect, but x_create_frame still needs it.  */
   /* Start up iconic or window? */
   struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
   x_wm_set_window_state
-    (f, (EQ (x_get_arg (dpyinfo, parms, Qvisibility, 0, 0, RES_TYPE_SYMBOL),
+    (f, (EQ (gui_display_get_arg (dpyinfo, parms, Qvisibility, 0, 0,
+                                  RES_TYPE_SYMBOL),
             Qicon)
         ? IconicState
         : NormalState));
@@ -3407,7 +3409,7 @@ x_free_gcs (struct frame *f)
 
 
 /* Handler for signals raised during x_create_frame and
-   x_create_tip_frame.  FRAME is the frame which is partially
+   Fx_create_tip_frame.  FRAME is the frame which is partially
    constructed.  */
 
 static Lisp_Object
@@ -3417,7 +3419,7 @@ unwind_create_frame (Lisp_Object frame)
 
   /* If frame is already dead, nothing to do.  This can happen if the
      display is disconnected after the frame has become official, but
-     before x_create_frame removes the unwind protect.  */
+     before Fx_create_frame removes the unwind protect.  */
   if (!FRAME_LIVE_P (f))
     return Qnil;
 
@@ -3463,8 +3465,8 @@ static void
 x_default_font_parameter (struct frame *f, Lisp_Object parms)
 {
   struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
-  Lisp_Object font_param = x_get_arg (dpyinfo, parms, Qfont, NULL, NULL,
-                                      RES_TYPE_STRING);
+  Lisp_Object font_param = gui_display_get_arg (dpyinfo, parms, Qfont, NULL, 
NULL,
+                                                RES_TYPE_STRING);
   Lisp_Object font = Qnil;
   if (EQ (font_param, Qunbound))
     font_param = Qnil;
@@ -3481,13 +3483,14 @@ x_default_font_parameter (struct frame *f, Lisp_Object 
parms)
 
   if (NILP (font))
       font = !NILP (font_param) ? font_param
-      : x_get_arg (dpyinfo, parms, Qfont, "font", "Font", RES_TYPE_STRING);
+      : gui_display_get_arg (dpyinfo, parms, Qfont, "font", "Font",
+                             RES_TYPE_STRING);
 
   if (! FONTP (font) && ! STRINGP (font))
     {
       const char *names[]
        = {
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
            /* This will find the normal Xft font.  */
            "monospace-10",
 #endif
@@ -3518,11 +3521,11 @@ x_default_font_parameter (struct frame *f, Lisp_Object 
parms)
       /* Remember the explicit font parameter, so we can re-apply it after
         we've applied the `default' face settings.  */
       AUTO_FRAME_ARG (arg, Qfont_parameter, font_param);
-      x_set_frame_parameters (f, arg);
+      gui_set_frame_parameters (f, arg);
     }
 
   /* This call will make X resources override any system font setting.  */
-  x_default_parameter (f, parms, Qfont, font, "font", "Font", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qfont, font, "font", "Font", 
RES_TYPE_STRING);
 }
 
 
@@ -3592,9 +3595,11 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
      until we know if this frame has a specified name.  */
   Vx_resource_name = Vinvocation_name;
 
-  display = x_get_arg (dpyinfo, parms, Qterminal, 0, 0, RES_TYPE_NUMBER);
+  display = gui_display_get_arg (dpyinfo, parms, Qterminal, 0, 0,
+                                 RES_TYPE_NUMBER);
   if (EQ (display, Qunbound))
-    display = x_get_arg (dpyinfo, parms, Qdisplay, 0, 0, RES_TYPE_STRING);
+    display = gui_display_get_arg (dpyinfo, parms, Qdisplay, 0, 0,
+                                   RES_TYPE_STRING);
   if (EQ (display, Qunbound))
     display = Qnil;
   dpyinfo = check_x_display_info (display);
@@ -3603,7 +3608,8 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   if (!dpyinfo->terminal->name)
     error ("Terminal is not live, can't create new frames on it");
 
-  name = x_get_arg (dpyinfo, parms, Qname, "name", "Name", RES_TYPE_STRING);
+  name = gui_display_get_arg (dpyinfo, parms, Qname, "name", "Name",
+                              RES_TYPE_STRING);
   if (!STRINGP (name)
       && ! EQ (name, Qunbound)
       && ! NILP (name))
@@ -3613,15 +3619,17 @@ This function is an internal primitive--use 
`make-frame' instead.  */)
     Vx_resource_name = name;
 
   /* See if parent window is specified.  */
-  parent = x_get_arg (dpyinfo, parms, Qparent_id, NULL, NULL, RES_TYPE_NUMBER);
+  parent = gui_display_get_arg (dpyinfo, parms, Qparent_id, NULL, NULL,
+                                RES_TYPE_NUMBER);
   if (EQ (parent, Qunbound))
     parent = Qnil;
   if (! NILP (parent))
     CHECK_FIXNUM (parent);
 
   frame = Qnil;
-  tem = x_get_arg (dpyinfo, parms, Qminibuffer, "minibuffer", "Minibuffer",
-                  RES_TYPE_SYMBOL);
+  tem = gui_display_get_arg (dpyinfo,
+                             parms, Qminibuffer, "minibuffer", "Minibuffer",
+                             RES_TYPE_SYMBOL);
   if (EQ (tem, Qnone) || NILP (tem))
     f = make_frame_without_minibuffer (Qnil, kb, display);
   else if (EQ (tem, Qonly))
@@ -3634,8 +3642,12 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   else
     f = make_frame (true);
 
-  parent_frame = x_get_arg (dpyinfo, parms, Qparent_frame, NULL, NULL,
-                           RES_TYPE_SYMBOL);
+  parent_frame = gui_display_get_arg (dpyinfo,
+                                      parms,
+                                      Qparent_frame,
+                                      NULL,
+                                      NULL,
+                                      RES_TYPE_SYMBOL);
   /* Accept parent-frame iff parent-id was not specified.  */
   if (!NILP (parent)
       || EQ (parent_frame, Qunbound)
@@ -3648,16 +3660,24 @@ This function is an internal primitive--use 
`make-frame' instead.  */)
   fset_parent_frame (f, parent_frame);
   store_frame_param (f, Qparent_frame, parent_frame);
 
-  if (!NILP (tem = (x_get_arg (dpyinfo, parms, Qundecorated, NULL, NULL,
-                              RES_TYPE_BOOLEAN)))
+  if (!NILP (tem = (gui_display_get_arg (dpyinfo,
+                                         parms,
+                                         Qundecorated,
+                                         NULL,
+                                         NULL,
+                                         RES_TYPE_BOOLEAN)))
       && !(EQ (tem, Qunbound)))
     undecorated = true;
 
   FRAME_UNDECORATED (f) = undecorated;
   store_frame_param (f, Qundecorated, undecorated ? Qt : Qnil);
 
-  if (!NILP (tem = (x_get_arg (dpyinfo, parms, Qoverride_redirect, NULL, NULL,
-                              RES_TYPE_BOOLEAN)))
+  if (!NILP (tem = (gui_display_get_arg (dpyinfo,
+                                         parms,
+                                         Qoverride_redirect,
+                                         NULL,
+                                         NULL,
+                                         RES_TYPE_BOOLEAN)))
       && !(EQ (tem, Qunbound)))
     override_redirect = true;
 
@@ -3681,9 +3701,12 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   f->output_data.x->white_relief.pixel = -1;
   f->output_data.x->black_relief.pixel = -1;
 
-  fset_icon_name (f,
-                 x_get_arg (dpyinfo, parms, Qicon_name, "iconName", "Title",
-                            RES_TYPE_STRING));
+  fset_icon_name (f, gui_display_get_arg (dpyinfo,
+                                          parms,
+                                          Qicon_name,
+                                          "iconName",
+                                          "Title",
+                                          RES_TYPE_STRING));
   if (! STRINGP (f->icon_name))
     fset_icon_name (f, Qnil);
 
@@ -3768,8 +3791,8 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   dpyinfo_refcount = dpyinfo->reference_count;
 #endif /* GLYPH_DEBUG */
 
-  x_default_parameter (f, parms, Qfont_backend, Qnil,
-                      "fontBackend", "FontBackend", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qfont_backend, Qnil,
+                         "fontBackend", "FontBackend", RES_TYPE_STRING);
 
   /* Extract the window parameters from the supplied values
      that are needed to determine window geometry.  */
@@ -3782,8 +3805,8 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
 
   /* Frame contents get displaced if an embedded X window has a border.  */
   if (! FRAME_X_EMBEDDED_P (f))
-    x_default_parameter (f, parms, Qborder_width, make_fixnum (0),
-                        "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
+    gui_default_parameter (f, parms, Qborder_width, make_fixnum (0),
+                           "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
 
   /* This defaults to 1 in order to match xterm.  We recognize either
      internalBorderWidth or internalBorder (which is what xterm calls
@@ -3792,54 +3815,55 @@ This function is an internal primitive--use 
`make-frame' instead.  */)
     {
       Lisp_Object value;
 
-      value = x_get_arg (dpyinfo, parms, Qinternal_border_width,
-                        "internalBorder", "internalBorder", RES_TYPE_NUMBER);
+      value = gui_display_get_arg (dpyinfo, parms, Qinternal_border_width,
+                                   "internalBorder", "internalBorder",
+                                   RES_TYPE_NUMBER);
       if (! EQ (value, Qunbound))
        parms = Fcons (Fcons (Qinternal_border_width, value),
                       parms);
     }
-  x_default_parameter (f, parms, Qinternal_border_width,
+  gui_default_parameter (f, parms, Qinternal_border_width,
 #ifdef USE_GTK /* We used to impose 0 in xg_create_frame_widgets.  */
-                      make_fixnum (0),
+                         make_fixnum (0),
 #else
-                      make_fixnum (1),
+                         make_fixnum (1),
 #endif
-                      "internalBorderWidth", "internalBorderWidth",
-                      RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qright_divider_width, make_fixnum (0),
-                      NULL, NULL, RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qbottom_divider_width, make_fixnum (0),
-                      NULL, NULL, RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qvertical_scroll_bars,
+                         "internalBorderWidth", "internalBorderWidth",
+                         RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qright_divider_width, make_fixnum (0),
+                         NULL, NULL, RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qbottom_divider_width, make_fixnum (0),
+                         NULL, NULL, RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qvertical_scroll_bars,
 #if defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS)
-                      Qright,
+                         Qright,
 #else
-                      Qleft,
+                         Qleft,
 #endif
-                      "verticalScrollBars", "ScrollBars",
-                      RES_TYPE_SYMBOL);
-  x_default_parameter (f, parms, Qhorizontal_scroll_bars, Qnil,
-                      "horizontalScrollBars", "ScrollBars",
-                      RES_TYPE_SYMBOL);
+                         "verticalScrollBars", "ScrollBars",
+                         RES_TYPE_SYMBOL);
+  gui_default_parameter (f, parms, Qhorizontal_scroll_bars, Qnil,
+                         "horizontalScrollBars", "ScrollBars",
+                         RES_TYPE_SYMBOL);
   /* Also do the stuff which must be set before the window exists.  */
-  x_default_parameter (f, parms, Qforeground_color, build_string ("black"),
-                      "foreground", "Foreground", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qbackground_color, build_string ("white"),
-                      "background", "Background", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qmouse_color, build_string ("black"),
-                      "pointerColor", "Foreground", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qborder_color, build_string ("black"),
-                      "borderColor", "BorderColor", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qscreen_gamma, Qnil,
-                      "screenGamma", "ScreenGamma", RES_TYPE_FLOAT);
-  x_default_parameter (f, parms, Qline_spacing, Qnil,
-                      "lineSpacing", "LineSpacing", RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qleft_fringe, Qnil,
-                      "leftFringe", "LeftFringe", RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qright_fringe, Qnil,
-                      "rightFringe", "RightFringe", RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qno_special_glyphs, Qnil,
-                      NULL, NULL, RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parms, Qforeground_color, build_string ("black"),
+                         "foreground", "Foreground", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qbackground_color, build_string ("white"),
+                         "background", "Background", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qmouse_color, build_string ("black"),
+                         "pointerColor", "Foreground", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qborder_color, build_string ("black"),
+                         "borderColor", "BorderColor", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qscreen_gamma, Qnil,
+                         "screenGamma", "ScreenGamma", RES_TYPE_FLOAT);
+  gui_default_parameter (f, parms, Qline_spacing, Qnil,
+                         "lineSpacing", "LineSpacing", RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qleft_fringe, Qnil,
+                         "leftFringe", "LeftFringe", RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qright_fringe, Qnil,
+                         "rightFringe", "RightFringe", RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qno_special_glyphs, Qnil,
+                         NULL, NULL, RES_TYPE_BOOLEAN);
 
   x_default_scroll_bar_color_parameter (f, parms, Qscroll_bar_foreground,
                                        "scrollBarForeground",
@@ -3848,7 +3872,7 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
                                        "scrollBarBackground",
                                        "ScrollBarBackground", false);
 
-  /* Init faces before x_default_parameter is called for the
+  /* Init faces before gui_default_parameter is called for the
      scroll-bar-width parameter because otherwise we end up in
      init_iterator with a null face cache, which should not happen.  */
   init_frame_faces (f);
@@ -3865,10 +3889,12 @@ This function is an internal primitive--use 
`make-frame' instead.  */)
 
      Also process `min-width' and `min-height' parameters right here
      because `frame-windows-min-size' needs them.  */
-  tem = x_get_arg (dpyinfo, parms, Qmin_width, NULL, NULL, RES_TYPE_NUMBER);
+  tem = gui_display_get_arg (dpyinfo, parms, Qmin_width, NULL, NULL,
+                             RES_TYPE_NUMBER);
   if (FIXNUMP (tem))
     store_frame_param (f, Qmin_width, tem);
-  tem = x_get_arg (dpyinfo, parms, Qmin_height, NULL, NULL, RES_TYPE_NUMBER);
+  tem = gui_display_get_arg (dpyinfo, parms, Qmin_height, NULL, NULL,
+                             RES_TYPE_NUMBER);
   if (FIXNUMP (tem))
     store_frame_param (f, Qmin_height, tem);
   adjust_frame_size (f, FRAME_COLS (f) * FRAME_COLUMN_WIDTH (f),
@@ -3880,32 +3906,34 @@ This function is an internal primitive--use 
`make-frame' instead.  */)
      here; they are processed specially at startup, and reflected in
      the values of the mode variables.  */
 
-  x_default_parameter (f, parms, Qmenu_bar_lines,
-                      NILP (Vmenu_bar_mode)
-                      ? make_fixnum (0) : make_fixnum (1),
-                      NULL, NULL, RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qtool_bar_lines,
-                      NILP (Vtool_bar_mode)
-                      ? make_fixnum (0) : make_fixnum (1),
-                      NULL, NULL, RES_TYPE_NUMBER);
-
-  x_default_parameter (f, parms, Qbuffer_predicate, Qnil,
-                      "bufferPredicate", "BufferPredicate",
-                      RES_TYPE_SYMBOL);
-  x_default_parameter (f, parms, Qtitle, Qnil,
-                      "title", "Title", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qwait_for_wm, Qt,
-                      "waitForWM", "WaitForWM", RES_TYPE_BOOLEAN);
-  x_default_parameter (f, parms, Qtool_bar_position,
-                       FRAME_TOOL_BAR_POSITION (f), 0, 0, RES_TYPE_SYMBOL);
-  x_default_parameter (f, parms, Qinhibit_double_buffering, Qnil,
-                       "inhibitDoubleBuffering", "InhibitDoubleBuffering",
-                       RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parms, Qmenu_bar_lines,
+                         NILP (Vmenu_bar_mode)
+                         ? make_fixnum (0) : make_fixnum (1),
+                         NULL, NULL, RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qtool_bar_lines,
+                         NILP (Vtool_bar_mode)
+                         ? make_fixnum (0) : make_fixnum (1),
+                         NULL, NULL, RES_TYPE_NUMBER);
+
+  gui_default_parameter (f, parms, Qbuffer_predicate, Qnil,
+                         "bufferPredicate", "BufferPredicate",
+                         RES_TYPE_SYMBOL);
+  gui_default_parameter (f, parms, Qtitle, Qnil,
+                         "title", "Title", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qwait_for_wm, Qt,
+                         "waitForWM", "WaitForWM", RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parms, Qtool_bar_position,
+                         FRAME_TOOL_BAR_POSITION (f), 0, 0, RES_TYPE_SYMBOL);
+  gui_default_parameter (f, parms, Qinhibit_double_buffering, Qnil,
+                         "inhibitDoubleBuffering", "InhibitDoubleBuffering",
+                         RES_TYPE_BOOLEAN);
 
   /* Compute the size of the X window.  */
-  window_prompting = x_figure_window_size (f, parms, true, &x_width, 
&x_height);
+  window_prompting = gui_figure_window_size (f, parms, true,
+                                             &x_width, &x_height);
 
-  tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
+  tem = gui_display_get_arg (dpyinfo, parms, Qunsplittable, 0, 0,
+                             RES_TYPE_BOOLEAN);
   f->no_split = minibuffer_only || EQ (tem, Qt);
 
   x_icon_verify (f, parms);
@@ -3927,23 +3955,23 @@ This function is an internal primitive--use 
`make-frame' instead.  */)
 
   /* We need to do this after creating the X window, so that the
      icon-creation functions can say whose icon they're describing.  */
-  x_default_parameter (f, parms, Qicon_type, Qt,
-                      "bitmapIcon", "BitmapIcon", RES_TYPE_BOOLEAN);
-
-  x_default_parameter (f, parms, Qauto_raise, Qnil,
-                      "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
-  x_default_parameter (f, parms, Qauto_lower, Qnil,
-                      "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
-  x_default_parameter (f, parms, Qcursor_type, Qbox,
-                      "cursorType", "CursorType", RES_TYPE_SYMBOL);
-  x_default_parameter (f, parms, Qscroll_bar_width, Qnil,
-                      "scrollBarWidth", "ScrollBarWidth",
-                      RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qscroll_bar_height, Qnil,
-                      "scrollBarHeight", "ScrollBarHeight",
-                      RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qalpha, Qnil,
-                      "alpha", "Alpha", RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qicon_type, Qt,
+                         "bitmapIcon", "BitmapIcon", RES_TYPE_BOOLEAN);
+
+  gui_default_parameter (f, parms, Qauto_raise, Qnil,
+                         "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parms, Qauto_lower, Qnil,
+                         "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parms, Qcursor_type, Qbox,
+                         "cursorType", "CursorType", RES_TYPE_SYMBOL);
+  gui_default_parameter (f, parms, Qscroll_bar_width, Qnil,
+                         "scrollBarWidth", "ScrollBarWidth",
+                         RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qscroll_bar_height, Qnil,
+                         "scrollBarHeight", "ScrollBarHeight",
+                         RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qalpha, Qnil,
+                         "alpha", "Alpha", RES_TYPE_NUMBER);
 
   if (!NILP (parent_frame))
     {
@@ -3955,10 +3983,10 @@ This function is an internal primitive--use 
`make-frame' instead.  */)
       unblock_input ();
     }
 
-  x_default_parameter (f, parms, Qno_focus_on_map, Qnil,
-                      NULL, NULL, RES_TYPE_BOOLEAN);
-  x_default_parameter (f, parms, Qno_accept_focus, Qnil,
-                      NULL, NULL, RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parms, Qno_focus_on_map, Qnil,
+                         NULL, NULL, RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parms, Qno_accept_focus, Qnil,
+                         NULL, NULL, RES_TYPE_BOOLEAN);
 
 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
   /* Create the menu bar.  */
@@ -3979,7 +4007,7 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
 #endif /* USE_X_TOOLKIT || USE_GTK */
 
   /* Consider frame official, now.  */
-  f->can_x_set_window_size = true;
+  f->can_set_window_size = true;
 
   if (x_width > 0)
     SET_FRAME_WIDTH (f, x_width);
@@ -3999,8 +4027,8 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   /* Process fullscreen parameter here in the hope that normalizing a
      fullheight/fullwidth frame will produce the size set by the last
      adjust_frame_size call.  */
-  x_default_parameter (f, parms, Qfullscreen, Qnil,
-                      "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
+  gui_default_parameter (f, parms, Qfullscreen, Qnil,
+                         "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
 
   /* Make the window appear on the frame and enable display, unless
      the caller says not to.  However, with explicit parent, Emacs
@@ -4008,7 +4036,8 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
   if (!f->output_data.x->explicit_parent)
     {
       Lisp_Object visibility
-       = x_get_arg (dpyinfo, parms, Qvisibility, 0, 0, RES_TYPE_SYMBOL);
+       = gui_display_get_arg (dpyinfo, parms, Qvisibility, 0, 0,
+                               RES_TYPE_SYMBOL);
 
       if (EQ (visibility, Qicon))
        x_iconify_frame (f);
@@ -4043,11 +4072,11 @@ This function is an internal primitive--use 
`make-frame' instead.  */)
   unblock_input ();
 
   /* Works iff frame has been already mapped.  */
-  x_default_parameter (f, parms, Qskip_taskbar, Qnil,
-                      NULL, NULL, RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parms, Qskip_taskbar, Qnil,
+                         NULL, NULL, RES_TYPE_BOOLEAN);
   /* The `z-group' parameter works only for visible frames.  */
-  x_default_parameter (f, parms, Qz_group, Qnil,
-                      NULL, NULL, RES_TYPE_SYMBOL);
+  gui_default_parameter (f, parms, Qz_group, Qnil,
+                         NULL, NULL, RES_TYPE_SYMBOL);
 
   /* Initialize `default-minibuffer-frame' in case this is the first
      frame on this terminal.  */
@@ -4056,8 +4085,9 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
           || !FRAME_LIVE_P (XFRAME (KVAR (kb, Vdefault_minibuffer_frame)))))
     kset_default_minibuffer_frame (kb, frame);
 
-  /* All remaining specified parameters, which have not been "used"
-     by x_get_arg and friends, now go in the misc. alist of the frame.  */
+  /* All remaining specified parameters, which have not been "used" by
+     gui_display_get_arg and friends, now go in the misc. alist of the
+     frame.  */
   for (tem = parms; CONSP (tem); tem = XCDR (tem))
     if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem))))
       fset_param_alist (f, Fcons (XCAR (tem), f->param_alist));
@@ -4069,60 +4099,6 @@ This function is an internal primitive--use `make-frame' 
instead.  */)
  return unbind_to (count, frame);
 }
 
-
-/* FRAME is used only to get a handle on the X display.  We don't pass the
-   display info directly because we're called from frame.c, which doesn't
-   know about that structure.  */
-
-Lisp_Object
-x_get_focus_frame (struct frame *frame)
-{
-  struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (frame);
-  Lisp_Object xfocus;
-  if (! dpyinfo->x_focus_frame)
-    return Qnil;
-
-  XSETFRAME (xfocus, dpyinfo->x_focus_frame);
-  return xfocus;
-}
-
-
-/* In certain situations, when the window manager follows a
-   click-to-focus policy, there seems to be no way around calling
-   XSetInputFocus to give another frame the input focus .
-
-   In an ideal world, XSetInputFocus should generally be avoided so
-   that applications don't interfere with the window manager's focus
-   policy.  But I think it's okay to use when it's clearly done
-   following a user-command.  */
-
-void
-x_focus_frame (struct frame *f, bool noactivate)
-{
-  Display *dpy = FRAME_X_DISPLAY (f);
-
-  block_input ();
-  x_catch_errors (dpy);
-
-  if (FRAME_X_EMBEDDED_P (f))
-    {
-      /* For Xembedded frames, normally the embedder forwards key
-        events.  See XEmbed Protocol Specification at
-        http://freedesktop.org/wiki/Specifications/xembed-spec  */
-      xembed_request_focus (f);
-    }
-  else
-    {
-      XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-                     RevertToParent, CurrentTime);
-      if (!noactivate)
-       x_ewmh_activate_frame (f);
-    }
-
-  x_uncatch_errors ();
-  unblock_input ();
-}
-
 
 DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
        doc: /* Internal function called by `color-defined-p'.
@@ -4134,7 +4110,7 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, 
Sxw_color_defined_p, 1, 2, 0,
 
   CHECK_STRING (color);
 
-  if (x_defined_color (f, SSDATA (color), &foo, false))
+  if (x_defined_color (f, SSDATA (color), &foo, false, false))
     return Qt;
   else
     return Qnil;
@@ -4150,7 +4126,7 @@ DEFUN ("xw-color-values", Fxw_color_values, 
Sxw_color_values, 1, 2, 0,
 
   CHECK_STRING (color);
 
-  if (x_defined_color (f, SSDATA (color), &foo, false))
+  if (x_defined_color (f, SSDATA (color), &foo, false, false))
     return list3i (foo.red, foo.green, foo.blue);
   else
     return Qnil;
@@ -4496,7 +4472,7 @@ On MS Windows, this just returns nil.  */)
    Return false if and only if the workarea information cannot be
    obtained via the _NET_WORKAREA root window property.  */
 
-#if ! GTK_CHECK_VERSION (3, 4, 0)
+#ifndef HAVE_GTK3
 static bool
 x_get_net_workarea (struct x_display_info *dpyinfo, XRectangle *rect)
 {
@@ -4583,7 +4559,7 @@ x_get_monitor_for_frame (struct frame *f,
 
       if (mi->geom.width == 0) continue;
 
-      if (x_intersect_rectangles (&mi->geom, &frect, &res))
+      if (gui_intersect_rectangles (&mi->geom, &frect, &res))
         {
           a = res.width * res.height;
           if (a > area)
@@ -4712,7 +4688,7 @@ x_get_monitor_attributes_xinerama (struct x_display_info 
*dpyinfo)
       if (i == 0 && x_get_net_workarea (dpyinfo, &workarea_r))
        {
          mi->work = workarea_r;
-         if (! x_intersect_rectangles (&mi->geom, &mi->work, &mi->work))
+         if (! gui_intersect_rectangles (&mi->geom, &mi->work, &mi->work))
            mi->work = mi->geom;
        }
       else
@@ -4816,7 +4792,7 @@ x_get_monitor_attributes_xrandr (struct x_display_info 
*dpyinfo)
           if (i == primary && x_get_net_workarea (dpyinfo, &workarea_r))
             {
               mi->work= workarea_r;
-              if (! x_intersect_rectangles (&mi->geom, &mi->work, &mi->work))
+              if (! gui_intersect_rectangles (&mi->geom, &mi->work, &mi->work))
                 mi->work = mi->geom;
             }
           else
@@ -4906,9 +4882,9 @@ Internal use only, use `display-monitor-attributes-list' 
instead.  */)
   Lisp_Object attributes_list = Qnil;
 
 #ifdef USE_GTK
-  double mm_width_per_pixel, mm_height_per_pixel;
   GdkDisplay *gdpy;
 #if ! GTK_CHECK_VERSION (3, 22, 0)
+  double mm_width_per_pixel, mm_height_per_pixel;
   GdkScreen *gscreen;
 #endif
   gint primary_monitor = 0, n_monitors, i;
@@ -4917,19 +4893,18 @@ Internal use only, use 
`display-monitor-attributes-list' instead.  */)
   struct MonitorInfo *monitors;
 
   block_input ();
-  mm_width_per_pixel = ((double) WidthMMOfScreen (dpyinfo->screen)
-                       / x_display_pixel_width (dpyinfo));
-  mm_height_per_pixel = ((double) HeightMMOfScreen (dpyinfo->screen)
-                        / x_display_pixel_height (dpyinfo));
   gdpy = gdk_x11_lookup_xdisplay (dpyinfo->display);
 #if GTK_CHECK_VERSION (3, 22, 0)
   n_monitors = gdk_display_get_n_monitors (gdpy);
 #else
   gscreen = gdk_display_get_default_screen (gdpy);
-#if GTK_CHECK_VERSION (2, 20, 0)
-  primary_monitor = gdk_screen_get_primary_monitor (gscreen);
-#endif
   n_monitors = gdk_screen_get_n_monitors (gscreen);
+  primary_monitor = gdk_screen_get_primary_monitor (gscreen);
+  /* Fallback if gdk_screen_get_monitor_{width,height}_mm fail */
+  mm_width_per_pixel = ((double) WidthMMOfScreen (dpyinfo->screen)
+                       / x_display_pixel_width (dpyinfo));
+  mm_height_per_pixel = ((double) HeightMMOfScreen (dpyinfo->screen)
+                        / x_display_pixel_height (dpyinfo));
 #endif
   monitor_frames = make_nil_vector (n_monitors);
   monitors = xzalloc (n_monitors * sizeof *monitors);
@@ -4958,7 +4933,7 @@ Internal use only, use `display-monitor-attributes-list' 
instead.  */)
 
   for (i = 0; i < n_monitors; ++i)
     {
-      gint width_mm = -1, height_mm = -1;
+      gint width_mm, height_mm;
       GdkRectangle rec, work;
       struct MonitorInfo *mi = &monitors[i];
       int scale = 1;
@@ -4975,18 +4950,17 @@ Internal use only, use 
`display-monitor-attributes-list' instead.  */)
 #if GTK_CHECK_VERSION (3, 22, 0)
       width_mm = gdk_monitor_get_width_mm (monitor);
       height_mm = gdk_monitor_get_height_mm (monitor);
-#elif GTK_CHECK_VERSION (2, 14, 0)
+#else
       width_mm = gdk_screen_get_monitor_width_mm (gscreen, i);
       height_mm = gdk_screen_get_monitor_height_mm (gscreen, i);
-#endif
       if (width_mm < 0)
        width_mm = rec.width * mm_width_per_pixel + 0.5;
       if (height_mm < 0)
        height_mm = rec.height * mm_height_per_pixel + 0.5;
-
+#endif
 #if GTK_CHECK_VERSION (3, 22, 0)
       gdk_monitor_get_workarea (monitor, &work);
-#elif GTK_CHECK_VERSION (3, 4, 0)
+#elif defined HAVE_GTK3
       gdk_screen_get_monitor_workarea (gscreen, i, &work);
 #else
       /* Emulate the behavior of GTK+ 3.4.  */
@@ -5010,7 +4984,7 @@ Internal use only, use `display-monitor-attributes-list' 
instead.  */)
       /* GTK returns scaled sizes for the workareas.  */
 #if GTK_CHECK_VERSION (3, 22, 0)
       scale = gdk_monitor_get_scale_factor (monitor);
-#elif GTK_CHECK_VERSION (3, 10, 0)
+#elif defined HAVE_GTK3
       scale = gdk_screen_get_monitor_scale_factor (gscreen, i);
 #endif
       rec.width *= scale;
@@ -5030,8 +5004,8 @@ Internal use only, use `display-monitor-attributes-list' 
instead.  */)
       mi->mm_height = height_mm;
 
 #if GTK_CHECK_VERSION (3, 22, 0)
-      mi->name = g_strdup (gdk_monitor_get_model (monitor));
-#elif GTK_CHECK_VERSION (2, 14, 0)
+      dupstring (&mi->name, (gdk_monitor_get_model (monitor)));
+#else
       mi->name = gdk_screen_get_monitor_plug_name (gscreen, i);
 #endif
     }
@@ -5041,6 +5015,7 @@ Internal use only, use `display-monitor-attributes-list' 
instead.  */)
                                                  primary_monitor,
                                                  monitor_frames,
                                                  source);
+  free_monitors (monitors, n_monitors);
   unblock_input ();
 #else  /* not USE_GTK */
 
@@ -5132,7 +5107,7 @@ frame_geometry (Lisp_Object frame, Lisp_Object attribute)
   inner_right = native_right - internal_border_width;
   inner_bottom = native_bottom - internal_border_width;
 
-#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
+#ifdef HAVE_EXT_MENU_BAR
   menu_bar_external = true;
   menu_bar_height = FRAME_MENUBAR_HEIGHT (f);
   native_top += menu_bar_height;
@@ -5143,7 +5118,7 @@ frame_geometry (Lisp_Object frame, Lisp_Object attribute)
 #endif
   menu_bar_width = menu_bar_height ? native_width : 0;
 
-#if defined (USE_GTK)
+#ifdef HAVE_EXT_TOOL_BAR
   tool_bar_external = true;
   if (EQ (FRAME_TOOL_BAR_POSITION (f), Qleft))
     {
@@ -5185,18 +5160,14 @@ frame_geometry (Lisp_Object frame, Lisp_Object 
attribute)
 
   /* Construct list.  */
   if (EQ (attribute, Qouter_edges))
-    return list4 (make_fixnum (outer_left), make_fixnum (outer_top),
-                 make_fixnum (outer_right), make_fixnum (outer_bottom));
+    return list4i (outer_left, outer_top, outer_right, outer_bottom);
   else if (EQ (attribute, Qnative_edges))
-    return list4 (make_fixnum (native_left), make_fixnum (native_top),
-                 make_fixnum (native_right), make_fixnum (native_bottom));
+    return list4i (native_left, native_top, native_right, native_bottom);
   else if (EQ (attribute, Qinner_edges))
-    return list4 (make_fixnum (inner_left), make_fixnum (inner_top),
-                 make_fixnum (inner_right), make_fixnum (inner_bottom));
+    return list4i (inner_left, inner_top, inner_right, inner_bottom);
   else
     return
-      listn (CONSTYPE_HEAP, 11,
-            Fcons (Qouter_position,
+       list (Fcons (Qouter_position,
                    Fcons (make_fixnum (outer_left),
                           make_fixnum (outer_top))),
             Fcons (Qouter_size,
@@ -5379,7 +5350,7 @@ Frames are listed from topmost (first) to bottommost 
(last).  */)
 static void
 x_frame_restack (struct frame *f1, struct frame *f2, bool above_flag)
 {
-#if defined (USE_GTK) && GTK_CHECK_VERSION (2, 18, 0)
+#ifdef USE_GTK
   block_input ();
   xg_frame_restack (f1, f2, above_flag);
   unblock_input ();
@@ -5534,8 +5505,8 @@ select_visual (struct x_display_info *dpyinfo)
   /* See if a visual is specified.  */
   AUTO_STRING (visualClass, "visualClass");
   AUTO_STRING (VisualClass, "VisualClass");
-  Lisp_Object value = display_x_get_resource (dpyinfo, visualClass,
-                                             VisualClass, Qnil, Qnil);
+  Lisp_Object value = gui_display_get_resource (dpyinfo, visualClass,
+                                                VisualClass, Qnil, Qnil);
 
   if (STRINGP (value))
     {
@@ -6121,7 +6092,7 @@ unwind_create_tip_frame (Lisp_Object frame)
    PARMS is a list of frame parameters.  TEXT is the string to
    display in the tip frame.  Value is the frame.
 
-   Note that functions called here, esp. x_default_parameter can
+   Note that functions called here, esp. gui_default_parameter can
    signal errors, for instance when a specified color name is
    undefined.  We have to make sure that we're in a consistent state
    when this happens.  */
@@ -6143,7 +6114,8 @@ x_create_tip_frame (struct x_display_info *dpyinfo, 
Lisp_Object parms)
   parms = Fcopy_alist (parms);
 
   /* Get the name of the frame to use for resource lookup.  */
-  name = x_get_arg (dpyinfo, parms, Qname, "name", "Name", RES_TYPE_STRING);
+  name = gui_display_get_arg (dpyinfo, parms, Qname, "name", "Name",
+                              RES_TYPE_STRING);
   if (!STRINGP (name)
       && !EQ (name, Qunbound)
       && !NILP (name))
@@ -6244,15 +6216,15 @@ x_create_tip_frame (struct x_display_info *dpyinfo, 
Lisp_Object parms)
   dpyinfo_refcount = dpyinfo->reference_count;
 #endif /* GLYPH_DEBUG */
 
-  x_default_parameter (f, parms, Qfont_backend, Qnil,
-                      "fontBackend", "FontBackend", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qfont_backend, Qnil,
+                         "fontBackend", "FontBackend", RES_TYPE_STRING);
 
   /* Extract the window parameters from the supplied values that are
      needed to determine window geometry.  */
   x_default_font_parameter (f, parms);
 
-  x_default_parameter (f, parms, Qborder_width, make_fixnum (0),
-                      "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qborder_width, make_fixnum (0),
+                         "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
 
   /* This defaults to 2 in order to match xterm.  We recognize either
      internalBorderWidth or internalBorder (which is what xterm calls
@@ -6261,43 +6233,44 @@ x_create_tip_frame (struct x_display_info *dpyinfo, 
Lisp_Object parms)
     {
       Lisp_Object value;
 
-      value = x_get_arg (dpyinfo, parms, Qinternal_border_width,
-                        "internalBorder", "internalBorder", RES_TYPE_NUMBER);
+      value = gui_display_get_arg (dpyinfo, parms, Qinternal_border_width,
+                                   "internalBorder", "internalBorder",
+                                   RES_TYPE_NUMBER);
       if (! EQ (value, Qunbound))
        parms = Fcons (Fcons (Qinternal_border_width, value),
                       parms);
     }
 
-  x_default_parameter (f, parms, Qinternal_border_width, make_fixnum (1),
-                      "internalBorderWidth", "internalBorderWidth",
-                      RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qright_divider_width, make_fixnum (0),
-                      NULL, NULL, RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qbottom_divider_width, make_fixnum (0),
-                      NULL, NULL, RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qinternal_border_width, make_fixnum (1),
+                         "internalBorderWidth", "internalBorderWidth",
+                         RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qright_divider_width, make_fixnum (0),
+                         NULL, NULL, RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qbottom_divider_width, make_fixnum (0),
+                         NULL, NULL, RES_TYPE_NUMBER);
 
   /* Also do the stuff which must be set before the window exists.  */
-  x_default_parameter (f, parms, Qforeground_color, build_string ("black"),
-                      "foreground", "Foreground", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qbackground_color, build_string ("white"),
-                      "background", "Background", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qmouse_color, build_string ("black"),
-                      "pointerColor", "Foreground", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qcursor_color, build_string ("black"),
-                      "cursorColor", "Foreground", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qborder_color, build_string ("black"),
-                      "borderColor", "BorderColor", RES_TYPE_STRING);
-  x_default_parameter (f, parms, Qno_special_glyphs, Qnil,
-                      NULL, NULL, RES_TYPE_BOOLEAN);
-
-  /* Init faces before x_default_parameter is called for the
+  gui_default_parameter (f, parms, Qforeground_color, build_string ("black"),
+                         "foreground", "Foreground", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qbackground_color, build_string ("white"),
+                         "background", "Background", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qmouse_color, build_string ("black"),
+                         "pointerColor", "Foreground", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qcursor_color, build_string ("black"),
+                         "cursorColor", "Foreground", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qborder_color, build_string ("black"),
+                         "borderColor", "BorderColor", RES_TYPE_STRING);
+  gui_default_parameter (f, parms, Qno_special_glyphs, Qnil,
+                         NULL, NULL, RES_TYPE_BOOLEAN);
+
+  /* Init faces before gui_default_parameter is called for the
      scroll-bar-width parameter because otherwise we end up in
      init_iterator with a null face cache, which should not happen.  */
   init_frame_faces (f);
 
   f->output_data.x->parent_desc = FRAME_DISPLAY_INFO (f)->root_window;
 
-  x_figure_window_size (f, parms, false, &x_width, &x_height);
+  gui_figure_window_size (f, parms, false, &x_width, &x_height);
 
   {
     XSetWindowAttributes attrs;
@@ -6340,14 +6313,14 @@ x_create_tip_frame (struct x_display_info *dpyinfo, 
Lisp_Object parms)
 
   x_make_gc (f);
 
-  x_default_parameter (f, parms, Qauto_raise, Qnil,
-                      "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
-  x_default_parameter (f, parms, Qauto_lower, Qnil,
-                      "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
-  x_default_parameter (f, parms, Qcursor_type, Qbox,
-                      "cursorType", "CursorType", RES_TYPE_SYMBOL);
-  x_default_parameter (f, parms, Qalpha, Qnil,
-                      "alpha", "Alpha", RES_TYPE_NUMBER);
+  gui_default_parameter (f, parms, Qauto_raise, Qnil,
+                         "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parms, Qauto_lower, Qnil,
+                         "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
+  gui_default_parameter (f, parms, Qcursor_type, Qbox,
+                         "cursorType", "CursorType", RES_TYPE_SYMBOL);
+  gui_default_parameter (f, parms, Qalpha, Qnil,
+                         "alpha", "Alpha", RES_TYPE_NUMBER);
 
   /* Dimensions, especially FRAME_LINES (f), must be done via 
change_frame_size.
      Change will not be effected unless different from the current
@@ -6418,7 +6391,7 @@ x_create_tip_frame (struct x_display_info *dpyinfo, 
Lisp_Object parms)
      below.  And the frame needs to be on Vframe_list or making it
      visible won't work.  */
   Vframe_list = Fcons (frame, Vframe_list);
-  f->can_x_set_window_size = true;
+  f->can_set_window_size = true;
 
   /* Setting attributes of faces of the tooltip frame from resources
      and similar will set face_change, which leads to the clearing of
@@ -7604,41 +7577,41 @@ visible.  */)
 
 frame_parm_handler x_frame_parm_handlers[] =
 {
-  x_set_autoraise,
-  x_set_autolower,
+  gui_set_autoraise,
+  gui_set_autolower,
   x_set_background_color,
   x_set_border_color,
-  x_set_border_width,
+  gui_set_border_width,
   x_set_cursor_color,
   x_set_cursor_type,
-  x_set_font,
+  gui_set_font,
   x_set_foreground_color,
   x_set_icon_name,
   x_set_icon_type,
   x_set_internal_border_width,
-  x_set_right_divider_width,
-  x_set_bottom_divider_width,
+  gui_set_right_divider_width,
+  gui_set_bottom_divider_width,
   x_set_menu_bar_lines,
   x_set_mouse_color,
   x_explicitly_set_name,
-  x_set_scroll_bar_width,
-  x_set_scroll_bar_height,
+  gui_set_scroll_bar_width,
+  gui_set_scroll_bar_height,
   x_set_title,
-  x_set_unsplittable,
-  x_set_vertical_scroll_bars,
-  x_set_horizontal_scroll_bars,
-  x_set_visibility,
+  gui_set_unsplittable,
+  gui_set_vertical_scroll_bars,
+  gui_set_horizontal_scroll_bars,
+  gui_set_visibility,
   x_set_tool_bar_lines,
   x_set_scroll_bar_foreground,
   x_set_scroll_bar_background,
-  x_set_screen_gamma,
-  x_set_line_spacing,
-  x_set_left_fringe,
-  x_set_right_fringe,
+  gui_set_screen_gamma,
+  gui_set_line_spacing,
+  gui_set_left_fringe,
+  gui_set_right_fringe,
   x_set_wait_for_wm,
-  x_set_fullscreen,
-  x_set_font_backend,
-  x_set_alpha,
+  gui_set_fullscreen,
+  gui_set_font_backend,
+  gui_set_alpha,
   x_set_sticky,
   x_set_tool_bar_position,
   x_set_inhibit_double_buffering,
@@ -7649,7 +7622,7 @@ frame_parm_handler x_frame_parm_handlers[] =
   x_set_no_accept_focus,
   x_set_z_group,
   x_set_override_redirect,
-  x_set_no_special_glyphs,
+  gui_set_no_special_glyphs,
 };
 
 void
@@ -7675,7 +7648,7 @@ syms_of_xfns (void)
 #endif
 
   Fput (Qundefined_color, Qerror_conditions,
-       listn (CONSTYPE_PURE, 2, Qundefined_color, Qerror));
+       pure_list (Qundefined_color, Qerror));
   Fput (Qundefined_color, Qerror_message,
        build_pure_c_string ("Undefined color"));
 
diff --git a/src/xfont.c b/src/xfont.c
index 02976f6..5ecbd6d 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -1,5 +1,5 @@
 /* xfont.c -- X core font driver.
-   Copyright (C) 2006-2018 Free Software Foundation, Inc.
+   Copyright (C) 2006-2019 Free Software Foundation, Inc.
    Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H13PRO009
@@ -31,6 +31,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "character.h"
 #include "charset.h"
 #include "font.h"
+#include "pdumper.h"
 
 
 /* X core font driver.  */
@@ -131,7 +132,7 @@ compare_font_names (const void *name1, const void *name2)
 
 /* Decode XLFD as iso-8859-1 into OUTPUT, and return the byte length
    of the decoding result.  LEN is the byte length of XLFD, or -1 if
-   XLFD is NULL terminated.  The caller must assure that OUTPUT is at
+   XLFD is NUL terminated.  The caller must assure that OUTPUT is at
    least twice (plus 1) as large as XLFD.  */
 
 static ptrdiff_t
@@ -1077,6 +1078,7 @@ xfont_check (struct frame *f, struct font *font)
 }
 
 
+static void syms_of_xfont_for_pdumper (void);
 
 struct font_driver const xfont_driver =
   {
@@ -1102,5 +1104,11 @@ syms_of_xfont (void)
   xfont_scripts_cache = CALLN (Fmake_hash_table, QCtest, Qequal);
   staticpro (&xfont_scratch_props);
   xfont_scratch_props = make_nil_vector (8);
+  pdumper_do_now_and_after_load (syms_of_xfont_for_pdumper);
+}
+
+static void
+syms_of_xfont_for_pdumper (void)
+{
   register_font_driver (&xfont_driver, NULL);
 }
diff --git a/src/xftfont.c b/src/xftfont.c
index 6531929..b636a75 100644
--- a/src/xftfont.c
+++ b/src/xftfont.c
@@ -1,5 +1,5 @@
 /* xftfont.c -- XFT font driver.
-   Copyright (C) 2006-2018 Free Software Foundation, Inc.
+   Copyright (C) 2006-2019 Free Software Foundation, Inc.
    Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H13PRO009
@@ -32,6 +32,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "composite.h"
 #include "font.h"
 #include "ftfont.h"
+#include "pdumper.h"
 
 /* Xft font driver.  */
 
@@ -738,6 +739,8 @@ xftfont_cached_font_ok (struct frame *f, Lisp_Object 
font_object,
   return ok;
 }
 
+static void syms_of_xftfont_for_pdumper (void);
+
 struct font_driver const xftfont_driver =
   {
     /* We can't draw a text without device dependent functions.  */
@@ -789,7 +792,11 @@ syms_of_xftfont (void)
 This is needed with some fonts to correct vertical overlap of glyphs.  */);
   xft_font_ascent_descent_override = 0;
 
-  ascii_printable[0] = 0;
+  pdumper_do_now_and_after_load (syms_of_xftfont_for_pdumper);
+}
 
+static void
+syms_of_xftfont_for_pdumper (void)
+{
   register_font_driver (&xftfont_driver, NULL);
 }
diff --git a/src/xgselect.c b/src/xgselect.c
index fedd312..9982a1f 100644
--- a/src/xgselect.c
+++ b/src/xgselect.c
@@ -1,6 +1,6 @@
 /* Function for handling the GLib event loop.
 
-Copyright (C) 2009-2018 Free Software Foundation, Inc.
+Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/xgselect.h b/src/xgselect.h
index a2728c6..92c79c5 100644
--- a/src/xgselect.h
+++ b/src/xgselect.h
@@ -1,6 +1,6 @@
 /* Header for xg_select.
 
-Copyright (C) 2009-2018 Free Software Foundation, Inc.
+Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/xmenu.c b/src/xmenu.c
index 31034f7..22d1cc2 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -1,6 +1,6 @@
 /* X Communication module for terminals which understand the X protocol.
 
-Copyright (C) 1986, 1988, 1993-1994, 1996, 1999-2018 Free Software
+Copyright (C) 1986, 1988, 1993-1994, 1996, 1999-2019 Free Software
 Foundation, Inc.
 
 Author: Jon Arnold
@@ -45,6 +45,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "buffer.h"
 #include "coding.h"
 #include "sysselect.h"
+#include "pdumper.h"
 
 #ifdef MSDOS
 #include "msdos.h"
@@ -143,7 +144,7 @@ x_menu_set_in_use (bool in_use)
 {
   Lisp_Object frames, frame;
 
-  menu_items_inuse = in_use ? Qt : Qnil;
+  menu_items_inuse = in_use;
   popup_activated_flag = in_use;
 #ifdef USE_X_TOOLKIT
   if (popup_activated_flag)
@@ -2401,15 +2402,12 @@ DEFUN ("menu-or-popup-active-p", 
Fmenu_or_popup_active_p, Smenu_or_popup_active_
   return (popup_activated ()) ? Qt : Qnil;
 }
 
+
+static void syms_of_xmenu_for_pdumper (void);
+
 void
 syms_of_xmenu (void)
 {
-#ifdef USE_X_TOOLKIT
-  enum { WIDGET_ID_TICK_START = 1 << 16 };
-  widget_id_tick = WIDGET_ID_TICK_START;
-  next_menubar_widget_id = 1;
-#endif
-
   DEFSYM (Qdebug_on_next_call, "debug-on-next-call");
   defsubr (&Smenu_or_popup_active_p);
 
@@ -2422,4 +2420,16 @@ syms_of_xmenu (void)
   Ffset (intern_c_string ("accelerate-menu"),
         intern_c_string (Sx_menu_bar_open_internal.s.symbol_name));
 #endif
+
+  pdumper_do_now_and_after_load (syms_of_xmenu_for_pdumper);
+}
+
+static void
+syms_of_xmenu_for_pdumper (void)
+{
+#ifdef USE_X_TOOLKIT
+  enum { WIDGET_ID_TICK_START = 1 << 16 };
+  widget_id_tick = WIDGET_ID_TICK_START;
+  next_menubar_widget_id = 1;
+#endif
 }
diff --git a/src/xml.c b/src/xml.c
index e85891d..60bd958 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -1,5 +1,5 @@
 /* Interface to libxml2.
-   Copyright (C) 2010-2018 Free Software Foundation, Inc.
+   Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/xrdb.c b/src/xrdb.c
index 87c2faf..9c625e9 100644
--- a/src/xrdb.c
+++ b/src/xrdb.c
@@ -1,5 +1,5 @@
 /* Deal with the X Resource Manager.
-   Copyright (C) 1990, 1993-1994, 2000-2018 Free Software Foundation,
+   Copyright (C) 1990, 1993-1994, 2000-2019 Free Software Foundation,
    Inc.
 
 Author: Joseph Arceneaux
@@ -60,12 +60,12 @@ x_get_customization_string (XrmDatabase db, const char 
*name,
 {
   char *full_name = alloca (strlen (name) + sizeof "customization" + 3);
   char *full_class = alloca (strlen (class) + sizeof "Customization" + 3);
-  char *result;
+  const char *result;
 
   sprintf (full_name,  "%s.%s", name,  "customization");
   sprintf (full_class, "%s.%s", class, "Customization");
 
-  result = x_get_string_resource (db, full_name, full_class);
+  result = x_get_string_resource (&db, full_name, full_class);
   return result ? xstrdup (result) : NULL;
 }
 
@@ -383,7 +383,7 @@ x_load_resources (Display *display, const char *xrm_string,
   XrmDatabase db;
   char line[256];
 
-#if defined USE_MOTIF || !defined HAVE_XFT || !defined USE_LUCID
+#if defined USE_MOTIF || !(defined USE_CAIRO || defined HAVE_XFT) || !defined 
USE_LUCID
   const char *helv = "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1";
 #endif
 
@@ -456,7 +456,7 @@ x_load_resources (Display *display, const char *xrm_string,
 
   sprintf (line, "Emacs.dialog*.background: grey75");
   XrmPutLineResource (&rdb, line);
-#if !defined (HAVE_XFT) || !defined (USE_LUCID)
+#if !(defined USE_CAIRO || defined HAVE_XFT) || !defined (USE_LUCID)
   sprintf (line, "Emacs.dialog*.font: %s", helv);
   XrmPutLineResource (&rdb, line);
   sprintf (line, "*XlwMenu*font: %s", helv);
@@ -547,19 +547,20 @@ x_get_resource (XrmDatabase rdb, const char *name, const 
char *class,
 /* Retrieve the string resource specified by NAME with CLASS from
    database RDB. */
 
-char *
-x_get_string_resource (XrmDatabase rdb, const char *name, const char *class)
+const char *
+x_get_string_resource (void *v_rdb, const char *name, const char *class)
 {
+  XrmDatabase *rdb = v_rdb;
   XrmValue value;
 
   if (inhibit_x_resources)
     /* --quick was passed, so this is a no-op.  */
     return NULL;
 
-  if (x_get_resource (rdb, name, class, x_rm_string, &value))
-    return (char *) value.addr;
+  if (x_get_resource (*rdb, name, class, x_rm_string, &value))
+    return (const char *) value.addr;
 
-  return 0;
+  return NULL;
 }
 
 /* Stand-alone test facilities.  */
@@ -648,7 +649,7 @@ main (int argc, char **argv)
          printf ("Class: ");
          gets (query_class);
 
-         value = x_get_string_resource (xdb, query_name, query_class);
+         value = x_get_string_resource (&xdb, query_name, query_class);
 
          if (value != NULL)
            printf ("\t%s(%s):  %s\n\n", query_name, query_class, value);
diff --git a/src/xselect.c b/src/xselect.c
index e1f353b..5f0bb44 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -1,5 +1,5 @@
 /* X Selection processing for Emacs.
-   Copyright (C) 1993-1997, 2000-2018 Free Software Foundation, Inc.
+   Copyright (C) 1993-1997, 2000-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -35,6 +35,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "blockinput.h"
 #include "termhooks.h"
 #include "keyboard.h"
+#include "pdumper.h"
 
 #include <X11/Xproto.h>
 
@@ -1084,10 +1085,10 @@ wait_for_property_change (struct prop_location 
*location)
      property_change_reply, because property_change_reply_object says so.  */
   if (! location->arrived)
     {
-      EMACS_INT timeout = max (0, x_selection_timeout);
-      EMACS_INT secs = timeout / 1000;
+      intmax_t timeout = max (0, x_selection_timeout);
+      intmax_t secs = timeout / 1000;
       int nsecs = (timeout % 1000) * 1000000;
-      TRACE2 ("  Waiting %"pI"d secs, %d nsecs", secs, nsecs);
+      TRACE2 ("  Waiting %"PRIdMAX" secs, %d nsecs", secs, nsecs);
       wait_reading_process_output (secs, nsecs, 0, false,
                                   property_change_reply, NULL, 0);
 
@@ -1157,8 +1158,6 @@ x_get_foreign_selection (Lisp_Object selection_symbol, 
Lisp_Object target_type,
   Atom type_atom = (CONSP (target_type)
                    ? symbol_to_x_atom (dpyinfo, XCAR (target_type))
                    : symbol_to_x_atom (dpyinfo, target_type));
-  EMACS_INT timeout, secs;
-  int nsecs;
 
   if (!FRAME_LIVE_P (f))
     return Qnil;
@@ -1194,10 +1193,10 @@ x_get_foreign_selection (Lisp_Object selection_symbol, 
Lisp_Object target_type,
   unblock_input ();
 
   /* This allows quits.  Also, don't wait forever.  */
-  timeout = max (0, x_selection_timeout);
-  secs = timeout / 1000;
-  nsecs = (timeout % 1000) * 1000000;
-  TRACE1 ("  Start waiting %"pI"d secs for SelectionNotify", secs);
+  intmax_t timeout = max (0, x_selection_timeout);
+  intmax_t secs = timeout / 1000;
+  int nsecs = (timeout % 1000) * 1000000;
+  TRACE1 ("  Start waiting %"PRIdMAX" secs for SelectionNotify", secs);
   wait_reading_process_output (secs, nsecs, 0, false,
                               reading_selection_reply, NULL, 0);
   TRACE1 ("  Got event = %d", !NILP (XCAR (reading_selection_reply)));
@@ -2613,6 +2612,9 @@ x_send_client_event (Lisp_Object display, Lisp_Object 
dest, Lisp_Object from,
 }
 
 
+
+static void syms_of_xselect_for_pdumper (void);
+
 void
 syms_of_xselect (void)
 {
@@ -2628,17 +2630,9 @@ syms_of_xselect (void)
 
   reading_selection_reply = Fcons (Qnil, Qnil);
   staticpro (&reading_selection_reply);
-  reading_selection_window = 0;
-  reading_which_selection = 0;
 
-  property_change_wait_list = 0;
-  prop_location_identifier = 0;
-  property_change_reply = Fcons (Qnil, Qnil);
   staticpro (&property_change_reply);
 
-  converted_selections = NULL;
-  conversion_fail_tag = None;
-
   /* FIXME: Duplicate definition in nsselect.c.  */
   DEFVAR_LISP ("selection-converter-alist", Vselection_converter_alist,
               doc: /* An alist associating X Windows selection-types with 
functions.
@@ -2717,4 +2711,18 @@ A value of 0 means wait as long as necessary.  This is 
initialized from the
   DEFSYM (Qforeign_selection, "foreign-selection");
   DEFSYM (Qx_lost_selection_functions, "x-lost-selection-functions");
   DEFSYM (Qx_sent_selection_functions, "x-sent-selection-functions");
+
+  pdumper_do_now_and_after_load (syms_of_xselect_for_pdumper);
+}
+
+static void
+syms_of_xselect_for_pdumper (void)
+{
+  reading_selection_window = 0;
+  reading_which_selection = 0;
+  property_change_wait_list = 0;
+  prop_location_identifier = 0;
+  property_change_reply = Fcons (Qnil, Qnil);
+  converted_selections = NULL;
+  conversion_fail_tag = None;
 }
diff --git a/src/xsettings.c b/src/xsettings.c
index 0b67db3..3e9012e 100644
--- a/src/xsettings.c
+++ b/src/xsettings.c
@@ -1,6 +1,6 @@
 /* Functions for handling font and other changes dynamically.
 
-Copyright (C) 2009-2018 Free Software Foundation, Inc.
+Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -32,6 +32,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "keyboard.h"
 #include "blockinput.h"
 #include "termhooks.h"
+#include "pdumper.h"
 
 #include <X11/Xproto.h>
 
@@ -44,9 +45,13 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include <gconf/gconf-client.h>
 #endif
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
+#ifdef USE_CAIRO
+#include <fontconfig/fontconfig.h>
+#else  /* HAVE_XFT */
 #include <X11/Xft/Xft.h>
 #endif
+#endif
 
 static char *current_mono_font;
 static char *current_font;
@@ -82,7 +87,7 @@ dpyinfo_valid (struct x_display_info *dpyinfo)
 
 /* Store a monospace font change event if the monospaced font changed.  */
 
-#if defined HAVE_XFT && (defined HAVE_GSETTINGS || defined HAVE_GCONF)
+#if (defined USE_CAIRO || defined HAVE_XFT) && (defined HAVE_GSETTINGS || 
defined HAVE_GCONF)
 static void
 store_monospaced_changed (const char *newfont)
 {
@@ -101,7 +106,7 @@ store_monospaced_changed (const char *newfont)
 
 /* Store a font name change event if the font name changed.  */
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
 static void
 store_font_name_changed (const char *newfont)
 {
@@ -116,7 +121,7 @@ store_font_name_changed (const char *newfont)
                                   XCAR (first_dpyinfo->name_list_element));
     }
 }
-#endif /* HAVE_XFT */
+#endif /* USE_CAIRO || HAVE_XFT */
 
 /* Map TOOL_BAR_STYLE from a string to its corresponding Lisp value.
    Return Qnil if TOOL_BAR_STYLE is not known.  */
@@ -156,7 +161,7 @@ store_tool_bar_style_changed (const char *newstyle,
                                 XCAR (dpyinfo->name_list_element));
 }
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
 #define XSETTINGS_FONT_NAME       "Gtk/FontName"
 #endif
 #define XSETTINGS_TOOL_BAR_STYLE  "Gtk/ToolbarStyle"
@@ -173,7 +178,7 @@ enum {
 };
 struct xsettings
 {
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   FcBool aa, hinting;
   int rgba, lcdfilter, hintstyle;
   double dpi;
@@ -190,7 +195,7 @@ struct xsettings
 #define GSETTINGS_SCHEMA         "org.gnome.desktop.interface"
 #define GSETTINGS_TOOL_BAR_STYLE "toolbar-style"
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
 #define GSETTINGS_MONO_FONT  "monospace-font-name"
 #define GSETTINGS_FONT_NAME  "font-name"
 #endif
@@ -223,7 +228,7 @@ something_changed_gsettingsCB (GSettings *settings,
           g_variant_unref (val);
         }
     }
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   else if (strcmp (key, GSETTINGS_MONO_FONT) == 0)
     {
       val = g_settings_get_value (settings, GSETTINGS_MONO_FONT);
@@ -252,14 +257,14 @@ something_changed_gsettingsCB (GSettings *settings,
           g_variant_unref (val);
         }
     }
-#endif /* HAVE_XFT */
+#endif /* USE_CAIRO || HAVE_XFT */
 }
 
 #endif /* HAVE_GSETTINGS */
 
 #ifdef HAVE_GCONF
 #define GCONF_TOOL_BAR_STYLE "/desktop/gnome/interface/toolbar_style"
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
 #define GCONF_MONO_FONT  "/desktop/gnome/interface/monospace_font_name"
 #define GCONF_FONT_NAME  "/desktop/gnome/interface/font_name"
 #endif
@@ -285,7 +290,7 @@ something_changed_gconfCB (GConfClient *client,
       const char *value = gconf_value_get_string (v);
       store_tool_bar_style_changed (value, first_dpyinfo);
     }
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   else if (strcmp (key, GCONF_MONO_FONT) == 0)
     {
       const char *value = gconf_value_get_string (v);
@@ -296,12 +301,12 @@ something_changed_gconfCB (GConfClient *client,
       const char *value = gconf_value_get_string (v);
       store_font_name_changed (value);
     }
-#endif /* HAVE_XFT */
+#endif /* USE_CAIRO || HAVE_XFT */
 }
 
 #endif /* HAVE_GCONF */
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
 
 /* Older fontconfig versions don't have FC_LCD_*.  */
 #ifndef FC_LCD_NONE
@@ -314,7 +319,7 @@ something_changed_gconfCB (GConfClient *client,
 #define FC_LCD_FILTER "lcdfilter"
 #endif
 
-#endif /* HAVE_XFT */
+#endif /* USE_CAIRO || HAVE_XFT */
 
 /* Find the window that contains the XSETTINGS property values.  */
 
@@ -392,8 +397,8 @@ parse_settings (unsigned char *prop,
                 unsigned long bytes,
                 struct xsettings *settings)
 {
-  Lisp_Object byteorder = Fbyteorder ();
-  int my_bo = XFIXNAT (byteorder) == 'B' ? MSBFirst : LSBFirst;
+  int int1 = 1;
+  int my_bo = *(char *) &int1 == 1 ? LSBFirst : MSBFirst;
   int that_bo = prop[0];
   CARD32 n_settings;
   int bytes_parsed = 0;
@@ -439,7 +444,7 @@ parse_settings (unsigned char *prop,
       if (bytes_parsed > bytes) return settings_seen;
 
       want_this = strcmp (XSETTINGS_TOOL_BAR_STYLE, name) == 0;
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
       if ((nlen > 6 && memcmp (name, "Xft/", 4) == 0)
          || strcmp (XSETTINGS_FONT_NAME, name) == 0)
        want_this = true;
@@ -489,7 +494,7 @@ parse_settings (unsigned char *prop,
               dupstring (&settings->tb_style, sval);
               settings->seen |= SEEN_TB_STYLE;
             }
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
           else if (strcmp (name, XSETTINGS_FONT_NAME) == 0)
             {
               dupstring (&settings->font, sval);
@@ -552,7 +557,7 @@ parse_settings (unsigned char *prop,
               else
                 settings->seen &= ~SEEN_LCDFILTER;
             }
-#endif /* HAVE_XFT */
+#endif /* USE_CAIRO || HAVE_XFT */
          else
            want_this = false;
          settings_seen += want_this;
@@ -603,16 +608,18 @@ static void
 apply_xft_settings (struct x_display_info *dpyinfo,
                     struct xsettings *settings)
 {
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   FcPattern *pat;
   struct xsettings oldsettings;
   bool changed = false;
 
   memset (&oldsettings, 0, sizeof (oldsettings));
   pat = FcPatternCreate ();
+#ifdef HAVE_XFT
   XftDefaultSubstitute (dpyinfo->display,
                         XScreenNumberOfScreen (dpyinfo->screen),
                         pat);
+#endif
   FcPatternGetBool (pat, FC_ANTIALIAS, 0, &oldsettings.aa);
   FcPatternGetBool (pat, FC_HINTING, 0, &oldsettings.hinting);
 #ifdef FC_HINT_STYLE
@@ -712,7 +719,9 @@ apply_xft_settings (struct x_display_info *dpyinfo,
       };
       char buf[sizeof format + d_formats * d_growth + lf_formats * lf_growth];
 
+#ifdef HAVE_XFT
       XftDefaultSet (dpyinfo->display, pat);
+#endif
       store_config_changed_event (Qfont_render,
                                  XCAR (dpyinfo->name_list_element));
       Vxft_settings
@@ -724,7 +733,7 @@ apply_xft_settings (struct x_display_info *dpyinfo,
     }
   else
     FcPatternDestroy (pat);
-#endif /* HAVE_XFT */
+#endif /* USE_CAIRO || HAVE_XFT */
 }
 
 /* Read XSettings from the display for DPYINFO.
@@ -747,7 +756,7 @@ read_and_apply_settings (struct x_display_info *dpyinfo, 
bool send_event_p)
         current_tool_bar_style = map_tool_bar_style (settings.tb_style);
       xfree (settings.tb_style);
     }
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   if (settings.seen & SEEN_FONT)
     {
       if (send_event_p)
@@ -849,7 +858,7 @@ init_gsettings (void)
       g_variant_unref (val);
     }
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   val = g_settings_get_value (gsettings_client, GSETTINGS_MONO_FONT);
   if (val)
     {
@@ -867,7 +876,7 @@ init_gsettings (void)
         dupstring (&current_font, g_variant_get_string (val, NULL));
       g_variant_unref (val);
     }
-#endif /* HAVE_XFT */
+#endif /* USE_CAIRO || HAVE_XFT */
 
 #endif /* HAVE_GSETTINGS */
 }
@@ -902,7 +911,7 @@ init_gconf (void)
       g_free (s);
     }
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   s = gconf_client_get_string (gconf_client, GCONF_MONO_FONT, NULL);
   if (s)
     {
@@ -931,7 +940,7 @@ init_gconf (void)
                            GCONF_FONT_NAME,
                            something_changed_gconfCB,
                            NULL, NULL, NULL);
-#endif /* HAVE_XFT */
+#endif /* USE_CAIRO || HAVE_XFT */
 #endif /* HAVE_GCONF */
 }
 
@@ -1023,13 +1032,18 @@ void
 syms_of_xsettings (void)
 {
   current_mono_font = NULL;
+  PDUMPER_IGNORE (current_mono_font);
   current_font = NULL;
+  PDUMPER_IGNORE (current_font);
   first_dpyinfo = NULL;
+  PDUMPER_IGNORE (first_dpyinfo);
 #ifdef HAVE_GSETTINGS
   gsettings_client = NULL;
+  PDUMPER_IGNORE (gsettings_client);
 #endif
 #ifdef HAVE_GCONF
   gconf_client = NULL;
+  PDUMPER_IGNORE (gconf_client);
 #endif
 
   DEFSYM (Qmonospace_font_name, "monospace-font-name");
@@ -1049,7 +1063,7 @@ If this variable is nil, Emacs ignores system font 
changes.  */);
                doc: /* Font settings applied to Xft.  */);
   Vxft_settings = empty_unibyte_string;
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   Fprovide (intern_c_string ("font-render-setting"), Qnil);
 #if defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
   Fprovide (intern_c_string ("system-font-setting"), Qnil);
diff --git a/src/xsettings.h b/src/xsettings.h
index 0c704f4..d5609f8 100644
--- a/src/xsettings.h
+++ b/src/xsettings.h
@@ -1,6 +1,6 @@
 /* Functions for handle font changes dynamically.
 
-Copyright (C) 2009-2018 Free Software Foundation, Inc.
+Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/xsmfns.c b/src/xsmfns.c
index 2f1da6e..1706cdd 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -1,7 +1,7 @@
 /* Session management module for systems which understand the X Session
    management protocol.
 
-Copyright (C) 2002-2018 Free Software Foundation, Inc.
+Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
diff --git a/src/xterm.c b/src/xterm.c
index 3a7e31e..dd19b8b 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1,6 +1,6 @@
 /* X Communication module for terminals which understand the X protocol.
 
-Copyright (C) 1989, 1993-2018 Free Software Foundation, Inc.
+Copyright (C) 1989, 1993-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -38,11 +38,6 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include <X11/extensions/Xfixes.h>
 #endif
 
-/* Using Xft implies that XRender is available.  */
-#ifdef HAVE_XFT
-#include <X11/extensions/Xrender.h>
-#endif
-
 #ifdef HAVE_XDBE
 #include <X11/extensions/Xdbe.h>
 #endif
@@ -79,6 +74,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #include "xsettings.h"
 #include "sysselect.h"
 #include "menu.h"
+#include "pdumper.h"
 
 #ifdef USE_X_TOOLKIT
 #include <X11/Shell.h>
@@ -238,7 +234,7 @@ static void x_wm_set_window_state (struct frame *, int);
 static void x_wm_set_icon_pixmap (struct frame *, ptrdiff_t);
 static void x_initialize (void);
 
-static bool get_current_wm_state (struct frame *, Window, int *, bool *);
+static bool x_get_current_wm_state (struct frame *, Window, int *, bool *);
 
 /* Flush display of frame F.  */
 
@@ -360,10 +356,15 @@ x_begin_cr_clip (struct frame *f, GC gc)
 
       if (! FRAME_CR_SURFACE (f))
         {
+         int scale = 1;
+#ifdef USE_GTK
+         scale = xg_get_scale (f);
+#endif
+
          FRAME_CR_SURFACE (f) =
            cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
-                                       FRAME_PIXEL_WIDTH (f),
-                                       FRAME_PIXEL_HEIGHT (f));
+                                       scale * FRAME_PIXEL_WIDTH (f),
+                                       scale * FRAME_PIXEL_HEIGHT (f));
        }
       cr = cairo_create (FRAME_CR_SURFACE (f));
       FRAME_CR_CONTEXT (f) = cr;
@@ -404,7 +405,7 @@ x_set_cr_source_with_gc_foreground (struct frame *f, GC gc)
 
   XGetGCValues (FRAME_X_DISPLAY (f), gc, GCForeground, &xgcv);
   color.pixel = xgcv.foreground;
-  x_query_color (f, &color);
+  x_query_colors (f, &color, 1);
   cairo_set_source_rgb (FRAME_CR_CONTEXT (f), color.red / 65535.0,
                        color.green / 65535.0, color.blue / 65535.0);
 }
@@ -417,7 +418,7 @@ x_set_cr_source_with_gc_background (struct frame *f, GC gc)
 
   XGetGCValues (FRAME_X_DISPLAY (f), gc, GCBackground, &xgcv);
   color.pixel = xgcv.background;
-  x_query_color (f, &color);
+  x_query_colors (f, &color, 1);
   cairo_set_source_rgb (FRAME_CR_CONTEXT (f), color.red / 65535.0,
                        color.green / 65535.0, color.blue / 65535.0);
 }
@@ -425,7 +426,7 @@ x_set_cr_source_with_gc_background (struct frame *f, GC gc)
 /* Fringe bitmaps.  */
 
 static int max_fringe_bmp = 0;
-static cairo_pattern_t **fringe_bmp = 0;
+static cairo_surface_t **fringe_bmp = 0;
 
 static void
 x_cr_define_fringe_bitmap (int which, unsigned short *bits, int h, int wd)
@@ -433,13 +434,12 @@ x_cr_define_fringe_bitmap (int which, unsigned short 
*bits, int h, int wd)
   int i, stride;
   cairo_surface_t *surface;
   unsigned char *data;
-  cairo_pattern_t *pattern;
 
   if (which >= max_fringe_bmp)
     {
       i = max_fringe_bmp;
       max_fringe_bmp = which + 20;
-      fringe_bmp = (cairo_pattern_t **) xrealloc (fringe_bmp, max_fringe_bmp * 
sizeof (cairo_pattern_t *));
+      fringe_bmp = xrealloc (fringe_bmp, max_fringe_bmp * sizeof 
(*fringe_bmp));
       while (i < max_fringe_bmp)
        fringe_bmp[i++] = 0;
     }
@@ -457,12 +457,10 @@ x_cr_define_fringe_bitmap (int which, unsigned short 
*bits, int h, int wd)
     }
 
   cairo_surface_mark_dirty (surface);
-  pattern = cairo_pattern_create_for_surface (surface);
-  cairo_surface_destroy (surface);
 
   unblock_input ();
 
-  fringe_bmp[which] = pattern;
+  fringe_bmp[which] = surface;
 }
 
 static void
@@ -474,23 +472,20 @@ x_cr_destroy_fringe_bitmap (int which)
   if (fringe_bmp[which])
     {
       block_input ();
-      cairo_pattern_destroy (fringe_bmp[which]);
+      cairo_surface_destroy (fringe_bmp[which]);
       unblock_input ();
     }
   fringe_bmp[which] = 0;
 }
 
 static void
-x_cr_draw_image (struct frame *f, GC gc, cairo_pattern_t *image,
+x_cr_draw_image (struct frame *f, GC gc, cairo_surface_t *image,
+                int image_width, int image_height,
                 int src_x, int src_y, int width, int height,
                 int dest_x, int dest_y, bool overlay_p)
 {
-  cairo_t *cr;
-  cairo_matrix_t matrix;
-  cairo_surface_t *surface;
-  cairo_format_t format;
+  cairo_t *cr = x_begin_cr_clip (f, gc);
 
-  cr = x_begin_cr_clip (f, gc);
   if (overlay_p)
     cairo_rectangle (cr, dest_x, dest_y, width, height);
   else
@@ -499,21 +494,33 @@ x_cr_draw_image (struct frame *f, GC gc, cairo_pattern_t 
*image,
       cairo_rectangle (cr, dest_x, dest_y, width, height);
       cairo_fill_preserve (cr);
     }
-  cairo_clip (cr);
-  cairo_matrix_init_translate (&matrix, src_x - dest_x, src_y - dest_y);
-  cairo_pattern_set_matrix (image, &matrix);
-  cairo_pattern_get_surface (image, &surface);
-  format = cairo_image_surface_get_format (surface);
+
+  int orig_image_width = cairo_image_surface_get_width (image);
+  if (image_width == 0) image_width = orig_image_width;
+  int orig_image_height = cairo_image_surface_get_height (image);
+  if (image_height == 0) image_height = orig_image_height;
+
+  cairo_pattern_t *pattern = cairo_pattern_create_for_surface (image);
+  cairo_matrix_t matrix;
+  cairo_matrix_init_scale (&matrix, orig_image_width / (double) image_width,
+                          orig_image_height / (double) image_height);
+  cairo_matrix_translate (&matrix, src_x - dest_x, src_y - dest_y);
+  cairo_pattern_set_matrix (pattern, &matrix);
+
+  cairo_format_t format = cairo_image_surface_get_format (image);
   if (format != CAIRO_FORMAT_A8 && format != CAIRO_FORMAT_A1)
     {
-      cairo_set_source (cr, image);
+      cairo_set_source (cr, pattern);
       cairo_fill (cr);
     }
   else
     {
       x_set_cr_source_with_gc_foreground (f, gc);
-      cairo_mask (cr, image);
+      cairo_clip (cr);
+      cairo_mask (cr, pattern);
     }
+  cairo_pattern_destroy (pattern);
+
   x_end_cr_clip (f);
 }
 
@@ -899,7 +906,7 @@ x_find_topmost_parent (struct frame *f)
 
 #define OPAQUE  0xffffffff
 
-void
+static void
 x_set_frame_alpha (struct frame *f)
 {
   struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
@@ -910,21 +917,22 @@ x_set_frame_alpha (struct frame *f)
   unsigned long opac;
   Window parent;
 
-  if (dpyinfo->x_highlight_frame == f)
+  if (dpyinfo->highlight_frame == f)
     alpha = f->alpha[0];
   else
     alpha = f->alpha[1];
 
+  if (alpha < 0.0)
+    return;
+
   if (FLOATP (Vframe_alpha_lower_limit))
     alpha_min = XFLOAT_DATA (Vframe_alpha_lower_limit);
   else if (FIXNUMP (Vframe_alpha_lower_limit))
     alpha_min = (XFIXNUM (Vframe_alpha_lower_limit)) / 100.0;
 
-  if (alpha < 0.0)
-    return;
-  else if (alpha > 1.0)
+  if (alpha > 1.0)
     alpha = 1.0;
-  else if (0.0 <= alpha && alpha < alpha_min && alpha_min <= 1.0)
+  else if (alpha < alpha_min && alpha_min <= 1.0)
     alpha = alpha_min;
 
   opac = alpha * OPAQUE;
@@ -999,8 +1007,9 @@ x_update_begin (struct frame *f)
       if (FRAME_GTK_WIDGET (f))
         {
           GdkWindow *w = gtk_widget_get_window (FRAME_GTK_WIDGET (f));
-          width = gdk_window_get_width (w);
-          height = gdk_window_get_height (w);
+         int scale = xg_get_scale (f);
+         width = scale * gdk_window_get_width (w);
+         height = scale * gdk_window_get_height (w);
         }
       else
 #endif
@@ -1159,9 +1168,9 @@ x_update_window_end (struct window *w, bool cursor_on_p,
       if (draw_window_fringes (w, true))
        {
          if (WINDOW_RIGHT_DIVIDER_WIDTH (w))
-           x_draw_right_divider (w);
+           gui_draw_right_divider (w);
          else
-           x_draw_vertical_border (w);
+           gui_draw_vertical_border (w);
        }
 
       unblock_input ();
@@ -1300,7 +1309,11 @@ x_clear_under_internal_border (struct frame *f)
 #else
       int margin = FRAME_TOP_MARGIN_HEIGHT (f);
 #endif
-      struct face *face = FACE_FROM_ID_OR_NULL (f, INTERNAL_BORDER_FACE_ID);
+      int face_id =
+       !NILP (Vface_remapping_alist)
+       ? lookup_basic_face (NULL, f, INTERNAL_BORDER_FACE_ID)
+       : INTERNAL_BORDER_FACE_ID;
+      struct face *face = FACE_FROM_ID_OR_NULL (f, face_id);
 
       block_input ();
 
@@ -1363,7 +1376,11 @@ x_after_update_window_line (struct window *w, struct 
glyph_row *desired_row)
            height > 0))
       {
        int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y));
-       struct face *face = FACE_FROM_ID_OR_NULL (f, INTERNAL_BORDER_FACE_ID);
+       int face_id =
+         !NILP (Vface_remapping_alist)
+         ? lookup_basic_face (NULL, f, INTERNAL_BORDER_FACE_ID)
+         : INTERNAL_BORDER_FACE_ID;
+       struct face *face = FACE_FROM_ID_OR_NULL (f, face_id);
 
        block_input ();
        if (face)
@@ -1428,7 +1445,7 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row 
*row, struct draw_fring
                                       : f->output_data.x->cursor_pixel)
                                    : face->foreground));
       XSetBackground (display, gc, face->background);
-      x_cr_draw_image (f, gc, fringe_bmp[p->which], 0, p->dh,
+      x_cr_draw_image (f, gc, fringe_bmp[p->which], 0, 0, 0, p->dh,
                       p->wd, p->h, p->x, p->y, p->overlay_p);
       XSetForeground (display, gc, gcv.foreground);
       XSetBackground (display, gc, gcv.background);
@@ -1488,35 +1505,8 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row 
*row, struct draw_fring
                            Glyph display
  ***********************************************************************/
 
-
-
-static void x_set_glyph_string_clipping (struct glyph_string *);
-static void x_set_glyph_string_gc (struct glyph_string *);
-static void x_draw_glyph_string_foreground (struct glyph_string *);
-static void x_draw_composite_glyph_string_foreground (struct glyph_string *);
-static void x_draw_glyph_string_box (struct glyph_string *);
-static void x_draw_glyph_string  (struct glyph_string *);
-static _Noreturn void x_delete_glyphs (struct frame *, int);
-static void x_compute_glyph_string_overhangs (struct glyph_string *);
-static void x_set_cursor_gc (struct glyph_string *);
-static void x_set_mode_line_face_gc (struct glyph_string *);
-static void x_set_mouse_face_gc (struct glyph_string *);
 static bool x_alloc_lighter_color (struct frame *, Display *, Colormap,
                                   unsigned long *, double, int);
-static void x_setup_relief_color (struct frame *, struct relief *,
-                                  double, int, unsigned long);
-static void x_setup_relief_colors (struct glyph_string *);
-static void x_draw_image_glyph_string (struct glyph_string *);
-static void x_draw_image_relief (struct glyph_string *);
-static void x_draw_image_foreground (struct glyph_string *);
-static void x_draw_image_foreground_1 (struct glyph_string *, Pixmap);
-static void x_clear_glyph_string_rect (struct glyph_string *, int,
-                                       int, int, int);
-static void x_draw_relief_rect (struct frame *, int, int, int, int,
-                                int, bool, bool, bool, bool, bool,
-                                XRectangle *);
-static void x_draw_box_rect (struct glyph_string *, int, int, int, int,
-                             int, bool, bool, XRectangle *);
 static void x_scroll_bar_clear (struct frame *);
 
 #ifdef GLYPH_DEBUG
@@ -2335,17 +2325,15 @@ x_query_colors (struct frame *f, XColor *colors, int 
ncolors)
   XQueryColors (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), colors, ncolors);
 }
 
+/* Store F's background color into *BGCOLOR.  */
 
-/* On frame F, translate pixel color to RGB values for the color in
-   COLOR.  Use cached information, if available.  */
-
-void
-x_query_color (struct frame *f, XColor *color)
+static void
+x_query_frame_background_color (struct frame *f, XColor *bgcolor)
 {
-  x_query_colors (f, color, 1);
+  bgcolor->pixel = FRAME_BACKGROUND_PIXEL (f);
+  x_query_colors (f, bgcolor, 1);
 }
 
-
 /* On frame F, translate the color name to RGB values.  Use cached
    information, if possible.
 
@@ -2509,7 +2497,7 @@ x_copy_color (struct frame *f, unsigned long pixel)
   color.pixel = pixel;
   block_input ();
   /* The color could still be found in the color_cells array.  */
-  x_query_color (f, &color);
+  x_query_colors (f, &color, 1);
   XAllocColor (FRAME_X_DISPLAY (f), FRAME_X_COLORMAP (f), &color);
   unblock_input ();
 #ifdef DEBUG_X_COLORS
@@ -2550,7 +2538,7 @@ x_alloc_lighter_color (struct frame *f, Display *display, 
Colormap cmap,
 
   /* Get RGB color values.  */
   color.pixel = *pixel;
-  x_query_color (f, &color);
+  x_query_colors (f, &color, 1);
 
   /* Change RGB values by specified FACTOR.  Avoid overflow!  */
   eassert (factor >= 0);
@@ -2970,6 +2958,49 @@ x_draw_glyph_string_box (struct glyph_string *s)
 }
 
 
+#ifndef USE_CAIRO
+static void
+x_composite_image (struct glyph_string *s, Pixmap dest,
+                   int srcX, int srcY, int dstX, int dstY,
+                   int width, int height)
+{
+#ifdef HAVE_XRENDER
+  if (s->img->picture)
+    {
+      Picture destination;
+      XRenderPictFormat *default_format;
+      XRenderPictureAttributes attr;
+
+      /* FIXME: Should we do this each time or would it make sense to
+         store destination in the frame struct?  */
+      default_format = XRenderFindVisualFormat (s->display,
+                                                DefaultVisual (s->display, 0));
+      destination = XRenderCreatePicture (s->display, dest,
+                                          default_format, 0, &attr);
+
+      /* FIXME: It may make sense to use PictOpSrc instead of
+         PictOpOver, as I don't know if we care about alpha values too
+         much here.  */
+      XRenderComposite (s->display, PictOpOver,
+                        s->img->picture, s->img->mask_picture, destination,
+                        srcX, srcY,
+                        srcX, srcY,
+                        dstX, dstY,
+                        width, height);
+
+      XRenderFreePicture (s->display, destination);
+      return;
+    }
+#endif
+
+  XCopyArea (s->display, s->img->pixmap,
+            dest, s->gc,
+            srcX, srcY,
+            width, height, dstX, dstY);
+}
+#endif /* !USE_CAIRO */
+
+
 /* Draw foreground of image glyph string S.  */
 
 static void
@@ -2992,6 +3023,32 @@ x_draw_image_foreground (struct glyph_string *s)
   if (s->slice.y == 0)
     y += s->img->vmargin;
 
+#ifdef USE_CAIRO
+  if (s->img->cr_data)
+    {
+      x_set_glyph_string_clipping (s);
+      x_cr_draw_image (s->f, s->gc,
+                      s->img->cr_data, s->img->width, s->img->height,
+                      s->slice.x, s->slice.y, s->slice.width, s->slice.height,
+                      x, y, true);
+      if (!s->img->mask)
+       {
+         /* When the image has a mask, we can expect that at
+            least part of a mouse highlight or a block cursor will
+            be visible.  If the image doesn't have a mask, make
+            a block cursor visible by drawing a rectangle around
+            the image.  I believe it's looking better if we do
+            nothing here for mouse-face.  */
+         if (s->hl == DRAW_CURSOR)
+           {
+             int relief = eabs (s->img->relief);
+             x_draw_rectangle (s->f, s->gc, x - relief, y - relief,
+                               s->slice.width + relief*2 - 1,
+                               s->slice.height + relief*2 - 1);
+           }
+       }
+    }
+#else  /* ! USE_CAIRO */
   if (s->img->pixmap)
     {
       if (s->img->mask)
@@ -3001,6 +3058,7 @@ x_draw_image_foreground (struct glyph_string *s)
             trust on the shape extension to be available
             (XShapeCombineRegion).  So, compute the rectangle to draw
             manually.  */
+          /* FIXME: Do we need to do this when using XRender compositing?  */
          unsigned long mask = (GCClipMask | GCClipXOrigin | GCClipYOrigin
                                | GCFunction);
          XGCValues xgcv;
@@ -3017,11 +3075,10 @@ x_draw_image_foreground (struct glyph_string *s)
          image_rect.y = y;
          image_rect.width = s->slice.width;
          image_rect.height = s->slice.height;
-         if (x_intersect_rectangles (&clip_rect, &image_rect, &r))
-            XCopyArea (s->display, s->img->pixmap,
-                       FRAME_X_DRAWABLE (s->f), s->gc,
-                      s->slice.x + r.x - x, s->slice.y + r.y - y,
-                      r.width, r.height, r.x, r.y);
+         if (gui_intersect_rectangles (&clip_rect, &image_rect, &r))
+            x_composite_image (s, FRAME_X_DRAWABLE (s->f),
+                              s->slice.x + r.x - x, s->slice.y + r.y - y,
+                               r.x, r.y, r.width, r.height);
        }
       else
        {
@@ -3032,11 +3089,9 @@ x_draw_image_foreground (struct glyph_string *s)
          image_rect.y = y;
          image_rect.width = s->slice.width;
          image_rect.height = s->slice.height;
-         if (x_intersect_rectangles (&clip_rect, &image_rect, &r))
-            XCopyArea (s->display, s->img->pixmap,
-                       FRAME_X_DRAWABLE (s->f), s->gc,
-                      s->slice.x + r.x - x, s->slice.y + r.y - y,
-                      r.width, r.height, r.x, r.y);
+         if (gui_intersect_rectangles (&clip_rect, &image_rect, &r))
+            x_composite_image (s, FRAME_X_DRAWABLE (s->f), s->slice.x + r.x - 
x, s->slice.y + r.y - y,
+                               r.x, r.y, r.width, r.height);
 
          /* When the image has a mask, we can expect that at
             least part of a mouse highlight or a block cursor will
@@ -3054,6 +3109,7 @@ x_draw_image_foreground (struct glyph_string *s)
            }
        }
     }
+#endif /* ! USE_CAIRO */
   else
     /* Draw a rectangle if image could not be loaded.  */
     x_draw_rectangle (s->f, s->gc, x, y,
@@ -3090,7 +3146,9 @@ x_draw_image_relief (struct glyph_string *s)
   if (s->hl == DRAW_IMAGE_SUNKEN
       || s->hl == DRAW_IMAGE_RAISED)
     {
-      thick = tool_bar_button_relief >= 0 ? tool_bar_button_relief : 
DEFAULT_TOOL_BAR_BUTTON_RELIEF;
+      thick = (tool_bar_button_relief < 0
+              ? DEFAULT_TOOL_BAR_BUTTON_RELIEF
+              : min (tool_bar_button_relief, 1000000));
       raised_p = s->hl == DRAW_IMAGE_RAISED;
     }
   else
@@ -3134,6 +3192,7 @@ x_draw_image_relief (struct glyph_string *s)
 }
 
 
+#ifndef USE_CAIRO
 /* Draw the foreground of image glyph string S to PIXMAP.  */
 
 static void
@@ -3206,6 +3265,7 @@ x_draw_image_foreground_1 (struct glyph_string *s, Pixmap 
pixmap)
     x_draw_rectangle (s->f, s->gc, x, y,
                    s->slice.width - 1, s->slice.height - 1);
 }
+#endif /* ! USE_CAIRO */
 
 
 /* Draw part of the background of glyph string S.  X, Y, W, and H
@@ -3246,7 +3306,9 @@ x_draw_image_glyph_string (struct glyph_string *s)
   int box_line_hwidth = eabs (s->face->box_line_width);
   int box_line_vwidth = max (s->face->box_line_width, 0);
   int height;
+#ifndef USE_CAIRO
   Pixmap pixmap = None;
+#endif
 
   height = s->height;
   if (s->slice.y == 0)
@@ -3265,6 +3327,7 @@ x_draw_image_glyph_string (struct glyph_string *s)
       || s->img->pixmap == 0
       || s->width != s->background_width)
     {
+#ifndef USE_CAIRO
       if (s->img->mask)
        {
          /* Create a pixmap as large as the glyph string.  Fill it
@@ -3305,6 +3368,7 @@ x_draw_image_glyph_string (struct glyph_string *s)
            }
        }
       else
+#endif /* ! USE_CAIRO */
        {
          int x = s->x;
          int y = s->y;
@@ -3327,25 +3391,8 @@ x_draw_image_glyph_string (struct glyph_string *s)
     }
 
   /* Draw the foreground.  */
-#ifdef USE_CAIRO
-  if (s->img->cr_data)
-    {
-      cairo_t *cr = x_begin_cr_clip (s->f, s->gc);
-
-      int x = s->x + s->img->hmargin;
-      int y = s->y + s->img->vmargin;
-      int width = s->background_width;
-
-      cairo_set_source_surface (cr, s->img->cr_data,
-                                x - s->slice.x,
-                                y - s->slice.y);
-      cairo_rectangle (cr, x, y, width, height);
-      cairo_fill (cr);
-      x_end_cr_clip (s->f);
-    }
-  else
-#endif
-    if (pixmap != None)
+#ifndef USE_CAIRO
+  if (pixmap != None)
     {
       x_draw_image_foreground_1 (s, pixmap);
       x_set_glyph_string_clipping (s);
@@ -3354,6 +3401,7 @@ x_draw_image_glyph_string (struct glyph_string *s)
       XFreePixmap (s->display, pixmap);
     }
   else
+#endif /* ! USE_CAIRO */
     x_draw_image_foreground (s);
 
   /* If we must draw a relief around the image, do it.  */
@@ -3528,7 +3576,7 @@ x_draw_underwave (struct glyph_string *s)
   wave_clip.height = wave_height;
   get_glyph_string_clip_rect (s, &string_clip);
 
-  if (!x_intersect_rectangles (&wave_clip, &string_clip, &final_clip))
+  if (!gui_intersect_rectangles (&wave_clip, &string_clip, &final_clip))
     return;
 
   XSetClipRectangles (s->display, s->gc, 0, 0, &final_clip, 1, Unsorted);
@@ -3896,7 +3944,7 @@ x_shift_glyphs_for_insert (struct frame *f, int x, int y, 
int width, int height,
    for X frames.  */
 
 static void
-x_delete_glyphs (struct frame *f, register int n)
+x_delete_glyphs (struct frame *f, int n)
 {
   emacs_abort ();
 }
@@ -4259,12 +4307,11 @@ x_scroll_run (struct window *w, struct run *run)
   block_input ();
 
   /* Cursor off.  Will be switched on again in x_update_window_end.  */
-  x_clear_cursor (w);
+  gui_clear_cursor (w);
 
 #ifdef USE_CAIRO
   if (FRAME_CR_CONTEXT (f))
     {
-      int wx = WINDOW_LEFT_EDGE_X (w);
       cairo_surface_t *s = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
                                                       width, height);
       cairo_t *cr = cairo_create (s);
@@ -4275,8 +4322,8 @@ x_scroll_run (struct window *w, struct run *run)
 
       cr = FRAME_CR_CONTEXT (f);
       cairo_save (cr);
-      cairo_set_source_surface (cr, s, wx, to_y);
-      cairo_rectangle (cr, wx, to_y, width, height);
+      cairo_set_source_surface (cr, s, x, to_y);
+      cairo_rectangle (cr, x, to_y, width, height);
       cairo_fill (cr);
       cairo_restore (cr);
       cairo_surface_destroy (s);
@@ -4305,7 +4352,7 @@ x_scroll_run (struct window *w, struct run *run)
 
 
 static void
-frame_highlight (struct frame *f)
+x_frame_highlight (struct frame *f)
 {
   /* We used to only do this if Vx_no_window_manager was non-nil, but
      the ICCCM (section 4.1.6) says that the window's border pixmap
@@ -4321,12 +4368,12 @@ frame_highlight (struct frame *f)
                    f->output_data.x->border_pixel);
   x_uncatch_errors ();
   unblock_input ();
-  x_update_cursor (f, true);
+  gui_update_cursor (f, true);
   x_set_frame_alpha (f);
 }
 
 static void
-frame_unhighlight (struct frame *f)
+x_frame_unhighlight (struct frame *f)
 {
   /* We used to only do this if Vx_no_window_manager was non-nil, but
      the ICCCM (section 4.1.6) says that the window's border pixmap
@@ -4339,7 +4386,7 @@ frame_unhighlight (struct frame *f)
                          f->output_data.x->border_tile);
   x_uncatch_errors ();
   unblock_input ();
-  x_update_cursor (f, true);
+  gui_update_cursor (f, true);
   x_set_frame_alpha (f);
 }
 
@@ -4671,29 +4718,29 @@ XTframe_rehighlight (struct frame *frame)
 static void
 x_frame_rehighlight (struct x_display_info *dpyinfo)
 {
-  struct frame *old_highlight = dpyinfo->x_highlight_frame;
+  struct frame *old_highlight = dpyinfo->highlight_frame;
 
   if (dpyinfo->x_focus_frame)
     {
-      dpyinfo->x_highlight_frame
+      dpyinfo->highlight_frame
        = ((FRAMEP (FRAME_FOCUS_FRAME (dpyinfo->x_focus_frame)))
           ? XFRAME (FRAME_FOCUS_FRAME (dpyinfo->x_focus_frame))
           : dpyinfo->x_focus_frame);
-      if (! FRAME_LIVE_P (dpyinfo->x_highlight_frame))
+      if (! FRAME_LIVE_P (dpyinfo->highlight_frame))
        {
          fset_focus_frame (dpyinfo->x_focus_frame, Qnil);
-         dpyinfo->x_highlight_frame = dpyinfo->x_focus_frame;
+         dpyinfo->highlight_frame = dpyinfo->x_focus_frame;
        }
     }
   else
-    dpyinfo->x_highlight_frame = 0;
+    dpyinfo->highlight_frame = 0;
 
-  if (dpyinfo->x_highlight_frame != old_highlight)
+  if (dpyinfo->highlight_frame != old_highlight)
     {
       if (old_highlight)
-       frame_unhighlight (old_highlight);
-      if (dpyinfo->x_highlight_frame)
-       frame_highlight (dpyinfo->x_highlight_frame);
+       x_frame_unhighlight (old_highlight);
+      if (dpyinfo->highlight_frame)
+       x_frame_highlight (dpyinfo->highlight_frame);
     }
 }
 
@@ -4843,7 +4890,7 @@ x_x_to_emacs_modifiers (struct x_display_info *dpyinfo, 
int state)
 }
 
 static int
-x_emacs_to_x_modifiers (struct x_display_info *dpyinfo, EMACS_INT state)
+x_emacs_to_x_modifiers (struct x_display_info *dpyinfo, intmax_t state)
 {
   EMACS_INT mod_ctrl = ctrl_modifier;
   EMACS_INT mod_meta = meta_modifier;
@@ -4876,7 +4923,7 @@ x_emacs_to_x_modifiers (struct x_display_info *dpyinfo, 
EMACS_INT state)
 /* Convert a keysym to its name.  */
 
 char *
-x_get_keysym_name (int keysym)
+get_keysym_name (int keysym)
 {
   char *value;
 
@@ -4913,9 +4960,9 @@ x_get_keysym_name (int keysym)
    the mouse.  */
 
 static Lisp_Object
-construct_mouse_click (struct input_event *result,
-                      const XButtonEvent *event,
-                      struct frame *f)
+x_construct_mouse_click (struct input_event *result,
+                         const XButtonEvent *event,
+                         struct frame *f)
 {
   /* Make the event type NO_EVENT; we'll change that when we decide
      otherwise.  */
@@ -4944,7 +4991,7 @@ construct_mouse_click (struct input_event *result,
    another motion event, so we can check again the next time it moves.  */
 
 static bool
-note_mouse_movement (struct frame *frame, const XMotionEvent *event)
+x_note_mouse_movement (struct frame *frame, const XMotionEvent *event)
 {
   XRectangle *r;
   struct x_display_info *dpyinfo;
@@ -5082,7 +5129,7 @@ XTmouse_position (struct frame **fp, int insist, 
Lisp_Object *bar_window,
 
        x_catch_errors (FRAME_X_DISPLAY (*fp));
 
-       if (x_mouse_grabbed (dpyinfo))
+       if (gui_mouse_grabbed (dpyinfo))
          {
            /* If mouse was grabbed on a frame, give coords for that frame
               even if the mouse is now outside it.  */
@@ -5270,7 +5317,7 @@ x_window_to_scroll_bar (Display *display, Window 
window_id, int type)
           bar = XSCROLL_BAR (bar)->next)
        if (XSCROLL_BAR (bar)->x_window == window_id
             && FRAME_X_DISPLAY (XFRAME (frame)) == display
-           && (type = 2
+           && (type == 2
                || (type == 1 && XSCROLL_BAR (bar)->horizontal)
                || (type == 0 && !XSCROLL_BAR (bar)->horizontal)))
          return XSCROLL_BAR (bar);
@@ -6538,8 +6585,8 @@ x_scroll_bar_create (struct window *w, int top, int left,
                     int width, int height, bool horizontal)
 {
   struct frame *f = XFRAME (w->frame);
-  struct scroll_bar *bar
-    = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, x_window, PVEC_OTHER);
+  struct scroll_bar *bar = ALLOCATE_PSEUDOVECTOR (struct scroll_bar, prev,
+                                                 PVEC_OTHER);
   Lisp_Object barobj;
 
   block_input ();
@@ -7621,7 +7668,7 @@ x_net_wm_state (struct frame *f, Window window)
   Lisp_Object lval = Qnil;
   bool sticky = false;
 
-  get_current_wm_state (f, window, &value, &sticky);
+  x_get_current_wm_state (f, window, &value, &sticky);
 
   switch (value)
     {
@@ -8110,7 +8157,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
       if (event->xunmap.window == tip_window)
         {
           tip_window = None;
-          x_redo_mouse_highlight (dpyinfo);
+          gui_redo_mouse_highlight (dpyinfo);
         }
 
       f = x_top_window_to_frame (dpyinfo, event->xunmap.window);
@@ -8545,12 +8592,12 @@ handle_one_xevent (struct x_display_info *dpyinfo,
       /* EnterNotify counts as mouse movement,
         so update things that depend on mouse position.  */
       if (f && !f->output_data.x->hourglass_p)
-       note_mouse_movement (f, &event->xmotion);
+       x_note_mouse_movement (f, &event->xmotion);
 #ifdef USE_GTK
       /* We may get an EnterNotify on the buttons in the toolbar.  In that
          case we moved out of any highlighted area and need to note this.  */
       if (!f && dpyinfo->last_mouse_glyph_frame)
-        note_mouse_movement (dpyinfo->last_mouse_glyph_frame, &event->xmotion);
+        x_note_mouse_movement (dpyinfo->last_mouse_glyph_frame, 
&event->xmotion);
 #endif
       goto OTHER;
 
@@ -8583,7 +8630,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 #ifdef USE_GTK
       /* See comment in EnterNotify above */
       else if (dpyinfo->last_mouse_glyph_frame)
-        note_mouse_movement (dpyinfo->last_mouse_glyph_frame, &event->xmotion);
+        x_note_mouse_movement (dpyinfo->last_mouse_glyph_frame, 
&event->xmotion);
 #endif
       goto OTHER;
 
@@ -8597,7 +8644,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
         previous_help_echo_string = help_echo_string;
         help_echo_string = Qnil;
 
-       f = (x_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
+       f = (gui_mouse_grabbed (dpyinfo) ? dpyinfo->last_mouse_frame
             : x_window_to_frame (dpyinfo, event->xmotion.window));
 
         if (hlinfo->mouse_face_hidden)
@@ -8652,7 +8699,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                last_mouse_window = window;
              }
 
-            if (!note_mouse_movement (f, &event->xmotion))
+            if (!x_note_mouse_movement (f, &event->xmotion))
              help_echo_string = previous_help_echo_string;
           }
         else
@@ -8844,7 +8891,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
        dpyinfo->last_mouse_glyph_frame = NULL;
        x_display_set_last_user_time (dpyinfo, event->xbutton.time);
 
-       if (x_mouse_grabbed (dpyinfo))
+       if (gui_mouse_grabbed (dpyinfo))
          f = dpyinfo->last_mouse_frame;
        else
          {
@@ -8860,7 +8907,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                   into a parent frame with the child frame selected and
                   `no-accept-focus' is not set, select the clicked
                   frame.  */
-               struct frame *hf = dpyinfo->x_highlight_frame;
+               struct frame *hf = dpyinfo->highlight_frame;
 
                if (FRAME_PARENT_FRAME (f) || (hf && frame_ancestor_p (f, hf)))
                  {
@@ -8910,13 +8957,13 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                           && event->xbutton.time > 
ignore_next_mouse_click_timeout)
                         {
                           ignore_next_mouse_click_timeout = 0;
-                          construct_mouse_click (&inev.ie, &event->xbutton, f);
+                          x_construct_mouse_click (&inev.ie, &event->xbutton, 
f);
                         }
                       if (event->type == ButtonRelease)
                         ignore_next_mouse_click_timeout = 0;
                     }
                   else
-                    construct_mouse_click (&inev.ie, &event->xbutton, f);
+                    x_construct_mouse_click (&inev.ie, &event->xbutton, f);
                 }
             if (FRAME_X_EMBEDDED_P (f))
               xembed_send_message (f, event->xbutton.time,
@@ -9477,7 +9524,7 @@ x_draw_window_cursor (struct window *w, struct glyph_row 
*glyph_row, int x,
 
 /* Make the x-window of frame F use the gnu icon bitmap.  */
 
-bool
+static bool
 x_bitmap_icon (struct frame *f, Lisp_Object file)
 {
   ptrdiff_t bitmap_id;
@@ -9487,7 +9534,7 @@ x_bitmap_icon (struct frame *f, Lisp_Object file)
 
   /* Free up our existing icon bitmap and mask if any.  */
   if (f->output_data.x->icon_bitmap > 0)
-    x_destroy_bitmap (f, f->output_data.x->icon_bitmap);
+    image_destroy_bitmap (f, f->output_data.x->icon_bitmap);
   f->output_data.x->icon_bitmap = 0;
 
   if (STRINGP (file))
@@ -9498,7 +9545,7 @@ x_bitmap_icon (struct frame *f, Lisp_Object file)
       if (xg_set_icon (f, file))
        return false;
 #endif /* USE_GTK */
-      bitmap_id = x_create_bitmap_from_file (f, file);
+      bitmap_id = image_create_bitmap_from_file (f, file);
       x_create_bitmap_mask (f, bitmap_id);
     }
   else
@@ -9528,8 +9575,10 @@ x_bitmap_icon (struct frame *f, Lisp_Object file)
          /* If all else fails, use the (black and white) xbm image. */
          if (rc == -1)
            {
-             rc = x_create_bitmap_from_data (f, (char *) gnu_xbm_bits,
-                                             gnu_xbm_width, gnu_xbm_height);
+              rc = image_create_bitmap_from_data (f,
+                                                  (char *) gnu_xbm_bits,
+                                                  gnu_xbm_width,
+                                                  gnu_xbm_height);
              if (rc == -1)
                return true;
 
@@ -9542,7 +9591,7 @@ x_bitmap_icon (struct frame *f, Lisp_Object file)
         this increments the ref-count one extra time.
         As a result, the GNU bitmap and mask are never freed.
         That way, we don't have to worry about allocating it again.  */
-      x_reference_bitmap (f, FRAME_DISPLAY_INFO (f)->icon_bitmap_id);
+      image_reference_bitmap (f, FRAME_DISPLAY_INFO (f)->icon_bitmap_id);
 
       bitmap_id = FRAME_DISPLAY_INFO (f)->icon_bitmap_id;
     }
@@ -9573,7 +9622,7 @@ x_text_icon (struct frame *f, const char *icon_name)
   }
 
   if (f->output_data.x->icon_bitmap > 0)
-    x_destroy_bitmap (f, f->output_data.x->icon_bitmap);
+    image_destroy_bitmap (f, f->output_data.x->icon_bitmap);
   f->output_data.x->icon_bitmap = 0;
   x_wm_set_icon_pixmap (f, 0);
 
@@ -9764,7 +9813,7 @@ static char *error_msg;
 /* Handle the loss of connection to display DPY.  ERROR_MESSAGE is
    the text of an error message that lead to the connection loss.  */
 
-static _Noreturn void
+static AVOID
 x_connection_closed (Display *dpy, const char *error_message, bool ioerror)
 {
   struct x_display_info *dpyinfo = x_display_info_for_display (dpy);
@@ -9927,7 +9976,7 @@ x_error_quitter (Display *display, XErrorEvent *event)
    It kills all frames on the display that we lost touch with.
    If that was the only one, it prints an error message and kills Emacs.  */
 
-static _Noreturn int
+static _Noreturn ATTRIBUTE_COLD int
 x_io_error_quitter (Display *display)
 {
   char buf[256];
@@ -9944,7 +9993,7 @@ x_io_error_quitter (Display *display)
    frame.  If it is negative, generate a new fontset from
    FONT-OBJECT.  */
 
-Lisp_Object
+static Lisp_Object
 x_new_font (struct frame *f, Lisp_Object font_object, int fontset)
 {
   struct font *font = XFONT_OBJECT (font_object);
@@ -10076,7 +10125,7 @@ xim_open_dpy (struct x_display_info *dpyinfo, char 
*resource_name)
     {
       if (dpyinfo->xim)
        XCloseIM (dpyinfo->xim);
-      xim = XOpenIM (dpyinfo->display, dpyinfo->xrdb, resource_name,
+      xim = XOpenIM (dpyinfo->display, dpyinfo->rdb, resource_name,
                     emacs_class);
       dpyinfo->xim = xim;
 
@@ -10175,7 +10224,7 @@ xim_initialize (struct x_display_info *dpyinfo, char 
*resource_name)
       xim_inst->dpyinfo = dpyinfo;
       xim_inst->resource_name = xstrdup (resource_name);
       ret = XRegisterIMInstantiateCallback
-       (dpyinfo->display, dpyinfo->xrdb, xim_inst->resource_name,
+       (dpyinfo->display, dpyinfo->rdb, xim_inst->resource_name,
         emacs_class, xim_instantiate_callback,
         /* This is XPointer in XFree86 but (XPointer *)
            on Tru64, at least, hence the configure test.  */
@@ -10203,7 +10252,7 @@ xim_close_dpy (struct x_display_info *dpyinfo)
       if (dpyinfo->display)
        {
          Bool ret = XUnregisterIMInstantiateCallback
-           (dpyinfo->display, dpyinfo->xrdb, xim_inst->resource_name,
+           (dpyinfo->display, dpyinfo->rdb, xim_inst->resource_name,
             emacs_class, xim_instantiate_callback,
             (XRegisterIMInstantiateCallback_arg6) xim_inst);
          eassert (ret == True);
@@ -10316,10 +10365,10 @@ x_calc_absolute_position (struct frame *f)
 /* CHANGE_GRAVITY is 1 when calling from Fset_frame_position,
    to really change the position, and 0 when calling from
    x_make_frame_visible (in that case, XOFF and YOFF are the current
-   position values).  It is -1 when calling from x_set_frame_parameters,
+   position values).  It is -1 when calling from gui_set_frame_parameters,
    which means, do adjust for borders but don't change the gravity.  */
 
-void
+static void
 x_set_offset (struct frame *f, register int xoff, register int yoff, int 
change_gravity)
 {
   int modified_top, modified_left;
@@ -10622,10 +10671,10 @@ x_set_z_group (struct frame *f, Lisp_Object 
new_value, Lisp_Object old_value)
    Return true iff we are not hidden.  */
 
 static bool
-get_current_wm_state (struct frame *f,
-                      Window window,
-                      int *size_state,
-                      bool *sticky)
+x_get_current_wm_state (struct frame *f,
+                        Window window,
+                        int *size_state,
+                        bool *sticky)
 {
   unsigned long actual_size;
   int i;
@@ -10732,7 +10781,7 @@ do_ewmh_fullscreen (struct frame *f)
   int cur;
   bool dummy;
 
-  get_current_wm_state (f, FRAME_OUTER_WINDOW (f), &cur, &dummy);
+  x_get_current_wm_state (f, FRAME_OUTER_WINDOW (f), &cur, &dummy);
 
   /* Some window managers don't say they support _NET_WM_STATE, but they do say
      they support _NET_WM_STATE_FULLSCREEN.  Try that also.  */
@@ -10873,7 +10922,7 @@ x_handle_net_wm_state (struct frame *f, const 
XPropertyEvent *event)
   int value = FULLSCREEN_NONE;
   Lisp_Object lval;
   bool sticky = false;
-  bool not_hidden = get_current_wm_state (f, event->window, &value, &sticky);
+  bool not_hidden = x_get_current_wm_state (f, event->window, &value, &sticky);
 
   lval = Qnil;
   switch (value)
@@ -11138,8 +11187,7 @@ x_set_window_size_1 (struct frame *f, bool 
change_gravity,
     {
       frame_size_history_add
        (f, Qx_set_window_size_1, width, height,
-        list2 (make_fixnum (old_height),
-               make_fixnum (pixelheight + FRAME_MENUBAR_HEIGHT (f))));
+        list2i (old_height, pixelheight + FRAME_MENUBAR_HEIGHT (f)));
 
       XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
                     old_width, pixelheight + FRAME_MENUBAR_HEIGHT (f));
@@ -11148,7 +11196,7 @@ x_set_window_size_1 (struct frame *f, bool 
change_gravity,
     {
       frame_size_history_add
        (f, Qx_set_window_size_2, width, height,
-        list2 (make_fixnum (old_width), make_fixnum (pixelwidth)));
+        list2i (old_width, pixelwidth));
 
       XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
                     pixelwidth, old_height);
@@ -11158,10 +11206,10 @@ x_set_window_size_1 (struct frame *f, bool 
change_gravity,
     {
       frame_size_history_add
        (f, Qx_set_window_size_3, width, height,
-        list3 (make_fixnum (pixelwidth + FRAME_TOOLBAR_WIDTH (f)),
-               make_fixnum (pixelheight + FRAME_TOOLBAR_HEIGHT (f)
-                            + FRAME_MENUBAR_HEIGHT (f)),
-               make_fixnum (FRAME_MENUBAR_HEIGHT (f))));
+        list3i (pixelwidth + FRAME_TOOLBAR_WIDTH (f),
+                (pixelheight + FRAME_TOOLBAR_HEIGHT (f)
+                 + FRAME_MENUBAR_HEIGHT (f)),
+                FRAME_MENUBAR_HEIGHT (f)));
 
       XResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
                     pixelwidth, pixelheight + FRAME_MENUBAR_HEIGHT (f));
@@ -11201,7 +11249,7 @@ x_set_window_size_1 (struct frame *f, bool 
change_gravity,
        /* Try to restore fullscreen state.  */
        {
          store_frame_param (f, Qfullscreen, fullscreen);
-         x_set_fullscreen (f, fullscreen, fullscreen);
+         gui_set_fullscreen (f, fullscreen, fullscreen);
        }
     }
   else
@@ -11295,7 +11343,7 @@ frame_set_mouse_pixel_position (struct frame *f, int 
pix_x, int pix_y)
 
 /* Raise frame F.  */
 
-void
+static void
 x_raise_frame (struct frame *f)
 {
   block_input ();
@@ -11319,9 +11367,18 @@ x_lower_frame (struct frame *f)
     }
 }
 
+static void
+XTframe_raise_lower (struct frame *f, bool raise_flag)
+{
+  if (raise_flag)
+    x_raise_frame (f);
+  else
+    x_lower_frame (f);
+}
+
 /* Request focus with XEmbed */
 
-void
+static void
 xembed_request_focus (struct frame *f)
 {
   /* See XEmbed Protocol Specification at
@@ -11333,7 +11390,7 @@ xembed_request_focus (struct frame *f)
 
 /* Activate frame with Extended Window Manager Hints */
 
-void
+static void
 x_ewmh_activate_frame (struct frame *f)
 {
   /* See Window Manager Specification/Extended Window Manager Hints at
@@ -11352,14 +11409,56 @@ x_ewmh_activate_frame (struct frame *f)
     }
 }
 
+static Lisp_Object
+x_get_focus_frame (struct frame *f)
+{
+  Lisp_Object lisp_focus;
+
+  struct frame *focus =  FRAME_DISPLAY_INFO (f)->x_focus_frame;
+
+  if (!focus)
+    return Qnil;
+
+  XSETFRAME (lisp_focus, focus);
+  return lisp_focus;
+}
+
+/* In certain situations, when the window manager follows a
+   click-to-focus policy, there seems to be no way around calling
+   XSetInputFocus to give another frame the input focus .
+
+   In an ideal world, XSetInputFocus should generally be avoided so
+   that applications don't interfere with the window manager's focus
+   policy.  But I think it's okay to use when it's clearly done
+   following a user-command.  */
+
 static void
-XTframe_raise_lower (struct frame *f, bool raise_flag)
+x_focus_frame (struct frame *f, bool noactivate)
 {
-  if (raise_flag)
-    x_raise_frame (f);
+  Display *dpy = FRAME_X_DISPLAY (f);
+
+  block_input ();
+  x_catch_errors (dpy);
+
+  if (FRAME_X_EMBEDDED_P (f))
+    {
+      /* For Xembedded frames, normally the embedder forwards key
+        events.  See XEmbed Protocol Specification at
+        http://freedesktop.org/wiki/Specifications/xembed-spec  */
+      xembed_request_focus (f);
+    }
   else
-    x_lower_frame (f);
+    {
+      XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+                     RevertToParent, CurrentTime);
+      if (!noactivate)
+       x_ewmh_activate_frame (f);
+    }
+
+  x_uncatch_errors ();
+  unblock_input ();
 }
+
 
 /* XEmbed implementation.  */
 
@@ -11440,7 +11539,7 @@ x_make_frame_visible (struct frame *f)
 
   block_input ();
 
-  x_set_bitmap_icon (f);
+  gui_set_bitmap_icon (f);
 
   if (! FRAME_VISIBLE_P (f))
     {
@@ -11575,8 +11674,8 @@ x_make_frame_invisible (struct frame *f)
   window = FRAME_OUTER_WINDOW (f);
 
   /* Don't keep the highlight on an invisible frame.  */
-  if (FRAME_DISPLAY_INFO (f)->x_highlight_frame == f)
-    FRAME_DISPLAY_INFO (f)->x_highlight_frame = 0;
+  if (FRAME_DISPLAY_INFO (f)->highlight_frame == f)
+    FRAME_DISPLAY_INFO (f)->highlight_frame = 0;
 
   block_input ();
 
@@ -11617,6 +11716,15 @@ x_make_frame_invisible (struct frame *f)
   unblock_input ();
 }
 
+static void
+x_make_frame_visible_invisible (struct frame *f, bool visible)
+{
+  if (visible)
+    x_make_frame_visible (f);
+  else
+    x_make_frame_invisible (f);
+}
+
 /* Change window state from mapped to iconified.  */
 
 void
@@ -11627,15 +11735,15 @@ x_iconify_frame (struct frame *f)
 #endif
 
   /* Don't keep the highlight on an invisible frame.  */
-  if (FRAME_DISPLAY_INFO (f)->x_highlight_frame == f)
-    FRAME_DISPLAY_INFO (f)->x_highlight_frame = 0;
+  if (FRAME_DISPLAY_INFO (f)->highlight_frame == f)
+    FRAME_DISPLAY_INFO (f)->highlight_frame = 0;
 
   if (FRAME_ICONIFIED_P (f))
     return;
 
   block_input ();
 
-  x_set_bitmap_icon (f);
+  gui_set_bitmap_icon (f);
 
 #if defined (USE_GTK)
   if (FRAME_GTK_OUTER_WIDGET (f))
@@ -11891,8 +11999,8 @@ x_free_frame_resources (struct frame *f)
     dpyinfo->x_focus_frame = 0;
   if (f == dpyinfo->x_focus_event_frame)
     dpyinfo->x_focus_event_frame = 0;
-  if (f == dpyinfo->x_highlight_frame)
-    dpyinfo->x_highlight_frame = 0;
+  if (f == dpyinfo->highlight_frame)
+    dpyinfo->highlight_frame = 0;
   if (f == hlinfo->mouse_face_mouse_frame)
     reset_mouse_highlight (hlinfo);
 
@@ -12060,7 +12168,7 @@ x_wm_set_icon_pixmap (struct frame *f, ptrdiff_t 
pixmap_id)
 
   if (pixmap_id > 0)
     {
-      icon_pixmap = x_bitmap_pixmap (f, pixmap_id);
+      icon_pixmap = image_bitmap_pixmap (f, pixmap_id);
       f->output_data.x->wm_hints.icon_pixmap = icon_pixmap;
       icon_mask = x_bitmap_mask (f, pixmap_id);
       f->output_data.x->wm_hints.icon_mask = icon_mask;
@@ -12441,7 +12549,7 @@ x_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
 
         dpy = DEFAULT_GDK_DISPLAY ();
 
-#if ! GTK_CHECK_VERSION (2, 90, 0)
+#ifndef HAVE_GTK3
         /* Load our own gtkrc if it exists.  */
         {
           const char *file = "~/.emacs.d/gtkrc";
@@ -12634,7 +12742,7 @@ x_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
 #endif
   /* Put the rdb where we can find it in a way that works on
      all versions.  */
-  dpyinfo->xrdb = xrdb;
+  dpyinfo->rdb = xrdb;
 
   dpyinfo->screen = ScreenOfDisplay (dpyinfo->display,
                                     DefaultScreen (dpyinfo->display));
@@ -12665,8 +12773,8 @@ x_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
          AUTO_STRING (privateColormap, "privateColormap");
          AUTO_STRING (PrivateColormap, "PrivateColormap");
          Lisp_Object value
-           = display_x_get_resource (dpyinfo, privateColormap,
-                                     PrivateColormap, Qnil, Qnil);
+           = gui_display_get_resource (dpyinfo, privateColormap,
+                                        PrivateColormap, Qnil, Qnil);
          if (STRINGP (value)
              && (!strcmp (SSDATA (value), "true")
                  || !strcmp (SSDATA (value), "on")))
@@ -12685,7 +12793,7 @@ x_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
     dpyinfo->supports_xdbe = true;
 #endif
 
-#ifdef HAVE_XFT
+#if defined USE_CAIRO || defined HAVE_XFT
   {
     /* If we are using Xft, the following precautions should be made:
 
@@ -12883,8 +12991,8 @@ x_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
   {
     AUTO_STRING (synchronous, "synchronous");
     AUTO_STRING (Synchronous, "Synchronous");
-    Lisp_Object value = display_x_get_resource (dpyinfo, synchronous,
-                                               Synchronous, Qnil, Qnil);
+    Lisp_Object value = gui_display_get_resource (dpyinfo, synchronous,
+                                                  Synchronous, Qnil, Qnil);
     if (STRINGP (value)
        && (!strcmp (SSDATA (value), "true")
            || !strcmp (SSDATA (value), "on")))
@@ -12894,8 +13002,8 @@ x_term_init (Lisp_Object display_name, char 
*xrm_option, char *resource_name)
   {
     AUTO_STRING (useXIM, "useXIM");
     AUTO_STRING (UseXIM, "UseXIM");
-    Lisp_Object value = display_x_get_resource (dpyinfo, useXIM, UseXIM,
-                                               Qnil, Qnil);
+    Lisp_Object value = gui_display_get_resource (dpyinfo, useXIM, UseXIM,
+                                                  Qnil, Qnil);
 #ifdef USE_XIM
     if (STRINGP (value)
        && (!strcmp (SSDATA (value), "false")
@@ -13026,21 +13134,23 @@ x_activate_timeout_atimer (void)
 
 /* Set up use of X before we make the first connection.  */
 
+extern frame_parm_handler x_frame_parm_handlers[];
+
 static struct redisplay_interface x_redisplay_interface =
   {
     x_frame_parm_handlers,
-    x_produce_glyphs,
-    x_write_glyphs,
-    x_insert_glyphs,
-    x_clear_end_of_line,
+    gui_produce_glyphs,
+    gui_write_glyphs,
+    gui_insert_glyphs,
+    gui_clear_end_of_line,
     x_scroll_run,
     x_after_update_window_line,
     x_update_window_begin,
     x_update_window_end,
     x_flip_and_flush,
-    x_clear_window_mouse_face,
-    x_get_glyph_overhangs,
-    x_fix_overlapping_area,
+    gui_clear_window_mouse_face,
+    gui_get_glyph_overhangs,
+    gui_fix_overlapping_area,
     x_draw_fringe_bitmap,
 #ifdef USE_CAIRO
     x_cr_define_fringe_bitmap,
@@ -13053,6 +13163,7 @@ static struct redisplay_interface x_redisplay_interface 
=
     x_draw_glyph_string,
     x_define_frame_cursor,
     x_clear_frame_area,
+    x_clear_under_internal_border,
     x_draw_window_cursor,
     x_draw_vertical_window_border,
     x_draw_window_divider,
@@ -13084,13 +13195,13 @@ x_delete_terminal (struct terminal *terminal)
   /* Normally, the display is available...  */
   if (dpyinfo->display)
     {
-      x_destroy_all_bitmaps (dpyinfo);
+      image_destroy_all_bitmaps (dpyinfo);
       XSetCloseDownMode (dpyinfo->display, DestroyAll);
 
       /* Whether or not XCloseDisplay destroys the associated resource
         database depends on the version of libX11.  To avoid both
         crash and memory leak, we dissociate the database from the
-        display and then destroy dpyinfo->xrdb ourselves.
+        display and then destroy dpyinfo->rdb ourselves.
 
         Unfortunately, the above strategy does not work in some
         situations due to a bug in newer versions of libX11: because
@@ -13110,7 +13221,7 @@ x_delete_terminal (struct terminal *terminal)
       /* We used to call XrmDestroyDatabase from x_delete_display, but
         some older versions of libX11 crash if we call it after
         closing all the displays.  */
-      XrmDestroyDatabase (dpyinfo->xrdb);
+      XrmDestroyDatabase (dpyinfo->rdb);
 #endif
 
 #ifdef USE_GTK
@@ -13168,19 +13279,41 @@ x_create_terminal (struct x_display_info *dpyinfo)
   terminal->read_socket_hook = XTread_socket;
   terminal->frame_up_to_date_hook = XTframe_up_to_date;
   terminal->buffer_flipping_unblocked_hook = XTbuffer_flipping_unblocked_hook;
+  terminal->defined_color_hook = x_defined_color;
+  terminal->query_frame_background_color = x_query_frame_background_color;
+  terminal->query_colors = x_query_colors;
   terminal->mouse_position_hook = XTmouse_position;
+  terminal->get_focus_frame = x_get_focus_frame;
+  terminal->focus_frame_hook = x_focus_frame;
   terminal->frame_rehighlight_hook = XTframe_rehighlight;
   terminal->frame_raise_lower_hook = XTframe_raise_lower;
+  terminal->frame_visible_invisible_hook = x_make_frame_visible_invisible;
   terminal->fullscreen_hook = XTfullscreen_hook;
+  terminal->iconify_frame_hook = x_iconify_frame;
+  terminal->set_window_size_hook = x_set_window_size;
+  terminal->set_frame_offset_hook = x_set_offset;
+  terminal->set_frame_alpha_hook = x_set_frame_alpha;
+  terminal->set_new_font_hook = x_new_font;
+  terminal->set_bitmap_icon_hook = x_bitmap_icon;
+  terminal->implicit_set_name_hook = x_implicitly_set_name;
   terminal->menu_show_hook = x_menu_show;
+#ifdef HAVE_EXT_MENU_BAR
+  terminal->activate_menubar_hook = x_activate_menubar;
+#endif
 #if defined (USE_X_TOOLKIT) || defined (USE_GTK)
   terminal->popup_dialog_hook = xw_popup_dialog;
 #endif
+#ifndef HAVE_EXT_TOOL_BAR
+  terminal->change_tool_bar_height_hook = x_change_tool_bar_height;
+#endif
   terminal->set_vertical_scroll_bar_hook = XTset_vertical_scroll_bar;
   terminal->set_horizontal_scroll_bar_hook = XTset_horizontal_scroll_bar;
+  terminal->set_scroll_bar_default_width_hook = x_set_scroll_bar_default_width;
+  terminal->set_scroll_bar_default_height_hook = 
x_set_scroll_bar_default_height;
   terminal->condemn_scroll_bars_hook = XTcondemn_scroll_bars;
   terminal->redeem_scroll_bar_hook = XTredeem_scroll_bar;
   terminal->judge_scroll_bars_hook = XTjudge_scroll_bars;
+  terminal->get_string_resource_hook = x_get_string_resource;
   terminal->delete_frame_hook = x_destroy_window;
   terminal->delete_terminal_hook = x_delete_terminal;
   /* Other hooks are NULL by default.  */
@@ -13258,6 +13391,7 @@ void
 syms_of_xterm (void)
 {
   x_error_message = NULL;
+  PDUMPER_IGNORE (x_error_message);
 
   DEFSYM (Qvendor_specific_keysyms, "vendor-specific-keysyms");
   DEFSYM (Qlatin_1, "latin-1");
diff --git a/src/xterm.h b/src/xterm.h
index 2ea8a93..266a42a 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -1,5 +1,5 @@
 /* Definitions and headers for communication with X protocol.
-   Copyright (C) 1989, 1993-1994, 1998-2018 Free Software Foundation,
+   Copyright (C) 1989, 1993-1994, 1998-2019 Free Software Foundation,
    Inc.
 
 This file is part of GNU Emacs.
@@ -50,17 +50,8 @@ typedef Widget xt_or_gtk_widget;
 #include <gdk/gdkx.h>
 #endif /* USE_GTK */
 
-/* True iff GTK's version is at least I.J.K.  */
-#ifndef GTK_CHECK_VERSION
-# ifdef USE_GTK
-#  define GTK_CHECK_VERSION(i, j, k) \
-     ((i) \
-      < GTK_MAJOR_VERSION + ((j) \
-                            < GTK_MINOR_VERSION + ((k) \
-                                                   <= GTK_MICRO_VERSION)))
-# else
-#  define GTK_CHECK_VERSION(i, j, k) false
-# endif
+#ifndef USE_GTK
+#define GTK_CHECK_VERSION(i, j, k) false
 #endif
 
 #ifdef USE_GTK
@@ -76,11 +67,6 @@ typedef GtkWidget *xt_or_gtk_widget;
 #endif
 #endif /* USE_GTK */
 
-/* The GtkTooltip API came in 2.12, but gtk-enable-tooltips in 2.14. */
-#if GTK_CHECK_VERSION (2, 14, 0)
-#define USE_GTK_TOOLTIP
-#endif
-
 #ifdef USE_CAIRO
 #include <cairo-xlib.h>
 #ifdef CAIRO_HAS_PDF_SURFACE
@@ -249,7 +235,7 @@ struct x_display_info
 #endif
 
   /* X Resource data base */
-  XrmDatabase xrdb;
+  XrmDatabase rdb;
 
   /* Minimum width over all characters in all fonts in font_table.  */
   int smallest_char_width;
@@ -364,7 +350,7 @@ struct x_display_info
      event).  It points to the X focus frame's selected window's
      frame.  It differs from x_focus_frame when we're using a global
      minibuffer.  */
-  struct frame *x_highlight_frame;
+  struct frame *highlight_frame;
 
   /* The frame waiting to be auto-raised in XTread_socket.  */
   struct frame *x_pending_autoraise_frame;
@@ -594,12 +580,9 @@ struct x_output
   GdkGeometry size_hints;
   long hint_flags;
 
-#ifdef USE_GTK_TOOLTIP
   GtkTooltip *ttip_widget;
   GtkWidget *ttip_lbl;
   GtkWindow *ttip_window;
-#endif /* USE_GTK_TOOLTIP */
-
 #endif /* USE_GTK */
 
   /* If >=0, a bitmap index.  The indicated bitmap is used for the
@@ -764,9 +747,11 @@ enum
 
 /* Return the X output data for frame F.  */
 #define FRAME_X_OUTPUT(f) ((f)->output_data.x)
+#define FRAME_OUTPUT_DATA(f) FRAME_X_OUTPUT (f)
 
 /* Return the X window used for displaying data in frame F.  */
 #define FRAME_X_WINDOW(f) ((f)->output_data.x->window_desc)
+#define FRAME_NATIVE_WINDOW(f) FRAME_X_WINDOW (f)
 
 /* Return the drawable used for rendering to frame F.  */
 #define FRAME_X_RAW_DRAWABLE(f) ((f)->output_data.x->draw_desc)
@@ -793,18 +778,6 @@ extern void x_mark_frame_dirty (struct frame *f);
                                FRAME_X_WINDOW (f))
 #else
 #ifdef USE_GTK
-/* Functions not present in older Gtk+ */
-
-#ifndef HAVE_GTK_WIDGET_GET_WINDOW
-#define gtk_widget_get_window(w) ((w)->window)
-#endif
-#ifndef HAVE_GTK_WIDGET_GET_MAPPED
-#define gtk_widget_get_mapped(w) (GTK_WIDGET_MAPPED (w))
-#endif
-#ifndef HAVE_GTK_ADJUSTMENT_GET_PAGE_SIZE
-#define gtk_adjustment_get_page_size(w) ((w)->page_size)
-#define gtk_adjustment_get_upper(w) ((w)->upper)
-#endif
 
 #ifdef HAVE_GTK3
 #define DEFAULT_GDK_DISPLAY() \
@@ -897,7 +870,7 @@ struct scroll_bar
   /* The next and previous in the chain of scroll bars in this frame.  */
   Lisp_Object next, prev;
 
-  /* Fields from `x_window' down will not be traced by the GC.  */
+  /* Fields after 'prev' are not traced by the GC.  */
 
   /* The X window representing this scroll bar.  */
   Window x_window;
@@ -1087,6 +1060,7 @@ extern void x_real_pos_and_offsets (struct frame *f,
 
 XrmDatabase x_load_resources (Display *, const char *, const char *,
                              const char *);
+extern const char *x_get_string_resource (void *, const char *, const char *);
 
 /* Defined in xterm.c */
 
@@ -1103,8 +1077,13 @@ extern bool x_had_errors_p (Display *);
 extern void x_uncatch_errors (void);
 extern void x_uncatch_errors_after_check (void);
 extern void x_clear_errors (Display *);
-extern void xembed_request_focus (struct frame *);
-extern void x_ewmh_activate_frame (struct frame *);
+extern void x_set_window_size (struct frame *f, bool, int, int, bool);
+extern void x_make_frame_visible (struct frame *f);
+extern void x_make_frame_invisible (struct frame *f);
+extern void x_iconify_frame (struct frame *f);
+extern void x_free_frame_resources (struct frame *);
+extern void x_wm_set_size_hint (struct frame *, long, bool);
+
 extern void x_delete_terminal (struct terminal *terminal);
 extern unsigned long x_copy_color (struct frame *, unsigned long);
 #ifdef USE_X_TOOLKIT
@@ -1117,7 +1096,7 @@ extern bool x_alloc_lighter_color_for_widget (Widget, 
Display *, Colormap,
                                              double, int);
 #endif
 extern bool x_alloc_nearest_color (struct frame *, Colormap, XColor *);
-extern void x_query_color (struct frame *f, XColor *);
+extern void x_query_colors (struct frame *f, XColor *, int);
 extern void x_clear_area (struct frame *f, int, int, int, int);
 #if !defined USE_X_TOOLKIT && !defined USE_GTK
 extern void x_mouse_leave (struct x_display_info *);
@@ -1194,6 +1173,13 @@ extern void x_clear_under_internal_border (struct frame 
*f);
 extern void tear_down_x_back_buffer (struct frame *f);
 extern void initial_set_up_x_back_buffer (struct frame *f);
 
+/* Defined in xfns.c.  */
+extern void x_real_positions (struct frame *, int *, int *);
+extern void x_change_tool_bar_height (struct frame *, int);
+extern void x_implicitly_set_name (struct frame *, Lisp_Object, Lisp_Object);
+extern void x_set_scroll_bar_default_width (struct frame *);
+extern void x_set_scroll_bar_default_height (struct frame *);
+
 /* Defined in xselect.c.  */
 
 extern void x_handle_property_notify (const XPropertyEvent *);
@@ -1236,7 +1222,7 @@ extern void destroy_frame_xic (struct frame *);
 extern void xic_set_preeditarea (struct window *, int, int);
 extern void xic_set_statusarea (struct frame *);
 extern void xic_set_xfontset (struct frame *, const char *);
-extern bool x_defined_color (struct frame *, const char *, XColor *, bool);
+extern bool x_defined_color (struct frame *, const char *, XColor *, bool, 
bool);
 #ifdef HAVE_X_I18N
 extern void free_frame_xic (struct frame *);
 # if defined HAVE_X_WINDOWS && defined USE_X_TOOLKIT
diff --git a/src/xwidget.c b/src/xwidget.c
index 9229a82..2486a2d 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -1,6 +1,6 @@
 /* Support for embedding graphical components in a buffer.
 
-Copyright (C) 2011-2018 Free Software Foundation, Inc.
+Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -41,14 +41,13 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 static struct xwidget *
 allocate_xwidget (void)
 {
-  return ALLOCATE_PSEUDOVECTOR (struct xwidget, height, PVEC_XWIDGET);
+  return ALLOCATE_PSEUDOVECTOR (struct xwidget, script_callbacks, 
PVEC_XWIDGET);
 }
 
 static struct xwidget_view *
 allocate_xwidget_view (void)
 {
-  return ALLOCATE_PSEUDOVECTOR (struct xwidget_view, redisplayed,
-                                PVEC_XWIDGET_VIEW);
+  return ALLOCATE_PSEUDOVECTOR (struct xwidget_view, w, PVEC_XWIDGET_VIEW);
 }
 
 #define XSETXWIDGET(a, b) XSETPSEUDOVECTOR (a, b, PVEC_XWIDGET)
@@ -831,8 +830,7 @@ Emacs allocated area accordingly.  */)
   CHECK_XWIDGET (xwidget);
   GtkRequisition requisition;
   gtk_widget_size_request (XXWIDGET (xwidget)->widget_osr, &requisition);
-  return list2 (make_fixnum (requisition.width),
-               make_fixnum (requisition.height));
+  return list2i (requisition.width, requisition.height);
 }
 
 DEFUN ("xwidgetp",
diff --git a/src/xwidget.h b/src/xwidget.h
index c203d4f..1b6368d 100644
--- a/src/xwidget.h
+++ b/src/xwidget.h
@@ -1,6 +1,6 @@
 /* Support for embedding graphical components in a buffer.
 
-Copyright (C) 2011-2018 Free Software Foundation, Inc.
+Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -49,8 +49,7 @@ struct xwidget
 
   /* Vector of currently executing scripts with callbacks.  */
   Lisp_Object script_callbacks;
-
-  /* Here ends the Lisp part.  "height" is the marker field.  */
+  /* Here ends the Lisp part.  script_callbacks is the marker field.  */
 
   int height;
   int width;
@@ -68,8 +67,7 @@ struct xwidget_view
   union vectorlike_header header;
   Lisp_Object model;
   Lisp_Object w;
-
-  /* Here ends the lisp part.  "redisplayed" is the marker field.  */
+  /* Here ends the lisp part.  "w" is the marker field.  */
 
   /* If touched by redisplay.  */
   bool redisplayed;
diff --git a/test/ChangeLog.1 b/test/ChangeLog.1
index 279238f..0ed7b9a 100644
--- a/test/ChangeLog.1
+++ b/test/ChangeLog.1
@@ -2952,7 +2952,7 @@
 ;; coding: utf-8
 ;; End:
 
-  Copyright (C) 2008-2018 Free Software Foundation, Inc.
+  Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
   This file is part of GNU Emacs.
 
diff --git a/test/Makefile.in b/test/Makefile.in
index adb316c..ec20a42 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -1,6 +1,6 @@
 ### @configure_input@
 
-# Copyright (C) 2010-2018 Free Software Foundation, Inc.
+# Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 # This file is part of GNU Emacs.
 
@@ -190,6 +190,12 @@ else
 maybe_exclude_module_tests := -name emacs-module-tests.el -prune -o
 endif
 
+## Optional list of .el files to exclude from testing.
+## Intended for use in automated testing where one or more files
+## has some problem and needs to be excluded.
+## To avoid writing full name, can use eg %foo-tests.el.
+EXCLUDE_TESTS =
+
 ## To speed up parallel builds, put these slow test files (which can
 ## take longer than all the rest combined) at the start of the list.
 SLOW_TESTS = ${srcdir}/lisp/net/tramp-tests.el
@@ -202,6 +208,8 @@ ELFILES := $(sort $(shell find ${srcdir} -path 
"${srcdir}/manual" -prune -o \
 
 $(foreach slow,${SLOW_TESTS},$(eval ELFILES:= ${slow} $(filter-out 
${slow},${ELFILES})))
 
+$(foreach exclude,${EXCLUDE_TESTS},$(eval ELFILES:= $(filter-out 
${exclude},${ELFILES})))
+
 ## .log files may be in a different directory for out of source builds
 LOGFILES := $(patsubst %.el,%.log, \
                $(patsubst $(srcdir)/%,%,$(ELFILES)))
@@ -246,17 +254,23 @@ else
 FPIC_CFLAGS = -fPIC
 endif
 
+HYBRID_MALLOC = @HYBRID_MALLOC@
+LIBEGNU_ARCHIVE = ../lib/lib$(if $(HYBRID_MALLOC),e)gnu.a
+GMP_LIB = @GMP_LIB@
+GMP_OBJ = $(if @GMP_OBJ@, ../src/@GMP_OBJ@)
+
 # Note: emacs-module.h is generated from emacs-module.h.in, hence we
 # look in ../src, not $(srcdir)/../src.
-MODULE_CFLAGS = -I../src $(FPIC_CFLAGS) $(PROFILING_CFLAGS) \
+MODULE_CFLAGS = -I../src -I$(srcdir)/../lib \
+  $(FPIC_CFLAGS) $(PROFILING_CFLAGS) \
   $(WARN_CFLAGS) $(WERROR_CFLAGS) $(CFLAGS)
 
 test_module = $(test_module_dir)/mod-test${SO}
 src/emacs-module-tests.log: $(test_module)
-$(test_module): $(test_module:${SO}=.c) ../src/emacs-module.h
+$(test_module): $(test_module:${SO}=.c) ../src/emacs-module.h 
$(LIBEGNU_ARCHIVE)
        $(AM_V_at)${MKDIR_P} $(dir $@)
        $(AM_V_CCLD)$(CC) -shared $(CPPFLAGS) $(MODULE_CFLAGS) $(LDFLAGS) \
-         -o $@ $<
+         -o $@ $< $(LIBEGNU_ARCHIVE) $(GMP_LIB) $(GMP_OBJ)
 endif
 
 ## Check that there is no 'automated' subdirectory, which would
diff --git a/test/README b/test/README
index e6f28ec..cd6905d 100644
--- a/test/README
+++ b/test/README
@@ -1,4 +1,4 @@
-Copyright (C) 2008-2018 Free Software Foundation, Inc.
+Copyright (C) 2008-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
 This directory contains files intended to test various aspects of
@@ -89,6 +89,16 @@ value in order to overwrite the default value:
   env REMOTE_TEMPORARY_FILE_DIRECTORY=/ssh:host:/tmp make ...
 
 
+There are also continuous integration tests on
+<https://hydra.nixos.org/jobset/gnu/emacs-trunk> (see
+admin/notes/hydra) and <https://emba.gnu.org/emacs/emacs>.  Both
+environments provide an environment variable, which could be used to
+determine, whether the tests run in one of these test environments.
+
+$EMACS_HYDRA_CI indicates the hydra environment, and $EMACS_EMBA_CI
+indicates the emba environment, respectively.
+
+
 (Also, see etc/compilation.txt for compilation mode font lock tests.)
 
 
diff --git a/test/data/decompress/tg.tar.gz b/test/data/decompress/tg.tar.gz
new file mode 100644
index 0000000..3dc8185
Binary files /dev/null and b/test/data/decompress/tg.tar.gz differ
diff --git a/test/data/decompress/zg.zip b/test/data/decompress/zg.zip
new file mode 100644
index 0000000..c4c998e
Binary files /dev/null and b/test/data/decompress/zg.zip differ
diff --git a/test/data/emacs-module/mod-test.c 
b/test/data/emacs-module/mod-test.c
index a9b459b..b7007bd 100644
--- a/test/data/emacs-module/mod-test.c
+++ b/test/data/emacs-module/mod-test.c
@@ -1,6 +1,6 @@
 /* Test GNU Emacs modules.
 
-Copyright 2015-2018 Free Software Foundation, Inc.
+Copyright 2015-2019 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -17,12 +17,28 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
 
+#include "config.h"
+
 #include <assert.h>
+#include <errno.h>
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <limits.h>
+#include <string.h>
+#include <time.h>
+
+#ifdef HAVE_GMP
+#include <gmp.h>
+#else
+#include "mini-gmp.h"
+#define EMACS_MODULE_HAVE_MPZ_T
+#endif
+
+#define EMACS_MODULE_GMP
 #include <emacs-module.h>
 
+#include "timespec.h"
+
 int plugin_is_GPL_compatible;
 
 #if INTPTR_MAX <= 0
@@ -86,7 +102,7 @@ Fmod_test_signal (emacs_env *env, ptrdiff_t nargs, 
emacs_value args[],
   assert (env->non_local_exit_check (env) == emacs_funcall_exit_return);
   env->non_local_exit_signal (env, env->intern (env, "error"),
                              env->make_integer (env, 56));
-  return env->intern (env, "nil");
+  return NULL;
 }
 
 
@@ -98,7 +114,7 @@ Fmod_test_throw (emacs_env *env, ptrdiff_t nargs, 
emacs_value args[],
   assert (env->non_local_exit_check (env) == emacs_funcall_exit_return);
   env->non_local_exit_throw (env, env->intern (env, "tag"),
                             env->make_integer (env, 65));
-  return env->intern (env, "nil");
+  return NULL;
 }
 
 
@@ -296,9 +312,110 @@ Fmod_test_invalid_finalizer (emacs_env *env, ptrdiff_t 
nargs, emacs_value *args,
 {
   current_env = env;
   env->make_user_ptr (env, invalid_finalizer, NULL);
-  return env->funcall (env, env->intern (env, "garbage-collect"), 0, NULL);
+  return env->intern (env, "nil");
+}
+
+static void
+signal_wrong_type_argument (emacs_env *env, const char *predicate,
+                            emacs_value arg)
+{
+  emacs_value symbol = env->intern (env, "wrong-type-argument");
+  emacs_value elements[2] = {env->intern (env, predicate), arg};
+  emacs_value data = env->funcall (env, env->intern (env, "list"), 2, 
elements);
+  env->non_local_exit_signal (env, symbol, data);
+}
+
+static void
+signal_errno (emacs_env *env, const char *function)
+{
+  const char *message = strerror (errno);
+  emacs_value message_value = env->make_string (env, message, strlen 
(message));
+  emacs_value symbol = env->intern (env, "file-error");
+  emacs_value elements[2]
+    = {env->make_string (env, function, strlen (function)), message_value};
+  emacs_value data = env->funcall (env, env->intern (env, "list"), 2, 
elements);
+  env->non_local_exit_signal (env, symbol, data);
+}
+
+/* A long-running operation that occasionally calls `should_quit' or
+   `process_input'.  */
+
+static emacs_value
+Fmod_test_sleep_until (emacs_env *env, ptrdiff_t nargs, emacs_value *args,
+                       void *data)
+{
+  assert (nargs == 2);
+  const double until_seconds = env->extract_float (env, args[0]);
+  if (env->non_local_exit_check (env))
+    return NULL;
+  if (until_seconds <= 0)
+    {
+      signal_wrong_type_argument (env, "cl-plusp", args[0]);
+      return NULL;
+    }
+  const bool process_input = env->is_not_nil (env, args[1]);
+  const struct timespec until = dtotimespec (until_seconds);
+  const struct timespec amount = make_timespec(0,  10000000);
+  while (true)
+    {
+      const struct timespec now = current_timespec ();
+      if (timespec_cmp (now, until) >= 0)
+        break;
+      if (nanosleep (&amount, NULL) && errno != EINTR)
+        {
+          signal_errno (env, "nanosleep");
+          return NULL;
+        }
+      if ((process_input
+           && env->process_input (env) == emacs_process_input_quit)
+          || env->should_quit (env))
+        return NULL;
+    }
+  return env->intern (env, "finished");
 }
 
+static emacs_value
+Fmod_test_add_nanosecond (emacs_env *env, ptrdiff_t nargs, emacs_value *args,
+                          void *data)
+{
+  assert (nargs == 1);
+  struct timespec time = env->extract_time (env, args[0]);
+  assert (time.tv_nsec >= 0);
+  assert (time.tv_nsec < 2000000000);  /* possible leap second */
+  time.tv_nsec++;
+  return env->make_time (env, time);
+}
+
+static emacs_value
+Fmod_test_nanoseconds (emacs_env *env, ptrdiff_t nargs, emacs_value *args, 
void *data) {
+  assert (nargs == 1);
+  struct timespec time = env->extract_time (env, args[0]);
+  struct emacs_mpz nanoseconds;
+  assert (LONG_MIN <= time.tv_sec && time.tv_sec <= LONG_MAX);
+  mpz_init_set_si (nanoseconds.value, time.tv_sec);
+  static_assert (1000000000 <= ULONG_MAX, "unsupported architecture");
+  mpz_mul_ui (nanoseconds.value, nanoseconds.value, 1000000000);
+  assert (0 <= time.tv_nsec && time.tv_nsec <= ULONG_MAX);
+  mpz_add_ui (nanoseconds.value, nanoseconds.value, time.tv_nsec);
+  emacs_value result = env->make_big_integer (env, &nanoseconds);
+  mpz_clear (nanoseconds.value);
+  return result;
+}
+
+static emacs_value
+Fmod_test_double (emacs_env *env, ptrdiff_t nargs, emacs_value *args,
+                  void *data)
+{
+  assert (nargs == 1);
+  emacs_value arg = args[0];
+  struct emacs_mpz value;
+  mpz_init (value.value);
+  env->extract_big_integer (env, arg, &value);
+  mpz_mul_ui (value.value, value.value, 2);
+  emacs_value result = env->make_big_integer (env, &value);
+  mpz_clear (value.value);
+  return result;
+}
 
 /* Lisp utilities for easier readability (simple wrappers).  */
 
@@ -367,6 +484,10 @@ emacs_module_init (struct emacs_runtime *ert)
   DEFUN ("mod-test-invalid-load", Fmod_test_invalid_load, 0, 0, NULL, NULL);
   DEFUN ("mod-test-invalid-finalizer", Fmod_test_invalid_finalizer, 0, 0,
          NULL, NULL);
+  DEFUN ("mod-test-sleep-until", Fmod_test_sleep_until, 2, 2, NULL, NULL);
+  DEFUN ("mod-test-add-nanosecond", Fmod_test_add_nanosecond, 1, 1, NULL, 
NULL);
+  DEFUN ("mod-test-nanoseconds", Fmod_test_nanoseconds, 1, 1, NULL, NULL);
+  DEFUN ("mod-test-double", Fmod_test_double, 1, 1, NULL, NULL);
 
 #undef DEFUN
 
diff --git a/test/data/shr/ol.html b/test/data/shr/ol.html
new file mode 100644
index 0000000..f9a15f2
--- /dev/null
+++ b/test/data/shr/ol.html
@@ -0,0 +1,29 @@
+<ol>
+  <li>one</li>
+  <li>two</li>
+  <li>three</li>
+</ol>
+
+<ol start="10">
+  <li>ten</li>
+  <li>eleven</li>
+  <li>twelve</li>
+</ol>
+
+<ol start="0">
+  <li>zero</li>
+  <li>one</li>
+  <li>two</li>
+</ol>
+
+<ol start="-5">
+  <li>minus five</li>
+  <li>minus four</li>
+  <li>minus three</li>
+</ol>
+
+<ol start="notanumber">
+  <li>one</li>
+  <li>two</li>
+  <li>three</li>
+</ol>
diff --git a/test/data/shr/ol.txt b/test/data/shr/ol.txt
new file mode 100644
index 0000000..0d46e2a
--- /dev/null
+++ b/test/data/shr/ol.txt
@@ -0,0 +1,19 @@
+1 one
+2 two
+3 three
+
+10 ten
+11 eleven
+12 twelve
+
+0 zero
+1 one
+2 two
+
+-5 minus five
+-4 minus four
+-3 minus three
+
+1 one
+2 two
+3 three
diff --git a/test/data/vc/diff-mode/hello_emacs.c 
b/test/data/vc/diff-mode/hello_emacs.c
new file mode 100644
index 0000000..c7ed753
--- /dev/null
+++ b/test/data/vc/diff-mode/hello_emacs.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+int main()
+{
+  printf("Hello, Emacs!\n");
+  return 0;
+}
diff --git a/test/data/vc/diff-mode/hello_emacs_1.c 
b/test/data/vc/diff-mode/hello_emacs_1.c
new file mode 100644
index 0000000..62145a6
--- /dev/null
+++ b/test/data/vc/diff-mode/hello_emacs_1.c
@@ -0,0 +1 @@
+int main() { printf("Hello, Emacs!\n"); return 0; }
\ No newline at end of file
diff --git a/test/data/vc/diff-mode/hello_world.c 
b/test/data/vc/diff-mode/hello_world.c
new file mode 100644
index 0000000..dcbe06c
--- /dev/null
+++ b/test/data/vc/diff-mode/hello_world.c
@@ -0,0 +1,6 @@
+#include <stdio.h>
+int main()
+{
+  printf("Hello, World!\n");
+  return 0;
+}
diff --git a/test/data/vc/diff-mode/hello_world_1.c 
b/test/data/vc/diff-mode/hello_world_1.c
new file mode 100644
index 0000000..606afb3
--- /dev/null
+++ b/test/data/vc/diff-mode/hello_world_1.c
@@ -0,0 +1 @@
+int main() { printf("Hello, World!\n"); return 0; }
\ No newline at end of file
diff --git a/test/lib-src/emacsclient-tests.el 
b/test/lib-src/emacsclient-tests.el
index 9676595..0b58fef 100644
--- a/test/lib-src/emacsclient-tests.el
+++ b/test/lib-src/emacsclient-tests.el
@@ -1,6 +1,6 @@
 ;;; emacsclient-tests.el --- Test emacsclient
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/abbrev-tests.el b/test/lisp/abbrev-tests.el
index e50f931..3b8acf5 100644
--- a/test/lisp/abbrev-tests.el
+++ b/test/lisp/abbrev-tests.el
@@ -1,6 +1,6 @@
 ;;; abbrev-tests.el --- Test suite for abbrevs  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Eli Zaretskii <address@hidden>
 ;; Keywords: abbrevs
diff --git a/test/lisp/arc-mode-tests.el b/test/lisp/arc-mode-tests.el
index c82599a..79d3ac6 100644
--- a/test/lisp/arc-mode-tests.el
+++ b/test/lisp/arc-mode-tests.el
@@ -1,6 +1,6 @@
 ;;; arc-mode-tests.el --- Test suite for arc-mode. -*- lexical-binding: t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -21,6 +21,8 @@
 (require 'ert)
 (require 'arc-mode)
 
+(defvar arc-mode-tests-data-directory
+  (expand-file-name "test/data/decompress" source-directory))
 
 (ert-deftest arc-mode-test-archive-int-to-mode ()
   (let ((alist (list (cons 448 "-rwx------")
@@ -32,6 +34,18 @@
     (dolist (x alist)
       (should (equal (cdr x) (archive-int-to-mode (car x)))))))
 
+(ert-deftest arc-mode-test-zip-extract-gz ()
+  (skip-unless (and archive-zip-extract (executable-find (car 
archive-zip-extract))))
+  (skip-unless (executable-find "gzip"))
+  (let* ((zip-file (expand-file-name "zg.zip" arc-mode-tests-data-directory))
+         zip-buffer gz-buffer)
+    (unwind-protect
+        (with-current-buffer (setq zip-buffer (find-file-noselect zip-file))
+          (setq gz-buffer (archive-extract))
+          (should (equal (char-after) ?\N{SNOWFLAKE})))
+      (when (buffer-live-p zip-buffer) (kill-buffer zip-buffer))
+      (when (buffer-live-p gz-buffer) (kill-buffer gz-buffer)))))
+
 (provide 'arc-mode-tests)
 
 ;; arc-mode-tests.el ends here
diff --git a/test/lisp/auth-source-pass-tests.el 
b/test/lisp/auth-source-pass-tests.el
index b30419f..d1e486a 100644
--- a/test/lisp/auth-source-pass-tests.el
+++ b/test/lisp/auth-source-pass-tests.el
@@ -1,6 +1,6 @@
 ;;; auth-source-pass-tests.el --- Tests for auth-source-pass.el  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2013, 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Damien Cassou <address@hidden>
 
diff --git a/test/lisp/auth-source-tests.el b/test/lisp/auth-source-tests.el
index ca8a3eb..c8460c0 100644
--- a/test/lisp/auth-source-tests.el
+++ b/test/lisp/auth-source-tests.el
@@ -1,6 +1,6 @@
 ;;; auth-source-tests.el --- Tests for auth-source.el  -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Damien Cassou <address@hidden>,
 ;;         Nicolas Petton <address@hidden>
diff --git a/test/lisp/autorevert-tests.el b/test/lisp/autorevert-tests.el
index abf73ff..6e8219d 100644
--- a/test/lisp/autorevert-tests.el
+++ b/test/lisp/autorevert-tests.el
@@ -1,6 +1,6 @@
 ;;; auto-revert-tests.el --- Tests of auto-revert
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 
diff --git a/test/lisp/buff-menu-tests.el b/test/lisp/buff-menu-tests.el
index a942a56..d49abc4 100644
--- a/test/lisp/buff-menu-tests.el
+++ b/test/lisp/buff-menu-tests.el
@@ -1,6 +1,6 @@
 ;;; buff-menu-tests.el --- Test suite for buff-menu.el -*- lexical-binding: t 
-*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Tino Calancha <address@hidden>
 
diff --git a/test/lisp/button-tests.el b/test/lisp/button-tests.el
new file mode 100644
index 0000000..d54a992
--- /dev/null
+++ b/test/lisp/button-tests.el
@@ -0,0 +1,40 @@
+;;; button-tests.el --- tests for button.el -*- lexical-binding: t -*-
+
+;; Copyright (C) 2019 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert)
+
+(ert-deftest button-at ()
+  "Test `button-at' behavior."
+  (with-temp-buffer
+    (should-not (button-at (point)))
+    (let ((button (insert-text-button "text button"))
+          (marker (button-at (1- (point)))))
+      (should (markerp marker))
+      (should (= (button-end button) (button-end marker) (point))))
+    (let ((button  (insert-button "overlay button"))
+          (overlay (button-at (1- (point)))))
+      (should (overlayp overlay))
+      (should (eq button overlay)))
+    ;; Buttons and widgets are incompatible (bug#34506).
+    (widget-create 'link "link widget")
+    (should-not (button-at (1- (point))))))
+
+;;; button-tests.el ends here
diff --git a/test/lisp/calc/calc-tests.el b/test/lisp/calc/calc-tests.el
index 101786c..8afec59 100644
--- a/test/lisp/calc/calc-tests.el
+++ b/test/lisp/calc/calc-tests.el
@@ -1,6 +1,6 @@
 ;;; calc-tests.el --- tests for calc                 -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Leo Liu <address@hidden>
 ;; Keywords: maint
diff --git a/test/lisp/calendar/icalendar-tests.el 
b/test/lisp/calendar/icalendar-tests.el
index 617e886..af617e6 100644
--- a/test/lisp/calendar/icalendar-tests.el
+++ b/test/lisp/calendar/icalendar-tests.el
@@ -1,6 +1,6 @@
 ;; icalendar-tests.el --- Test suite for icalendar.el
 
-;; Copyright (C) 2005, 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2008-2019 Free Software Foundation, Inc.
 
 ;; Author:         Ulf Jasper <address@hidden>
 ;; Created:        March 2005
diff --git a/test/lisp/calendar/parse-time-tests.el 
b/test/lisp/calendar/parse-time-tests.el
index ca71ff7..7435620 100644
--- a/test/lisp/calendar/parse-time-tests.el
+++ b/test/lisp/calendar/parse-time-tests.el
@@ -1,6 +1,6 @@
 ;; parse-time-tests.el --- Test suite for parse-time.el
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Ingebrigtsen <address@hidden>
 
diff --git a/test/lisp/calendar/todo-mode-tests.el 
b/test/lisp/calendar/todo-mode-tests.el
index 015fbac..7d4f7a7 100644
--- a/test/lisp/calendar/todo-mode-tests.el
+++ b/test/lisp/calendar/todo-mode-tests.el
@@ -1,6 +1,6 @@
 ;;; todo-mode-tests.el --- tests for todo-mode.el  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Stephen Berman <address@hidden>
 ;; Keywords: calendar
diff --git a/test/lisp/char-fold-tests.el b/test/lisp/char-fold-tests.el
index 3649753..8a647bd 100644
--- a/test/lisp/char-fold-tests.el
+++ b/test/lisp/char-fold-tests.el
@@ -1,6 +1,6 @@
 ;;; char-fold-tests.el --- Tests for char-fold.el  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Artur Malabarba <address@hidden>
 
diff --git a/test/lisp/color-tests.el b/test/lisp/color-tests.el
index 17c43e2..dceed1a 100644
--- a/test/lisp/color-tests.el
+++ b/test/lisp/color-tests.el
@@ -1,6 +1,6 @@
 ;;; color-tests.el --- Tests for color.el  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Simen Heggestøyl <address@hidden>
 ;; Keywords:
diff --git a/test/lisp/comint-tests.el b/test/lisp/comint-tests.el
index eab2709..49e59c5 100644
--- a/test/lisp/comint-tests.el
+++ b/test/lisp/comint-tests.el
@@ -1,6 +1,6 @@
 ;;; comint-testsuite.el
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/custom-resources/custom--test-theme.el 
b/test/lisp/custom-resources/custom--test-theme.el
new file mode 100644
index 0000000..da9121e
--- /dev/null
+++ b/test/lisp/custom-resources/custom--test-theme.el
@@ -0,0 +1,9 @@
+(deftheme custom--test
+  "A test theme.")
+
+(custom-theme-set-variables
+ 'custom--test
+ '(custom--test-user-option 'bar)
+ '(custom--test-variable 'bar))
+
+(provide-theme 'custom--test)
diff --git a/test/lisp/custom-tests.el b/test/lisp/custom-tests.el
index 96887f8..0c49db6 100644
--- a/test/lisp/custom-tests.el
+++ b/test/lisp/custom-tests.el
@@ -1,6 +1,6 @@
 ;;; custom-tests.el --- tests for custom.el  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -84,4 +84,43 @@
       (when (file-directory-p tmpdir)
         (delete-directory tmpdir t)))))
 
+(defcustom custom--test-user-option 'foo
+  "User option for test."
+  :group 'emacs
+  :type 'symbol)
+
+(defvar custom--test-variable 'foo
+  "Variable for test.")
+
+;; This is demonstrating bug#34027.
+(ert-deftest custom--test-theme-variables ()
+  "Test variables setting with enabling / disabling a custom theme."
+  :expected-result :failed
+  ;; We load custom-resources/custom--test-theme.el.
+  (let ((custom-theme-load-path
+         `(,(expand-file-name "custom-resources" (file-name-directory #$)))))
+    (load-theme 'custom--test 'no-confirm 'no-enable)
+    ;; The variables have still their initial values.
+    (should (equal custom--test-user-option 'foo))
+    (should (equal custom--test-variable 'foo))
+
+    (custom-set-variables
+     '(custom--test-user-option 'baz)
+     '(custom--test-variable 'baz))
+    ;; The initial values have been changed.
+    (should (equal custom--test-user-option 'baz))
+    (should (equal custom--test-variable 'baz))
+
+    (enable-theme 'custom--test)
+    ;; The variables have the theme values.
+    (should (equal custom--test-user-option 'bar))
+    (should (equal custom--test-variable 'bar))
+
+    (disable-theme 'custom--test)
+    ;; The variables should have the changed values, by reverting.
+    ;; This doesn't work as expected.  Instead, they have their
+    ;; initial values `foo'.
+    (should (equal custom--test-user-option 'baz))
+    (should (equal custom--test-variable 'baz))))
+
 ;;; custom-tests.el ends here
diff --git a/test/lisp/dabbrev-tests.el b/test/lisp/dabbrev-tests.el
index 8084674..a6ab2e7 100644
--- a/test/lisp/dabbrev-tests.el
+++ b/test/lisp/dabbrev-tests.el
@@ -1,6 +1,6 @@
 ;;; dabbrev-tests.el --- Test suite for dabbrev.
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Alan Third <address@hidden>
 ;; Keywords: dabbrev
diff --git a/test/lisp/descr-text-tests.el b/test/lisp/descr-text-tests.el
index c3b102b..09dadde 100644
--- a/test/lisp/descr-text-tests.el
+++ b/test/lisp/descr-text-tests.el
@@ -1,6 +1,6 @@
 ;;; descr-text-test.el --- ERT tests for descr-text.el -*- lexical-binding: t 
-*-
 
-;; Copyright (C) 2014, 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014, 2016-2019 Free Software Foundation, Inc.
 
 ;; Author:     Michal Nazarewicz <address@hidden>
 
diff --git a/test/lisp/dired-aux-tests.el b/test/lisp/dired-aux-tests.el
index daf60f7..ccd3192 100644
--- a/test/lisp/dired-aux-tests.el
+++ b/test/lisp/dired-aux-tests.el
@@ -1,6 +1,6 @@
 ;;; dired-aux-tests.el --- Test suite for dired-aux. -*- lexical-binding: t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/dired-tests.el b/test/lisp/dired-tests.el
index 49ae4bc..71ffcdd 100644
--- a/test/lisp/dired-tests.el
+++ b/test/lisp/dired-tests.el
@@ -1,6 +1,6 @@
 ;;; dired-tests.el --- Test suite. -*- lexical-binding: t -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/dired-x-tests.el b/test/lisp/dired-x-tests.el
index 9cdbcb4..d4d6934 100644
--- a/test/lisp/dired-x-tests.el
+++ b/test/lisp/dired-x-tests.el
@@ -1,6 +1,6 @@
 ;;; dired-x-tests.el --- Test suite for dired-x. -*- lexical-binding: t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/dom-tests.el b/test/lisp/dom-tests.el
index 77c9a01..fb87b7b 100644
--- a/test/lisp/dom-tests.el
+++ b/test/lisp/dom-tests.el
@@ -1,6 +1,6 @@
 ;;; dom-tests.el --- Tests for dom.el  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Simen Heggestøyl <address@hidden>
 ;; Keywords:
diff --git a/test/lisp/electric-tests.el b/test/lisp/electric-tests.el
index a665d2e..4f1e572 100644
--- a/test/lisp/electric-tests.el
+++ b/test/lisp/electric-tests.el
@@ -1,6 +1,6 @@
 ;;; electric-tests.el --- tests for electric.el
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: João Távora <address@hidden>
 ;; Keywords:
@@ -157,7 +157,7 @@ The buffer's contents should %s:
           expected-string
           expected-point
           bindings
-          (modes '(quote (ruby-mode c++-mode)))
+          (modes '(quote (ruby-mode js-mode)))
           (test-in-comments t)
           (test-in-strings t)
           (test-in-code t)
@@ -391,10 +391,17 @@ baz\"\""
   :bindings '((electric-pair-skip-whitespace . chomp))
   :test-in-comments nil)
 
-
-;; A test failure introduced by some changes in CC mode.  Hopefully CC
-;; mode will sort this out eventually, using some new e-p-m machinery.
-;; See
+(ert-deftest 
electric-pair-whitespace-chomping-2-at-point-4-in-c++-mode-in-strings nil
+  "Check if whitespace chomping works in `c++' unterminated strings."
+  (electric-pair-test-for
+   "\" ( \n            \n  )  \"" 4 41 "\" ()  \"" 5 'c++-mode
+   '((electric-pair-skip-whitespace . chomp))
+   (lambda () (electric-pair-mode 1))))
+;; A test failure introduced by:
+;;
+;;    bb591f139f: Enhance CC Mode's fontification, etc., of unterminated 
strings.
+;;
+;; Hopefully CC mode will sort this out eventually.  See
 ;; https://lists.gnu.org/archive/html/emacs-devel/2018-06/msg00535.html
 (setf
  (ert-test-expected-result-type
@@ -507,6 +514,7 @@ baz\"\""
   :fixture-fn #'(lambda ()
                   (electric-pair-mode 1)))
 
+
 (define-electric-pair-test js-mode-braces-with-layout
   "" "{" :expected-string "{\n\n}" :expected-point 3
   :modes '(js-mode)
@@ -526,6 +534,16 @@ baz\"\""
                   (electric-indent-mode 1)
                   (electric-layout-mode 1)))
 
+(define-electric-pair-test js-mode-braces-with-layout-and-indent
+  "" "{" :expected-string "{\n    \n}" :expected-point 7
+  :modes '(js-mode)
+  :test-in-comments nil
+  :test-in-strings nil
+  :fixture-fn #'(lambda ()
+                  (electric-pair-mode 1)
+                  (electric-indent-mode 1)
+                  (electric-layout-mode 1)))
+
 
 ;;; Backspacing
 ;;; TODO: better tests
@@ -812,5 +830,127 @@ baz\"\""
   :bindings '((comment-start . "<!--") (comment-use-syntax . t))
   :test-in-comments nil :test-in-strings nil)
 
+
+;;; tests for `electric-layout-mode'
+
+(define-derived-mode plainer-c-mode c-mode "pC"
+  "A plainer/saner C-mode with no internal electric machinery."
+  (c-toggle-electric-state -1)
+  (setq-local electric-indent-local-mode-hook nil)
+  (setq-local electric-indent-mode-hook nil)
+  (electric-indent-local-mode 1)
+  (dolist (key '(?\" ?\' ?\{ ?\} ?\( ?\) ?\[ ?\]))
+    (local-set-key (vector key) 'self-insert-command)))
+
+(defun electric-layout-for-c-style-du-jour (inserted)
+  "A function to use in `electric-layout-rules'"
+  (when (memq inserted '(?{ ?}))
+    (save-excursion
+      (backward-char 2) (c-point-syntax) (forward-char) ; silly, but needed
+      (c-brace-newlines (c-point-syntax)))))
+
+(ert-deftest electric-layout-plainer-c-mode-use-c-style ()
+  (ert-with-test-buffer ()
+    (plainer-c-mode)
+    (electric-layout-local-mode 1)
+    (electric-pair-local-mode 1)
+    (electric-indent-local-mode 1)
+    (setq-local electric-layout-rules
+                '(electric-layout-for-c-style-du-jour))
+    (insert "int main () ")
+    (let ((last-command-event ?\{))
+      (call-interactively (key-binding `[,last-command-event])))
+    (should (equal (buffer-string) "int main ()\n{\n  \n}\n"))))
+
+(ert-deftest electric-layout-int-main-kernel-style ()
+  (ert-with-test-buffer ()
+    (plainer-c-mode)
+    (electric-layout-local-mode 1)
+    (electric-pair-local-mode 1)
+    (electric-indent-local-mode 1)
+    (setq-local electric-layout-rules
+                '((?\{ . (after))
+                  (?\} . (before))))
+    (insert "int main () ")
+    (let ((last-command-event ?\{))
+      (call-interactively (key-binding `[,last-command-event])))
+    (should (equal (buffer-string) "int main () {\n  \n}"))))
+
+(define-derived-mode plainer-c-mode c-mode "pC"
+  "A plainer/saner C-mode with no internal electric machinery."
+  (c-toggle-electric-state -1)
+  (setq-local electric-indent-local-mode-hook nil)
+  (setq-local electric-indent-mode-hook nil)
+  (electric-indent-local-mode 1)
+  (dolist (key '(?\" ?\' ?\{ ?\} ?\( ?\) ?\[ ?\]))
+    (local-set-key (vector key) 'self-insert-command)))
+
+(ert-deftest electric-modes-int-main-allman-style ()
+  (ert-with-test-buffer ()
+    (plainer-c-mode)
+    (electric-layout-local-mode 1)
+    (electric-pair-local-mode 1)
+    (electric-indent-local-mode 1)
+    (setq-local electric-layout-rules
+                '((?\{ . (before after))
+                  (?\} . (before))))
+    (insert "int main () ")
+    (let ((last-command-event ?\{))
+      (call-interactively (key-binding `[,last-command-event])))
+    (should (equal (buffer-string) "int main ()\n{\n  \n}"))))
+
+(ert-deftest electric-pair-mode-newline-between-parens ()
+  (ert-with-test-buffer ()
+    (plainer-c-mode)
+    (electric-layout-local-mode -1) ;; ensure e-l-m mode is off
+    (electric-pair-local-mode 1)
+    (insert-before-markers "int main () {}")
+    (backward-char 1)
+    (let ((last-command-event ?
))
+      (call-interactively (key-binding `[,last-command-event])))
+    (should (equal (buffer-string) "int main () {\n  \n}"))))
+
+(ert-deftest electric-layout-mode-newline-between-parens-without-e-p-m ()
+  (ert-with-test-buffer ()
+    (plainer-c-mode)
+    (electric-layout-local-mode 1)
+    (electric-pair-local-mode -1) ;; ensure e-p-m mode is off
+    (electric-indent-local-mode 1)
+    (setq-local electric-layout-rules
+                '((?\n
+                   .
+                   (lambda ()
+                     (when (eq (save-excursion
+                                 (skip-chars-backward "\t\s")
+                                 (char-before (1- (point))))
+                               (matching-paren (char-after)))
+                       '(after-stay))))))
+    (insert "int main () {}")
+    (backward-char 1)
+    (let ((last-command-event ?
))
+      (call-interactively (key-binding `[,last-command-event])))
+    (should (equal (buffer-string) "int main () {\n  \n}"))))
+
+(ert-deftest electric-layout-mode-newline-between-parens-without-e-p-m-2 ()
+  (ert-with-test-buffer ()
+    (plainer-c-mode)
+    (electric-layout-local-mode 1)
+    (electric-pair-local-mode -1) ;; ensure e-p-m mode is off
+    (electric-indent-local-mode 1)
+    (setq-local electric-layout-rules
+                '((lambda (char)
+                    (when (and
+                           (eq char ?\n)
+                           (eq (save-excursion
+                                 (skip-chars-backward "\t\s")
+                                 (char-before (1- (point))))
+                               (matching-paren (char-after))))
+                       '(after-stay)))))
+    (insert "int main () {}")
+    (backward-char 1)
+    (let ((last-command-event ?
))
+      (call-interactively (key-binding `[,last-command-event])))
+    (should (equal (buffer-string) "int main () {\n  \n}"))))
+
 (provide 'electric-tests)
 ;;; electric-tests.el ends here
diff --git a/test/lisp/emacs-lisp/backtrace-tests.el 
b/test/lisp/emacs-lisp/backtrace-tests.el
index edd45c7..ce827e0 100644
--- a/test/lisp/emacs-lisp/backtrace-tests.el
+++ b/test/lisp/emacs-lisp/backtrace-tests.el
@@ -1,6 +1,6 @@
 ;;; backtrace-tests.el --- Tests for backtraces -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; Author: Gemini Lasswell
 
diff --git a/test/lisp/emacs-lisp/benchmark-tests.el 
b/test/lisp/emacs-lisp/benchmark-tests.el
index 26bd3ff..a8c37bb 100644
--- a/test/lisp/emacs-lisp/benchmark-tests.el
+++ b/test/lisp/emacs-lisp/benchmark-tests.el
@@ -1,6 +1,6 @@
 ;;; benchmark-tests.el --- Test suite for benchmark.  -*- lexical-binding: t 
-*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el 
b/test/lisp/emacs-lisp/bytecomp-tests.el
index ba62549..5fb64ff 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -1,6 +1,6 @@
 ;;; bytecomp-tests.el
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Shigeru Fukaya <address@hidden>
 ;; Author: Stefan Monnier <address@hidden>
@@ -540,7 +540,9 @@ literals (Bug#20852)."
         (should (equal (cdr err)
                        (list (concat "unescaped character literals "
                                      "`?\"', `?(', `?)', `?;', `?[', `?]' "
-                                     "detected!"))))))))
+                                     "detected, "
+                                     "`?\\\"', `?\\(', `?\\)', `?\\;', `?\\[', 
"
+                                     "`?\\]' expected!"))))))))
 
 (ert-deftest bytecomp-tests--old-style-backquotes ()
   "Check that byte compiling warns about old-style backquotes."
diff --git a/test/lisp/emacs-lisp/cconv-tests.el 
b/test/lisp/emacs-lisp/cconv-tests.el
index d14847c..c218bd6 100644
--- a/test/lisp/emacs-lisp/cconv-tests.el
+++ b/test/lisp/emacs-lisp/cconv-tests.el
@@ -1,6 +1,6 @@
 ;;; cconv-tests.el -*- lexical-binding: t -*-
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/emacs-lisp/checkdoc-tests.el 
b/test/lisp/emacs-lisp/checkdoc-tests.el
index 2960236..1cefc4c 100644
--- a/test/lisp/emacs-lisp/checkdoc-tests.el
+++ b/test/lisp/emacs-lisp/checkdoc-tests.el
@@ -1,6 +1,6 @@
 ;;; checkdoc-tests.el --- unit tests for checkdoc.el  -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Philipp Stephani <address@hidden>
 
diff --git a/test/lisp/emacs-lisp/cl-extra-tests.el 
b/test/lisp/emacs-lisp/cl-extra-tests.el
index baad8eb..152d431 100644
--- a/test/lisp/emacs-lisp/cl-extra-tests.el
+++ b/test/lisp/emacs-lisp/cl-extra-tests.el
@@ -1,6 +1,6 @@
 ;;; cl-extra-tests.el --- tests for emacs-lisp/cl-extra.el  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -94,4 +94,9 @@
     (should (equal (list lst3 (cdr lst3) (cddr lst3))
                    (cl-maplist fn3 lst lst2 lst3)))))
 
+(ert-deftest cl-extra-test-cl-make-random-state ()
+  (let ((s (cl-make-random-state)))
+    ;; Test for Bug#33731.
+    (should-not (eq s (cl-make-random-state s)))))
+
 ;;; cl-extra-tests.el ends here
diff --git a/test/lisp/emacs-lisp/cl-generic-tests.el 
b/test/lisp/emacs-lisp/cl-generic-tests.el
index 79de538..36e09af 100644
--- a/test/lisp/emacs-lisp/cl-generic-tests.el
+++ b/test/lisp/emacs-lisp/cl-generic-tests.el
@@ -1,6 +1,6 @@
 ;;; cl-generic-tests.el --- Tests for cl-generic.el functionality  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 
diff --git a/test/lisp/emacs-lisp/cl-lib-tests.el 
b/test/lisp/emacs-lisp/cl-lib-tests.el
index a338e16..82c2c0d 100644
--- a/test/lisp/emacs-lisp/cl-lib-tests.el
+++ b/test/lisp/emacs-lisp/cl-lib-tests.el
@@ -1,6 +1,6 @@
 ;;; cl-lib-tests.el --- tests for emacs-lisp/cl-lib.el  -*- lexical-binding:t 
-*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el 
b/test/lisp/emacs-lisp/cl-macs-tests.el
index 6e9fb44..989553b 100644
--- a/test/lisp/emacs-lisp/cl-macs-tests.el
+++ b/test/lisp/emacs-lisp/cl-macs-tests.el
@@ -1,6 +1,6 @@
 ;;; cl-macs-tests.el --- tests for emacs-lisp/cl-macs.el  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/emacs-lisp/cl-preloaded-tests.el 
b/test/lisp/emacs-lisp/cl-preloaded-tests.el
index 9d5feee..3251b5f 100644
--- a/test/lisp/emacs-lisp/cl-preloaded-tests.el
+++ b/test/lisp/emacs-lisp/cl-preloaded-tests.el
@@ -1,6 +1,6 @@
 ;;; cl-preloaded-tests.el --- unit tests for cl-preloaded.el  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 ;; Author: Philipp Stephani <address@hidden>
 
 ;; This file is part of GNU Emacs.
diff --git a/test/lisp/emacs-lisp/cl-print-tests.el 
b/test/lisp/emacs-lisp/cl-print-tests.el
index a469b55..406c528 100644
--- a/test/lisp/emacs-lisp/cl-print-tests.el
+++ b/test/lisp/emacs-lisp/cl-print-tests.el
@@ -1,6 +1,6 @@
 ;;; cl-print-tests.el --- Test suite for the cl-print facility.  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -34,7 +34,7 @@
     (let ((print-circle t))
       (should (equal (cl-prin1-to-string `((x . ,x) (y . ,x)))
                      "((x . #1=#s(cl-print--test :a 1 :b 2)) (y . #1#))")))
-    (should (string-match "\\`#f(compiled-function (x) \"[^\"]+\" [^\)]*)\\'"
+    (should (string-match "\\`#f(compiled-function (x) \"[^\"]+\" [^)]*)\\'"
                           (cl-prin1-to-string (symbol-function #'caar))))))
 
 (ert-deftest cl-print-tests-2 ()
diff --git a/test/lisp/emacs-lisp/cl-seq-tests.el 
b/test/lisp/emacs-lisp/cl-seq-tests.el
index 11a98aa..86288e9 100644
--- a/test/lisp/emacs-lisp/cl-seq-tests.el
+++ b/test/lisp/emacs-lisp/cl-seq-tests.el
@@ -1,6 +1,6 @@
 ;;; cl-seq-tests.el --- Tests for cl-seq.el functionality  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Nicolas Richard <address@hidden>
 
diff --git a/test/lisp/emacs-lisp/cl-tests.el b/test/lisp/emacs-lisp/cl-tests.el
index b673822..aee2438 100644
--- a/test/lisp/emacs-lisp/cl-tests.el
+++ b/test/lisp/emacs-lisp/cl-tests.el
@@ -1,6 +1,6 @@
 ;;; cl-tests.el --- tests for emacs-lisp/cl.el  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/emacs-lisp/derived-tests.el 
b/test/lisp/emacs-lisp/derived-tests.el
index c614f1e..1f71822 100644
--- a/test/lisp/emacs-lisp/derived-tests.el
+++ b/test/lisp/emacs-lisp/derived-tests.el
@@ -1,6 +1,6 @@
 ;;; derived-tests.el --- tests for derived.el  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el 
b/test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el
index 97dead0..0138438 100644
--- a/test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el
+++ b/test/lisp/emacs-lisp/edebug-resources/edebug-test-code.el
@@ -1,6 +1,6 @@
 ;;; edebug-test-code.el --- Sample code for the Edebug test suite
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Gemini Lasswell
 
diff --git a/test/lisp/emacs-lisp/edebug-tests.el 
b/test/lisp/emacs-lisp/edebug-tests.el
index 7880aaf..4c51740 100644
--- a/test/lisp/emacs-lisp/edebug-tests.el
+++ b/test/lisp/emacs-lisp/edebug-tests.el
@@ -1,6 +1,6 @@
 ;;; edebug-tests.el --- Edebug test suite   -*- lexical-binding:t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Gemini Lasswell
 
diff --git a/test/lisp/emacs-lisp/eieio-tests/eieio-test-methodinvoke.el 
b/test/lisp/emacs-lisp/eieio-tests/eieio-test-methodinvoke.el
index 52014ae..a7c63467 100644
--- a/test/lisp/emacs-lisp/eieio-tests/eieio-test-methodinvoke.el
+++ b/test/lisp/emacs-lisp/eieio-tests/eieio-test-methodinvoke.el
@@ -1,6 +1,6 @@
 ;;; eieio-testsinvoke.el -- eieio tests for method invocation
 
-;; Copyright (C) 2005, 2008, 2010, 2013-2018 Free Software Foundation,
+;; Copyright (C) 2005, 2008, 2010, 2013-2019 Free Software Foundation,
 ;; Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
diff --git a/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el 
b/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el
index f5c25e6..2820d16 100644
--- a/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el
+++ b/test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el
@@ -1,6 +1,6 @@
 ;;; eieio-test-persist.el --- Tests for eieio-persistent class
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el 
b/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el
index 74c7660..ea6df0f 100644
--- a/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el
+++ b/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el
@@ -1,6 +1,6 @@
 ;;; eieio-tests.el -- eieio tests routines
 
-;; Copyright (C) 1999-2003, 2005-2010, 2012-2018 Free Software
+;; Copyright (C) 1999-2003, 2005-2010, 2012-2019 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
diff --git a/test/lisp/emacs-lisp/ert-tests.el 
b/test/lisp/emacs-lisp/ert-tests.el
index 06e3fb2..36db1ee 100644
--- a/test/lisp/emacs-lisp/ert-tests.el
+++ b/test/lisp/emacs-lisp/ert-tests.el
@@ -1,6 +1,6 @@
 ;;; ert-tests.el --- ERT's self-tests  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2007-2008, 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2007-2008, 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Christian Ohler <address@hidden>
 
diff --git a/test/lisp/emacs-lisp/ert-x-tests.el 
b/test/lisp/emacs-lisp/ert-x-tests.el
index 9798f0c..0737572 100644
--- a/test/lisp/emacs-lisp/ert-x-tests.el
+++ b/test/lisp/emacs-lisp/ert-x-tests.el
@@ -1,6 +1,6 @@
 ;;; ert-x-tests.el --- Tests for ert-x.el
 
-;; Copyright (C) 2008, 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008, 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Phil Hagelberg
 ;;        Christian Ohler <address@hidden>
diff --git a/test/lisp/emacs-lisp/faceup-resources/faceup-test-mode.el 
b/test/lisp/emacs-lisp/faceup-resources/faceup-test-mode.el
index 7d1a128..e940c5f 100644
--- a/test/lisp/emacs-lisp/faceup-resources/faceup-test-mode.el
+++ b/test/lisp/emacs-lisp/faceup-resources/faceup-test-mode.el
@@ -1,6 +1,6 @@
 ;;; faceup-test-mode.el --- Dummy major mode for testing `faceup'.
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Anders Lindgren
 ;; Keywords: languages, faces
diff --git 
a/test/lisp/emacs-lisp/faceup-resources/faceup-test-this-file-directory.el 
b/test/lisp/emacs-lisp/faceup-resources/faceup-test-this-file-directory.el
index 0558bd1..11c48de 100644
--- a/test/lisp/emacs-lisp/faceup-resources/faceup-test-this-file-directory.el
+++ b/test/lisp/emacs-lisp/faceup-resources/faceup-test-this-file-directory.el
@@ -1,6 +1,6 @@
 ;;; faceup-test-this-file-directory.el --- Support file for faceup tests
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Anders Lindgren
 ;; Keywords: languages, faces
diff --git a/test/lisp/emacs-lisp/faceup-tests/faceup-test-basics.el 
b/test/lisp/emacs-lisp/faceup-tests/faceup-test-basics.el
index f910a1d..c35188e 100644
--- a/test/lisp/emacs-lisp/faceup-tests/faceup-test-basics.el
+++ b/test/lisp/emacs-lisp/faceup-tests/faceup-test-basics.el
@@ -1,6 +1,6 @@
 ;;; faceup-test-basics.el --- Tests for the `faceup' package.
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Anders Lindgren
 ;; Keywords: languages, faces
diff --git a/test/lisp/emacs-lisp/faceup-tests/faceup-test-files.el 
b/test/lisp/emacs-lisp/faceup-tests/faceup-test-files.el
index 8df38bc..c8c3a1f 100644
--- a/test/lisp/emacs-lisp/faceup-tests/faceup-test-files.el
+++ b/test/lisp/emacs-lisp/faceup-tests/faceup-test-files.el
@@ -1,6 +1,6 @@
 ;;; faceup-test-files.el --- Self test of `faceup' using dummy major mode.
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Anders Lindgren
 ;; Keywords: languages, faces
diff --git a/test/lisp/emacs-lisp/generator-tests.el 
b/test/lisp/emacs-lisp/generator-tests.el
index bca3efa..613de2f 100644
--- a/test/lisp/emacs-lisp/generator-tests.el
+++ b/test/lisp/emacs-lisp/generator-tests.el
@@ -1,6 +1,6 @@
 ;;; generator-tests.el --- Testing generators -*- lexical-binding: t -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Daniel Colascione <address@hidden>
 ;; Keywords:
diff --git a/test/lisp/emacs-lisp/gv-tests.el b/test/lisp/emacs-lisp/gv-tests.el
index a380445..cfd982b 100644
--- a/test/lisp/emacs-lisp/gv-tests.el
+++ b/test/lisp/emacs-lisp/gv-tests.el
@@ -1,6 +1,6 @@
 ;;; gv-tests.el --- tests for gv.el  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/emacs-lisp/let-alist-tests.el 
b/test/lisp/emacs-lisp/let-alist-tests.el
index 66efc13..31db4a9 100644
--- a/test/lisp/emacs-lisp/let-alist-tests.el
+++ b/test/lisp/emacs-lisp/let-alist-tests.el
@@ -1,6 +1,6 @@
 ;;; let-alist.el --- tests for file handling. -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/emacs-lisp/lisp-mode-tests.el 
b/test/lisp/emacs-lisp/lisp-mode-tests.el
index 30f606d..a637074 100644
--- a/test/lisp/emacs-lisp/lisp-mode-tests.el
+++ b/test/lisp/emacs-lisp/lisp-mode-tests.el
@@ -1,6 +1,6 @@
 ;;; lisp-mode-tests.el --- Test Lisp editing commands  -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
diff --git a/test/lisp/emacs-lisp/lisp-tests.el 
b/test/lisp/emacs-lisp/lisp-tests.el
index 07eddb7..282c372 100644
--- a/test/lisp/emacs-lisp/lisp-tests.el
+++ b/test/lisp/emacs-lisp/lisp-tests.el
@@ -1,6 +1,6 @@
 ;;; lisp-tests.el --- Test Lisp editing commands     -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Aaron S. Hawley <address@hidden>
 ;; Author: Stefan Monnier <address@hidden>
diff --git a/test/lisp/emacs-lisp/map-tests.el 
b/test/lisp/emacs-lisp/map-tests.el
index 885b09b..a54af80 100644
--- a/test/lisp/emacs-lisp/map-tests.el
+++ b/test/lisp/emacs-lisp/map-tests.el
@@ -1,6 +1,6 @@
 ;;; map-tests.el --- Tests for map.el  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Nicolas Petton <address@hidden>
 ;; Maintainer: address@hidden
@@ -38,17 +38,19 @@ Evaluate BODY for each created map.
 \(fn (var map) body)"
   (declare (indent 1) (debug (symbolp body)))
   (let ((alist (make-symbol "alist"))
+        (plist (make-symbol "plist"))
         (vec (make-symbol "vec"))
         (ht (make-symbol "ht")))
    `(let ((,alist (list (cons 0 3)
                         (cons 1 4)
                         (cons 2 5)))
+          (,plist (list 0 3 1 4 2 5))
           (,vec (vector 3 4 5))
           (,ht (make-hash-table)))
       (puthash 0 3 ,ht)
       (puthash 1 4 ,ht)
       (puthash 2 5 ,ht)
-      (dolist (,var (list ,alist ,vec ,ht))
+      (dolist (,var (list ,alist ,plist ,vec ,ht))
         ,@body))))
 
 (ert-deftest test-map-elt ()
@@ -76,13 +78,26 @@ Evaluate BODY for each created map.
                          'b
                          '2))))
 
-(ert-deftest test-map-put ()
+(ert-deftest test-map-put! ()
   (with-maps-do map
     (setf (map-elt map 2) 'hello)
     (should (eq (map-elt map 2) 'hello)))
   (with-maps-do map
     (map-put map 2 'hello)
     (should (eq (map-elt map 2) 'hello)))
+  (with-maps-do map
+    (map-put! map 2 'hello)
+    (should (eq (map-elt map 2) 'hello))
+    (if (not (or (hash-table-p map)
+                 (and (listp map) (not (listp (car map)))))) ;plist!
+        (should-error (map-put! map 5 'value)
+                      ;; For vectors, it could arguably signal
+                      ;; map-not-inplace as well, but it currently doesn't.
+                      :type (if (listp map)
+                                'map-not-inplace
+                              'error))
+      (map-put! map 5 'value)
+      (should (eq (map-elt map 5) 'value))))
   (let ((ht (make-hash-table)))
     (setf (map-elt ht 2) 'a)
     (should (eq (map-elt ht 2)
@@ -92,7 +107,7 @@ Evaluate BODY for each created map.
     (should (eq (map-elt alist 2)
                 'a)))
   (let ((vec [3 4 5]))
-   (should-error (setf (map-elt vec 3) 6))))
+    (should-error (setf (map-elt vec 3) 6))))
 
 (ert-deftest test-map-put-alist-new-key ()
   "Regression test for Bug#23105."
@@ -105,9 +120,9 @@ Evaluate BODY for each created map.
   (let ((alist (list (cons "a" 1) (cons "b" 2)))
         ;; Make sure to use a non-eq "a", even when compiled.
         (noneq-key (string ?a)))
-    (map-put alist noneq-key 3 'equal)
+    (map-put alist noneq-key 3 #'equal)
     (should-not (cddr alist))
-    (map-put alist noneq-key 9)
+    (map-put alist noneq-key 9 #'eql)
     (should (cddr alist))))
 
 (ert-deftest test-map-put-return-value ()
diff --git a/test/lisp/emacs-lisp/nadvice-tests.el 
b/test/lisp/emacs-lisp/nadvice-tests.el
index 3945d66..e14d136 100644
--- a/test/lisp/emacs-lisp/nadvice-tests.el
+++ b/test/lisp/emacs-lisp/nadvice-tests.el
@@ -1,6 +1,6 @@
 ;;; advice-tests.el --- Test suite for the new advice thingy.
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/emacs-lisp/package-tests.el 
b/test/lisp/emacs-lisp/package-tests.el
index f08bc92..c757bcc 100644
--- a/test/lisp/emacs-lisp/package-tests.el
+++ b/test/lisp/emacs-lisp/package-tests.el
@@ -1,6 +1,6 @@
 ;;; package-test.el --- Tests for the Emacs package system
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Daniel Hackney <address@hidden>
 ;; Version: 1.0
@@ -190,12 +190,33 @@ Must called from within a `tar-mode' buffer."
   "Return the package version as a string."
   (package-version-join (package-desc-version desc)))
 
+(defun package-test--compatible-p (pkg-desc pkg-sample &optional kind)
+  (and (cl-every (lambda (f)
+                   (equal (funcall f pkg-desc)
+                          (funcall f pkg-sample)))
+                 (cons (if kind #'package-desc-kind #'ignore)
+                       '(package-desc-name
+                         package-desc-version
+                         package-desc-summary
+                         package-desc-reqs
+                         package-desc-archive
+                         package-desc-dir
+                         package-desc-signed)))
+       ;; The `extras' field should contain at least the specified elements.
+       (let ((extras (package-desc-extras pkg-desc))
+             (extras-sample (package-desc-extras pkg-sample)))
+         (cl-every (lambda (sample-elem)
+                     (member sample-elem extras))
+                   extras-sample))))
+
 (ert-deftest package-test-desc-from-buffer ()
   "Parse an elisp buffer to get a `package-desc' object."
   (with-package-test (:basedir "package-resources" :file 
"simple-single-1.3.el")
-    (should (equal (package-buffer-info) simple-single-desc)))
+    (should (package-test--compatible-p
+             (package-buffer-info) simple-single-desc 'kind)))
   (with-package-test (:basedir "package-resources" :file 
"simple-depend-1.0.el")
-    (should (equal (package-buffer-info) simple-depend-desc)))
+    (should (package-test--compatible-p
+             (package-buffer-info) simple-depend-desc 'kind)))
   (with-package-test (:basedir "package-resources"
                                :file "multi-file-0.2.3.tar")
     (tar-mode)
@@ -223,15 +244,12 @@ Must called from within a `tar-mode' buffer."
       (with-temp-buffer
         (insert-file-contents (expand-file-name "simple-single-pkg.el"
                                                 simple-pkg-dir))
-        (should (string= (buffer-string)
-                         (concat ";;; -*- no-byte-compile: t -*-\n"
-                                 "(define-package \"simple-single\" \"1.3\" "
-                                 "\"A single-file package "
-                                 "with no dependencies\" 'nil "
-                                 ":authors '((\"J. R. Hacker\" . 
\"address@hidden")) "
-                                 ":maintainer '(\"J. R. Hacker\" . 
\"address@hidden") "
-                                 ":url \"http://doodles.au\"";
-                                 ")\n"))))
+        (goto-char (point-min))
+        (let ((sexp (read (current-buffer))))
+          (should (eq (car-safe sexp) 'define-package))
+          (should (package-test--compatible-p
+                   (apply #'package-desc-from-define (cdr sexp))
+                   simple-single-desc))))
       (should (file-exists-p autoloads-file))
       (should-not (get-file-buffer autoloads-file)))))
 
@@ -435,11 +453,24 @@ Must called from within a `tar-mode' buffer."
      (save-excursion (should (search-forward "Summary: A single-file package 
with no dependencies" nil t)))
      (save-excursion (should (search-forward "Homepage: http://doodles.au"; nil 
t)))
      (save-excursion (should (re-search-forward "Keywords: \\[?frobnicate\\]?" 
nil t)))
-     ;; No description, though. Because at this point we don't know
-     ;; what archive the package originated from, and we don't have
-     ;; its readme file saved.
+     (save-excursion (should (search-forward "This package provides a minor 
mode to frobnicate"
+                                             nil t)))
      )))
 
+(ert-deftest package-test-describe-installed-multi-file-package ()
+  "Test displaying of the readme for installed multi-file package."
+
+  (with-package-test ()
+    (package-initialize)
+    (package-refresh-contents)
+    (package-install 'multi-file)
+    (with-fake-help-buffer
+     (describe-package 'multi-file)
+     (goto-char (point-min))
+     (should (search-forward "Homepage: http://puddles.li"; nil t))
+     (should (search-forward "This is a bare-bones readme file for the 
multi-file"
+                             nil t)))))
+
 (ert-deftest package-test-describe-non-installed-package ()
   "Test displaying of the readme for non-installed package."
 
@@ -567,8 +598,17 @@ Must called from within a `tar-mode' buffer."
         (setq archive-contents
               (package-read-from-string
                (buffer-substring (point-min) (point-max)))))
-      (should (equal archive-contents
-                     (list 1 package-x-test--single-archive-entry-1-3))))))
+      (should (equal 1 (car archive-contents)))
+      (should (equal 2 (length archive-contents)))
+      (let ((pac (cadr archive-contents))
+            (pac-sample package-x-test--single-archive-entry-1-3))
+        (should (equal (pop pac) (pop pac-sample)))
+        (dotimes (i 4)
+          (should (equal (aref pac i) (aref pac-sample i))))
+        ;; The `extras' field should contain at least the specified elements.
+        (should (cl-every (lambda (sample-elem)
+                            (member sample-elem (aref pac 4)))
+                          (aref pac-sample 4)))))))
 
 (ert-deftest package-x-test-upload-new-version ()
   "Test uploading a new version of a package"
@@ -588,8 +628,17 @@ Must called from within a `tar-mode' buffer."
         (setq archive-contents
               (package-read-from-string
                (buffer-substring (point-min) (point-max)))))
-      (should (equal archive-contents
-                     (list 1 package-x-test--single-archive-entry-1-4))))))
+      (should (equal 1 (car archive-contents)))
+      (should (equal 2 (length archive-contents)))
+      (let ((pac (cadr archive-contents))
+            (pac-sample package-x-test--single-archive-entry-1-4))
+        (should (equal (pop pac) (pop pac-sample)))
+        (dotimes (i 4)
+          (should (equal (aref pac i) (aref pac-sample i))))
+        ;; The `extras' field should contain at least the specified elements.
+        (should (cl-every (lambda (sample-elem)
+                            (member sample-elem (aref pac 4)))
+                          (aref pac-sample 4)))))))
 
 (ert-deftest package-test-get-deps ()
   "Test `package--get-deps' with complex structures."
diff --git a/test/lisp/emacs-lisp/pcase-tests.el 
b/test/lisp/emacs-lisp/pcase-tests.el
index c706c10..af8c9a3 100644
--- a/test/lisp/emacs-lisp/pcase-tests.el
+++ b/test/lisp/emacs-lisp/pcase-tests.el
@@ -1,6 +1,6 @@
 ;;; pcase-tests.el --- Test suite for pcase macro.
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -51,11 +51,13 @@
 
 (ert-deftest pcase-tests-member ()
   (should (pcase-tests-grep
-           'memq (macroexpand-all '(pcase x ((or 1 2 3) body)))))
+           'memql (macroexpand-all '(pcase x ((or 1 2 3) body)))))
   (should (pcase-tests-grep
            'member (macroexpand-all '(pcase x ((or "a" 2 3) body)))))
   (should-not (pcase-tests-grep
                'memq (macroexpand-all '(pcase x ((or "a" 2 3) body)))))
+  (should-not (pcase-tests-grep
+               'memql (macroexpand-all '(pcase x ((or "a" 2 3) body)))))
   (let ((exp (macroexpand-all
                       '(pcase x
                          ("a" body1)
diff --git a/test/lisp/emacs-lisp/pp-tests.el b/test/lisp/emacs-lisp/pp-tests.el
index 95feda5..2660bd2 100644
--- a/test/lisp/emacs-lisp/pp-tests.el
+++ b/test/lisp/emacs-lisp/pp-tests.el
@@ -1,6 +1,6 @@
 ;;; pp-tests.el --- Test suite for pretty printer.  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/emacs-lisp/regexp-opt-tests.el 
b/test/lisp/emacs-lisp/regexp-opt-tests.el
index 7eae769..1fc4990 100644
--- a/test/lisp/emacs-lisp/regexp-opt-tests.el
+++ b/test/lisp/emacs-lisp/regexp-opt-tests.el
@@ -1,6 +1,6 @@
 ;;; regexp-tests.el --- Test suite for regular expression handling.
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords:       internal
diff --git a/test/lisp/emacs-lisp/ring-tests.el 
b/test/lisp/emacs-lisp/ring-tests.el
index 9fa36aa..991c4e5 100644
--- a/test/lisp/emacs-lisp/ring-tests.el
+++ b/test/lisp/emacs-lisp/ring-tests.el
@@ -1,6 +1,6 @@
 ;;; ring-tests.el --- Tests for ring.el  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Simen Heggestøyl <address@hidden>
 ;; Keywords:
diff --git a/test/lisp/emacs-lisp/rmc-tests.el 
b/test/lisp/emacs-lisp/rmc-tests.el
index f8b3e5a..b20bfd4 100644
--- a/test/lisp/emacs-lisp/rmc-tests.el
+++ b/test/lisp/emacs-lisp/rmc-tests.el
@@ -1,6 +1,6 @@
 ;;; rmc-tests.el --- Test suite for rmc.el  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Tino Calancha <address@hidden>
 ;; Keywords:
diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el
index d15e3d7..4a5919e 100644
--- a/test/lisp/emacs-lisp/rx-tests.el
+++ b/test/lisp/emacs-lisp/rx-tests.el
@@ -1,6 +1,6 @@
 ;;; rx-tests.el --- test for rx.el functions -*- lexical-binding: t -*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -25,7 +25,7 @@
 ;;; Code:
 
 (ert-deftest rx-char-any ()
-  "Test character alternatives with `\]' and `-' (Bug#25123)."
+  "Test character alternatives with `]' and `-' (Bug#25123)."
   (should (string-match
            (rx string-start (1+ (char (?\] . ?\{) (?< . ?\]) (?- . ?:)))
                string-end)
@@ -33,6 +33,36 @@
                                   (number-sequence ?< ?\])
                                   (number-sequence ?- ?:))))))
 
+(ert-deftest rx-char-any-range-nl ()
+  "Test character alternatives with LF as a range endpoint."
+  (should (equal (rx (any "\n-\r"))
+                 "[\n-\r]"))
+  (should (equal (rx (any "\a-\n"))
+                 "[\a-\n]")))
+
+(ert-deftest rx-char-any-range-bad ()
+  (should-error (rx (any "0-9a-Z")))
+  (should-error (rx (any (?0 . ?9) (?a . ?Z)))))
+
+(ert-deftest rx-char-any-raw-byte ()
+  "Test raw bytes in character alternatives."
+  ;; Separate raw characters.
+  (should (equal (string-match-p (rx (any "\326A\333B"))
+                                 "X\326\333")
+                 1))
+  ;; Range of raw characters, unibyte.
+  (should (equal (string-match-p (rx (any "\200-\377"))
+                                 "ÿA\310B")
+                 2))
+  ;; Range of raw characters, multibyte.
+  (should (equal (string-match-p (rx (any "Å\211\326-\377\177"))
+                                 "XY\355\177\327")
+                 2))
+  ;; Split range; \177-\377ÿ should not be optimised to \177-\377.
+  (should (equal (string-match-p (rx (any "\177-\377" ?ÿ))
+                                 "ÿA\310B")
+                 0)))
+
 (ert-deftest rx-pcase ()
   (should (equal (pcase "a 1 2 3 1 1 b"
                    ((rx (let u (+ digit)) space
@@ -43,5 +73,41 @@
                     (list u v)))
                  '("1" "3"))))
 
+(ert-deftest rx-kleene ()
+  "Test greedy and non-greedy repetition operators."
+  (should (equal (rx (* "a") (+ "b") (\? "c") (?\s "d")
+                     (*? "e") (+? "f") (\?? "g") (?? "h"))
+                 "a*b+c?d?e*?f+?g??h??"))
+  (should (equal (rx (zero-or-more "a") (0+ "b")
+                     (one-or-more "c") (1+ "d")
+                     (zero-or-one "e") (optional "f") (opt "g"))
+                 "a*b*c+d+e?f?g?"))
+  (should (equal (rx (minimal-match
+                      (seq (* "a") (+ "b") (\? "c") (?\s "d")
+                           (*? "e") (+? "f") (\?? "g") (?? "h"))))
+                 "a*b+c?d?e*?f+?g??h??"))
+  (should (equal (rx (minimal-match
+                      (seq (zero-or-more "a") (0+ "b")
+                           (one-or-more "c") (1+ "d")
+                           (zero-or-one "e") (optional "f") (opt "g"))))
+                 "a*?b*?c+?d+?e??f??g??"))
+  (should (equal (rx (maximal-match
+                      (seq (* "a") (+ "b") (\? "c") (?\s "d")
+                         (*? "e") (+? "f") (\?? "g") (?? "h"))))
+                 "a*b+c?d?e*?f+?g??h??")))
+
+(ert-deftest rx-or ()
+  ;; Test or-pattern reordering (Bug#34641).
+  (let ((s "abc"))
+    (should (equal (and (string-match (rx (or "abc" "ab" "a")) s)
+                        (match-string 0 s))
+                   "abc"))
+    (should (equal (and (string-match (rx (or "ab" "abc" "a")) s)
+                        (match-string 0 s))
+                   "ab"))
+    (should (equal (and (string-match (rx (or "a" "ab" "abc")) s)
+                        (match-string 0 s))
+                   "a"))))
+
 (provide 'rx-tests)
 ;; rx-tests.el ends here.
diff --git a/test/lisp/emacs-lisp/seq-tests.el 
b/test/lisp/emacs-lisp/seq-tests.el
index 989ec3c..ef05e2b 100644
--- a/test/lisp/emacs-lisp/seq-tests.el
+++ b/test/lisp/emacs-lisp/seq-tests.el
@@ -1,6 +1,6 @@
 ;;; seq-tests.el --- Tests for sequences.el
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Nicolas Petton <address@hidden>
 ;; Maintainer: address@hidden
@@ -185,6 +185,18 @@ Evaluate BODY for each created sequence.
   (with-test-sequences (seq '(3 4 5 6))
     (should (= 5 (seq-contains seq 5)))))
 
+(ert-deftest test-seq-contains-p ()
+  (with-test-sequences (seq '(3 4 5 6))
+    (should (eq (seq-contains-p seq 3) t))
+    (should-not (seq-contains-p seq 7)))
+  (with-test-sequences (seq '())
+    (should-not (seq-contains-p seq 3))
+    (should-not (seq-contains-p seq nil))))
+
+(ert-deftest test-seq-contains-p-with-nil ()
+  (should (seq-contains-p  [nil] nil))
+  (should (seq-contains-p '(nil) nil)))
+
 (ert-deftest test-seq-every-p ()
   (with-test-sequences (seq '(43 54 22 1))
     (should (seq-every-p (lambda (elt) t) seq))
@@ -424,5 +436,30 @@ Evaluate BODY for each created sequence.
     (should (eq (seq-into vec 'vector) vec))
     (should (eq (seq-into str 'string) str))))
 
+(ert-deftest test-seq-first ()
+  (let ((lst '(1 2 3))
+        (vec [1 2 3]))
+    (should (eq (seq-first lst) 1))
+    (should (eq (seq-first vec) 1))))
+
+(ert-deftest test-seq-rest ()
+  (let ((lst '(1 2 3))
+        (vec [1 2 3]))
+    (should (equal (seq-rest lst) '(2 3)))
+    (should (equal (seq-rest vec) [2 3]))))
+
+;; Regression tests for bug#34852
+(progn
+  (ert-deftest test-seq-intersection-with-nil ()
+    (should (equal (seq-intersection '(1 2 nil) '(1 nil)) '(1 nil))))
+
+  (ert-deftest test-seq-set-equal-p-with-nil ()
+    (should (seq-set-equal-p '("a" "b" nil)
+                             '(nil "b" "a"))))
+
+  (ert-deftest test-difference-with-nil ()
+    (should (equal (seq-difference '(1 nil) '(2 nil))
+                   '(1)))))
+
 (provide 'seq-tests)
 ;;; seq-tests.el ends here
diff --git a/test/lisp/emacs-lisp/shadow-tests.el 
b/test/lisp/emacs-lisp/shadow-tests.el
index f0aa131..e3a2d6b 100644
--- a/test/lisp/emacs-lisp/shadow-tests.el
+++ b/test/lisp/emacs-lisp/shadow-tests.el
@@ -1,6 +1,6 @@
 ;;; shadow-tests.el --- Test suite for shadow.  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/emacs-lisp/subr-x-tests.el 
b/test/lisp/emacs-lisp/subr-x-tests.el
index 81467ba..d3cb2b1 100644
--- a/test/lisp/emacs-lisp/subr-x-tests.el
+++ b/test/lisp/emacs-lisp/subr-x-tests.el
@@ -1,6 +1,6 @@
 ;;; subr-x-tests.el --- Testing the extended lisp routines
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Fabián E. Gallina <address@hidden>
 ;; Keywords:
diff --git a/test/lisp/emacs-lisp/tabulated-list-test.el 
b/test/lisp/emacs-lisp/tabulated-list-test.el
index 25a7c9f..052d2e8 100644
--- a/test/lisp/emacs-lisp/tabulated-list-test.el
+++ b/test/lisp/emacs-lisp/tabulated-list-test.el
@@ -1,6 +1,6 @@
 ;;; tabulated-list-test.el --- Tests for emacs-lisp/tabulated-list.el  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Artur Malabarba <address@hidden>
 
diff --git a/test/lisp/emacs-lisp/testcover-resources/testcases.el 
b/test/lisp/emacs-lisp/testcover-resources/testcases.el
index 69ef5b5..571e9ab 100644
--- a/test/lisp/emacs-lisp/testcover-resources/testcases.el
+++ b/test/lisp/emacs-lisp/testcover-resources/testcases.el
@@ -1,6 +1,6 @@
 ;;;; testcases.el -- Test cases for testcover-tests.el
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Gemini Lasswell
 
diff --git a/test/lisp/emacs-lisp/testcover-tests.el 
b/test/lisp/emacs-lisp/testcover-tests.el
index 6c76421..cbef493 100644
--- a/test/lisp/emacs-lisp/testcover-tests.el
+++ b/test/lisp/emacs-lisp/testcover-tests.el
@@ -1,6 +1,6 @@
 ;;; testcover-tests.el --- Testcover test suite   -*- lexical-binding:t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Gemini Lasswell
 
diff --git a/test/lisp/emacs-lisp/text-property-search-tests.el 
b/test/lisp/emacs-lisp/text-property-search-tests.el
index 5ea6b53..47db54a 100644
--- a/test/lisp/emacs-lisp/text-property-search-tests.el
+++ b/test/lisp/emacs-lisp/text-property-search-tests.el
@@ -1,6 +1,6 @@
 ;;; text-property-search-tests.el --- Testing text-property-search
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Ingebrigtsen <address@hidden>
 ;; Keywords:
diff --git a/test/lisp/emacs-lisp/thunk-tests.el 
b/test/lisp/emacs-lisp/thunk-tests.el
index b24e8d1..caa2c41 100644
--- a/test/lisp/emacs-lisp/thunk-tests.el
+++ b/test/lisp/emacs-lisp/thunk-tests.el
@@ -1,6 +1,6 @@
 ;;; thunk-tests.el --- Tests for thunk.el -*- lexical-binding: t -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Nicolas Petton <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/test/lisp/emacs-lisp/timer-tests.el 
b/test/lisp/emacs-lisp/timer-tests.el
index e463b9e..bd2dcbe 100644
--- a/test/lisp/emacs-lisp/timer-tests.el
+++ b/test/lisp/emacs-lisp/timer-tests.el
@@ -1,6 +1,6 @@
 ;;; timer-tests.el --- tests for timers -*- lexical-binding:t -*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/emulation/viper-tests.el 
b/test/lisp/emulation/viper-tests.el
index efb84f1..1359dcf 100644
--- a/test/lisp/emulation/viper-tests.el
+++ b/test/lisp/emulation/viper-tests.el
@@ -1,6 +1,6 @@
 ;;; viper-tests.el --- tests for viper.
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/epg-tests.el b/test/lisp/epg-tests.el
index 69c3838f..1a11e41 100644
--- a/test/lisp/epg-tests.el
+++ b/test/lisp/epg-tests.el
@@ -1,6 +1,6 @@
 ;;; epg-tests.el --- Test suite for epg.el -*- lexical-binding: t -*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -107,7 +107,10 @@
         (delete-directory epg-tests-home-directory t)))))
 
 (ert-deftest epg-decrypt-1 ()
+  :expected-result (if (getenv "EMACS_HYDRA_CI") :failed :passed) ; fixme
   (with-epg-tests (:require-passphrase t)
+    (with-temp-file (expand-file-name "gpg.conf" epg-tests-home-directory)
+      (insert "ignore-mdc-error"))
     (should (equal "test"
                   (epg-decrypt-string epg-tests-context "\
 -----BEGIN PGP MESSAGE-----
@@ -118,6 +121,7 @@ jA0EAwMCE19JBLTvvmhgyRrGGglRbnKkK9PJG8fDwO5ccjysrR7IcdNcnA==
 -----END PGP MESSAGE-----")))))
 
 (ert-deftest epg-roundtrip-1 ()
+ :expected-result (if (getenv "EMACS_HYDRA_CI") :failed :passed) ; fixme
   (with-epg-tests (:require-passphrase t)
     (let ((cipher (epg-encrypt-string epg-tests-context "symmetric" nil)))
       (should (equal "symmetric"
diff --git a/test/lisp/erc/erc-track-tests.el b/test/lisp/erc/erc-track-tests.el
index 44a952c..feb7ee6 100644
--- a/test/lisp/erc/erc-track-tests.el
+++ b/test/lisp/erc/erc-track-tests.el
@@ -1,6 +1,6 @@
 ;;; erc-track-tests.el --- Tests for erc-track.
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Mario Lang <address@hidden>
 ;; Author: Vivek Dasmohapatra <address@hidden>
diff --git a/test/lisp/eshell/em-hist-tests.el 
b/test/lisp/eshell/em-hist-tests.el
index 3d73b12..2fec115 100644
--- a/test/lisp/eshell/em-hist-tests.el
+++ b/test/lisp/eshell/em-hist-tests.el
@@ -1,6 +1,6 @@
 ;;; tests/em-hist-tests.el --- em-hist test suite
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/eshell/em-ls-tests.el b/test/lisp/eshell/em-ls-tests.el
index c5c9eac..d5f9d24 100644
--- a/test/lisp/eshell/em-ls-tests.el
+++ b/test/lisp/eshell/em-ls-tests.el
@@ -1,6 +1,6 @@
 ;;; tests/em-ls-tests.el --- em-ls test suite
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Tino Calancha <address@hidden>
 
@@ -78,6 +78,11 @@
 
 (ert-deftest em-ls-test-bug27844 ()
   "Test for https://debbugs.gnu.org/27844 ."
+  ;; FIXME: it would be better to use something other than source-directory
+  ;; in this test.
+  (skip-unless (and source-directory
+                    (file-exists-p
+                     (expand-file-name "lisp/subr.el" source-directory))))
   (let ((orig eshell-ls-use-in-dired)
         (dired-use-ls-dired 'unspecified)
         buf insert-directory-program)
@@ -88,7 +93,14 @@
           (dired-toggle-marks)
           (should (cdr (dired-get-marked-files)))
           (kill-buffer buf)
-          (setq buf (dired (expand-file-name "lisp/subr.el" source-directory)))
+          ;; Eshell's default format duplicates the year for non-recent files,
+          ;; eg "2015-05-06  2015", which doesn't make a lot of sense,
+          ;; and causes this portion of the test to fail if subr.el
+          ;; is non-recent (eg if building from a tarfile unpacked
+          ;; with a fixed early timestamp for reproducibility).  Bug#33734.
+          (let ((eshell-ls-date-format "%b %e"))
+            (setq buf (dired (expand-file-name "lisp/subr.el"
+                                               source-directory))))
           (should (looking-at "subr\\.el")))
       (customize-set-variable 'eshell-ls-use-in-dired orig)
       (and (buffer-live-p buf) (kill-buffer)))))
diff --git a/test/lisp/eshell/esh-opt-tests.el 
b/test/lisp/eshell/esh-opt-tests.el
index 13b522b..39284c0 100644
--- a/test/lisp/eshell/esh-opt-tests.el
+++ b/test/lisp/eshell/esh-opt-tests.el
@@ -1,6 +1,6 @@
 ;;; tests/esh-opt-tests.el --- esh-opt test suite
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/eshell/eshell-tests.el b/test/lisp/eshell/eshell-tests.el
index cefbeef..53cf854 100644
--- a/test/lisp/eshell/eshell-tests.el
+++ b/test/lisp/eshell/eshell-tests.el
@@ -1,6 +1,6 @@
 ;;; tests/eshell-tests.el --- Eshell test suite
 
-;; Copyright (C) 1999-2018 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2019 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <address@hidden>
 
@@ -33,7 +33,7 @@
   `(let* ((eshell-directory-name (make-temp-file "eshell" t))
           ;; We want no history file, so prevent Eshell from falling
           ;; back on $HISTFILE.
-          (_ (setenv "HISTFILE"))
+          (process-environment (cons "HISTFILE" process-environment))
           (eshell-history-file-name nil)
           (eshell-buffer (eshell t)))
      (unwind-protect
diff --git a/test/lisp/faces-tests.el b/test/lisp/faces-tests.el
index 3fad8bd..f00c93c 100644
--- a/test/lisp/faces-tests.el
+++ b/test/lisp/faces-tests.el
@@ -1,6 +1,6 @@
 ;;; faces-tests.el --- Tests for faces.el            -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Artur Malabarba <address@hidden>
 ;; Keywords:
@@ -60,5 +60,14 @@
     (should (equal (background-color-at-point) "black"))
     (should (equal (foreground-color-at-point) "black"))))
 
+(ert-deftest faces--test-face-id ()
+  ;; Face ID of 0 is the 'default' face; no face should have the same ID.
+  (should (> (face-id 'faces--test1) 0))
+  ;; 'tooltip' is the last face defined by preloaded packages, so any
+  ;; face we define in Emacs should have a face ID greater than that,
+  ;; since the ID of a face is just its index in the array that maps
+  ;; face IDs to faces.
+  (should (> (face-id 'faces--test1) (face-id 'tooltip))))
+
 (provide 'faces-tests)
 ;;; faces-tests.el ends here
diff --git a/test/lisp/ffap-tests.el b/test/lisp/ffap-tests.el
index 479d8c6..5b2f43c 100644
--- a/test/lisp/ffap-tests.el
+++ b/test/lisp/ffap-tests.el
@@ -1,6 +1,6 @@
 ;;; ffap-tests.el --- Test suite for ffap.el -*- lexical-binding: t -*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Tino Calancha <address@hidden>
 
diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el
index 612ea8c..a40dc72 100644
--- a/test/lisp/filenotify-tests.el
+++ b/test/lisp/filenotify-tests.el
@@ -1,6 +1,6 @@
 ;;; filenotify-tests.el --- Tests of file notifications  -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 
@@ -31,6 +31,21 @@
 ;; remote host, set this environment variable to "/dev/null" or
 ;; whatever is appropriate on your system.
 
+;; For the remote file-notify library, Tramp checks for the existence
+;; of a respective command.  The first command found is used.  In
+;; order to use a dedicated one, the environment variable
+;; $REMOTE_FILE_NOTIFY_LIBRARY shall be set, possible values are
+;; "inotifywait", "gio-monitor" and "gvfs-monitor-dir".
+
+;; Local file-notify libraries are auto-detected during Emacs
+;; configuration.  This can be changed with a respective configuration
+;; argument, like
+;;
+;;   --with-file-notification=inotify
+;;   --with-file-notification=kqueue
+;;   --with-file-notification=gfile
+;;   --with-file-notification=w32
+
 ;; A whole test run can be performed calling the command 
`file-notify-test-all'.
 
 ;;; Code:
@@ -64,6 +79,12 @@
       (format "/mock::%s" temporary-file-directory)))
   "Temporary directory for Tramp tests.")
 
+;; Filter suppressed remote file-notify libraries.
+(when (stringp (getenv "REMOTE_FILE_NOTIFY_LIBRARY"))
+  (dolist (lib '("inotifywait" "gio-monitor" "gvfs-monitor-dir"))
+    (unless (string-equal (getenv "REMOTE_FILE_NOTIFY_LIBRARY") lib)
+      (add-to-list 'tramp-connection-properties `(nil ,lib nil)))))
+
 (defvar file-notify--test-tmpdir nil)
 (defvar file-notify--test-tmpfile nil)
 (defvar file-notify--test-tmpfile1 nil)
@@ -240,15 +261,17 @@ This returns only for the local case and gfilenotify; 
otherwise it is nil.
                              (gfile-monitor-name file-notify--test-desc)))
           (cdr (assq file-notify--test-desc file-notify--test-monitors))))))
 
-(defmacro file-notify--deftest-remote (test docstring)
-  "Define ert `TEST-remote' for remote files."
+(defmacro file-notify--deftest-remote (test docstring &optional unstable)
+  "Define ert `TEST-remote' for remote files.
+If UNSTABLE is non-nil, the test is tagged as `:unstable'."
   (declare (indent 1))
   `(ert-deftest ,(intern (concat (symbol-name test) "-remote")) ()
      ,docstring
-     :tags '(:expensive-test)
+     :tags (if ,unstable '(:expensive-test :unstable) '(:expensive-test))
      (let* ((temporary-file-directory
             file-notify-test-remote-temporary-file-directory)
-           (ert-test (ert-get-test ',test)))
+           (ert-test (ert-get-test ',test))
+            vc-handled-backends)
        (skip-unless (file-notify--test-remote-enabled))
        (tramp-cleanup-connection
        (tramp-dissect-file-name temporary-file-directory) nil 'keep-password)
@@ -426,36 +449,36 @@ This returns only for the local case and gfilenotify; 
otherwise it is nil.
       ;; harm.  This fails on Cygwin because of timing issues unless a
       ;; long `sit-for' is added before the call to
       ;; `file-notify--test-read-event'.
-    (if (not (eq system-type 'cygwin))
-      (let (results)
-        (cl-flet ((first-callback (event)
-                   (when (eq (nth 1 event) 'deleted) (push 1 results)))
-                  (second-callback (event)
-                   (when (eq (nth 1 event) 'deleted) (push 2 results))))
-          (setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
-          (write-region
-           "any text" nil file-notify--test-tmpfile nil 'no-message)
-          (should
-           (setq file-notify--test-desc
-                 (file-notify-add-watch
-                  file-notify--test-tmpfile
-                  '(change) #'first-callback)))
-          (should
-           (setq file-notify--test-desc1
-                 (file-notify-add-watch
-                  file-notify--test-tmpfile
-                  '(change) #'second-callback)))
-          ;; Remove first watch.
-          (file-notify-rm-watch file-notify--test-desc)
-          ;; Only the second callback shall run.
-         (file-notify--test-read-event)
-          (delete-file file-notify--test-tmpfile)
-          (file-notify--wait-for-events
-           (file-notify--test-timeout) results)
-          (should (equal results (list 2)))
-
-          ;; The environment shall be cleaned up.
-          (file-notify--test-cleanup-p))))
+      (unless (eq system-type 'cygwin)
+        (let (results)
+          (cl-flet ((first-callback (event)
+                     (when (eq (nth 1 event) 'deleted) (push 1 results)))
+                    (second-callback (event)
+                     (when (eq (nth 1 event) 'deleted) (push 2 results))))
+            (setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
+            (write-region
+             "any text" nil file-notify--test-tmpfile nil 'no-message)
+            (should
+             (setq file-notify--test-desc
+                   (file-notify-add-watch
+                    file-notify--test-tmpfile
+                    '(change) #'first-callback)))
+            (should
+             (setq file-notify--test-desc1
+                   (file-notify-add-watch
+                    file-notify--test-tmpfile
+                    '(change) #'second-callback)))
+            ;; Remove first watch.
+            (file-notify-rm-watch file-notify--test-desc)
+            ;; Only the second callback shall run.
+           (file-notify--test-read-event)
+            (delete-file file-notify--test-tmpfile)
+            (file-notify--wait-for-events
+             (file-notify--test-timeout) results)
+            (should (equal results (list 2)))
+
+            ;; The environment shall be cleaned up.
+            (file-notify--test-cleanup-p))))
 
     ;; Cleanup.
     (file-notify--test-cleanup)))
@@ -664,6 +687,10 @@ delivered."
              '(created deleted stopped))
             ((string-equal (file-notify--test-library) "kqueue")
              '(created changed deleted stopped))
+             ;; On emba, `deleted' and `stopped' events of the
+             ;; directory are not detected.
+             ((getenv "EMACS_EMBA_CI")
+              '(created changed deleted))
             (t '(created changed deleted deleted stopped)))
          (write-region
           "any text" nil file-notify--test-tmpfile nil 'no-message)
@@ -709,6 +736,10 @@ delivered."
              '(created created changed changed deleted stopped))
             ((string-equal (file-notify--test-library) "kqueue")
              '(created changed created changed deleted stopped))
+             ;; On emba, `deleted' and `stopped' events of the
+             ;; directory are not detected.
+             ((getenv "EMACS_EMBA_CI")
+              '(created changed created changed deleted deleted))
             (t '(created changed created changed
                  deleted deleted deleted stopped)))
          (write-region
@@ -761,6 +792,10 @@ delivered."
              '(created created deleted deleted stopped))
             ((string-equal (file-notify--test-library) "kqueue")
              '(created changed renamed deleted stopped))
+             ;; On emba, `deleted' and `stopped' events of the
+             ;; directory are not detected.
+             ((getenv "EMACS_EMBA_CI")
+              '(created changed renamed deleted))
             (t '(created changed renamed deleted deleted stopped)))
          (write-region
           "any text" nil file-notify--test-tmpfile nil 'no-message)
@@ -979,51 +1014,55 @@ delivered."
     (file-notify--test-cleanup))
 
   (unwind-protect
-      (let ((file-notify--test-tmpdir
-            (make-temp-file "file-notify-test-parent" t)))
-       (should
-        (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)
-              file-notify--test-desc
-              (file-notify-add-watch
-               file-notify--test-tmpdir
-               '(change) #'file-notify--test-event-handler)))
-       (should (file-notify-valid-p file-notify--test-desc))
-       (file-notify--test-with-events
-        (cond
-         ;; w32notify does not raise `deleted' and `stopped' events
-         ;; for the watched directory.
-         ((string-equal (file-notify--test-library) "w32notify")
-          '(created changed deleted))
-          ;; gvfs-monitor-dir on cygwin does not detect the `created'
-          ;; event reliably.
-         ((string-equal (file-notify--test-library) "gvfs-monitor-dir.exe")
-          '((deleted stopped)
-            (created deleted stopped)))
-         ;; There are two `deleted' events, for the file and for the
-         ;; directory.  Except for cygwin and kqueue.  And cygwin
-         ;; does not raise a `changed' event.
-         ((eq system-type 'cygwin)
-          '(created deleted stopped))
-         ((string-equal (file-notify--test-library) "kqueue")
-          '(created changed deleted stopped))
-         (t '(created changed deleted deleted stopped)))
-        (write-region
-         "any text" nil file-notify--test-tmpfile nil 'no-message)
-        (file-notify--test-read-event)
-        (delete-directory file-notify--test-tmpdir 'recursive))
-       ;; After deleting the parent directory, the descriptor must
-       ;; not be valid anymore.
-       (should-not (file-notify-valid-p file-notify--test-desc))
-        ;; w32notify doesn't generate `stopped' events when the parent
-        ;; directory is deleted, which doesn't provide a chance for
-        ;; filenotify.el to remove the descriptor from the internal
-        ;; hash table it maintains.  So we must remove the descriptor
-        ;; manually.
-        (if (string-equal (file-notify--test-library) "w32notify")
-            (file-notify--rm-descriptor file-notify--test-desc))
+      ;; On emba, `deleted' and `stopped' events of the directory are
+      ;; not detected.
+      (unless (getenv "EMACS_EMBA_CI")
+        (let ((file-notify--test-tmpdir
+              (make-temp-file "file-notify-test-parent" t)))
+         (should
+          (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)
+                file-notify--test-desc
+                (file-notify-add-watch
+                 file-notify--test-tmpdir
+                 '(change) #'file-notify--test-event-handler)))
+         (should (file-notify-valid-p file-notify--test-desc))
+         (file-notify--test-with-events
+             (cond
+              ;; w32notify does not raise `deleted' and `stopped'
+              ;; events for the watched directory.
+              ((string-equal (file-notify--test-library) "w32notify")
+               '(created changed deleted))
+               ;; gvfs-monitor-dir on cygwin does not detect the
+               ;; `created' event reliably.
+              ((string-equal
+                 (file-notify--test-library) "gvfs-monitor-dir.exe")
+               '((deleted stopped)
+                 (created deleted stopped)))
+              ;; There are two `deleted' events, for the file and for
+              ;; the directory.  Except for cygwin and kqueue.  And
+              ;; cygwin does not raise a `changed' event.
+              ((eq system-type 'cygwin)
+               '(created deleted stopped))
+              ((string-equal (file-notify--test-library) "kqueue")
+               '(created changed deleted stopped))
+              (t '(created changed deleted deleted stopped)))
+           (write-region
+            "any text" nil file-notify--test-tmpfile nil 'no-message)
+           (file-notify--test-read-event)
+           (delete-directory file-notify--test-tmpdir 'recursive))
+         ;; After deleting the parent directory, the descriptor must
+         ;; not be valid anymore.
+         (should-not (file-notify-valid-p file-notify--test-desc))
+          ;; w32notify doesn't generate `stopped' events when the
+          ;; parent directory is deleted, which doesn't provide a
+          ;; chance for filenotify.el to remove the descriptor from
+          ;; the internal hash table it maintains.  So we must remove
+          ;; the descriptor manually.
+          (if (string-equal (file-notify--test-library) "w32notify")
+              (file-notify--rm-descriptor file-notify--test-desc))
 
-        ;; The environment shall be cleaned up.
-        (file-notify--test-cleanup-p))
+          ;; The environment shall be cleaned up.
+          (file-notify--test-cleanup-p)))
 
     ;; Cleanup.
     (file-notify--test-cleanup)))
@@ -1061,7 +1100,9 @@ delivered."
     (file-notify--test-cleanup))
 
   (unwind-protect
-      (progn
+      ;; On emba, `deleted' and `stopped' events of the directory are
+      ;; not detected.
+      (unless (getenv "EMACS_EMBA_CI")
        (should
         (setq file-notify--test-tmpfile
               (make-temp-file "file-notify-test-parent" t)))
@@ -1150,7 +1191,8 @@ delivered."
             (file-notify--test-read-event)
             (delete-file file)))
         (delete-directory file-notify--test-tmpfile)
-        (if (string-equal (file-notify--test-library) "w32notify")
+        (if (or (string-equal (file-notify--test-library) "w32notify")
+                (getenv "EMACS_EMBA_CI"))
             (file-notify--rm-descriptor file-notify--test-desc))
 
         ;; The environment shall be cleaned up.
@@ -1159,8 +1201,10 @@ delivered."
     ;; Cleanup.
     (file-notify--test-cleanup)))
 
+;; Unpredictable failures, eg https://hydra.nixos.org/build/86016286
 (file-notify--deftest-remote file-notify-test07-many-events
-   "Check that events are not dropped for remote directories.")
+  "Check that events are not dropped for remote directories."
+  (getenv "EMACS_HYDRA_CI"))
 
 (ert-deftest file-notify-test08-backup ()
   "Check that backup keeps file notification."
@@ -1357,11 +1401,17 @@ the file watch."
                  ;; w32notify does not raise `deleted' and `stopped'
                  ;; events for the watched directory.
                   ((string-equal (file-notify--test-library) "w32notify") '())
+                  ;; On emba, `deleted' and `stopped' events of the
+                  ;; directory are not detected.
+                  ((getenv "EMACS_EMBA_CI")
+                   '())
                   (t '(deleted stopped))))))
           (delete-directory file-notify--test-tmpfile 'recursive))
-        (should-not (file-notify-valid-p file-notify--test-desc1))
-        (should-not (file-notify-valid-p file-notify--test-desc2))
-        (when (string-equal (file-notify--test-library) "w32notify")
+        (unless (getenv "EMACS_EMBA_CI")
+          (should-not (file-notify-valid-p file-notify--test-desc1))
+          (should-not (file-notify-valid-p file-notify--test-desc2)))
+        (when (or (string-equal (file-notify--test-library) "w32notify")
+                  (getenv "EMACS_EMBA_CI"))
           (file-notify--rm-descriptor file-notify--test-desc1)
           (file-notify--rm-descriptor file-notify--test-desc2))
 
@@ -1371,8 +1421,8 @@ the file watch."
     ;; Cleanup.
     (file-notify--test-cleanup)))
 
-;(file-notify--deftest-remote file-notify-test09-watched-file-in-watched-dir
-;  "Check `file-notify-test09-watched-file-in-watched-dir' for remote files.")
+(file-notify--deftest-remote file-notify-test09-watched-file-in-watched-dir
+  "Check `file-notify-test09-watched-file-in-watched-dir' for remote files." t)
 
 (ert-deftest file-notify-test10-sufficient-resources ()
   "Check that file notification does not use too many resources."
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index 3b192ee..ae8ea41 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -1,6 +1,6 @@
 ;;; files-tests.el --- tests for files.el.  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -137,7 +137,7 @@ form.")
       (hack-local-variables)
       (eval (nth 2 test-settings)))))
 
-(ert-deftest files-test-local-variables ()
+(ert-deftest files-tests-local-variables ()
   "Test the file-local variables implementation."
   (cl-letf (((symbol-function 'hack-local-variables-confirm)
              (lambda (&rest _)
@@ -154,7 +154,7 @@ form.")
   (expand-file-name "data/files-bug18141.el.gz" (getenv 
"EMACS_TEST_DIRECTORY"))
   "Test file for bug#18141.")
 
-(ert-deftest files-test-bug-18141 ()
+(ert-deftest files-tests-bug-18141 ()
   "Test for https://debbugs.gnu.org/18141 ."
   (skip-unless (executable-find "gzip"))
   ;; If called interactively, environment variable
@@ -170,7 +170,7 @@ form.")
            (should (eq buffer-file-coding-system 'iso-2022-7bit-unix))))
       (delete-file tempfile))))
 
-(ert-deftest files-test-make-temp-file-empty-prefix ()
+(ert-deftest files-tests-make-temp-file-empty-prefix ()
   "Test make-temp-file with an empty prefix."
   (let ((tempfile (make-temp-file ""))
         (tempdir (make-temp-file "" t))
@@ -188,7 +188,7 @@ form.")
 ;; Stop the above "Local Var..." confusing Emacs.
 
 
-(ert-deftest files-test-bug-21454 ()
+(ert-deftest files-tests-bug-21454 ()
   "Test for https://debbugs.gnu.org/21454 ."
   :expected-result :failed
   (let ((input-result
@@ -216,7 +216,7 @@ form.")
       (setenv "FOO" foo-env)
       (setenv "BAR" bar-env))))
 
-(ert-deftest files-test--save-buffers-kill-emacs--confirm-kill-processes ()
+(ert-deftest files-tests-save-buffers-kill-emacs--confirm-kill-processes ()
   "Test that `save-buffers-kill-emacs' honors
 `confirm-kill-processes'."
   (cl-letf* ((yes-or-no-p-prompts nil)
@@ -239,7 +239,7 @@ form.")
     (should-not yes-or-no-p-prompts)
     (should (equal kill-emacs-args '(nil)))))
 
-(ert-deftest files-test-read-file-in-~ ()
+(ert-deftest files-tests-read-file-in-~ ()
   "Test file prompting in directory named '~'.
 If we are in a directory named '~', the default value should not
 be $HOME."
@@ -278,7 +278,7 @@ be $HOME."
                    (file-name-unquote
                     (file-name-unquote temporary-file-directory))))))
 
-(ert-deftest files-tests--file-name-non-special--subprocess ()
+(ert-deftest files-tests-file-name-non-special--subprocess ()
   "Check that Bug#25949 is fixed."
   (skip-unless (executable-find "true"))
   (let ((default-directory (file-name-quote temporary-file-directory)))
@@ -306,7 +306,7 @@ be $HOME."
          (progn ,@body)
        (delete-file ,name))))
 
-(ert-deftest files-tests--file-name-non-special--buffers ()
+(ert-deftest files-tests-file-name-non-special--buffers ()
   "Check that Bug#25951 is fixed.
 We call `verify-visited-file-modtime' on a buffer visiting a file
 with a quoted name.  We use two different variants: first with
@@ -1109,7 +1109,17 @@ unquoted file names."
     (with-temp-buffer
       (write-region nil nil nospecial nil :visit))))
 
-(ert-deftest files-tests--insert-directory-wildcard-in-dir-p ()
+(ert-deftest files-tests-file-name-non-special-make-process ()
+  "Check that the ‘:file-handler’ argument of ‘make-process’
+works as expected if the default directory is quoted."
+  (let ((default-directory (file-name-quote invocation-directory))
+        (program (file-name-quote
+                  (expand-file-name invocation-name invocation-directory))))
+    (should (processp (make-process :name "name"
+                                    :command (list program "--version")
+                                    :file-handler t)))))
+
+(ert-deftest files-tests-insert-directory-wildcard-in-dir-p ()
   (let ((alist (list (cons "/home/user/*/.txt" (cons "/home/user/" "*/.txt"))
                      (cons "/home/user/.txt" nil)
                      (cons "/home/*/.txt" (cons "/home/" "*/.txt"))
@@ -1126,7 +1136,7 @@ unquoted file names."
         (cdr path-res)
         (insert-directory-wildcard-in-dir-p (car path-res)))))))
 
-(ert-deftest files-tests--make-directory ()
+(ert-deftest files-tests-make-directory ()
   (let* ((dir (make-temp-file "files-mkdir-test" t))
         (dirname (file-name-as-directory dir))
         (file (concat dirname "file"))
@@ -1148,7 +1158,7 @@ unquoted file names."
     (should-not (make-directory a/b t))
     (delete-directory dir 'recursive)))
 
-(ert-deftest files-test-no-file-write-contents ()
+(ert-deftest files-tests-no-file-write-contents ()
   "Test that `write-contents-functions' permits saving a file.
 Usually `basic-save-buffer' will prompt for a file name if the
 current buffer has none.  It should first call the functions in
@@ -1177,7 +1187,7 @@ name (Bug#28412)."
         (should (null (save-buffer)))
         (should (eq (buffer-size) 1))))))
 
-(ert-deftest files-tests--copy-directory ()
+(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"))
@@ -1194,7 +1204,7 @@ name (Bug#28412)."
     (should (file-directory-p (concat (file-name-as-directory dest2) "a")))
     (delete-directory dir 'recursive)))
 
-(ert-deftest files-test-abbreviated-home-dir ()
+(ert-deftest files-tests-abbreviated-home-dir ()
   "Test that changing HOME does not confuse `abbreviate-file-name'.
 See <https://debbugs.gnu.org/19657#20>."
   (let* ((homedir temporary-file-directory)
@@ -1208,5 +1218,31 @@ See <https://debbugs.gnu.org/19657#20>."
                                     process-environment)))
     (should (equal old (file-truename (abbreviate-file-name testfile))))))
 
+(ert-deftest files-tests-executable-find ()
+  "Test that `executable-find' works also with a relative or remote PATH.
+See <https://debbugs.gnu.org/35241>."
+  (let ((tmpfile (make-temp-file "files-test" nil (car exec-suffixes))))
+    (unwind-protect
+        (progn
+          (set-file-modes tmpfile #o777)
+          (let ((exec-path `(,temporary-file-directory)))
+            (should
+             (equal tmpfile
+                    (executable-find (file-name-nondirectory tmpfile)))))
+          ;; An empty element of `exec-path' means `default-directory'.
+          (let ((default-directory temporary-file-directory)
+                (exec-path nil))
+            (should
+             (equal tmpfile
+                    (executable-find (file-name-nondirectory tmpfile)))))
+          ;; The remote file name shall be quoted, and handled like a
+          ;; non-existing directory.
+          (let ((default-directory "/ssh::")
+                (exec-path (append exec-path `("." 
,temporary-file-directory))))
+            (should
+             (equal tmpfile
+                    (executable-find (file-name-nondirectory tmpfile))))))
+      (delete-file tmpfile))))
+
 (provide 'files-tests)
 ;;; files-tests.el ends here
diff --git a/test/lisp/files-x-tests.el b/test/lisp/files-x-tests.el
index a77c681..568a898 100644
--- a/test/lisp/files-x-tests.el
+++ b/test/lisp/files-x-tests.el
@@ -1,6 +1,6 @@
 ;;; files-x-tests.el --- tests for files-x.el.
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 
@@ -35,6 +35,11 @@
   '((remote-null-device . "/dev/null")))
 (defconst files-x-test--variables4
   '((remote-null-device . "null")))
+(put 'remote-shell-file-name 'safe-local-variable #'identity)
+(put 'remote-shell-command-switch 'safe-local-variable #'identity)
+(put 'remote-shell-interactive-switch 'safe-local-variable #'identity)
+(put 'remote-shell-login-switch 'safe-local-variable #'identity)
+(put 'remote-null-device 'safe-local-variable #'identity)
 
 (defconst files-x-test--application '(:application 'my-application))
 (defconst files-x-test--another-application
@@ -268,7 +273,9 @@
         (should-not (local-variable-p 'remote-shell-file-name))
         (should-not (boundp 'remote-shell-file-name))))))
 
-(ert-deftest files-x-test-with-connection-local-profiles ()
+(defvar tramp-connection-local-default-profile)
+
+(ert-deftest files-x-test-with-connection-local-variables ()
   "Test setting connection-local variables."
 
   (let (connection-local-profile-alist connection-local-criteria-alist)
@@ -303,46 +310,48 @@
          (string-equal (symbol-value 'remote-null-device) "/dev/null"))
 
        ;; A candidate connection-local variable is not bound yet.
-        (should-not (local-variable-p 'remote-shell-command-switch))
-
-       ;; Use the macro.
-        (with-connection-local-profiles '(remote-bash remote-ksh)
-          ;; All connection-local variables are set.  They apply in
-          ;; reverse order in `connection-local-variables-alist'.
-          ;; This variable keeps only the variables to be set inside
-          ;; the macro.
-          (should
-           (equal connection-local-variables-alist
-                  (nreverse (copy-tree files-x-test--variables1))))
-          ;; The variables exist also as local variables.
-          (should (local-variable-p 'remote-shell-file-name))
-          (should (local-variable-p 'remote-shell-command-switch))
-          ;; The proper variable values are set.  The settings from
-          ;; `remote-bash' overwrite the same variables as in
-          ;; `remote-ksh'.
-          (should
-           (string-equal (symbol-value 'remote-shell-file-name) "/bin/bash"))
-          (should
-           (string-equal (symbol-value 'remote-shell-command-switch) "-c")))
-
-        ;; Everything is rewound.  The old variable values are reset.
-        (should
-         (equal connection-local-variables-alist
-               (append
-                (nreverse (copy-tree files-x-test--variables3))
-                (nreverse (copy-tree files-x-test--variables2)))))
-        ;; The variables exist also as local variables.
-        (should (local-variable-p 'remote-shell-file-name))
-        (should (local-variable-p 'remote-null-device))
-        ;; The proper variable values are set.  The settings from
-       ;; `remote-ksh' are back.
-        (should
-         (string-equal (symbol-value 'remote-shell-file-name) "/bin/ksh"))
-        (should
-         (string-equal (symbol-value 'remote-null-device) "/dev/null"))
+        (should-not (local-variable-p 'remote-shell-command-switch))))
 
-       ;; The variable set temporarily is not unbound, again.
-        (should-not (local-variable-p 'remote-shell-command-switch))))))
+    (with-temp-buffer
+      ;; Use the macro.  We need a remote `default-directory'.
+      (let ((enable-connection-local-variables t)
+           (default-directory "/method:host:")
+           (remote-null-device "null"))
+        (should-not connection-local-variables-alist)
+        (should-not (local-variable-p 'remote-shell-file-name))
+        (should-not (local-variable-p 'remote-null-device))
+        (should-not (boundp 'remote-shell-file-name))
+        (should (string-equal (symbol-value 'remote-null-device) "null"))
+
+       (with-connection-local-variables
+        ;; All connection-local variables are set.  They apply in
+        ;; reverse order in `connection-local-variables-alist'.
+        ;; Since we ha a remote default directory, Tramp's settings
+        ;; are appended as well.
+         (should
+          (equal
+           connection-local-variables-alist
+          (append
+           (nreverse (copy-tree files-x-test--variables3))
+           (nreverse (copy-tree files-x-test--variables2))
+            (nreverse (copy-tree tramp-connection-local-default-profile)))))
+         ;; The variables exist also as local variables.
+         (should (local-variable-p 'remote-shell-file-name))
+         (should (local-variable-p 'remote-null-device))
+         ;; The proper variable values are set.
+         (should
+          (string-equal (symbol-value 'remote-shell-file-name) "/bin/ksh"))
+         (should
+          (string-equal (symbol-value 'remote-null-device) "/dev/null")))
+
+       ;; Everything is rewound.  The old variable values are reset.
+       (should-not connection-local-variables-alist)
+       ;; The variables don't exist as local variables.
+       (should-not (local-variable-p 'remote-shell-file-name))
+       (should-not (local-variable-p 'remote-null-device))
+       ;; The variable values are reset.
+       (should-not (boundp 'remote-shell-file-name))
+       (should (string-equal (symbol-value 'remote-null-device) "null"))))))
 
 (provide 'files-x-tests)
 ;;; files-x-tests.el ends here
diff --git a/test/lisp/gnus/gnus-test-headers.el 
b/test/lisp/gnus/gnus-test-headers.el
new file mode 100644
index 0000000..abf3d4f
--- /dev/null
+++ b/test/lisp/gnus/gnus-test-headers.el
@@ -0,0 +1,178 @@
+;;; gnus-test-headers.el --- Tests for Gnus header-related functions  -*- 
lexical-binding: t; -*-
+
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
+
+;; Author: Eric Abrahamsen <address@hidden>
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; The tests her are for
+
+;;; Code:
+
+(require 'ert)
+(require 'gnus-sum)
+
+(defconst gnus-headers-test-data
+  '([2 "Re: [Emacs-devel] Emacs move" "Dave Love <address@hidden>"
+       "Thu, 14 Sep 2000 11:10:46 +0100"
+       "<address@hidden>"
+       "<address@hidden>"
+       1882 16 "nnmaildir mails:2"
+       ((To . "Jeff Bailey <address@hidden>")
+        (Cc . "address@hidden, address@hidden"))]
+    [3 "Re: [Emacs-devel] Emacs move" "Sam Steingold <address@hidden>"
+       "14 Sep 2000 10:21:56 -0400" "<address@hidden>"
+       "<address@hidden>"
+       2991 50 "nnmaildir mails:3"
+       ((To . "Jeff Bailey <address@hidden>")
+        (Cc . "address@hidden, address@hidden"))]
+    [4 "Re: [Emacs-devel] Emacs move" "Jeff Bailey <address@hidden>"
+       "Thu, 14 Sep 2000 09:14:47 -0700"
+       "<address@hidden>"
+       "<address@hidden> <address@hidden>"
+       1780 15 "nnmaildir mails:4"
+       ((To . "address@hidden, Jeff Bailey <address@hidden>")
+        (Cc . "address@hidden, address@hidden"))]
+    [5 "Re: [Emacs-devel] Emacs move" "Dave Love <address@hidden>"
+       "Thu, 14 Sep 2000 18:24:36 +0100"
+       "<address@hidden>"
+       "<address@hidden>"
+       1343 9 "nnmaildir mails:5"
+       ((To . "Jeff Bailey <address@hidden>")
+        (Cc . "address@hidden, address@hidden"))]
+    [6 "Re: [Emacs-devel] Emacs move" "Karl Fogel <address@hidden>"
+       "14 Sep 2000 10:37:35 -0500" "<address@hidden>"
+       "<address@hidden> <address@hidden>"
+       3740 124 "nnmaildir mails:6"
+       ((To . "Dave Love <address@hidden>")
+        (Cc . "Jeff Bailey <address@hidden>, address@hidden, address@hidden"))]
+    [7 "Re: [Emacs-devel] Emacs move" "Jeff Bailey <address@hidden>"
+       "Thu, 14 Sep 2000 10:55:12 -0700"
+       "<address@hidden>"
+       "<address@hidden> <address@hidden> <address@hidden>"
+       1687 16 "nnmaildir mails:7"
+       ((To . "address@hidden, Dave Love <address@hidden>")
+        (Cc . "Jeff Bailey <address@hidden>, address@hidden, address@hidden"))]
+    [8 "Re: [Emacs-devel] Emacs move" "John Wiegley <address@hidden>"
+       "Thu, 14 Sep 2000 12:19:01 -0700"
+       "<address@hidden>"
+       "<address@hidden>"
+       1978 27 "nnmaildir mails:8"
+       ((To . "address@hidden"))]
+    [9 "Re: [Emacs-devel] Emacs move"
+       "\"Robert J. Chassell\" <address@hidden>"
+       "Thu, 14 Sep 2000 07:33:15 -0400 (EDT)"
+       "<address@hidden>"
+       "<address@hidden>"
+       3046 72 "nnmaildir mails:9"
+       ((To . "address@hidden")
+        (Cc . "address@hidden, address@hidden"))]
+    [10 "Re: [Emacs-devel] Emacs move"
+        "address@hidden (William M. Perry)"
+        "14 Sep 2000 09:10:25 -0500"
+        "<address@hidden>"
+        "<address@hidden> <address@hidden>"
+        3104 44 "nnmaildir mails:10"
+        ((To . "address@hidden")
+         (Cc . "address@hidden, address@hidden, address@hidden"))]
+    [11 "Re: [Emacs-devel] Emacs move" "Gerd Moellmann <address@hidden>"
+        "Thu, 14 Sep 2000 21:51:05 +0200 (CEST)"
+        "<address@hidden>"
+        "<address@hidden> <address@hidden> <address@hidden>"
+        1884 6 "nnmaildir mails:11"
+        ((To . "address@hidden")
+         (Cc . "address@hidden, address@hidden, address@hidden, 
address@hidden"))]
+    [12 "Re: [Emacs-devel] Emacs move" "Gerd Moellmann <address@hidden>"
+        "Thu, 14 Sep 2000 21:49:03 +0200 (CEST)"
+        "<address@hidden>"
+        "<address@hidden> <address@hidden>"
+        2408 24 "nnmaildir mails:12"
+        ((To . "address@hidden")
+         (Cc . "address@hidden, address@hidden, address@hidden"))]
+    [13 "Re: [Emacs-devel] Emacs move"
+        "\"Robert J. Chassell\" <address@hidden>"
+        "Thu, 14 Sep 2000 17:50:01 -0400 (EDT)"
+        "<address@hidden>"
+        "<address@hidden> <address@hidden> <address@hidden>"
+        1968 23 "nnmaildir mails:13"
+        ((To . "address@hidden")
+         (Cc . "address@hidden, address@hidden, address@hidden, 
address@hidden"))]
+    [14 "Re: [Emacs-devel] Emacs move" "Richard Stallman <address@hidden>"
+        "Fri, 15 Sep 2000 16:28:12 -0600 (MDT)"
+        "<address@hidden>"
+        "<address@hidden> <address@hidden>"
+        1288 2 "nnmaildir mails:14"
+        ((To . "address@hidden, address@hidden, address@hidden"))]
+    [15 "[Emacs-devel] Emacs move" "Jeff Bailey <address@hidden>"
+        "Wed, 13 Sep 2000 17:59:43 -0700"
+        "<address@hidden>" ""
+        1661 26 "nnmaildir mails:15"
+        ((To . "address@hidden")
+         (Cc . "address@hidden"))]
+    [16 "Re: [Emacs-devel] Emacs move" "Jeff Bailey <address@hidden>"
+        "Fri, 15 Sep 2000 22:00:12 -0700"
+        "<address@hidden>"
+        "<address@hidden> <address@hidden> <address@hidden> <address@hidden>"
+        2857 51 "nnmaildir mails:16"
+        ((To . "address@hidden, address@hidden")
+         (Cc . "address@hidden, address@hidden, address@hidden"))])
+  "A pile of headers with potential interdependencies.")
+
+(ert-deftest gnus-headers-make-dependency-table ()
+  (let ((table (gnus-make-hashtable 20))
+        (data (copy-sequence gnus-headers-test-data))
+        ret)
+    (dolist (h data)
+      ;; `gnus-dependencies-add-header' returns nil if it fails to add
+      ;; the header.
+      (should (gnus-dependencies-add-header h table nil)))
+    ;; Pick a value to test.
+    (setq ret (gethash "<address@hidden>"
+                       table))
+    ;; The message has three children.
+    (should (= 3 (length (cdr ret))))
+    ;; The first of those children has one child.
+    (should (= 1 (length (cdr (nth 1 ret)))))))
+
+(ert-deftest gnus-headers-loop-dependencies ()
+  "Intentionally create a reference loop."
+  (let ((table (gnus-make-hashtable 20))
+        (data (copy-sequence gnus-headers-test-data))
+        (parent-id "<address@hidden>")
+        (child-id "<address@hidden>")
+        parent)
+    (dolist (h data)
+      (gnus-dependencies-add-header h table nil))
+
+    (setq parent (gethash parent-id table))
+
+    ;; Put the parent header in the child references of one of its own
+    ;; children.  `gnus-thread-loop-p' only checks if there's a loop
+    ;; between parent and immediate child, not parent and random
+    ;; descendant.  At least, near as I can tell that's the case.
+
+    (push (list (car parent)) (cdr (gethash child-id table)))
+
+    (let ((gnus-newsgroup-dependencies table))
+     (should
+      (= 1                              ; 1 indicates an infloop.
+         (gnus-thread-loop-p (car parent) (cadr parent)))))))
+
+(provide 'gnus-test-headers)
+;;; gnus-test-headers.el ends here
diff --git a/test/lisp/gnus/gnus-tests.el b/test/lisp/gnus/gnus-tests.el
index fe1fc18..4b7c91f 100644
--- a/test/lisp/gnus/gnus-tests.el
+++ b/test/lisp/gnus/gnus-tests.el
@@ -1,6 +1,6 @@
 ;;; gnus-tests.el --- Wrapper for the Gnus tests
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Teodor Zlatanov <address@hidden>
 
diff --git a/test/lisp/gnus/message-tests.el b/test/lisp/gnus/message-tests.el
index 7fa0fe9..aa3587d 100644
--- a/test/lisp/gnus/message-tests.el
+++ b/test/lisp/gnus/message-tests.el
@@ -1,6 +1,6 @@
 ;;; message-mode-tests.el --- Tests for message-mode  -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: João Távora <address@hidden>
 
diff --git a/test/lisp/help-fns-tests.el b/test/lisp/help-fns-tests.el
index 7e726eb..e31ac6a 100644
--- a/test/lisp/help-fns-tests.el
+++ b/test/lisp/help-fns-tests.el
@@ -1,6 +1,6 @@
 ;;; help-fns.el --- tests for help-fns.el
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 
diff --git a/test/lisp/hi-lock-tests.el b/test/lisp/hi-lock-tests.el
index 4c639b0..c4d25b6 100644
--- a/test/lisp/hi-lock-tests.el
+++ b/test/lisp/hi-lock-tests.el
@@ -1,6 +1,6 @@
 ;;; hi-lock-tests.el --- Tests for hi-lock.el  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Tino Calancha <address@hidden>
 ;; Keywords:
diff --git a/test/lisp/htmlfontify-tests.el b/test/lisp/htmlfontify-tests.el
index 002415c..ada8294 100644
--- a/test/lisp/htmlfontify-tests.el
+++ b/test/lisp/htmlfontify-tests.el
@@ -1,6 +1,6 @@
 ;;; htmlfontify-tests.el --- Test suite. -*- lexical-binding: t -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/ibuffer-tests.el b/test/lisp/ibuffer-tests.el
index ff5162f..0616c9b 100644
--- a/test/lisp/ibuffer-tests.el
+++ b/test/lisp/ibuffer-tests.el
@@ -1,6 +1,6 @@
 ;;; ibuffer-tests.el --- Test suite. -*- lexical-binding: t -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -312,8 +312,8 @@
                 (funcall create-non-file-buffer "ibuf-test-3.b" :size 50
                          :mode #'text-mode
                          :include-content "...but a multitude of drops?\n"))
-               (dirA (with-current-buffer bufA default-directory))
-               (dirB (with-current-buffer bufB default-directory)))
+               (dirA (regexp-quote (with-current-buffer bufA 
default-directory)))
+               (dirB (regexp-quote (with-current-buffer bufB 
default-directory))))
           (should (ibuffer-included-in-filters-p
                    bufA '((basename . "ibuf-test-3"))))
           (should (ibuffer-included-in-filters-p
diff --git a/test/lisp/ido-tests.el b/test/lisp/ido-tests.el
index 7a7b0e7..c9736eb 100644
--- a/test/lisp/ido-tests.el
+++ b/test/lisp/ido-tests.el
@@ -1,6 +1,6 @@
 ;;; ido-tests.el --- unit tests for ido.el           -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Philipp Stephani <address@hidden>
 
@@ -25,6 +25,8 @@
 
 ;;; Code:
 
+(require 'ido)
+
 (ert-deftest ido-tests--other-window-frame ()
   "Verifies that Bug#26360 is fixed."
   (should-not ido-mode)
@@ -44,4 +46,9 @@
         (should (commandp #'ido-display-buffer-other-frame)))
     (ido-mode 0)))
 
+(ert-deftest ido-directory-too-big-p ()
+  (should-not (ido-directory-too-big-p "/some/dir/"))
+  (let ((ido-big-directories (cons (rx "me/di") ido-big-directories)))
+    (should (ido-directory-too-big-p "/some/dir/"))))
+
 ;;; ido-tests.el ends here
diff --git a/test/lisp/image-tests.el b/test/lisp/image-tests.el
new file mode 100644
index 0000000..89b926e
--- /dev/null
+++ b/test/lisp/image-tests.el
@@ -0,0 +1,45 @@
+;;; image-tests.el --- tests for image.el -*- lexical-binding: t -*-
+
+;; Copyright (C) 2019 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert)
+(require 'image)
+
+(ert-deftest image--set-property ()
+  "Test `image--set-property' behavior."
+  (let ((image (list 'image)))
+    ;; Add properties.
+    (setf (image-property image :scale) 1)
+    (should (equal image '(image :scale 1)))
+    (setf (image-property image :width) 8)
+    (should (equal image '(image :scale 1 :width 8)))
+    (setf (image-property image :height) 16)
+    (should (equal image '(image :scale 1 :width 8 :height 16)))
+    ;; Delete properties.
+    (setf (image-property image :type) nil)
+    (should (equal image '(image :scale 1 :width 8 :height 16)))
+    (setf (image-property image :scale) nil)
+    (should (equal image '(image :width 8 :height 16)))
+    (setf (image-property image :height) nil)
+    (should (equal image '(image :width 8)))
+    (setf (image-property image :width) nil)
+    (should (equal image '(image)))))
+
+;;; image-tests.el ends here
diff --git a/test/lisp/imenu-tests.el b/test/lisp/imenu-tests.el
index 5ea6f65..820e834 100644
--- a/test/lisp/imenu-tests.el
+++ b/test/lisp/imenu-tests.el
@@ -1,6 +1,6 @@
 ;;; imenu-tests.el --- Test suite for imenu.
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Masatake YAMATO <address@hidden>
 ;; Keywords: tools convenience
diff --git a/test/lisp/info-xref-tests.el b/test/lisp/info-xref-tests.el
index 1fcbb38..1de3a0d 100644
--- a/test/lisp/info-xref-tests.el
+++ b/test/lisp/info-xref-tests.el
@@ -1,6 +1,6 @@
 ;;; info-xref.el --- tests for info-xref.el
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/international/ccl-tests.el 
b/test/lisp/international/ccl-tests.el
index 7dd7224..69e3930 100644
--- a/test/lisp/international/ccl-tests.el
+++ b/test/lisp/international/ccl-tests.el
@@ -1,4 +1,4 @@
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/international/mule-tests.el 
b/test/lisp/international/mule-tests.el
index 59c9ff5..4c937ca 100644
--- a/test/lisp/international/mule-tests.el
+++ b/test/lisp/international/mule-tests.el
@@ -1,6 +1,6 @@
 ;;; mule-tests.el --- unit tests for mule.el         -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/international/mule-util-tests.el 
b/test/lisp/international/mule-util-tests.el
index 9254813..75e8bf7 100644
--- a/test/lisp/international/mule-util-tests.el
+++ b/test/lisp/international/mule-util-tests.el
@@ -1,6 +1,6 @@
 ;;; mule-util --- tests for international/mule-util.el
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/international/ucs-normalize-tests.el 
b/test/lisp/international/ucs-normalize-tests.el
index 1a1cc75..97d3eae 100644
--- a/test/lisp/international/ucs-normalize-tests.el
+++ b/test/lisp/international/ucs-normalize-tests.el
@@ -1,6 +1,6 @@
 ;;; ucs-normalize --- tests for international/ucs-normalize.el -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2002-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -182,25 +182,24 @@ implementations:
 
 (defconst ucs-normalize-tests--failing-lines-part1
   (list 15131 15132 15133 15134 15135 15136 15137 15138
-        15139
-        16149 16150 16151 16152 16153 16154 16155 16156
-        16157 16158 16159 16160 16161 16162 16163 16164
-        16165 16166 16167 16168 16169 16170 16171 16172
-        16173 16174 16175 16176 16177 16178 16179 16180
-        16181 16182 16183 16184 16185 16186 16187 16188
-        16189 16190 16191 16192 16193 16194 16195 16196
-        16197 16198 16199 16200 16201 16202 16203 16204
-        16205 16206 16207 16208 16209 16210 16211 16212
-        16213 16214 16215 16216 16217 16218 16219 16220
-        16221 16222 16223 16224 16225 16226 16227 16228
-        16229 16230 16231 16232 16233 16234 16235 16236
-        16237 16238 16239 16240 16241 16242 16243 16244
-        16245 16246 16247 16248 16249 16250 16251 16252
-        16253 16254 16255 16256 16257 16258 16259 16260
-        16261 16262 16263 16264 16265 16266 16267 16268
-        16269 16270 16271 16272 16273 16274 16275 16276
-        16277 16278 16279 16280 16281 16282 16283 16284
-        16285 16286 16287 16288 16289))
+        15139 16149 16150 16151 16152 16153 16154 16155
+        16156 16157 16158 16159 16160 16161 16162 16163
+        16164 16165 16166 16167 16168 16169 16170 16171
+        16172 16173 16174 16175 16176 16177 16178 16179
+        16180 16181 16182 16183 16184 16185 16186 16187
+        16188 16189 16190 16191 16192 16193 16194 16195
+        16196 16197 16198 16199 16200 16201 16202 16203
+        16204 16205 16206 16207 16208 16209 16210 16211
+        16212 16213 16214 16215 16216 16217 16218 16219
+        16220 16221 16222 16223 16224 16225 16226 16227
+        16228 16229 16230 16231 16232 16233 16234 16235
+        16236 16237 16238 16239 16240 16241 16242 16243
+        16244 16245 16246 16247 16248 16249 16250 16251
+        16252 16253 16254 16255 16256 16257 16258 16259
+        16260 16261 16262 16263 16264 16265 16266 16267
+        16268 16269 16270 16271 16272 16273 16274 16275
+        16276 16277 16278 16279 16280 16281 16282 16283
+        16284 16285 16286 16287 16288 16289 16366))
 
 ;; Keep a record of failures, for consulting afterwards (the ert
 ;; backtrace only shows a truncated version of these lists).
@@ -258,23 +257,22 @@ implementations:
     ucs-normalize-tests--failing-lines-part1)))
 
 (defconst ucs-normalize-tests--failing-lines-part2
-  (list 17482 17532 17636 18338 18340 18342 18344 18346
-        18348 18350 18352 18354 18356 18358 18360 18362
-        18364 18366 18376 18378 18380 18382 18384 18386
-        18388 18390 18392 18394 18396 18398 18400 18402
-        18404 18406 18408 18410 18412 18414 18416 18418
-        18420 18422 18424 18426 18428 18430 18432 18434
-        18436 18438 18440 18442 18444 18446 18448 18450
-        18452 18454 18456 18458 18460 18462 18464 18466
-        18468 18470 18472 18474 18476 18478 18480 18482
-        18484 18486 18488 18490 18492 18494 18496 18564
-        18566 18568 18570 18572 18574 18576 18578 18580
-        18582 18584 18586 18588 18590 18592 18594 18596
-        18598 18600 18602 18604 18606 18608 18610 18612
-        18614 18616 18618 18620 18622 18624 18626 18628
-        18630 18632 18634 18636 18638 18640 18642 18644
-        18646 18648 18650 18652 18654 18656 18658 18660
-        18662 18664 18666))
+  (list 17689 18379 18381 18383 18385 18387 18389 18391
+        18393 18395 18397 18399 18401 18403 18405 18407
+        18409 18411 18413 18415 18417 18419 18421 18423
+        18425 18427 18429 18431 18433 18435 18437 18439
+        18441 18443 18445 18447 18449 18451 18453 18455
+        18457 18459 18461 18463 18465 18467 18469 18471
+        18473 18475 18477 18479 18481 18483 18485 18487
+        18489 18491 18493 18495 18497 18499 18501 18569
+        18571 18573 18575 18577 18579 18581 18583 18585
+        18587 18589 18591 18593 18595 18597 18599 18601
+        18603 18605 18607 18609 18611 18613 18615 18617
+        18619 18621 18623 18625 18627 18629 18631 18633
+        18635 18637 18639 18641 18643 18645 18647 18649
+        18651 18653 18655 18657 18659 18661 18663 18665
+        18667 18669 18671 18673 18675 18677 18679 18681
+        18683 18685 18687 18689 18691 18693))
 
 (ert-deftest ucs-normalize-part2 ()
   :tags '(:expensive-test)
diff --git a/test/lisp/isearch-tests.el b/test/lisp/isearch-tests.el
index 44ce59c..23acc19 100644
--- a/test/lisp/isearch-tests.el
+++ b/test/lisp/isearch-tests.el
@@ -1,6 +1,6 @@
 ;;; isearch-tests.el --- Tests for isearch.el        -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Artur Malabarba <address@hidden>
 
diff --git a/test/lisp/jit-lock-tests.el b/test/lisp/jit-lock-tests.el
index b65e698..16fff35 100644
--- a/test/lisp/jit-lock-tests.el
+++ b/test/lisp/jit-lock-tests.el
@@ -1,6 +1,6 @@
 ;;; jit-lock-tests.el --- tests for jit-lock
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Dmitry Gutov <address@hidden>
 
diff --git a/test/lisp/json-tests.el b/test/lisp/json-tests.el
index 84039c0..8d1978f 100644
--- a/test/lisp/json-tests.el
+++ b/test/lisp/json-tests.el
@@ -1,6 +1,6 @@
 ;;; json-tests.el --- Test suite for json.el
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Dmitry Gutov <address@hidden>
 
diff --git a/test/lisp/jsonrpc-tests.el b/test/lisp/jsonrpc-tests.el
index 585eb20..52f709f 100644
--- a/test/lisp/jsonrpc-tests.el
+++ b/test/lisp/jsonrpc-tests.el
@@ -1,6 +1,6 @@
 ;;; jsonrpc-tests.el --- tests for jsonrpc.el        -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; Author: João Távora <address@hidden>
 ;; Maintainer: João Távora <address@hidden>
diff --git a/test/lisp/kmacro-tests.el b/test/lisp/kmacro-tests.el
index 7c3dde1..f27f22a 100644
--- a/test/lisp/kmacro-tests.el
+++ b/test/lisp/kmacro-tests.el
@@ -1,6 +1,6 @@
 ;;; kmacro-tests.el --- Tests for kmacro.el       -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Gemini Lasswell <address@hidden>
 
diff --git a/test/lisp/ls-lisp-tests.el b/test/lisp/ls-lisp-tests.el
index 91e8b0b..e97c0fc 100644
--- a/test/lisp/ls-lisp-tests.el
+++ b/test/lisp/ls-lisp-tests.el
@@ -1,6 +1,6 @@
 ;;; ls-lisp-tests.el --- tests for ls-lisp.el  -*- lexical-binding: t-*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Tino Calancha <address@hidden>
 ;; Keywords:
diff --git a/test/lisp/mail/rmail-tests.el b/test/lisp/mail/rmail-tests.el
index e494003..3a0fdbc 100644
--- a/test/lisp/mail/rmail-tests.el
+++ b/test/lisp/mail/rmail-tests.el
@@ -1,6 +1,6 @@
 ;;; rmail-tests.el --- Test suite. -*- lexical-binding: t -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -23,7 +23,7 @@
 
 
 (ert-deftest rmail-autoload ()
-  "Tests to see whether reftex-auc has been autoloaded"
+  "Test that `rmail-edit-current-message' has been autoloaded."
   (should
    (fboundp 'rmail-edit-current-message))
   (should
diff --git a/test/lisp/man-tests.el b/test/lisp/man-tests.el
index dfabf20..dca0ff1 100644
--- a/test/lisp/man-tests.el
+++ b/test/lisp/man-tests.el
@@ -1,6 +1,6 @@
 ;;; man-tests.el --- Test suite for man.
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Wolfgang Jenkner <address@hidden>
 ;; Keywords: help, internal, unix
diff --git a/test/lisp/md4-tests.el b/test/lisp/md4-tests.el
index b011e8b..9712411 100644
--- a/test/lisp/md4-tests.el
+++ b/test/lisp/md4-tests.el
@@ -1,6 +1,6 @@
 ;;; md4-tests.el --- tests for md4.el -*- lexical-binding: t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Mark Oteiza <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/test/lisp/minibuffer-tests.el b/test/lisp/minibuffer-tests.el
index bfacd6b..35df7cc 100644
--- a/test/lisp/minibuffer-tests.el
+++ b/test/lisp/minibuffer-tests.el
@@ -1,6 +1,6 @@
 ;;; completion-tests.el --- Tests for completion functions  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords:
@@ -74,5 +74,11 @@
                     'completion-table-with-predicate
                     full-collection no-A nil))))))
 
+(ert-deftest completion-table-subvert-test ()
+  (let* ((origtable '("A-hello" "A-there"))
+         (subvtable (completion-table-subvert origtable "B" "A")))
+    (should (equal (try-completion "B-hel" subvtable)
+                   "B-hello"))))
+
 (provide 'completion-tests)
 ;;; completion-tests.el ends here
diff --git a/test/lisp/mouse-tests.el b/test/lisp/mouse-tests.el
index 909ba64..aa7b145 100644
--- a/test/lisp/mouse-tests.el
+++ b/test/lisp/mouse-tests.el
@@ -1,6 +1,6 @@
 ;;; mouse-tests.el --- unit tests for mouse.el       -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Philipp Stephani <address@hidden>
 
diff --git a/test/lisp/net/dbus-tests.el b/test/lisp/net/dbus-tests.el
index 1ada255..5245e34 100644
--- a/test/lisp/net/dbus-tests.el
+++ b/test/lisp/net/dbus-tests.el
@@ -1,6 +1,6 @@
 ;;; dbus-tests.el --- Tests of D-Bus integration into Emacs
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 
diff --git a/test/lisp/net/gnutls-tests.el b/test/lisp/net/gnutls-tests.el
index 326e241..ea8dd7e 100644
--- a/test/lisp/net/gnutls-tests.el
+++ b/test/lisp/net/gnutls-tests.el
@@ -1,6 +1,6 @@
 ;;; gnutls-tests.el --- Test suite for gnutls.el
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Ted Zlatanov <address@hidden>
 
diff --git a/test/lisp/net/mailcap-tests.el b/test/lisp/net/mailcap-tests.el
index b108065..e1ec7e1 100644
--- a/test/lisp/net/mailcap-tests.el
+++ b/test/lisp/net/mailcap-tests.el
@@ -1,6 +1,6 @@
 ;;; mailcap-tests.el --- tests for mailcap.el -*- lexical-binding: t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Mark Oteiza <address@hidden>
 
diff --git a/test/lisp/net/network-stream-tests.el 
b/test/lisp/net/network-stream-tests.el
index ddb8f9e..b85746a 100644
--- a/test/lisp/net/network-stream-tests.el
+++ b/test/lisp/net/network-stream-tests.el
@@ -1,6 +1,6 @@
 ;;; network-stream-tests.el --- tests for network processes       -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Ingebrigtsen <address@hidden>
 
@@ -25,6 +25,10 @@
 ;;; Code:
 
 (require 'gnutls)
+(require 'network-stream)
+;; The require above is needed for 'open-network-stream' to work, but
+;; it pulls in nsm, which then makes the :nowait t' tests fail unless
+;; we disable the nsm, which we do by binding 'network-security-level'
 
 (ert-deftest make-local-unix-server ()
   (skip-unless (featurep 'make-network-process '(:family local)))
@@ -67,12 +71,45 @@
                  (= (aref (process-contact server :local) 4) 57869)))
     (delete-process server)))
 
-(defun make-server (host)
+(ert-deftest make-ipv6-tcp-server-with-unspecified-port ()
+  (skip-unless (featurep 'make-network-process '(:family ipv6)))
+  (let ((server
+         (ignore-errors
+           (make-network-process
+            :name "server"
+            :server t
+            :noquery t
+            :family 'ipv6
+            :service t
+            :host 'local))))
+    (skip-unless server)
+    (should (and (arrayp (process-contact server :local))
+                 (numberp (aref (process-contact server :local) 8))
+                 (> (aref (process-contact server :local) 8) 0)))
+    (delete-process server)))
+
+(ert-deftest make-ipv6-tcp-server-with-specified-port ()
+  (skip-unless (featurep 'make-network-process '(:family ipv6)))
+  (let ((server
+         (ignore-errors
+           (make-network-process
+            :name "server"
+            :server t
+            :noquery t
+            :family 'ipv6
+            :service 57870
+            :host 'local))))
+    (skip-unless server)
+    (should (and (arrayp (process-contact server :local))
+                 (= (aref (process-contact server :local) 8) 57870)))
+    (delete-process server)))
+
+(defun make-server (host &optional family)
   (make-network-process
    :name "server"
    :server t
    :noquery t
-   :family 'ipv4
+   :family (or family 'ipv4)
    :coding 'raw-text-unix
    :buffer (get-buffer-create "*server*")
    :service t
@@ -125,6 +162,36 @@
       (should (equal (buffer-string) "foo\n")))
     (delete-process server)))
 
+(ert-deftest echo-server-with-local-ipv4 ()
+  (let* ((server (make-server 'local 'ipv4))
+         (port (aref (process-contact server :local) 4))
+         (proc (make-network-process :name "foo"
+                                     :buffer (generate-new-buffer "*foo*")
+                                     :host 'local
+                                     :family 'ipv4
+                                     :service port)))
+    (with-current-buffer (process-buffer proc)
+      (process-send-string proc "echo foo")
+      (sleep-for 0.1)
+      (should (equal (buffer-string) "foo\n")))
+    (delete-process server)))
+
+(ert-deftest echo-server-with-local-ipv6 ()
+  (skip-unless (featurep 'make-network-process '(:family ipv6)))
+  (let ((server (ignore-errors (make-server 'local 'ipv6))))
+    (skip-unless server)
+    (let* ((port (aref (process-contact server :local) 8))
+           (proc (make-network-process :name "foo"
+                                       :buffer (generate-new-buffer "*foo*")
+                                       :host 'local
+                                       :family 'ipv6
+                                       :service port)))
+      (with-current-buffer (process-buffer proc)
+        (process-send-string proc "echo foo")
+        (sleep-for 0.1)
+        (should (equal (buffer-string) "foo\n")))
+      (delete-process server))))
+
 (ert-deftest echo-server-with-ip ()
   (let* ((server (make-server 'local))
          (port (aref (process-contact server :local) 4))
@@ -214,6 +281,7 @@
   (skip-unless (gnutls-available-p))
   (let ((server (make-tls-server 44331))
         (times 0)
+        (network-security-level 'low)
         proc status)
     (unwind-protect
         (progn
@@ -257,6 +325,7 @@
   (skip-unless (featurep 'make-network-process '(:family ipv6)))
   (let ((server (make-tls-server 44333))
         (times 0)
+        (network-security-level 'low)
         proc status)
     (unwind-protect
         (progn
@@ -294,4 +363,365 @@
       (setq issuer (split-string issuer ","))
       (should (equal (nth 3 issuer) "O=Emacs Test Servicess LLC")))))
 
+(ert-deftest open-network-stream-tls-wait ()
+  (skip-unless (executable-find "gnutls-serv"))
+  (skip-unless (gnutls-available-p))
+  (let ((server (make-tls-server 44334))
+        (times 0)
+        (network-security-level 'low)
+        proc status)
+    (unwind-protect
+        (progn
+          (sleep-for 1)
+          (with-current-buffer (process-buffer server)
+            (message "gnutls-serv: %s" (buffer-string)))
+
+          ;; It takes a while for gnutls-serv to start.
+          (while (and (null (ignore-errors
+                              (setq proc (open-network-stream
+                                          "bar"
+                                          (generate-new-buffer "*foo*")
+                                          "localhost"
+                                          44334
+                                          :type 'tls
+                                          :nowait nil))))
+                      (< (setq times (1+ times)) 10))
+            (sit-for 0.1))
+          (should proc)
+          (skip-unless (not (eq (process-status proc) 'connect))))
+      (if (process-live-p server) (delete-process server)))
+    (setq status (gnutls-peer-status proc))
+    (should (consp status))
+    (delete-process proc)
+    ;; This sleep-for is needed for the native MS-Windows build.  If
+    ;; it is removed, the next test mysteriously fails because the
+    ;; initial part of the echo is not received.
+    (sleep-for 0.1)
+    (let ((issuer (plist-get (plist-get status :certificate) :issuer)))
+      (should (stringp issuer))
+      (setq issuer (split-string issuer ","))
+      (should (equal (nth 3 issuer) "O=Emacs Test Servicess LLC")))))
+
+(ert-deftest open-network-stream-tls-nowait ()
+  (skip-unless (executable-find "gnutls-serv"))
+  (skip-unless (gnutls-available-p))
+  (let ((server (make-tls-server 44335))
+        (times 0)
+        (network-security-level 'low)
+        proc status)
+    (unwind-protect
+        (progn
+          (sleep-for 1)
+          (with-current-buffer (process-buffer server)
+            (message "gnutls-serv: %s" (buffer-string)))
+
+          ;; It takes a while for gnutls-serv to start.
+          (while (and (null (ignore-errors
+                              (setq proc (open-network-stream
+                                          "bar"
+                                          (generate-new-buffer "*foo*")
+                                          "localhost"
+                                          44335
+                                          :type 'tls
+                                          :nowait t))))
+                      (< (setq times (1+ times)) 10))
+            (sit-for 0.1))
+          (should proc)
+          (setq times 0)
+          (while (and (eq (process-status proc) 'connect)
+                      (< (setq times (1+ times)) 10))
+            (sit-for 0.1))
+          (skip-unless (not (eq (process-status proc) 'connect))))
+      (if (process-live-p server) (delete-process server)))
+    (setq status (gnutls-peer-status proc))
+    (should (consp status))
+    (delete-process proc)
+    ;; This sleep-for is needed for the native MS-Windows build.  If
+    ;; it is removed, the next test mysteriously fails because the
+    ;; initial part of the echo is not received.
+    (sleep-for 0.1)
+    (let ((issuer (plist-get (plist-get status :certificate) :issuer)))
+      (should (stringp issuer))
+      (setq issuer (split-string issuer ","))
+      (should (equal (nth 3 issuer) "O=Emacs Test Servicess LLC")))))
+
+(ert-deftest open-network-stream-tls ()
+  (skip-unless (executable-find "gnutls-serv"))
+  (skip-unless (gnutls-available-p))
+  (let ((server (make-tls-server 44336))
+        (times 0)
+        (network-security-level 'low)
+        proc status)
+    (unwind-protect
+        (progn
+          (sleep-for 1)
+          (with-current-buffer (process-buffer server)
+            (message "gnutls-serv: %s" (buffer-string)))
+
+          ;; It takes a while for gnutls-serv to start.
+          (while (and (null (ignore-errors
+                              (setq proc (open-network-stream
+                                          "bar"
+                                          (generate-new-buffer "*foo*")
+                                          "localhost"
+                                          44336
+                                          :type 'tls))))
+                      (< (setq times (1+ times)) 10))
+            (sit-for 0.1))
+          (should proc)
+          (skip-unless (not (eq (process-status proc) 'connect))))
+      (if (process-live-p server) (delete-process server)))
+    (setq status (gnutls-peer-status proc))
+    (should (consp status))
+    (delete-process proc)
+    ;; This sleep-for is needed for the native MS-Windows build.  If
+    ;; it is removed, the next test mysteriously fails because the
+    ;; initial part of the echo is not received.
+    (sleep-for 0.1)
+    (let ((issuer (plist-get (plist-get status :certificate) :issuer)))
+      (should (stringp issuer))
+      (setq issuer (split-string issuer ","))
+      (should (equal (nth 3 issuer) "O=Emacs Test Servicess LLC")))))
+
+(ert-deftest open-network-stream-tls-nocert ()
+  (skip-unless (executable-find "gnutls-serv"))
+  (skip-unless (gnutls-available-p))
+  (let ((server (make-tls-server 44337))
+        (times 0)
+        (network-security-level 'low)
+        proc status)
+    (unwind-protect
+        (progn
+          (sleep-for 1)
+          (with-current-buffer (process-buffer server)
+            (message "gnutls-serv: %s" (buffer-string)))
+
+          ;; It takes a while for gnutls-serv to start.
+          (while (and (null (ignore-errors
+                              (setq proc (open-network-stream
+                                          "bar"
+                                          (generate-new-buffer "*foo*")
+                                          "localhost"
+                                          44337
+                                          :type 'tls
+                                          :client-certificate nil))))
+                      (< (setq times (1+ times)) 10))
+            (sit-for 0.1))
+          (should proc)
+          (skip-unless (not (eq (process-status proc) 'connect))))
+      (if (process-live-p server) (delete-process server)))
+    (setq status (gnutls-peer-status proc))
+    (should (consp status))
+    (delete-process proc)
+    ;; This sleep-for is needed for the native MS-Windows build.  If
+    ;; it is removed, the next test mysteriously fails because the
+    ;; initial part of the echo is not received.
+    (sleep-for 0.1)
+    (let ((issuer (plist-get (plist-get status :certificate) :issuer)))
+      (should (stringp issuer))
+      (setq issuer (split-string issuer ","))
+      (should (equal (nth 3 issuer) "O=Emacs Test Servicess LLC")))))
+
+(ert-deftest open-gnutls-stream-new-api-default ()
+  (skip-unless (executable-find "gnutls-serv"))
+  (skip-unless (gnutls-available-p))
+  (let ((server (make-tls-server 44665))
+        (times 0)
+        proc status)
+    (unwind-protect
+        (progn
+          (sleep-for 1)
+          (with-current-buffer (process-buffer server)
+            (message "gnutls-serv: %s" (buffer-string)))
+
+          ;; It takes a while for gnutls-serv to start.
+          (while (and (null (ignore-errors
+                              (setq proc (open-gnutls-stream
+                                          "bar"
+                                          (generate-new-buffer "*foo*")
+                                          "localhost"
+                                          44665))))
+                      (< (setq times (1+ times)) 10))
+            (sit-for 0.1))
+          (should proc)
+      (if (process-live-p server) (delete-process server)))
+    (setq status (gnutls-peer-status proc))
+    (should (consp status))
+    (delete-process proc)
+    ;; This sleep-for is needed for the native MS-Windows build.  If
+    ;; it is removed, the next test mysteriously fails because the
+    ;; initial part of the echo is not received.
+    (sleep-for 0.1)
+    (let ((issuer (plist-get (plist-get status :certificate) :issuer)))
+      (should (stringp issuer))
+      (setq issuer (split-string issuer ","))
+      (should (equal (nth 3 issuer) "O=Emacs Test Servicess LLC"))))))
+
+(ert-deftest open-gnutls-stream-new-api-wait ()
+  (skip-unless (executable-find "gnutls-serv"))
+  (skip-unless (gnutls-available-p))
+  (let ((server (make-tls-server 44666))
+        (times 0)
+        proc status)
+    (unwind-protect
+        (progn
+          (sleep-for 1)
+          (with-current-buffer (process-buffer server)
+            (message "gnutls-serv: %s" (buffer-string)))
+
+          ;; It takes a while for gnutls-serv to start.
+          (while (and (null (ignore-errors
+                              (setq proc (open-gnutls-stream
+                                          "bar"
+                                          (generate-new-buffer "*foo*")
+                                          "localhost"
+                                          44666
+                                          (list :nowait nil)))))
+                      (< (setq times (1+ times)) 10))
+            (sit-for 0.1))
+          (should proc)
+      (if (process-live-p server) (delete-process server)))
+    (setq status (gnutls-peer-status proc))
+    (should (consp status))
+    (delete-process proc)
+    ;; This sleep-for is needed for the native MS-Windows build.  If
+    ;; it is removed, the next test mysteriously fails because the
+    ;; initial part of the echo is not received.
+    (sleep-for 0.1)
+    (let ((issuer (plist-get (plist-get status :certificate) :issuer)))
+      (should (stringp issuer))
+      (setq issuer (split-string issuer ","))
+      (should (equal (nth 3 issuer) "O=Emacs Test Servicess LLC"))))))
+
+(ert-deftest open-gnutls-stream-old-api-wait ()
+  (skip-unless (executable-find "gnutls-serv"))
+  (skip-unless (gnutls-available-p))
+  (let ((server (make-tls-server 44667))
+        (times 0)
+        nowait
+        proc status)
+    (unwind-protect
+        (progn
+          (sleep-for 1)
+          (with-current-buffer (process-buffer server)
+            (message "gnutls-serv: %s" (buffer-string)))
+
+          ;; It takes a while for gnutls-serv to start.
+          (while (and (null (ignore-errors
+                              (setq proc (open-gnutls-stream
+                                          "bar"
+                                          (generate-new-buffer "*foo*")
+                                          "localhost"
+                                          44667
+                                          nowait))))
+                      (< (setq times (1+ times)) 10))
+            (sit-for 0.1))
+          (should proc)
+      (if (process-live-p server) (delete-process server)))
+    (setq status (gnutls-peer-status proc))
+    (should (consp status))
+    (delete-process proc)
+    ;; This sleep-for is needed for the native MS-Windows build.  If
+    ;; it is removed, the next test mysteriously fails because the
+    ;; initial part of the echo is not received.
+    (sleep-for 0.1)
+    (let ((issuer (plist-get (plist-get status :certificate) :issuer)))
+      (should (stringp issuer))
+      (setq issuer (split-string issuer ","))
+      (should (equal (nth 3 issuer) "O=Emacs Test Servicess LLC"))))))
+
+(ert-deftest open-gnutls-stream-new-api-nowait ()
+  (skip-unless (executable-find "gnutls-serv"))
+  (skip-unless (gnutls-available-p))
+  (let ((server (make-tls-server 44668))
+        (times 0)
+        (network-security-level 'low)
+        proc status)
+    (unwind-protect
+        (progn
+          (sleep-for 1)
+          (with-current-buffer (process-buffer server)
+            (message "gnutls-serv: %s" (buffer-string)))
+
+          ;; It takes a while for gnutls-serv to start.
+          (while (and (null (ignore-errors
+                              (setq proc (open-gnutls-stream
+                                          "bar"
+                                          (generate-new-buffer "*foo*")
+                                          "localhost"
+                                          44668
+                                          (list :nowait t)))))
+                      (< (setq times (1+ times)) 10))
+            (sit-for 0.1))
+          (should proc)
+          (setq times 0)
+          (while (and (eq (process-status proc) 'connect)
+                      (< (setq times (1+ times)) 10))
+            (sit-for 0.1))
+          (skip-unless (not (eq (process-status proc) 'connect))))
+      (if (process-live-p server) (delete-process server)))
+    (setq status (gnutls-peer-status proc))
+    (should (consp status))
+    (delete-process proc)
+    (let ((issuer (plist-get (plist-get status :certificate) :issuer)))
+      (should (stringp issuer))
+      (setq issuer (split-string issuer ","))
+      (should (equal (nth 3 issuer) "O=Emacs Test Servicess LLC")))))
+
+(ert-deftest open-gnutls-stream-old-api-nowait ()
+  (skip-unless (executable-find "gnutls-serv"))
+  (skip-unless (gnutls-available-p))
+  (let ((server (make-tls-server 44669))
+        (times 0)
+        (network-security-level 'low)
+        (nowait t)
+        proc status)
+    (unwind-protect
+        (progn
+          (sleep-for 1)
+          (with-current-buffer (process-buffer server)
+            (message "gnutls-serv: %s" (buffer-string)))
+
+          ;; It takes a while for gnutls-serv to start.
+          (while (and (null (ignore-errors
+                              (setq proc (open-gnutls-stream
+                                          "bar"
+                                          (generate-new-buffer "*foo*")
+                                          "localhost"
+                                          44669
+                                          nowait))))
+                      (< (setq times (1+ times)) 10))
+            (sit-for 0.1))
+          (should proc)
+          (setq times 0)
+          (while (and (eq (process-status proc) 'connect)
+                      (< (setq times (1+ times)) 10))
+            (sit-for 0.1))
+          (skip-unless (not (eq (process-status proc) 'connect))))
+      (if (process-live-p server) (delete-process server)))
+    (setq status (gnutls-peer-status proc))
+    (should (consp status))
+    (delete-process proc)
+    (let ((issuer (plist-get (plist-get status :certificate) :issuer)))
+      (should (stringp issuer))
+      (setq issuer (split-string issuer ","))
+      (should (equal (nth 3 issuer) "O=Emacs Test Servicess LLC")))))
+
+(ert-deftest open-gnutls-stream-new-api-errors ()
+  (skip-unless (gnutls-available-p))
+  (should-error
+   (open-gnutls-stream
+    "bar"
+    (generate-new-buffer "*foo*")
+    "localhost"
+    44777
+    (list t)))
+  (should-error
+   (open-gnutls-stream
+    "bar"
+    (generate-new-buffer "*foo*")
+    "localhost"
+    44777
+    (vector :nowait t))))
+
 ;;; network-stream-tests.el ends here
diff --git a/test/lisp/net/newsticker-tests.el 
b/test/lisp/net/newsticker-tests.el
index ad66d30..47f8bd6 100644
--- a/test/lisp/net/newsticker-tests.el
+++ b/test/lisp/net/newsticker-tests.el
@@ -1,6 +1,6 @@
 ;;; newsticker-testsuite.el --- Test suite for newsticker.
 
-;; Copyright (C) 2003-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2019 Free Software Foundation, Inc.
 
 ;; Author:      Ulf Jasper <address@hidden>
 ;; Keywords:    News, RSS, Atom
diff --git a/test/lisp/net/puny-tests.el b/test/lisp/net/puny-tests.el
index 41eacff..d85e20f 100644
--- a/test/lisp/net/puny-tests.el
+++ b/test/lisp/net/puny-tests.el
@@ -1,6 +1,6 @@
 ;;; puny-tests.el --- tests for net/puny.el  -*- coding: utf-8; -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/net/sasl-scram-rfc-tests.el 
b/test/lisp/net/sasl-scram-rfc-tests.el
index 497f0d6..af043e9 100644
--- a/test/lisp/net/sasl-scram-rfc-tests.el
+++ b/test/lisp/net/sasl-scram-rfc-tests.el
@@ -1,6 +1,6 @@
 ;;; sasl-scram-rfc-tests.el --- tests for SCRAM-SHA-1       -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Magnus Henoch <address@hidden>
 
diff --git a/test/lisp/net/secrets-tests.el b/test/lisp/net/secrets-tests.el
index de3ce73..c565eba 100644
--- a/test/lisp/net/secrets-tests.el
+++ b/test/lisp/net/secrets-tests.el
@@ -1,6 +1,6 @@
 ;;; secrets-tests.el --- Tests of Secret Service API
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 
@@ -90,10 +90,6 @@
   (unwind-protect
       (progn
        (should (secrets-open-session))
-
-       ;; There must be at least the collections "Login" and "session".
-       (should (or (member "Login" (secrets-list-collections))
-                    (member "login" (secrets-list-collections))))
        (should (member "session" (secrets-list-collections)))
 
        ;; Create a random collection.  This asks for a password
@@ -160,9 +156,6 @@
 
        ;; There shall be no items in the "session" collection.
        (should-not (secrets-list-items "session"))
-       ;; There shall be items in the "Login" collection.
-       (should (or (secrets-list-items "Login")
-                    (secrets-list-items "login")))
 
        ;; Create a new item.
        (should (setq item-path (secrets-create-item "session" "foo" "secret")))
diff --git a/test/lisp/net/shr-tests.el b/test/lisp/net/shr-tests.el
index 398d519..dd820e2 100644
--- a/test/lisp/net/shr-tests.el
+++ b/test/lisp/net/shr-tests.el
@@ -1,6 +1,6 @@
 ;;; network-stream-tests.el --- tests for network processes       -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Ingebrigtsen <address@hidden>
 
diff --git a/test/lisp/net/tramp-archive-tests.el 
b/test/lisp/net/tramp-archive-tests.el
index e759786..454279e 100644
--- a/test/lisp/net/tramp-archive-tests.el
+++ b/test/lisp/net/tramp-archive-tests.el
@@ -1,6 +1,6 @@
 ;;; tramp-archive-tests.el --- Tests of file archive access  -*- 
lexical-binding:t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 
@@ -24,6 +24,8 @@
 
 (require 'ert)
 (require 'tramp-archive)
+(defvar tramp-copy-size-limit)
+(defvar tramp-persistency-file-name)
 
 (defconst tramp-archive-test-resource-directory
   (let ((default-directory
@@ -76,7 +78,7 @@ the origin of the temporary TMPFILE, have no write 
permissions."
   (if (file-regular-p tmpfile)
       (delete-file tmpfile)
     (mapc
-     'tramp-archive--test-delete
+     #'tramp-archive--test-delete
      (directory-files tmpfile 'full directory-files-no-dot-files-regexp))
     (delete-directory tmpfile)))
 
@@ -513,7 +515,7 @@ This checks also `file-name-as-directory', 
`file-name-directory',
   (skip-unless tramp-archive-enabled)
 
   (let ((tmp-name tramp-archive-test-archive)
-       (files '("." ".." "bar"  "baz.tar" "foo.hrd" "foo.lnk" "foo.txt")))
+       (files '("." ".." "bar" "baz.tar" "foo.hrd" "foo.lnk" "foo.txt")))
     (unwind-protect
        (progn
          (should (file-directory-p tmp-name))
@@ -568,26 +570,35 @@ This checks also `file-name-as-directory', 
`file-name-directory',
               (format
                "\\(.+ %s\\( ->.+\\)?\n\\)\\{%d\\}"
                (regexp-opt (directory-files tramp-archive-test-archive))
-               (length (directory-files tramp-archive-test-archive))))))))
+               (length (directory-files tramp-archive-test-archive)))))))
+
+         ;; Check error case.
+         (with-temp-buffer
+           (should-error
+            (insert-directory
+             (expand-file-name "baz" tramp-archive-test-archive) nil)
+            :type tramp-file-missing)))
 
       ;; Cleanup.
       (tramp-archive-cleanup-hash))))
 
 (ert-deftest tramp-archive-test18-file-attributes ()
   "Check `file-attributes'.
-This tests also `file-readable-p' and `file-regular-p'."
+This tests also `access-file', `file-readable-p' and `file-regular-p'."
   :tags '(:expensive-test)
   (skip-unless tramp-archive-enabled)
 
   (let ((tmp-name1 (expand-file-name "foo.txt" tramp-archive-test-archive))
        (tmp-name2 (expand-file-name "foo.lnk" tramp-archive-test-archive))
        (tmp-name3 (expand-file-name "bar" tramp-archive-test-archive))
+       (tmp-name4 (expand-file-name "baz" tramp-archive-test-archive))
        attr)
     (unwind-protect
        (progn
          (should (file-exists-p tmp-name1))
          (should (file-readable-p tmp-name1))
          (should (file-regular-p tmp-name1))
+         (should-not (access-file tmp-name1 "error"))
 
          ;; We do not test inodes and device numbers.
          (setq attr (file-attributes tmp-name1))
@@ -620,7 +631,13 @@ This tests also `file-readable-p' and `file-regular-p'."
          (should (file-readable-p tmp-name3))
          (should-not (file-regular-p tmp-name3))
          (setq attr (file-attributes tmp-name3))
-         (should (eq (car attr) t)))
+         (should (eq (car attr) t))
+         (should-not (access-file tmp-name3 "error"))
+
+         ;; Check error case.
+         (should-error
+          (access-file tmp-name4  "error")
+          :type tramp-file-missing))
 
       ;; Cleanup.
       (tramp-archive-cleanup-hash))))
@@ -645,7 +662,7 @@ This tests also `file-readable-p' and `file-regular-p'."
          (dolist (elt attr)
            (should (equal (file-attributes (car elt)) (cdr elt))))
          (setq attr (directory-files-and-attributes tmp-name nil "^b"))
-         (should (equal (mapcar 'car attr) '("bar"))))
+         (should (equal (mapcar #'car attr) '("bar"))))
 
       ;; Cleanup.
       (tramp-archive-cleanup-hash))))
@@ -735,14 +752,14 @@ This tests also `file-executable-p', `file-writable-p' 
and `set-file-modes'."
          (should-not (file-name-completion "a" tmp-name))
          (should
           (equal
-           (file-name-completion "b" tmp-name 'file-directory-p) "bar/"))
+           (file-name-completion "b" tmp-name #'file-directory-p) "bar/"))
          (should
           (equal
-           (sort (file-name-all-completions "fo" tmp-name) 'string-lessp)
+           (sort (file-name-all-completions "fo" tmp-name) #'string-lessp)
            '("foo.hrd" "foo.lnk" "foo.txt")))
          (should
           (equal
-           (sort (file-name-all-completions "b" tmp-name) 'string-lessp)
+           (sort (file-name-all-completions "b" tmp-name) #'string-lessp)
            '("bar/" "baz.tar")))
          (should-not (file-name-all-completions "a" tmp-name))
          ;; `completion-regexp-list' restricts the completion to
@@ -753,14 +770,14 @@ This tests also `file-executable-p', `file-writable-p' 
and `set-file-modes'."
             (equal (file-name-completion "" tmp-name) "ba"))
            (should
             (equal
-             (sort (file-name-all-completions "" tmp-name) 'string-lessp)
+             (sort (file-name-all-completions "" tmp-name) #'string-lessp)
              '("bar/" "baz.tar")))))
 
       ;; Cleanup.
       (tramp-archive-cleanup-hash))))
 
 ;; The functions were introduced in Emacs 26.1.
-(ert-deftest tramp-archive-test38-make-nearby-temp-file ()
+(ert-deftest tramp-archive-test39-make-nearby-temp-file ()
   "Check `make-nearby-temp-file' and `temporary-file-directory'."
   (skip-unless tramp-archive-enabled)
   ;; Since Emacs 26.1.
@@ -797,7 +814,7 @@ This tests also `file-executable-p', `file-writable-p' and 
`set-file-modes'."
     (delete-directory tmp-file)
     (should-not (file-exists-p tmp-file))))
 
-(ert-deftest tramp-archive-test41-file-system-info ()
+(ert-deftest tramp-archive-test42-file-system-info ()
   "Check that `file-system-info' returns proper values."
   (skip-unless tramp-archive-enabled)
   ;; Since Emacs 27.1.
@@ -814,7 +831,7 @@ This tests also `file-executable-p', `file-writable-p' and 
`set-file-modes'."
                 (zerop (nth 1 fsi))
                 (zerop (nth 2 fsi))))))
 
-(ert-deftest tramp-archive-test44-auto-load ()
+(ert-deftest tramp-archive-test45-auto-load ()
   "Check that `tramp-archive' autoloads properly."
   :tags '(:expensive-test)
   (skip-unless tramp-archive-enabled)
@@ -842,10 +859,10 @@ This tests also `file-executable-p', `file-writable-p' 
and `set-file-modes'."
          "%s -batch -Q -L %s --eval %s"
          (shell-quote-argument
           (expand-file-name invocation-name invocation-directory))
-         (mapconcat 'shell-quote-argument load-path " -L ")
+         (mapconcat #'shell-quote-argument load-path " -L ")
          (shell-quote-argument (format code file)))))))))
 
-(ert-deftest tramp-archive-test44-delay-load ()
+(ert-deftest tramp-archive-test45-delay-load ()
   "Check that `tramp-archive' is loaded lazily, only when needed."
   :tags '(:expensive-test)
   (skip-unless tramp-archive-enabled)
@@ -879,7 +896,7 @@ This tests also `file-executable-p', `file-writable-p' and 
`set-file-modes'."
          "%s -batch -Q -L %s --eval %s"
          (shell-quote-argument
           (expand-file-name invocation-name invocation-directory))
-         (mapconcat 'shell-quote-argument load-path " -L ")
+         (mapconcat #'shell-quote-argument load-path " -L ")
          (shell-quote-argument
            (format
             code tae tramp-archive-test-file-archive
@@ -941,7 +958,7 @@ This tests also `file-executable-p', `file-writable-p' and 
`set-file-modes'."
   "Run all tests for \\[tramp-archive]."
   (interactive "p")
   (funcall
-   (if interactive 'ert-run-tests-interactively 'ert-run-tests-batch)
+   (if interactive #'ert-run-tests-interactively #'ert-run-tests-batch)
    "^tramp-archive"))
 
 (provide 'tramp-archive-tests)
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index d68804a..4495a1f 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -1,6 +1,6 @@
 ;;; tramp-tests.el --- Tests of remote file access  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 
@@ -33,7 +33,7 @@
 ;; remote host, set this environment variable to "/dev/null" or
 ;; whatever is appropriate on your system.
 
-;; For slow remote connections, `tramp-test42-asynchronous-requests'
+;; For slow remote connections, `tramp-test43-asynchronous-requests'
 ;; might be too heavy.  Setting $REMOTE_PARALLEL_PROCESSES to a proper
 ;; value less than 10 could help.
 
@@ -57,14 +57,18 @@
 (declare-function tramp-method-out-of-band-p "tramp-sh")
 (declare-function tramp-smb-get-localname "tramp-smb")
 (defvar auto-save-file-name-transforms)
+(defvar tramp-connection-properties)
 (defvar tramp-copy-size-limit)
+(defvar tramp-display-escape-sequence-regexp)
+(defvar tramp-inline-compress-start-size)
 (defvar tramp-persistency-file-name)
+(defvar tramp-remote-path)
 (defvar tramp-remote-process-environment)
 
 ;; Beautify batch mode.
 (when noninteractive
   ;; Suppress nasty messages.
-  (fset 'shell-command-sentinel 'ignore)
+  (fset #'shell-command-sentinel #'ignore)
   ;; We do not want to be interrupted.
   (eval-after-load 'tramp-gvfs
     '(fset 'tramp-gvfs-handler-askquestion
@@ -145,7 +149,7 @@ If LOCAL is non-nil, a local file name is returned.
 If QUOTED is non-nil, the local part of the file name is quoted.
 The temporary file is not created."
   (funcall
-   (if quoted 'tramp-compat-file-name-quote 'identity)
+   (if quoted #'tramp-compat-file-name-quote #'identity)
    (expand-file-name
     (make-temp-name "tramp-test")
     (if local temporary-file-directory tramp-test-temporary-file-directory))))
@@ -157,9 +161,9 @@ This shall used dynamically bound only.")
 
 (defmacro tramp--test-instrument-test-case (verbose &rest body)
   "Run BODY with `tramp-verbose' equal VERBOSE.
-Print the content of the Tramp debug buffer, if BODY does not
-eval properly in `should' or `should-not'.  `should-error' is not
-handled properly.  BODY shall not contain a timeout."
+Print the content of the Tramp connection and debug buffers, if
+`tramp-verbose' is greater than 3.  `should-error' is not handled
+properly.  BODY shall not contain a timeout."
   (declare (indent 1) (debug (natnump body)))
   `(let ((tramp-verbose (max (or ,verbose 0) (or tramp-verbose 0)))
         (tramp-message-show-message t)
@@ -181,7 +185,7 @@ handled properly.  BODY shall not contain a timeout."
   "Emit a message into ERT *Messages*."
   (tramp--test-instrument-test-case 0
     (apply
-     'tramp-message
+     #'tramp-message
      (tramp-dissect-file-name tramp-test-temporary-file-directory) 0
      fmt-string arguments)))
 
@@ -233,6 +237,10 @@ handled properly.  BODY shall not contain a timeout."
   (should (tramp-tramp-file-p "/method:[::1]:"))
   (should (tramp-tramp-file-p "/method:address@hidden::1]:"))
 
+  ;; Using an IPv4 mapped IPv6 address.
+  (should (tramp-tramp-file-p "/method:[::ffff:1.2.3.4]:"))
+  (should (tramp-tramp-file-p "/method:address@hidden::ffff:1.2.3.4]:"))
+
   ;; Local file name part.
   (should (tramp-tramp-file-p "/method:::"))
   (should (tramp-tramp-file-p "/method::/:"))
@@ -260,6 +268,7 @@ handled properly.  BODY shall not contain a timeout."
   (should-not (tramp-tramp-file-p "/1.2.3.4:"))
   (should-not (tramp-tramp-file-p "/[]:"))
   (should-not (tramp-tramp-file-p "/[::1]:"))
+  (should-not (tramp-tramp-file-p "/[::ffff:1.2.3.4]:"))
   (should-not (tramp-tramp-file-p "/host:/:"))
   (should-not (tramp-tramp-file-p "/host1|host2:"))
   (should-not (tramp-tramp-file-p "/address@hidden|address@hidden:"))
@@ -308,6 +317,10 @@ handled properly.  BODY shall not contain a timeout."
          (should (tramp-tramp-file-p "/[::1]:"))
          (should (tramp-tramp-file-p "/address@hidden::1]:"))
 
+         ;; Using an IPv4 mapped IPv6 address.
+         (should (tramp-tramp-file-p "/[::ffff:1.2.3.4]:"))
+         (should (tramp-tramp-file-p "/address@hidden::ffff:1.2.3.4]:"))
+
          ;; Local file name part.
          (should (tramp-tramp-file-p "/host::"))
          (should (tramp-tramp-file-p "/host:/:"))
@@ -358,6 +371,10 @@ handled properly.  BODY shall not contain a timeout."
          (should (tramp-tramp-file-p "/[method/::1]"))
          (should (tramp-tramp-file-p "/[method/user@::1]"))
 
+         ;; Using an IPv4 mapped IPv6 address.
+         (should (tramp-tramp-file-p "/[method/::ffff:1.2.3.4]"))
+         (should (tramp-tramp-file-p "/[method/user@::ffff:1.2.3.4]"))
+
          ;; Local file name part.
          (should (tramp-tramp-file-p "/[method/]"))
          (should (tramp-tramp-file-p "/[method/]/:"))
@@ -401,7 +418,7 @@ handled properly.  BODY shall not contain a timeout."
        tramp-default-user-alist
        tramp-default-host-alist
        ;; Suppress check for multihops.
-       (tramp-cache-data  (make-hash-table :test 'equal))
+       (tramp-cache-data (make-hash-table :test #'equal))
        (tramp-connection-properties '((nil "login-program" t))))
     ;; Expand `tramp-default-user' and `tramp-default-host'.
     (should (string-equal
@@ -840,7 +857,7 @@ handled properly.  BODY shall not contain a timeout."
        tramp-default-user-alist
        tramp-default-host-alist
        ;; Suppress check for multihops.
-       (tramp-cache-data  (make-hash-table :test 'equal))
+       (tramp-cache-data (make-hash-table :test #'equal))
        (tramp-connection-properties '((nil "login-program" t)))
        (syntax tramp-syntax))
     (unwind-protect
@@ -1164,7 +1181,7 @@ handled properly.  BODY shall not contain a timeout."
        tramp-default-user-alist
        tramp-default-host-alist
        ;; Suppress check for multihops.
-       (tramp-cache-data  (make-hash-table :test 'equal))
+       (tramp-cache-data (make-hash-table :test #'equal))
        (tramp-connection-properties '((nil "login-program" t)))
        (syntax tramp-syntax))
     (unwind-protect
@@ -1813,17 +1830,15 @@ handled properly.  BODY shall not contain a timeout."
   (should (string-equal (file-remote-p "/-:ftp.host:" 'method) "ftp"))
   (dolist (u '("ftp" "anonymous"))
     (should (string-equal (file-remote-p (format "/-:%s@:" u) 'method) "ftp")))
-  ;; Default values in tramp-gvfs.el.
-  (when (and (load "tramp-gvfs" 'noerror 'nomessage)
-            (symbol-value 'tramp-gvfs-enabled))
-    (should (string-equal (file-remote-p "/synce::" 'user) nil)))
-  ;; Default values in tramp-sh.el.
+  ;; Default values in tramp-sh.el and tramp-sudoedit.el.
   (dolist (h `("127.0.0.1" "[::1]" "localhost" "localhost6" ,(system-name)))
     (should
      (string-equal (file-remote-p (format "/-:address@hidden:" h) 'method) 
"su")))
-  (dolist (m '("su" "sudo" "ksu"))
-    (should (string-equal (file-remote-p (format "/%s::" m) 'user) "root")))
-  (dolist (m '("rcp" "remcp" "rsh" "telnet" "krlogin" "fcp"))
+  (dolist (m '("su" "sudo" "ksu" "doas" "sudoedit"))
+    (should (string-equal (file-remote-p (format "/%s::" m) 'user) "root"))
+    (should
+     (string-equal (file-remote-p (format "/%s::" m) 'host) (system-name))))
+  (dolist (m '("rcp" "remcp" "rsh" "telnet" "krlogin" "fcp" "nc"))
     (should
      (string-equal (file-remote-p (format "/%s::" m) 'user) 
(user-login-name))))
   ;; Default values in tramp-smb.el.
@@ -1973,6 +1988,18 @@ handled properly.  BODY shall not contain a timeout."
   (should
    (string-equal
     (expand-file-name "/method:host:/path/../file") "/method:host:/file"))
+  (should
+   (string-equal
+    (expand-file-name "/method:host:/path/.") "/method:host:/path"))
+  (should
+   (string-equal
+    (expand-file-name "/method:host:/path/..") "/method:host:/"))
+  (should
+   (string-equal
+    (expand-file-name "." "/method:host:/path/") "/method:host:/path"))
+  (should
+   (string-equal
+    (expand-file-name "" "/method:host:/path/") "/method:host:/path"))
   ;; Quoting local part.
   (should
    (string-equal
@@ -1986,9 +2013,9 @@ handled properly.  BODY shall not contain a timeout."
     (expand-file-name "/method:host:/:/~/path/./file")
     "/method:host:/:/~/path/file")))
 
-;; The following test is inspired by Bug#26911.  It is rather a bug in
-;; `expand-file-name', and it fails for all Emacs versions.  Test
-;; added for later, when it is fixed.
+;; The following test is inspired by Bug#26911 and Bug#34834.  They
+;; are rather bugs in `expand-file-name', and it fails for all Emacs
+;; versions.  Test added for later, when they are fixed.
 (ert-deftest tramp-test05-expand-file-name-relative ()
   "Check `expand-file-name'."
   ;; Mark as failed until bug has been fixed.
@@ -2063,7 +2090,8 @@ This checks also `file-name-as-directory', 
`file-name-directory',
       ;; We must clear `tramp-default-method'.  On hydra, it is "ftp",
       ;; which ruins the tests.
       (let ((non-essential n-e)
-           tramp-default-method)
+           (tramp-default-method
+            (file-remote-p tramp-test-temporary-file-directory 'method)))
        (dolist
            (file
             `(,(format
@@ -2727,7 +2755,14 @@ This tests also `file-directory-p' and 
`file-accessible-directory-p'."
                 (format
                  "\\(.+ %s\\( ->.+\\)?\n\\)\\{%d\\}"
                  (regexp-opt (directory-files tmp-name1))
-                 (length (directory-files tmp-name1))))))))
+                 (length (directory-files tmp-name1)))))))
+
+           ;; Check error case.  We do not check for the error type,
+           ;; because ls-lisp returns `file-error', and native Tramp
+           ;; returns `file-missing'.
+           (delete-directory tmp-name1 'recursive)
+           (with-temp-buffer
+             (should-error (insert-directory tmp-name1 nil))))
 
        ;; Cleanup.
        (ignore-errors (delete-directory tmp-name1 'recursive))))))
@@ -2749,7 +2784,7 @@ This tests also `file-directory-p' and 
`file-accessible-directory-p'."
           (tmp-name4 (expand-file-name "bar" tmp-name2))
           (tramp-test-temporary-file-directory
            (funcall
-            (if quoted 'tramp-compat-file-name-quote 'identity)
+            (if quoted #'tramp-compat-file-name-quote #'identity)
             tramp-test-temporary-file-directory))
           buffer)
       (unwind-protect
@@ -2853,8 +2888,8 @@ This tests also `file-directory-p' and 
`file-accessible-directory-p'."
 
 (ert-deftest tramp-test18-file-attributes ()
   "Check `file-attributes'.
-This tests also `file-readable-p', `file-regular-p' and
-`file-ownership-preserved-p'."
+This tests also `access-file', `file-readable-p',
+`file-regular-p' and `file-ownership-preserved-p'."
   (skip-unless (tramp--test-enabled))
 
   (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
@@ -2875,6 +2910,9 @@ This tests also `file-readable-p', `file-regular-p' and
           attr)
       (unwind-protect
          (progn
+           (should-error
+            (access-file tmp-name1 "error")
+            :type tramp-file-missing)
            ;; `file-ownership-preserved-p' should return t for
            ;; non-existing files.  It is implemented only in tramp-sh.el.
            (when (tramp--test-sh-p)
@@ -2883,6 +2921,7 @@ This tests also `file-readable-p', `file-regular-p' and
            (should (file-exists-p tmp-name1))
            (should (file-readable-p tmp-name1))
            (should (file-regular-p tmp-name1))
+           (should-not (access-file tmp-name1 "error"))
            (when (tramp--test-sh-p)
              (should (file-ownership-preserved-p tmp-name1 'group)))
 
@@ -2907,18 +2946,22 @@ This tests also `file-readable-p', `file-regular-p' and
            (should (stringp (nth 3 attr))) ;; Gid.
 
            (tramp--test-ignore-make-symbolic-link-error
+            (should-error
+             (access-file tmp-name2 "error")
+             :type tramp-file-missing)
              (when (tramp--test-sh-p)
                (should (file-ownership-preserved-p tmp-name2 'group)))
              (make-symbolic-link tmp-name1 tmp-name2)
              (should (file-exists-p tmp-name2))
              (should (file-symlink-p tmp-name2))
+             (should-not (access-file tmp-name2 "error"))
              (when (tramp--test-sh-p)
                (should (file-ownership-preserved-p tmp-name2 'group)))
              (setq attr (file-attributes tmp-name2))
              (should
               (string-equal
                (funcall
-                (if quoted 'tramp-compat-file-name-quote 'identity)
+                (if quoted #'tramp-compat-file-name-quote #'identity)
                 (car attr))
                (file-remote-p (file-truename tmp-name1) 'localname)))
              (delete-file tmp-name2))
@@ -2950,6 +2993,7 @@ This tests also `file-readable-p', `file-regular-p' and
            (should (file-exists-p tmp-name1))
            (should (file-readable-p tmp-name1))
            (should-not (file-regular-p tmp-name1))
+           (should-not (access-file tmp-name1 ""))
            (when (tramp--test-sh-p)
              (should (file-ownership-preserved-p tmp-name1 'group)))
            (setq attr (file-attributes tmp-name1))
@@ -2960,6 +3004,16 @@ This tests also `file-readable-p', `file-regular-p' and
        (ignore-errors (delete-file tmp-name1))
        (ignore-errors (delete-file tmp-name2))))))
 
+(defsubst tramp--test-file-attributes-equal-p (attr1 attr2)
+  "Check, whether file attributes ATTR1 and ATTR2 are equal.
+They might differ only in access time."
+  (setcar (nthcdr 4 attr1) tramp-time-dont-know)
+  (setcar (nthcdr 4 attr2) tramp-time-dont-know)
+  (equal attr1 attr2))
+
+;; This isn't 100% correct, but better than no explainer at all.
+(put #'tramp--test-file-attributes-equal-p 'ert-explainer #'ert--explain-equal)
+
 (ert-deftest tramp-test19-directory-files-and-attributes ()
   "Check `directory-files-and-attributes'."
   (skip-unless (tramp--test-enabled))
@@ -2991,16 +3045,18 @@ This tests also `file-readable-p', `file-regular-p' and
                    5 (file-attributes (expand-file-name (car elt) tmp-name2)))
                   tramp-time-dont-know)
                (should
-                (equal (file-attributes (expand-file-name (car elt) tmp-name2))
-                       (cdr elt)))))
+                (tramp--test-file-attributes-equal-p
+                 (file-attributes (expand-file-name (car elt) tmp-name2))
+                 (cdr elt)))))
            (setq attr (directory-files-and-attributes tmp-name2 'full))
            (dolist (elt attr)
              (unless (tramp-compat-time-equal-p
                       (nth 5 (file-attributes (car elt))) tramp-time-dont-know)
                (should
-                (equal (file-attributes (car elt)) (cdr elt)))))
+                (tramp--test-file-attributes-equal-p
+                 (file-attributes (car elt)) (cdr elt)))))
            (setq attr (directory-files-and-attributes tmp-name2 nil "^b"))
-           (should (equal (mapcar 'car attr) '("bar" "boz"))))
+           (should (equal (mapcar #'car attr) '("bar" "boz"))))
 
        ;; Cleanup.
        (ignore-errors (delete-directory tmp-name1 'recursive))))))
@@ -3009,7 +3065,7 @@ This tests also `file-readable-p', `file-regular-p' and
   "Check `file-modes'.
 This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
   (skip-unless (tramp--test-enabled))
-  (skip-unless (tramp--test-sh-p))
+  (skip-unless (or (tramp--test-sh-p) (tramp--test-sudoedit-p)))
 
   (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
     (let ((tmp-name (tramp--test-make-temp-name nil quoted)))
@@ -3072,7 +3128,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
            (should
             (string-equal
              (funcall
-              (if quoted 'tramp-compat-file-name-unquote 'identity)
+              (if quoted #'tramp-compat-file-name-unquote #'identity)
               (file-remote-p tmp-name1 'localname))
              (file-symlink-p tmp-name2)))
            (when (tramp--test-expensive-test)
@@ -3081,7 +3137,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
               :type 'file-already-exists))
            (when (tramp--test-expensive-test)
              ;; A number means interactive case.
-             (cl-letf (((symbol-function 'yes-or-no-p) 'ignore))
+             (cl-letf (((symbol-function 'yes-or-no-p) #'ignore))
                (should-error
                 (make-symbolic-link tmp-name1 tmp-name2 0)
                 :type 'file-already-exists)))
@@ -3090,14 +3146,14 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
              (should
               (string-equal
                (funcall
-                (if quoted 'tramp-compat-file-name-unquote 'identity)
+                (if quoted #'tramp-compat-file-name-unquote #'identity)
                 (file-remote-p tmp-name1 'localname))
                (file-symlink-p tmp-name2))))
            (make-symbolic-link tmp-name1 tmp-name2 'ok-if-already-exists)
            (should
             (string-equal
              (funcall
-              (if quoted 'tramp-compat-file-name-unquote 'identity)
+              (if quoted #'tramp-compat-file-name-unquote #'identity)
               (file-remote-p tmp-name1 'localname))
              (file-symlink-p tmp-name2)))
            ;; If we use the local part of `tmp-name1', it shall still work.
@@ -3107,7 +3163,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
            (should
             (string-equal
              (funcall
-              (if quoted 'tramp-compat-file-name-unquote 'identity)
+              (if quoted #'tramp-compat-file-name-unquote #'identity)
               (file-remote-p tmp-name1 'localname))
              (file-symlink-p tmp-name2)))
            ;; `tmp-name3' is a local file name.  Therefore, the link
@@ -3127,7 +3183,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
            (should
             (string-equal
              (funcall
-              (if quoted 'tramp-compat-file-name-unquote 'identity)
+              (if quoted #'tramp-compat-file-name-unquote #'identity)
               (file-remote-p tmp-name1 'localname))
              (file-symlink-p tmp-name5)))
            ;; `smbclient' does not show symlinks in directories, so
@@ -3154,7 +3210,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
              (add-name-to-file tmp-name1 tmp-name2)
              :type 'file-already-exists)
             ;; A number means interactive case.
-            (cl-letf (((symbol-function 'yes-or-no-p) 'ignore))
+            (cl-letf (((symbol-function 'yes-or-no-p) #'ignore))
               (should-error
                (add-name-to-file tmp-name1 tmp-name2 0)
                :type 'file-already-exists))
@@ -3211,7 +3267,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
            (delete-file tmp-name2)
            (make-symbolic-link
             (funcall
-             (if quoted 'tramp-compat-file-name-unquote 'identity)
+             (if quoted #'tramp-compat-file-name-unquote #'identity)
              "/penguin:motd:")
             tmp-name2)
            (should (file-symlink-p tmp-name2))
@@ -3300,7 +3356,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
       (let* ((dir1
              (directory-file-name
               (funcall
-               (if quoted 'tramp-compat-file-name-quote 'identity)
+               (if quoted #'tramp-compat-file-name-quote #'identity)
                tramp-test-temporary-file-directory)))
             (dir2 (file-name-as-directory dir1)))
        (should (string-equal (file-truename dir1) (expand-file-name dir1)))
@@ -3309,7 +3365,8 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
 (ert-deftest tramp-test22-file-times ()
   "Check `set-file-times' and `file-newer-than-file-p'."
   (skip-unless (tramp--test-enabled))
-  (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p)))
+  (skip-unless
+   (or (tramp--test-adb-p) (tramp--test-sh-p) (tramp--test-sudoedit-p)))
 
   (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
     (let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
@@ -3679,12 +3736,12 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
              (should-not (file-name-completion "a" tmp-name))
              (should
               (equal
-               (file-name-completion "b" tmp-name 'file-directory-p) "boz/"))
+               (file-name-completion "b" tmp-name #'file-directory-p) "boz/"))
              (should
               (equal (file-name-all-completions "fo" tmp-name) '("foo")))
              (should
               (equal
-               (sort (file-name-all-completions "b" tmp-name) 'string-lessp)
+               (sort (file-name-all-completions "b" tmp-name) #'string-lessp)
                '("bold" "boz/")))
              (should-not (file-name-all-completions "a" tmp-name))
              ;; `completion-regexp-list' restricts the completion to
@@ -3695,7 +3752,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
                 (equal (file-name-completion "" tmp-name) "bo"))
                (should
                 (equal
-                 (sort (file-name-all-completions "" tmp-name) 'string-lessp)
+                 (sort (file-name-all-completions "" tmp-name) #'string-lessp)
                  '("bold" "boz/"))))
              ;; `file-name-completion' ignores file names that end in
              ;; any string in `completion-ignored-extensions'.
@@ -3710,7 +3767,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
                ;; `file-name-all-completions' is not affected.
                (should
                 (equal
-                 (sort (file-name-all-completions "" tmp-name) 'string-lessp)
+                 (sort (file-name-all-completions "" tmp-name) #'string-lessp)
                  '("../" "./" "bold" "boz/" "foo" "foo.ext")))))
 
          ;; Cleanup.
@@ -3785,16 +3842,24 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
        ;; Cleanup.
        (ignore-errors (delete-file tmp-name))))))
 
+;; Must be a command, because used as `sigusr' handler.
+(defun tramp--test-timeout-handler (&rest _ignore)
+  "Timeout handler, reporting a failed test."
+  (interactive)
+  (ert-fail (format "`%s' timed out" (ert-test-name (ert-running-test)))))
+
 (ert-deftest tramp-test29-start-file-process ()
   "Check `start-file-process'."
   :tags '(:expensive-test)
   (skip-unless (tramp--test-enabled))
-  (skip-unless (tramp--test-sh-p))
+  (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p)))
 
   (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
     (let ((default-directory tramp-test-temporary-file-directory)
          (tmp-name (tramp--test-make-temp-name nil quoted))
          kill-buffer-query-functions proc)
+
+      ;; Simple process.
       (unwind-protect
          (with-temp-buffer
            (setq proc (start-file-process "test1" (current-buffer) "cat"))
@@ -3803,14 +3868,17 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
            (process-send-string proc "foo")
            (process-send-eof proc)
            ;; Read output.
-           (with-timeout (10 (ert-fail "`start-file-process' timed out"))
+           (with-timeout (10 (tramp--test-timeout-handler))
              (while (< (- (point-max) (point-min)) (length "foo"))
-               (accept-process-output proc 0.1)))
-           (should (string-equal (buffer-string) "foo")))
+               (while (accept-process-output proc 0 nil t))))
+           ;; We cannot use `string-equal', because tramp-adb.el
+           ;; echoes also the sent string.
+           (should (string-match "\\`foo" (buffer-string))))
 
        ;; Cleanup.
        (ignore-errors (delete-process proc)))
 
+      ;; Simple process using a file.
       (unwind-protect
          (with-temp-buffer
            (write-region "foo" nil tmp-name)
@@ -3821,9 +3889,9 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
                   "cat" (file-name-nondirectory tmp-name)))
            (should (processp proc))
            ;; Read output.
-           (with-timeout (10 (ert-fail "`start-file-process' timed out"))
+           (with-timeout (10 (tramp--test-timeout-handler))
              (while (< (- (point-max) (point-min)) (length "foo"))
-               (accept-process-output proc 0.1)))
+               (while (accept-process-output proc 0 nil t))))
            (should (string-equal (buffer-string) "foo")))
 
        ;; Cleanup.
@@ -3831,6 +3899,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
          (delete-process proc)
          (delete-file tmp-name)))
 
+      ;; Process filter.
       (unwind-protect
          (with-temp-buffer
            (setq proc (start-file-process "test3" (current-buffer) "cat"))
@@ -3842,15 +3911,151 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
            (process-send-string proc "foo")
            (process-send-eof proc)
            ;; Read output.
-           (with-timeout (10 (ert-fail "`start-file-process' timed out"))
+           (with-timeout (10 (tramp--test-timeout-handler))
              (while (< (- (point-max) (point-min)) (length "foo"))
-               (accept-process-output proc 0.1)))
-           (should (string-equal (buffer-string) "foo")))
+               (while (accept-process-output proc 0 nil t))))
+           ;; We cannot use `string-equal', because tramp-adb.el
+           ;; echoes also the sent string.
+           (should (string-match "\\`foo" (buffer-string))))
 
        ;; Cleanup.
        (ignore-errors (delete-process proc))))))
 
-(ert-deftest tramp-test30-interrupt-process ()
+(ert-deftest tramp-test30-make-process ()
+  "Check `make-process'."
+  :tags '(:expensive-test)
+  (skip-unless (tramp--test-enabled))
+  (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p)))
+  ;; `make-process' supports file name handlers since Emacs 27.
+  (skip-unless (tramp--test-emacs27-p))
+
+  (tramp--test-instrument-test-case 0
+  (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
+    (let ((default-directory tramp-test-temporary-file-directory)
+         (tmp-name (tramp--test-make-temp-name nil quoted))
+         kill-buffer-query-functions proc)
+      (should-not (make-process))
+
+      ;; Simple process.
+      (unwind-protect
+         (with-temp-buffer
+           (setq proc
+                 (make-process
+                  :name "test1" :buffer (current-buffer) :command '("cat")
+                  :file-handler t))
+           (should (processp proc))
+           (should (equal (process-status proc) 'run))
+           (process-send-string proc "foo")
+           (process-send-eof proc)
+           ;; Read output.
+           (with-timeout (10 (tramp--test-timeout-handler))
+             (while (< (- (point-max) (point-min)) (length "foo"))
+               (while (accept-process-output proc 0 nil t))))
+           ;; We cannot use `string-equal', because tramp-adb.el
+           ;; echoes also the sent string.
+           (should (string-match "\\`foo" (buffer-string))))
+
+       ;; Cleanup.
+       (ignore-errors (delete-process proc)))
+
+      ;; Simple process using a file.
+      (unwind-protect
+         (with-temp-buffer
+           (write-region "foo" nil tmp-name)
+           (should (file-exists-p tmp-name))
+           (setq proc
+                 (make-process
+                  :name "test2" :buffer (current-buffer)
+                  :command `("cat" ,(file-name-nondirectory tmp-name))
+                  :file-handler t))
+           (should (processp proc))
+           ;; Read output.
+           (with-timeout (10 (tramp--test-timeout-handler))
+             (while (< (- (point-max) (point-min)) (length "foo"))
+               (while (accept-process-output proc 0 nil t))))
+           (should (string-equal (buffer-string) "foo")))
+
+       ;; Cleanup.
+       (ignore-errors
+         (delete-process proc)
+         (delete-file tmp-name)))
+
+      ;; Process filter.
+      (unwind-protect
+         (with-temp-buffer
+           (setq proc
+                 (make-process
+                  :name "test3" :buffer (current-buffer) :command '("cat")
+                  :filter
+                  (lambda (p s)
+                    (with-current-buffer (process-buffer p) (insert s)))
+                  :file-handler t))
+           (should (processp proc))
+           (should (equal (process-status proc) 'run))
+           (process-send-string proc "foo")
+           (process-send-eof proc)
+           ;; Read output.
+           (with-timeout (10 (tramp--test-timeout-handler))
+             (while (not (string-match "foo" (buffer-string)))
+               (while (accept-process-output proc 0 nil t))))
+           ;; We cannot use `string-equal', because tramp-adb.el
+           ;; echoes also the sent string.
+           (should (string-match "\\`foo" (buffer-string))))
+
+       ;; Cleanup.
+       (ignore-errors (delete-process proc)))
+
+      ;; Process sentinel.
+      (unwind-protect
+         (with-temp-buffer
+           (setq proc
+                 (make-process
+                  :name "test4" :buffer (current-buffer) :command '("cat")
+                  :sentinel
+                  (lambda (p s)
+                    (with-current-buffer (process-buffer p) (insert s)))
+                  :file-handler t))
+           (should (processp proc))
+           (should (equal (process-status proc) 'run))
+           (process-send-string proc "foo")
+           (process-send-eof proc)
+           (delete-process proc)
+           ;; Read output.
+           (with-timeout (10 (tramp--test-timeout-handler))
+             (while (accept-process-output proc 0 nil t)))
+           ;; We cannot use `string-equal', because tramp-adb.el
+           ;; echoes also the sent string.
+           (should (string-match "killed\n\\'" (buffer-string))))
+
+       ;; Cleanup.
+       (ignore-errors (delete-process proc)))
+
+      ;; Process with stderr.  tramp-adb.el doesn't support it (yet).
+      (unless (tramp--test-adb-p)
+       (let ((stderr
+              (generate-new-buffer (generate-new-buffer-name "stderr"))))
+         (unwind-protect
+             (with-temp-buffer
+               (setq proc
+                     (make-process
+                      :name "test5" :buffer (current-buffer)
+                      :command '("cat" "/")
+                      :stderr stderr
+                      :file-handler t))
+               (should (processp proc))
+               ;; Read stderr.
+               (with-current-buffer stderr
+                 (with-timeout (10 (tramp--test-timeout-handler))
+                   (while (= (point-min) (point-max))
+                     (while (accept-process-output proc 0 nil t))))
+                 (should
+                  (string-match "^cat:.* Is a directory" (buffer-string)))))
+
+           ;; Cleanup.
+           (ignore-errors (delete-process proc))
+           (ignore-errors (kill-buffer stderr)))))))))
+
+(ert-deftest tramp-test31-interrupt-process ()
   "Check `interrupt-process'."
   :tags '(:expensive-test)
   (skip-unless (tramp--test-enabled))
@@ -3869,7 +4074,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
          (should (numberp (process-get proc 'remote-pid)))
          (should (interrupt-process proc))
          ;; Let the process accept the interrupt.
-          (accept-process-output proc 1 nil 0)
+         (while (accept-process-output proc nil nil 0))
          (should-not (process-live-p proc))
          ;; An interrupted process cannot be interrupted, again.
          (should-error (interrupt-process proc) :type 'error))
@@ -3877,11 +4082,24 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
       ;; Cleanup.
       (ignore-errors (delete-process proc)))))
 
-(ert-deftest tramp-test31-shell-command ()
+(defun tramp--test-shell-command-to-string-asynchronously (command)
+  "Like `shell-command-to-string', but for asynchronous processes."
+  (with-temp-buffer
+    (async-shell-command command (current-buffer))
+    (with-timeout
+        ((if (getenv "EMACS_EMBA_CI") 30 10) (tramp--test-timeout-handler))
+      (while (accept-process-output
+             (get-buffer-process (current-buffer)) nil nil t)))
+    (buffer-substring-no-properties (point-min) (point-max))))
+
+(ert-deftest tramp-test32-shell-command ()
   "Check `shell-command'."
   :tags '(:expensive-test)
   (skip-unless (tramp--test-enabled))
-  (skip-unless (tramp--test-sh-p))
+  ;; Prior Emacs 27, `shell-file-name' was hard coded as "/bin/sh" for
+  ;; remote processes in Emacs.  That doesn't work for tramp-adb.el.
+  (skip-unless (or (and (tramp--test-adb-p) (tramp--test-emacs27-p))
+                  (tramp--test-sh-p)))
 
   (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
     (let ((tmp-name (tramp--test-make-temp-name nil quoted))
@@ -3889,6 +4107,8 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
          ;; Suppress nasty messages.
          (inhibit-message t)
          kill-buffer-query-functions)
+
+      ;; Test ordinary `shell-command'.
       (unwind-protect
          (with-temp-buffer
            (write-region "foo" nil tmp-name)
@@ -3909,6 +4129,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
        ;; Cleanup.
        (ignore-errors (delete-file tmp-name)))
 
+      ;; Test ordinary `async-shell-command'.
       (unwind-protect
          (with-temp-buffer
            (write-region "foo" nil tmp-name)
@@ -3917,11 +4138,9 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
             (format "ls %s" (file-name-nondirectory tmp-name))
             (current-buffer))
            ;; Read output.
-           (with-timeout (10 (ert-fail "`async-shell-command' timed out"))
-             (while (< (- (point-max) (point-min))
-                       (1+ (length (file-name-nondirectory tmp-name))))
-               (accept-process-output
-                (get-buffer-process (current-buffer)) 0.1)))
+           (with-timeout (10 (tramp--test-timeout-handler))
+             (while (accept-process-output
+                     (get-buffer-process (current-buffer)) nil nil t)))
            ;; `ls' could produce colorized output.
            (goto-char (point-min))
            (while
@@ -3939,6 +4158,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
        ;; Cleanup.
        (ignore-errors (delete-file tmp-name)))
 
+      ;; Test sending string to `async-shell-command'.
       (unwind-protect
          (with-temp-buffer
            (write-region "foo" nil tmp-name)
@@ -3948,11 +4168,9 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
             (get-buffer-process (current-buffer))
             (format "%s\n" (file-name-nondirectory tmp-name)))
            ;; Read output.
-           (with-timeout (10 (ert-fail "`async-shell-command' timed out"))
-             (while (< (- (point-max) (point-min))
-                       (1+ (length (file-name-nondirectory tmp-name))))
-               (accept-process-output
-                (get-buffer-process (current-buffer)) 0.1)))
+           (with-timeout (10 (tramp--test-timeout-handler))
+             (while (accept-process-output
+                     (get-buffer-process (current-buffer)) nil nil t)))
            ;; `ls' could produce colorized output.
            (goto-char (point-min))
            (while
@@ -3968,20 +4186,28 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
              (buffer-string))))
 
        ;; Cleanup.
-       (ignore-errors (delete-file tmp-name))))))
+       (ignore-errors (delete-file tmp-name)))
 
-(defun tramp--test-shell-command-to-string-asynchronously (command)
-  "Like `shell-command-to-string', but for asynchronous processes."
-  (with-temp-buffer
-    (async-shell-command command (current-buffer))
-    (with-timeout (10)
-      (while (get-buffer-process (current-buffer))
-       (accept-process-output (get-buffer-process (current-buffer)) 0.1)))
-    (accept-process-output nil 0.1)
-    (buffer-substring-no-properties (point-min) (point-max))))
+      ;; Test `shell-command-width' of `async-shell-command'.
+      ;; Since Emacs 27.1.
+      (when (and (boundp 'shell-command-width)
+                (zerop (call-process "tput" nil nil nil "cols"))
+                 (zerop (process-file "tput" nil nil nil "cols")))
+       (let (shell-command-width)
+         (should
+          (string-equal
+           (format "%s\n" (car (process-lines "tput" "cols")))
+           (tramp--test-shell-command-to-string-asynchronously
+            "tput cols")))
+         (setq shell-command-width 1024)
+         (should
+          (string-equal
+           "1024\n"
+           (tramp--test-shell-command-to-string-asynchronously
+            "tput cols"))))))))
 
 ;; This test is inspired by Bug#23952.
-(ert-deftest tramp-test32-environment-variables ()
+(ert-deftest tramp-test33-environment-variables ()
   "Check that remote processes set / unset environment variables properly."
   :tags '(:expensive-test)
   (skip-unless (tramp--test-enabled))
@@ -4056,10 +4282,10 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
              (should-not
               (string-match
                (regexp-quote envvar)
-               (funcall this-shell-command-to-string "set")))))))))
+               (funcall this-shell-command-to-string "env")))))))))
 
 ;; This test is inspired by Bug#27009.
-(ert-deftest tramp-test32-environment-variables-and-port-numbers ()
+(ert-deftest tramp-test33-environment-variables-and-port-numbers ()
   "Check that two connections with separate ports are different."
   (skip-unless (tramp--test-enabled))
   ;; We test it only for the mock-up connection; otherwise there might
@@ -4094,12 +4320,81 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
     (dolist (dir '("/mock:localhost#11111:" "/mock:localhost#22222:"))
       (tramp-cleanup-connection (tramp-dissect-file-name dir)))))
 
+;; Connection-local variables are enabled per default since Emacs 27.1.
+(ert-deftest tramp-test34-connection-local-variables ()
+  "Check that connection-local variables are enabled."
+  :tags '(:expensive-test)
+  (skip-unless (tramp--test-enabled))
+  ;; Since Emacs 27.1.
+  (skip-unless (fboundp 'with-connection-local-variables))
+
+  ;; `connection-local-set-profile-variables' and
+  ;; `connection-local-set-profiles' exist since Emacs 26.1.  We don't
+  ;; want to see compiler warnings for older Emacsen.
+  (let* ((default-directory tramp-test-temporary-file-directory)
+        (tmp-name1 (tramp--test-make-temp-name))
+        (tmp-name2 (expand-file-name "foo" tmp-name1))
+        (enable-local-variables :all)
+        (enable-remote-dir-locals t)
+        kill-buffer-query-functions
+        connection-local-profile-alist connection-local-criteria-alist)
+    (unwind-protect
+       (progn
+         (make-directory tmp-name1)
+          (should (file-directory-p tmp-name1))
+
+         ;; `local-variable' is buffer-local due to explicit setting.
+         (with-no-warnings
+           (defvar-local local-variable 'buffer))
+         (with-temp-buffer
+           (should (eq local-variable 'buffer)))
+
+         ;; `local-variable' is connection-local due to Tramp.
+         (write-region "foo" nil tmp-name2)
+         (should (file-exists-p tmp-name2))
+         (with-no-warnings
+           (connection-local-set-profile-variables
+            'local-variable-profile
+            '((local-variable . connect)))
+           (connection-local-set-profiles
+            `(:application tramp
+              :protocol ,(file-remote-p default-directory 'method)
+              :user ,(file-remote-p default-directory 'user)
+              :machine ,(file-remote-p default-directory 'host))
+            'local-variable-profile))
+         (with-current-buffer (find-file-noselect tmp-name2)
+           (should (eq local-variable 'connect))
+           (kill-buffer (current-buffer)))
+
+         ;; `local-variable' is dir-local due to existence of .dir-locals.el.
+         (write-region
+          "((nil . ((local-variable . dir))))" nil
+          (expand-file-name ".dir-locals.el" tmp-name1))
+         (should (file-exists-p (expand-file-name ".dir-locals.el" tmp-name1)))
+         (with-current-buffer (find-file-noselect tmp-name2)
+           (should (eq local-variable 'dir))
+           (kill-buffer (current-buffer)))
+
+         ;; `local-variable' is file-local due to specifying as file variable.
+         (write-region
+          "-*- mode: comint; local-variable: file; -*-" nil tmp-name2)
+          (should (file-exists-p tmp-name2))
+         (with-current-buffer (find-file-noselect tmp-name2)
+           (should (eq local-variable 'file))
+           (kill-buffer (current-buffer))))
+
+      ;; Cleanup.
+      (ignore-errors (delete-directory tmp-name1 'recursive)))))
+
 ;; The functions were introduced in Emacs 26.1.
-(ert-deftest tramp-test33-explicit-shell-file-name ()
+(ert-deftest tramp-test34-explicit-shell-file-name ()
   "Check that connection-local `explicit-shell-file-name' is set."
   :tags '(:expensive-test)
   (skip-unless (tramp--test-enabled))
-  (skip-unless (tramp--test-sh-p))
+  ;; Prior Emacs 27, `shell-file-name' was hard coded as "/bin/sh" for
+  ;; remote processes in Emacs.  That doesn't work for tramp-adb.el.
+  (skip-unless (or (and (tramp--test-adb-p) (tramp--test-emacs27-p))
+                  (tramp--test-sh-p)))
   ;; Since Emacs 26.1.
   (skip-unless (and (fboundp 'connection-local-set-profile-variables)
                    (fboundp 'connection-local-set-profiles)))
@@ -4108,41 +4403,51 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
   ;; `connection-local-set-profiles' exist since Emacs 26.1.  We don't
   ;; want to see compiler warnings for older Emacsen.
   (let ((default-directory tramp-test-temporary-file-directory)
-       explicit-shell-file-name kill-buffer-query-functions)
+       explicit-shell-file-name kill-buffer-query-functions
+       connection-local-profile-alist connection-local-criteria-alist)
     (unwind-protect
        (progn
          ;; `shell-mode' would ruin our test, because it deletes all
-         ;; buffer local variables.
+         ;; buffer local variables.  Not needed in Emacs 27.1.
          (put 'explicit-shell-file-name 'permanent-local t)
-         ;; Declare connection-local variable `explicit-shell-file-name'.
+         ;; Declare connection-local variables `explicit-shell-file-name'
+         ;; and `explicit-sh-args'.
          (with-no-warnings
            (connection-local-set-profile-variables
             'remote-sh
-            '((explicit-shell-file-name . "/bin/sh")
-              (explicit-sh-args . ("-i"))))
+            `((explicit-shell-file-name
+               . ,(if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh"))
+              (explicit-sh-args . ("-c" "echo foo"))))
            (connection-local-set-profiles
             `(:application tramp
               :protocol ,(file-remote-p default-directory 'method)
               :user ,(file-remote-p default-directory 'user)
               :machine ,(file-remote-p default-directory 'host))
             'remote-sh))
+         (put 'explicit-shell-file-name 'safe-local-variable #'identity)
+         (put 'explicit-sh-args 'safe-local-variable #'identity)
 
-         ;; Run interactive shell.  Since the default directory is
-         ;; remote, `explicit-shell-file-name' shall be set in order
-         ;; to avoid a question.
+         ;; Run `shell' interactively.  Since the default directory
+         ;; is remote, `explicit-shell-file-name' shall be set in
+         ;; order to avoid a question.  `explicit-sh-args' echoes the
+         ;; test data.
          (with-current-buffer (get-buffer-create "*shell*")
            (ignore-errors (kill-process (current-buffer)))
            (should-not explicit-shell-file-name)
-           (call-interactively 'shell)
-           (should explicit-shell-file-name)))
+           (call-interactively #'shell)
+           (with-timeout (10)
+             (while (accept-process-output
+                     (get-buffer-process (current-buffer)) nil nil t)))
+           (should (string-match "^foo$" (buffer-string)))))
 
+      ;; Cleanup.
       (put 'explicit-shell-file-name 'permanent-local nil)
       (kill-buffer "*shell*"))))
 
 ;; `exec-path' was introduced in Emacs 27.1.  `executable-find' has
 ;; changed the number of parameters, so we use `apply' for older
 ;; Emacsen.
-(ert-deftest tramp-test34-exec-path ()
+(ert-deftest tramp-test35-exec-path ()
   "Check `exec-path' and `executable-find'."
   (skip-unless (tramp--test-enabled))
   (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p)))
@@ -4160,7 +4465,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
            (car (last (with-no-warnings (exec-path))))
            (file-remote-p default-directory 'localname)))
          ;; The shell "sh" shall always exist.
-         (should (apply 'executable-find '("sh" remote)))
+         (should (apply #'executable-find '("sh" remote)))
          ;; Since the last element in `exec-path' is the current
          ;; directory, an executable file in that directory will be
          ;; found.
@@ -4171,17 +4476,83 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
          (should
           (string-equal
            (apply
-            'executable-find `(,(file-name-nondirectory tmp-name) remote))
+            #'executable-find `(,(file-name-nondirectory tmp-name) remote))
            (file-remote-p tmp-name 'localname)))
          (should-not
           (apply
-           'executable-find
+           #'executable-find
            `(,(concat (file-name-nondirectory tmp-name) "foo") remote))))
 
       ;; Cleanup.
       (ignore-errors (delete-file tmp-name)))))
 
-(ert-deftest tramp-test35-vc-registered ()
+;; This test is inspired by Bug#33781.
+;; `exec-path' was introduced in Emacs 27.1.  `executable-find' has
+;; changed the number of parameters, so we use `apply' for older
+;; Emacsen.
+(ert-deftest tramp-test35-remote-path ()
+  "Check loooong `tramp-remote-path'."
+  (skip-unless (tramp--test-enabled))
+  (skip-unless (tramp--test-sh-p))
+  ;; Since Emacs 27.1.
+  (skip-unless (fboundp 'exec-path))
+
+  (let* ((tmp-name (tramp--test-make-temp-name))
+        (default-directory tramp-test-temporary-file-directory)
+         (orig-exec-path (with-no-warnings (exec-path)))
+         (tramp-remote-path tramp-remote-path)
+        (orig-tramp-remote-path tramp-remote-path))
+    (unwind-protect
+       (progn
+          ;; Non existing directories are removed.
+          (setq tramp-remote-path
+                (cons (file-remote-p tmp-name 'localname) tramp-remote-path))
+          (tramp-cleanup-connection
+           (tramp-dissect-file-name tramp-test-temporary-file-directory)
+           'keep-debug 'keep-password)
+          (should (equal (with-no-warnings (exec-path)) orig-exec-path))
+          (setq tramp-remote-path orig-tramp-remote-path)
+
+          ;; Double entries are removed.
+          (setq tramp-remote-path (append '("/" "/") tramp-remote-path))
+          (tramp-cleanup-connection
+           (tramp-dissect-file-name tramp-test-temporary-file-directory)
+           'keep-debug 'keep-password)
+          (should
+          (equal (with-no-warnings (exec-path)) (cons "/" orig-exec-path)))
+          (setq tramp-remote-path orig-tramp-remote-path)
+
+          ;; We make a super long `tramp-remote-path'.
+          (make-directory tmp-name)
+          (should (file-directory-p tmp-name))
+          (while (< (length (mapconcat #'identity orig-exec-path ":")) 5000)
+            (let ((dir (make-temp-file (file-name-as-directory tmp-name) 
'dir)))
+              (should (file-directory-p dir))
+              (setq tramp-remote-path
+                    (cons (file-remote-p dir 'localname) tramp-remote-path)
+                    orig-exec-path
+                    (cons (file-remote-p dir 'localname) orig-exec-path))))
+          (tramp-cleanup-connection
+           (tramp-dissect-file-name tramp-test-temporary-file-directory)
+           'keep-debug 'keep-password)
+          (should (equal (with-no-warnings (exec-path)) orig-exec-path))
+          (should
+          (string-equal
+           ;; Ignore trailing newline.
+           (substring (shell-command-to-string "echo $PATH") nil -1)
+           ;; The last element of `exec-path' is `exec-directory'.
+           (mapconcat #'identity (butlast orig-exec-path) ":")))
+         ;; The shell "sh" shall always exist.
+         (should (apply #'executable-find '("sh" remote))))
+
+      ;; Cleanup.
+      (tramp-cleanup-connection
+       (tramp-dissect-file-name tramp-test-temporary-file-directory)
+       'keep-debug 'keep-password)
+      (setq tramp-remote-path orig-tramp-remote-path)
+      (ignore-errors (delete-directory tmp-name 'recursive)))))
+
+(ert-deftest tramp-test36-vc-registered ()
   "Check `vc-registered'."
   :tags '(:expensive-test)
   (skip-unless (tramp--test-enabled))
@@ -4233,7 +4604,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
              ;; skip the test then.
              (condition-case nil
                  (vc-create-repo (car vc-handled-backends))
-               (error (skip-unless nil)))
+               (error (ert-skip "`vc-create-repo' not supported")))
              ;; The structure of VC-FILESET is not documented.  Let's
              ;; hope it won't change.
              (condition-case nil
@@ -4251,7 +4622,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
        ;; Cleanup.
        (ignore-errors (delete-directory tmp-name1 'recursive))))))
 
-(ert-deftest tramp-test36-make-auto-save-file-name ()
+(ert-deftest tramp-test37-make-auto-save-file-name ()
   "Check `make-auto-save-file-name'."
   (skip-unless (tramp--test-enabled))
 
@@ -4288,7 +4659,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
                 (string-equal
                  (make-auto-save-file-name)
                  (funcall
-                  (if quoted 'tramp-compat-file-name-quote 'identity)
+                  (if quoted #'tramp-compat-file-name-quote #'identity)
                   (expand-file-name
                    (format "#%s#" (file-name-nondirectory tmp-name1))
                    tramp-test-temporary-file-directory))))))
@@ -4342,7 +4713,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
        (ignore-errors (delete-file tmp-name1))
        (ignore-errors (delete-directory tmp-name2 'recursive))))))
 
-(ert-deftest tramp-test37-find-backup-file-name ()
+(ert-deftest tramp-test38-find-backup-file-name ()
   "Check `find-backup-file-name'."
   (skip-unless (tramp--test-enabled))
 
@@ -4362,7 +4733,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
              (find-backup-file-name tmp-name1)
              (list
               (funcall
-               (if quoted 'tramp-compat-file-name-quote 'identity)
+               (if quoted #'tramp-compat-file-name-quote #'identity)
                (expand-file-name
                 (format "%s~" (file-name-nondirectory tmp-name1))
                 tramp-test-temporary-file-directory)))))))
@@ -4376,7 +4747,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
              (find-backup-file-name tmp-name1)
              (list
               (funcall
-               (if quoted 'tramp-compat-file-name-quote 'identity)
+               (if quoted #'tramp-compat-file-name-quote #'identity)
                (expand-file-name
                 (format
                  "%s~"
@@ -4404,7 +4775,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
              (find-backup-file-name tmp-name1)
              (list
               (funcall
-               (if quoted 'tramp-compat-file-name-quote 'identity)
+               (if quoted #'tramp-compat-file-name-quote #'identity)
                (expand-file-name
                 (format
                  "%s~"
@@ -4433,7 +4804,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
              (find-backup-file-name tmp-name1)
              (list
               (funcall
-               (if quoted 'tramp-compat-file-name-quote 'identity)
+               (if quoted #'tramp-compat-file-name-quote #'identity)
                (expand-file-name
                 (format
                  "%s~"
@@ -4453,7 +4824,7 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
        (ignore-errors (delete-directory tmp-name2 'recursive))))))
 
 ;; The functions were introduced in Emacs 26.1.
-(ert-deftest tramp-test38-make-nearby-temp-file ()
+(ert-deftest tramp-test39-make-nearby-temp-file ()
   "Check `make-nearby-temp-file' and `temporary-file-directory'."
   (skip-unless (tramp--test-enabled))
   ;; Since Emacs 26.1.
@@ -4567,6 +4938,10 @@ This does not support special file names."
    (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
    'tramp-sh-file-name-handler))
 
+(defun tramp--test-sudoedit-p ()
+  "Check, whether the sudoedit method is used."
+  (tramp-sudoedit-file-name-p tramp-test-temporary-file-directory))
+
 (defun tramp--test-windows-nt ()
   "Check, whether the locale host runs MS Windows."
   (eq system-type 'windows-nt))
@@ -4638,7 +5013,7 @@ This requires restrictions of file name syntax."
                  (should
                   (string-equal
                    (funcall
-                    (if quoted 'tramp-compat-file-name-quote 'identity)
+                    (if quoted #'tramp-compat-file-name-quote #'identity)
                     (car (file-attributes file3)))
                    (file-remote-p (file-truename file1) 'localname)))
                  ;; Check file contents.
@@ -4650,10 +5025,10 @@ This requires restrictions of file name syntax."
            ;; Check file names.
            (should (equal (directory-files
                            tmp-name1 nil directory-files-no-dot-files-regexp)
-                          (sort (copy-sequence files) 'string-lessp)))
+                          (sort (copy-sequence files) #'string-lessp)))
            (should (equal (directory-files
                            tmp-name2 nil directory-files-no-dot-files-regexp)
-                          (sort (copy-sequence files) 'string-lessp)))
+                          (sort (copy-sequence files) #'string-lessp)))
 
            ;; `substitute-in-file-name' could return different
            ;; values.  For `adb', there could be strange file
@@ -4713,7 +5088,7 @@ This requires restrictions of file name syntax."
                    (should
                     (string-equal
                      (funcall
-                      (if quoted 'tramp-compat-file-name-quote 'identity)
+                      (if quoted #'tramp-compat-file-name-quote #'identity)
                       (cadr (car (directory-files-and-attributes
                                   file1 nil (regexp-quote elt1)))))
                      (file-remote-p (file-truename file2) 'localname)))
@@ -4751,7 +5126,7 @@ This requires restrictions of file name syntax."
        (ignore-errors (delete-directory tmp-name2 'recursive))))))
 
 (defun tramp--test-special-characters ()
-  "Perform the test in `tramp-test39-special-characters*'."
+  "Perform the test in `tramp-test40-special-characters*'."
   ;; Newlines, slashes and backslashes in file names are not
   ;; supported.  So we don't test.  And we don't test the tab
   ;; character on Windows or Cygwin, because the backslash is
@@ -4761,6 +5136,7 @@ This requires restrictions of file name syntax."
         (list
          (if (or (tramp--test-gvfs-p)
                  (tramp--test-rclone-p)
+                 (tramp--test-sudoedit-p)
                  (tramp--test-windows-nt-or-smb-p))
              "foo bar baz"
            (if (or (tramp--test-adb-p)
@@ -4798,12 +5174,12 @@ This requires restrictions of file name syntax."
          (unless (or (tramp--test-ftp-p) (tramp--test-gvfs-p)) "[foo]bar[baz]")
          "{foo}bar{baz}")))
     ;; Simplify test in order to speed up.
-    (apply 'tramp--test-check-files
+    (apply #'tramp--test-check-files
           (if (tramp--test-expensive-test)
-              files (list (mapconcat 'identity files ""))))))
+              files (list (mapconcat #'identity files ""))))))
 
 ;; These tests are inspired by Bug#17238.
-(ert-deftest tramp-test39-special-characters ()
+(ert-deftest tramp-test40-special-characters ()
   "Check special characters in file names."
   (skip-unless (tramp--test-enabled))
   (skip-unless (not (tramp--test-rsync-p)))
@@ -4811,7 +5187,7 @@ This requires restrictions of file name syntax."
 
   (tramp--test-special-characters))
 
-(ert-deftest tramp-test39-special-characters-with-stat ()
+(ert-deftest tramp-test40-special-characters-with-stat ()
   "Check special characters in file names.
 Use the `stat' command."
   :tags '(:expensive-test)
@@ -4829,7 +5205,7 @@ Use the `stat' command."
          tramp-connection-properties)))
     (tramp--test-special-characters)))
 
-(ert-deftest tramp-test39-special-characters-with-perl ()
+(ert-deftest tramp-test40-special-characters-with-perl ()
   "Check special characters in file names.
 Use the `perl' command."
   :tags '(:expensive-test)
@@ -4850,7 +5226,7 @@ Use the `perl' command."
          tramp-connection-properties)))
     (tramp--test-special-characters)))
 
-(ert-deftest tramp-test39-special-characters-with-ls ()
+(ert-deftest tramp-test40-special-characters-with-ls ()
   "Check special characters in file names.
 Use the `ls' command."
   :tags '(:expensive-test)
@@ -4873,7 +5249,7 @@ Use the `ls' command."
     (tramp--test-special-characters)))
 
 (defun tramp--test-utf8 ()
-  "Perform the test in `tramp-test40-utf8*'."
+  "Perform the test in `tramp-test41-utf8*'."
   (let* ((utf8 (if (and (eq system-type 'darwin)
                        (memq 'utf-8-hfs (coding-system-list)))
                   'utf-8-hfs 'utf-8))
@@ -4882,7 +5258,7 @@ Use the `ls' command."
         (file-name-coding-system
          (coding-system-change-eol-conversion utf8 'unix)))
     (apply
-     'tramp--test-check-files
+     #'tramp--test-check-files
      (append
       (list
        (unless (tramp--test-hpux-p) "Γυρίστε το Γαλαξία με Ώτο Στοπ")
@@ -4908,7 +5284,7 @@ Use the `ls' command."
             (replace-regexp-in-string "[\t\n/.?]" "" x)))
          language-info-alist)))))))
 
-(ert-deftest tramp-test40-utf8 ()
+(ert-deftest tramp-test41-utf8 ()
   "Check UTF8 encoding in file names and file contents."
   (skip-unless (tramp--test-enabled))
   (skip-unless (not (tramp--test-docker-p)))
@@ -4918,7 +5294,7 @@ Use the `ls' command."
 
   (tramp--test-utf8))
 
-(ert-deftest tramp-test40-utf8-with-stat ()
+(ert-deftest tramp-test41-utf8-with-stat ()
   "Check UTF8 encoding in file names and file contents.
 Use the `stat' command."
   :tags '(:expensive-test)
@@ -4938,7 +5314,7 @@ Use the `stat' command."
          tramp-connection-properties)))
     (tramp--test-utf8)))
 
-(ert-deftest tramp-test40-utf8-with-perl ()
+(ert-deftest tramp-test41-utf8-with-perl ()
   "Check UTF8 encoding in file names and file contents.
 Use the `perl' command."
   :tags '(:expensive-test)
@@ -4961,7 +5337,7 @@ Use the `perl' command."
          tramp-connection-properties)))
     (tramp--test-utf8)))
 
-(ert-deftest tramp-test40-utf8-with-ls ()
+(ert-deftest tramp-test41-utf8-with-ls ()
   "Check UTF8 encoding in file names and file contents.
 Use the `ls' command."
   :tags '(:expensive-test)
@@ -4984,7 +5360,7 @@ Use the `ls' command."
          tramp-connection-properties)))
     (tramp--test-utf8)))
 
-(ert-deftest tramp-test41-file-system-info ()
+(ert-deftest tramp-test42-file-system-info ()
   "Check that `file-system-info' returns proper values."
   (skip-unless (tramp--test-enabled))
   ;; Since Emacs 27.1.
@@ -5001,32 +5377,38 @@ Use the `ls' command."
                 (numberp (nth 1 fsi))
                 (numberp (nth 2 fsi))))))
 
-(defun tramp--test-timeout-handler ()
-  "Timeout handler, reporting a failed test."
-  (ert-fail (format "`%s' timed out" (ert-test-name (ert-running-test)))))
+;; `tramp-test43-asynchronous-requests' could be blocked.  So we set a
+;; timeout of 300 seconds, and we send a SIGUSR1 signal after 300
+;; seconds.  Similar check is performed in the timer function.
+(defconst tramp--test-asynchronous-requests-timeout 300
+  "Timeout for `tramp-test43-asynchronous-requests'.")
 
 ;; This test is inspired by Bug#16928.
-(ert-deftest tramp-test42-asynchronous-requests ()
+(ert-deftest tramp-test43-asynchronous-requests ()
   "Check parallel asynchronous requests.
 Such requests could arrive from timers, process filters and
 process sentinels.  They shall not disturb each other."
+  ;; The test fails from time to time, w/o a reproducible pattern.  So
+  ;; we mark it as unstable.
   :tags '(:expensive-test :unstable)
   (skip-unless (tramp--test-enabled))
-  (skip-unless (tramp--test-sh-p))
-
-  ;; This test could be blocked on hydra.  So we set a timeout of 300
-  ;; seconds, and we send a SIGUSR1 signal after 300 seconds.
-  ;; This clearly doesn't work though, because the test not
-  ;; infrequently hangs for hours until killed by the infrastructure.
-  (with-timeout (300 (tramp--test-timeout-handler))
-    (define-key special-event-map [sigusr1] 'tramp--test-timeout-handler)
-    (tramp--test-instrument-test-case (if (getenv "EMACS_HYDRA_CI") 10 0)
+  ;; Prior Emacs 27, `shell-file-name' was hard coded as "/bin/sh" for
+  ;; remote processes in Emacs.  That doesn't work for tramp-adb.el.
+  (skip-unless (or (and (tramp--test-adb-p) (tramp--test-emacs27-p))
+                  (tramp--test-sh-p)))
+
+  (with-timeout
+      (tramp--test-asynchronous-requests-timeout (tramp--test-timeout-handler))
+    (define-key special-event-map [sigusr1] #'tramp--test-timeout-handler)
     (let* (;; For the watchdog.
           (default-directory (expand-file-name temporary-file-directory))
+          (shell-file-name (if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh"))
           (watchdog
-            (start-process
-             "*watchdog*" nil shell-file-name shell-command-switch
-             (format "sleep 300; kill -USR1 %d" (emacs-pid))))
+            (start-process-shell-command
+             "*watchdog*" nil
+             (format
+             "sleep %d; kill -USR1 %d"
+             tramp--test-asynchronous-requests-timeout (emacs-pid))))
            (tmp-name (tramp--test-make-temp-name))
            (default-directory tmp-name)
            ;; Do not cache Tramp properties.
@@ -5052,8 +5434,11 @@ process sentinels.  They shall not disturb each other."
            ;; We must distinguish due to performance reasons.
            (timer-operation
             (cond
-             ((tramp--test-mock-p) 'vc-registered)
-             (t 'file-attributes)))
+             ((tramp--test-mock-p) #'vc-registered)
+             (t #'file-attributes)))
+          ;; This is when all timers start.  We check inside the
+          ;; timer function, that we don't exceed timeout.
+          (timer-start (current-time))
            timer buffers kill-buffer-query-functions)
 
       (unwind-protect
@@ -5068,6 +5453,9 @@ process sentinels.  They shall not disturb each other."
              (run-at-time
               0 timer-repeat
               (lambda ()
+                (when (> (- (time-to-seconds) (time-to-seconds timer-start))
+                         tramp--test-asynchronous-requests-timeout)
+                  (tramp--test-timeout-handler))
                 (when buffers
                   (let ((time (float-time))
                         (default-directory tmp-name)
@@ -5077,12 +5465,13 @@ process sentinels.  They shall not disturb each other."
                      "Start timer %s %s" file (current-time-string))
                     (funcall timer-operation file)
                     ;; Adjust timer if it takes too much time.
+                    (tramp--test-message
+                     "Stop timer %s %s" file (current-time-string))
                     (when (> (- (float-time) time) timer-repeat)
                       (setq timer-repeat (* 1.5 timer-repeat))
                       (setf (timer--repeat-delay timer) timer-repeat)
-                      (tramp--test-message "Increase timer %s" timer-repeat))
-                    (tramp--test-message
-                     "Stop timer %s %s" file (current-time-string)))))))
+                      (tramp--test-message
+                      "Increase timer %s" timer-repeat)))))))
 
             ;; Create temporary buffers.  The number of buffers
             ;; corresponds to the number of processes; it could be
@@ -5098,9 +5487,9 @@ process sentinels.  They shall not disturb each other."
                      (start-file-process-shell-command
                       (buffer-name buf) buf
                       (concat
-                       "(read line && echo $line >$line);"
-                       "(read line && cat $line);"
-                       "(read line && rm $line)")))
+                      "(read line && echo $line >$line && echo $line);"
+                      "(read line && cat $line);"
+                      "(read line && rm -f $line)")))
                     (file (expand-file-name (buffer-name buf))))
                 ;; Remember the file name.  Add counter.
                 (process-put proc 'foo file)
@@ -5113,20 +5502,19 @@ process sentinels.  They shall not disturb each other."
                     "Process filter %s %s %s" proc string 
(current-time-string))
                    (with-current-buffer (process-buffer proc)
                      (insert string))
-                   (unless (zerop (length string))
+                   (when (< (process-get proc 'bar) 2)
                     (dired-uncache (process-get proc 'foo))
                      (should (file-attributes (process-get proc 'foo))))))
-                ;; Add process sentinel.
+                ;; Add process sentinel.  It shall not perform remote
+                ;; operations, triggering Tramp processes.  This blocks.
                 (set-process-sentinel
                  proc
                  (lambda (proc _state)
                    (tramp--test-message
-                    "Process sentinel %s %s" proc (current-time-string))
-                  (dired-uncache (process-get proc 'foo))
-                   (should-not (file-attributes (process-get proc 'foo)))))))
+                    "Process sentinel %s %s" proc (current-time-string))))))
 
-            ;; Send a string.  Use a random order of the buffers.  Mix
-            ;; with regular operation.
+            ;; Send a string to the processes.  Use a random order of
+            ;; the buffers.  Mix with regular operation.
             (let ((buffers (copy-sequence buffers)))
               (while buffers
                ;; Activate timer.
@@ -5144,7 +5532,7 @@ process sentinels.  They shall not disturb each other."
                     (should (file-attributes file)))
                   ;; Send string to process.
                   (process-send-string proc (format "%s\n" (buffer-name buf)))
-                  (accept-process-output proc 0.1 nil 0)
+                  (while (accept-process-output proc 0 nil 0))
                   ;; Give the watchdog a chance.
                   (read-event nil nil 0.01)
                   (tramp--test-message
@@ -5166,22 +5554,28 @@ process sentinels.  They shall not disturb each other."
             (tramp--test-message "Check %s" (current-time-string))
             (dolist (buf buffers)
               (with-current-buffer buf
-                (should (string-equal (format "%s\n" buf) (buffer-string)))))
+                (should
+                (string-equal
+                 ;; tramp-adb.el echoes, so we must add the three strings.
+                 (if (tramp--test-adb-p)
+                     (format "%s\n%s\n%s\n%s\n%s\n" buf buf buf buf buf)
+                   (format "%s\n%s\n" buf buf))
+                 (buffer-string)))))
             (should-not
              (directory-files
               tmp-name nil directory-files-no-dot-files-regexp)))
 
         ;; Cleanup.
-        (define-key special-event-map [sigusr1] 'ignore)
+        (define-key special-event-map [sigusr1] #'ignore)
         (ignore-errors (quit-process watchdog))
         (dolist (buf buffers)
           (ignore-errors (delete-process (get-buffer-process buf)))
           (ignore-errors (kill-buffer buf)))
         (ignore-errors (cancel-timer timer))
-        (ignore-errors (delete-directory tmp-name 'recursive)))))))
+        (ignore-errors (delete-directory tmp-name 'recursive))))))
 
 ;; This test is inspired by Bug#29163.
-(ert-deftest tramp-test43-auto-load ()
+(ert-deftest tramp-test44-auto-load ()
   "Check that Tramp autoloads properly."
   (skip-unless (tramp--test-enabled))
 
@@ -5198,10 +5592,10 @@ process sentinels.  They shall not disturb each other."
        "%s -batch -Q -L %s --eval %s"
        (shell-quote-argument
         (expand-file-name invocation-name invocation-directory))
-       (mapconcat 'shell-quote-argument load-path " -L ")
+       (mapconcat #'shell-quote-argument load-path " -L ")
        (shell-quote-argument code)))))))
 
-(ert-deftest tramp-test43-delay-load ()
+(ert-deftest tramp-test44-delay-load ()
   "Check that Tramp is loaded lazily, only when needed."
   ;; The autoloaded Tramp objects are different since Emacs 26.1.  We
   ;; cannot test older Emacsen, therefore.
@@ -5231,10 +5625,10 @@ process sentinels.  They shall not disturb each other."
          "%s -batch -Q -L %s --eval %s"
          (shell-quote-argument
           (expand-file-name invocation-name invocation-directory))
-         (mapconcat 'shell-quote-argument load-path " -L ")
+         (mapconcat #'shell-quote-argument load-path " -L ")
          (shell-quote-argument (format code tm)))))))))
 
-(ert-deftest tramp-test43-recursive-load ()
+(ert-deftest tramp-test44-recursive-load ()
   "Check that Tramp does not fail due to recursive load."
   (skip-unless (tramp--test-enabled))
 
@@ -5255,10 +5649,10 @@ process sentinels.  They shall not disturb each other."
          "%s -batch -Q -L %s --eval %s"
          (shell-quote-argument
           (expand-file-name invocation-name invocation-directory))
-         (mapconcat 'shell-quote-argument load-path " -L ")
+         (mapconcat #'shell-quote-argument load-path " -L ")
          (shell-quote-argument code))))))))
 
-(ert-deftest tramp-test43-remote-load-path ()
+(ert-deftest tramp-test44-remote-load-path ()
   "Check that Tramp autoloads its packages with remote `load-path'."
   ;; The autoloaded Tramp objects are different since Emacs 26.1.  We
   ;; cannot test older Emacsen, therefore.
@@ -5276,17 +5670,18 @@ process sentinels.  They shall not disturb each other."
      (string-match
       (format
        "Loading %s"
-       (expand-file-name
-       "tramp-cmds" (file-name-directory (locate-library "tramp"))))
+       (regexp-quote
+        (expand-file-name
+         "tramp-cmds" (file-name-directory (locate-library "tramp")))))
       (shell-command-to-string
        (format
        "%s -batch -Q -L %s -l tramp-sh --eval %s"
        (shell-quote-argument
         (expand-file-name invocation-name invocation-directory))
-       (mapconcat 'shell-quote-argument load-path " -L ")
+       (mapconcat #'shell-quote-argument load-path " -L ")
        (shell-quote-argument code)))))))
 
-(ert-deftest tramp-test44-unload ()
+(ert-deftest tramp-test45-unload ()
   "Check that Tramp and its subpackages unload completely.
 Since it unloads Tramp, it shall be the last test to run."
   :tags '(:expensive-test)
@@ -5311,7 +5706,7 @@ Since it unloads Tramp, it shall be the last test to run."
    (all-completions
     "tramp" (delq 'tramp-tests (delq 'tramp-archive-tests features))))
   ;; `file-name-handler-alist' must be clean.
-  (should-not (all-completions "tramp" (mapcar 'cdr file-name-handler-alist)))
+  (should-not (all-completions "tramp" (mapcar #'cdr file-name-handler-alist)))
   ;; There shouldn't be left a bound symbol, except buffer-local
   ;; variables, and autoload functions.  We do not regard our test
   ;; symbols, and the Tramp unload hooks.
@@ -5346,7 +5741,8 @@ Since it unloads Tramp, it shall be the last test to run."
   "Run all tests for \\[tramp]."
   (interactive "p")
   (funcall
-   (if interactive 'ert-run-tests-interactively 'ert-run-tests-batch) 
"^tramp"))
+   (if interactive
+       #'ert-run-tests-interactively #'ert-run-tests-batch) "^tramp"))
 
 ;; TODO:
 
@@ -5355,6 +5751,7 @@ Since it unloads Tramp, it shall be the last test to run."
 ;; * file-equal-p (partly done in `tramp-test21-file-links')
 ;; * file-in-directory-p
 ;; * file-name-case-insensitive-p
+;; * tramp-set-file-uid-gid
 
 ;; * Work on skipped tests.  Make a comment, when it is impossible.
 ;; * Revisit expensive tests, once problems in `tramp-error' are solved.
@@ -5362,9 +5759,11 @@ Since it unloads Tramp, it shall be the last test to 
run."
 ;; * Fix `tramp-test06-directory-file-name' for `ftp'.
 ;; * Investigate, why `tramp-test11-copy-file' and `tramp-test12-rename-file'
 ;;   do not work properly for `nextcloud'.
-;; * Fix `tramp-test29-start-file-process' on MS Windows (`process-send-eof'?).
-;; * Fix `tramp-test30-interrupt-process', timeout doesn't work reliably.
-;; * Fix Bug#16928 in `tramp-test42-asynchronous-requests'.
+;; * Fix `tramp-test29-start-file-process' and
+;;   `tramp-test30-make-process' on MS Windows (`process-send-eof'?).
+;; * Fix Bug#16928 in `tramp-test43-asynchronous-requests'.  Looks
+;;   like it is resolved now.  Remove `:unstable' tag?
+;; * Implement `tramp-test31-interrupt-process' for `adb'.
 
 (provide 'tramp-tests)
 ;;; tramp-tests.el ends here
diff --git a/test/lisp/obarray-tests.el b/test/lisp/obarray-tests.el
index 9a02046..5096f78 100644
--- a/test/lisp/obarray-tests.el
+++ b/test/lisp/obarray-tests.el
@@ -1,6 +1,6 @@
 ;;; obarray-tests.el --- Tests for obarray -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Przemysław Wojnowski <address@hidden>
 
diff --git a/test/lisp/org/org-tests.el b/test/lisp/org/org-tests.el
index a220188..4b82aa8 100644
--- a/test/lisp/org/org-tests.el
+++ b/test/lisp/org/org-tests.el
@@ -1,6 +1,6 @@
 ;;; org-tests.el --- tests for org/org.el
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 
diff --git a/test/lisp/progmodes/bat-mode-tests.el 
b/test/lisp/progmodes/bat-mode-tests.el
index 5b82484..05b8459 100644
--- a/test/lisp/progmodes/bat-mode-tests.el
+++ b/test/lisp/progmodes/bat-mode-tests.el
@@ -1,6 +1,6 @@
 ;;; bat-mode-tests.el --- Tests for bat-mode.el  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Vladimir Panteleev <address@hidden>
 ;; Keywords:
diff --git a/test/lisp/progmodes/cc-mode-tests.el 
b/test/lisp/progmodes/cc-mode-tests.el
index 5f5e33d..0b8f37d 100644
--- a/test/lisp/progmodes/cc-mode-tests.el
+++ b/test/lisp/progmodes/cc-mode-tests.el
@@ -1,6 +1,6 @@
 ;;; cc-mode-tests.el --- Test suite for cc-mode.  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Michal Nazarewicz <address@hidden>
 ;; Keywords:       internal
diff --git a/test/lisp/progmodes/compile-tests.el 
b/test/lisp/progmodes/compile-tests.el
index 4e2dc86..a7d1c6b 100644
--- a/test/lisp/progmodes/compile-tests.el
+++ b/test/lisp/progmodes/compile-tests.el
@@ -1,6 +1,6 @@
 ;;; compile-tests.el --- Test suite for compile.el.  -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Chong Yidong <address@hidden>
 ;; Keywords:       internal
diff --git a/test/lisp/progmodes/elisp-mode-tests.el 
b/test/lisp/progmodes/elisp-mode-tests.el
index 941e85b..bc2d14b 100644
--- a/test/lisp/progmodes/elisp-mode-tests.el
+++ b/test/lisp/progmodes/elisp-mode-tests.el
@@ -1,6 +1,6 @@
 ;;; elisp-mode-tests.el --- Tests for emacs-lisp-mode  -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Dmitry Gutov <address@hidden>
 ;; Author: Stephen Leake <address@hidden>
@@ -298,6 +298,16 @@
       )))
 
 
+;; tmp may be on a different filesystem to the tests, but, ehh.
+(defvar xref--case-insensitive
+  (let ((dir (make-temp-file "xref-test" t)))
+    (unwind-protect
+        (progn
+          (with-temp-file (expand-file-name "hElLo" dir) "hello")
+          (file-exists-p (expand-file-name "HELLO" dir)))
+      (delete-directory dir t)))
+  "Non-nil if file system seems to be case-insensitive.")
+
 (defun xref-elisp-test-run (xrefs expected-xrefs)
   (should (= (length xrefs) (length expected-xrefs)))
   (while xrefs
@@ -307,11 +317,13 @@
            (expected-source (when (consp expected) (cdr expected))))
 
       ;; Downcase the filenames for case-insensitive file systems.
-      (setf (xref-elisp-location-file (oref xref location))
-            (downcase (xref-elisp-location-file (oref xref location))))
+      (when xref--case-insensitive
+        (setf (xref-elisp-location-file (oref xref location))
+              (downcase (xref-elisp-location-file (oref xref location))))
 
-      (setf (xref-elisp-location-file (oref expected-xref location))
-            (downcase (xref-elisp-location-file (oref expected-xref 
location))))
+        (setf (xref-elisp-location-file (oref expected-xref location))
+              (downcase (xref-elisp-location-file
+                         (oref expected-xref location)))))
 
       (should (equal xref expected-xref))
 
@@ -346,10 +358,10 @@ to (xref-elisp-test-descr-to-target xref)."
 ;; `load-path' has the correct case, so this causes the expected test
 ;; values to have the wrong case). This is handled in
 ;; `xref-elisp-test-run'.
-(defconst emacs-test-dir
-  (downcase
-   (file-truename (file-name-directory
-                  (or load-file-name (buffer-file-name))))))
+(defvar emacs-test-dir
+  (funcall (if xref--case-insensitive 'downcase 'identity)
+           (file-truename (file-name-directory
+                           (or load-file-name (buffer-file-name))))))
 
 
 ;; alphabetical by test name
diff --git a/test/lisp/progmodes/etags-tests.el 
b/test/lisp/progmodes/etags-tests.el
index b4a853e..ac059c3 100644
--- a/test/lisp/progmodes/etags-tests.el
+++ b/test/lisp/progmodes/etags-tests.el
@@ -1,6 +1,6 @@
 ;;; etags-tests.el --- Test suite for etags.el.
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Eli Zaretskii <address@hidden>
 
diff --git a/test/lisp/progmodes/f90-tests.el b/test/lisp/progmodes/f90-tests.el
index 28a1c69..b164238 100644
--- a/test/lisp/progmodes/f90-tests.el
+++ b/test/lisp/progmodes/f90-tests.el
@@ -1,6 +1,6 @@
 ;;; f90-tests.el --- tests for progmodes/f90.el
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Glenn Morris <address@hidden>
 
@@ -98,7 +98,7 @@ end subroutine test")
     (insert "(/ x /)")
     (f90-do-auto-fill)
     (beginning-of-line)
-    (skip-chars-forward "[ \t]")
+    (skip-chars-forward " \t")
     (should (equal "&(/" (buffer-substring (point) (+ 3 (point)))))))
 
 ;; TODO bug#5593
diff --git a/test/lisp/progmodes/flymake-resources/Makefile 
b/test/lisp/progmodes/flymake-resources/Makefile
index 4944075..05399ba 100644
--- a/test/lisp/progmodes/flymake-resources/Makefile
+++ b/test/lisp/progmodes/flymake-resources/Makefile
@@ -8,6 +8,6 @@ CC_OPTS = -Wall -Wextra
 ## normally use flymake, so it seems like just avoiding the issue
 ## in this test is fine.  Set flymake-log-level to 3 to investigate.
 check-syntax:
-       GCC_COLORS= $(CC) $(CC_OPTS) ${CHK_SOURCES} || true
+       GCC_COLORS= gcc $(CC_OPTS) ${CHK_SOURCES} || true
 
 # eof
diff --git a/test/lisp/progmodes/flymake-tests.el 
b/test/lisp/progmodes/flymake-tests.el
index bba1f12..c116862 100644
--- a/test/lisp/progmodes/flymake-tests.el
+++ b/test/lisp/progmodes/flymake-tests.el
@@ -1,6 +1,6 @@
 ;;; flymake-tests.el --- Test suite for flymake -*- lexical-binding: t -*-
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Eduard Wiebe <address@hidden>
 
@@ -53,7 +53,7 @@
            while notdone
            unless noninteractive do (read-event "" nil 0.1)
            do (sleep-for (+ 0.5 flymake-no-changes-timeout))
-           finally (when notdone (ert-fail
+           finally (when notdone (ert-skip
                                   (format "Some backends not reporting yet %s"
                                           notdone)))))
 
@@ -142,6 +142,9 @@ SEVERITY-PREDICATE is used to setup
 
 (ert-deftest different-diagnostic-types ()
   "Test GCC warning via function predicate."
+  ;; http://lists.gnu.org/archive/html/emacs-devel/2019-03/msg01043.html
+  :expected-result (if (or (getenv "EMACS_HYDRA_CI") (getenv "EMACS_EMBA_CI"))
+                       :failed :passed)
   (skip-unless (and (executable-find "gcc")
                     (version<=
                      "5" (string-trim
diff --git a/test/lisp/progmodes/js-tests.el b/test/lisp/progmodes/js-tests.el
index 5836e3b..b654979 100644
--- a/test/lisp/progmodes/js-tests.el
+++ b/test/lisp/progmodes/js-tests.el
@@ -1,6 +1,6 @@
 ;;; js-tests.el --- Test suite for js-mode
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/progmodes/python-tests.el 
b/test/lisp/progmodes/python-tests.el
index 0b9f848..b940f45 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -1,6 +1,6 @@
 ;;; python-tests.el --- Test suite for python.el
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -1161,10 +1161,13 @@ def b()
 if do:
     something()
     else
+outside
 "
    (python-tests-look-at "else")
    (goto-char (line-end-position))
    (python-tests-self-insert ":")
+   (should (= (current-indentation) 0))
+   (python-tests-look-at "outside")
    (should (= (current-indentation) 0))))
 
 (ert-deftest python-indent-electric-colon-3 ()
@@ -5342,13 +5345,23 @@ class SomeClass:
 (ert-deftest python-tests--python-nav-end-of-statement--infloop ()
   "Checks that `python-nav-end-of-statement' doesn't infloop in a
 buffer with overlapping strings."
+  ;; FIXME: The treatment of strings has changed in the mean time, and the
+  ;; test below now neither signals an error nor inf-loops.
+  ;; The description of the problem it's trying to catch is not clear enough
+  ;; to be able to see if the underlying problem is really fixed, sadly.
+  ;; E.g. I don't know what is meant by "overlap", really.
+  :tags '(:unstable)
   (python-tests-with-temp-buffer "''' '\n''' ' '\n"
     (syntax-propertize (point-max))
     ;; Create a situation where strings nominally overlap.  This
     ;; shouldn't happen in practice, but apparently it can happen when
     ;; a package calls `syntax-ppss' in a narrowed buffer during JIT
     ;; lock.
+    ;; FIXME: 4-5 is the SPC right after the opening triple quotes: why
+    ;; put a string-fence syntax on it?
     (put-text-property 4 5 'syntax-table (string-to-syntax "|"))
+    ;; FIXME: 8-9 is the middle quote in the closing triple quotes:
+    ;; it shouldn't have any syntax-table property to remove anyway!
     (remove-text-properties 8 9 '(syntax-table nil))
     (goto-char 4)
     (setq-local syntax-propertize-function nil)
diff --git a/test/lisp/progmodes/ruby-mode-tests.el 
b/test/lisp/progmodes/ruby-mode-tests.el
index 72d83af..efbe012 100644
--- a/test/lisp/progmodes/ruby-mode-tests.el
+++ b/test/lisp/progmodes/ruby-mode-tests.el
@@ -1,6 +1,6 @@
 ;;; ruby-mode-tests.el --- Test suite for ruby-mode
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -718,6 +718,96 @@ VALUES-PLIST is a list with alternating index and value 
elements."
     (ruby-backward-sexp)
     (should (= 2 (line-number-at-pos)))))
 
+(ert-deftest ruby-forward-sexp-jumps-do-end-block-with-no-args ()
+  (ruby-with-temp-buffer
+    (ruby-test-string
+     "proc do
+     |end")
+    (search-backward "do\n")
+    (ruby-forward-sexp)
+    (should (eobp))))
+
+(ert-deftest ruby-backward-sexp-jumps-do-end-block-with-no-args ()
+  (ruby-with-temp-buffer
+    (ruby-test-string
+     "proc do
+     |end")
+    (goto-char (point-max))
+    (ruby-backward-sexp)
+    (should (looking-at "do$"))))
+
+(ert-deftest ruby-forward-sexp-jumps-do-end-block-with-empty-args ()
+  (ruby-with-temp-buffer
+    (ruby-test-string
+     "proc do ||
+     |end")
+    (search-backward "do ")
+    (ruby-forward-sexp)
+    (should (eobp))))
+
+(ert-deftest ruby-backward-sexp-jumps-do-end-block-with-empty-args ()
+  (ruby-with-temp-buffer
+    (ruby-test-string
+     "proc do ||
+     |end")
+    (goto-char (point-max))
+    (ruby-backward-sexp)
+    (should (looking-at "do "))))
+
+(ert-deftest ruby-forward-sexp-jumps-do-end-block-with-args ()
+  (ruby-with-temp-buffer
+    (ruby-test-string
+     "proc do |a,b|
+     |end")
+    (search-backward "do ")
+    (ruby-forward-sexp)
+    (should (eobp))))
+
+(ert-deftest ruby-backward-sexp-jumps-do-end-block-with-args ()
+  (ruby-with-temp-buffer
+    (ruby-test-string
+     "proc do |a,b|
+     |end")
+    (goto-char (point-max))
+    (ruby-backward-sexp)
+    (should (looking-at "do "))))
+
+(ert-deftest ruby-forward-sexp-jumps-do-end-block-with-any-args ()
+  (ruby-with-temp-buffer
+    (ruby-test-string
+     "proc do |*|
+     |end")
+    (search-backward "do ")
+    (ruby-forward-sexp)
+    (should (eobp))))
+
+(ert-deftest ruby-forward-sexp-jumps-do-end-block-with-expanded-one-arg ()
+  (ruby-with-temp-buffer
+    (ruby-test-string
+     "proc do |a,|
+     |end")
+    (search-backward "do ")
+    (ruby-forward-sexp)
+    (should (eobp))))
+
+(ert-deftest ruby-forward-sexp-jumps-do-end-block-with-one-and-any-args ()
+  (ruby-with-temp-buffer
+    (ruby-test-string
+     "proc do |a,*|
+     |end")
+    (search-backward "do ")
+    (ruby-forward-sexp)
+    (should (eobp))))
+
+(ert-deftest ruby-backward-sexp-jumps-do-end-block-with-one-and-any-args ()
+  (ruby-with-temp-buffer
+    (ruby-test-string
+     "proc do |a,*|
+     |end")
+    (goto-char (point-max))
+    (ruby-backward-sexp)
+    (should (looking-at "do "))))
+
 (ert-deftest ruby-toggle-string-quotes-quotes-correctly ()
   (let ((pairs
          '(("puts '\"foo\"\\''" . "puts \"\\\"foo\\\"'\"")
diff --git a/test/lisp/progmodes/sql-tests.el b/test/lisp/progmodes/sql-tests.el
index a3484ea..3ac9fb1 100644
--- a/test/lisp/progmodes/sql-tests.el
+++ b/test/lisp/progmodes/sql-tests.el
@@ -1,6 +1,6 @@
 ;;; sql-tests.el --- Tests for sql.el  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Simen Heggestøyl <address@hidden>
 ;; Keywords:
@@ -53,5 +53,363 @@
           (error "some error"))))
     (should-not (sql-postgres-list-databases))))
 
+;;; Check Connection Password Handling/Wallet
+
+(defvar sql-test-login-params nil)
+(defmacro with-sql-test-connect-harness (id login-params connection expected)
+  "Set-up and tear-down SQL connect related test.
+
+Identify tests by ID.  Set :sql-login dialect attribute to
+LOGIN-PARAMS.  Provide the CONNECTION parameters and the EXPECTED
+string of values passed to the comint function for validation."
+  (declare (indent 2))
+  `(cl-letf
+       ((sql-test-login-params ' ,login-params)
+        ((symbol-function 'sql-comint-test)
+         (lambda (product options &optional buf-name)
+           (with-current-buffer (get-buffer-create buf-name)
+             (insert (pp-to-string (list product options sql-user sql-password 
sql-server sql-database))))))
+        ((symbol-function 'sql-run-test)
+         (lambda (&optional buffer)
+           (interactive "P")
+           (sql-product-interactive 'sqltest buffer)))
+        (sql-user nil)
+        (sql-server nil)
+        (sql-database nil)
+        (sql-product-alist
+         '((ansi)
+           (sqltest
+            :name "SqlTest"
+            :sqli-login sql-test-login-params
+            :sqli-comint-func sql-comint-test)))
+        (sql-connection-alist
+         '((,(format "test-%s" id)
+            ,@connection)))
+        (sql-password-wallet
+         (list
+          (make-temp-file
+           "sql-test-netrc" nil nil
+           (mapconcat #'identity
+                      '("machine aMachine user aUserName password \"netrc-A 
aPassword\""
+                        "machine aServer user aUserName password \"netrc-B 
aPassword\""
+                        "machine aMachine server aServer user aUserName 
password \"netrc-C aPassword\""
+                        "machine aMachine database aDatabase user aUserName 
password \"netrc-D aPassword\""
+                        "machine aDatabase user aUserName password \"netrc-E 
aPassword\""
+                        "machine aMachine server aServer database aDatabase 
user aUserName password \"netrc-F aPassword\""
+                        "machine \"aServer/aDatabase\" user aUserName password 
\"netrc-G aPassword\""
+                        ) "\n")))))
+
+     (let* ((connection ,(format "test-%s" id))
+            (buffername (format "*SQL: ERT TEST <%s>*" connection)))
+       (when (get-buffer buffername)
+         (kill-buffer buffername))
+       (sql-connect connection buffername)
+       (should (get-buffer buffername))
+       (should (string-equal (with-current-buffer buffername (buffer-string)) 
,expected))
+       (when (get-buffer buffername)
+         (kill-buffer buffername))
+       (delete-file (car sql-password-wallet)))))
+
+(ert-deftest sql-test-connect ()
+  "Test of basic `sql-connect'."
+  (with-sql-test-connect-harness 1 (user password server database)
+    ((sql-product 'sqltest)
+     (sql-user "aUserName")
+     (sql-password "test-1 aPassword")
+     (sql-server "aServer")
+     (sql-database "aDatabase"))
+    "(sqltest nil \"aUserName\" \"test-1 aPassword\" \"aServer\" 
\"aDatabase\")\n"))
+
+(ert-deftest sql-test-connect-password-func ()
+  "Test of password function."
+  (with-sql-test-connect-harness 2 (user password server database)
+    ((sql-product 'sqltest)
+     (sql-user "aUserName")
+     (sql-password (lambda () (concat [?t ?e ?s ?t ?- ?2 ?\s
+                                     ?a ?P ?a ?s ?s ?w ?o ?r ?d])))
+     (sql-server "aServer")
+     (sql-database "aDatabase"))
+    "(sqltest nil \"aUserName\" \"test-2 aPassword\" \"aServer\" 
\"aDatabase\")\n"))
+
+(ert-deftest sql-test-connect-wallet-server-database ()
+  "Test of password function."
+  (with-sql-test-connect-harness 3 (user password server database)
+    ((sql-product 'sqltest)
+     (sql-user "aUserName")
+     (sql-server "aServer")
+     (sql-database "aDatabase"))
+    "(sqltest nil \"aUserName\" \"netrc-G aPassword\" \"aServer\" 
\"aDatabase\")\n"))
+
+(ert-deftest sql-test-connect-wallet-database ()
+  "Test of password function."
+  (with-sql-test-connect-harness 4 (user password database)
+    ((sql-product 'sqltest)
+     (sql-user "aUserName")
+     (sql-database "aDatabase"))
+    "(sqltest nil \"aUserName\" \"netrc-E aPassword\" nil \"aDatabase\")\n"))
+
+(ert-deftest sql-test-connect-wallet-server ()
+  "Test of password function."
+  (with-sql-test-connect-harness 5 (user password server)
+    ((sql-product 'sqltest)
+     (sql-user "aUserName")
+     (sql-server "aServer"))
+    "(sqltest nil \"aUserName\" \"netrc-B aPassword\" \"aServer\" nil)\n"))
+
+;;; Set/Get Product Features
+
+(defvar sql-test-feature-value-a nil "Indirect value A.")
+(defvar sql-test-feature-value-b nil "Indirect value B.")
+(defvar sql-test-feature-value-c nil "Indirect value C.")
+(defvar sql-test-feature-value-d nil "Indirect value D.")
+(defmacro sql-test-product-feature-harness (&rest action)
+  "Set-up and tear-down of testing product/feature API.
+
+Perform ACTION and validate results"
+  (declare (indent 2))
+  `(cl-letf
+       ((sql-product-alist
+         (list (list 'a :X 1 :Y 2 :Z 'sql-test-feature-value-a)
+               (list 'b :X 3      :Z 'sql-test-feature-value-b)
+               (list 'c      :Y 6 :Z 'sql-test-feature-value-c)
+               (list 'd :X 7 :Y 8                            )))
+        (sql-indirect-features '(:Z :W))
+        (sql-test-feature-value-a "original A")
+        (sql-test-feature-value-b "original B")
+        (sql-test-feature-value-c "original C")
+        (sql-test-feature-value-d "original D"))
+     ,@action))
+
+(ert-deftest sql-test-add-product ()
+  "Add a product"
+
+  (sql-test-product-feature-harness
+      (sql-add-product 'xyz "XyzDb")
+
+      (should (equal (pp-to-string (assoc 'xyz sql-product-alist))
+                     "(xyz :name \"XyzDb\")\n"))))
+
+(ert-deftest sql-test-add-existing-product ()
+  "Add a product that already exists."
+
+  (sql-test-product-feature-harness
+      (should-error (sql-add-feature 'a "Aaa"))
+      (should (equal (pp-to-string (assoc 'a sql-product-alist))
+                     "(a :X 1 :Y 2 :Z sql-test-feature-value-a)\n"))))
+
+(ert-deftest sql-test-set-feature ()
+  "Add a feature"
+
+  (sql-test-product-feature-harness
+      (sql-set-product-feature 'b :Y 4)
+      (should (equal (pp-to-string (assoc 'b sql-product-alist))
+                     "(b :Y 4 :X 3 :Z sql-test-feature-value-b)\n"))))
+
+(ert-deftest sql-test-set-indirect-feature ()
+  "Set a new indirect feature"
+
+  (sql-test-product-feature-harness
+      (sql-set-product-feature 'd :Z 'sql-test-feature-value-d)
+      (should (equal (pp-to-string (assoc 'd sql-product-alist))
+                     "(d :Z sql-test-feature-value-d :X 7 :Y 8)\n"))))
+
+(ert-deftest sql-test-set-existing-feature ()
+  "Set an existing feature."
+
+  (sql-test-product-feature-harness
+      (sql-set-product-feature 'b :X 33)
+      (should (equal (pp-to-string (assoc 'b sql-product-alist))
+                     "(b :X 33 :Z sql-test-feature-value-b)\n"))))
+
+(ert-deftest sql-test-set-existing-indirect-feature ()
+  "Set an existing indirect feature."
+
+  (sql-test-product-feature-harness
+      (should (equal sql-test-feature-value-b "original B"))
+      (sql-set-product-feature 'b :Z "Hurray!")
+    (should (equal (pp-to-string (assoc 'b sql-product-alist))
+                   "(b :X 3 :Z sql-test-feature-value-b)\n")) ;; unchanged
+    (should (equal sql-test-feature-value-b "Hurray!"))))
+
+(ert-deftest sql-test-set-missing-product ()
+  "Add a feature to a missing product."
+
+  (sql-test-product-feature-harness
+      (should-error (sql-set-product-feature 'x :Y 4))
+      (should-not (assoc 'x sql-product-alist))))
+
+(ert-deftest sql-test-get-feature ()
+  "Get a feature value."
+
+  (sql-test-product-feature-harness
+      (should (equal (sql-get-product-feature 'c :Y) 6))))
+
+(ert-deftest sql-test-get-indirect-feature ()
+  "Get a feature indirect value."
+
+  (sql-test-product-feature-harness
+      (should (equal (sql-get-product-feature 'c :Z nil t) 
'sql-test-feature-value-c))
+      (should (equal sql-test-feature-value-c "original C"))
+    (should (equal (sql-get-product-feature 'c :Z) "original C"))))
+
+(ert-deftest sql-test-get-missing-product ()
+  "Get a feature value from a missing product."
+
+  (sql-test-product-feature-harness
+      (should-error (sql-get-product-feature 'x :Y))))
+
+(ert-deftest sql-test-get-missing-feature ()
+  "Get a missing feature value."
+
+  (sql-test-product-feature-harness
+      (should-not (sql-get-product-feature 'c :X))))
+
+(ert-deftest sql-test-get-missing-indirect-feature ()
+  "Get a missing indirect feature value."
+
+  (sql-test-product-feature-harness
+      (should-not (sql-get-product-feature 'd :Z))))
+
+;;; SQL Oracle SCAN/DEFINE
+(defmacro sql-tests-placeholder-filter-harness (orig repl outp)
+  "Set-up and tear-down of testing of placeholder filter.
+
+The placeholder in ORIG will be replaced by REPL which should
+yield OUTP."
+
+  (declare (indent 0))
+  `(let ((syntab (syntax-table))
+         (sql-oracle-scan-on t))
+     (set-syntax-table sql-mode-syntax-table)
+
+     (cl-letf
+         (((symbol-function 'read-from-minibuffer)
+           (lambda (&rest _) ,repl)))
+
+       (should (equal (sql-placeholders-filter ,orig) ,outp)))
+
+     (set-syntax-table syntab)))
+
+(ert-deftest sql-tests-placeholder-filter-simple ()
+  "Test that placeholder relacement of simple replacement text."
+  (sql-tests-placeholder-filter-harness
+    "select '&x' from dual;" "XX"
+    "select 'XX' from dual;"))
+
+(ert-deftest sql-tests-placeholder-filter-ampersand ()
+  "Test that placeholder relacement of replacement text with ampersand."
+  (sql-tests-placeholder-filter-harness
+    "select '&x' from dual;" "&Y"
+    "select '&Y' from dual;")
+
+  (sql-tests-placeholder-filter-harness
+    "select '&x' from dual;" "Y&"
+    "select 'Y&' from dual;")
+
+  (sql-tests-placeholder-filter-harness
+    "select '&x' from dual;" "Y&Y"
+    "select 'Y&Y' from dual;"))
+
+(ert-deftest sql-tests-placeholder-filter-period ()
+  "Test that placeholder relacement of token terminated by a period."
+  (sql-tests-placeholder-filter-harness
+    "select '&x.' from dual;" "&Y"
+    "select '&Y' from dual;")
+
+  (sql-tests-placeholder-filter-harness
+    "select '&x.y' from dual;" "&Y"
+    "select '&Yy' from dual;")
+
+  (sql-tests-placeholder-filter-harness
+    "select '&x..y' from dual;" "&Y"
+    "select '&Y.y' from dual;"))
+
+;; Buffer naming
+(defmacro sql-tests-buffer-naming-harness (product &rest action)
+  "Set-up and tear-down of test of buffer naming.
+
+The ACTION will be tested after set-up of PRODUCT."
+
+  (declare (indent 1))
+  `(progn
+     (ert--skip-unless (executable-find sql-sqlite-program))
+     (let (new-bufs)
+       (cl-letf
+           (((symbol-function 'make-comint-in-buffer)
+             (lambda (_name buffer _program &optional _startfile &rest 
_switches)
+               (let ((b (get-buffer-create buffer)))
+                 (message ">>make-comint-in-buffer %S" b)
+                 (cl-pushnew b new-bufs) ;; Keep track of what we create
+                 b))))
+
+         (let (,(intern (format "sql-%s-login-params" product)))
+           ,@action)
+
+         (let (kill-buffer-query-functions) ;; Kill what we create
+           (mapc #'kill-buffer new-bufs))))))
+
+(ert-deftest sql-tests-buffer-naming-default ()
+  "Test buffer naming."
+  (sql-tests-buffer-naming-harness sqlite
+    (sql-sqlite)
+    (message ">> %S" (current-buffer))
+    (should (equal (buffer-name) "*SQL: SQLite*"))))
+
+(ert-deftest sql-tests-buffer-naming-multiple ()
+  "Test buffer naming of multiple buffers."
+  (sql-tests-buffer-naming-harness sqlite
+    (sql-sqlite)
+    (should (equal (buffer-name) "*SQL: SQLite*"))
+
+    (switch-to-buffer "*scratch*")
+
+    (sql-sqlite)
+    (should (equal (buffer-name) "*SQL: SQLite*"))))
+
+(ert-deftest sql-tests-buffer-naming-explicit ()
+  "Test buffer naming with explicit name."
+  (sql-tests-buffer-naming-harness sqlite
+    (sql-sqlite "A")
+    (should (equal (buffer-name) "*SQL: A*"))
+
+    (switch-to-buffer "*scratch*")
+
+    (sql-sqlite "A")
+    (should (equal (buffer-name) "*SQL: A*"))))
+
+(ert-deftest sql-tests-buffer-naming-universal-argument ()
+  "Test buffer naming with explicit name."
+  (sql-tests-buffer-naming-harness sqlite
+    (cl-letf
+        (((symbol-function 'read-string)
+          (lambda (_prompt &optional _initial-input _history _default-value 
_inherit-input-method)
+            "1")))
+      (sql-sqlite '(4))
+      (should (equal (buffer-name) "*SQL: 1*")))
+
+    (switch-to-buffer "*scratch*")
+
+    (cl-letf
+        (((symbol-function 'read-string)
+          (lambda (_prompt &optional _initial-input _history _default-value 
_inherit-input-method)
+            "2")))
+      (sql-sqlite '(16))
+      (should (equal (buffer-name) "*SQL: 2*")))))
+
+(ert-deftest sql-tests-buffer-naming-existing ()
+  "Test buffer naming with an existing non-SQLi buffer."
+  (sql-tests-buffer-naming-harness sqlite
+    (get-buffer-create "*SQL: exist*")
+
+    (cl-letf
+        (((symbol-function 'read-string)
+          (lambda (_prompt &optional _initial-input _history _default-value 
_inherit-input-method)
+            "exist")))
+      (sql-sqlite '(4))
+      (should (equal (buffer-name) "*SQL: exist-1*")))
+
+    (kill-buffer "*SQL: exist*")))
+
+
 (provide 'sql-tests)
 ;;; sql-tests.el ends here
diff --git a/test/lisp/progmodes/subword-tests.el 
b/test/lisp/progmodes/subword-tests.el
index fa11500..52e2cac 100644
--- a/test/lisp/progmodes/subword-tests.el
+++ b/test/lisp/progmodes/subword-tests.el
@@ -1,6 +1,6 @@
 ;;; subword-tests.el --- Testing the subword rules
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <address@hidden>
 ;; Keywords:
diff --git a/test/lisp/progmodes/tcl-tests.el b/test/lisp/progmodes/tcl-tests.el
index 0614886..50c3eba 100644
--- a/test/lisp/progmodes/tcl-tests.el
+++ b/test/lisp/progmodes/tcl-tests.el
@@ -1,6 +1,6 @@
 ;;; tcl-tests.el --- Test suite for tcl-mode
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/progmodes/xref-tests.el 
b/test/lisp/progmodes/xref-tests.el
index e8441a5..31f4550 100644
--- a/test/lisp/progmodes/xref-tests.el
+++ b/test/lisp/progmodes/xref-tests.el
@@ -1,6 +1,6 @@
 ;;; xref-tests.el --- tests for xref
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Dmitry Gutov <address@hidden>
 
diff --git a/test/lisp/ps-print-tests.el b/test/lisp/ps-print-tests.el
index 3714d84..b9bf92d 100644
--- a/test/lisp/ps-print-tests.el
+++ b/test/lisp/ps-print-tests.el
@@ -1,6 +1,6 @@
 ;;; ps-print-tests.el --- Test suite for ps-print.el  -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Phillip Lord <address@hidden>
 
diff --git a/test/lisp/register-tests.el b/test/lisp/register-tests.el
index 4743764..b939ae8 100644
--- a/test/lisp/register-tests.el
+++ b/test/lisp/register-tests.el
@@ -1,6 +1,6 @@
 ;;; register-tests.el --- tests for register.el  -*- lexical-binding: t-*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Tino Calancha <address@hidden>
 ;; Keywords:
diff --git a/test/lisp/replace-tests.el b/test/lisp/replace-tests.el
index 5a91a2c..ed948ad 100644
--- a/test/lisp/replace-tests.el
+++ b/test/lisp/replace-tests.el
@@ -1,6 +1,6 @@
 ;;; replace-tests.el --- tests for replace.el.
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; Author: Nicolas Richard <address@hidden>
 ;; Author: Juri Linkov <address@hidden>
diff --git a/test/lisp/rot13-tests.el b/test/lisp/rot13-tests.el
index f91f00b..851ab7b 100644
--- a/test/lisp/rot13-tests.el
+++ b/test/lisp/rot13-tests.el
@@ -1,6 +1,6 @@
 ;;; rot13-tests.el --- Tests for rot13.el  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Simen Heggestøyl <address@hidden>
 ;; Keywords:
diff --git a/test/lisp/ses-tests.el b/test/lisp/ses-tests.el
index c773c9b..8b07a55 100644
--- a/test/lisp/ses-tests.el
+++ b/test/lisp/ses-tests.el
@@ -1,6 +1,6 @@
 ;;; ses-tests.el --- Tests for ses.el              -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Vincent Belaïche <address@hidden>
 
diff --git a/test/lisp/shadowfile-tests.el b/test/lisp/shadowfile-tests.el
index 3bab22f..2a777af 100644
--- a/test/lisp/shadowfile-tests.el
+++ b/test/lisp/shadowfile-tests.el
@@ -1,6 +1,6 @@
 ;;; shadowfile-tests.el --- Tests of shadowfile
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 
diff --git a/test/lisp/shell-tests.el b/test/lisp/shell-tests.el
index 9550800..329f5cf 100644
--- a/test/lisp/shell-tests.el
+++ b/test/lisp/shell-tests.el
@@ -1,6 +1,6 @@
 ;;; shell-tests.el  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2010-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el
index 417aa64..cc2feeb 100644
--- a/test/lisp/simple-tests.el
+++ b/test/lisp/simple-tests.el
@@ -1,6 +1,6 @@
 ;;; simple-test.el --- Tests for simple.el           -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Artur Malabarba <address@hidden>
 
@@ -22,6 +22,11 @@
 (require 'ert)
 (eval-when-compile (require 'cl-lib))
 
+(defun simple-test--buffer-substrings ()
+  "Return cons of buffer substrings before and after point."
+  (cons (buffer-substring (point-min) (point))
+        (buffer-substring (point) (point-max))))
+
 (defmacro simple-test--dummy-buffer (&rest body)
   (declare (indent 0)
            (debug t))
@@ -31,10 +36,7 @@
      (insert "(a b")
      (save-excursion (insert " c d)"))
      ,@body
-     (with-no-warnings
-       (cons (buffer-substring (point-min) (point))
-             (buffer-substring (point) (point-max))))))
-
+     (with-no-warnings (simple-test--buffer-substrings))))
 
 
 ;;; `transpose-sexps'
@@ -46,8 +48,7 @@
      (insert "(s1) (s2) (s3) (s4) (s5)")
      (backward-sexp 1)
      ,@body
-     (cons (buffer-substring (point-min) (point))
-           (buffer-substring (point) (point-max)))))
+     (simple-test--buffer-substrings)))
 
 ;;; Transposition with negative args (bug#20698, bug#21885)
 (ert-deftest simple-transpose-subr ()
@@ -214,6 +215,147 @@
       (remove-hook 'post-self-insert-hook inc))))
 
 
+;;; `delete-indentation'
+
+(ert-deftest simple-delete-indentation-no-region ()
+  "Test `delete-indentation' when no mark is set; see bug#35021."
+  (with-temp-buffer
+    (insert " first \n second \n third \n fourth ")
+    (should-not (mark t))
+    ;; Without prefix argument.
+    (should-not (call-interactively #'delete-indentation))
+    (should (equal (simple-test--buffer-substrings)
+                   '(" first \n second \n third" . " fourth ")))
+    (should-not (call-interactively #'delete-indentation))
+    (should (equal (simple-test--buffer-substrings)
+                   '(" first \n second" . " third fourth ")))
+    ;; With prefix argument.
+    (goto-char (point-min))
+    (let ((current-prefix-arg '(4)))
+      (should-not (call-interactively #'delete-indentation)))
+    (should (equal (simple-test--buffer-substrings)
+                   '(" first" . " second third fourth ")))))
+
+(ert-deftest simple-delete-indentation-inactive-region ()
+  "Test `delete-indentation'  with an inactive region."
+  (with-temp-buffer
+    (insert " first \n second \n third ")
+    (set-marker (mark-marker) (point-min))
+    (should (mark t))
+    (should-not (call-interactively #'delete-indentation))
+    (should (equal (simple-test--buffer-substrings)
+                   '(" first \n second" . " third ")))))
+
+(ert-deftest simple-delete-indentation-blank-line ()
+  "Test `delete-indentation' does not skip blank lines.
+See bug#35036."
+  (with-temp-buffer
+    (insert "\n\n third \n \n \n sixth \n\n")
+    ;; Without prefix argument.
+    (should-not (delete-indentation))
+    (should (equal (simple-test--buffer-substrings)
+                   '("\n\n third \n \n \n sixth \n" . "")))
+    (should-not (delete-indentation))
+    (should (equal (simple-test--buffer-substrings)
+                   '("\n\n third \n \n \n sixth" . "")))
+    (should-not (delete-indentation))
+    (should (equal (simple-test--buffer-substrings)
+                   '("\n\n third \n \n" . "sixth")))
+    ;; With prefix argument.
+    (goto-char (point-min))
+    (should-not (delete-indentation t))
+    (should (equal (simple-test--buffer-substrings)
+                   '("" . "\n third \n \nsixth")))
+    (should-not (delete-indentation t))
+    (should (equal (simple-test--buffer-substrings)
+                   '("" . "third \n \nsixth")))
+    (should-not (delete-indentation t))
+    (should (equal (simple-test--buffer-substrings)
+                   '("third" . "\nsixth")))
+    (should-not (delete-indentation t))
+    (should (equal (simple-test--buffer-substrings)
+                   '("third" . " sixth")))))
+
+(ert-deftest simple-delete-indentation-boundaries ()
+  "Test `delete-indentation' motion at buffer boundaries."
+  (with-temp-buffer
+    (insert " first \n second \n third ")
+    ;; Stay at EOB.
+    (should-not (delete-indentation t))
+    (should (equal (simple-test--buffer-substrings)
+                   '(" first \n second \n third " . "")))
+    ;; Stay at BOB.
+    (forward-line -1)
+    (save-restriction
+      (narrow-to-region (point) (line-end-position))
+      (should-not (delete-indentation))
+      (should (equal (simple-test--buffer-substrings)
+                     '("" . " second ")))
+      ;; Go to EOB.
+      (should-not (delete-indentation t))
+      (should (equal (simple-test--buffer-substrings)
+                     '(" second " . ""))))
+    ;; Go to BOB.
+    (end-of-line 0)
+    (should-not (delete-indentation))
+    (should (equal (simple-test--buffer-substrings)
+                   '("" . " first \n second \n third ")))))
+
+(ert-deftest simple-delete-indentation-region ()
+  "Test `delete-indentation' with an active region."
+  (with-temp-buffer
+    ;; Empty region.
+    (insert " first ")
+    (should-not (delete-indentation nil (point) (point)))
+    (should (equal (simple-test--buffer-substrings)
+                   '(" first " . "")))
+    ;; Single line.
+    (should-not (delete-indentation
+                 nil (line-beginning-position) (1- (point))))
+    (should (equal (simple-test--buffer-substrings)
+                   '("" . " first ")))
+    (should-not (delete-indentation nil (1+ (point)) (line-end-position)))
+    (should (equal (simple-test--buffer-substrings)
+                   '(" " . "first ")))
+    (should-not (delete-indentation
+                 nil (line-beginning-position) (line-end-position)))
+    (should (equal (simple-test--buffer-substrings)
+                   '("" . " first ")))
+    ;; Multiple lines.
+    (goto-char (point-max))
+    (insert "\n second \n third \n fourth ")
+    (goto-char (point-min))
+    (should-not (delete-indentation
+                 nil (line-end-position) (line-beginning-position 2)))
+    (should (equal (simple-test--buffer-substrings)
+                   '(" first" . " second \n third \n fourth ")))
+    (should-not (delete-indentation
+                 nil (point) (1+ (line-beginning-position 2))))
+    (should (equal (simple-test--buffer-substrings)
+                   '(" first second" . " third \n fourth ")))
+    ;; Prefix argument overrides region.
+    (should-not (delete-indentation t (point-min) (point)))
+    (should (equal (simple-test--buffer-substrings)
+                   '(" first second third" . " fourth ")))))
+
+(ert-deftest simple-delete-indentation-prefix ()
+  "Test `delete-indentation' with a fill prefix."
+  (with-temp-buffer
+    (insert "> first \n> second \n> third \n> fourth ")
+    (let ((fill-prefix ""))
+      (delete-indentation))
+    (should (equal (simple-test--buffer-substrings)
+                   '("> first \n> second \n> third" . " > fourth ")))
+    (let ((fill-prefix "<"))
+      (delete-indentation))
+    (should (equal (simple-test--buffer-substrings)
+                   '("> first \n> second" . " > third > fourth ")))
+    (let ((fill-prefix ">"))
+      (delete-indentation))
+    (should (equal (simple-test--buffer-substrings)
+                   '("> first" . " second > third > fourth ")))))
+
+
 ;;; `delete-trailing-whitespace'
 (ert-deftest simple-delete-trailing-whitespace--bug-21766 ()
   "Test bug#21766: delete-whitespace sometimes deletes non-whitespace."
diff --git a/test/lisp/sort-tests.el b/test/lisp/sort-tests.el
index e875af9..8694ce4 100644
--- a/test/lisp/sort-tests.el
+++ b/test/lisp/sort-tests.el
@@ -1,6 +1,6 @@
 ;;; sort-tests.el --- Tests for sort.el              -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Artur Malabarba <address@hidden>
 
diff --git a/test/lisp/soundex-tests.el b/test/lisp/soundex-tests.el
index 571253e..d8d79b8 100644
--- a/test/lisp/soundex-tests.el
+++ b/test/lisp/soundex-tests.el
@@ -1,6 +1,6 @@
 ;;; soundex-tests.el --- tests for soundex.el -*- lexical-binding: t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index f218a76..c458eef 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -1,6 +1,6 @@
 ;;; subr-tests.el --- Tests for subr.el
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Oleh Krehel <address@hidden>,
 ;;         Nicolas Petton <address@hidden>
@@ -318,24 +318,6 @@ cf. Bug#25477."
   (should (eq (string-to-char (symbol-name (gensym))) ?g))
   (should (eq (string-to-char (symbol-name (gensym "X"))) ?X)))
 
-(ert-deftest subr-tests--proper-list-p ()
-  "Test `proper-list-p' behavior."
-  (dotimes (length 4)
-    ;; Proper and dotted lists.
-    (let ((list (make-list length 0)))
-      (should (= (proper-list-p list) length))
-      (should (not (proper-list-p (nconc list 0)))))
-    ;; Circular lists.
-    (dotimes (n (1+ length))
-      (let ((circle (make-list (1+ length) 0)))
-        (should (not (proper-list-p (nconc circle (nthcdr n circle))))))))
-  ;; Atoms.
-  (should (not (proper-list-p 0)))
-  (should (not (proper-list-p "")))
-  (should (not (proper-list-p [])))
-  (should (not (proper-list-p (make-bool-vector 0 nil))))
-  (should (not (proper-list-p (make-symbol "a")))))
-
 (ert-deftest subr-tests--assq-delete-all ()
   "Test `assq-delete-all' behavior."
   (cl-flet ((new-list-fn
@@ -372,5 +354,24 @@ See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19350.";
                             (shell-quote-argument "%ca%")))
                    "without-caret %ca%"))))
 
+(ert-deftest subr-tests-flatten-tree ()
+  "Test `flatten-tree' behavior."
+  (should (equal (flatten-tree '(1 (2 . 3) nil (4 5 (6)) 7))
+                 '(1 2 3 4 5 6 7)))
+  (should (equal (flatten-tree '((1 . 2)))
+                 '(1 2)))
+  (should (equal (flatten-tree '(1 nil 2))
+                 '(1 2)))
+  (should (equal (flatten-tree 42)
+                 '(42)))
+  (should (equal (flatten-tree t)
+                 '(t)))
+  (should (equal (flatten-tree nil)
+                 nil))
+  (should (equal (flatten-tree '((nil) ((((nil)))) nil))
+                 nil))
+  (should (equal (flatten-tree '(1 ("foo" "bar") 2))
+                 '(1 "foo" "bar" 2))))
+
 (provide 'subr-tests)
 ;;; subr-tests.el ends here
diff --git a/test/lisp/tar-mode-tests.el b/test/lisp/tar-mode-tests.el
index f36fc71..1fce200 100644
--- a/test/lisp/tar-mode-tests.el
+++ b/test/lisp/tar-mode-tests.el
@@ -1,6 +1,6 @@
 ;;; tar-mode-tests.el --- Test suite for tar-mode. -*- lexical-binding: t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -21,6 +21,8 @@
 (require 'ert)
 (require 'tar-mode)
 
+(defvar tar-mode-tests-data-directory
+  (expand-file-name "test/data/decompress" source-directory))
 
 (ert-deftest tar-mode-test-tar-grind-file-mode ()
   (let ((alist (list (cons 448 "rwx------")
@@ -31,6 +33,17 @@
     (dolist (x alist)
       (should (equal (cdr x) (tar-grind-file-mode (car x)))))))
 
+(ert-deftest tar-mode-test-tar-extract-gz ()
+  (skip-unless (executable-find "gzip"))
+  (let* ((tar-file (expand-file-name "tg.tar.gz" 
tar-mode-tests-data-directory))
+         tar-buffer gz-buffer)
+    (unwind-protect
+        (with-current-buffer (setq tar-buffer (find-file-noselect tar-file))
+          (setq gz-buffer (tar-extract))
+          (should (equal (char-after) ?\N{SNOWFLAKE})))
+      (when (buffer-live-p tar-buffer) (kill-buffer tar-buffer))
+      (when (buffer-live-p gz-buffer) (kill-buffer gz-buffer)))))
+
 (provide 'tar-mode-tests)
 
 ;; tar-mode-tests.el ends here
diff --git a/test/lisp/term-tests.el b/test/lisp/term-tests.el
index ebf48d5..9f5dcd5 100644
--- a/test/lisp/term-tests.el
+++ b/test/lisp/term-tests.el
@@ -1,6 +1,6 @@
 ;;; term-tests.el --- tests for term.el  -*- lexical-binding: t -*-
 
-;; Copyright (C) 2017 Free Software Foundation, Inc.
+;; Copyright (C) 2017, 2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/textmodes/conf-mode-tests.el 
b/test/lisp/textmodes/conf-mode-tests.el
new file mode 100644
index 0000000..3eefc8f
--- /dev/null
+++ b/test/lisp/textmodes/conf-mode-tests.el
@@ -0,0 +1,204 @@
+;;; conf-mode-tests.el --- Test suite for conf mode  -*- lexical-binding: t; 
-*-
+
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
+
+;; Author: J. Alexander Branham <address@hidden>
+;; Keywords: internal
+
+;; 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:
+
+;;; Code:
+(require 'conf-mode)
+(require 'ert)
+
+(ert-deftest conf-test-align-assignments ()
+  "Test for `conf-align-assignments'."
+  (with-temp-buffer
+    (insert "foo: bar\nbar: baz")
+    (conf-colon-mode)
+    (conf-align-assignments)
+    (should (equal (buffer-string)
+                   "foo:                       bar\nbar:                       
baz"))))
+
+(ert-deftest conf-test-font-lock ()
+  (with-temp-buffer
+    (insert "foo: bar\nbar: baz")
+    (conf-colon-mode)
+    (font-lock-mode)
+    (font-lock-ensure)
+    (goto-char (point-min))
+    (should (equal (face-at-point) 'font-lock-variable-name-face))
+    (search-forward "bar")
+    (should-not (face-at-point))))
+
+(ert-deftest conf-test-windows-mode ()
+  (with-temp-buffer
+    ;; from `conf-windows-mode' docstring:
+    (insert "[ExtShellFolderViews]
+Default={5984FFE0-28D4-11CF-AE66-08002B2E1262}
+{5984FFE0-28D4-11CF-AE66-08002B2E1262}={5984FFE0-28D4-11CF-AE66-08002B2E1262}
+
+[{5984FFE0-28D4-11CF-AE66-08002B2E1262}]
+PersistMoniker=file://Folder.htt")
+    (goto-char (point-min))
+    (conf-windows-mode)
+    (font-lock-mode)
+    (font-lock-ensure)
+    (search-forward "ExtShell")
+    (should (equal (face-at-point) 'font-lock-type-face))
+    (search-forward "Defau")
+    (should (equal (face-at-point) 'font-lock-variable-name-face))
+    (forward-line)
+    (beginning-of-line)
+    (should (equal (face-at-point) 'font-lock-variable-name-face))
+    (forward-line 2)
+    (should-not (face-at-point))
+    (forward-char)
+    (should (equal (face-at-point) 'font-lock-type-face))))
+
+(ert-deftest conf-test-javaprop-mode ()
+  (with-temp-buffer
+    ;; From `conf-javaprop-mode' docstring
+    (insert "// another kind of comment
+/* yet another */
+
+name:value
+name=value
+name value
+x.1 =
+x.2.y.1.z.1 =
+x.2.y.1.z.2.zz =")
+    (goto-char (point-min))
+    (conf-javaprop-mode)
+    (font-lock-mode)
+    (font-lock-ensure)
+    (should (equal (face-at-point) 'font-lock-comment-delimiter-face))
+    (forward-char 3)
+    (should (equal (face-at-point) 'font-lock-comment-face))
+    (search-forward "*")
+    (should (equal (face-at-point) 'font-lock-comment-delimiter-face))
+    (while (search-forward "nam" nil t)
+      (should (equal (face-at-point) 'font-lock-variable-name-face))
+      (search-forward "val")
+      (should-not (face-at-point)))
+    (while (re-search-forward "a-z" nil t)
+      (backward-char)
+      (should (equal (face-at-point) 'font-lock-variable-name-face))
+      (re-search-forward "[0-0]" nil t)
+      (backward-char)
+      (should (equal (face-at-point) 'font-lock-constant-face)))))
+
+(ert-deftest conf-test-space-mode ()
+  ;; From `conf-space-mode' docstring.
+  (with-temp-buffer
+    (insert "image/jpeg                        jpeg jpg jpe
+image/png                      png
+image/tiff                     tiff tif
+")
+    (goto-char (point-min))
+    (conf-space-mode)
+    (font-lock-mode)
+    (font-lock-ensure)
+    (should (equal (face-at-point) 'font-lock-variable-name-face))
+    (forward-char 15)
+    (should-not (face-at-point))))
+
+(ert-deftest conf-test-colon-mode ()
+  ;; From `conf-colon-mode' docstring.
+  (with-temp-buffer
+    (insert "<Multi_key> <exclam> <exclam>             : \"\\241\"     
exclamdown
+<Multi_key> <c> <slash>                        : \"\\242\"     cent")
+    (goto-char (point-min))
+    (conf-colon-mode)
+    (font-lock-mode)
+    (font-lock-ensure)
+    (should (equal (face-at-point) 'font-lock-variable-name-face))
+    (search-forward "24")
+    (should (equal (face-at-point) 'font-lock-string-face))
+    (forward-line)
+    (should (equal (face-at-point) 'font-lock-variable-name-face))))
+
+(ert-deftest conf-test-ppd-mode ()
+  ;; From `conf-ppd-mode' docstring.
+  (with-temp-buffer
+    (insert "*DefaultTransfer: Null
+*Transfer Null.Inverse: \"{ 1 exch sub }\"")
+    (goto-char (point-min))
+    (conf-ppd-mode)
+    (font-lock-mode)
+    (font-lock-ensure)
+    (should (equal (face-at-point) 'font-lock-variable-name-face))
+    (search-forward "Nul")
+    (should-not (face-at-point))))
+
+(ert-deftest conf-test-xdefaults-mode ()
+  ;; From `conf-xdefaults-mode' docstring.
+  (with-temp-buffer
+    (insert "*background:                      gray99
+*foreground:                   black")
+    (goto-char (point-min))
+    (conf-xdefaults-mode)
+    (font-lock-mode)
+    (font-lock-ensure)
+    (should (equal (face-at-point) 'font-lock-variable-name-face))
+    (search-forward "gray")
+    (should-not (face-at-point))))
+
+(ert-deftest conf-test-toml-mode ()
+  ;; From `conf-toml-mode' docstring.
+  (with-temp-buffer
+    (insert "\[entry]
+value = \"some string\"")
+    (goto-char (point-min))
+    (conf-toml-mode)
+    (font-lock-mode)
+    (font-lock-ensure)
+    (should-not (face-at-point))
+    (forward-char)
+    (should (equal (face-at-point) 'font-lock-type-face))
+    (forward-line)
+    (should (equal (face-at-point) 'font-lock-variable-name-face))
+    (search-forward "som")
+    (should (equal (face-at-point) 'font-lock-string-face))))
+
+(ert-deftest conf-test-desktop-mode ()
+  ;; From `conf-desktop-mode' dostring.
+  (with-temp-buffer
+    (insert "  [Desktop Entry]
+       Name=GNU Image Manipulation Program
+       Name[oc]=Editor d'imatge GIMP
+       Exec=gimp-2.8 %U
+       Terminal=false")
+    (goto-char (point-min))
+    (conf-desktop-mode)
+    (font-lock-mode)
+    (font-lock-ensure)
+    (search-forward "Desk")
+    (should (equal (face-at-point) 'font-lock-type-face))
+    (search-forward "Nam")
+    (should (equal (face-at-point) 'font-lock-variable-name-face))
+    (forward-char 2)
+    (should-not (face-at-point))
+    (search-forward "[")
+    (should (equal (face-at-point) 'font-lock-constant-face))))
+
+
+
+(provide 'conf-mode-tests)
+
+;;; conf-mode-tests.el ends here
diff --git a/test/lisp/textmodes/css-mode-tests.el 
b/test/lisp/textmodes/css-mode-tests.el
index bfae1bf..98dac74 100644
--- a/test/lisp/textmodes/css-mode-tests.el
+++ b/test/lisp/textmodes/css-mode-tests.el
@@ -1,6 +1,6 @@
 ;;; css-mode-tests.el --- Test suite for CSS mode  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Simen Heggestøyl <address@hidden>
 ;; Keywords: internal
diff --git a/test/lisp/textmodes/dns-mode-tests.el 
b/test/lisp/textmodes/dns-mode-tests.el
index 565fde3..2e8bb59 100644
--- a/test/lisp/textmodes/dns-mode-tests.el
+++ b/test/lisp/textmodes/dns-mode-tests.el
@@ -1,6 +1,6 @@
 ;;; dns-mode-tests.el --- Test suite for dns-mode  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Peder O. Klingenberg <address@hidden>
 ;; Keywords: dns zone
diff --git a/test/lisp/textmodes/fill-tests.el 
b/test/lisp/textmodes/fill-tests.el
index a2bcde4..0872874 100644
--- a/test/lisp/textmodes/fill-tests.el
+++ b/test/lisp/textmodes/fill-tests.el
@@ -1,6 +1,6 @@
 ;;; fill-test.el --- ERT tests for fill.el -*- lexical-binding: t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author:     Marcin Borkowski <address@hidden>
 ;; Keywords:   text, wp
diff --git a/test/lisp/textmodes/mhtml-mode-tests.el 
b/test/lisp/textmodes/mhtml-mode-tests.el
index b20cda7..d6a184a 100644
--- a/test/lisp/textmodes/mhtml-mode-tests.el
+++ b/test/lisp/textmodes/mhtml-mode-tests.el
@@ -1,6 +1,6 @@
 ;;; mhtml-mode-tests.el --- Tests for mhtml-mode
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Keywords: tests
 
diff --git a/test/lisp/textmodes/reftex-tests.el 
b/test/lisp/textmodes/reftex-tests.el
index 28a0f62..ba6f1e0 100644
--- a/test/lisp/textmodes/reftex-tests.el
+++ b/test/lisp/textmodes/reftex-tests.el
@@ -1,6 +1,6 @@
 ;;; reftex-tests.el --- Test suite for reftex. -*- lexical-binding: t -*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Rüdiger Sonderfeld <address@hidden>
 ;; Keywords:       internal
diff --git a/test/lisp/textmodes/sgml-mode-tests.el 
b/test/lisp/textmodes/sgml-mode-tests.el
index 6c0070c..61ae87e 100644
--- a/test/lisp/textmodes/sgml-mode-tests.el
+++ b/test/lisp/textmodes/sgml-mode-tests.el
@@ -1,6 +1,6 @@
 ;;; sgml-mode-tests.el --- Tests for sgml-mode
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Przemysław Wojnowski <address@hidden>
 ;; Keywords: tests
diff --git a/test/lisp/textmodes/tildify-tests.el 
b/test/lisp/textmodes/tildify-tests.el
index a7368ae..eb23174 100644
--- a/test/lisp/textmodes/tildify-tests.el
+++ b/test/lisp/textmodes/tildify-tests.el
@@ -1,6 +1,6 @@
 ;;; tildify-test.el --- ERT tests for tildify.el -*- lexical-binding: t -*-
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author:     Michal Nazarewicz <address@hidden>
 ;; Version:    4.5
diff --git a/test/lisp/thingatpt-tests.el b/test/lisp/thingatpt-tests.el
index aa29924..347cc7f 100644
--- a/test/lisp/thingatpt-tests.el
+++ b/test/lisp/thingatpt-tests.el
@@ -1,6 +1,6 @@
 ;;; thingatpt.el --- tests for thing-at-point.
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/thread-tests.el b/test/lisp/thread-tests.el
index 0d57d38..3f7beed 100644
--- a/test/lisp/thread-tests.el
+++ b/test/lisp/thread-tests.el
@@ -1,6 +1,6 @@
 ;;; thread-tests.el --- Test suite for thread.el  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; Author: Gemini Lasswell <address@hidden>
 ;; Keywords: threads
diff --git a/test/lisp/url/url-auth-tests.el b/test/lisp/url/url-auth-tests.el
index 1307553..7eaf13f 100644
--- a/test/lisp/url/url-auth-tests.el
+++ b/test/lisp/url/url-auth-tests.el
@@ -1,6 +1,6 @@
 ;;; url-auth-tests.el --- Test suite for url-auth.
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Jarno Malmari <address@hidden>
 
diff --git a/test/lisp/url/url-expand-tests.el 
b/test/lisp/url/url-expand-tests.el
index d58485d..23f1179 100644
--- a/test/lisp/url/url-expand-tests.el
+++ b/test/lisp/url/url-expand-tests.el
@@ -1,6 +1,6 @@
 ;;; url-expand-tests.el --- Test suite for relative URI/URL resolution.
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Alain Schneble <address@hidden>
 ;; Version: 1.0
diff --git a/test/lisp/url/url-file-tests.el b/test/lisp/url/url-file-tests.el
index 969bca7..45af1bb 100644
--- a/test/lisp/url/url-file-tests.el
+++ b/test/lisp/url/url-file-tests.el
@@ -1,6 +1,6 @@
 ;;; url-file-tests.el --- Test suite for url-file. -*- lexical-binding: t -*-
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/url/url-future-tests.el 
b/test/lisp/url/url-future-tests.el
index 0e14a99..17c32fd 100644
--- a/test/lisp/url/url-future-tests.el
+++ b/test/lisp/url/url-future-tests.el
@@ -1,6 +1,6 @@
 ;;; url-future-tests.el --- Test suite for url-future.
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Teodor Zlatanov <address@hidden>
 ;; Keywords: data
diff --git a/test/lisp/url/url-handlers-test.el 
b/test/lisp/url/url-handlers-test.el
index 5822e16..1613f87 100644
--- a/test/lisp/url/url-handlers-test.el
+++ b/test/lisp/url/url-handlers-test.el
@@ -1,6 +1,6 @@
 ;;; url-handlers-test.el --- Test suite for url-handlers.el  -*- 
lexical-binding: t; -*-
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; Author: Nicolas Petton <address@hidden>
 
diff --git a/test/lisp/url/url-misc-tests.el b/test/lisp/url/url-misc-tests.el
index fec2609..7bee22d 100644
--- a/test/lisp/url/url-misc-tests.el
+++ b/test/lisp/url/url-misc-tests.el
@@ -1,6 +1,6 @@
 ;;; url-misc-tests.el --- Test suite for url-misc. -*- lexical-binding: t -*-
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/url/url-parse-tests.el b/test/lisp/url/url-parse-tests.el
index 63923ac..b2b6161 100644
--- a/test/lisp/url/url-parse-tests.el
+++ b/test/lisp/url/url-parse-tests.el
@@ -1,6 +1,6 @@
 ;;; url-parse-tests.el --- Test suite for URI/URL parsing.
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Alain Schneble <address@hidden>
 ;; Version: 1.0
diff --git a/test/lisp/url/url-tramp-tests.el b/test/lisp/url/url-tramp-tests.el
index 4566cd3..bf657a8 100644
--- a/test/lisp/url/url-tramp-tests.el
+++ b/test/lisp/url/url-tramp-tests.el
@@ -1,6 +1,6 @@
 ;;; url-tramp-tests.el --- Test suite for Tramp / URL conversion.
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 
diff --git a/test/lisp/url/url-util-tests.el b/test/lisp/url/url-util-tests.el
index 2e2875a..69117b8 100644
--- a/test/lisp/url/url-util-tests.el
+++ b/test/lisp/url/url-util-tests.el
@@ -1,6 +1,6 @@
 ;;; url-util-tests.el --- Test suite for url-util.
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Teodor Zlatanov <address@hidden>
 ;; Keywords: data
diff --git a/test/lisp/vc/add-log-tests.el b/test/lisp/vc/add-log-tests.el
index cced7e4..21b82ff 100644
--- a/test/lisp/vc/add-log-tests.el
+++ b/test/lisp/vc/add-log-tests.el
@@ -1,6 +1,6 @@
 ;;; add-log-tests.el --- Test suite for add-log.
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Masatake YAMATO <address@hidden>
 ;; Keywords: vc tools
diff --git a/test/lisp/vc/diff-mode-tests.el b/test/lisp/vc/diff-mode-tests.el
index 7900e41..676d461 100644
--- a/test/lisp/vc/diff-mode-tests.el
+++ b/test/lisp/vc/diff-mode-tests.el
@@ -1,4 +1,4 @@
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Dima Kogan <address@hidden>
 ;; Maintainer: address@hidden
@@ -21,7 +21,10 @@
 ;;; Code:
 
 (require 'diff-mode)
+(require 'diff)
 
+(defconst diff-mode-tests--datadir
+  (expand-file-name "test/data/vc/diff-mode" source-directory))
 
 (ert-deftest diff-mode-test-ignore-trailing-dashes ()
   "Check to make sure we successfully ignore trailing -- made by
@@ -199,5 +202,118 @@ youthfulness
           (kill-buffer buf2)
           (delete-directory temp-dir 'recursive))))))
 
+(ert-deftest diff-mode-test-font-lock ()
+  "Check font-locking of diff hunks."
+  (skip-unless (executable-find shell-file-name))
+  (skip-unless (executable-find diff-command))
+  (let ((default-directory diff-mode-tests--datadir)
+        (old "hello_world.c")
+        (new "hello_emacs.c")
+        (diff-buffer (get-buffer-create "*Diff*"))
+        (diff-refine 'font-lock)
+        (diff-font-lock-syntax t)
+        diff-beg)
+    (diff-no-select old new '("-u") 'no-async diff-buffer)
+    (with-current-buffer diff-buffer
+      (font-lock-ensure)
+      (narrow-to-region (progn (diff-hunk-next)
+                               (setq diff-beg (diff-beginning-of-hunk)))
+                        (diff-end-of-hunk))
+
+      (should (equal-including-properties
+               (buffer-string)
+               #("@@ -1,6 +1,6 @@
+ #include <stdio.h>
+ int main()
+ {
+-  printf(\"Hello, World!\\n\");
++  printf(\"Hello, Emacs!\\n\");
+   return 0;
+ }
+"
+                 0 15 (face diff-hunk-header)
+                 16 36 (face diff-context)
+                 36 48 (face diff-context)
+                 48 51 (face diff-context)
+                 51 52 (face diff-indicator-removed)
+                 52 81 (face diff-removed)
+                 81 82 (face diff-indicator-added)
+                 82 111 (face diff-added)
+                 111 124 (face diff-context)
+                 124 127 (face diff-context))))
+
+      (should (equal (mapcar (lambda (o)
+                               (list (- (overlay-start o) diff-beg)
+                                     (- (overlay-end o) diff-beg)
+                                     (append (and (overlay-get o 'diff-mode)
+                                                  `(diff-mode ,(overlay-get o 
'diff-mode)))
+                                             (and (overlay-get o 'face)
+                                                  `(face ,(overlay-get o 
'face))))))
+                             (sort (overlays-in (point-min) (point-max))
+                                   (lambda (a b) (< (overlay-start a) 
(overlay-start b)))))
+                     '((0 127 (diff-mode fine))
+                       (0 127 (diff-mode syntax))
+                       (17 25 (diff-mode syntax face 
font-lock-preprocessor-face))
+                       (26 35 (diff-mode syntax face font-lock-string-face))
+                       (37 40 (diff-mode syntax face font-lock-type-face))
+                       (41 45 (diff-mode syntax face 
font-lock-function-name-face))
+                       (61 78 (diff-mode syntax face font-lock-string-face))
+                       (69 74 (diff-mode fine face diff-refine-removed))
+                       (91 108 (diff-mode syntax face font-lock-string-face))
+                       (99 104 (diff-mode fine face diff-refine-added))
+                       (114 120 (diff-mode syntax face 
font-lock-keyword-face))))))))
+
+(ert-deftest diff-mode-test-font-lock-syntax-one-line ()
+  "Check diff syntax highlighting for one line with no newline at end."
+  (skip-unless (executable-find shell-file-name))
+  (skip-unless (executable-find diff-command))
+  (let ((default-directory diff-mode-tests--datadir)
+        (old "hello_world_1.c")
+        (new "hello_emacs_1.c")
+        (diff-buffer (get-buffer-create "*Diff*"))
+        (diff-refine nil)
+        (diff-font-lock-syntax t)
+        diff-beg)
+    (diff-no-select old new '("-u") 'no-async diff-buffer)
+    (with-current-buffer diff-buffer
+      (font-lock-ensure)
+      (narrow-to-region (progn (diff-hunk-next)
+                               (setq diff-beg (diff-beginning-of-hunk)))
+                        (diff-end-of-hunk))
+
+      (should (equal-including-properties
+               (buffer-string)
+               #("@@ -1 +1 @@
+-int main() { printf(\"Hello, World!\\n\"); return 0; }
+\\ No newline at end of file
++int main() { printf(\"Hello, Emacs!\\n\"); return 0; }
+\\ No newline at end of file
+"
+                 0 11 (face diff-hunk-header)
+                 12 13 (face diff-indicator-removed)
+                 13 65 (face diff-removed)
+                 65 93 (face diff-context)
+                 93 94 (face diff-indicator-added)
+                 94 146 (face diff-added)
+                 146 174 (face diff-context))))
+
+      (should (equal (mapcar (lambda (o)
+                               (list (- (overlay-start o) diff-beg)
+                                     (- (overlay-end o) diff-beg)
+                                     (append (and (overlay-get o 'diff-mode)
+                                                  `(diff-mode ,(overlay-get o 
'diff-mode)))
+                                             (and (overlay-get o 'face)
+                                                  `(face ,(overlay-get o 
'face))))))
+                             (sort (overlays-in (point-min) (point-max))
+                                   (lambda (a b) (< (overlay-start a) 
(overlay-start b)))))
+                     '((0 174 (diff-mode syntax))
+                       (13 16 (diff-mode syntax face font-lock-type-face))
+                       (17 21 (diff-mode syntax face 
font-lock-function-name-face))
+                       (33 50 (diff-mode syntax face font-lock-string-face))
+                       (53 59 (diff-mode syntax face font-lock-keyword-face))
+                       (94 97 (diff-mode syntax face font-lock-type-face))
+                       (98 102 (diff-mode syntax face 
font-lock-function-name-face))
+                       (114 131 (diff-mode syntax face font-lock-string-face))
+                       (134 140 (diff-mode syntax face 
font-lock-keyword-face))))))))
 
 (provide 'diff-mode-tests)
diff --git a/test/lisp/vc/ediff-diff-tests.el b/test/lisp/vc/ediff-diff-tests.el
index bd9f018..b414862 100644
--- a/test/lisp/vc/ediff-diff-tests.el
+++ b/test/lisp/vc/ediff-diff-tests.el
@@ -1,6 +1,6 @@
 ;;; ediff-diff-tests.el --- Unit tests for ediff-diff.el  -*- lexical-binding: 
t; -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Author: Philipp Stephani <address@hidden>
 
diff --git a/test/lisp/vc/ediff-ptch-tests.el b/test/lisp/vc/ediff-ptch-tests.el
index 123fae5..73e1098 100644
--- a/test/lisp/vc/ediff-ptch-tests.el
+++ b/test/lisp/vc/ediff-ptch-tests.el
@@ -1,6 +1,6 @@
 ;;; ediff-ptch-tests.el --- Tests for ediff-ptch.el
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Tino Calancha <address@hidden>
 
diff --git a/test/lisp/vc/smerge-mode-tests.el 
b/test/lisp/vc/smerge-mode-tests.el
index 6004c58..032afa9 100644
--- a/test/lisp/vc/smerge-mode-tests.el
+++ b/test/lisp/vc/smerge-mode-tests.el
@@ -1,4 +1,4 @@
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 
diff --git a/test/lisp/vc/vc-bzr-tests.el b/test/lisp/vc/vc-bzr-tests.el
index 6b96f3b..8fa16cd 100644
--- a/test/lisp/vc/vc-bzr-tests.el
+++ b/test/lisp/vc/vc-bzr-tests.el
@@ -1,6 +1,6 @@
 ;;; vc-bzr.el --- tests for vc/vc-bzr.el
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Glenn Morris <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/test/lisp/vc/vc-hg-tests.el b/test/lisp/vc/vc-hg-tests.el
index a0a0c1e..1bdc320 100644
--- a/test/lisp/vc/vc-hg-tests.el
+++ b/test/lisp/vc/vc-hg-tests.el
@@ -1,6 +1,6 @@
 ;;; vc-hg-tests.el --- tests for vc/vc-hg.el
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Dmitry Gutov <address@hidden>
 ;; Maintainer: address@hidden
diff --git a/test/lisp/vc/vc-tests.el b/test/lisp/vc/vc-tests.el
index cd774d3..0e61d2a 100644
--- a/test/lisp/vc/vc-tests.el
+++ b/test/lisp/vc/vc-tests.el
@@ -1,6 +1,6 @@
 ;;; vc-tests.el --- Tests of different backends of vc.el
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <address@hidden>
 
diff --git a/test/lisp/wdired-tests.el b/test/lisp/wdired-tests.el
index f1ec4af..9682843 100644
--- a/test/lisp/wdired-tests.el
+++ b/test/lisp/wdired-tests.el
@@ -1,6 +1,6 @@
 ;;; wdired-tests.el --- tests for wdired.el          -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -124,6 +124,51 @@ wdired-mode."
            (kill-buffer buf)))
        (delete-directory test-dir t)))))
 
+(ert-deftest wdired-test-bug34915 ()
+  "Test editing when dired-listing-switches includes -F.
+Appended file indicators should not count as part of the file
+name, either before or after editing.  Since
+dired-move-to-end-of-filename handles indicator characters, it
+suffices to compare the return values of dired-get-filename and
+wdired-get-filename before and after editing."
+  ;; FIXME: Add a test for a door (indicator ">") only under Solaris?
+  (let* ((test-dir (make-temp-file "test-dir-" t))
+         (server-socket-dir test-dir)
+         (dired-listing-switches "-Fl")
+         (buf (find-file-noselect test-dir)))
+    (unwind-protect
+        (progn
+         (with-current-buffer buf
+            (dired-create-empty-file "foo")
+            (set-file-modes "foo" (file-modes-symbolic-to-number "+x"))
+            (make-symbolic-link "foo" "bar")
+            (make-directory "foodir")
+            (require 'dired-x)
+            (dired-smart-shell-command "mkfifo foopipe")
+            (server-force-delete)
+            (server-start)              ; Add a socket file.
+            (kill-buffer buf))
+          (dired test-dir)
+          (dired-toggle-read-only)
+          (let (names)
+            ;; Test that the file names are the same in Dired and WDired.
+            (while (not (eobp))
+              (should (equal (dired-get-filename 'no-dir t)
+                             (wdired-get-filename t)))
+              (insert "w")
+              (push (wdired-get-filename t) names)
+              (dired-next-line 1))
+            (wdired-finish-edit)
+            ;; Test that editing the file names ignores the indicator
+            ;; character.
+            (let (dir)
+              (while (and (dired-previous-line 1)
+                          (setq dir (dired-get-filename 'no-dir t)))
+                (should (equal dir (pop names)))))))
+      (kill-buffer (get-buffer test-dir))
+      (server-force-delete)
+      (delete-directory test-dir t))))
+
 
 (provide 'wdired-tests)
 ;;; wdired-tests.el ends here
diff --git a/test/lisp/whitespace-tests.el b/test/lisp/whitespace-tests.el
index b6e1849..3fd5016 100644
--- a/test/lisp/whitespace-tests.el
+++ b/test/lisp/whitespace-tests.el
@@ -1,6 +1,6 @@
 ;;; whitespace-tests.el --- Test suite for whitespace -*- lexical-binding: t 
-*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/lisp/shell-tests.el b/test/lisp/wid-edit-tests.el
similarity index 52%
copy from test/lisp/shell-tests.el
copy to test/lisp/wid-edit-tests.el
index 9550800..a4350e71 100644
--- a/test/lisp/shell-tests.el
+++ b/test/lisp/wid-edit-tests.el
@@ -1,6 +1,6 @@
-;;; shell-tests.el  -*- lexical-binding:t -*-
+;;; wid-edit-tests.el --- tests for wid-edit.el -*- lexical-binding: t -*-
 
-;; Copyright (C) 2010-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -17,25 +17,23 @@
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
 
-;;; Commentary:
-
-;; Tests for comint and related modes.
-
 ;;; Code:
 
-(require 'shell)
 (require 'ert)
+(require 'wid-edit)
 
-(ert-deftest shell-tests-unquote-1 ()
-  "Test problem found by Filipp Gunbin in emacs-devel."
-  (should (equal (car (shell--unquote&requote-argument "te'st" 2)) "test")))
-
-(ert-deftest shell-tests-completion-before-semi ()
+(ert-deftest widget-at ()
+  "Test `widget-at' behavior."
   (with-temp-buffer
-    (shell-mode)
-    (insert "cd ba;")
-    (forward-char -1)
-    (should (equal (shell--parse-pcomplete-arguments)
-                   '(("cd" "ba") 1 4)))))
-
-;;; shell-tests.el ends here
+    (should-not (widget-at))
+    (let ((marco (widget-create 'link "link widget"))
+          (polo  (widget-at (1- (point)))))
+      (should (widgetp polo))
+      (should (eq marco polo)))
+    ;; Buttons and widgets are incompatible (bug#34506).
+    (insert-text-button "text button")
+    (should-not (widget-at (1- (point))))
+    (insert-button "overlay button")
+    (should-not (widget-at (1- (point))))))
+
+;;; wid-edit-tests.el ends here
diff --git a/test/lisp/xdg-tests.el b/test/lisp/xdg-tests.el
index ad5e4a4..9c81506 100644
--- a/test/lisp/xdg-tests.el
+++ b/test/lisp/xdg-tests.el
@@ -1,6 +1,6 @@
 ;;; xdg-tests.el --- tests for xdg.el -*- lexical-binding: t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Author: Mark Oteiza <address@hidden>
diff --git a/test/lisp/xml-tests.el b/test/lisp/xml-tests.el
index 016ba9a..a4c809e 100644
--- a/test/lisp/xml-tests.el
+++ b/test/lisp/xml-tests.el
@@ -1,6 +1,6 @@
 ;;; xml-parse-tests.el --- Test suite for XML parsing.
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Chong Yidong <address@hidden>
 ;; Keywords:       internal
diff --git a/test/lisp/xt-mouse-tests.el b/test/lisp/xt-mouse-tests.el
index 0b644d2..6053f9f 100644
--- a/test/lisp/xt-mouse-tests.el
+++ b/test/lisp/xt-mouse-tests.el
@@ -1,6 +1,6 @@
 ;;; xt-mouse-tests.el --- Test suite for xt-mouse.  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Philipp Stephani <address@hidden>
 
diff --git a/test/manual/BidiCharacterTest.txt 
b/test/manual/BidiCharacterTest.txt
index 6a0df6d..064594b 100644
--- a/test/manual/BidiCharacterTest.txt
+++ b/test/manual/BidiCharacterTest.txt
@@ -1,5 +1,5 @@
-# BidiCharacterTest-11.0.0.txt
-# Date: 2018-02-18, 05:50:00 GMT [LI]
+# BidiCharacterTest-12.0.0.txt
+# Date: 2018-11-02, 16:34:00 GMT [LI]
 # © 2018 Unicode®, Inc.
 # For terms of use, see http://www.unicode.org/terms_of_use.html
 #
diff --git a/test/manual/biditest.el b/test/manual/biditest.el
index fd2dd4a..d813642 100644
--- a/test/manual/biditest.el
+++ b/test/manual/biditest.el
@@ -1,6 +1,6 @@
 ;;; biditest.el --- test bidi reordering in GNU Emacs display engine.
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Eli Zaretskii
 ;; Maintainer: address@hidden
diff --git a/test/manual/cedet/cedet-utests.el 
b/test/manual/cedet/cedet-utests.el
index 1044195..23362db 100644
--- a/test/manual/cedet/cedet-utests.el
+++ b/test/manual/cedet/cedet-utests.el
@@ -1,6 +1,6 @@
 ;;; cedet-utests.el --- Run all unit tests in the CEDET suite.
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/manual/cedet/ede-tests.el b/test/manual/cedet/ede-tests.el
index c4f70da..0b5864d 100644
--- a/test/manual/cedet/ede-tests.el
+++ b/test/manual/cedet/ede-tests.el
@@ -1,6 +1,6 @@
 ;;; ede-tests.el --- Some tests for the Emacs Development Environment
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/manual/cedet/semantic-ia-utest.el 
b/test/manual/cedet/semantic-ia-utest.el
index 938d152..665a538 100644
--- a/test/manual/cedet/semantic-ia-utest.el
+++ b/test/manual/cedet/semantic-ia-utest.el
@@ -1,6 +1,6 @@
 ;;; semantic-ia-utest.el --- Analyzer unit tests
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/manual/cedet/semantic-tests.el 
b/test/manual/cedet/semantic-tests.el
index d4be930..9109d66 100644
--- a/test/manual/cedet/semantic-tests.el
+++ b/test/manual/cedet/semantic-tests.el
@@ -1,6 +1,6 @@
 ;;; semantic-utest.el --- Miscellaneous Semantic tests.
 
-;;; Copyright (C) 2003-2004, 2007-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2003-2004, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/manual/cedet/semantic-utest-c.el 
b/test/manual/cedet/semantic-utest-c.el
index cbfe92f..a24bf10 100644
--- a/test/manual/cedet/semantic-utest-c.el
+++ b/test/manual/cedet/semantic-utest-c.el
@@ -1,6 +1,6 @@
 ;;; semantic-utest-c.el --- C based parsing tests.
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/manual/cedet/semantic-utest.el 
b/test/manual/cedet/semantic-utest.el
index df22174..102c128 100644
--- a/test/manual/cedet/semantic-utest.el
+++ b/test/manual/cedet/semantic-utest.el
@@ -1,6 +1,6 @@
 ;;; semantic-utest.el --- Tests for semantic's parsing system.
 
-;;; Copyright (C) 2003-2004, 2007-2018 Free Software Foundation, Inc.
+;;; Copyright (C) 2003-2004, 2007-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/manual/cedet/srecode-tests.el 
b/test/manual/cedet/srecode-tests.el
index 6f02b7d..5d5a970 100644
--- a/test/manual/cedet/srecode-tests.el
+++ b/test/manual/cedet/srecode-tests.el
@@ -1,6 +1,6 @@
 ;;; srecode-tests.el --- Some tests for CEDET's srecode
 
-;; Copyright (C) 2008-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/manual/cedet/tests/test.c b/test/manual/cedet/tests/test.c
index 0437463..7d6411e 100644
--- a/test/manual/cedet/tests/test.c
+++ b/test/manual/cedet/tests/test.c
@@ -1,6 +1,6 @@
 /* test.c --- Semantic unit test for C.
 
-   Copyright (C) 2001-2018 Free Software Foundation, Inc.
+   Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
    Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/manual/cedet/tests/test.el b/test/manual/cedet/tests/test.el
index b7341ca..664e6cb 100644
--- a/test/manual/cedet/tests/test.el
+++ b/test/manual/cedet/tests/test.el
@@ -1,6 +1,6 @@
 ;;; test.el --- Unit test file for Semantic Emacs Lisp support.
 
-;; Copyright (C) 2005-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005-2019 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/manual/cedet/tests/test.make 
b/test/manual/cedet/tests/test.make
index 3e1309f..60a4070 100644
--- a/test/manual/cedet/tests/test.make
+++ b/test/manual/cedet/tests/test.make
@@ -1,6 +1,6 @@
 # test.make --- Semantic unit test for Make -*- makefile -*-
 
-# Copyright (C) 2001-2002, 2010-2018 Free Software Foundation, Inc.
+# Copyright (C) 2001-2002, 2010-2019 Free Software Foundation, Inc.
 
 # Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/manual/cedet/tests/testdoublens.cpp 
b/test/manual/cedet/tests/testdoublens.cpp
index 946b3ea..62efad4 100644
--- a/test/manual/cedet/tests/testdoublens.cpp
+++ b/test/manual/cedet/tests/testdoublens.cpp
@@ -1,6 +1,6 @@
 // testdoublens.cpp --- semantic-ia-utest completion engine unit tests
 
-// Copyright (C) 2008-2018 Free Software Foundation, Inc.
+// Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 // Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/manual/cedet/tests/testdoublens.hpp 
b/test/manual/cedet/tests/testdoublens.hpp
index fe73d76..54f2acf 100644
--- a/test/manual/cedet/tests/testdoublens.hpp
+++ b/test/manual/cedet/tests/testdoublens.hpp
@@ -1,6 +1,6 @@
 // testdoublens.hpp --- Header file used in one of the Semantic tests
 
-// Copyright (C) 2008-2018 Free Software Foundation, Inc.
+// Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 // Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/manual/cedet/tests/testjavacomp.java 
b/test/manual/cedet/tests/testjavacomp.java
index 8d51999..1ebd7dc 100644
--- a/test/manual/cedet/tests/testjavacomp.java
+++ b/test/manual/cedet/tests/testjavacomp.java
@@ -1,6 +1,6 @@
 //  testjavacomp.java --- Semantic unit test for Java
 
-// Copyright (C) 2009-2018 Free Software Foundation, Inc.
+// Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 //  Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/manual/cedet/tests/testpolymorph.cpp 
b/test/manual/cedet/tests/testpolymorph.cpp
index 4639c10..cf605f6 100644
--- a/test/manual/cedet/tests/testpolymorph.cpp
+++ b/test/manual/cedet/tests/testpolymorph.cpp
@@ -1,6 +1,6 @@
 /** testpolymorph.cpp --- A sequence of polymorphism examples.
  *
- * Copyright (C) 2009-2018 Free Software Foundation, Inc.
+ * Copyright (C) 2009-2019 Free Software Foundation, Inc.
  *
  * Author: Eric M. Ludlam <address@hidden>
  *
diff --git a/test/manual/cedet/tests/testspp.c 
b/test/manual/cedet/tests/testspp.c
index dc52c83..beead02 100644
--- a/test/manual/cedet/tests/testspp.c
+++ b/test/manual/cedet/tests/testspp.c
@@ -1,6 +1,6 @@
 /* testspp.cpp --- Semantic unit test for the C preprocessor
 
-   Copyright (C) 2007-2018 Free Software Foundation, Inc.
+   Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
    Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/manual/cedet/tests/testsppreplace.c 
b/test/manual/cedet/tests/testsppreplace.c
index fdbba65..a76d420 100644
--- a/test/manual/cedet/tests/testsppreplace.c
+++ b/test/manual/cedet/tests/testsppreplace.c
@@ -1,5 +1,5 @@
 /* testsppreplace.c --- unit test for CPP/SPP Replacement
-   Copyright (C) 2007-2018 Free Software Foundation, Inc.
+   Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
    Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/manual/cedet/tests/testsppreplaced.c 
b/test/manual/cedet/tests/testsppreplaced.c
index eeedad8..ab13b3a 100644
--- a/test/manual/cedet/tests/testsppreplaced.c
+++ b/test/manual/cedet/tests/testsppreplaced.c
@@ -1,5 +1,5 @@
 /* testsppreplaced.c --- unit test for CPP/SPP Replacement
-   Copyright (C) 2007-2018 Free Software Foundation, Inc.
+   Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
    Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/manual/cedet/tests/testsubclass.cpp 
b/test/manual/cedet/tests/testsubclass.cpp
index c65f79a..ece497b 100644
--- a/test/manual/cedet/tests/testsubclass.cpp
+++ b/test/manual/cedet/tests/testsubclass.cpp
@@ -1,6 +1,6 @@
 // testsubclass.cpp --- unit test for analyzer and complex C++ inheritance
 
-// Copyright (C) 2007-2018 Free Software Foundation, Inc.
+// Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 // Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/manual/cedet/tests/testsubclass.hh 
b/test/manual/cedet/tests/testsubclass.hh
index 919b9c2..1963e15 100644
--- a/test/manual/cedet/tests/testsubclass.hh
+++ b/test/manual/cedet/tests/testsubclass.hh
@@ -1,6 +1,6 @@
 // testsubclass.hh --- unit test for analyzer and complex C++ inheritance
 
-// Copyright (C) 2007-2018 Free Software Foundation, Inc.
+// Copyright (C) 2007-2019 Free Software Foundation, Inc.
 
 // Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/manual/cedet/tests/testtypedefs.cpp 
b/test/manual/cedet/tests/testtypedefs.cpp
index 3969573..f8a3f2e 100644
--- a/test/manual/cedet/tests/testtypedefs.cpp
+++ b/test/manual/cedet/tests/testtypedefs.cpp
@@ -1,6 +1,6 @@
 // testtypedefs.cpp --- Sample with some fake bits out of std::string
 
-// Copyright (C) 2008-2018 Free Software Foundation, Inc.
+// Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
 // Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/manual/cedet/tests/testvarnames.c 
b/test/manual/cedet/tests/testvarnames.c
index 65a891c..7776072 100644
--- a/test/manual/cedet/tests/testvarnames.c
+++ b/test/manual/cedet/tests/testvarnames.c
@@ -1,7 +1,7 @@
 /* testvarnames.cpp
    Test variable and function names, lists of variables on one line, etc.
 
-   Copyright (C) 2008-2018 Free Software Foundation, Inc.
+   Copyright (C) 2008-2019 Free Software Foundation, Inc.
 
    Author: Eric M. Ludlam <address@hidden>
 
diff --git a/test/manual/etags/c-src/abbrev.c b/test/manual/etags/c-src/abbrev.c
index f9c591d..aa3a994 100644
--- a/test/manual/etags/c-src/abbrev.c
+++ b/test/manual/etags/c-src/abbrev.c
@@ -1,5 +1,5 @@
 /* Primitives for word-abbrev mode.
-   Copyright (C) 1985-1986, 1993, 1996, 1998, 2016-2018 Free Software
+   Copyright (C) 1985-1986, 1993, 1996, 1998, 2016-2019 Free Software
    Foundation, Inc.
 
 This file is part of GNU Emacs.
diff --git a/test/manual/etags/c-src/emacs/src/gmalloc.c 
b/test/manual/etags/c-src/emacs/src/gmalloc.c
index 2d494cc..6a5d04b 100644
--- a/test/manual/etags/c-src/emacs/src/gmalloc.c
+++ b/test/manual/etags/c-src/emacs/src/gmalloc.c
@@ -1,5 +1,5 @@
 /* Declarations for `malloc' and friends.
-   Copyright (C) 1990-1993, 1995-1996, 1999, 2002-2007, 2013-2018 Free
+   Copyright (C) 1990-1993, 1995-1996, 1999, 2002-2007, 2013-2019 Free
    Software Foundation, Inc.
                  Written May 1989 by Mike Haertel.
 
diff --git a/test/manual/etags/c-src/emacs/src/keyboard.c 
b/test/manual/etags/c-src/emacs/src/keyboard.c
index cf1dbfd..0151316 100644
--- a/test/manual/etags/c-src/emacs/src/keyboard.c
+++ b/test/manual/etags/c-src/emacs/src/keyboard.c
@@ -1,6 +1,6 @@
 /* Keyboard and mouse input; editor command loop.
 
-Copyright (C) 1985-1989, 1993-1997, 1999-2018 Free Software Foundation,
+Copyright (C) 1985-1989, 1993-1997, 1999-2019 Free Software Foundation,
 Inc.
 
 This file is part of GNU Emacs.
diff --git a/test/manual/etags/c-src/emacs/src/lisp.h 
b/test/manual/etags/c-src/emacs/src/lisp.h
index fd47758..9d7805d 100644
--- a/test/manual/etags/c-src/emacs/src/lisp.h
+++ b/test/manual/etags/c-src/emacs/src/lisp.h
@@ -1,6 +1,6 @@
 /* Fundamental definitions for GNU Emacs Lisp interpreter.
 
-Copyright (C) 1985-1987, 1993-1995, 1997-2018 Free Software Foundation,
+Copyright (C) 1985-1987, 1993-1995, 1997-2019 Free Software Foundation,
 Inc.
 
 This file is part of GNU Emacs.
diff --git a/test/manual/etags/c-src/emacs/src/regex.h 
b/test/manual/etags/c-src/emacs/src/regex.h
index bc4ca39..94fdbba 100644
--- a/test/manual/etags/c-src/emacs/src/regex.h
+++ b/test/manual/etags/c-src/emacs/src/regex.h
@@ -1,7 +1,7 @@
 /* Definitions for data structures and routines for the regular
    expression library, version 0.12.
 
-   Copyright (C) 1985, 1989-1993, 1995, 2000-2018 Free Software
+   Copyright (C) 1985, 1989-1993, 1995, 2000-2019 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/test/manual/etags/c-src/etags.c b/test/manual/etags/c-src/etags.c
index 7f67ce7..3a87ef2 100644
--- a/test/manual/etags/c-src/etags.c
+++ b/test/manual/etags/c-src/etags.c
@@ -28,7 +28,7 @@ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
SOFTWARE, EVEN
 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
-Copyright (C) 1984, 1987-1989, 1993-1995, 1998-2018 Free Software
+Copyright (C) 1984, 1987-1989, 1993-1995, 1998-2019 Free Software
 Foundation, Inc.
 
 This file is not considered part of GNU Emacs.
diff --git a/test/manual/etags/c-src/exit.c b/test/manual/etags/c-src/exit.c
index a1dbf20..4ba7039 100644
--- a/test/manual/etags/c-src/exit.c
+++ b/test/manual/etags/c-src/exit.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 2016-2018 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 2016-2019 Free Software Foundation, Inc.
 This file is part of the GNU C Library.
 
 The GNU C Library is free software; you can redistribute it and/or
diff --git a/test/manual/etags/c-src/exit.strange_suffix 
b/test/manual/etags/c-src/exit.strange_suffix
index a1dbf20..4ba7039 100644
--- a/test/manual/etags/c-src/exit.strange_suffix
+++ b/test/manual/etags/c-src/exit.strange_suffix
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 2016-2018 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 2016-2019 Free Software Foundation, Inc.
 This file is part of the GNU C Library.
 
 The GNU C Library is free software; you can redistribute it and/or
diff --git a/test/manual/etags/c-src/getopt.h b/test/manual/etags/c-src/getopt.h
index 58243cc..171ab59 100644
--- a/test/manual/etags/c-src/getopt.h
+++ b/test/manual/etags/c-src/getopt.h
@@ -1,5 +1,5 @@
 /* Declarations for getopt.
-   Copyright (C) 1989-1992, 2016-2018 Free Software Foundation, Inc.
+   Copyright (C) 1989-1992, 2016-2019 Free Software Foundation, Inc.
 
    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
diff --git a/test/manual/etags/c-src/sysdep.h b/test/manual/etags/c-src/sysdep.h
index b0684e4..a962a75 100644
--- a/test/manual/etags/c-src/sysdep.h
+++ b/test/manual/etags/c-src/sysdep.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-1993, 2016-2018 Free Software Foundation, Inc.
+/* Copyright (C) 1992-1993, 2016-2019 Free Software Foundation, Inc.
 This file is part of the GNU C Library.
 
 The GNU C Library is free software; you can redistribute it and/or
diff --git a/test/manual/etags/el-src/emacs/lisp/progmodes/etags.el 
b/test/manual/etags/el-src/emacs/lisp/progmodes/etags.el
index 667b235..250aeb1 100644
--- a/test/manual/etags/el-src/emacs/lisp/progmodes/etags.el
+++ b/test/manual/etags/el-src/emacs/lisp/progmodes/etags.el
@@ -1,6 +1,6 @@
 ;;; etags.el --- etags facility for Emacs  -*- lexical-binding: t -*-
 
-;; Copyright (C) 1985-1986, 1988-1989, 1992-1996, 1998, 2000-2018 Free
+;; Copyright (C) 1985-1986, 1988-1989, 1992-1996, 1998, 2000-2019 Free
 ;; Software Foundation, Inc.
 
 ;; Author: Roland McGrath <address@hidden>
diff --git a/test/manual/etags/tex-src/texinfo.tex 
b/test/manual/etags/tex-src/texinfo.tex
index ee94104..a2c05af 100644
--- a/test/manual/etags/tex-src/texinfo.tex
+++ b/test/manual/etags/tex-src/texinfo.tex
@@ -1,6 +1,6 @@
 %% TeX macros to handle texinfo files
 
-%   Copyright (C) 1985-1986, 1988, 1990-1991, 2016-2018 Free Software
+%   Copyright (C) 1985-1986, 1988, 1990-1991, 2016-2019 Free Software
 %   Foundation, Inc.
 
 %This texinfo.tex file is free software; you can redistribute it and/or
diff --git a/test/manual/etags/y-src/cccp.c b/test/manual/etags/y-src/cccp.c
index 221f91e..1af4385 100644
--- a/test/manual/etags/y-src/cccp.c
+++ b/test/manual/etags/y-src/cccp.c
@@ -320,7 +320,7 @@ static const short yycheck[] =
 #line 3 "/usr/share/bison/bison.simple"
 
 /* Skeleton output parser for bison,
-   Copyright (C) 1984, 1989-1990, 2000-2001, 2016-2018 Free Software
+   Copyright (C) 1984, 1989-1990, 2000-2001, 2016-2019 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/test/manual/etags/y-src/parse.c b/test/manual/etags/y-src/parse.c
index 1fcf7a6..6f5c6d9 100644
--- a/test/manual/etags/y-src/parse.c
+++ b/test/manual/etags/y-src/parse.c
@@ -28,7 +28,7 @@
 
 #line 1 "y-src/parse.y"
 
-/*     Copyright (C) 1990, 1992-1993, 2016-2018 Free Software Foundation,
+/*     Copyright (C) 1990, 1992-1993, 2016-2019 Free Software Foundation,
  *     Inc.
 
 This file is part of Oleo, the GNU Spreadsheet.
diff --git a/test/manual/etags/y-src/parse.y b/test/manual/etags/y-src/parse.y
index 475cea0..a6ed7c0 100644
--- a/test/manual/etags/y-src/parse.y
+++ b/test/manual/etags/y-src/parse.y
@@ -1,5 +1,5 @@
 %{
-/*     Copyright (C) 1990, 1992-1993, 2016-2018 Free Software Foundation,
+/*     Copyright (C) 1990, 1992-1993, 2016-2019 Free Software Foundation,
  *     Inc.
 
 This file is part of Oleo, the GNU Spreadsheet.
diff --git a/test/manual/image-size-tests.el b/test/manual/image-size-tests.el
index 70e86da..29f6abf 100644
--- a/test/manual/image-size-tests.el
+++ b/test/manual/image-size-tests.el
@@ -1,6 +1,6 @@
 ;;; image-size-tests.el -- tests for image scaling
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/manual/indent/js-jsx.js b/test/manual/indent/js-jsx.js
deleted file mode 100644
index 7401939..0000000
--- a/test/manual/indent/js-jsx.js
+++ /dev/null
@@ -1,85 +0,0 @@
-// -*- mode: js-jsx; -*-
-
-var foo = <div></div>;
-
-return (
-  <div>
-  </div>
-  <div>
-    <div></div>
-    <div>
-      <div></div>
-    </div>
-  </div>
-);
-
-React.render(
-  <div>
-    <div></div>
-  </div>,
-  {
-    a: 1
-  },
-  <div>
-    <div></div>
-  </div>
-);
-
-return (
-  // Sneaky!
-  <div></div>
-);
-
-return (
-  <div></div>
-  // Sneaky!
-);
-
-React.render(
-  <input
-    />,
-  {
-    a: 1
-  }
-);
-
-return (
-  <div>
-    {array.map(function () {
-      return {
-        a: 1
-      };
-    })}
-  </div>
-);
-
-return (
-  <div attribute={array.map(function () {
-         return {
-           a: 1
-         };
-
-         return {
-           a: 1
-         };
-
-         return {
-           a: 1
-         };
-       })}>
-  </div>
-);
-
-// Local Variables:
-// indent-tabs-mode: nil
-// js-indent-level: 2
-// End:
-
-// The following test has intentionally unclosed elements and should
-// be placed below all other tests to prevent awkward indentation.
-
-return (
-  <div>
-    {array.map(function () {
-      return {
-        a: 1
diff --git a/test/manual/indent/js.js b/test/manual/indent/js.js
index b0d8bca..9658c95 100644
--- a/test/manual/indent/js.js
+++ b/test/manual/indent/js.js
@@ -144,6 +144,27 @@ bar(
   /abc/
 )
 
+// No infloop inside js--re-search-backward-inner
+let b = {
+  a : `
+  //1
+  `
+}
+
+// bug#25904
+foo.bar.baz(very => // A comment
+  very
+).biz(([baz={a: [123]}, boz]) =>
+  baz
+).snarf((snorf) => /* Another comment */
+  snorf
+);
+
+// Continuation of bug#25904; support broken arrow as N+1th arg
+map(arr, (val) =>
+  val
+)
+
 // Local Variables:
 // indent-tabs-mode: nil
 // js-indent-level: 2
diff --git a/test/manual/indent/jsx-align-gt-with-lt.jsx 
b/test/manual/indent/jsx-align-gt-with-lt.jsx
new file mode 100644
index 0000000..8eb1d6d
--- /dev/null
+++ b/test/manual/indent/jsx-align-gt-with-lt.jsx
@@ -0,0 +1,12 @@
+<element
+  attr=""
+  >
+</element>
+<input
+  />
+
+// Local Variables:
+// indent-tabs-mode: nil
+// js-indent-level: 2
+// js-jsx-align->-with-<: nil
+// End:
diff --git a/test/manual/indent/jsx-indent-level.jsx 
b/test/manual/indent/jsx-indent-level.jsx
new file mode 100644
index 0000000..0a84b9e
--- /dev/null
+++ b/test/manual/indent/jsx-indent-level.jsx
@@ -0,0 +1,13 @@
+return (
+    <element>
+      <element>
+        Hello World!
+      </element>
+    </element>
+)
+
+// Local Variables:
+// indent-tabs-mode: nil
+// js-indent-level: 4
+// js-jsx-indent-level: 2
+// End:
diff --git a/test/manual/indent/jsx-quote.jsx b/test/manual/indent/jsx-quote.jsx
new file mode 100644
index 0000000..1b2c652
--- /dev/null
+++ b/test/manual/indent/jsx-quote.jsx
@@ -0,0 +1,16 @@
+// JSX text node values should be strings, but only JS string syntax
+// is considered, so quote marks delimit strings like normal, with
+// disastrous results (https://github.com/mooz/js2-mode/issues/409).
+function Bug() {
+  return <div>C'est Montréal</div>;
+}
+function Test(foo = /'/,
+              bar = 123) {}
+
+// This test is in a separate file because it can break other tests
+// when indenting the whole buffer (not sure why).
+
+// Local Variables:
+// indent-tabs-mode: nil
+// js-indent-level: 2
+// End:
diff --git a/test/manual/indent/jsx-self-closing.jsx 
b/test/manual/indent/jsx-self-closing.jsx
new file mode 100644
index 0000000..f8ea7a1
--- /dev/null
+++ b/test/manual/indent/jsx-self-closing.jsx
@@ -0,0 +1,13 @@
+// Local Variables:
+// indent-tabs-mode: nil
+// js-indent-level: 2
+// End:
+
+// The following test goes below any comments to avoid including
+// misindented comments among the erroring lines.
+
+// Properly parse/indent code with a self-closing tag inside the
+// attribute of another self-closing tag.
+<div>
+  <div attr={() => <div attr="" />} />
+</div>
diff --git a/test/manual/indent/jsx-unclosed-1.jsx 
b/test/manual/indent/jsx-unclosed-1.jsx
new file mode 100644
index 0000000..1f5c3fb
--- /dev/null
+++ b/test/manual/indent/jsx-unclosed-1.jsx
@@ -0,0 +1,13 @@
+// Local Variables:
+// indent-tabs-mode: nil
+// js-indent-level: 2
+// End:
+
+// The following test goes below any comments to avoid including
+// misindented comments among the erroring lines.
+
+return (
+  <div>
+    {array.map(function () {
+      return {
+        a: 1
diff --git a/test/manual/indent/jsx-unclosed-2.jsx 
b/test/manual/indent/jsx-unclosed-2.jsx
new file mode 100644
index 0000000..fb665b9
--- /dev/null
+++ b/test/manual/indent/jsx-unclosed-2.jsx
@@ -0,0 +1,65 @@
+// Local Variables:
+// indent-tabs-mode: nil
+// js-indent-level: 2
+// End:
+
+// The following tests go below any comments to avoid including
+// misindented comments among the erroring lines.
+
+// Don’t misinterpret inequality operators as JSX.
+for (; i < length;) void 0
+if (foo > bar) void 0
+
+// Don’t misintrepet inequalities within JSX, either.
+<div>
+  {foo < bar}
+</div>
+
+// Don’t even misinterpret unary operators as JSX.
+if (foo < await bar) void 0
+while (await foo > bar) void 0
+
+<div>
+  {foo < await bar}
+</div>
+
+// Allow unary keyword names as null-valued JSX attributes.
+// (As if this will EVER happen…)
+<Foo yield>
+  <Bar void>
+    <Baz
+      zorp
+      typeof>
+      <Please do_n0t delete this_stupidTest >
+        How would we ever live without unary support
+      </Please>
+    </Baz>
+  </Bar>
+</Foo>
+
+// “-” is not allowed in a JSXBoundaryElement’s name.
+<ABC />
+  <A-B-C /> // Weirdly-indented “continued expression.”
+
+// “-” may be used in a JSXAttribute’s name.
+<Foo a-b-c=""
+     x-y-z="" />
+
+// Weird spaces should be tolerated.
+< div >
+  < div >
+    < div
+      attr=""
+      / >
+    < div
+      attr=""
+      / >
+  < / div>
+< / div >
+
+// Non-ASCII identifiers are acceptable.
+<Über>
+  <Québec διακριτικός sueño="">
+    Guten Tag!
+  </Québec>
+</Über>
diff --git a/test/manual/indent/jsx.jsx b/test/manual/indent/jsx.jsx
new file mode 100644
index 0000000..c200979
--- /dev/null
+++ b/test/manual/indent/jsx.jsx
@@ -0,0 +1,314 @@
+var foo = <div></div>;
+
+return (
+  <div>
+  </div>
+  <div>
+    <div></div>
+    <div>
+      <div></div>
+    </div>
+  </div>
+);
+
+React.render(
+  <div>
+    <div></div>
+  </div>,
+  {
+    a: 1
+  },
+  <div>
+    <div></div>
+  </div>
+);
+
+return (
+  // Sneaky!
+  <div></div>
+);
+
+return (
+  <div></div>
+  // Sneaky!
+);
+
+React.render(
+  <input
+  />,
+  {
+    a: 1
+  }
+);
+
+return (
+  <div>
+    {array.map(function () {
+      return {
+        a: 1
+      };
+    })}
+  </div>
+);
+
+return (
+  <div attribute={array.map(function () {
+         return {
+           a: 1
+         };
+
+         return {
+           a: 1
+         };
+
+         return {
+           a: 1
+         };
+       })}>
+  </div>
+);
+
+return (
+  <div attribute={{
+         a: 1, // Indent relative to “attribute” column.
+         b: 2
+       } && {  // Dedent to “attribute” column.
+         a: 1,
+         b: 2
+       }} />   // Also dedent.
+);
+
+return (
+  <div attribute=
+       {   // Indent properly on another line, too.
+         {
+           a: 1,
+           b: 2,
+         } && (
+           // Indent other forms, too.
+           a ? b :
+             c ? d :
+             e
+         )
+       } />
+)
+
+// JSXMemberExpression names are parsed/indented:
+<Foo.Bar>
+  <div>
+    <Foo.Bar>
+      Hello World!
+    </Foo.Bar>
+    <Foo.Bar>
+      <div>
+      </div>
+    </Foo.Bar>
+  </div>
+</Foo.Bar>
+
+// JSXOpeningFragment and JSXClosingFragment are parsed/indented:
+<>
+  <div>
+    <>
+      Hello World!
+    </>
+    <>
+      <div>
+      </div>
+    </>
+  </div>
+</>
+
+// Indent void expressions (no need for contextual parens / commas)
+// (https://github.com/mooz/js2-mode/issues/140#issuecomment-166250016).
+<div className="class-name">
+  <h2>Title</h2>
+  {array.map(() => {
+    return <Element />;
+  })}
+  {message}
+</div>
+// Another example of above issue
+// (https://github.com/mooz/js2-mode/issues/490).
+<App>
+  <div>
+    {variable1}
+    <Component/>
+  </div>
+</App>
+
+// Comments and arrows can break indentation (Bug#24896 /
+// https://github.com/mooz/js2-mode/issues/389).
+const Component = props => (
+  <FatArrow a={e => c}
+            b={123}>
+  </FatArrow>
+);
+const Component = props => (
+  <NoFatArrow a={123}
+              b={123}>
+  </NoFatArrow>
+);
+const Component = props => ( // Parse this comment, please.
+  <FatArrow a={e => c}
+            b={123}>
+  </FatArrow>
+);
+const Component = props => ( // Parse this comment, please.
+  <NoFatArrow a={123}
+              b={123}>
+  </NoFatArrow>
+);
+// Another example of above issue (Bug#30225).
+class {
+  render() {
+    return (
+      <select style={{paddingRight: "10px"}}
+              onChange={e => this.setState({value: e.target.value})}
+              value={this.state.value}>
+        <option>Hi</option>
+      </select>
+    );
+  }
+}
+
+// JSX attributes of an arrow function’s expression body’s JSX
+// expression should be indented with respect to the JSX opening
+// element (Bug#26001 /
+// https://github.com/mooz/js2-mode/issues/389#issuecomment-271869380).
+class {
+  render() {
+    const messages = this.state.messages.map(
+      message => <Message key={message.id}
+                          text={message.text}
+                          mine={message.mine} />
+    );    return messages;
+  }
+  render() {
+    const messages = this.state.messages.map(message =>
+      <Message key={message.timestamp}
+               text={message.text}
+               mine={message.mine} />
+    );    return messages;
+  }
+}
+
+// Users expect tag closers to align with the tag’s start; this is the
+// style used in the React docs, so it should be the default.
+// - https://github.com/mooz/js2-mode/issues/389#issuecomment-390766873
+// - https://github.com/mooz/js2-mode/issues/482
+// - Bug#32158
+const foo = (props) => (
+  <div>
+    <input
+      cat={i => i}
+    />
+    <button
+      className="square"
+    >
+      {this.state.value}
+    </button>
+  </div>
+);
+
+// Embedded JSX in parens breaks indentation
+// (https://github.com/mooz/js2-mode/issues/411).
+let a = (
+  <div>
+    {condition && <Component/>}
+    {condition && <Component/>}
+    <div/>
+  </div>
+)
+let b = (
+  <div>
+    {condition && (<Component/>)}
+    <div/>
+  </div>
+)
+let c = (
+  <div>
+    {condition && (<Component/>)}
+    {condition && "something"}
+  </div>
+)
+let d = (
+  <div>
+    {(<Component/>)}
+    {condition && "something"}
+  </div>
+)
+// Another example of the above issue (Bug#27000).
+function testA() {
+  return (
+    <div>
+      <div> { ( <div/> ) } </div>
+    </div>
+  );
+}
+function testB() {
+  return (
+    <div>
+      <div> { <div/> } </div>
+    </div>
+  );
+}
+// Another example of the above issue
+// (https://github.com/mooz/js2-mode/issues/451).
+class Classy extends React.Component {
+  render () {
+    return (
+      <div>
+        <ul className="tocListRoot">
+          { this.state.list.map((item) => {
+            return (<div />)
+          })}
+        </ul>
+      </div>
+    )
+  }
+}
+
+// Self-closing tags should be indented properly
+// (https://github.com/mooz/js2-mode/issues/459).
+export default ({ stars }) => (
+  <div className='overlay__container'>
+    <div className='overlay__header overlay--text'>
+      Congratulations!
+    </div>
+    <div className='overlay__reward'>
+      <Icon {...createIconProps(stars > 0)} size='large' />
+      <div className='overlay__reward__bottom'>
+        <Icon {...createIconProps(stars > 1)} size='small' />
+        <Icon {...createIconProps(stars > 2)} size='small' />
+      </div>
+    </div>
+    <div className='overlay__description overlay--text'>
+      You have created <large>1</large> reminder
+    </div>
+  </div>
+)
+
+// JS expressions should not break indentation
+// (https://github.com/mooz/js2-mode/issues/462).
+//
+// In the referenced issue, the user actually wanted indentation which
+// was simply different than Emacs’ SGML attribute indentation.
+// Nevertheless, his issue highlighted our inability to properly
+// indent code with JSX inside JSXExpressionContainers inside JSX.
+return (
+  <Router>
+    <Bar>
+      <Route exact path="/foo"
+             render={() => (
+               <div>nothing</div>
+             )} />
+      <Route exact path="/bar" />
+    </Bar>
+  </Router>
+)
+
+// Local Variables:
+// indent-tabs-mode: nil
+// js-indent-level: 2
+// End:
diff --git a/test/manual/indent/pascal.pas b/test/manual/indent/pascal.pas
index 485293b..1b360bc 100644
--- a/test/manual/indent/pascal.pas
+++ b/test/manual/indent/pascal.pas
@@ -1,6 +1,6 @@
 { GPC demo program for the CRT unit.
 
-Copyright (C) 1999-2006, 2013-2018 Free Software Foundation, Inc.
+Copyright (C) 1999-2006, 2013-2019 Free Software Foundation, Inc.
 
 Author: Frank Heckenbach <address@hidden>
 
diff --git a/test/manual/redisplay-testsuite.el 
b/test/manual/redisplay-testsuite.el
index 822a7f0..153b357 100644
--- a/test/manual/redisplay-testsuite.el
+++ b/test/manual/redisplay-testsuite.el
@@ -1,6 +1,6 @@
 ;;; redisplay-testsuite.el --- Test suite for redisplay.
 
-;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2019 Free Software Foundation, Inc.
 
 ;; Author: Chong Yidong <address@hidden>
 ;; Keywords:       internal
diff --git a/test/manual/rmailmm.el b/test/manual/rmailmm.el
index a524787..eb09c8c 100644
--- a/test/manual/rmailmm.el
+++ b/test/manual/rmailmm.el
@@ -1,6 +1,6 @@
 ;;; rmailmm.el --- tests for mail/rmailmm.el
 
-;; Copyright (C) 2006-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/manual/scroll-tests.el b/test/manual/scroll-tests.el
index 0e93c54..e053b3f 100644
--- a/test/manual/scroll-tests.el
+++ b/test/manual/scroll-tests.el
@@ -1,6 +1,6 @@
 ;;; scroll-tests.el -- tests for scrolling -*- lexical-binding: t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/src/alloc-tests.el b/test/src/alloc-tests.el
index 21166af..32acc51 100644
--- a/test/src/alloc-tests.el
+++ b/test/src/alloc-tests.el
@@ -1,6 +1,6 @@
 ;;; alloc-tests.el --- alloc tests -*- lexical-binding: t -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Daniel Colascione <address@hidden>
 ;; Keywords:
diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el
index 609585f..845d41f 100644
--- a/test/src/buffer-tests.el
+++ b/test/src/buffer-tests.el
@@ -1,6 +1,6 @@
 ;;; buffer-tests.el --- tests for buffer.c functions -*- lexical-binding: t -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/src/callint-tests.el b/test/src/callint-tests.el
index feee9b6..5c310b5 100644
--- a/test/src/callint-tests.el
+++ b/test/src/callint-tests.el
@@ -1,6 +1,6 @@
 ;;; callint-tests.el --- unit tests for callint.c    -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
 
 ;; Author: Philipp Stephani <address@hidden>
 
diff --git a/test/src/callproc-tests.el b/test/src/callproc-tests.el
index 481116e..1cad836 100644
--- a/test/src/callproc-tests.el
+++ b/test/src/callproc-tests.el
@@ -1,6 +1,6 @@
 ;;; callproc-tests.el --- callproc.c tests -*- lexical-binding: t -*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -37,3 +37,26 @@
         (split-string-and-unquote (buffer-string)))
     (should (equal initial-shell "nil"))
     (should-not (equal initial-shell shell))))
+
+(ert-deftest call-process-w32-debug-spawn-error ()
+  "Check that debugger runs on `call-process' failure (Bug#33016)."
+  (skip-unless (eq system-type 'windows-nt))
+  (let* ((debug-on-error t)
+         (have-called-debugger nil)
+         (debugger (lambda (&rest _)
+                     (setq have-called-debugger t)
+                     ;; Allow entering the debugger later in the same
+                     ;; test run, before going back to the command
+                     ;; loop.
+                     (setq internal-when-entered-debugger -1))))
+    (should (eq :got-error ;; NOTE: `should-error' would inhibit debugger.
+                (condition-case-unless-debug ()
+                    ;; On MS-Windows, "nul.FOO" resolves to the null
+                    ;; device, and thus acts like an always-empty
+                    ;; file, for any FOO, in any directory.  So
+                    ;; c:/null.exe passes Emacs' test for the file's
+                    ;; existence, and ensures we hit an error in the
+                    ;; w32 process spawn code.
+                    (call-process "c:/nul.exe")
+                  (error :got-error))))
+    (should have-called-debugger)))
diff --git a/test/src/casefiddle-tests.el b/test/src/casefiddle-tests.el
index 5d8798c..ed9a2f9 100644
--- a/test/src/casefiddle-tests.el
+++ b/test/src/casefiddle-tests.el
@@ -1,6 +1,6 @@
 ;;; casefiddle-tests.el --- tests for casefiddle.c functions -*- 
lexical-binding: t -*-
 
-;; Copyright (C) 2015-2016, 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2016, 2018-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/src/charset-tests.el b/test/src/charset-tests.el
index c1eec69..3bf6739 100644
--- a/test/src/charset-tests.el
+++ b/test/src/charset-tests.el
@@ -1,6 +1,6 @@
 ;;; charset-tests.el --- Tests for charset.c
 
-;; Copyright 2017-2018 Free Software Foundation, Inc.
+;; Copyright 2017-2019 Free Software Foundation, Inc.
 
 ;; 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
diff --git a/test/src/chartab-tests.el b/test/src/chartab-tests.el
index bda9701..11dd1cb 100644
--- a/test/src/chartab-tests.el
+++ b/test/src/chartab-tests.el
@@ -1,6 +1,6 @@
 ;;; chartab-tests.el --- Tests for char-tab.c
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Eli Zaretskii <address@hidden>
 
diff --git a/test/src/cmds-tests.el b/test/src/cmds-tests.el
index caf444c..bab8b5f 100644
--- a/test/src/cmds-tests.el
+++ b/test/src/cmds-tests.el
@@ -1,6 +1,6 @@
 ;;; cmds-tests.el --- Testing some Emacs commands
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Nicolas Richard <address@hidden>
 ;; Keywords:
@@ -30,5 +30,13 @@
   (let ((last-command-event ?a))
     (should-error (self-insert-command -1))))
 
+(ert-deftest forward-line-with-bignum ()
+  (with-temp-buffer
+    (insert "x\n")
+    (let ((shortage (forward-line (1- most-negative-fixnum))))
+      (should (= shortage most-negative-fixnum)))
+    (let ((shortage (forward-line (+ 2 most-positive-fixnum))))
+      (should (= shortage (1+ most-positive-fixnum))))))
+
 (provide 'cmds-tests)
 ;;; cmds-tests.el ends here
diff --git a/test/src/coding-tests.el b/test/src/coding-tests.el
index a3ca715..1a08c1e 100644
--- a/test/src/coding-tests.el
+++ b/test/src/coding-tests.el
@@ -1,6 +1,6 @@
 ;;; coding-tests.el --- tests for text encoding and decoding
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Eli Zaretskii <address@hidden>
 ;; Author: Kenichi Handa <address@hidden>
diff --git a/test/src/data-tests.el b/test/src/data-tests.el
index d41c762..a9d48e2 100644
--- a/test/src/data-tests.el
+++ b/test/src/data-tests.el
@@ -1,6 +1,6 @@
 ;;; data-tests.el --- tests for src/data.c  -*- lexical-binding:t -*-
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -656,6 +656,10 @@ comparing the subr with a much slower lisp implementation."
 (ert-deftest data-tests-ash-lsh ()
   (should (= (ash most-negative-fixnum 1)
              (* most-negative-fixnum 2)))
+  (should (= (ash 0 (* 2 most-positive-fixnum)) 0))
+  (should (= (ash 1000 (* 2 most-negative-fixnum)) 0))
+  (should (= (ash -1000 (* 2 most-negative-fixnum)) -1))
+  (should (= (ash (* 2 most-negative-fixnum) (* 2 most-negative-fixnum)) -1))
   (should (= (lsh most-negative-fixnum 1)
              (* most-negative-fixnum 2)))
   (should (= (ash (* 2 most-negative-fixnum) -1)
@@ -665,4 +669,22 @@ comparing the subr with a much slower lisp implementation."
   (should (= (lsh -1 -1) most-positive-fixnum))
   (should-error (lsh (1- most-negative-fixnum) -1)))
 
+(ert-deftest data-tests-make-local-forwarded-var () ;bug#34318
+  ;; Boy, this bug is tricky to trigger.  You need to:
+  ;; - call make-local-variable on a forwarded var (i.e. one that
+  ;;   has a corresponding C var linked via DEFVAR_(LISP|INT|BOOL))
+  ;; - cause the C code to modify this variable from the C side of the
+  ;;   forwarding, but this needs to happen before the var is accessed
+  ;;   from the Lisp side and before we switch to another buffer.
+  ;; The trigger in bug#34318 doesn't exist any more because the C code has
+  ;; changes.  Instead I found the trigger below.
+  (with-temp-buffer
+    (setq last-coding-system-used 'bug34318)
+    (make-local-variable 'last-coding-system-used)
+    ;; This should set last-coding-system-used to `no-conversion'.
+    (decode-coding-string "hello" nil)
+    (should (equal (list last-coding-system-used
+                         (default-value 'last-coding-system-used))
+                   '(no-conversion bug34318)))))
+
 ;;; data-tests.el ends here
diff --git a/test/src/decompress-tests.el b/test/src/decompress-tests.el
index 647dbeb..50d947b 100644
--- a/test/src/decompress-tests.el
+++ b/test/src/decompress-tests.el
@@ -1,6 +1,6 @@
 ;;; decompress-tests.el --- Test suite for decompress.
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; Author: Lars Ingebrigtsen <address@hidden>
 
diff --git a/test/src/doc-tests.el b/test/src/doc-tests.el
index 7c07504..9bcb240 100644
--- a/test/src/doc-tests.el
+++ b/test/src/doc-tests.el
@@ -1,6 +1,6 @@
 ;;; doc-tests.el --- Tests for doc.c
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Eli Zaretskii <address@hidden>
 
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el
index 66375a6..1e8b706 100644
--- a/test/src/editfns-tests.el
+++ b/test/src/editfns-tests.el
@@ -1,6 +1,6 @@
 ;;; editfns-tests.el -- tests for editfns.c
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -184,12 +184,11 @@
               'integer))
   (should (eq (type-of (read (format "#32rG%x" most-positive-fixnum)))
               'integer))
-  (let ((binary-as-unsigned nil))
-    (dolist (fmt '("%d" "%s" "#o%o" "#x%x"))
-      (dolist (val (list most-negative-fixnum (1+ most-negative-fixnum)
-                         -1 0 1
-                         (1- most-positive-fixnum) most-positive-fixnum))
-        (should (eq val (read (format fmt val))))))))
+  (dolist (fmt '("%d" "%s" "#o%o" "#x%x"))
+    (dolist (val (list most-negative-fixnum (1+ most-negative-fixnum)
+                      -1 0 1
+                      (1- most-positive-fixnum) most-positive-fixnum))
+      (should (eq val (read (format fmt val)))))))
 
 (ert-deftest format-%o-invalid-float ()
   (should-error (format "%o" -1e-37)
@@ -352,6 +351,9 @@
                    "-0x000000003ffffffffffffffe000000000000000        "))))
 
 (ert-deftest test-group-name ()
+  ;; FIXME: Actually my GID in one of my systems has no associated entry
+  ;; in /etc/group so there's no name for it and `group-name' correctly
+  ;; returns nil!
   (should (stringp (group-name (group-gid))))
   (should-error (group-name 'foo))
   (cond
@@ -373,4 +375,13 @@
               ((eq stat 2)
                (should-not name)))))))))
 
+(ert-deftest test-translate-region-internal ()
+  (with-temp-buffer
+    (let ((max-char #16r3FFFFF)
+          (tt (make-char-table 'translation-table)))
+      (aset tt max-char ?*)
+      (insert max-char)
+      (translate-region-internal (point-min) (point-max) tt)
+      (should (string-equal (buffer-string) "*")))))
+
 ;;; editfns-tests.el ends here
diff --git a/test/src/emacs-module-tests.el b/test/src/emacs-module-tests.el
index c67190b..173b636 100644
--- a/test/src/emacs-module-tests.el
+++ b/test/src/emacs-module-tests.el
@@ -1,6 +1,6 @@
 ;;; Test GNU Emacs modules.
 
-;; Copyright 2015-2018 Free Software Foundation, Inc.
+;; Copyright 2015-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -265,7 +265,8 @@ during garbage collection."
   (skip-unless (file-executable-p mod-test-emacs))
   (module--test-assertion
       (rx "Module function called during garbage collection\n")
-    (mod-test-invalid-finalizer)))
+    (mod-test-invalid-finalizer)
+    (garbage-collect)))
 
 (ert-deftest module/describe-function-1 ()
   "Check that Bug#30163 is fixed."
@@ -289,4 +290,82 @@ Return A + B"
     (should (member '(provide . mod-test) entries))
     (should (member '(defun . mod-test-sum) entries))))
 
+(ert-deftest mod-test-sleep-until ()
+  "Check that `mod-test-sleep-until' either returns normally or quits.
+Interactively, you can try hitting \\[keyboard-quit] to quit."
+  (dolist (arg '(nil t))
+    ;; Guard against some caller setting `inhibit-quit'.
+    (with-local-quit
+      (condition-case nil
+          (should (eq (with-local-quit
+                        ;; Because `inhibit-quit' is nil here, the next
+                        ;; form either quits or returns `finished'.
+                        (mod-test-sleep-until
+                         ;; Interactively, run for 5 seconds to give the
+                         ;; user time to quit.  In batch mode, run only
+                         ;; briefly since the user can't quit.
+                         (float-time (time-add nil (if noninteractive 0.1 5)))
+                         ;; should_quit or process_input
+                         arg))
+                      'finished))
+        (quit)))))
+
+(ert-deftest mod-test-add-nanosecond/valid ()
+  (dolist (input (list
+                  ;; Some realistic examples.
+                  (current-time) (time-to-seconds)
+                  (encode-time 12 34 5 6 7 2019 t)
+                  ;; Various legacy timestamp forms.
+                  '(123 456) '(123 456 789) '(123 456 789 6000)
+                  ;; Corner case: this will result in a nanosecond
+                  ;; value of 1000000000 after addition.  The module
+                  ;; code should handle this correctly.
+                  '(123 65535 999999 999000)
+                  ;; Seconds since the epoch.
+                  123 123.45
+                  ;; New (TICKS . HZ) format.
+                  '(123456789 . 1000000000)))
+    (ert-info ((format "input: %s" input))
+      (let ((result (mod-test-add-nanosecond input)))
+        (should (consp result))
+        (should (integerp (car result)))
+        (should (integerp (cdr result)))
+        (should (cl-plusp (cdr result)))
+        (should (time-equal-p result (time-add input '(0 0 0 1000))))))))
+
+(ert-deftest mod-test-add-nanosecond/nil ()
+  (should (<= (float-time (mod-test-add-nanosecond nil))
+              (+ (float-time) 1e-9))))
+
+(ert-deftest mod-test-add-nanosecond/invalid ()
+  (dolist (input '(1.0e+INF 1.0e-INF 0.0e+NaN (123) (123.45 6 7) "foo" [1 2]))
+    (ert-info ((format "input: %s" input))
+      (should-error (mod-test-add-nanosecond input)))))
+
+(ert-deftest mod-test-nanoseconds ()
+  "Test truncation when converting to `struct timespec'."
+  (dolist (test-case '((0 . 0)
+                       (-1 . -1000000000)
+                       ((1 . 1000000000) . 1)
+                       ((-1 . 1000000000) . -1)
+                       ((1 . 1000000000000) . 0)
+                       ((-1 . 1000000000000) . -1)
+                       ((999 . 1000000000000) . 0)
+                       ((-999 . 1000000000000) . -1)
+                       ((1000 . 1000000000000) . 1)
+                       ((-1000 . 1000000000000) . -1)
+                       ((0 0 0 1) . 0)
+                       ((0 0 0 -1) . -1)))
+    (let ((input (car test-case))
+          (expected (cdr test-case)))
+      (ert-info ((format "input: %S, expected result: %d" input expected))
+        (should (eq (mod-test-nanoseconds input) expected))))))
+
+(ert-deftest mod-test-double ()
+  (dolist (input (list 0 1 2 -1 42 12345678901234567890
+                       most-positive-fixnum (1+ most-positive-fixnum)
+                       most-negative-fixnum (1- most-negative-fixnum)))
+    (ert-info ((format "input: %d" input))
+      (should (= (mod-test-double input) (* 2 input))))))
+
 ;;; emacs-module-tests.el ends here
diff --git a/test/src/eval-tests.el b/test/src/eval-tests.el
index 0c24291..48295b8 100644
--- a/test/src/eval-tests.el
+++ b/test/src/eval-tests.el
@@ -1,6 +1,6 @@
 ;;; eval-tests.el --- unit tests for src/eval.c      -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Philipp Stephani <address@hidden>
 
diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el
index b7b78bb..6262d94 100644
--- a/test/src/fileio-tests.el
+++ b/test/src/fileio-tests.el
@@ -1,6 +1,6 @@
 ;;; unit tests for src/fileio.c      -*- lexical-binding: t; -*-
 
-;; Copyright 2017-2018 Free Software Foundation, Inc.
+;; Copyright 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -102,4 +102,8 @@ Also check that an encoding error can appear in a symlink."
     (setenv "HOME" "a/b/c")
     (should (equal (expand-file-name "~/foo")
                    (expand-file-name "a/b/c/foo")))
+    (when (memq system-type '(ms-dos windows-nt))
+      ;; Test expansion of drive-relative file names.
+      (setenv "HOME" "x:foo")
+      (should (equal (expand-file-name "~/bar") "x:/foo/bar")))
     (setenv "HOME" old-home)))
diff --git a/test/src/floatfns-tests.el b/test/src/floatfns-tests.el
index 61b1c25..643866f 100644
--- a/test/src/floatfns-tests.el
+++ b/test/src/floatfns-tests.el
@@ -1,6 +1,6 @@
 ;;; floatfns-tests.el --- tests for floating point operations
 
-;; Copyright 2017-2018 Free Software Foundation, Inc.
+;; Copyright 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el
index b180f30..6ebab42 100644
--- a/test/src/fns-tests.el
+++ b/test/src/fns-tests.el
@@ -1,6 +1,6 @@
 ;;; fns-tests.el --- tests for src/fns.c
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -161,7 +161,10 @@
             '(9 . "ppp") '(8 . "ttt") '(8 . "eee") '(9 . "fff"))
            (lambda (x y) (< (car x) (car y))))
           [(8 . "xxx") (8 . "bbb") (8 . "ttt") (8 . "eee")
-           (9 . "aaa") (9 . "zzz") (9 . "ppp") (9 . "fff")])))
+           (9 . "aaa") (9 . "zzz") (9 . "ppp") (9 . "fff")]))
+  ;; Bug#34104
+  (should (equal (should-error (sort "cba" #'<) :type 'wrong-type-argument)
+                 '(wrong-type-argument list-or-vector-p "cba"))))
 
 (ert-deftest fns-tests-collate-sort ()
   (skip-unless (fns-tests--collate-enabled-p))
@@ -645,4 +648,22 @@
           (should (equal (list (eq a b) n len)
                          (list t n len))))))))
 
+(ert-deftest test-proper-list-p ()
+  "Test `proper-list-p' behavior."
+  (dotimes (length 4)
+    ;; Proper and dotted lists.
+    (let ((list (make-list length 0)))
+      (should (= (proper-list-p list) length))
+      (should (not (proper-list-p (nconc list 0)))))
+    ;; Circular lists.
+    (dotimes (n (1+ length))
+      (let ((circle (make-list (1+ length) 0)))
+        (should (not (proper-list-p (nconc circle (nthcdr n circle))))))))
+  ;; Atoms.
+  (should (not (proper-list-p 0)))
+  (should (not (proper-list-p "")))
+  (should (not (proper-list-p [])))
+  (should (not (proper-list-p (make-bool-vector 0 nil))))
+  (should (not (proper-list-p (make-symbol "a")))))
+
 (provide 'fns-tests)
diff --git a/test/src/font-tests.el b/test/src/font-tests.el
index 70b32c8..971d79d 100644
--- a/test/src/font-tests.el
+++ b/test/src/font-tests.el
@@ -1,6 +1,6 @@
 ;;; font-tests.el --- Test suite for font-related functions.
 
-;; Copyright (C) 2011-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
 
 ;; Author: Chong Yidong <address@hidden>
 ;; Keywords:       internal
diff --git a/test/src/inotify-tests.el b/test/src/inotify-tests.el
index b46014e..06d6d65 100644
--- a/test/src/inotify-tests.el
+++ b/test/src/inotify-tests.el
@@ -1,6 +1,6 @@
 ;;; inotify-tests.el --- Test suite for inotify. -*- lexical-binding: t -*-
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Rüdiger Sonderfeld <address@hidden>
 ;; Keywords:       internal
diff --git a/test/src/json-tests.el b/test/src/json-tests.el
index 651b0a0..7d824b5 100644
--- a/test/src/json-tests.el
+++ b/test/src/json-tests.el
@@ -1,6 +1,6 @@
 ;;; json-tests.el --- unit tests for json.c          -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -117,6 +117,14 @@
     (should (equal (json-parse-string input :object-type 'plist)
                    '(:abc [9 :false] :def :null)))))
 
+(ert-deftest json-parse-string/array ()
+  (skip-unless (fboundp 'json-parse-string))
+  (let ((input "[\"a\", 1, [\"b\", 2]]"))
+    (should (equal (json-parse-string input)
+                   ["a" 1 ["b" 2]]))
+    (should (equal (json-parse-string input :array-type 'list)
+                   '("a" 1 ("b" 2))))))
+
 (ert-deftest json-parse-string/string ()
   (skip-unless (fboundp 'json-parse-string))
   (should-error (json-parse-string "[\"formfeed\f\"]") :type 'json-parse-error)
@@ -151,7 +159,7 @@
   (skip-unless (fboundp 'json-parse-string))
   (should-error (json-parse-string "\x00") :type 'wrong-type-argument)
   ;; FIXME: Reconsider whether this is the right behavior.
-  (should-error (json-parse-string "[a\\u0000b]") :type 'json-parse-error))
+  (should-error (json-parse-string "[\"a\\u0000b\"]") :type 'json-parse-error))
 
 (ert-deftest json-parse-string/invalid-unicode ()
   "Some examples from
diff --git a/test/src/keyboard-tests.el b/test/src/keyboard-tests.el
index 125dbd0..3e7d131 100644
--- a/test/src/keyboard-tests.el
+++ b/test/src/keyboard-tests.el
@@ -1,6 +1,6 @@
 ;;; keyboard-tests.el --- Tests for keyboard.c -*- lexical-binding: t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/src/keymap-tests.el b/test/src/keymap-tests.el
index 56ff436..d61f304 100644
--- a/test/src/keymap-tests.el
+++ b/test/src/keymap-tests.el
@@ -1,6 +1,6 @@
 ;;; keymap-tests.el --- Test suite for src/keymap.c
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Juanma Barranquero <address@hidden>
 
diff --git a/test/src/lcms-tests.el b/test/src/lcms-tests.el
index 28afd5a..f1d1110 100644
--- a/test/src/lcms-tests.el
+++ b/test/src/lcms-tests.el
@@ -1,6 +1,6 @@
 ;;; lcms-tests.el --- tests for Little CMS interface -*- lexical-binding: t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el
index f19d983..82b75b1 100644
--- a/test/src/lread-tests.el
+++ b/test/src/lread-tests.el
@@ -1,6 +1,6 @@
 ;;; lread-tests.el --- tests for lread.c -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; Author: Philipp Stephani <address@hidden>
 
@@ -140,7 +140,9 @@ literals (Bug#20852)."
     (should (equal (lread-tests--last-message)
                    (concat (format-message "Loading `%s': " file-name)
                            "unescaped character literals "
-                           "`?\"', `?(', `?)', `?;', `?[', `?]' detected!")))))
+                           "`?\"', `?(', `?)', `?;', `?[', `?]' detected, "
+                           "`?\\\"', `?\\(', `?\\)', `?\\;', `?\\[', `?\\]' "
+                           "expected!")))))
 
 (ert-deftest lread-tests--funny-quote-symbols ()
   "Check that 'smart quotes' or similar trigger errors in symbol names."
diff --git a/test/src/marker-tests.el b/test/src/marker-tests.el
index 859323e..79e298d 100644
--- a/test/src/marker-tests.el
+++ b/test/src/marker-tests.el
@@ -1,6 +1,6 @@
 ;;; marker-tests.el --- tests for marker.c functions -*- lexical-binding: t -*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/src/minibuf-tests.el b/test/src/minibuf-tests.el
index 5ee7e5c..12b018b 100644
--- a/test/src/minibuf-tests.el
+++ b/test/src/minibuf-tests.el
@@ -1,6 +1,6 @@
 ;;; minibuf-tests.el --- tests for minibuf.c functions -*- lexical-binding: t 
-*-
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/src/print-tests.el b/test/src/print-tests.el
index 78e769f..8e377d7 100644
--- a/test/src/print-tests.el
+++ b/test/src/print-tests.el
@@ -1,6 +1,6 @@
 ;;; print-tests.el --- tests for src/print.c         -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/src/process-tests.el b/test/src/process-tests.el
index 551b34f..b853f77 100644
--- a/test/src/process-tests.el
+++ b/test/src/process-tests.el
@@ -1,6 +1,6 @@
 ;;; process-tests.el --- Testing the process facilities
 
-;; Copyright (C) 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
 
 ;; 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
@@ -207,13 +207,91 @@
                     :sentinel #'ignore
                     :noquery t
                     :connection-type 'pipe)))
-      (while (process-live-p process)
-        (accept-process-output process))
+      (while (or (accept-process-output process)
+                (process-live-p process)))
       (should (eq (process-status process) 'exit))
       (should (eq (process-exit-status process) 0))
       (should (process-tests--mixable (string-to-list (buffer-string))
                                       (string-to-list "stdout\n")
                                       (string-to-list "stderr\n"))))))
 
+(ert-deftest make-process-w32-debug-spawn-error ()
+  "Check that debugger runs on `make-process' failure (Bug#33016)."
+  (skip-unless (eq system-type 'windows-nt))
+  (let* ((debug-on-error t)
+         (have-called-debugger nil)
+         (debugger (lambda (&rest _)
+                     (setq have-called-debugger t)
+                     ;; Allow entering the debugger later in the same
+                     ;; test run, before going back to the command
+                     ;; loop.
+                     (setq internal-when-entered-debugger -1))))
+    (should (eq :got-error ;; NOTE: `should-error' would inhibit debugger.
+                (condition-case-unless-debug ()
+                    ;; Emacs doesn't search for absolute filenames, so
+                    ;; the error will be hit in the w32 process spawn
+                    ;; code.
+                    (make-process :name "test" :command 
'("c:/No-Such-Command"))
+                  (error :got-error))))
+    (should have-called-debugger)))
+
+(ert-deftest make-process/file-handler/found ()
+  "Check that the ‘:file-handler’ argument of ‘make-process’
+works as expected if a file name handler is found."
+  (let ((file-handler-calls 0))
+    (cl-flet ((file-handler
+               (&rest args)
+               (should (equal default-directory "test-handler:/dir/"))
+               (should (equal args '(make-process :name "name"
+                                                  :command ("/some/binary")
+                                                  :file-handler t)))
+               (cl-incf file-handler-calls)
+               'fake-process))
+      (let ((file-name-handler-alist (list (cons (rx bos "test-handler:")
+                                                 #'file-handler)))
+            (default-directory "test-handler:/dir/"))
+        (should (eq (make-process :name "name"
+                                  :command '("/some/binary")
+                                  :file-handler t)
+                    'fake-process))
+        (should (= file-handler-calls 1))))))
+
+(ert-deftest make-process/file-handler/not-found ()
+  "Check that the ‘:file-handler’ argument of ‘make-process’
+works as expected if no file name handler is found."
+  (let ((file-name-handler-alist ())
+        (default-directory invocation-directory)
+        (program (expand-file-name invocation-name invocation-directory)))
+    (should (processp (make-process :name "name"
+                                    :command (list program "--version")
+                                    :file-handler t)))))
+
+(ert-deftest make-process/file-handler/disable ()
+  "Check ‘make-process’ works as expected if it shouldn’t use the
+file name handler."
+  (let ((file-name-handler-alist (list (cons (rx bos "test-handler:")
+                                             #'process-tests--file-handler)))
+        (default-directory "test-handler:/dir/")
+        (program (expand-file-name invocation-name invocation-directory)))
+    (should (processp (make-process :name "name"
+                                    :command (list program "--version"))))))
+
+(defun process-tests--file-handler (operation &rest _args)
+  (cl-ecase operation
+    (unhandled-file-name-directory "/")
+    (make-process (ert-fail "file name handler called unexpectedly"))))
+
+(put #'process-tests--file-handler 'operations
+     '(unhandled-file-name-directory make-process))
+
+(ert-deftest make-process/stop ()
+  "Check that `make-process' doesn't accept a `:stop' key.
+See Bug#30460."
+  (should-error
+   (make-process :name "test"
+                 :command (list (expand-file-name invocation-name
+                                                  invocation-directory))
+                 :stop t)))
+
 (provide 'process-tests)
 ;; process-tests.el ends here.
diff --git a/test/src/regex-emacs-tests.el b/test/src/regex-emacs-tests.el
index 7a07590..0ae50c9 100644
--- a/test/src/regex-emacs-tests.el
+++ b/test/src/regex-emacs-tests.el
@@ -1,6 +1,6 @@
 ;;; regex-emacs-tests.el --- tests for regex-emacs.c -*- lexical-binding: t -*-
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -278,7 +278,7 @@ on success"
 
 
 (defconst regex-tests-re-even-escapes
-  "\\(?:^\\|[^\\\\]\\)\\(?:\\\\\\\\\\)*"
+  "\\(?:^\\|[^\\]\\)\\(?:\\\\\\\\\\)*"
   "Regex that matches an even number of \\ characters")
 
 (defconst regex-tests-re-odd-escapes
@@ -555,11 +555,11 @@ differences in behavior.")
 
 (defconst regex-tests-PTESTS-whitelist
   [
-   ;; emacs doesn't barf on weird ranges such as [b-a], but simply
-   ;; fails to match
+   ;; emacs doesn't see DEL (0x7f) as a [:cntrl:] character
    138
 
-   ;; emacs doesn't see DEL (0x78) as a [:cntrl:] character
+   ;; emacs doesn't barf on weird ranges such as [b-a], but simply
+   ;; fails to match
    168
   ]
   "Line numbers in the PTESTS test that should be skipped.  These
diff --git a/test/src/syntax-tests.el b/test/src/syntax-tests.el
index 4057d75..3c3245f 100644
--- a/test/src/syntax-tests.el
+++ b/test/src/syntax-tests.el
@@ -1,6 +1,6 @@
 ;;; syntax-tests.el --- tests for syntax.c functions -*- lexical-binding: t -*-
 
-;; Copyright (C) 2017-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/src/textprop-tests.el b/test/src/textprop-tests.el
index 11cb9e1..db7256f 100644
--- a/test/src/textprop-tests.el
+++ b/test/src/textprop-tests.el
@@ -1,6 +1,6 @@
 ;;; textprop-tests.el --- Test suite for text properties.
 
-;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
 
 ;; Author: Wolfgang Jenkner <address@hidden>
 ;; Keywords: internal
diff --git a/test/src/thread-tests.el b/test/src/thread-tests.el
index 36bb637..5e5bfd1 100644
--- a/test/src/thread-tests.el
+++ b/test/src/thread-tests.el
@@ -1,6 +1,6 @@
 ;;; threads.el --- tests for threads.
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/src/timefns-tests.el b/test/src/timefns-tests.el
index ebeb43d..5c858ef 100644
--- a/test/src/timefns-tests.el
+++ b/test/src/timefns-tests.el
@@ -1,6 +1,6 @@
 ;;; timefns-tests.el -- tests for timefns.c
 
-;; Copyright (C) 2016-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
diff --git a/test/src/undo-tests.el b/test/src/undo-tests.el
index dab3619..b84f5a5 100644
--- a/test/src/undo-tests.el
+++ b/test/src/undo-tests.el
@@ -1,6 +1,6 @@
 ;;; undo-tests.el --- Tests of primitive-undo
 
-;; Copyright (C) 2012-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
 
 ;; Author: Aaron S. Hawley <address@hidden>
 
diff --git a/test/src/xml-tests.el b/test/src/xml-tests.el
index c1d65b9..aa7a71e 100644
--- a/test/src/xml-tests.el
+++ b/test/src/xml-tests.el
@@ -1,6 +1,6 @@
 ;;; libxml-parse-tests.el --- Test suite for libxml parsing.
 
-;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
 ;; Author: Ulf Jasper <address@hidden>
 ;; Keywords:       internal



reply via email to

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